init: workspace opencode sync

This commit is contained in:
2026-08-15 00:28:08 +07:00
commit 2451170708
122 changed files with 10549 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
# Test the fix_script logic locally
def fix_script(s):
s = s.replace(':pickk', ':pick')
s = s.replace(':pick', '\x00PICKGUARD\x00')
s = s.replace(':pic', ':pick')
s = s.replace('\x00PICKGUARD\x00', ':pick')
return s
# Test cases
test1 = ':local days [ :pic $d 4 6 ];' # original typo
test2 = ':local days [ :pickk $d 4 6 ];' # current broken state
test3 = ':local days [ :pick $d 4 6 ];' # already correct
test4 = ':local gettime [:pick $comment 12 20];' # correct $comment
test5 = ':local gettime [:pic $comment 12 20];' # original typo $comment
test6 = test1 + ' ' + test4 # mixed
for name, t in [('test1 orig typo', test1), ('test2 double-k', test2),
('test3 correct', test3), ('test4 comment ok', test4),
('test5 comment typo', test5), ('test6 mixed', test6)]:
result = fix_script(t)
pic = result.count(':pic')
pick = result.count(':pick')
pickk = result.count(':pickk')
print(f"{name}: pic={pic} pick={pick} pickk={pickk}")
if result != 'ERROR':
if pic == 0 and pick > 0:
print(f" OK: {result}")
else:
print(f" FAIL: {result}")
# Test with actual long script (simulated)
long_script = ';'.join([
':local dateint do={:local montharray ( "jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec" );:local days [ :pickk $d 4 6 ];:local month [ :pickk $d 0 3 ];:local year [ :pickk $d 7 11 ];:local monthint ([ :find $montharray $month]);:local month ($monthint + 1);:if ( [len $month] = 1) do={:local zero ("0");:return [:tonum ("$year$zero$month$days")];} else={:return [:tonum ("$year$month$days")];}}',
':local timeint do={ :local hours [ :pickk $t 0 2 ]; :local minutes [ :pickk $t 3 5 ]; :return ($hours * 60 + $minutes) ; }',
':local date [ /system clock get date ]',
':local time [ /system clock get time ]',
':local today [$dateint d=$date]',
':local curtime [$timeint t=$time]',
':foreach i in [ /ip hotspot user find where profile="test" ] do={ :local comment [ /ip hotspot user get $i comment]; :local name [ /ip hotspot user get $i name]; :local gettime [:pick $comment 12 20]; :if ([:pick $comment 3] = "/" and [:pick $comment 6] = "/") do={:local expd [$dateint d=$comment] ; :local expt [$timeint t=$gettime] ; :if (($expd < $today and $expt < $curtime)) do={ /ip hotspot user set limit-uptime=1s $i } } }'
])
print(f"\nLong script test:")
print(f" Before: pic={long_script.count(':pic')} pick={long_script.count(':pick')} pickk={long_script.count(':pickk')}")
result = fix_script(long_script)
print(f" After: pic={result.count(':pic')} pick={result.count(':pick')} pickk={result.count(':pickk')}")
if result.count(':pic') == 0:
print(" PASS: No :pic remaining")
else:
print(" FAIL: :pic still present")