explorbot 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/dist/src/ai/planner/session-dedup.js +3 -0
- package/dist/src/ai/planner/styles.js +3 -0
- package/dist/src/ai/researcher/cache.js +4 -3
- package/dist/src/ai/researcher/fingerprint-worker.js +7 -6
- package/package.json +2 -1
- package/src/ai/planner/session-dedup.ts +4 -0
- package/src/ai/planner/styles.ts +4 -0
- package/src/ai/researcher/cache.ts +4 -3
- package/src/ai/researcher/fingerprint-worker.ts +7 -13
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { Worker } from 'node:worker_threads';
|
|
3
4
|
import { outputPath } from "../../config.js";
|
|
4
5
|
import { computeHtmlFingerprint } from "../../utils/html-diff.js";
|
|
5
6
|
import { debugLog } from "./mixin.js";
|
|
@@ -69,16 +70,16 @@ function findSimilarMatch(combinedHtml) {
|
|
|
69
70
|
debugLog('Fingerprint worker timed out');
|
|
70
71
|
resolve(null);
|
|
71
72
|
}, FINGERPRINT_WORKER_TIMEOUT_MS);
|
|
72
|
-
worker.
|
|
73
|
+
worker.on('message', (data) => {
|
|
73
74
|
clearTimeout(timeout);
|
|
74
|
-
const { matchHash, similarity } =
|
|
75
|
+
const { matchHash, similarity } = data;
|
|
75
76
|
if (!matchHash) {
|
|
76
77
|
resolve(null);
|
|
77
78
|
return;
|
|
78
79
|
}
|
|
79
80
|
debugLog(`Similar fingerprint found: ${matchHash} (${similarity}% similar)`);
|
|
80
81
|
resolve({ hash: matchHash, similarity });
|
|
81
|
-
};
|
|
82
|
+
});
|
|
82
83
|
worker.postMessage({
|
|
83
84
|
html: combinedHtml,
|
|
84
85
|
statesDir,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { parentPort } from 'node:worker_threads';
|
|
3
4
|
import { computeHtmlFingerprint } from "../../utils/html-diff.js";
|
|
4
5
|
function diceSimilarity(a, b) {
|
|
5
6
|
let intersection = 0;
|
|
@@ -12,15 +13,15 @@ function diceSimilarity(a, b) {
|
|
|
12
13
|
return 100;
|
|
13
14
|
return Math.round(((2 * intersection) / total) * 100);
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
const { html, statesDir, maxAgeMs, threshold } =
|
|
16
|
+
parentPort.on('message', (data) => {
|
|
17
|
+
const { html, statesDir, maxAgeMs, threshold } = data;
|
|
17
18
|
if (!existsSync(statesDir)) {
|
|
18
|
-
|
|
19
|
+
parentPort.postMessage({ matchHash: null, similarity: 0 });
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
21
22
|
const currentFingerprint = new Set(computeHtmlFingerprint(html));
|
|
22
23
|
if (currentFingerprint.size === 0) {
|
|
23
|
-
|
|
24
|
+
parentPort.postMessage({ matchHash: null, similarity: 0 });
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
26
27
|
const now = Date.now();
|
|
@@ -41,5 +42,5 @@ self.onmessage = (event) => {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
const matched = bestSimilarity >= threshold;
|
|
44
|
-
|
|
45
|
-
};
|
|
45
|
+
parentPort.postMessage({ matchHash: matched ? bestHash : null, similarity: bestSimilarity });
|
|
46
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "explorbot",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "CLI app built with React Ink, CodeceptJS, and Playwright",
|
|
5
5
|
"license": "Elastic-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -114,6 +114,7 @@
|
|
|
114
114
|
},
|
|
115
115
|
"devDependencies": {
|
|
116
116
|
"@biomejs/biome": "^1.5.3",
|
|
117
|
+
"@copilotkit/aimock": "^1.14.0",
|
|
117
118
|
"@testing-library/react": "^16.3.0",
|
|
118
119
|
"@types/debug": "^4.1.12",
|
|
119
120
|
"@types/jsdom": "^27.0.0",
|
package/src/ai/planner/styles.ts
CHANGED
|
@@ -15,3 +15,7 @@ export function getStyles(): Record<string, string> {
|
|
|
15
15
|
export function getActiveStyle(iteration: number, override?: string): { name: string; approach: string } {
|
|
16
16
|
return RulesLoader.getActiveStyle(getStyles(), iteration, override);
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
export function clearStyleCache(): void {
|
|
20
|
+
cache = null;
|
|
21
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { Worker } from 'node:worker_threads';
|
|
3
4
|
import { outputPath } from '../../config.ts';
|
|
4
5
|
import { computeHtmlFingerprint } from '../../utils/html-diff.ts';
|
|
5
6
|
import { debugLog } from './mixin.ts';
|
|
@@ -76,9 +77,9 @@ function findSimilarMatch(combinedHtml: string): Promise<{ hash: string; similar
|
|
|
76
77
|
resolve(null);
|
|
77
78
|
}, FINGERPRINT_WORKER_TIMEOUT_MS);
|
|
78
79
|
|
|
79
|
-
worker.
|
|
80
|
+
worker.on('message', (data: { matchHash: string | null; similarity: number }) => {
|
|
80
81
|
clearTimeout(timeout);
|
|
81
|
-
const { matchHash, similarity } =
|
|
82
|
+
const { matchHash, similarity } = data;
|
|
82
83
|
if (!matchHash) {
|
|
83
84
|
resolve(null);
|
|
84
85
|
return;
|
|
@@ -86,7 +87,7 @@ function findSimilarMatch(combinedHtml: string): Promise<{ hash: string; similar
|
|
|
86
87
|
|
|
87
88
|
debugLog(`Similar fingerprint found: ${matchHash} (${similarity}% similar)`);
|
|
88
89
|
resolve({ hash: matchHash, similarity });
|
|
89
|
-
};
|
|
90
|
+
});
|
|
90
91
|
|
|
91
92
|
worker.postMessage({
|
|
92
93
|
html: combinedHtml,
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { parentPort } from 'node:worker_threads';
|
|
3
4
|
import { computeHtmlFingerprint } from '../../utils/html-diff.ts';
|
|
4
5
|
|
|
5
|
-
declare const self: Worker;
|
|
6
|
-
|
|
7
6
|
function diceSimilarity(a: Set<string>, b: Set<string>): number {
|
|
8
7
|
let intersection = 0;
|
|
9
8
|
for (const item of a) {
|
|
@@ -14,22 +13,17 @@ function diceSimilarity(a: Set<string>, b: Set<string>): number {
|
|
|
14
13
|
return Math.round(((2 * intersection) / total) * 100);
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
const { html, statesDir, maxAgeMs, threshold } =
|
|
19
|
-
html: string;
|
|
20
|
-
statesDir: string;
|
|
21
|
-
maxAgeMs: number;
|
|
22
|
-
threshold: number;
|
|
23
|
-
};
|
|
16
|
+
parentPort!.on('message', (data: { html: string; statesDir: string; maxAgeMs: number; threshold: number }) => {
|
|
17
|
+
const { html, statesDir, maxAgeMs, threshold } = data;
|
|
24
18
|
|
|
25
19
|
if (!existsSync(statesDir)) {
|
|
26
|
-
|
|
20
|
+
parentPort!.postMessage({ matchHash: null, similarity: 0 });
|
|
27
21
|
return;
|
|
28
22
|
}
|
|
29
23
|
|
|
30
24
|
const currentFingerprint = new Set(computeHtmlFingerprint(html));
|
|
31
25
|
if (currentFingerprint.size === 0) {
|
|
32
|
-
|
|
26
|
+
parentPort!.postMessage({ matchHash: null, similarity: 0 });
|
|
33
27
|
return;
|
|
34
28
|
}
|
|
35
29
|
|
|
@@ -55,5 +49,5 @@ self.onmessage = (event: MessageEvent) => {
|
|
|
55
49
|
}
|
|
56
50
|
|
|
57
51
|
const matched = bestSimilarity >= threshold;
|
|
58
|
-
|
|
59
|
-
};
|
|
52
|
+
parentPort!.postMessage({ matchHash: matched ? bestHash : null, similarity: bestSimilarity });
|
|
53
|
+
});
|