{
  "markdown": "<h1 align=\"center\">\n  <img src=\"public/logo.png\" alt=\"difit\" width=\"260\">\n</h1>\n\n<p align=\"center\">\n  <a href=\"https://www.npmjs.com/package/difit\"><img src=\"https://img.shields.io/npm/v/difit.svg\" alt=\"npm version\"></a>\n  <a href=\"https://github.com/yoshiko-pg/difit/actions/workflows/pr.yml\"><img src=\"https://github.com/yoshiko-pg/difit/actions/workflows/pr.yml/badge.svg\" alt=\"CI\"></a>\n</p>\n\n<p align=\"center\">\n  English | <a href=\"./README.ja.md\">日本語</a> | <a href=\"./README.zh.md\">简体中文</a> | <a href=\"./README.ko.md\">한국어</a>\n</p>\n\n![difit screenshot](docs/images/screenshot.png)\n\n**difit** is a CLI tool that lets you view and review local git diffs with a GitHub-style viewer. In addition to clean visuals, comments can be copied as prompts for AI. The local code review tool for the AI era!\n\n## ⚡ Quick Start\n\nTry it first\n\n```bash\nnpx difit  # View the latest commit diff in WebUI\n```\n\nInstall and use\n\n```bash\nnpm install -g difit\ndifit  # View the latest commit diff in WebUI\n```\n\nEnable use from AI agents\n\n```bash\nnpx skills add yoshiko-pg/difit # Add the Skills to your agent\n```\n\nInstalled skills include:\n\n- `difit`: ask the user for a review in the difit viewer when the user explicitly opts in to difit\n- `difit-review`: review a specific diff or PR and show the findings inside the difit viewer, when the user explicitly asks for difit\n\n## 🚀 Usage\n\n### Basic Usage\n\n```bash\ndifit <target>                    # View single commit diff\ndifit <target> [compare-with]     # Compare two commits/branches\n```\n\n### Single commit review\n\n```bash\ndifit          # HEAD (latest) commit\ndifit 6f4a9b7  # Specific commit\ndifit feature  # Latest commit on feature branch\n```\n\n### Compare two commits\n\n```bash\ndifit @ main         # Compare with main branch (@ is alias for HEAD)\ndifit feature main   # Compare branches\ndifit . origin/main  # Compare working directory with remote main\n```\n\n### Special Arguments\n\ndifit supports special keywords for common diff scenarios:\n\n```bash\ndifit .        # All uncommitted changes (staging area + unstaged)\ndifit staged   # Staging area changes\ndifit working  # Unstaged changes only\n```\n\n### GitHub PR\n\n```bash\ndifit --pr https://github.com/owner/repo/pull/123\n```\n\n`--pr` mode fetches patches by running `gh pr diff --patch` under the hood.\nIt also imports unresolved inline review threads from the PR so they appear as startup comments in difit.\n\nAuthentication is handled by GitHub CLI:\n\n1. **Login once** (recommended): `gh auth login`\n2. **Token-based auth** (CI/non-interactive): set `GH_TOKEN` or `GITHUB_TOKEN`\n\n#### GitHub Enterprise Server\n\nFor Enterprise Server PRs, authenticate GitHub CLI against your Enterprise host:\n\n1. `gh auth login --hostname YOUR-ENTERPRISE-SERVER`\n2. Or set `GH_HOST=YOUR-ENTERPRISE-SERVER` with `GH_TOKEN`/`GITHUB_TOKEN`\n\n### Initial Comments\n\nYou can inject initial review comments when launching difit:\n\n```bash\ndifit --comment '{\"type\":\"thread\",\"filePath\":\"src/example.ts\",\"position\":{\"side\":\"new\",\"line\":10},\"body\":\"The background for this change is...\"}'\n```\n\n`--comment` is repeatable and accepts either a single JSON object or a JSON array. Supported types:\n\n- `thread`: create a new thread at the specified diff position\n- `reply`: add a reply to the latest existing thread at the same diff position\n\nIf the same comment already exists, difit skips importing it.\n\n### Stdin\n\nBy using a pipe to pass unified diffs via stdin, you can view diffs from any tool with difit.\n\n```bash\n# View diffs from other tools\ndiff -u file1.txt file2.txt | difit\n\n# Review saved patches\ncat changes.patch | difit\n\n# Compare against merge base\ngit diff --merge-base main feature | difit\n\n# Review an entire existing file as newly added\ngit diff -- /dev/null path/to/file | difit\n\n# Explicit stdin mode\ngit diff --cached | difit -\n```\n\nStdin mode is selected with intent-first rules:\n\n- `-` explicitly enables stdin mode\n- If positional arguments (`<target>` / `[compare-with]`) or `--pr` are provided, difit treats the command as Git/PR mode and does not auto-read stdin\n- Auto stdin detection applies only when no explicit mode is selected and stdin is a pipe/file/socket\n\n## ⚙️ CLI Options\n\n| Flag                  | Default         | Description                                                                                             |\n| --------------------- | --------------- | ------------------------------------------------------------------------------------------------------- |\n| `<target>`            | HEAD            | Commit hash, tag, HEAD~n, branch, or special arguments                                                  |\n| `[compare-with]`      | -               | Optional second commit to compare with (shows diff between the two)                                     |\n| `--merge-base`        | false           | Resolve the base revision with `git merge-base` before diffing (Git revision mode only)                 |\n| `--pr <url>`          | -               | GitHub PR URL to review (e.g., https://github.com/owner/repo/pull/123)                                  |\n| `--comment <json>`    | -               | Inject initial comments (repeatable; accepts a JSON object or array)                                    |\n| `--port`              | 4966            | Preferred port; falls back to +1 if occupied                                                            |\n| `--host`              | 127.0.0.1       | Host address to bind server to (use 0.0.0.0 for external access)                                        |\n| `--no-open`           | false           | Don't automatically open browser                                                                        |\n| `--clean`             | false           | Clear all existing comments and viewed files on startup                                                 |\n| `--include-untracked` | false           | Automatically include untracked files in diff (only with `.` or `working`)                              |\n| `--keep-alive`        | false           | Keep server running after browser disconnects (stop manually with Ctrl+C)                               |\n| `--background`        | false           | Keep the server running in the background and output JSON connection info                               |\n| `--context <lines>`   | git default (3) | Limit surrounding context lines per change (`0` shows changes only; not available with `--pr` or stdin) |\n\n## 💬 Comment System\n\ndifit includes a review comment system that makes it easy to provide feedback to AI coding agents:\n\n1. **Add Comments**: Click the comment button on any diff line or drag to select a range\n2. **Edit Comments**: Edit existing comments with the edit button\n3. **Generate Prompts**: Comments include a \"Copy Prompt\" button that formats the context for AI coding agents\n4. **Copy All**: Use \"Copy All Prompt\" to copy all comments in a structured format\n5. **Persistent Storage**: Comments are saved in browser localStorage per commit\n\n### Comment Prompt Format\n\n```sh\nsrc/components/Button.tsx:L42   # This line is automatically added\nMake this variable name more descriptive\n```\n\nFor range selections:\n\n```sh\nsrc/components/Button.tsx:L42-L48   # This line is automatically added\nThis section is unnecessary\n```\n\n## 🤖 Calling from Agents\n\nYou can install the following Skills to work with difit from AI agents.\n\n```sh\nnpx skills add yoshiko-pg/difit\n```\n\nInstalled skills include:\n\n- `difit`: ask the user for a review in the difit viewer when the user explicitly opts in to difit\n- `difit-review`: review a specific diff or PR and show the findings inside the difit viewer, when the user explicitly asks for difit\n\nAfter code edits or automated review, the agent can start the difit server with the appropriate skill.\n\n## 🎨 Syntax Highlighting Languages\n\n- **JavaScript/TypeScript**: `.js`, `.jsx`, `.ts`, `.tsx`, `.svelte`\n- **Web Technologies**: HTML, CSS, JSON, XML, Markdown\n- **Shell Scripts**: `.sh`, `.bash`, `.zsh`, `.fish`\n- **Backend Languages**: PHP, SQL, Ruby, Java, Groovy, Scala, Perl, Elixir, Haskell, Clojure\n- **Systems Languages**: C, C++, C#, Rust, Go\n- **Mobile Languages**: Swift, Kotlin, Dart\n- **Infrastructure as Code**: Terraform (HCL), Nix\n- **Others**: Python, Protobuf, YAML, Solidity, Vim script, GDScript\n\n## 🔍 Auto-collapsed Files\n\ndifit automatically identifies and collapses certain files to keep your view clean:\n\n- **Deleted files**: Removed files are auto-collapsed since they don't require close review\n- **Generated files**: Auto-generated code is collapsed by default. This includes:\n  - Lock files (`package-lock.json`, `go.sum`, `Cargo.lock`, `Gemfile.lock`, etc.)\n  - Minified files (`*.min.js`, `*.min.css`)\n  - Source maps (`*.map`)\n  - Generated code:\n    - Orval (`*.msw.ts`, `*.zod.ts`, `*.api.ts`)\n    - Dart (`*.g.dart`, `*.freezed.dart`)\n    - C# (`*.g.cs`, `*.designer.cs`)\n    - Protobuf (`*.pb.go`, `*.pb.cc`, `*.pb.h`)\n  - Frameworks:\n    - Ruby on Rails (`db/schema.rb`)\n    - Laravel (`_ide_helper.php`)\n    - Gradle (`gradle.lockfile`)\n    - Python (`uv.lock`, `pdm.lock`)\n  - Generic generated files (`*.generated.cs`, `*.generated.ts`, `*.generated.js`)\n  - Content-based detection:\n    - Files containing `@generated` marker\n    - Files containing `DO NOT EDIT` header\n    - Language-specific generated headers (Go, Python, etc.)\n\n## 🛠️ Development\n\n```bash\n# Install dependencies\npnpm install\n\n# Start development server (with hot reload)\n# This runs both Vite dev server and CLI with NODE_ENV=development\npnpm run dev\n\n# Build and start production server\npnpm run start <target>\n\n# Build for production\npnpm run build\n\n# Run tests\npnpm test\n\n# Run typecheck, lint, and format\npnpm run check\npnpm run format\n```\n\n### Development Workflow\n\n- **`pnpm run dev`**: Starts both Vite dev server (with hot reload) and CLI server simultaneously\n- **`pnpm run start <target>`**: Builds everything and starts production server (for testing final build)\n- **Development mode**: Uses Vite's dev server for hot reload and fast development\n- **Production mode**: Serves built static files (used by npx and production builds)\n\n## 🏗️ Architecture\n\n- **CLI**: Commander.js for argument parsing with comprehensive validation\n- **Backend**: Express server with simple-git for diff processing\n- **GitHub Integration**: GitHub CLI (`gh pr diff --patch`) for PR patch retrieval\n- **Frontend**: React 18 + TypeScript + Vite\n- **Styling**: Tailwind CSS v4 with GitHub-like dark theme\n- **Syntax Highlighting**: Prism.js with dynamic language loading\n- **Testing**: Vitest for unit tests with co-located test files\n- **Quality**: oxlint, oxfmt, lefthook pre-commit hooks\n\n## 📋 Requirements\n\n- Node.js ≥ 21.0.0\n- Git repository with commits to review\n- GitHub CLI (`gh`) for `--pr` mode\n\n## 📄 License\n\nMIT\n",
  "bytes": 10788,
  "sha": "d9aa5cfd4bb0398990ea46a3943f8b3d146abc777044a7ccb30094f842db2149",
  "repo_slug": "yoshiko-pg/difit",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/skl_yoshiko_pg_difit_difit_review_a90e1649/readme"
}