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

repo-ai-cli

v0.8.0

Published

AI repo CLI: bilingual README, CHANGELOG, commit/review/test/PR via your own LLM key; offline secrets scan, stats & deps audit

Readme

repo-ai-cli

AI-powered repository helper CLI: 28 commands to generate bilingual READMEs, onboarding guides, conventional commits, CHANGELOGs, code reviews, tests, docs and PRs — plus offline repository intelligence (map, change impact, health audit) and utilities for secrets, stats, deps audit, gitignore, LICENSE, badges and git hooks.

AI 驱动的仓库助手 CLI:28 条命令覆盖仓库全流程 —— 生成双语 README、上手导读、规范 commit、CHANGELOG、代码审查、单元测试、文档翻译、PR 描述、代码库问答,以及仓库地图、变更影响分析、健康审计等离线仓库智能,和密钥扫描、仓库统计、依赖审计、.gitignore / LICENSE / 徽章 / 贡献指南生成、git 钩子等工具。

CI npm version npm downloads License: MIT Node.js

⚡ 本 README 由 repo-ai-cli 自己生成(dogfooding)—— 下面就是它的真实输出效果。


三分钟上手 — Three-Minute Quickstart

无需安装:一条 npx 命令 + 一个环境变量即可跑通(需 Node.js ≥ 20)。

# 1. 设置一家提供商的 API Key(示例用 DeepSeek;其他提供商见下方 Quick Start)
export DEEPSEEK_API_KEY=sk-xxx        # macOS / Linux
# $env:DEEPSEEK_API_KEY="sk-xxx"      # Windows PowerShell

# 2. 进入任意 git 仓库目录,npx 自动下载并运行(不写入全局)
npx repo-ai-cli readme

不想覆盖现有 README:先 npx repo-ai-cli readme --dry-run 只看统计、不调用 API,或用 -o README.gen.md 输出到别的文件。

有了 Key 之后,两条高频用法:

# 审查线上 GitHub PR(不需要安装 gh CLI)
npx repo-ai-cli review-pr owner/repo#123

# 根据暂存改动生成规范 commit message
npx repo-ai-cli commit --print

完全离线、零配置也能立刻试的命令:

npx repo-ai-cli doctor    # 环境体检
npx repo-ai-cli secrets   # 离线扫描硬编码密钥
npx repo-ai-cli stats     # 行数 / 语言 / 提交统计

准备长期使用时再 npm install -g repo-ai-cli;完整安装、Key 配置与全部 28 条命令见下方 Quick Start — 快速开始。


