claude-code-plus-plus 0.3.0 → 0.4.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/dist/constants.d.ts +6 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +7 -2
- package/dist/constants.js.map +1 -1
- package/dist/diff/diff-handler.d.ts +15 -0
- package/dist/diff/diff-handler.d.ts.map +1 -0
- package/dist/diff/diff-handler.js +235 -0
- package/dist/diff/diff-handler.js.map +1 -0
- package/dist/diff/diff-manager.d.ts +63 -0
- package/dist/diff/diff-manager.d.ts.map +1 -0
- package/dist/diff/diff-manager.js +271 -0
- package/dist/diff/diff-manager.js.map +1 -0
- package/dist/diff/diff-pane-render.d.ts +34 -0
- package/dist/diff/diff-pane-render.d.ts.map +1 -0
- package/dist/diff/diff-pane-render.js +222 -0
- package/dist/diff/diff-pane-render.js.map +1 -0
- package/dist/diff/file-diff-content-handler.d.ts +16 -0
- package/dist/diff/file-diff-content-handler.d.ts.map +1 -0
- package/dist/diff/file-diff-content-handler.js +142 -0
- package/dist/diff/file-diff-content-handler.js.map +1 -0
- package/dist/diff/file-diff-header-handler.d.ts +16 -0
- package/dist/diff/file-diff-header-handler.d.ts.map +1 -0
- package/dist/diff/file-diff-header-handler.js +191 -0
- package/dist/diff/file-diff-header-handler.js.map +1 -0
- package/dist/diff/file-diff-header-render.d.ts +30 -0
- package/dist/diff/file-diff-header-render.d.ts.map +1 -0
- package/dist/diff/file-diff-header-render.js +101 -0
- package/dist/diff/file-diff-header-render.js.map +1 -0
- package/dist/diff/file-diff-render.d.ts +27 -0
- package/dist/diff/file-diff-render.d.ts.map +1 -0
- package/dist/diff/file-diff-render.js +211 -0
- package/dist/diff/file-diff-render.js.map +1 -0
- package/dist/diff/git-diff.d.ts +54 -0
- package/dist/diff/git-diff.d.ts.map +1 -0
- package/dist/diff/git-diff.js +599 -0
- package/dist/diff/git-diff.js.map +1 -0
- package/dist/diff/index.d.ts +8 -0
- package/dist/diff/index.d.ts.map +1 -0
- package/dist/diff/index.js +37 -0
- package/dist/diff/index.js.map +1 -0
- package/dist/sidebar/app.d.ts +69 -0
- package/dist/sidebar/app.d.ts.map +1 -1
- package/dist/sidebar/app.js +508 -10
- package/dist/sidebar/app.js.map +1 -1
- package/dist/sidebar/commands.d.ts +1 -0
- package/dist/sidebar/commands.d.ts.map +1 -1
- package/dist/sidebar/commands.js +11 -0
- package/dist/sidebar/commands.js.map +1 -1
- package/dist/sidebar/pane-orchestrator.d.ts.map +1 -1
- package/dist/sidebar/pane-orchestrator.js +10 -1
- package/dist/sidebar/pane-orchestrator.js.map +1 -1
- package/dist/sidebar/render.d.ts.map +1 -1
- package/dist/sidebar/render.js +2 -1
- package/dist/sidebar/render.js.map +1 -1
- package/dist/tmux/index.d.ts +1 -1
- package/dist/tmux/index.d.ts.map +1 -1
- package/dist/tmux/index.js +2 -1
- package/dist/tmux/index.js.map +1 -1
- package/dist/tmux/pane.d.ts +5 -0
- package/dist/tmux/pane.d.ts.map +1 -1
- package/dist/tmux/pane.js +10 -0
- package/dist/tmux/pane.js.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* File Diff Content Handler
|
|
5
|
+
*
|
|
6
|
+
* Process that runs in the file diff content pane.
|
|
7
|
+
* - Prints file content based on view mode (full file with inline diffs or diffs only)
|
|
8
|
+
* - Uses native tmux scrollback (mouse scroll works)
|
|
9
|
+
* - Handles Esc key to close (sends FILEDIFF:close to sidebar)
|
|
10
|
+
*
|
|
11
|
+
* Communication:
|
|
12
|
+
* - Sends actions to sidebar via tmux send-keys
|
|
13
|
+
*
|
|
14
|
+
* Usage: node file-diff-content-handler.js <sidebarPaneId> <repoPath> <filename> [mode]
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const child_process_1 = require("child_process");
|
|
18
|
+
const ansi_1 = require("../ansi");
|
|
19
|
+
const git_diff_1 = require("./git-diff");
|
|
20
|
+
let state = {
|
|
21
|
+
sidebarPaneId: '',
|
|
22
|
+
repoPath: '',
|
|
23
|
+
filename: '',
|
|
24
|
+
mode: 'whole-file',
|
|
25
|
+
};
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Communication with Sidebar
|
|
28
|
+
// ============================================================================
|
|
29
|
+
/**
|
|
30
|
+
* Send a command to the sidebar via tmux send-keys
|
|
31
|
+
* Protocol: Ctrl+U followed by "FILEDIFF:<action>" then Enter
|
|
32
|
+
*/
|
|
33
|
+
function sendToSidebar(action) {
|
|
34
|
+
try {
|
|
35
|
+
// Send Ctrl+U to clear any existing input and enter command mode
|
|
36
|
+
(0, child_process_1.execSync)(`tmux send-keys -t ${state.sidebarPaneId} C-u`, { stdio: 'ignore' });
|
|
37
|
+
// Send the command
|
|
38
|
+
const cmd = `FILEDIFF:${action}`;
|
|
39
|
+
(0, child_process_1.execSync)(`tmux send-keys -t ${state.sidebarPaneId} -l "${cmd}"`, { stdio: 'ignore' });
|
|
40
|
+
// Send Enter to execute
|
|
41
|
+
(0, child_process_1.execSync)(`tmux send-keys -t ${state.sidebarPaneId} Enter`, { stdio: 'ignore' });
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
// Failed to send - sidebar may have exited
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// Content Display
|
|
49
|
+
// ============================================================================
|
|
50
|
+
/**
|
|
51
|
+
* Print file content to terminal
|
|
52
|
+
* Content goes into tmux scrollback buffer for native mouse scrolling
|
|
53
|
+
*/
|
|
54
|
+
async function printContent() {
|
|
55
|
+
// Clear screen and move to top before printing
|
|
56
|
+
process.stdout.write('\x1b[2J\x1b[H');
|
|
57
|
+
try {
|
|
58
|
+
let content;
|
|
59
|
+
if (state.mode === 'diffs-only') {
|
|
60
|
+
content = await (0, git_diff_1.getDiffsOnlyView)(state.repoPath, state.filename);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
content = await (0, git_diff_1.getFullFileWithInlineDiff)(state.repoPath, state.filename);
|
|
64
|
+
}
|
|
65
|
+
process.stdout.write(content);
|
|
66
|
+
process.stdout.write('\n'); // Ensure final newline
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
process.stdout.write(`Error loading file: ${state.filename}\n`);
|
|
70
|
+
process.stdout.write(`${err}\n`);
|
|
71
|
+
}
|
|
72
|
+
// Content is now in tmux scrollback - user can scroll with mouse
|
|
73
|
+
}
|
|
74
|
+
// ============================================================================
|
|
75
|
+
// Input Handling
|
|
76
|
+
// ============================================================================
|
|
77
|
+
function handleInput(data) {
|
|
78
|
+
const input = data.toString();
|
|
79
|
+
// Escape: close file diff view (single Esc byte)
|
|
80
|
+
if (input === '\x1b' && data.length === 1) {
|
|
81
|
+
sendToSidebar('close');
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// q: also close
|
|
85
|
+
if (input === 'q') {
|
|
86
|
+
sendToSidebar('close');
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// All other input (scrolling) is handled by tmux mouse bindings
|
|
90
|
+
}
|
|
91
|
+
// ============================================================================
|
|
92
|
+
// Lifecycle
|
|
93
|
+
// ============================================================================
|
|
94
|
+
async function start() {
|
|
95
|
+
// Hide cursor
|
|
96
|
+
process.stdout.write(ansi_1.ansi.hideCursor);
|
|
97
|
+
// Set up raw mode for input (to capture Esc key)
|
|
98
|
+
if (process.stdin.isTTY) {
|
|
99
|
+
process.stdin.setRawMode(true);
|
|
100
|
+
}
|
|
101
|
+
process.stdin.resume();
|
|
102
|
+
process.stdin.on('data', handleInput);
|
|
103
|
+
// Print content (goes into tmux scrollback)
|
|
104
|
+
await printContent();
|
|
105
|
+
}
|
|
106
|
+
function stop() {
|
|
107
|
+
process.stdout.write(ansi_1.ansi.showCursor);
|
|
108
|
+
process.stdout.write(ansi_1.ansi.reset);
|
|
109
|
+
if (process.stdin.isTTY) {
|
|
110
|
+
process.stdin.setRawMode(false);
|
|
111
|
+
}
|
|
112
|
+
process.stdin.pause();
|
|
113
|
+
}
|
|
114
|
+
// ============================================================================
|
|
115
|
+
// Main
|
|
116
|
+
// ============================================================================
|
|
117
|
+
async function main() {
|
|
118
|
+
const args = process.argv.slice(2);
|
|
119
|
+
if (args.length < 3) {
|
|
120
|
+
console.error('Usage: file-diff-content-handler <sidebarPaneId> <repoPath> <filename> [mode]');
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
state.sidebarPaneId = args[0];
|
|
124
|
+
state.repoPath = args[1];
|
|
125
|
+
state.filename = args[2];
|
|
126
|
+
state.mode = args[3] || 'whole-file';
|
|
127
|
+
// Handle graceful shutdown
|
|
128
|
+
process.on('SIGTERM', () => {
|
|
129
|
+
stop();
|
|
130
|
+
process.exit(0);
|
|
131
|
+
});
|
|
132
|
+
process.on('SIGINT', () => {
|
|
133
|
+
stop();
|
|
134
|
+
process.exit(0);
|
|
135
|
+
});
|
|
136
|
+
await start();
|
|
137
|
+
}
|
|
138
|
+
main().catch((err) => {
|
|
139
|
+
console.error('File diff content handler error:', err);
|
|
140
|
+
process.exit(1);
|
|
141
|
+
});
|
|
142
|
+
//# sourceMappingURL=file-diff-content-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-diff-content-handler.js","sourceRoot":"","sources":["../../src/diff/file-diff-content-handler.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;GAYG;;AAEH,iDAAyC;AACzC,kCAA+B;AAC/B,yCAAyE;AAczE,IAAI,KAAK,GAAiB;IACxB,aAAa,EAAE,EAAE;IACjB,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,YAAY;CACnB,CAAC;AAEF,+EAA+E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nB,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAC;IACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* File Diff Header Handler
|
|
4
|
+
*
|
|
5
|
+
* Lightweight process that runs in the 1-row header pane above the file diff content.
|
|
6
|
+
* Shows "Back to Claude" and filename, handles Escape/Enter/Click to close.
|
|
7
|
+
* Also handles view mode toggle buttons ([Diffs] / [Full]).
|
|
8
|
+
*
|
|
9
|
+
* Communication:
|
|
10
|
+
* - Receives render data from sidebar via stdin
|
|
11
|
+
* - Sends actions to sidebar via tmux send-keys
|
|
12
|
+
*
|
|
13
|
+
* Usage: node file-diff-header-handler.js <sidebarPaneId> <filename> <insertions> <deletions> <mode>
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=file-diff-header-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-diff-header-handler.d.ts","sourceRoot":"","sources":["../../src/diff/file-diff-header-handler.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* File Diff Header Handler
|
|
5
|
+
*
|
|
6
|
+
* Lightweight process that runs in the 1-row header pane above the file diff content.
|
|
7
|
+
* Shows "Back to Claude" and filename, handles Escape/Enter/Click to close.
|
|
8
|
+
* Also handles view mode toggle buttons ([Diffs] / [Full]).
|
|
9
|
+
*
|
|
10
|
+
* Communication:
|
|
11
|
+
* - Receives render data from sidebar via stdin
|
|
12
|
+
* - Sends actions to sidebar via tmux send-keys
|
|
13
|
+
*
|
|
14
|
+
* Usage: node file-diff-header-handler.js <sidebarPaneId> <filename> <insertions> <deletions> <mode>
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const child_process_1 = require("child_process");
|
|
18
|
+
const file_diff_header_render_1 = require("./file-diff-header-render");
|
|
19
|
+
const ansi_1 = require("../ansi");
|
|
20
|
+
let state = {
|
|
21
|
+
sidebarPaneId: '',
|
|
22
|
+
filename: '',
|
|
23
|
+
insertions: 0,
|
|
24
|
+
deletions: 0,
|
|
25
|
+
mode: 'whole-file',
|
|
26
|
+
buttonPositions: {
|
|
27
|
+
diffsOnly: [0, 0],
|
|
28
|
+
wholeFile: [0, 0],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
let running = false;
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// Communication with Sidebar
|
|
34
|
+
// ============================================================================
|
|
35
|
+
/**
|
|
36
|
+
* Send a command to the sidebar via tmux send-keys
|
|
37
|
+
* Protocol: Ctrl+U followed by "FILEDIFF:<action>" then Enter
|
|
38
|
+
*/
|
|
39
|
+
function sendToSidebar(action) {
|
|
40
|
+
try {
|
|
41
|
+
// Send Ctrl+U to clear any existing input and enter command mode
|
|
42
|
+
(0, child_process_1.execSync)(`tmux send-keys -t ${state.sidebarPaneId} C-u`, { stdio: 'ignore' });
|
|
43
|
+
// Send the command
|
|
44
|
+
const cmd = `FILEDIFF:${action}`;
|
|
45
|
+
(0, child_process_1.execSync)(`tmux send-keys -t ${state.sidebarPaneId} -l "${cmd}"`, { stdio: 'ignore' });
|
|
46
|
+
// Send Enter to execute
|
|
47
|
+
(0, child_process_1.execSync)(`tmux send-keys -t ${state.sidebarPaneId} Enter`, { stdio: 'ignore' });
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
// Failed to send - sidebar may have exited
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// ============================================================================
|
|
54
|
+
// Rendering
|
|
55
|
+
// ============================================================================
|
|
56
|
+
function render() {
|
|
57
|
+
const width = process.stdout.columns || 80;
|
|
58
|
+
const result = (0, file_diff_header_render_1.renderFileHeader)(state.filename, state.insertions, state.deletions, width, state.mode);
|
|
59
|
+
state.buttonPositions = result.buttonPositions;
|
|
60
|
+
process.stdout.write(result.output);
|
|
61
|
+
}
|
|
62
|
+
// ============================================================================
|
|
63
|
+
// Input Handling
|
|
64
|
+
// ============================================================================
|
|
65
|
+
function handleInput(data) {
|
|
66
|
+
const input = data.toString();
|
|
67
|
+
// Check for render command from sidebar: "RENDER:<json>"
|
|
68
|
+
if (input.startsWith('RENDER:')) {
|
|
69
|
+
try {
|
|
70
|
+
const json = input.slice(7).trim();
|
|
71
|
+
const renderData = JSON.parse(json);
|
|
72
|
+
state.filename = renderData.filename || state.filename;
|
|
73
|
+
state.insertions = renderData.insertions ?? state.insertions;
|
|
74
|
+
state.deletions = renderData.deletions ?? state.deletions;
|
|
75
|
+
if (renderData.mode) {
|
|
76
|
+
state.mode = renderData.mode;
|
|
77
|
+
}
|
|
78
|
+
render();
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
// Invalid render data
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// Check for SGR mouse events: \x1b[<button;col;rowM or \x1b[<button;col;rowm
|
|
86
|
+
const mouseMatch = input.match(/\x1b\[<(\d+);(\d+);(\d+)([Mm])/);
|
|
87
|
+
if (mouseMatch) {
|
|
88
|
+
const button = parseInt(mouseMatch[1], 10);
|
|
89
|
+
const col = parseInt(mouseMatch[2], 10);
|
|
90
|
+
const isRelease = mouseMatch[4] === 'm';
|
|
91
|
+
// Only handle left click release
|
|
92
|
+
if (button === 0 && isRelease) {
|
|
93
|
+
// Check if click is on "← Back" button (first ~10 columns)
|
|
94
|
+
if (col <= 10) {
|
|
95
|
+
sendToSidebar('close');
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// Check if click is on [Diffs] button
|
|
99
|
+
const [diffsStart, diffsEnd] = state.buttonPositions.diffsOnly;
|
|
100
|
+
if (col >= diffsStart && col <= diffsEnd) {
|
|
101
|
+
sendToSidebar('mode:diffs-only');
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
// Check if click is on [Full] button
|
|
105
|
+
const [fullStart, fullEnd] = state.buttonPositions.wholeFile;
|
|
106
|
+
if (col >= fullStart && col <= fullEnd) {
|
|
107
|
+
sendToSidebar('mode:whole-file');
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// Handle keyboard input
|
|
114
|
+
const key = input;
|
|
115
|
+
// Escape: close file diff view
|
|
116
|
+
if (key === '\x1b' && input.length === 1) {
|
|
117
|
+
sendToSidebar('close');
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// Enter/Backspace: also close
|
|
121
|
+
if (key === '\r' || key === '\x7f') {
|
|
122
|
+
sendToSidebar('close');
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
// q: close
|
|
126
|
+
if (key === 'q') {
|
|
127
|
+
sendToSidebar('close');
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// ============================================================================
|
|
132
|
+
// Lifecycle
|
|
133
|
+
// ============================================================================
|
|
134
|
+
function start() {
|
|
135
|
+
running = true;
|
|
136
|
+
// Set up terminal
|
|
137
|
+
process.stdout.write(ansi_1.ansi.hideCursor);
|
|
138
|
+
process.stdout.write(ansi_1.ansi.enableMouse);
|
|
139
|
+
// Set up raw mode for input
|
|
140
|
+
if (process.stdin.isTTY) {
|
|
141
|
+
process.stdin.setRawMode(true);
|
|
142
|
+
}
|
|
143
|
+
process.stdin.resume();
|
|
144
|
+
process.stdin.on('data', handleInput);
|
|
145
|
+
// Handle resize
|
|
146
|
+
process.stdout.on('resize', () => {
|
|
147
|
+
render();
|
|
148
|
+
});
|
|
149
|
+
// Initial render
|
|
150
|
+
render();
|
|
151
|
+
}
|
|
152
|
+
function stop() {
|
|
153
|
+
running = false;
|
|
154
|
+
process.stdout.write(ansi_1.ansi.disableMouse);
|
|
155
|
+
process.stdout.write(ansi_1.ansi.showCursor);
|
|
156
|
+
process.stdout.write(ansi_1.ansi.reset);
|
|
157
|
+
if (process.stdin.isTTY) {
|
|
158
|
+
process.stdin.setRawMode(false);
|
|
159
|
+
}
|
|
160
|
+
process.stdin.pause();
|
|
161
|
+
}
|
|
162
|
+
// ============================================================================
|
|
163
|
+
// Main
|
|
164
|
+
// ============================================================================
|
|
165
|
+
async function main() {
|
|
166
|
+
const args = process.argv.slice(2);
|
|
167
|
+
if (args.length < 4) {
|
|
168
|
+
console.error('Usage: file-diff-header-handler <sidebarPaneId> <filename> <insertions> <deletions> [mode]');
|
|
169
|
+
process.exit(1);
|
|
170
|
+
}
|
|
171
|
+
state.sidebarPaneId = args[0];
|
|
172
|
+
state.filename = args[1];
|
|
173
|
+
state.insertions = parseInt(args[2], 10) || 0;
|
|
174
|
+
state.deletions = parseInt(args[3], 10) || 0;
|
|
175
|
+
state.mode = args[4] || 'whole-file';
|
|
176
|
+
// Handle graceful shutdown
|
|
177
|
+
process.on('SIGTERM', () => {
|
|
178
|
+
stop();
|
|
179
|
+
process.exit(0);
|
|
180
|
+
});
|
|
181
|
+
process.on('SIGINT', () => {
|
|
182
|
+
stop();
|
|
183
|
+
process.exit(0);
|
|
184
|
+
});
|
|
185
|
+
start();
|
|
186
|
+
}
|
|
187
|
+
main().catch((err) => {
|
|
188
|
+
console.error('File diff header handler error:', err);
|
|
189
|
+
process.exit(1);
|
|
190
|
+
});
|
|
191
|
+
//# sourceMappingURL=file-diff-header-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-diff-header-handler.js","sourceRoot":"","sources":["../../src/diff/file-diff-header-handler.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;GAYG;;AAEH,iDAAyC;AACzC,uEAAmF;AACnF,kCAA+B;AAgB/B,IAAI,KAAK,GAAgB;IACvB,aAAa,EAA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header pane that appears
|
|
5
|
+
* above the file diff content. Shows "Back to Claude" button, filename,
|
|
6
|
+
* and view mode toggle buttons ([Diffs] [Full]).
|
|
7
|
+
*/
|
|
8
|
+
import type { DiffViewMode } from '../types';
|
|
9
|
+
export interface ButtonPositions {
|
|
10
|
+
diffsOnly: [number, number];
|
|
11
|
+
wholeFile: [number, number];
|
|
12
|
+
}
|
|
13
|
+
export interface FileHeaderRenderResult {
|
|
14
|
+
output: string;
|
|
15
|
+
buttonPositions: ButtonPositions;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Render the file diff header bar (1-row)
|
|
19
|
+
*
|
|
20
|
+
* Format: "← Back to Claude [Esc] │ file.ts +22 -10 [Diffs] [Full]"
|
|
21
|
+
*
|
|
22
|
+
* @param filename - The file being viewed
|
|
23
|
+
* @param insertions - Number of lines added
|
|
24
|
+
* @param deletions - Number of lines removed
|
|
25
|
+
* @param width - Available width in columns
|
|
26
|
+
* @param mode - Current view mode ('diffs-only' or 'whole-file')
|
|
27
|
+
* @returns Object with output string and button positions
|
|
28
|
+
*/
|
|
29
|
+
export declare function renderFileHeader(filename: string, insertions: number, deletions: number, width: number, mode?: DiffViewMode): FileHeaderRenderResult;
|
|
30
|
+
//# sourceMappingURL=file-diff-header-render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-diff-header-render.d.ts","sourceRoot":"","sources":["../../src/diff/file-diff-header-render.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAM7C,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,eAAe,CAAC;CAClC;AAkBD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,YAA2B,GAChC,sBAAsB,CAyExB"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* File Diff Header Rendering
|
|
4
|
+
*
|
|
5
|
+
* Pure function for rendering the 1-row header pane that appears
|
|
6
|
+
* above the file diff content. Shows "Back to Claude" button, filename,
|
|
7
|
+
* and view mode toggle buttons ([Diffs] [Full]).
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.renderFileHeader = renderFileHeader;
|
|
11
|
+
const ansi_1 = require("../ansi");
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Helpers
|
|
14
|
+
// ============================================================================
|
|
15
|
+
/**
|
|
16
|
+
* Get display name: always just the filename (basename)
|
|
17
|
+
*/
|
|
18
|
+
function getDisplayName(filepath) {
|
|
19
|
+
const parts = filepath.split('/');
|
|
20
|
+
return parts[parts.length - 1];
|
|
21
|
+
}
|
|
22
|
+
// ============================================================================
|
|
23
|
+
// Rendering
|
|
24
|
+
// ============================================================================
|
|
25
|
+
/**
|
|
26
|
+
* Render the file diff header bar (1-row)
|
|
27
|
+
*
|
|
28
|
+
* Format: "← Back to Claude [Esc] │ file.ts +22 -10 [Diffs] [Full]"
|
|
29
|
+
*
|
|
30
|
+
* @param filename - The file being viewed
|
|
31
|
+
* @param insertions - Number of lines added
|
|
32
|
+
* @param deletions - Number of lines removed
|
|
33
|
+
* @param width - Available width in columns
|
|
34
|
+
* @param mode - Current view mode ('diffs-only' or 'whole-file')
|
|
35
|
+
* @returns Object with output string and button positions
|
|
36
|
+
*/
|
|
37
|
+
function renderFileHeader(filename, insertions, deletions, width, mode = 'whole-file') {
|
|
38
|
+
// Ensure minimum width to prevent content being cut off
|
|
39
|
+
const effectiveWidth = Math.max(width, 60);
|
|
40
|
+
let output = ansi_1.ansi.hideCursor + ansi_1.ansi.clearScreen + ansi_1.ansi.moveTo(1, 1);
|
|
41
|
+
// Back button with keybinding hint
|
|
42
|
+
const back = '← Back to Claude';
|
|
43
|
+
const hint = '[Esc]';
|
|
44
|
+
const sep = ' │ ';
|
|
45
|
+
output += `${ansi_1.ansi.fg.cyan}${ansi_1.ansi.bold}${back}${ansi_1.ansi.reset}`;
|
|
46
|
+
output += ` ${ansi_1.ansi.dim}${hint}${ansi_1.ansi.reset}`;
|
|
47
|
+
output += `${ansi_1.ansi.dim}${sep}${ansi_1.ansi.reset}`;
|
|
48
|
+
// File name (basename only)
|
|
49
|
+
const displayName = getDisplayName(filename);
|
|
50
|
+
output += `${ansi_1.ansi.bold}${displayName}${ansi_1.ansi.reset}`;
|
|
51
|
+
// Stats
|
|
52
|
+
let statsStr = '';
|
|
53
|
+
if (insertions > 0 || deletions > 0) {
|
|
54
|
+
statsStr += ' ';
|
|
55
|
+
if (insertions > 0) {
|
|
56
|
+
const ins = insertions > 999 ? '999+' : String(insertions);
|
|
57
|
+
statsStr += `${ansi_1.ansi.fg.green}+${ins}${ansi_1.ansi.reset}`;
|
|
58
|
+
}
|
|
59
|
+
if (deletions > 0) {
|
|
60
|
+
if (insertions > 0)
|
|
61
|
+
statsStr += ' ';
|
|
62
|
+
const del = deletions > 999 ? '999+' : String(deletions);
|
|
63
|
+
statsStr += `${ansi_1.ansi.fg.red}-${del}${ansi_1.ansi.reset}`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
output += statsStr;
|
|
67
|
+
// Calculate positions for mode toggle buttons
|
|
68
|
+
// Buttons: "[Diffs] [Full]" - total 14 chars
|
|
69
|
+
const diffsBtn = '[Diffs]';
|
|
70
|
+
const fullBtn = '[Full]';
|
|
71
|
+
const btnSpace = ' ';
|
|
72
|
+
const buttonsWidth = diffsBtn.length + btnSpace.length + fullBtn.length; // 14
|
|
73
|
+
// Position buttons at right side
|
|
74
|
+
const diffsStart = effectiveWidth - buttonsWidth + 1; // 1-indexed
|
|
75
|
+
const diffsEnd = diffsStart + diffsBtn.length - 1;
|
|
76
|
+
const fullStart = diffsEnd + 1 + btnSpace.length; // after space
|
|
77
|
+
const fullEnd = fullStart + fullBtn.length - 1;
|
|
78
|
+
// Move cursor to button position and render buttons
|
|
79
|
+
output += ansi_1.ansi.moveTo(1, diffsStart);
|
|
80
|
+
// Render [Diffs] button - inverse if selected
|
|
81
|
+
if (mode === 'diffs-only') {
|
|
82
|
+
output += `${ansi_1.ansi.inverse}${diffsBtn}${ansi_1.ansi.reset}`;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
output += `${ansi_1.ansi.dim}${diffsBtn}${ansi_1.ansi.reset}`;
|
|
86
|
+
}
|
|
87
|
+
output += btnSpace;
|
|
88
|
+
// Render [Full] button - inverse if selected
|
|
89
|
+
if (mode === 'whole-file') {
|
|
90
|
+
output += `${ansi_1.ansi.inverse}${fullBtn}${ansi_1.ansi.reset}`;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
output += `${ansi_1.ansi.dim}${fullBtn}${ansi_1.ansi.reset}`;
|
|
94
|
+
}
|
|
95
|
+
const buttonPositions = {
|
|
96
|
+
diffsOnly: [diffsStart, diffsEnd],
|
|
97
|
+
wholeFile: [fullStart, fullEnd],
|
|
98
|
+
};
|
|
99
|
+
return { output, buttonPositions };
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=file-diff-header-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-diff-header-render.js","sourceRoot":"","sources":["../../src/diff/file-diff-header-render.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AA+CH,4CA+EC;AA5HD,kCAA+B;AAiB/B,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E;;GAEG;AACH,SAAS,cAAc,CAAC,QAAgB;IACtC,MAAM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AM,GAAG,CAAC,CAAC;IAE/C,oDAAoD;IACpD,MAAM,IAAI,WAAI,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAErC,8CAA8C;IAC9C,IAAI,IAAI,KAAK,YAAY,EAAE,CAAC;QAC1B,MAAM,IAAI,GAAG,WAAI,CAAC,OAAO,GAAG,QAAQ,GAAG,WAAI,CAAC,KAAK,EAAE,CAAC;IACtD,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,GAAG,WAAI,CAAC,GAAG,GAAG,QAAQ,GAAG,WAAI,CAAC,KAAK,EAAE,CAAC;IAClD,CAAC;IAED,MAAM,IAAI,QAAQ,CAAC;IAEnB,6CAA6C;IAC7C,IAAI,IAAI,KAAK,YAAY,EAAE,CAAC;QAC1B,MAAM,IAAI,GAAG,WAAI,CAAC,OAAO,GAAG,OAAO,GAAG,WAAI,CAAC,KAAK,EAAE,CAAC;IACrD,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,GAAG,WAAI,CAAC,GAAG,GAAG,OAAO,GAAG,WAAI,CAAC,KAAK,EAAE,CAAC;IACjD,CAAC;IAED,MAAM,eAAe,GAAoB;QACvC,SAAS,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC;QACjC,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC;KAChC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Diff View Rendering
|
|
3
|
+
*
|
|
4
|
+
* Renders a full-screen colored diff view for a single file.
|
|
5
|
+
* Shows in the Claude pane area when viewing a file diff.
|
|
6
|
+
*/
|
|
7
|
+
export interface FileDiffViewState {
|
|
8
|
+
filename: string;
|
|
9
|
+
diffContent: string;
|
|
10
|
+
scrollOffset: number;
|
|
11
|
+
insertions: number;
|
|
12
|
+
deletions: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Render the file diff view for fullscreen display
|
|
16
|
+
*
|
|
17
|
+
* @param state - The file diff view state
|
|
18
|
+
* @param width - Available width in columns
|
|
19
|
+
* @param height - Available height in rows
|
|
20
|
+
* @returns ANSI output string
|
|
21
|
+
*/
|
|
22
|
+
export declare function renderFileDiffView(state: FileDiffViewState, width: number, height: number): string;
|
|
23
|
+
/**
|
|
24
|
+
* Calculate the maximum scroll offset for the diff content
|
|
25
|
+
*/
|
|
26
|
+
export declare function getMaxScrollOffset(diffContent: string, viewHeight: number): number;
|
|
27
|
+
//# sourceMappingURL=file-diff-render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-diff-render.d.ts","sourceRoot":"","sources":["../../src/diff/file-diff-render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AA2DD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,iBAAiB,EACxB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,MAAM,CAoGR;AA2CD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAOlF"}
|