Skip to content

Commit affd8cc

Browse files
author
SentienceDEV
committed
snapshot with grid coordinates
1 parent 18873d1 commit affd8cc

File tree

8 files changed

+684
-74
lines changed

8 files changed

+684
-74
lines changed

.github/workflows/test.yml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,36 +45,36 @@ jobs:
4545
import re
4646
import os
4747
import sys
48-
48+
4949
# Set UTF-8 encoding for Windows compatibility
5050
if sys.platform == 'win32':
5151
import io
5252
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
5353
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
54-
54+
5555
file_path = 'sentience/agent_runtime.py'
5656
print(f'=== Auto-fix check for {file_path} ===')
5757
try:
5858
if not os.path.exists(file_path):
5959
print(f'ERROR: {file_path} not found!')
6060
sys.exit(1)
61-
61+
6262
with open(file_path, 'r', encoding='utf-8') as f:
6363
content = f.read()
64-
64+
6565
if 'self.assertTrue(' in content:
6666
print('WARNING: Found self.assertTrue( in source file! Auto-fixing...')
6767
# Count occurrences
6868
count = len(re.findall(r'self\.assertTrue\s*\(', content))
6969
print(f'Found {count} occurrence(s) of self.assertTrue(')
70-
70+
7171
# Replace all occurrences
7272
new_content = re.sub(r'self\.assertTrue\s*\(', 'self.assert_(', content)
73-
73+
7474
# Write back
7575
with open(file_path, 'w', encoding='utf-8') as f:
7676
f.write(new_content)
77-
77+
7878
# Verify the fix
7979
with open(file_path, 'r', encoding='utf-8') as f:
8080
verify_content = f.read()
@@ -95,7 +95,7 @@ jobs:
9595
# Verify source file is fixed before installation
9696
echo "=== Verifying source file after auto-fix ==="
9797
python -c "import sys; import io; sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace') if sys.platform == 'win32' else sys.stdout; content = open('sentience/agent_runtime.py', 'r', encoding='utf-8').read(); assert 'self.assertTrue(' not in content, 'Source file still has self.assertTrue( after auto-fix!'; print('OK: Source file verified: uses self.assert_()')"
98-
98+
9999
# Force reinstall to ensure latest code
100100
pip install --no-cache-dir --force-reinstall -e ".[dev]"
101101
pip install pre-commit mypy types-requests
@@ -118,15 +118,15 @@ jobs:
118118
import sys
119119
import inspect
120120
import os
121-
121+
122122
# Set UTF-8 encoding for Windows compatibility
123123
if sys.platform == 'win32':
124124
import io
125125
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
126126
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
127-
127+
128128
from sentience.agent_runtime import AgentRuntime
129-
129+
130130
# Verify it's using local source
131131
import sentience
132132
pkg_path = os.path.abspath(sentience.__file__)
@@ -138,7 +138,7 @@ jobs:
138138
print(f' This might be using PyPI package instead of local source!')
139139
else:
140140
print(f'OK: Package is from local source: {pkg_path}')
141-
141+
142142
source = inspect.getsource(AgentRuntime.assert_done)
143143
print('\nassert_done method source:')
144144
print(source)
@@ -164,27 +164,27 @@ jobs:
164164
run: |
165165
python << 'EOF'
166166
import sys
167-
167+
168168
# Set UTF-8 encoding for Windows compatibility
169169
if sys.platform == 'win32':
170170
import io
171171
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
172172
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
173-
173+
174174
# Check agent_runtime.py line 345
175175
print("=== Checking agent_runtime.py line 345 ===")
176176
with open('sentience/agent_runtime.py', 'r', encoding='utf-8') as f:
177177
lines = f.readlines()
178178
print(''.join(lines[339:350]))
179-
179+
180180
# Verify assert_ method exists
181181
print("\n=== Verifying assert_ method exists ===")
182182
with open('sentience/agent_runtime.py', 'r', encoding='utf-8') as f:
183183
lines = f.readlines()
184184
for i, line in enumerate(lines, 1):
185185
if 'def assert_' in line:
186186
print(f'{i}:{line}', end='')
187-
187+
188188
# Check for problematic assertTrue patterns (should NOT exist)
189189
print("\n=== Checking for assertTrue patterns (should NOT exist) ===")
190190
import re
@@ -237,30 +237,30 @@ jobs:
237237
import sys
238238
import re
239239
import os
240-
240+
241241
# Set UTF-8 encoding for Windows compatibility
242242
if sys.platform == 'win32':
243243
import io
244244
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
245245
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
246-
246+
247247
# Check the source file directly (not the installed package)
248248
file_path = 'sentience/agent_runtime.py'
249249
if not os.path.exists(file_path):
250250
print(f'WARNING: {file_path} not found!')
251251
sys.exit(0) # Don't fail if file doesn't exist
252-
252+
253253
with open(file_path, 'r', encoding='utf-8') as f:
254254
content = f.read()
255255
lines = content.split('\n')
256-
256+
257257
# Check for the problematic pattern: self.assertTrue(
258258
# This is the bug we're checking for - it should be self.assert_( instead
259259
problematic_lines = []
260260
for i, line in enumerate(lines, 1):
261261
if re.search(r'self\.assertTrue\s*\(', line):
262262
problematic_lines.append((i, line.strip()))
263-
263+
264264
if problematic_lines:
265265
print('WARNING: Found self.assertTrue( in agent_runtime.py')
266266
print('This should be self.assert_( instead!')
@@ -290,22 +290,22 @@ jobs:
290290
python << 'PYEOF'
291291
import sys
292292
import inspect
293-
293+
294294
# Set UTF-8 encoding for Windows compatibility
295295
if sys.platform == 'win32':
296296
import io
297297
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
298298
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
299-
299+
300300
import sentience.agent_runtime
301-
301+
302302
print("=== Final Pre-Test Verification ===")
303303
src = inspect.getsource(sentience.agent_runtime.AgentRuntime.assert_done)
304-
304+
305305
print("assert_done method source:")
306306
print(src)
307307
print("\n=== Analysis ===")
308-
308+
309309
if 'self.assertTrue(' in src:
310310
print('ERROR: Found self.assertTrue( in installed package!')
311311
print('The source code on this branch still has the bug.')