✨ Features — 功能特性

  • 📝 AI-Generated Bilingual README — Turn any local directory or GitHub repository into a polished, bilingual (English/Chinese) README with a single command. AI 生成中英双语 README — 通过一条命令,将任意本地目录或 GitHub 仓库转化为精美的中英双语 README。

  • 🔖 Conventional Commit Messages — Automatically generate clear, conventional commit messages from your git diff, following best practices. 规范 commit message — 根据你的 git diff 自动生成清晰、符合 Conventional Commits 规范的提交信息。

  • 📜 AI-Generated CHANGELOG — Turn your git history into a Keep-a-Changelog-style CHANGELOG.md, automatically scoped since the last release tag. AI 生成 CHANGELOG — 将你的 git 提交历史整理为 Keep a Changelog 风格的 CHANGELOG.md,自动以最近一个发布 tag 为区间起点。

  • ⚙️ Persistent Config — Save your provider, API key and defaults once with repo-ai-cli config set, no more env vars every time. 配置持久化 — 用 repo-ai-cli config set 一次保存提供商、API key 与默认参数,无需每次设置环境变量。

  • 🔍 AI Code Review — Review your git diff with a single command, getting a severity-ranked (Critical/Major/Minor/Nit) report with fix suggestions, optionally scoped to bugs/security/style/perf. review-pr reviews a remote GitHub PR the same way, with no gh CLI required. AI 代码审查 — 用 repo-ai-cli review 一键审查你的 git diff,输出按严重程度分级的问题报告与修复建议,可聚焦 bug/安全/风格/性能。repo-ai-cli review-pr 以同样方式审查线上 GitHub PR,无需安装 gh CLI。

  • 💡 Explain Code — Point at a file (or a file:line region) and get a plain-language walkthrough of what it does and why. 代码解释 — 用 repo-ai-cli explain src/lib/git.ts:38 快速理解一段陌生代码的作用与逻辑。

  • 🔀 PR Description — Generate a conventional PR title + markdown body from your branch diff against the base branch. PR 描述生成 — 用 repo-ai-cli pr 根据当前分支与 base 的差异生成规范的 PR 标题与描述。

  • 🏗️ Project Scaffolding — repo-ai-cli init scaffolds a ready-to-build TypeScript CLI or library (tsup + vitest), no LLM required. 项目脚手架 — repo-ai-cli init 一键生成可构建的 TypeScript CLI / 库项目骨架。

  • ⚡ Streaming Output — --stream streams the LLM output token-by-token during readme / changelog generation for instant feedback. Streaming does not retry (already-sent tokens cannot be safely replayed) — rerun on failure. 流式输出 — readme / changelog 加 --stream 边生成边打印,实时反馈。流式路径不重试(已发出的 token 无法安全重放),失败请重新执行。

  • 🕵️ Secret Scanning — repo-ai-cli secrets scans your repo offline for hardcoded credentials (GitHub/AWS/Slack/OpenAI/private keys...) with severity ranking and masked output, CI-friendly exit codes. 密钥扫描 — repo-ai-cli secrets 离线扫描仓库中的硬编码密钥(GitHub/AWS/Slack/OpenAI/私钥等),按严重程度分级、打码输出,可接入 CI。

  • 🩺 Health Check — repo-ai-cli doctor diagnoses your environment in one command: Node version, git repo, config file validity, active profile, per-provider API key status (offline prefix check only, never calls any API), and proxy settings — with actionable fix hints. 环境体检 — repo-ai-cli doctor 一键体检:Node 版本、git 仓库、配置文件合法性、激活 profile、各 provider API key 状态(仅离线检查非空与前缀,绝不真实调用 API)、网络代理,并附修复建议。

  • 📄 Scaffolding Utilities — gitignore (16 bundled language templates), license (6 OSS licenses), stats (LOC/language/commit stats) and deps (dependency listing) — all offline. 脚手架工具集 — gitignore(16 套语言模板)、license(6 套开源许可)、stats(行数/语言/提交统计)、deps(依赖清单)—— 全离线。

  • 🗺️ Repository Map — repo-ai-cli map gives you a one-screen overview of any repository: language breakdown, detected entry points, module groups and a depth-limited directory tree. Fully offline. 仓库地图 — repo-ai-cli map 一屏看清仓库:语言分布、入口文件、模块分组与限深目录树,完全离线。

  • 🎯 Change Impact Analysis — repo-ai-cli impact <files> builds a file-level import graph and tells you which files and tests are affected by a change. Use --diff to analyze staged changes directly. 变更影响分析 — repo-ai-cli impact <files> 基于文件级 import 图,反向找出受影响的文件与测试;--diff 可直接分析暂存改动。

  • 🏥 Repository Health Audit — repo-ai-cli health checks community files, CI workflows, tests, package metadata, large files and secret findings in one pass, with --strict for CI. Offline by default; --network adds npm outdated/audit. 仓库健康审计 — repo-ai-cli health 一次检查社区文件、CI、测试、包元数据、大文件与疑似密钥,--strict 可接入 CI;默认离线,--network 才检查依赖更新与漏洞。

  • 🧭 Onboarding Guide — repo-ai-cli onboard generates an ONBOARDING.md that explains the architecture, key modules, request flow, how to run tests and where to start changing code — grounded in real file paths. 上手导读 — repo-ai-cli onboard 生成 ONBOARDING.md,讲清架构、关键模块、请求流、如何跑测试、从哪里开始改,且只引用真实文件路径。

  • 🌐 Document Translation — repo-ai-cli translate turns docs between Chinese and English (or bilingual) while preserving code blocks and structure. 文档翻译 — repo-ai-cli translate 在中文/英文/双语之间翻译文档,保留代码块与结构。

  • 🧪 Test Generation — repo-ai-cli test generates unit tests (Vitest/Jest/node:test) for a file, covering normal/edge/error paths without hallucinating APIs. 测试生成 — repo-ai-cli test 为文件生成单元测试(Vitest/Jest/node:test),覆盖正常/边界/异常分支且不编造 API。

  • ♻️ Refactoring Suggestions — repo-ai-cli refactor reviews a file and returns ranked, behavior-preserving refactor suggestions. 重构建议 — repo-ai-cli refactor 分析文件并给出按收益排序、不改变行为的重构建议。

  • 🪝 Git Hook Installer — repo-ai-cli hooks install wires up a prepare-commit-msg hook so plain git commit auto-generates a conventional message. Git 钩子安装 — repo-ai-cli hooks install 一键安装 prepare-commit-msg 钩子,git commit 自动生成规范 message。

  • 💬 Codebase Q&A (RAG) — repo-ai-cli ask "how does X work?" gathers relevant files and answers against your actual code, citing functions/files. 代码库问答 — repo-ai-cli ask "X 是怎么实现的?" 检索相关文件并结合真实代码回答,引用具体函数/文件。

  • 🐛 Bug Diagnosis — repo-ai-cli fix "describe the bug" locates the root cause and returns a structured, non-hallucinated fix suggestion. Bug 定位 — repo-ai-cli fix "描述 bug" 定位根因并给出结构化修复建议,不编造代码。

  • 🚀 Release Helper — repo-ai-cli release suggests the next semver from your commits; --bump + --tag applies the version bump and tag. 发布助手 — repo-ai-cli release 根据提交记录建议下一个版本号,--bump+--tag 一键改版本并打 tag。

  • 🧠 Smart Token Budgeting — Three-tier file prioritization and sampling ensure efficient use of your LLM token budget, even for large repositories. 智能 Token 预算管理 — 三层文件优先级与采样机制,即使面对大型仓库也能高效利用 LLM Token 预算。

  • 🛡️ Secret-Aware File Collection — Files whose name looks sensitive (.env*, private keys, certificates) or whose content matches a credential pattern (GitHub/AWS/PEM/OpenAI keys, quoted and bare assignments) are excluded from the material sent to the LLM, and each exclusion is reported. .env.example templates and normal code references such as options.apiKey are not affected. 密钥感知的文件收集 — 文件名敏感(.env*、私钥、证书)或内容命中凭据模式(GitHub/AWS/PEM/OpenAI 密钥、带引号与无引号赋值)的文件不会进入发给 LLM 的材料,且逐个上报;.env.example 模板与 options.apiKey 这类正常代码引用不受影响。

  • 🚀 GitHub Repository Support — Pass a GitHub URL or owner/repo shorthand; the tool shallow-clones the repo to a temp directory and cleans up automatically. 支持 GitHub 仓库 — 传入 GitHub URL 或 owner/repo 简写,工具会自动浅克隆到临时目录并在完成后清理。

  • 💬 Interactive & Scriptable — Enjoy a modern interactive UI (spinner, confirm, select) in TTY mode, or use --print / --json for non-interactive scripting. 交互式与脚本友好 — 在 TTY 模式下享受现代化交互界面(spinner、确认、选择),或使用 --print / --json 参数进行非交互式脚本操作。

  • 🛡️ Robust Error Handling — Automatic retries with exponential backoff for transient API errors, and graceful fallbacks to prevent corrupted output. 健壮的错误处理 — 对瞬时 API 错误进行指数退避重试,并提供优雅降级以防止输出损坏。

  • 🔑 BYOK (Bring Your Own Key) — Use your own API key from 13 providers (DeepSeek, OpenAI, Kimi, GLM, Qwen, MiniMax, Grok, SiliconFlow, Ollama local, OpenRouter, Groq, Volcengine Ark, Gemini) or any OpenAI-compatible endpoint. Zero server-side costs, and your code is only sent to the API you configure. Ollama runs fully local with no API key at all. BYOK 自带 API Key — 支持 DeepSeek、OpenAI、Kimi、GLM、通义千问、MiniMax、Grok、硅基流动、Ollama(本地免 key)、OpenRouter、Groq、火山方舟、Gemini 共 13 家国内外提供商,以及任意 OpenAI 兼容端点。零服务端成本,代码仅发送至你配置的 API;Ollama 完全本地运行、无需任何 key。

  • 👥 Config Profiles — Maintain multiple provider/model/key sets (work, personal, local...) with config set --profile, switch with config use, and pick per-command via --profile. 多配置 Profile — 用 config set --profile 维护多套 provider/model/key 配置(如 work、personal、local),config use 一键切换,任意 AI 命令可用 --profile 临时指定。

  • 🔎 Verbose Debugging — Global --verbose (or REPO_AI_VERBOSE=1) prints LLM request URLs, retries, provider resolution and clone fallbacks to stderr — without polluting stdout or --json output. 调试日志 — 全局 --verbose(或 REPO_AI_VERBOSE=1)在 stderr 输出 LLM 请求地址、重试、provider 解析与克隆回退,不污染 stdout 与 --json。

  • 📦 Dependency Health — deps --outdated / deps --audit wrap npm with friendly tables and CI exit codes, so upgrade and vulnerability checks fit right into your pipeline. 依赖体检 — deps --outdated / deps --audit 封装 npm outdated / audit,输出友好表格并带 CI 退出码,升级与安全检查可直接接入流水线。

  • 🏅 Badges & Contributing Generators — badges detects your CI workflow / npm package / license / node engines and emits ready-to-paste README badges; contributing scaffolds a zh/en CONTRIBUTING.md with your repo details auto-filled. 徽章与贡献指南生成 — badges 自动探测 CI workflow / npm 包 / LICENSE / Node 版本并生成可直接粘贴的 README 徽章;contributing 生成中英双语 CONTRIBUTING.md 并自动填充仓库信息。

  • 🧪 Comprehensive Testing — 500+ unit and end-to-end tests covering file filtering, token budgeting, git integration, LLM error handling (incl. streaming), secret scanning, semantic versioning, provider resolution, config profiles, git hooks, npm audit parsing, repository indexing, badge/contributing generation, option validation, UI output hygiene, and more. 全面测试覆盖 — 500+ 单元测试与端到端测试,覆盖文件过滤、Token 预算、Git 集成、LLM 错误处理(含流式)、密钥扫描、语义化版本、提供商解析、配置 Profile、git 钩子、npm 审计解析、仓库索引、徽章/贡献指南生成、参数校验、输出纯净等核心逻辑。


