diffwatch 1.1.2 → 2.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sarfraz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,100 +1,168 @@
1
- # diffwatch
1
+ # DiffWatch
2
2
 
3
- A CLI-based Node.js application that provides a real-time Terminal User Interface (TUI) for monitoring Git repository changes. Watch file statuses and view diffs in a split-pane interface without leaving your terminal.
3
+ A TUI app for watching git repository file changes with diffs.
4
4
 
5
5
  ![Screenshot](screenshot.jpg)
6
6
 
7
7
  ## Features
8
8
 
9
- - **Real-time Monitoring**: Automatically refreshes every 5 seconds to show the latest Git status
10
- - **Split-pane TUI**: Left pane displays files with color-coded status, right pane shows unified diffs
11
- - **Color-coded Status**: Green for added, Red for deleted, Blue for modified, White for untracked
12
- - **Keyboard Navigation**: Use arrow keys to navigate files, Tab to switch panes
13
- - **Git-only Operation**: Works exclusively in Git repositories
14
- - **Cross-platform**: Built with Node.js and TypeScript
9
+ - **File Status Tracking**: Shows all changed files in a Git repository with their status (modified, new, deleted, renamed, etc.)
10
+ - **Visual Diff Viewer**: Displays differences between file versions with syntax highlighting and line-by-line comparison
11
+ - **Interactive Terminal Interface**: Built with React-like components for terminal UI using the @opentui library
12
+ - **Real-time Updates**: Automatically polls for changes in the repository every 2 seconds
13
+ - **File Operations**:
14
+ - Revert changes to files
15
+ - Delete files safely (with trash/recycle bin support)
16
+ - Open files in the default editor
17
+ - **Search Functionality**: Allows searching for files by content within the repository
18
+ - **Commit History Browser**: View commit history with hash, message, author, and date
19
+ - **Keyboard Navigation**: Full keyboard controls for navigating files and diffs
15
20
 
16
21
  ## Installation
17
22
 
18
- ### Global Installation (Recommended)
23
+ **Note:** This package currently supports Windows only. Linux and macOS support coming soon.
24
+
25
+ ### Option 1: Install from npm (recommended)
19
26
 
20
27
  ```bash
21
28
  npm install -g diffwatch
22
29
  ```
23
30
 
24
- ### Local Installation
31
+ Then run from any git repository:
32
+ ```bash
33
+ diffwatch
34
+ ```
25
35
 
36
+ ### Option 2: Install from source
37
+
38
+ 1. Clone the repository:
26
39
  ```bash
27
- git clone <repository-url>
40
+ git clone https://github.com/sarfraznawaz2005/diffwatch.git
28
41
  cd diffwatch
29
- npm install
30
- npm run build
31
- npm link
42
+ ```
43
+
44
+ 2. Install dependencies:
45
+ ```bash
46
+ bun install
32
47
  ```
33
48
 
34
49
  ## Usage
35
50
 
36
- Navigate to any Git repository and run:
51
+ ### Basic Usage
37
52
 
53
+ To watch the current git repository:
38
54
  ```bash
39
- diffwatch [path] [options]
55
+ diffwatch
40
56
  ```
41
57
 
42
- ### Arguments
58
+ To watch a specific git repository:
59
+ ```bash
60
+ diffwatch --path|-p /path/to/repo
61
+ ```
43
62
 
44
- - `path`: Path to the git repository (default: current directory)
63
+ ### Command Line Options
45
64
 
46
- ### Options
65
+ ```bash
66
+ diffwatch [OPTIONS]
67
+ ```
47
68
 
48
- - `-h, --help`: Show help information
69
+ **Options:**
70
+ - `--path <path>` or `-p <path>` - Specify git repository path to watch
71
+ - `--help` or `-h` - Show help message
72
+ - `--version` or `-v` - Show version number
49
73
 
50
- The application will:
51
- 1. Check if the current directory is a Git repository
52
- 2. Display a TUI with two panes
53
- 3. Automatically refresh every 5 seconds
74
+ ### Examples
54
75
 
55
- ### Controls
76
+ Watch the repository in the current directory:
77
+ ```bash
78
+ diffwatch
79
+ ```
56
80
 
57
- - **Arrow Keys / Tab**: Navigate through the file list and scroll in diff pane
58
- - **Enter**: Open selected file in default editor
59
- - **Escape/Q/Ctrl+C**: Exit the application
81
+ Watch a specific project:
82
+ ```bash
83
+ diffwatch --path ~/projects/my-app
84
+ ```
60
85
 
