claude-remote 0.1.7 → 0.1.8
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/package.json +1 -1
- package/server.js +24 -0
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -957,6 +957,8 @@ function startTailing() {
|
|
|
957
957
|
markExpectingSwitch();
|
|
958
958
|
}
|
|
959
959
|
}
|
|
960
|
+
// Enrich Edit tool_use blocks with source file start line
|
|
961
|
+
enrichEditStartLines(event);
|
|
960
962
|
const record = { seq: ++eventSeq, event };
|
|
961
963
|
eventBuffer.push(record);
|
|
962
964
|
if (eventBuffer.length > EVENT_BUFFER_MAX) {
|
|
@@ -974,6 +976,28 @@ function startTailing() {
|
|
|
974
976
|
}, 300);
|
|
975
977
|
}
|
|
976
978
|
|
|
979
|
+
function enrichEditStartLines(event) {
|
|
980
|
+
const content = event.message && event.message.content;
|
|
981
|
+
if (!Array.isArray(content)) return;
|
|
982
|
+
for (const block of content) {
|
|
983
|
+
if (block.type !== 'tool_use' || block.name !== 'Edit') continue;
|
|
984
|
+
const input = block.input;
|
|
985
|
+
if (!input || !input.file_path || input.old_string === undefined) continue;
|
|
986
|
+
try {
|
|
987
|
+
const filePath = path.resolve(CWD, input.file_path);
|
|
988
|
+
const src = fs.readFileSync(filePath, 'utf8');
|
|
989
|
+
// Search for new_string first (edit likely already applied), fallback to old_string
|
|
990
|
+
const needle = input.new_string || input.old_string;
|
|
991
|
+
const idx = src.indexOf(needle);
|
|
992
|
+
if (idx >= 0) {
|
|
993
|
+
input._startLine = src.substring(0, idx).split('\n').length;
|
|
994
|
+
}
|
|
995
|
+
} catch {
|
|
996
|
+
// file not readable — skip enrichment
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
|
|
977
1001
|
function stopTailing() {
|
|
978
1002
|
if (tailTimer) { clearInterval(tailTimer); tailTimer = null; }
|
|
979
1003
|
if (switchWatcher) { clearInterval(switchWatcher); switchWatcher = null; }
|