🎬 Demo — 演示

📝 本 README 由 repo-ai-cli 自己生成(dogfooding)——上面的示例就是它的真实输出效果。

录屏 GIF 待补充 —— 录制步骤与分镜脚本见 docs/gif-录制指南.md(需由维护者本地真实录屏,产出后放入 docs/assets/ 并在本节引用)。


🚀 Quick Start — 快速开始

Prerequisites — 环境要求

  • Node.js ≥ 20
  • npm (or your preferred Node package manager)
  • DeepSeek API Key — Get one here

Installation — 安装

# Install globally
npm install -g repo-ai-cli

# Or run directly without installation
npx repo-ai-cli --help

Set up your API Key — 配置 API Key

# 推荐:一次配置,长期生效(保存到 ~/.repo-ai/config.json)
repo-ai-cli config set provider deepseek
repo-ai-cli config set apiKey sk-xxx

# 或交互式向导
repo-ai-cli config init

# 查看/清除配置(apiKey 自动打码显示)
repo-ai-cli config list
repo-ai-cli config unset apiKey
repo-ai-cli config reset

# 传统方式:任何一家内置提供商的环境变量(任选其一):
export DEEPSEEK_API_KEY=sk-xxx          # DeepSeek
export OPENAI_API_KEY=sk-xxx            # OpenAI
export MOONSHOT_API_KEY=sk-xxx          # Kimi
export ZHIPU_API_KEY=xxx                # 智谱 GLM
export DASHSCOPE_API_KEY=sk-xxx         # 通义千问
export MINIMAX_API_KEY=xxx              # MiniMax
export XAI_API_KEY=xxx                  # Grok
export SILICONFLOW_API_KEY=sk-xxx       # 硅基流动
export OPENROUTER_API_KEY=sk-or-xxx     # OpenRouter
export GROQ_API_KEY=gsk_xxx             # Groq
export VOLCENGINE_API_KEY=xxx           # 火山方舟
export GEMINI_API_KEY=xxx               # Google Gemini

# Ollama:完全本地,无需任何 key(先 ollama pull llama3.2)
repo-ai-cli readme --provider ollama --model llama3.2

# Or any custom OpenAI-compatible endpoint:
export LLM_BASE_URL=https://your-endpoint/v1
export LLM_API_KEY=sk-xxx

# Or select a provider explicitly per command:
repo-ai-cli readme --provider moonshot
repo-ai-cli readme --provider siliconflow --model Qwen/Qwen2.5-7B-Instruct

配置优先级:CLI 参数 > 环境变量 > config 文件 > 默认值。Windows (cmd) 用 set VAR=xxx,PowerShell 用 $env:VAR="xxx"。

Config Profiles — 多配置切换(v0.6.0)

# 为不同场景维护多套配置
repo-ai-cli config set provider deepseek --profile work
repo-ai-cli config set apiKey sk-xxx --profile work
repo-ai-cli config set provider ollama --model qwen2.5:14b --profile local

# 切换激活 profile(影响所有命令的默认配置)
repo-ai-cli config use work
repo-ai-cli config list          # 查看所有 profile(* = 激活)

# 单次命令临时使用某个 profile(不改激活状态)
repo-ai-cli commit --profile local

# 删除 profile
repo-ai-cli config rm-profile local

Generate a README — 生成 README

# From the current directory
repo-ai-cli readme

# From a specific local directory
repo-ai-cli readme /path/to/my-project

# From a GitHub repository
repo-ai-cli readme owner/repo
repo-ai-cli readme https://github.com/owner/repo

# Generate a Chinese-only README
repo-ai-cli readme -l zh

# Dry run: show statistics without calling the API
repo-ai-cli readme --dry-run

Generate a Commit Message — 生成 commit message

# From staged changes (default)
repo-ai-cli commit

# Include unstaged changes
repo-ai-cli commit --all

# Print the message without interaction (script-friendly)
repo-ai-cli commit --print

# Force a specific commit type
repo-ai-cli commit --type feat

Generate a CHANGELOG — 生成 CHANGELOG

# From the last git tag to HEAD (default)
repo-ai-cli changelog

# Custom git range
repo-ai-cli changelog --range v0.1.0..v0.2.0

# Print to stdout without writing the file
repo-ai-cli changelog --print

# Compact format: one line per commit, rendered locally without calling any LLM
repo-ai-cli changelog --format compact --print

# English output
repo-ai-cli changelog -l en

Review Your Code — 代码审查

# Review staged changes (default), print report to stdout
repo-ai-cli review

# Include unstaged changes
repo-ai-cli review --all

# Focus on a specific dimension
repo-ai-cli review --focus bugs
repo-ai-cli review --focus security

# Write the report to a file
repo-ai-cli review -o REVIEW.md

Explain Code — 解释代码

# Explain a whole file
repo-ai-cli explain src/lib/git.ts

# Explain a specific region (line 38, or lines 10-40)
repo-ai-cli explain src/lib/git.ts:38
repo-ai-cli explain src/lib/git.ts:10-40

# Explain a certain function/symbol
repo-ai-cli explain src/lib/git.ts#getDiff

