difit 1.0.7 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,51 +11,104 @@ A lightweight command-line tool that spins up a local web server to display Git
11
11
  - šŸŒ™ **GitHub-like UI**: Familiar dark theme file list and diff interface
12
12
  - šŸ’¬ **Inline Comments**: Add comments to specific lines and generate Claude Code prompts
13
13
  - šŸ”„ **Side-by-Side & Inline Views**: Choose your preferred diff viewing mode
14
+ - šŸ–„ļø **Terminal UI Mode**: View diffs directly in your terminal with `--tui` flag
14
15
  - ⚔ **Zero Config**: Just run `npx reviewit <commit>` and it works
15
16
  - šŸ” **Local Only**: Never exposes data over network - runs on localhost only
16
17
  - šŸ› ļø **Modern Stack**: React 18 + TypeScript + Tailwind CSS
18
+ - šŸŽØ **Syntax Highlighting**: Dynamic language loading for Bash, PHP, SQL, Ruby, Java, and more
17
19
  - ✨ **100% vibe coding**: Built with pure coding energy and good vibes
18
20
 
19
21
  ## šŸ“¦ Installation
20
22
 
21
23
  ```bash
22
- # Global install
23
- npm install -g reviewit
24
-
25
- # Or use npx (no installation needed)
24
+ # use npx (no installation needed)
26
25
  npx reviewit <commit-ish>
26
+
27
+ # or Global install
28
+ npm install -g reviewit
27
29
  ```
28
30
 
29
31
  ## šŸš€ Usage
30
32
 
31
33
  ```bash
32
- # Review a specific commit
33
- reviewit 6f4a9b7
34
+ # default: HEAD commit changes
35
+ npx reviewit
34
36
 
35
- # Review HEAD~3
36
- reviewit HEAD~3
37
+ # Review a specific commit changes
38
+ npx reviewit 6f4a9b7
39
+ npx reviewit HEAD^
40
+ npx reviewit HEAD~3
37
41
 
38
- # Review uncommitted changes (working directory)
39
- reviewit .
42
+ # Special Arguments
43
+ npx reviewit staging # staging area changes
44
+ npx reviewit working # working directory changes
45
+ npx reviewit . # uncommited all changes
40
46
 
41
47
  # Custom port, don't auto-open browser
42
- reviewit 6f4a9b7 --port 4300 --no-open
48
+ npx reviewit 6f4a9b7 --port 4300 --no-open
43
49
 
44
- # Via npx
45
- npx reviewit main~1
46
- npx reviewit . # uncommitted changes
50
+ # Terminal UI mode (no browser)
51
+ npx reviewit --tui
52
+ npx reviewit working --tui
47
53
  ```
48
54
 
49
55
  ### āš™ļø CLI Options
50
56
 
51
- | Flag | Default | Description |
52
- | -------------- | ---------- | ---------------------------------------------------- |
53
- | `<commit-ish>` | (required) | Any Git reference: hash, tag, HEAD~n, branch, or `.` |
54
- | `--port` | auto | Preferred port; falls back if occupied |
55
- | `--no-open` | false | Don't automatically open browser |
56
- | `--mode` | inline | Diff mode: `inline` or `side-by-side` |
57
+ | Flag | Default | Description |
58
+ | -------------- | ------------ | ------------------------------------------------------------------ |
59
+ | `<commit-ish>` | (required) | Any Git reference: hash, tag, HEAD~n, branch, or Special Arguments |
60
+ | `--port` | auto | Preferred port; falls back if occupied |
61
+ | `--no-open` | false | Don't automatically open browser |
62
+ | `--mode` | side-by-side | Diff mode: `inline` or `side-by-side` |
63
+ | `--tui` | false | Use terminal UI mode instead of web interface |
64
+
65
+ ### šŸ”‘ Special Arguments
66
+
67
+ ReviewIt supports special arguments for common diff scenarios:
68
+
69
+ | Keyword | Description |
70
+ | --------- | ------------------------------------------------------ |
71
+ | `working` | Shows unstaged changes in your working directory |
72
+ | `staged` | Shows staged changes ready to be committed |
73
+ | `.` | Shows all uncommitted changes (both staged & unstaged) |
74
+
75
+ ## šŸ’¬ Comment System
76
+
77
+ ReviewIt includes an inline commenting system that integrates with Claude Code:
78
+
79
+ 1. **Add Comments**: Click on any diff line to add a comment
80
+ 2. **Edit Comments**: Edit existing comments with the edit button
81
+ 3. **Generate Prompts**: Comments include a "Copy Prompt" button that formats the context for Claude Code
82
+ 4. **Copy All**: Use "Copy All Prompt" to copy all comments in a structured format
83
+ 5. **Persistent Storage**: Comments are saved in browser localStorage per commit
84
+
85
+ ### Comment Prompt Format
86
+
87
+ ```
88
+ File: src/components/Button.tsx
89
+ Line: 42
90
+ Comment: This function name should probably be more specific
91
+ ```
92
+
93
+ ## šŸŽØ Syntax Highlighting
94
+
95
+ ReviewIt supports syntax highlighting for multiple programming languages with dynamic loading:
96
+
97
+ ### Supported Languages
98
+
99
+ - **JavaScript/TypeScript**: `.js`, `.jsx`, `.ts`, `.tsx`
100
+ - **Web Technologies**: HTML, CSS, JSON, XML, Markdown
101
+ - **Shell Scripts**: `.sh`, `.bash`, `.zsh`, `.fish` files
102
+ - **Backend Languages**: PHP, SQL, Ruby, Java
103
+ - **Systems Languages**: C, C++, Rust, Go
104
+ - **Others**: Python, Swift, Kotlin, YAML
105
+
106
+ ### Dynamic Language Loading
57
107
 
