opencode-hashline 1.0.4 → 1.0.5
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/{chunk-3AJXTHJ3.js → chunk-DDXOFWTU.js} +4 -2
- package/dist/{chunk-DUTTCCXT.js → chunk-JOA7B5LK.js} +7 -1
- package/dist/{hashline-V3FR43UZ.js → hashline-GY4XM34F.js} +1 -1
- package/dist/{hashline-Civwirvf.d.cts → hashline-yhMw1Abs.d.cts} +2 -0
- package/dist/{hashline-Civwirvf.d.ts → hashline-yhMw1Abs.d.ts} +2 -0
- package/dist/index.cjs +32 -10
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +28 -12
- package/dist/utils.cjs +6 -2
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +2 -2
- package/package.json +1 -1
|
@@ -38,7 +38,8 @@ var DEFAULT_CONFIG = {
|
|
|
38
38
|
hashLength: 0,
|
|
39
39
|
// 0 = adaptive
|
|
40
40
|
cacheSize: 100,
|
|
41
|
-
prefix: DEFAULT_PREFIX
|
|
41
|
+
prefix: DEFAULT_PREFIX,
|
|
42
|
+
debug: false
|
|
42
43
|
};
|
|
43
44
|
function resolveConfig(config, pluginConfig) {
|
|
44
45
|
const merged = {
|
|
@@ -53,7 +54,8 @@ function resolveConfig(config, pluginConfig) {
|
|
|
53
54
|
maxFileSize: merged.maxFileSize ?? DEFAULT_CONFIG.maxFileSize,
|
|
54
55
|
hashLength: merged.hashLength ?? DEFAULT_CONFIG.hashLength,
|
|
55
56
|
cacheSize: merged.cacheSize ?? DEFAULT_CONFIG.cacheSize,
|
|
56
|
-
prefix: merged.prefix !== void 0 ? merged.prefix : DEFAULT_CONFIG.prefix
|
|
57
|
+
prefix: merged.prefix !== void 0 ? merged.prefix : DEFAULT_CONFIG.prefix,
|
|
58
|
+
debug: merged.debug ?? DEFAULT_CONFIG.debug
|
|
57
59
|
};
|
|
58
60
|
}
|
|
59
61
|
function fnv1aHash(str) {
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
resolveConfig,
|
|
5
5
|
shouldExclude,
|
|
6
6
|
stripHashes
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DDXOFWTU.js";
|
|
8
8
|
|
|
9
9
|
// src/hooks.ts
|
|
10
10
|
import { appendFileSync } from "fs";
|
|
@@ -24,7 +24,12 @@ function createBoundedSet(maxSize) {
|
|
|
24
24
|
};
|
|
25
25
|
return set;
|
|
26
26
|
}
|
|
27
|
+
var debugEnabled = false;
|
|
28
|
+
function setDebug(enabled) {
|
|
29
|
+
debugEnabled = enabled;
|
|
30
|
+
}
|
|
27
31
|
function debug(...args) {
|
|
32
|
+
if (!debugEnabled) return;
|
|
28
33
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ")}
|
|
29
34
|
`;
|
|
30
35
|
try {
|
|
@@ -211,6 +216,7 @@ function createSystemPromptHook(config) {
|
|
|
211
216
|
}
|
|
212
217
|
|
|
213
218
|
export {
|
|
219
|
+
setDebug,
|
|
214
220
|
isFileReadTool,
|
|
215
221
|
createFileReadAfterHook,
|
|
216
222
|
createFileEditBeforeHook,
|
|
@@ -29,6 +29,8 @@ interface HashlineConfig {
|
|
|
29
29
|
* Set to `false` to disable prefix (legacy format: `1:a3f|code here`).
|
|
30
30
|
*/
|
|
31
31
|
prefix?: string | false;
|
|
32
|
+
/** Enable debug logging to ~/.config/opencode/hashline-debug.log (default: false) */
|
|
33
|
+
debug?: boolean;
|
|
32
34
|
}
|
|
33
35
|
/** Default exclude patterns */
|
|
34
36
|
declare const DEFAULT_EXCLUDE_PATTERNS: string[];
|
|
@@ -29,6 +29,8 @@ interface HashlineConfig {
|
|
|
29
29
|
* Set to `false` to disable prefix (legacy format: `1:a3f|code here`).
|
|
30
30
|
*/
|
|
31
31
|
prefix?: string | false;
|
|
32
|
+
/** Enable debug logging to ~/.config/opencode/hashline-debug.log (default: false) */
|
|
33
|
+
debug?: boolean;
|
|
32
34
|
}
|
|
33
35
|
/** Default exclude patterns */
|
|
34
36
|
declare const DEFAULT_EXCLUDE_PATTERNS: string[];
|
package/dist/index.cjs
CHANGED
|
@@ -67,7 +67,8 @@ function resolveConfig(config, pluginConfig) {
|
|
|
67
67
|
maxFileSize: merged.maxFileSize ?? DEFAULT_CONFIG.maxFileSize,
|
|
68
68
|
hashLength: merged.hashLength ?? DEFAULT_CONFIG.hashLength,
|
|
69
69
|
cacheSize: merged.cacheSize ?? DEFAULT_CONFIG.cacheSize,
|
|
70
|
-
prefix: merged.prefix !== void 0 ? merged.prefix : DEFAULT_CONFIG.prefix
|
|
70
|
+
prefix: merged.prefix !== void 0 ? merged.prefix : DEFAULT_CONFIG.prefix,
|
|
71
|
+
debug: merged.debug ?? DEFAULT_CONFIG.debug
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
74
|
function fnv1aHash(str) {
|
|
@@ -382,7 +383,8 @@ var init_hashline = __esm({
|
|
|
382
383
|
hashLength: 0,
|
|
383
384
|
// 0 = adaptive
|
|
384
385
|
cacheSize: 100,
|
|
385
|
-
prefix: DEFAULT_PREFIX
|
|
386
|
+
prefix: DEFAULT_PREFIX,
|
|
387
|
+
debug: false
|
|
386
388
|
};
|
|
387
389
|
modulusCache = /* @__PURE__ */ new Map();
|
|
388
390
|
stripRegexCache = /* @__PURE__ */ new Map();
|
|
@@ -481,7 +483,12 @@ function createBoundedSet(maxSize) {
|
|
|
481
483
|
};
|
|
482
484
|
return set;
|
|
483
485
|
}
|
|
486
|
+
var debugEnabled = false;
|
|
487
|
+
function setDebug(enabled) {
|
|
488
|
+
debugEnabled = enabled;
|
|
489
|
+
}
|
|
484
490
|
function debug(...args) {
|
|
491
|
+
if (!debugEnabled) return;
|
|
485
492
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ")}
|
|
486
493
|
`;
|
|
487
494
|
try {
|
|
@@ -789,12 +796,15 @@ function createHashlinePlugin(userConfig) {
|
|
|
789
796
|
const fileConfig = loadConfig(projectDir, userConfig);
|
|
790
797
|
const config = resolveConfig(fileConfig);
|
|
791
798
|
const cache = new HashlineCache(config.cacheSize);
|
|
799
|
+
setDebug(config.debug);
|
|
792
800
|
const { appendFileSync: writeLog } = await import("fs");
|
|
793
801
|
const debugLog = (0, import_path3.join)((0, import_os2.homedir)(), ".config", "opencode", "hashline-debug.log");
|
|
794
|
-
|
|
795
|
-
|
|
802
|
+
if (config.debug) {
|
|
803
|
+
try {
|
|
804
|
+
writeLog(debugLog, `[${(/* @__PURE__ */ new Date()).toISOString()}] plugin loaded, prefix: ${JSON.stringify(config.prefix)}, maxFileSize: ${config.maxFileSize}, projectDir: ${projectDir}
|
|
796
805
|
`);
|
|
797
|
-
|
|
806
|
+
} catch {
|
|
807
|
+
}
|
|
798
808
|
}
|
|
799
809
|
const tempFiles = /* @__PURE__ */ new Set();
|
|
800
810
|
const cleanupTempFiles = () => {
|
|
@@ -853,8 +863,13 @@ function createHashlinePlugin(userConfig) {
|
|
|
853
863
|
(0, import_fs3.writeFileSync)(tmpPath2, cached, "utf-8");
|
|
854
864
|
tempFiles.add(tmpPath2);
|
|
855
865
|
p.url = `file://${tmpPath2}`;
|
|
856
|
-
|
|
866
|
+
if (config.debug) {
|
|
867
|
+
try {
|
|
868
|
+
writeLog(debugLog, `[${(/* @__PURE__ */ new Date()).toISOString()}] chat.message annotated (cached): ${filePath}
|
|
857
869
|
`);
|
|
870
|
+
} catch {
|
|
871
|
+
}
|
|
872
|
+
}
|
|
858
873
|
continue;
|
|
859
874
|
}
|
|
860
875
|
const annotated = formatFileWithHashes2(content, hashLen || void 0, prefix);
|
|
@@ -862,14 +877,21 @@ function createHashlinePlugin(userConfig) {
|
|
|
862
877
|
const tmpPath = (0, import_path3.join)((0, import_os2.tmpdir)(), `hashline-${p.id}.txt`);
|
|
863
878
|
(0, import_fs3.writeFileSync)(tmpPath, annotated, "utf-8");
|
|
864
879
|
p.url = `file://${tmpPath}`;
|
|
865
|
-
|
|
880
|
+
if (config.debug) {
|
|
881
|
+
try {
|
|
882
|
+
writeLog(debugLog, `[${(/* @__PURE__ */ new Date()).toISOString()}] chat.message annotated: ${filePath} lines=${content.split("\n").length}
|
|
866
883
|
`);
|
|
884
|
+
} catch {
|
|
885
|
+
}
|
|
886
|
+
}
|
|
867
887
|
}
|
|
868
888
|
} catch (e) {
|
|
869
|
-
|
|
870
|
-
|
|
889
|
+
if (config.debug) {
|
|
890
|
+
try {
|
|
891
|
+
writeLog(debugLog, `[${(/* @__PURE__ */ new Date()).toISOString()}] chat.message error: ${e}
|
|
871
892
|
`);
|
|
872
|
-
|
|
893
|
+
} catch {
|
|
894
|
+
}
|
|
873
895
|
}
|
|
874
896
|
}
|
|
875
897
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from '@opencode-ai/plugin';
|
|
2
|
-
import { H as HashlineConfig } from './hashline-
|
|
3
|
-
export { a as HashEditInput, b as HashEditOperation, c as HashEditResult, d as HashlineInstance, R as ResolvedRange, V as VerifyHashResult } from './hashline-
|
|
2
|
+
import { H as HashlineConfig } from './hashline-yhMw1Abs.cjs';
|
|
3
|
+
export { a as HashEditInput, b as HashEditOperation, c as HashEditResult, d as HashlineInstance, R as ResolvedRange, V as VerifyHashResult } from './hashline-yhMw1Abs.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* opencode-hashline — Hashline plugin for OpenCode
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from '@opencode-ai/plugin';
|
|
2
|
-
import { H as HashlineConfig } from './hashline-
|
|
3
|
-
export { a as HashEditInput, b as HashEditOperation, c as HashEditResult, d as HashlineInstance, R as ResolvedRange, V as VerifyHashResult } from './hashline-
|
|
2
|
+
import { H as HashlineConfig } from './hashline-yhMw1Abs.js';
|
|
3
|
+
export { a as HashEditInput, b as HashEditOperation, c as HashEditResult, d as HashlineInstance, R as ResolvedRange, V as VerifyHashResult } from './hashline-yhMw1Abs.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* opencode-hashline — Hashline plugin for OpenCode
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createFileEditBeforeHook,
|
|
3
3
|
createFileReadAfterHook,
|
|
4
|
-
createSystemPromptHook
|
|
5
|
-
|
|
4
|
+
createSystemPromptHook,
|
|
5
|
+
setDebug
|
|
6
|
+
} from "./chunk-JOA7B5LK.js";
|
|
6
7
|
import {
|
|
7
8
|
HashlineCache,
|
|
8
9
|
applyHashEdit,
|
|
9
10
|
resolveConfig
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-DDXOFWTU.js";
|
|
11
12
|
|
|
12
13
|
// src/index.ts
|
|
13
14
|
import { readFileSync as readFileSync2, realpathSync as realpathSync2, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
|
|
@@ -133,12 +134,15 @@ function createHashlinePlugin(userConfig) {
|
|
|
133
134
|
const fileConfig = loadConfig(projectDir, userConfig);
|
|
134
135
|
const config = resolveConfig(fileConfig);
|
|
135
136
|
const cache = new HashlineCache(config.cacheSize);
|
|
137
|
+
setDebug(config.debug);
|
|
136
138
|
const { appendFileSync: writeLog } = await import("fs");
|
|
137
139
|
const debugLog = join(homedir(), ".config", "opencode", "hashline-debug.log");
|
|
138
|
-
|
|
139
|
-
|
|
140
|
+
if (config.debug) {
|
|
141
|
+
try {
|
|
142
|
+
writeLog(debugLog, `[${(/* @__PURE__ */ new Date()).toISOString()}] plugin loaded, prefix: ${JSON.stringify(config.prefix)}, maxFileSize: ${config.maxFileSize}, projectDir: ${projectDir}
|
|
140
143
|
`);
|
|
141
|
-
|
|
144
|
+
} catch {
|
|
145
|
+
}
|
|
142
146
|
}
|
|
143
147
|
const tempFiles = /* @__PURE__ */ new Set();
|
|
144
148
|
const cleanupTempFiles = () => {
|
|
@@ -163,7 +167,7 @@ function createHashlinePlugin(userConfig) {
|
|
|
163
167
|
const out = output;
|
|
164
168
|
const hashLen = config.hashLength || 0;
|
|
165
169
|
const prefix = config.prefix;
|
|
166
|
-
const { formatFileWithHashes, shouldExclude, getByteLength } = await import("./hashline-
|
|
170
|
+
const { formatFileWithHashes, shouldExclude, getByteLength } = await import("./hashline-GY4XM34F.js");
|
|
167
171
|
for (const p of out.parts ?? []) {
|
|
168
172
|
if (p.type !== "file") continue;
|
|
169
173
|
if (!p.url || !p.mime?.startsWith("text/")) continue;
|
|
@@ -197,8 +201,13 @@ function createHashlinePlugin(userConfig) {
|
|
|
197
201
|
writeFileSync2(tmpPath2, cached, "utf-8");
|
|
198
202
|
tempFiles.add(tmpPath2);
|
|
199
203
|
p.url = `file://${tmpPath2}`;
|
|
200
|
-
|
|
204
|
+
if (config.debug) {
|
|
205
|
+
try {
|
|
206
|
+
writeLog(debugLog, `[${(/* @__PURE__ */ new Date()).toISOString()}] chat.message annotated (cached): ${filePath}
|
|
201
207
|
`);
|
|
208
|
+
} catch {
|
|
209
|
+
}
|
|
210
|
+
}
|
|
202
211
|
continue;
|
|
203
212
|
}
|
|
204
213
|
const annotated = formatFileWithHashes(content, hashLen || void 0, prefix);
|
|
@@ -206,14 +215,21 @@ function createHashlinePlugin(userConfig) {
|
|
|
206
215
|
const tmpPath = join(tmpdir(), `hashline-${p.id}.txt`);
|
|
207
216
|
writeFileSync2(tmpPath, annotated, "utf-8");
|
|
208
217
|
p.url = `file://${tmpPath}`;
|
|
209
|
-
|
|
218
|
+
if (config.debug) {
|
|
219
|
+
try {
|
|
220
|
+
writeLog(debugLog, `[${(/* @__PURE__ */ new Date()).toISOString()}] chat.message annotated: ${filePath} lines=${content.split("\n").length}
|
|
210
221
|
`);
|
|
222
|
+
} catch {
|
|
223
|
+
}
|
|
224
|
+
}
|
|
211
225
|
}
|
|
212
226
|
} catch (e) {
|
|
213
|
-
|
|
214
|
-
|
|
227
|
+
if (config.debug) {
|
|
228
|
+
try {
|
|
229
|
+
writeLog(debugLog, `[${(/* @__PURE__ */ new Date()).toISOString()}] chat.message error: ${e}
|
|
215
230
|
`);
|
|
216
|
-
|
|
231
|
+
} catch {
|
|
232
|
+
}
|
|
217
233
|
}
|
|
218
234
|
}
|
|
219
235
|
}
|
package/dist/utils.cjs
CHANGED
|
@@ -97,7 +97,8 @@ var DEFAULT_CONFIG = {
|
|
|
97
97
|
hashLength: 0,
|
|
98
98
|
// 0 = adaptive
|
|
99
99
|
cacheSize: 100,
|
|
100
|
-
prefix: DEFAULT_PREFIX
|
|
100
|
+
prefix: DEFAULT_PREFIX,
|
|
101
|
+
debug: false
|
|
101
102
|
};
|
|
102
103
|
function resolveConfig(config, pluginConfig) {
|
|
103
104
|
const merged = {
|
|
@@ -112,7 +113,8 @@ function resolveConfig(config, pluginConfig) {
|
|
|
112
113
|
maxFileSize: merged.maxFileSize ?? DEFAULT_CONFIG.maxFileSize,
|
|
113
114
|
hashLength: merged.hashLength ?? DEFAULT_CONFIG.hashLength,
|
|
114
115
|
cacheSize: merged.cacheSize ?? DEFAULT_CONFIG.cacheSize,
|
|
115
|
-
prefix: merged.prefix !== void 0 ? merged.prefix : DEFAULT_CONFIG.prefix
|
|
116
|
+
prefix: merged.prefix !== void 0 ? merged.prefix : DEFAULT_CONFIG.prefix,
|
|
117
|
+
debug: merged.debug ?? DEFAULT_CONFIG.debug
|
|
116
118
|
};
|
|
117
119
|
}
|
|
118
120
|
function fnv1aHash(str) {
|
|
@@ -465,7 +467,9 @@ function createBoundedSet(maxSize) {
|
|
|
465
467
|
};
|
|
466
468
|
return set;
|
|
467
469
|
}
|
|
470
|
+
var debugEnabled = false;
|
|
468
471
|
function debug(...args) {
|
|
472
|
+
if (!debugEnabled) return;
|
|
469
473
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ")}
|
|
470
474
|
`;
|
|
471
475
|
try {
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HashlineConfig, e as HashlineCache } from './hashline-
|
|
2
|
-
export { D as DEFAULT_CONFIG, f as DEFAULT_EXCLUDE_PATTERNS, g as DEFAULT_PREFIX, a as HashEditInput, b as HashEditOperation, c as HashEditResult, d as HashlineInstance, R as ResolvedRange, V as VerifyHashResult, h as applyHashEdit, i as buildHashMap, j as computeLineHash, k as createHashline, l as formatFileWithHashes, m as getAdaptiveHashLength, n as getByteLength, o as matchesGlob, p as normalizeHashRef, q as parseHashRef, r as replaceRange, s as resolveConfig, t as resolveRange, u as shouldExclude, v as stripHashes, w as verifyHash } from './hashline-
|
|
1
|
+
import { H as HashlineConfig, e as HashlineCache } from './hashline-yhMw1Abs.cjs';
|
|
2
|
+
export { D as DEFAULT_CONFIG, f as DEFAULT_EXCLUDE_PATTERNS, g as DEFAULT_PREFIX, a as HashEditInput, b as HashEditOperation, c as HashEditResult, d as HashlineInstance, R as ResolvedRange, V as VerifyHashResult, h as applyHashEdit, i as buildHashMap, j as computeLineHash, k as createHashline, l as formatFileWithHashes, m as getAdaptiveHashLength, n as getByteLength, o as matchesGlob, p as normalizeHashRef, q as parseHashRef, r as replaceRange, s as resolveConfig, t as resolveRange, u as shouldExclude, v as stripHashes, w as verifyHash } from './hashline-yhMw1Abs.cjs';
|
|
3
3
|
import { Hooks } from '@opencode-ai/plugin';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HashlineConfig, e as HashlineCache } from './hashline-
|
|
2
|
-
export { D as DEFAULT_CONFIG, f as DEFAULT_EXCLUDE_PATTERNS, g as DEFAULT_PREFIX, a as HashEditInput, b as HashEditOperation, c as HashEditResult, d as HashlineInstance, R as ResolvedRange, V as VerifyHashResult, h as applyHashEdit, i as buildHashMap, j as computeLineHash, k as createHashline, l as formatFileWithHashes, m as getAdaptiveHashLength, n as getByteLength, o as matchesGlob, p as normalizeHashRef, q as parseHashRef, r as replaceRange, s as resolveConfig, t as resolveRange, u as shouldExclude, v as stripHashes, w as verifyHash } from './hashline-
|
|
1
|
+
import { H as HashlineConfig, e as HashlineCache } from './hashline-yhMw1Abs.js';
|
|
2
|
+
export { D as DEFAULT_CONFIG, f as DEFAULT_EXCLUDE_PATTERNS, g as DEFAULT_PREFIX, a as HashEditInput, b as HashEditOperation, c as HashEditResult, d as HashlineInstance, R as ResolvedRange, V as VerifyHashResult, h as applyHashEdit, i as buildHashMap, j as computeLineHash, k as createHashline, l as formatFileWithHashes, m as getAdaptiveHashLength, n as getByteLength, o as matchesGlob, p as normalizeHashRef, q as parseHashRef, r as replaceRange, s as resolveConfig, t as resolveRange, u as shouldExclude, v as stripHashes, w as verifyHash } from './hashline-yhMw1Abs.js';
|
|
3
3
|
import { Hooks } from '@opencode-ai/plugin';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createFileReadAfterHook,
|
|
4
4
|
createSystemPromptHook,
|
|
5
5
|
isFileReadTool
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JOA7B5LK.js";
|
|
7
7
|
import {
|
|
8
8
|
DEFAULT_CONFIG,
|
|
9
9
|
DEFAULT_EXCLUDE_PATTERNS,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
shouldExclude,
|
|
26
26
|
stripHashes,
|
|
27
27
|
verifyHash
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-DDXOFWTU.js";
|
|
29
29
|
export {
|
|
30
30
|
DEFAULT_CONFIG,
|
|
31
31
|
DEFAULT_EXCLUDE_PATTERNS,
|
package/package.json
CHANGED