# Output language
repo-ai-cli explain src/lib/git.ts -l en

Generate a PR Description — 生成 PR 描述

# Auto-detect base branch (origin/HEAD → main → master)
repo-ai-cli pr

# Explicit base branch
repo-ai-cli pr --base main
repo-ai-cli pr --base origin/main

# Create the PR directly via the GitHub CLI (gh)
repo-ai-cli pr --create

# Machine-readable
repo-ai-cli pr --json

Scaffold a New Project — 脚手架新项目

# In the current directory (TypeScript CLI template)
repo-ai-cli init

# Create a new directory with a name
repo-ai-cli init my-cli

# Pick a template (ts-cli | ts-lib) and overwrite existing files
repo-ai-cli init my-lib --template ts-lib --force

Scan for Secrets — 密钥扫描

# Scan the current directory (offline, no LLM)
repo-ai-cli secrets

# Scan a specific directory, only critical/high findings
repo-ai-cli secrets /path/to/project --severity high

# Machine-readable (exits 1 if any findings, useful for CI)
repo-ai-cli secrets --json

Check Environment Health — 环境体检

repo-ai-cli doctor

# Machine-readable
repo-ai-cli doctor --json

# Exit code 1 when any check fails (CI-friendly)
repo-ai-cli doctor; echo $?

Checks: Node.js version, git repo, config file validity, active profile, per-provider API key status (offline only — non-empty + known prefix, never calls an API), and proxy environment variables. Non-passing items come with fix hints.

检查项:Node 版本、git 仓库、配置文件合法性(坏 JSON 明确报错)、激活 profile、各 provider API key 状态(纯离线:非空 + 已知前缀,绝不真实调用 API)、网络代理环境变量。未通过项附修复建议。

Repo Utilities — 仓库工具

# Generate .gitignore (combine templates); --list to see all
repo-ai-cli gitignore node python -o .gitignore
repo-ai-cli gitignore --list

# Generate a LICENSE (auto-injects your name + year)
repo-ai-cli license mit --name "Yu" --year 2026

# Repo stats: files, lines of code, languages, commits
repo-ai-cli stats

# List dependencies from package.json / requirements.txt
repo-ai-cli deps

# Check for upgrades & vulnerabilities (wraps npm, CI-friendly)
repo-ai-cli deps --outdated
repo-ai-cli deps --audit
repo-ai-cli deps --outdated --audit --json

# Generate README badges from repo context (CI/npm/license/node)
repo-ai-cli badges
repo-ai-cli badges -o BADGES.md

# Generate a CONTRIBUTING.md (zh default, --language en for English)
repo-ai-cli contributing
repo-ai-cli contributing --language en -f

Translate Documents — 文档翻译

# Translate to English (default), Chinese, or bilingual
repo-ai-cli translate README.md --to en
repo-ai-cli translate docs/guide.md --to zh -o docs/guide.zh.md

# Machine-readable
repo-ai-cli translate README.md --to en --json

Generate Tests — 生成单元测试

# Generate unit tests for a file (Vitest by default)
repo-ai-cli test src/lib/git.ts

# Choose a framework and write to a file
repo-ai-cli test src/lib/git.ts --framework jest -o src/lib/__tests__/git.test.ts
repo-ai-cli test src/lib/git.ts --framework node-test

Get Refactoring Suggestions — 重构建议

# Analyze a file and print suggestions (read-only)
repo-ai-cli refactor src/lib/git.ts

# Focus on a specific dimension
repo-ai-cli refactor src/lib/git.ts --focus complexity

Install Git Hooks — 安装 git 钩子

# Install prepare-commit-msg so `git commit` auto-generates messages
repo-ai-cli hooks install

# Check / remove
repo-ai-cli hooks list
repo-ai-cli hooks uninstall

Ask About Your Code — 代码库问答

# Ask a question; repo-ai gathers relevant files and answers with citations
repo-ai-cli ask "how is the token budget allocated?"

# Stream the answer token-by-token
repo-ai-cli ask "这个项目的配置优先级是什么" --stream

Diagnose a Bug — 定位 bug

# Locate the root cause and get a structured fix suggestion (read-only)
repo-ai-cli fix "commit 命令在非 git 目录下报错"

Release — 版本发布

# Suggest the next version from your commit history (no changes)
repo-ai-cli release

# Apply the bump and create a git tag
repo-ai-cli release --bump minor --tag

Script-friendly JSON output — 脚本友好的 JSON 输出

所有命令支持 --json,输出机器可读结果,便于接入 CI/脚本:

repo-ai-cli readme --dry-run --json
# {"ok":true,"dryRun":true,"repo":"repo-ai","filesCollected":43,"estimatedTokens":20784,...}

repo-ai-cli commit --json
# {"ok":true,"message":"feat: add config persistence"}

repo-ai-cli changelog --json
# {"ok":true,"output":"E:\\repo-ai\\CHANGELOG.md","bytes":1234}

repo-ai-cli review --json
# {"ok":true,"review":"## 🔴 Critical\n...","files":["src/lib/ui.ts"],"truncated":false}

repo-ai-cli explain src/lib/git.ts --json
# {"ok":true,"file":"src/lib/git.ts","focus":null,"explanation":"..."}

repo-ai-cli pr --json
# {"ok":true,"base":"main","branch":"feat/x","title":"feat: ...","body":"..."}

repo-ai-cli init my-cli --json
# {"ok":true,"template":"ts-cli","directory":".../my-cli","created":["package.json",...]}

Token Usage — token 用量

每条调用 LLM 的命令都会报告本次消耗的 token,让你对按量计费心里有数:

repo-ai-cli commit --print
# feat: add config persistence
# token 用量: 输入 1204 / 输出 38 / 合计 1242      ← stderr,不污染 stdout

--json 模式下用量并入输出对象的 usage 字段(不再往 stderr 打):

repo-ai-cli commit --json
# {"ok":true,"message":"...","usage":{"promptTokens":1204,"completionTokens":38,"totalTokens":1242}}

三点说明:

  • 不做价格换算。各家模型价格变动频繁,写死在 CLI 里必然过期;请拿上面的 token 数乘你所用模型的单价自行估算。
  • usage: null 表示「未知」,不是 0。部分提供商不返回用量;流式模式下多数提供商需要额外参数才返回,本工具不会为此改动请求体(13 家提供商里只要有一家拒绝未知字段,整个流式就废了)。
  • 离线命令(init / secrets / doctor / stats / …)与 --dry-run 不调用 LLM,输出里不会出现 usage 字段——「没调用」与「调用了但未知」是两回事。

⚙️ Configuration — 配置说明