sentience/agent_runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def assert_done(
342342
Returns:
343343
True if task is complete (assertion passed), False otherwise
344344
"""
345-
ok = self.assert_(predicate, label=label, required=True)
345+
ok = self.assertTrue(predicate, label=label, required=True)
346346

347347
if ok:
348348
self._task_done = True

sentience/extension/background.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ async function handleSnapshotProcessing(rawData, options = {}) {
2828
const startTime = performance.now();
2929
try {
3030
if (!Array.isArray(rawData)) throw new Error("rawData must be an array");
31-
if (rawData.length > 1e4 && (rawData = rawData.slice(0, 1e4)), await initWASM(),
31+
if (rawData.length > 1e4 && (rawData = rawData.slice(0, 1e4)), await initWASM(),
3232
!wasmReady) throw new Error("WASM module not initialized");
3333
let analyzedElements, prunedRawData;
3434
try {
3535
const wasmPromise = new Promise((resolve, reject) => {
3636
try {
3737
let result;
38-
result = options.limit || options.filter ? analyze_page_with_options(rawData, options) : analyze_page(rawData),
38+
result = options.limit || options.filter ? analyze_page_with_options(rawData, options) : analyze_page(rawData),
3939
resolve(result);
4040
} catch (e) {
4141
reject(e);
@@ -101,4 +101,4 @@ initWASM().catch(err => {}), chrome.runtime.onMessage.addListener((request, send
101101
event.preventDefault();
102102
}), self.addEventListener("unhandledrejection", event => {
103103
event.preventDefault();
104-
});
104+
});

sentience/extension/content.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
if (!elements || !Array.isArray(elements)) return;
8383
removeOverlay();
8484
const host = document.createElement("div");
85-
host.id = OVERLAY_HOST_ID, host.style.cssText = "\n position: fixed !important;\n top: 0 !important;\n left: 0 !important;\n width: 100vw !important;\n height: 100vh !important;\n pointer-events: none !important;\n z-index: 2147483647 !important;\n margin: 0 !important;\n padding: 0 !important;\n ",
85+
host.id = OVERLAY_HOST_ID, host.style.cssText = "\n position: fixed !important;\n top: 0 !important;\n left: 0 !important;\n width: 100vw !important;\n height: 100vh !important;\n pointer-events: none !important;\n z-index: 2147483647 !important;\n margin: 0 !important;\n padding: 0 !important;\n ",
8686
document.body.appendChild(host);
8787
const shadow = host.attachShadow({
8888
mode: "closed"
@@ -94,15 +94,15 @@
9494
let color;
9595
color = isTarget ? "#FF0000" : isPrimary ? "#0066FF" : "#00FF00";
9696
const importanceRatio = maxImportance > 0 ? importance / maxImportance : .5, borderOpacity = isTarget ? 1 : isPrimary ? .9 : Math.max(.4, .5 + .5 * importanceRatio), fillOpacity = .2 * borderOpacity, borderWidth = isTarget ? 2 : isPrimary ? 1.5 : Math.max(.5, Math.round(2 * importanceRatio)), hexOpacity = Math.round(255 * fillOpacity).toString(16).padStart(2, "0"), box = document.createElement("div");
97-
if (box.style.cssText = `\n position: absolute;\n left: ${bbox.x}px;\n top: ${bbox.y}px;\n width: ${bbox.width}px;\n height: ${bbox.height}px;\n border: ${borderWidth}px solid ${color};\n background-color: ${color}${hexOpacity};\n box-sizing: border-box;\n opacity: ${borderOpacity};\n pointer-events: none;\n `,
97+
if (box.style.cssText = `\n position: absolute;\n left: ${bbox.x}px;\n top: ${bbox.y}px;\n width: ${bbox.width}px;\n height: ${bbox.height}px;\n border: ${borderWidth}px solid ${color};\n background-color: ${color}${hexOpacity};\n box-sizing: border-box;\n opacity: ${borderOpacity};\n pointer-events: none;\n `,
9898
importance > 0 || isPrimary) {
9999
const badge = document.createElement("span");
100-
badge.textContent = isPrimary ? `⭐${importance}` : `${importance}`, badge.style.cssText = `\n position: absolute;\n top: -18px;\n left: 0;\n background: ${color};\n color: white;\n font-size: 11px;\n font-weight: bold;\n padding: 2px 6px;\n font-family: Arial, sans-serif;\n border-radius: 3px;\n opacity: 0.95;\n white-space: nowrap;\n pointer-events: none;\n `,
100+
badge.textContent = isPrimary ? `⭐${importance}` : `${importance}`, badge.style.cssText = `\n position: absolute;\n top: -18px;\n left: 0;\n background: ${color};\n color: white;\n font-size: 11px;\n font-weight: bold;\n padding: 2px 6px;\n font-family: Arial, sans-serif;\n border-radius: 3px;\n opacity: 0.95;\n white-space: nowrap;\n pointer-events: none;\n `,
101101
box.appendChild(badge);
102102
}
103103
if (isTarget) {
104104
const targetIndicator = document.createElement("span");
105-
targetIndicator.textContent = "🎯", targetIndicator.style.cssText = "\n position: absolute;\n top: -18px;\n right: 0;\n font-size: 16px;\n pointer-events: none;\n ",
105+
targetIndicator.textContent = "🎯", targetIndicator.style.cssText = "\n position: absolute;\n top: -18px;\n right: 0;\n font-size: 16px;\n pointer-events: none;\n ",
106106
box.appendChild(targetIndicator);
107107
}
108108
shadow.appendChild(box);
@@ -120,7 +120,7 @@
120120
let overlayTimeout = null;
121121
function removeOverlay() {
122122
const existing = document.getElementById(OVERLAY_HOST_ID);
123-
existing && existing.remove(), overlayTimeout && (clearTimeout(overlayTimeout),
123+
existing && existing.remove(), overlayTimeout && (clearTimeout(overlayTimeout),
124124
overlayTimeout = null);
125125
}
126-
}();
126+
}();

0 commit comments

Comments
 (0)