58
- > **Note**: Use `.` as the commit-ish to review uncommitted changes in your working directory!
108
+ - Languages are loaded on-demand for better performance
109
+ - Automatic language detection from file extensions
110
+ - Fallback to plain text for unsupported languages
111
+ - Safe dependency resolution (e.g., PHP requires markup-templating)
59
112
 
60
113
  ## šŸ› ļø Development
61
114
 
@@ -94,30 +147,13 @@ pnpm run typecheck
94
147
  - **Development mode**: Uses Vite's dev server for hot reload and fast development
95
148
  - **Production mode**: Serves built static files (used by npx and production builds)
96
149
 
97
- ## šŸ’¬ Comment System
98
-
99
- ReviewIt includes an inline commenting system that integrates with Claude Code:
100
-
101
- 1. **Add Comments**: Click on any diff line to add a comment
102
- 2. **Edit Comments**: Edit existing comments with the edit button
103
- 3. **Generate Prompts**: Comments include a "Copy Prompt" button that formats the context for Claude Code
104
- 4. **Copy All**: Use "Copy All Prompt" to copy all comments in a structured format
105
- 5. **Persistent Storage**: Comments are saved in browser localStorage per commit
106
-
107
- ### Comment Prompt Format
108
-
109
- ```
110
- File: src/components/Button.tsx
111
- Line: 42
112
- Comment: This function name should probably be more specific
113
- ```
114
-
115
150
  ## šŸ—ļø Architecture
116
151
 
117
152
  - **CLI**: Commander.js for argument parsing
118
153
  - **Backend**: Express server with simple-git for diff processing
119
154
  - **Frontend**: React 18 + TypeScript + Vite
120
155
  - **Styling**: Tailwind CSS v4 with GitHub-like dark theme
156
+ - **Syntax Highlighting**: Prism.js with dynamic language loading
121
157
  - **Testing**: Vitest for unit tests
122
158
  - **Quality**: ESLint, Prettier, lefthook pre-commit hooks
123
159
 
package/dist/cli/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from 'commander';
3
+ import React from 'react';
3
4
  import pkg from '../../package.json' with { type: 'json' };
4
5
  import { startServer } from '../server/server.js';
5
6
  import { validateCommitish } from './utils.js';
@@ -8,24 +9,50 @@ program
8
9
  .name('reviewit')
9
10
  .description('A lightweight Git diff viewer with GitHub-like interface')
10
11
  .version(pkg.version)
11
- .argument('[commit-ish]', 'Git commit, tag, branch, or HEAD~n reference (default: HEAD)', 'HEAD')
12
+ .argument('[commit-ish]', 'Git commit, tag, branch, HEAD~n reference, or "working"/"staged"/"." (default: HEAD)', 'HEAD')
12
13
  .option('--port <port>', 'preferred port (auto-assigned if occupied)', parseInt)
13
14
  .option('--no-open', 'do not automatically open browser')
14
15
  .option('--mode <mode>', 'diff mode (inline only for now)', 'inline')
16
+ .option('--tui', 'use terminal UI instead of web interface')
15
17
  .action(async (commitish, options) => {
16
18
  try {
17
- if (!validateCommitish(commitish)) {
19
+ // Determine what to show
20
+ let targetCommitish = commitish;
21
+ // Handle special arguments
22
+ if (commitish === 'working') {
23
+ targetCommitish = 'working';
24
+ }
25
+ else if (commitish === 'staged') {
26
+ targetCommitish = 'staged';
27
+ }
28
+ else if (commitish === '.') {
29
+ targetCommitish = '.';
30
+ }
31
+ if (options.tui) {
32
+ // Check if we're in a TTY environment
33
+ if (!process.stdin.isTTY) {
34
+ console.error('Error: TUI mode requires an interactive terminal (TTY).');
35
+ console.error('Try running the command directly in your terminal without piping.');
36
+ process.exit(1);
37
+ }
38
+ // Dynamic import for TUI mode
39
+ const { render } = await import('ink');
40
+ const { default: TuiApp } = await import('../tui/App.js');
41
+ render(React.createElement(TuiApp, { commitish: targetCommitish }));
42
+ return;
43
+ }
44
+ if (!validateCommitish(targetCommitish)) {
18
45
  console.error('Error: Invalid commit-ish format');
19
46
  process.exit(1);
20
47
  }
21
48
  const { url } = await startServer({
22
- commitish,
49
+ commitish: targetCommitish,
23
50
  preferredPort: options.port,
24
51
  openBrowser: options.open,
25
52
  mode: options.mode,
26
53
  });
27
54
  console.log(`\nšŸš€ ReviewIt server started on ${url}`);
28
- console.log(`šŸ“‹ Reviewing: ${commitish}`);
55
+ console.log(`šŸ“‹ Reviewing: ${targetCommitish}`);
29
56
  if (options.open) {
30
57
  console.log('🌐 Opening browser...\n');
31
58
  }
package/dist/cli/utils.js CHANGED
@@ -10,8 +10,8 @@ export function validateCommitish(commitish) {
10
10
  if (trimmed === 'HEAD~') {
11
11
  return false;
12
12
  }
13
- if (trimmed === '.') {
14
- return true; // Allow '.' for working directory diff
13
+ if (trimmed === '.' || trimmed === 'working' || trimmed === 'staged') {
14
+ return true; // Allow special keywords for working directory and staging area diff
15
15
  }
16
16
  const validPatterns = [
17
17
  /^[a-f0-9]{4,40}$/i, // SHA hashes