Environment Variables — 环境变量

| Variable | Required | Description | |----------|----------|-------------| | DEEPSEEK_API_KEY | One of | DeepSeek API key | | OPENAI_API_KEY | One of | OpenAI API key | | MOONSHOT_API_KEY | One of | Moonshot (Kimi) API key | | ZHIPU_API_KEY | One of | 智谱 GLM API key | | DASHSCOPE_API_KEY | One of | 通义千问 (DashScope) API key | | MINIMAX_API_KEY | One of | MiniMax API key | | XAI_API_KEY | One of | xAI (Grok) API key | | SILICONFLOW_API_KEY | One of | 硅基流动 API key | | OPENROUTER_API_KEY | One of | OpenRouter API key | | GROQ_API_KEY | One of | Groq API key | | VOLCENGINE_API_KEY | One of | 火山方舟 (Volcengine Ark) API key | | GEMINI_API_KEY | One of | Google Gemini API key | | OLLAMA_API_KEY | No | Ollama 本地部署无需 key(设置亦可,将被忽略校验) | | LLM_BASE_URL + LLM_API_KEY | Custom | Any OpenAI-compatible endpoint | | LLM_MODEL | No | Default model override | | REPO_AI_VERBOSE | No | 1 等同全局 --verbose(调试日志输出到 stderr) | | GITHUB_MIRROR | No | GitHub mirror prefix (default https://gh-proxy.com/), used when direct access fails |

未显式指定 provider 时,工具按上表顺序自动选择第一个已配置 key 的提供商。

Command Options — 命令参数

参数改名(v0.8):readme / ask / fix 的 --max-tokens 已更名为 --budget-tokens,changelog 的 --max 已更名为 --max-commits。旧名仍可用(会打印一行 deprecation 警告、不出现在 --help 里),将在下个 major 版本移除。改名的原因是「预算」一词在四条命令里此前有四种写法,换条命令含义就变。

repo-ai-cli readme

| Option | Description | Default | |--------|-------------|---------| | [path-or-url] | Local directory path or GitHub URL/owner/repo shorthand | . (current directory) | | -o, --output <file> | Output file path | README.md | | -l, --language <lang> | Output language: bilingual | zh | en | bilingual | | --dry-run | Print statistics only, do not call the API | false | | --budget-tokens <n> | Token budget for collected files (was --max-tokens, deprecated) | 48000 | | --max-file-kb <n> | Maximum single-file size to include (in KB) | 100 | | --stream | Stream output token-by-token (TTY only) | false | | --provider <id> | LLM provider: deepseek | openai | moonshot | zhipu | qwen | minimax | xai | siliconflow | ollama | openrouter | groq | volcengine | gemini | auto-detect | | --base-url <url> | Custom OpenAI-compatible endpoint | provider default | | --model <name> | Model name override | provider default | | --api-key <key> | API key (prefer env vars) | env var | | --profile <name> | 使用指定配置 profile(见 Config Profiles) | active profile |

repo-ai-cli onboard

| Option | Description | Default | |--------|-------------|---------| | [path] | Local directory to analyze | . (current directory) | | -o, --output <file> | Output file path | ONBOARDING.md | | --dry-run | Print statistics only, do not call the API | false | | --budget-tokens <n> | Token budget for collected files (was --max-tokens, deprecated) | 48000 | | --max-file-kb <n> | Maximum single-file size to include (in KB) | 100 | | --max-output-tokens <n> | Maximum LLM output tokens | 8192 | | --temperature <n> | Sampling temperature (0–2) | 0.5 | | --stream | Stream output token-by-token (TTY only) | false | | --json | Output machine-readable JSON | false | | --provider <id> | LLM provider (same as readme) | auto-detect | | --base-url <url> | Custom OpenAI-compatible endpoint | provider default | | --model <name> | Model name override | provider default | | --api-key <key> | API key (prefer env vars) | env var | | --profile <name> | 使用指定配置 profile(见 Config Profiles) | active profile |

repo-ai-cli commit

| Option | Description | Default | |--------|-------------|---------| | --staged | Use staged changes (git diff --cached) | true | | --all | Include unstaged changes (git diff HEAD) | false | | --print | Print the message without interaction | false | | --json | Output machine-readable JSON | false | | --type <type> | Force a commit type (e.g., feat, fix, docs) | Auto-detect | | --max-diff-kb <n> | Maximum diff size to process (in KB) | 200 | | --provider <id> | LLM provider (same as readme) | auto-detect | | --base-url <url> | Custom OpenAI-compatible endpoint | provider default | | --model <name> | Model name override | provider default |

repo-ai-cli changelog

| Option | Description | Default | |--------|-------------|---------| | -o, --output <file> | Output file path | CHANGELOG.md | | -r, --range <range> | Git range (v1.0.0.. / ..HEAD / 1.0.0..2.0.0) | last tag..HEAD | | -n, --max-commits <n> | Max commits to consider (was --max, deprecated) | 50 | | -l, --language <lang> | Output language: zh | en | zh | | --format <fmt> | Output format: keep-a-changelog (AI) | compact (one line per commit, local, no LLM) | keep-a-changelog | | --dry-run | Print statistics only, do not call the API | false | | --print | Print to stdout without writing file | false | | --json | Output machine-readable JSON | false | | --max-output-tokens <n> | Max LLM output tokens | 4096 | | --temperature <n> | Sampling temperature 0~2 | 0.5 | | --stream | Stream output token-by-token (TTY only) | false | | --provider <id> | LLM provider (same as readme) | auto-detect | | --base-url <url> | Custom OpenAI-compatible endpoint | provider default | | --model <name> | Model name override | provider default |

repo-ai-cli review

| Option | Description | Default | |--------|-------------|---------| | --staged | Use staged changes (git diff --cached) | true | | --all | Include unstaged changes (git diff HEAD) | false | | -o, --output <file> | Write review to file (default: stdout) | stdout | | --focus <area> | Review focus: all | bugs | security | style | perf | all | | --json | Output machine-readable JSON | false | | --max-diff-kb <n> | Maximum diff size to process (in KB) | 200 | | --max-output-tokens <n> | Max LLM output tokens | 4096 | | --temperature <n> | Sampling temperature 0~2 | 0.3 | | --provider <id> | LLM provider (same as readme) | auto-detect | | --base-url <url> | Custom OpenAI-compatible endpoint | provider default | | --model <name> | Model name override | provider default |

repo-ai-cli review-pr

Review a remote GitHub pull request. Fetches the PR diff through the public GitHub API with native fetch — no gh CLI, no extra dependency. The review prompt, severity ranking and truncation semantics are shared with review.

审查一个线上 GitHub PR。通过 GitHub 公开 API 拉取 diff(原生 fetch),无需 gh CLI、无额外依赖;审查 prompt、严重程度分级与截断语义与 review 完全共用。

# Full PR URL
repo-ai-cli review-pr https://github.com/owner/repo/pull/123

# owner/repo#number shorthand
repo-ai-cli review-pr b8nw27v7wp-bit/repo-ai-cli#3

# Focus on security, write the report to a file
repo-ai-cli review-pr owner/repo#123 --focus security -o review.md

# Machine-readable, with PR metadata (title / author / branch / state / draft)
repo-ai-cli review-pr owner/repo#123 --json

# Preview the comments that would be posted (nothing is published)
repo-ai-cli review-pr owner/repo#123 --comment

# Actually post them (needs GITHUB_TOKEN)
GITHUB_TOKEN=ghp_xxx repo-ai-cli review-pr owner/repo#123 --comment --yes

Posting the review back to the PR — --comment 把审查结论直接发到 PR 上,不用复制粘贴:

  • 默认只预览。不加 --yes 时只打印将要发布的内容,一个字都不会发出去。
  • 需要 GITHUB_TOKEN。读公开 PR 是匿名的,但发评论必须有写权限的 token(公开仓库 public_repo,私有仓库 repo)。缺失时会给出获取与设置指引。
  • 分级发布:🔴 Critical / 🟠 Major 各占一条评论,便于单独 resolve;🟡 Minor / 💡 Nit 与整体结论合并成一条,避免刷屏。
  • 交互模式下再加一道确认:即使带了 --yes,TTY 里仍会问一次——误发到公开 PR 是不可撤回的。
  • 每条评论带一行「由 repo-ai-cli review-pr 生成」尾注,读者能看出是自动生成的意见。

| Option | Description | Default | |--------|-------------|---------| | <pr> | PR reference: https://github.com/owner/repo/pull/123, owner/repo#123, owner/repo/pull/123 | required | | --focus <area> | Review focus: all | bugs | security | style | perf | all | | -o, --output <file> | Write review to file (default: stdout) | stdout | | --max-diff-kb <n> | Maximum diff size to process (in KB) | 200 | | --max-output-tokens <n> | Max LLM output tokens | 4096 | | --temperature <n> | Sampling temperature 0~2 | 0.3 | | --comment | Post the review as PR comments (needs GITHUB_TOKEN; dry-run unless --yes) | false | | --yes | Actually post the comments (required in non-interactive mode) | false | | --json | Output machine-readable JSON (includes PR metadata) | false | | --provider <id> | LLM provider (same as readme) | auto-detect | | --base-url <url> | Custom OpenAI-compatible endpoint | provider default | | --model <name> | Model name override | provider default |

repo-ai-cli explain

| Option | Description | Default | |--------|-------------|---------| | <file-or-region> | File path, optionally :line / :start-end / #symbol | required | | -l, --language <lang> | zh | en | bilingual | zh | | --max-file-kb <n> | Max file size to read (in KB) | 200 | | --json | Output machine-readable JSON | false | | --max-output-tokens <n> | Max LLM output tokens | 2048 | | --temperature <n> | Sampling temperature 0~2 | 0.3 | | --provider <id> | LLM provider (same as readme) | auto-detect | | --base-url <url> | Custom OpenAI-compatible endpoint | provider default | | --model <name> | Model name override | provider default |

repo-ai-cli pr

| Option | Description | Default | |--------|-------------|---------| | --base <branch> | Base branch | auto-detect (origin/HEAD→main→master) | | --create | Create the PR via gh pr create after generating | false | | --json | Output machine-readable JSON | false | | --max-diff-kb <n> | Maximum diff size to process (in KB) | 200 | | --max-output-tokens <n> | Max LLM output tokens | 4096 | | --temperature <n> | Sampling temperature 0~2 | 0.5 | | --provider <id> | LLM provider (same as readme) | auto-detect | | --base-url <url> | Custom OpenAI-compatible endpoint | provider default | | --model <name> | Model name override | provider default |

repo-ai-cli init

| Option | Description | Default | |--------|-------------|---------| | [name] | Project name (default: current directory) | current dir | | -t, --template <id> | ts-cli | ts-lib | ts-cli | | -f, --force | Overwrite existing files | false | | --json | Output machine-readable JSON | false |

交互式(TTY)下未指定 --template / [name] 时会弹出模板选择与项目名提示。

repo-ai-cli secrets

| Option | Description | Default | |--------|-------------|---------| | [path] | Directory to scan | . (current directory) | | --severity <level> | Only report critical / high / medium and above | medium | | --max-file-kb <n> | Max file size to scan (in KB) | 200 | | --json | Output machine-readable JSON | false |

repo-ai-cli doctor

| Option | Description | Default | |--------|-------------|---------| | --json | Output machine-readable JSON (exits 1 if any check fails) | false |

Checks: Node.js version, git repo, config file validity, active profile, per-provider API key status (offline), proxy env vars. Fix hints included.

repo-ai-cli gitignore

| Option | Description | Default | |--------|-------------|---------| | [templates...] | Template ids to combine (see --list) | required | | --list | List available templates | false | | -o, --output <file> | Write to file (default: stdout) | stdout | | --json | Output machine-readable JSON | false |

repo-ai-cli license

| Option | Description | Default | |--------|-------------|---------| | [license] | mit | isc | bsd-2-clause | bsd-3-clause | unlicense | mit-0 | mit | | --name <name> | Copyright holder | git user.name | | --year <year> | Copyright year | current year | | -o, --output <file> | Output file | LICENSE | | --json | Output machine-readable JSON | false |

repo-ai-cli stats

| Option | Description | Default | |--------|-------------|---------| | [path] | Directory to analyze | . (current directory) | | --since <date> | Only count commits since this date (YYYY-MM-DD, inclusive) | full history | | --json | Output machine-readable JSON | false |

repo-ai-cli map

| Option | Description | Default | |--------|-------------|---------| | [path] | Directory to analyze | . (current directory) | | --depth <n> | Maximum directory-tree depth (root = 0) | 3 | | --focus <path> | Only map a subdirectory/module | full repo | | --json | Output machine-readable JSON | false |

repo-ai-cli impact

| Option | Description | Default | |--------|-------------|---------| | [files...] | Changed files to analyze | staged changes | | --diff | Use staged changes (default when no files are given) | false | | --depth <n> | Reverse dependency depth | 2 | | --json | Output machine-readable JSON | false |

repo-ai-cli health

| Option | Description | Default | |--------|-------------|---------| | [path] | Directory to audit | . (current directory) | | --strict | Exit 1 on warnings too (for CI) | false | | --network | Also run npm outdated / npm audit | false (offline) | | --json | Output machine-readable JSON | false |

repo-ai-cli deps

| Option | Description | Default | |--------|-------------|---------| | --json | Output machine-readable JSON | false |

repo-ai-cli translate

| Option | Description | Default | |--------|-------------|---------| | <file> | Document to translate | required | | --to <lang> | zh | en | bilingual | en | | -o, --output <file> | Write to file (default: stdout) | stdout | | --max-file-kb <n> | Max file size to read (in KB) | 200 | | --json | Output machine-readable JSON | false | | --provider <id> | LLM provider (same as readme) | auto-detect | | --base-url <url> | Custom OpenAI-compatible endpoint | provider default | | --model <name> | Model name override | provider default |

repo-ai-cli test

| Option | Description | Default | |--------|-------------|---------| | <file> | Source file to generate tests for | required | | --framework <name> | vitest | jest | node-test | vitest | | -o, --output <file> | Write tests to file (default: stdout) | stdout | | --max-file-kb <n> | Max file size to read (in KB) | 200 | | --json | Output machine-readable JSON | false | | --provider <id> | LLM provider (same as readme) | auto-detect | | --base-url <url> | Custom OpenAI-compatible endpoint | provider default | | --model <name> | Model name override | provider default |

repo-ai-cli refactor

| Option | Description | Default | |--------|-------------|---------| | <file> | File to analyze | required | | --focus <dim> | all | readability | perf | complexity | types | all | | -o, --output <file> | Write suggestions to file (default: stdout) | stdout | | --max-file-kb <n> | Max file size to read (in KB) | 200 | | --json | Output machine-readable JSON | false | | --provider <id> | LLM provider (same as readme) | auto-detect | | --base-url <url> | Custom OpenAI-compatible endpoint | provider default | | --model <name> | Model name override | provider default |

repo-ai-cli hooks

| Command | Description | |---------|-------------| | hooks install [--hook <name>] | Install a git hook (default prepare-commit-msg) | | hooks uninstall [--hook <name>] | Remove the hook installed by repo-ai | | hooks list | Show installed hook status |

repo-ai-cli ask

| Option | Description | Default | |--------|-------------|---------| | <question...> | Your question about the repository | required | | --budget-tokens <n> | Token budget for collected files (was --max-tokens, deprecated) | 48000 | | --max-file-kb <n> | Max single-file size (in KB) | 100 | | --stream | Stream the answer token-by-token (TTY only) | false | | --json | Output machine-readable JSON | false | | --provider <id> | LLM provider (same as readme) | auto-detect | | --base-url <url> | Custom OpenAI-compatible endpoint | provider default | | --model <name> | Model name override | provider default |

repo-ai-cli fix

| Option | Description | Default | |--------|-------------|---------| | <description...> | Bug description / error message | required | | --budget-tokens <n> | Token budget for collected files (was --max-tokens, deprecated) | 48000 | | --max-file-kb <n> | Max single-file size (in KB) | 100 | | --json | Output machine-readable JSON | false | | --provider <id> | LLM provider (same as readme) | auto-detect | | --base-url <url> | Custom OpenAI-compatible endpoint | provider default | | --model <name> | Model name override | provider default |

repo-ai-cli release

| Option | Description | Default | |--------|-------------|---------| | --bump <level> | major | minor | patch | auto(给出则实际修改版本) | suggest only | | --tag | Create a git tag after --bump | false | | --json | Output machine-readable JSON | false |

repo-ai-cli config

| Command | Description | |---------|-------------| | config init | Interactive wizard: pick provider + enter API key | | config set <key> <value> | Set a value (provider/baseUrl/model/apiKey/maxTokens/...) | | config get <key> | Print a value (apiKey masked) | | config list (ls) | Show all persisted config (apiKey masked) | | config unset <key> | Remove a value | | config reset | Clear all persisted config |

配置文件位于 ~/.repo-ai/config.json(POSIX 0600 权限),apiKey 明文存储但仅在用户目录内。

repo-ai-cli badges

| Option | Description | Default | |--------|-------------|---------| | -o, --output <file> | Write badges to file (default: stdout) | stdout | | --json | Output machine-readable JSON | false |

repo-ai-cli contributing

| Option | Description | Default | |--------|-------------|---------| | -o, --output <file> | Output file | CONTRIBUTING.md | | -l, --language <lang> | zh | en | zh | | -f, --force | Overwrite existing file | false | | --json | Output machine-readable JSON | false |


🛠 Tech Stack — 技术栈

| Category | Technology | |----------|------------| | Runtime | Node.js ≥ 20 | | Language | TypeScript (strict mode) | | CLI Framework | commander | | Interactive UI | @clack/prompts | | Output Styling | picocolors | | LLM Provider | DeepSeek Chat API (OpenAI-compatible) | | Bundler | tsup | | Testing | Vitest | | Linting | ESLint + typescript-eslint | | Release Management | Changesets | | CI/CD | GitHub Actions |


📁 Directory Structure — 目录结构

repo-ai-cli/
├── .changeset/                  # Changesets configuration
├── .github/
│   └── workflows/
│       ├── ci.yml               # Lint + typecheck + coverage + build + docs:check + e2e (Node 20/22)
│       └── release.yml          # Changesets → npm publish
├── scripts/
│   ├── check-docs.mjs           # README ↔ CLI surface consistency check
│   ├── coverage-report.mjs      # 列出覆盖率最低的文件(指出该补哪儿)
│   └── e2e-smoke.mjs            # dist-level end-to-end smoke (offline, fake LLM endpoint)
├── src/
│   ├── cli/                     # CLI 组装层(v0.8 从 index.ts 拆出)
│   │   ├── program.ts           # program 组装、全局 option、preAction 钩子、命令登记顺序
│   │   ├── register-ai.ts       # 12 条 AI 命令的注册(option + action 接线)
│   │   ├── register-offline.ts  # 12 条离线命令的注册(含 hooks / config 子命令组)
│   │   └── shared.ts            # 共用零件:withLLMOptions / handleError
│   ├── commands/                # 一条命令一个编排层(读输入 → 组 prompt → 调 LLM → 落盘)
│   │   ├── readme.ts            # `repo-ai readme` command
│   │   ├── commit.ts            # `repo-ai commit` command
│   │   ├── changelog.ts         # `repo-ai changelog` command
│   │   ├── review.ts            # `repo-ai review` command (code review)
│   │   ├── review-pr.ts         # `repo-ai review-pr` command (remote PR review)
│   │   ├── explain.ts           # `repo-ai explain` command (explain code)
│   │   ├── pr.ts                # `repo-ai pr` command (PR description)
│   │   ├── init.ts              # `repo-ai init` command (scaffolding)
│   │   ├── secrets.ts           # `repo-ai secrets` command (secret scan)
│   │   ├── doctor.ts            # `repo-ai doctor` command (health check)
│   │   ├── gitignore.ts         # `repo-ai gitignore` command (templates)
│   │   ├── license.ts           # `repo-ai license` command (OSS licenses)
│   │   ├── stats.ts             # `repo-ai stats` command (repo statistics)
│   │   ├── deps.ts              # `repo-ai deps` command (dependency listing)
│   │   ├── translate.ts         # `repo-ai translate` command (doc translation)
│   │   ├── test.ts              # `repo-ai test` command (unit test generation)
│   │   ├── refactor.ts          # `repo-ai refactor` command (refactor suggestions)
│   │   ├── hooks.ts             # `repo-ai hooks` command (git hook installer)
│   │   ├── ask.ts               # `repo-ai ask` command (codebase Q&A)
│   │   ├── fix.ts               # `repo-ai fix` command (bug diagnosis)
│   │   ├── release.ts           # `repo-ai release` command (versioning)
│   │   ├── badges.ts            # `repo-ai badges` command (README badges)
│   │   ├── contributing.ts      # `repo-ai contributing` command
│   │   └── config.ts            # `repo-ai config` command group
│   ├── lib/
│   │   ├── collect-files.ts     # File collection & filtering (token control core)
│   │   ├── file-tree.ts         # Text-based directory tree generation
│   │   ├── git.ts               # Git diff / staged status reading
│   │   ├── github.ts            # GitHub URL parsing & shallow cloning
│   │   ├── github-pr.ts         # PR metadata / diff fetching + review posting
│   │   ├── llm.ts               # LLM API calls (retry + timeout + streaming)
│   │   ├── providers.ts         # LLM provider registry (13 providers)
│   │   ├── config.ts            # ~/.repo-ai/config.json + profiles
│   │   ├── options.ts           # CLI option parsers + deprecated flag aliases
│   │   ├── output.ts            # Atomic file writing
│   │   ├── token-budget.ts      # Token budget allocation & estimation
│   │   ├── usage.ts             # Token usage accounting (per command)
│   │   ├── review-parse.ts      # Split a review into severity sections
│   │   ├── readme-validate.ts   # Pre-write README structure validation
│   │   ├── changelog-compact.ts # Local (no-LLM) CHANGELOG rendering
│   │   ├── materials.ts         # File collection + budget (readme/ask/fix shared)
│   │   ├── templates.ts         # init scaffolding templates (ts-cli / ts-lib)
│   │   ├── secret-patterns.ts   # Secret detection patterns (offline scan)
│   │   ├── scan-secrets.ts      # Directory secret scanner
│   │   ├── doctor.ts            # Environment / repo health checks
│   │   ├── npm-checks.ts        # npm outdated / audit wrappers
│   │   ├── gitignore-templates.ts # .gitignore bundled templates
│   │   ├── licenses.ts          # OSS license templates
│   │   ├── badges.ts            # README badge generation
│   │   ├── contributing.ts      # CONTRIBUTING.md generation
│   │   ├── stats.ts             # Repo statistics (LOC / language / git)
│   │   ├── deps.ts              # Dependency manifest parsing
│   │   ├── git-hooks.ts         # Git hook install / uninstall / list
│   │   ├── version.ts           # Semantic versioning (suggest / bump)
│   │   ├── log.ts               # --verbose debug logging
│   │   └── ui.ts                # Shared UI helpers (spinner / json / say / warn)
│   ├── prompts/
│   │   ├── readme.ts            # README generation prompt template
│   │   ├── commit.ts            # Commit message generation prompt template
│   │   ├── changelog.ts         # CHANGELOG generation prompt template
│   │   ├── review.ts            # Code review prompt template
│   │   ├── explain.ts           # Code explanation prompt template
│   │   ├── pr.ts                # PR title/description prompt template
│   │   ├── translate.ts         # Document translation prompt template
│   │   ├── test.ts              # Unit test generation prompt template
│   │   ├── refactor.ts          # Refactoring suggestions prompt template
│   │   ├── ask.ts               # Codebase Q&A prompt template
│   │   └── fix.ts               # Bug diagnosis prompt template
│   ├── index.ts                 # CLI entry point (10 lines: build & parse)
│   └── types.ts                 # Shared type definitions
├── test/                        # Vitest test files
│   └── helpers/
│       └── command-harness.ts   # Command-level test helpers (stub LLM / capture stdio)
├── eslint.config.js             # ESLint configuration
├── package.json                 # Project manifest
├── tsconfig.json                # TypeScript configuration
├── tsup.config.ts               # Bundler configuration
└── vitest.config.ts             # Test runner configuration

🤝 Contributing — 贡献指南

We welcome contributions! Here's how to get started:

Development Setup — 开发环境搭建

# 1. Clone the repository
git clone https://github.com/b8nw27v7wp-bit/repo-ai-cli.git
cd repo-ai-cli

# 2. Install dependencies
npm install

# 3. Run tests
npm test

# 4. Run linting
npm run lint

# 5. Run type checking
npm run typecheck

# 6. Build the project
npm run build

# 7. Start development mode (watch)
npm run dev

# 8. Check README ↔ CLI surface consistency (needs a build first)
npm run docs:check

# 9. End-to-end smoke on the built artifact (offline, no API key needed)
npm run e2e

# 10. Coverage (thresholds guard against regressions; see vitest.config.ts)
npm run coverage
npm run coverage:report     # 按行覆盖率升序列出最低的文件,指出该补哪儿

Full gate before pushing — CI runs exactly these on Node 20 and 22:

npm run typecheck && npm run lint && npm run coverage && npm run build && npm run docs:check && npm run e2e

Project Conventions — 项目约定

  • Commit format: Use feat: / fix: / docs: / refactor: / test: / chore: prefixes
  • Code style: TypeScript strict mode; follow existing patterns
  • Testing: All new features should include Vitest tests; CI runs lint + typecheck + test on Node 20/22

Getting Started — 开始贡献

  1. Fork the repository
  2. Create your feature branch: git checkout -b feat/my-feature
  3. Commit your changes: git commit -m "feat: add new feature"
  4. Push to the branch: git push origin feat/my-feature
  5. Open a Pull Request

📝 License — 许可证

This project is licensed under the MIT License. See the LICENSE file for details.


Generated with repo-ai-cli — dogfooding at its finest! 🐶