61
- ## Prerequisites
86
+ Check version:
87
+ ```bash
88
+ diffwatch --version
89
+ ```
62
90
 
63
- - Node.js 16 or higher
64
- - Git installed and accessible in PATH
65
- - A terminal that supports TUI applications (most modern terminals)
91
+ Show help:
92
+ ```bash
93
+ diffwatch --help
94
+ ```
95
+
96
+ ## Keyboard Shortcuts
97
+
98
+ - `↑` / `↓` - Navigate through the file list
99
+ - `Tab` / `←` / `→` - Switch between file list and diff view
100
+ - `Enter` - Open selected file in default editor
101
+ - `D` - Delete selected file
102
+ - `R` - Revert changes to selected file
103
+ - `S` - Enter search mode
104
+ - `H` - View commit history
105
+ - `Q` - Quit the application
106
+ - `Esc` - Exit search mode or close dialogs
66
107
 
67
108
  ## Development
68
109
 
110
+ ### Prerequisites
111
+
112
+ - [Bun](https://bun.sh/) - Fast JavaScript runtime and package manager
113
+ - Node.js 18+ (for running published package)
114
+
69
115
  ### Setup
70
116
 
117
+ 1. Clone the repository:
71
118
  ```bash
72
- npm install
73
- npm run build
74
- npm run dev # Run in development mode
75
- npm test # Run tests
119
+ git clone https://github.com/sarfraznawaz2005/diffwatch.git
120
+ cd diffwatch
76
121
  ```
77
122
 
78
- ### Project Structure
79
-
123
+ 2. Install dependencies:
124
+ ```bash
125
+ bun install
80
126
  ```
81
- src/
82
- ├── index.ts # Main application entry point
83
- └── utils/
84
- └── git.ts # Git operations and status handling
85
- tests/
86
- ├── git.test.ts # Unit tests for GitHandler
127
+
128
+ ### Running the App in Development
129
+
130
+ ```bash
131
+ bun run dev
132
+ # or
133
+ bun run start
87
134
  ```
88
135
 
89
136
  ### Building
90
137
 
138
+ To build the application for distribution:
139
+ ```bash
140
+ bun run build
141
+ ```
142
+
143
+ This creates a compiled binary in `dist/` directory.
144
+
145
+ ### Running Tests
146
+
91
147
  ```bash
92
- npm run build # Compile TypeScript to JavaScript
148
+ bun test # Run all tests
149
+ bun test:watch # Run tests in watch mode
150
+ bun test:coverage # Run tests with coverage
151
+ bun test:unit # Run unit tests only
152
+ bun test:integration # Run integration tests only
153
+ bun test:git # Run git-related tests only
154
+ bun test:components # Run component tests only
155
+ bun test:app # Run app integration tests
93
156
  ```
94
157
 
95
- ### Testing
158
+ ### Type Checking
96
159
 
97
160
  ```bash
98
- npm test # Run Jest test suite
161
+ bun run typecheck
162
+ # or
163
+ bun run lint
99
164
  ```
100
165
 
166
+ ## License
167
+
168
+ [MIT](LICENSE)
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawn } from 'child_process';
4
+ import { fileURLToPath } from 'url';
5
+ import { dirname, join } from 'path';
6
+ import { platform } from 'os';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+
11
+ let binary = 'diffwatch';
12
+ if (platform() === 'win32') {
13
+ binary += '.exe';
14
+ }
15
+
16
+ const appPath = join(__dirname, '..', 'dist', binary);
17
+
18
+ const child = spawn(appPath, process.argv.slice(2), {
19
+ stdio: 'inherit',
20
+ cwd: process.cwd()
21
+ });
22
+
23
+ child.on('error', (err) => {
24
+ console.error('Failed to start diffwatch:', err.message);
25
+ process.exit(1);
26
+ });
27
+
28
+ child.on('exit', (code) => {
29
+ process.exit(code);
30
+ });
Binary file
package/package.json CHANGED
@@ -1,40 +1,78 @@
1
1
  {
2
2
  "name": "diffwatch",
3
- "version": "1.1.2",
4
- "description": "An app for watching git repository file changes.",
5
- "author": "Sarfraz Ahmed <sarfraznawaz2005@gmail.com>",
6
- "main": "dist/index.js",
7
- "bin": {
8
- "diffwatch": "dist/index.js"
9
- },
10
- "scripts": {
11
- "build": "tsc",
12
- "start": "node dist/index.js",
13
- "dev": "ts-node src/index.ts",
14
- "test": "jest"
15
- },
3
+ "version": "2.0.0",
4
+ "description": "A TUI app for watching git repository file changes with diffs.",
16
5
  "keywords": [
6
+ "git",
17
7
  "diff",
18
- "watch",
19
- "file",
20
- "comparison",
21
- "utility"
8
+ "terminal",
9
+ "tui",
10
+ "cli",
11
+ "git-gui",
12
+ "git-diff",
13
+ "terminal-ui"
22
14
  ],
15
+ "homepage": "https://github.com/sarfraznawaz2005/diffwatch#readme",
16
+ "bugs": {
17
+ "url": "https://github.com/sarfraznawaz2005/diffwatch/issues"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/sarfraznawaz2005/diffwatch.git"
22
+ },
23
23
  "license": "MIT",
24
- "type": "commonjs",
25
- "dependencies": {
26
- "chalk": "^4.1.2",
27
- "cheerio": "^1.1.2",
28
- "diff2html": "^3.4.55",
29
- "neo-neo-blessed": "^0.7.1",
30
- "simple-git": "^3.30.0"
24
+ "author": "Sarfraz <sarfraznawaz2005@gmail.com>",
25
+ "engines": {
26
+ "node": ">=18.0.0"
31
27
  },
28
+ "bin": {
29
+ "diffwatch": "./bin/diffwatch.js"
30
+ },
31
+ "files": [
32
+ "dist/**/*",
33
+ "bin/**/*",
34
+ "README.md",
35
+ "LICENSE",
36
+ "package.json"
37
+ ],
38
+ "type": "module",
32
39
  "devDependencies": {
33
- "@types/jest": "^30.0.0",
34
- "@types/node": "^25.0.8",
35
- "jest": "^30.2.0",
36
- "ts-jest": "^29.4.6",
37
- "ts-node": "^10.9.2",
40
+ "@types/bun": "latest",
41
+ "@types/node": "^25.0.10",
42
+ "@types/react": "^19.2.9",
43
+ "@types/react-dom": "^19.2.3"
44
+ },
45
+ "peerDependencies": {
38
46
  "typescript": "^5.9.3"
47
+ },
48
+ "dependencies": {
49
+ "@opentui/core": "^0.1.75",
50
+ "@opentui/react": "^0.1.75",
51
+ "@types/diff": "^8.0.0",
52
+ "diff": "^8.0.3",
53
+ "diff2html": "^3.4.55",
54
+ "fuse.js": "^7.1.0",
55
+ "isbinaryfile": "^6.0.0",
56
+ "react": "^19.2.3",
57
+ "react-dom": "^19.2.3",
58
+ "simple-git": "^3.30.0",
59
+ "trash": "^9.0.0"
60
+ },
61
+ "scripts": {
62
+ "build": "bun run build:version && bun build src/index.tsx --compile --outfile dist/diffwatch",
63
+ "build:version": "node -e \"console.log('export const BUILD_VERSION = \\\"' + require('./package.json').version + '\\\";')\" > src/version.ts",
64
+ "dev": "bun run src/index.tsx",
65
+ "start": "bun run src/index.tsx",
66
+ "prepublishOnly": "bun run build",
67
+ "test": "bun test",
68
+ "test:watch": "bun test --watch",
69
+ "test:coverage": "bun test --coverage",
70
+ "test:git": "bun test tests/unit/git.test.ts",
71
+ "test:components": "bun test tests/unit/*.test.ts",
72
+ "test:app": "bun test tests/integration/App.test.ts",
73
+ "test:unit": "bun test tests/unit/",
74
+ "test:integration": "bun test tests/integration/",
75
+ "typecheck": "bun x tsc --noEmit",
76
+ "lint": "bun run typecheck"
39
77
  }
40
78
  }
package/AGENTS.md DELETED
@@ -1,201 +0,0 @@
1
- # DiffWatch Agent Guidelines
2
-
3
- This document provides coding standards and operational guidelines for agentic coding assistants working on the DiffWatch project.
4
-
5
- ## Build, Lint, and Test Commands
6
-
7
- ### Primary Commands
8
- - **Build**: `npm run build` - Compiles TypeScript to JavaScript using `tsc`
9
- - **Test**: `npm test` - Runs Jest test suite
10
- - **Dev**: `npm run dev` - Runs the application in development mode with `ts-node`
11
- - **Start**: `npm start` - Runs the compiled application from `dist/`
12
-
13
- ### Testing Specific Files
14
- - Run a single test file: `npm test -- tests/git.test.ts`
15
- - Run tests matching a pattern: `npm test -- --testNamePattern="should return file status"`
16
-
17
- ### Linting and Type Checking
18
- - **Type Check**: `npx tsc --noEmit` - TypeScript type checking without compilation
19
- - **No explicit linting configured** - TypeScript strict mode serves as the primary code quality gate
20
-
21
- ## Code Style Guidelines
22
-
23
- ### Language and Module System
24
- - **Language**: TypeScript with strict mode enabled
25
- - **Target**: ES6 JavaScript output
26
- - **Module System**: CommonJS output (`"type": "commonjs"` in package.json)
27
- - **Source**: ES6 modules with `import`/`export` syntax
28
-
29
- ### Import/Export Style
30
- ```typescript
31
- // ES6 imports at the top of files
32
- import { simpleGit, SimpleGit, StatusResult } from 'simple-git';
33
- import fs from 'fs/promises';
34
- import chalk from 'chalk';
35
-
36
- // Named exports for utilities
37
- export interface FileStatus {
38
- path: string;
39
- status: 'modified' | 'added' | 'deleted' | 'unstaged' | 'unknown' | 'unchanged';
40
- mtime?: Date;
41
- }
42
-
43
- // Default export for main classes
44
- export class GitHandler {
45
- // ...
46
- }
47
- ```
48
-
49
- ### Naming Conventions
50
- - **Variables/Functions**: camelCase (`filePath`, `getStatus`, `updateFileList`)
51
- - **Classes/Interfaces**: PascalCase (`GitHandler`, `FileStatus`)
52
- - **Constants**: UPPER_CASE (not commonly used in this codebase)
53
- - **Files**: kebab-case for directories (`diff-formatter.ts`), camelCase for utilities
54
- - **Test Files**: Match source filename with `.test.ts` extension (`git.test.ts`)
55
-
56
- ### Code Structure and Patterns
57
- - **Async/Await**: Preferred over Promises for asynchronous operations
58
- - **Error Handling**: Try-catch blocks with descriptive error messages
59
- - **Type Safety**: Use interfaces for data structures, avoid `any` type
60
- - **Class Design**: Private properties with public methods, constructor injection
61
- - **Functional Programming**: Pure functions where possible, avoid side effects
62
-
63
- ### Formatting and Style
64
- - **Indentation**: 2 spaces (no tabs)
65
- - **Semicolons**: Not used (TypeScript ASI)
66
- - **Quotes**: Single quotes for strings (`'string'`)
67
- - **Line Length**: No strict limit, break long lines naturally
68
- - **Blank Lines**: Use sparingly between logical code blocks
69
- - **Comments**: Minimal comments, rely on descriptive naming
70
- - **Braces**: Same line for functions/classes, new line for control structures
71
-
72
- ### Example Code Style
73
- ```typescript
74
- export class GitHandler {
75
- private git: SimpleGit;
76
-
77
- constructor(workingDir: string = process.cwd()) {
78
- this.git = simpleGit(workingDir);
79
- }
80
-
81
- async getStatus(): Promise<FileStatus[]> {
82
- const status: StatusResult = await this.git.status();
83
- const uniqueFiles = new Map<string, FileStatus>();
84
-
85
- status.modified.forEach(path => {
86
- uniqueFiles.set(path, { path, status: 'modified' });
87
- });
88
-
89
- // Process and return sorted results
90
- const fileArray = Array.from(uniqueFiles.values());
91
- return fileArray.sort((a, b) => {
92
- const timeDiff = (b.mtime || new Date(0)).getTime() - (a.mtime || new Date(0)).getTime();
93
- return timeDiff !== 0 ? timeDiff : a.path.localeCompare(b.path);
94
- });
95
- }
96
- }
97
- ```
98
-
99
- ### Error Handling Patterns
100
- ```typescript
101
- async getFileContent(filePath: string): Promise<string> {
102
- try {
103
- return await fs.readFile(filePath, 'utf8');
104
- } catch (error) {
105
- return `Error reading file: ${error}`;
106
- }
107
- }
108
-
109
- async isRepo(): Promise<boolean> {
110
- try {
111
- return await this.git.checkIsRepo();
112
- } catch {
113
- return false;
114
- }
115
- }
116
- ```
117
-
118
- ### Testing Guidelines
119
- - **Framework**: Jest with ts-jest for TypeScript support
120
- - **Mocking**: Mock external dependencies (simple-git, fs/promises)
121
- - **Test Structure**: `describe` blocks for classes, `it` blocks for methods
122
- - **Assertions**: Use Jest matchers (`expect().toBe()`, `expect().toEqual()`)
123
- - **Test Naming**: Descriptive sentences starting with "should"
124
- - **Coverage**: Aim for critical path coverage, especially Git operations
125
-
126
- ```typescript
127
- describe('GitHandler', () => {
128
- let gitHandler: GitHandler;
129
- let mockGit: any;
130
-
131
- beforeEach(() => {
132
- mockGit = { checkIsRepo: jest.fn() };
133
- (simpleGit as jest.Mock).mockReturnValue(mockGit);
134
- gitHandler = new GitHandler();
135
- });
136
-
137
- it('should return true if directory is a repo', async () => {
138
- mockGit.checkIsRepo.mockResolvedValue(true);
139
- const result = await gitHandler.isRepo();
140
- expect(result).toBe(true);
141
- });
142
- });
143
- ```
144
-
145
- ### File Organization
146
- - **Source Code**: `src/` directory with subdirectories for utilities
147
- - **Tests**: `tests/` directory mirroring source structure
148
- - **Build Output**: `dist/` directory (gitignored)
149
- - **Configuration**: Root level for `package.json`, `tsconfig.json`, `jest.config.js`
150
-
151
- ### TypeScript Configuration
152
- - **Strict Mode**: Enabled for type safety
153
- - **Source Maps**: Enabled for debugging
154
- - **Declaration Files**: Generated for library usage
155
- - **Module Resolution**: Node.js style
156
- - **ES Module Interop**: Enabled for compatibility
157
-
158
- ### Dependencies
159
- - **Runtime**: chalk (colors), simple-git (Git operations), neo-neo-blessed (TUI)
160
- - **Dev**: Jest, ts-jest, ts-node, TypeScript
161
- - **Keep dependencies minimal** - only add when necessary for functionality
162
-
163
- ### Git and Version Control
164
- - **Branching**: Feature branches for development
165
- - **Commits**: Descriptive messages focusing on "why" rather than "what"
166
- - **Tags**: Semantic versioning (current: 1.0.8)
167
- - **Hooks**: No custom hooks configured
168
-
169
- ### Security Considerations
170
- - **Input Validation**: Validate file paths and user inputs
171
- - **Error Messages**: Avoid exposing sensitive system information
172
- - **Dependencies**: Keep updated, audit regularly
173
- - **Secrets**: Never commit sensitive data
174
-
175
- ### Performance Guidelines
176
- - **Async Operations**: Use efficient patterns, avoid blocking operations
177
- - **Memory Management**: Clean up resources, avoid memory leaks
178
- - **File I/O**: Handle large files appropriately
179
- - **Real-time Updates**: Debounce rapid operations (150ms in current code)
180
-
181
- ### Code Review Checklist
182
- - [ ] TypeScript compiles without errors
183
- - [ ] Tests pass and cover new functionality
184
- - [ ] Follows established naming and style conventions
185
- - [ ] Error handling appropriate for use case
186
- - [ ] No console.log statements in production code
187
- - [ ] Dependencies justified and minimal
188
- - [ ] Documentation updated if public API changes</content>
189
- <parameter name="filePath">D:\SystemFolders\Downloads\Dev\node\diffwatch\AGENTS.md
190
-
191
- <!-- GENERAL-RULES-RULES-START -->
192
-
193
- ## You must always follow these rules:
194
-
195
- - If you are unsure about any requirement, behavior, or implementation detail, ask clarifying questions **before** writing code.
196
- - At every step, provide a **high-level explanation** of what changes were made and why.
197
- - After implementing changes or new features, always provide a list of **suggestions or improvements**, even if they differ from the user's original request.
198
- - If the user requests a change or feature that is an **anti-pattern** or violates well-established best practices, clearly explain the issue and ask for confirmation before proceeding.
199
- - Always use Context7 MCP when I need library/API documentation, code generation, setup or configuration steps without me having to explicitly ask.
200
-
201
- <!-- GENERAL-RULES-RULES-END -->
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}