omp-plugin-duplicate-detector 0.2.1 → 0.2.3

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.
@@ -12838,7 +12838,7 @@ class SourceAwareCloneIndex {
12838
12838
 
12839
12839
  // src/disk-cache.ts
12840
12840
  var DEFAULT_MAX_CACHE_BYTES = 250 * 1024 * 1024;
12841
- var TOKENIZER_CACHE_VERSION = "4.0";
12841
+ var TOKENIZER_CACHE_VERSION = "5.0";
12842
12842
  function getDefaultCacheDir() {
12843
12843
  if (process.platform === "win32") {
12844
12844
  const localAppData = process.env.LOCALAPPDATA;
@@ -12879,7 +12879,7 @@ function computeWorkspaceCachePath(baseDir, repositoryKeyOrRootDir, configFinger
12879
12879
  return path3.join(baseDir, `${repoKey}_${configFingerprint}_v${CACHE_FORMAT_VERSION}.sqlite`);
12880
12880
  }
12881
12881
  var CACHE_FORMAT_MAGIC = "DUP3";
12882
- var CACHE_FORMAT_VERSION = 4;
12882
+ var CACHE_FORMAT_VERSION = 5;
12883
12883
  function packBinaryShard(shard) {
12884
12884
  return packBinaryShardV3(shard, shard.tokens ?? []);
12885
12885
  }
@@ -12913,20 +12913,22 @@ function packBinaryShardV3(shard, tokens) {
12913
12913
  const dLenBuf = Buffer.allocUnsafe(colBytes);
12914
12914
  let prevLine = 0;
12915
12915
  let prevCol = 0;
12916
- let prevPos = 0;
12916
+ let prevRangeStart = 0;
12917
12917
  for (let i = 0;i < tokenCount; i++) {
12918
12918
  const tok = tokens[i];
12919
12919
  const dLine = tok.line - prevLine;
12920
12920
  const dCol = tok.column - prevCol;
12921
- const dPos = tok.position - prevPos;
12922
- const len = Array.isArray(tok.range) && tok.range.length >= 2 ? tok.range[1] - tok.range[0] : 0;
12921
+ const startRange = Array.isArray(tok.range) && tok.range.length >= 2 ? tok.range[0] : tok.position ?? i;
12922
+ const endRange = Array.isArray(tok.range) && tok.range.length >= 2 ? tok.range[1] : startRange;
12923
+ const len = Math.max(0, endRange - startRange);
12924
+ const dRangeStart = startRange - prevRangeStart;
12923
12925
  dLinesBuf.writeInt32LE(dLine, i * 4);
12924
12926
  dColsBuf.writeInt32LE(dCol, i * 4);
12925
- dPosBuf.writeInt32LE(dPos, i * 4);
12927
+ dPosBuf.writeInt32LE(dRangeStart, i * 4);
12926
12928
  dLenBuf.writeUInt32LE(len, i * 4);
12927
12929
  prevLine = tok.line;
12928
12930
  prevCol = tok.column;
12929
- prevPos = tok.position;
12931
+ prevRangeStart = startRange;
12930
12932
  }
12931
12933
  const meta = {
12932
12934
  sourceId: shard.sourceId,
@@ -12975,7 +12977,7 @@ function unpackBinaryShard(compressed) {
12975
12977
  function unpackBinaryShardV3(buf) {
12976
12978
  try {
12977
12979
  const version = buf.readUInt16LE(4);
12978
- if (version < 3 || version > CACHE_FORMAT_VERSION)
12980
+ if (version !== CACHE_FORMAT_VERSION)
12979
12981
  return null;
12980
12982
  const metaLen = buf.readUInt16LE(6);
12981
12983
  const tokenCount = buf.readUInt32LE(8);
@@ -13027,11 +13029,11 @@ function unpackBinaryShardV3(buf) {
13027
13029
  const tokens = new Array(tokenCount);
13028
13030
  let curLine = 0;
13029
13031
  let curCol = 0;
13030
- let curPos = 0;
13032
+ let curRangeStart = 0;
13031
13033
  for (let i = 0;i < tokenCount; i++) {
13032
13034
  curLine += dLines[i];
13033
13035
  curCol += dCols[i];
13034
- curPos += dPos[i];
13036
+ curRangeStart += dPos[i];
13035
13037
  const len = dLens[i];
13036
13038
  const dictIdx = indices[i];
13037
13039
  const hash2 = dictionary[dictIdx] ?? "";
@@ -13039,8 +13041,8 @@ function unpackBinaryShardV3(buf) {
13039
13041
  hash: hash2,
13040
13042
  line: curLine,
13041
13043
  column: curCol,
13042
- position: curPos,
13043
- range: [curPos, curPos + len]
13044
+ position: i,
13045
+ range: [curRangeStart, curRangeStart + len]
13044
13046
  };
13045
13047
  }
13046
13048
  const minTokens = meta.minTokens ?? 40;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omp-plugin-duplicate-detector",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Code clone and duplication detector plugin for oh-my-pi powered by jscpd",
5
5
  "type": "module",
6
6
  "files": [
package/src/disk-cache.ts CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  import type { WorkspaceOptions } from "./worker-protocol";
22
22
 
23
23
  const DEFAULT_MAX_CACHE_BYTES = 250 * 1024 * 1024; // 250 MB
24
- const TOKENIZER_CACHE_VERSION = "4.0";
24
+ const TOKENIZER_CACHE_VERSION = "5.0";
25
25
 
26
26
  export interface DiskCacheOptions {
27
27
  /** Root directory of the workspace */
@@ -136,7 +136,7 @@ export function computeShardKey(
136
136
  export const CACHE_FORMAT_MAGIC = "DUP3";
137
137
 
138
138
  /** Current binary format & SQLite schema version */
139
- export const CACHE_FORMAT_VERSION = 4;
139
+ export const CACHE_FORMAT_VERSION = 5;
140
140
 
141
141
  /**
142
142
  * Encodes a SerializedSourceShard into a high-density, zlib-compressed binary buffer (DUP3 format).
@@ -187,26 +187,31 @@ function packBinaryShardV3(
187
187
 
188
188
  let prevLine = 0;
189
189
  let prevCol = 0;
190
- let prevPos = 0;
190
+ let prevRangeStart = 0;
191
191
 
192
192
  for (let i = 0; i < tokenCount; i++) {
193
193
  const tok = tokens[i]!;
194
194
  const dLine = tok.line - prevLine;
195
195
  const dCol = tok.column - prevCol;
196
- const dPos = tok.position - prevPos;
197
- const len =
196
+ const startRange =
198
197
  Array.isArray(tok.range) && tok.range.length >= 2
199
- ? tok.range[1] - tok.range[0]
200
- : 0;
198
+ ? tok.range[0]
199
+ : (tok.position ?? i);
200
+ const endRange =
201
+ Array.isArray(tok.range) && tok.range.length >= 2
202
+ ? tok.range[1]
203
+ : startRange;
204
+ const len = Math.max(0, endRange - startRange);
205
+ const dRangeStart = startRange - prevRangeStart;
201
206
 
202
207
  dLinesBuf.writeInt32LE(dLine, i * 4);
203
208
  dColsBuf.writeInt32LE(dCol, i * 4);
204
- dPosBuf.writeInt32LE(dPos, i * 4);
209
+ dPosBuf.writeInt32LE(dRangeStart, i * 4);
205
210
  dLenBuf.writeUInt32LE(len, i * 4);
206
211
 
207
212
  prevLine = tok.line;
208
213
  prevCol = tok.column;
209
- prevPos = tok.position;
214
+ prevRangeStart = startRange;
210
215
  }
211
216
 
212
217
  const meta = {
@@ -267,7 +272,7 @@ export function unpackBinaryShard(
267
272
  function unpackBinaryShardV3(buf: Buffer): SerializedSourceShard | null {
268
273
  try {
269
274
  const version = buf.readUInt16LE(4);
270
- if (version < 3 || version > CACHE_FORMAT_VERSION) return null;
275
+ if (version !== CACHE_FORMAT_VERSION) return null;
271
276
 
272
277
  const metaLen = buf.readUInt16LE(6);
273
278
  const tokenCount = buf.readUInt32LE(8);
@@ -329,12 +334,12 @@ function unpackBinaryShardV3(buf: Buffer): SerializedSourceShard | null {
329
334
  const tokens: SerializedToken[] = new Array(tokenCount);
330
335
  let curLine = 0;
331
336
  let curCol = 0;
332
- let curPos = 0;
337
+ let curRangeStart = 0;
333
338
 
334
339
  for (let i = 0; i < tokenCount; i++) {
335
340
  curLine += dLines[i]!;
336
341
  curCol += dCols[i]!;
337
- curPos += dPos[i]!;
342
+ curRangeStart += dPos[i]!;
338
343
  const len = dLens[i]!;
339
344
  const dictIdx = indices[i]!;
340
345
  const hash = dictionary[dictIdx] ?? "";
@@ -343,8 +348,8 @@ function unpackBinaryShardV3(buf: Buffer): SerializedSourceShard | null {
343
348
  hash,
344
349
  line: curLine,
345
350
  column: curCol,
346
- position: curPos,
347
- range: [curPos, curPos + len],
351
+ position: i,
352
+ range: [curRangeStart, curRangeStart + len],
348
353
  };
349
354
  }
350
355
 
@@ -43,9 +43,11 @@ export class DuplicateLedger {
43
43
 
44
44
  for (const clone of clones) {
45
45
  const id = cloneIdentity(clone);
46
- currentIdentities.add(id);
47
- if (!previous?.has(id)) {
48
- fresh.push(clone);
46
+ if (!currentIdentities.has(id)) {
47
+ currentIdentities.add(id);
48
+ if (!previous?.has(id)) {
49
+ fresh.push(clone);
50
+ }
49
51
  }
50
52
  }
51
53
 
package/src/index.ts CHANGED
@@ -302,15 +302,16 @@ function notifyBaselineStatus(
302
302
  ? "warning"
303
303
  : "info";
304
304
 
305
- // 1. Send transient TUI toast if UI is active
305
+ // 1. Send TUI notification if UI is active (presents directly without wiping chat container)
306
306
  ctx?.ui?.notify?.(message, level);
307
307
 
308
- // 2. Send persistent transcript notification into the chat feed
308
+ // 2. Send status message into session with display: false to prevent triggering
309
+ // an invasive chat rebuild that clears ephemeral startup banners (e.g. omp update notification)
309
310
  pi.sendMessage(
310
311
  {
311
312
  customType: "duplicate-detector-status",
312
313
  content: message,
313
- display: true,
314
+ display: false,
314
315
  attribution: "user",
315
316
  details: {
316
317
  status,
@@ -447,7 +448,7 @@ export default function duplicateDetectorExtension(pi: ExtensionAPI): void {
447
448
  {
448
449
  customType: "duplicate-detector-status",
449
450
  content: message,
450
- display: true,
451
+ display: false,
451
452
  attribution: "user",
452
453
  details: {
453
454
  status: "failed",