@heyhuynhgiabuu/pi-diff 0.1.1 → 0.1.2
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 +75 -1
- package/biome.json +20 -15
- package/package.json +50 -50
- package/src/index.ts +608 -169
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# pi-diff
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@heyhuynhgiabuu/pi-diff)
|
|
4
|
+
[](https://github.com/heyhuynhgiabuu/pi-diff/releases/latest)
|
|
5
|
+
|
|
3
6
|
A [pi](https://pi.dev) extension that replaces the default `write` and `edit` tool output with **Shiki-powered, syntax-highlighted diffs** — side-by-side split view, unified stacked view, and word-level change emphasis, all rendered directly in your terminal.
|
|
4
7
|
|
|
5
8
|
> **Status:** Early release.
|
|
@@ -30,6 +33,8 @@ A [pi](https://pi.dev) extension that replaces the default `write` and `edit` to
|
|
|
30
33
|
pi install npm:@heyhuynhgiabuu/pi-diff
|
|
31
34
|
```
|
|
32
35
|
|
|
36
|
+
Latest release: https://github.com/heyhuynhgiabuu/pi-diff/releases/latest
|
|
37
|
+
|
|
33
38
|
Or load directly for development:
|
|
34
39
|
|
|
35
40
|
```bash
|
|
@@ -71,7 +76,76 @@ Both views show:
|
|
|
71
76
|
|
|
72
77
|
## Configuration
|
|
73
78
|
|
|
74
|
-
|
|
79
|
+
### Diff Theme Presets
|
|
80
|
+
|
|
81
|
+
pi-diff ships with built-in theme presets optimized for different terminal backgrounds. Add to your `.pi/settings.json`:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"theme": "dark",
|
|
86
|
+
"diffTheme": "midnight"
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
| Preset | Best for | Description |
|
|
91
|
+
|--------|----------|-------------|
|
|
92
|
+
| `default` | Dark theme bases (~`#1e1e2e`) | Original pi-diff colors — balanced contrast |
|
|
93
|
+
| `midnight` | Pure black (`#000000`) terminals | Subtle tints that don't overwhelm on black |
|
|
94
|
+
| `subtle` | Any dark theme | Minimal backgrounds — barely-there tints for a clean look |
|
|
95
|
+
| `neon` | Low-contrast displays | Higher contrast backgrounds for better visibility |
|
|
96
|
+
|
|
97
|
+
### Per-Color Overrides
|
|
98
|
+
|
|
99
|
+
Override individual diff colors in `.pi/settings.json` using hex `#RRGGBB` values:
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"theme": "dark",
|
|
104
|
+
"diffTheme": "midnight",
|
|
105
|
+
"diffColors": {
|
|
106
|
+
"bgAdd": "#0d1a12",
|
|
107
|
+
"bgDel": "#1a0d0d",
|
|
108
|
+
"bgAddHighlight": "#1a3825",
|
|
109
|
+
"bgDelHighlight": "#381a1a",
|
|
110
|
+
"bgGutterAdd": "#091208",
|
|
111
|
+
"bgGutterDel": "#120908",
|
|
112
|
+
"bgEmpty": "#080808",
|
|
113
|
+
"fgAdd": "#64b478",
|
|
114
|
+
"fgDel": "#c86464",
|
|
115
|
+
"fgDim": "#404040",
|
|
116
|
+
"fgLnum": "#505050",
|
|
117
|
+
"fgRule": "#282828",
|
|
118
|
+
"fgStripe": "#1e1e1e",
|
|
119
|
+
"fgSafeMuted": "#8b949e",
|
|
120
|
+
"shikiTheme": "github-dark"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`diffColors` overrides take priority over `diffTheme` presets, so you can start from a preset and tweak individual colors.
|
|
126
|
+
|
|
127
|
+
### Auto-Derive (Default Behavior)
|
|
128
|
+
|
|
129
|
+
When no `diffTheme` or `diffColors` is set, pi-diff **automatically derives** background colors from your pi theme's diff foreground colors. This ensures diffs look good with any pi theme and terminal background — no configuration needed.
|
|
130
|
+
|
|
131
|
+
The auto-derive uses different intensity levels:
|
|
132
|
+
- **Line backgrounds**: 8–10% of the theme's diff fg color (subtle tint)
|
|
133
|
+
- **Word highlights**: 20–22% (more visible for changed characters)
|
|
134
|
+
- **Gutters**: 5–6% (subtler than line backgrounds)
|
|
135
|
+
|
|
136
|
+
### Color Resolution Order
|
|
137
|
+
|
|
138
|
+
For each color, pi-diff checks (highest priority first):
|
|
139
|
+
|
|
140
|
+
1. **Environment variable** — e.g. `DIFF_BG_ADD="#1a3320"` (backward compatible)
|
|
141
|
+
2. **`diffColors`** from `.pi/settings.json` (per-color hex overrides)
|
|
142
|
+
3. **`diffTheme` preset** from `.pi/settings.json` (named preset bundle)
|
|
143
|
+
4. **Auto-derived** from pi theme's `toolDiffAdded`/`toolDiffRemoved` colors
|
|
144
|
+
5. **Hardcoded fallback** (original defaults)
|
|
145
|
+
|
|
146
|
+
### Environment Variables
|
|
147
|
+
|
|
148
|
+
All settings are also controllable via environment variables. Add them to your shell profile or `.envrc`:
|
|
75
149
|
|
|
76
150
|
### Theme
|
|
77
151
|
|
package/biome.json
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.4.8/schema.json",
|
|
3
|
+
"assist": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"actions": {
|
|
6
|
+
"source": {
|
|
7
|
+
"organizeImports": "on"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"linter": {
|
|
12
|
+
"enabled": true,
|
|
13
|
+
"rules": {
|
|
14
|
+
"recommended": true
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"formatter": {
|
|
18
|
+
"enabled": true,
|
|
19
|
+
"indentStyle": "tab",
|
|
20
|
+
"lineWidth": 120
|
|
21
|
+
}
|
|
17
22
|
}
|
package/package.json
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
2
|
+
"name": "@heyhuynhgiabuu/pi-diff",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Shiki-powered terminal diff renderer for pi — syntax-highlighted, word-level diffs in split and unified views.",
|
|
5
|
+
"author": "huynhgiabuu",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/heyhuynhgiabuu/pi-diff.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/heyhuynhgiabuu/pi-diff#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/heyhuynhgiabuu/pi-diff/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"pi-package",
|
|
17
|
+
"pi",
|
|
18
|
+
"pi-extension",
|
|
19
|
+
"diff",
|
|
20
|
+
"syntax-highlighting",
|
|
21
|
+
"shiki",
|
|
22
|
+
"terminal"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"diff": "^7.0.0",
|
|
26
|
+
"@shikijs/cli": "^4.0.2"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@mariozechner/pi-coding-agent": "*",
|
|
30
|
+
"@mariozechner/pi-tui": "*"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/diff": "^7.0.2",
|
|
34
|
+
"@types/node": "^20.0.0",
|
|
35
|
+
"typescript": "^5.0.0",
|
|
36
|
+
"@biomejs/biome": "^2.3.5",
|
|
37
|
+
"vitest": "^4.0.18"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"lint": "biome check src/",
|
|
43
|
+
"lint:fix": "biome check --fix src/",
|
|
44
|
+
"test": "vitest run --passWithNoTests",
|
|
45
|
+
"test:watch": "vitest --passWithNoTests"
|
|
46
|
+
},
|
|
47
|
+
"pi": {
|
|
48
|
+
"extensions": [
|
|
49
|
+
"./src/index.ts"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
52
|
}
|