vibe64 0.1.68 → 0.1.69
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/bin/run.js +644 -644
- package/bin/upgrade-state.js +2163 -2170
- package/node_modules/@local/vibe64-execution/package.json +1 -0
- package/node_modules/@local/vibe64-execution/src/host/execHelper.js +638 -634
- package/node_modules/@local/vibe64-genesis/src/server/agentSpecs.js +148 -120
- package/node_modules/@local/vibe64-genesis/src/server/index.js +612 -525
- package/node_modules/@local/vibe64-source-editor/src/server/searchIndexWorker.js +50 -46
- package/package.json +1 -1
- package/server.bundle.mjs +27333 -27361
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { createRequire as __vibe64CreateRequire } from 'node:module';const require=__vibe64CreateRequire(import.meta.url);
|
|
2
|
-
import{constants as
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
i
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import{constants as _}from"node:fs";import{lstat as b,mkdir as J,open as V,readdir as Q,readFile as Z}from"node:fs/promises";
|
|
3
|
+
import w from"node:path";import{DatabaseSync as q}from"node:sqlite";import{randomUUID as v}from"node:crypto";import{mkdir as j,open as L,rename as H,rm as z}from"node:fs/promises";import S from"node:path";
|
|
4
|
+
async function y(t,n,r={}){let{directoryMode:e,fileMode:i}=r,s=S.dirname(t);await j(s,{recursive:!0,mode:e});let c=S.join(
|
|
5
|
+
s,`.${S.basename(t)}.${process.pid}.${v()}.tmp`),E;try{let a=await L(c,"wx",i);try{await a.writeFile(n,"utf8"),i!==void 0&&
|
|
6
|
+
await a.chmod(i),await a.sync(),E=await a.stat({bigint:!0})}finally{await a.close()}await H(c,t)}finally{await z(c,{force:!0})}
|
|
7
|
+
return await W(s),E}async function W(t){let n=await L(t,"r");try{await n.sync()}finally{await n.close()}}var F=".vibe64",Y=`${F}/`,ce=Object.freeze([".git",".git/**"]);function x(t=""){return String(t??"").trim().replaceAll("\
|
|
8
|
+
\\","/").replace(/^\.\/+/u,"").replace(/\/+$/u,"")}function K(t=""){let n=x(t);return n===F||n.startsWith(Y)}function C(t=""){
|
|
9
|
+
let n="^",r=String(t||"");for(let e=0;e<r.length;e+=1){let i=r[e];if(i==="*"){r[e+1]==="*"?(n+=".*",e+=1):n+="[^/]*";continue}
|
|
10
|
+
n+=i.replace(/[\\^$+?.()|{}[\]]/gu,"\\$&")}return n+="$",new RegExp(n,"u")}function M(t="",n=""){let r=x(t),e=x(n);if(!r||
|
|
11
|
+
!e)return!1;if(!e.includes("/")&&!e.includes("*"))return r.split("/").includes(e);if(!e.includes("/")&&e.includes("*")){
|
|
12
|
+
let s=C(e);return r.split("/").some(c=>s.test(c))}let i=e.endsWith("/**")?e.slice(0,-3):e;return!i.includes("*")&&(r===i||
|
|
13
|
+
r.startsWith(`${i}/`))?!0:C(e).test(r)}function U(t={},n=""){let r=[n,String(n??"").toLowerCase()];return t.protectSourceContract!==
|
|
14
|
+
!1&&r.some(K)?!0:(Array.isArray(t.exclude)?t.exclude:[]).some(e=>r.some(i=>M(i,e)))}var ae=Object.freeze({pathMatchesPolicyPattern:M});var g=64*1024,B=240;function $(t,n=!1){let r=new q(w.join(t,"content.sqlite"),{readOnly:n,timeout:1e3});return n||r.exec(
|
|
11
15
|
`
|
|
12
16
|
PRAGMA journal_mode=WAL;
|
|
13
17
|
PRAGMA synchronous=NORMAL;
|
|
@@ -23,42 +27,42 @@ T);
|
|
|
23
27
|
CREATE TRIGGER IF NOT EXISTS chunks_removed AFTER DELETE ON chunks BEGIN
|
|
24
28
|
INSERT INTO terms(terms, rowid, text) VALUES ('delete', old.id, old.text);
|
|
25
29
|
END;
|
|
26
|
-
`),
|
|
27
|
-
let
|
|
28
|
-
includes(
|
|
29
|
-
let
|
|
30
|
-
let e="",
|
|
31
|
-
`);
|
|
32
|
-
`).length-1,
|
|
33
|
-
{encoding:"utf8",autoClose:!1})){if(
|
|
34
|
-
`,
|
|
35
|
-
!0}async function
|
|
36
|
-
"status.json");try{
|
|
37
|
-
scanned:0,total:0,changed:0,updatedAt:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
e.exec("ROLLBACK"),!["ENOENT","ENOTDIR","ELOOP"].includes(
|
|
48
|
-
T.id),e.exec("COMMIT"))}finally{await p?.close(),
|
|
49
|
-
f.run(
|
|
50
|
-
e.isTransaction&&e.exec("ROLLBACK"),e.exec("PRAGMA wal_checkpoint(TRUNCATE)"),e.close()}}function
|
|
51
|
-
limit:
|
|
52
|
-
""));let
|
|
30
|
+
`),r}function P(t){return`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`}async function*G(t,n,r=""){let e;try{
|
|
31
|
+
let i=w.join(t,r);if(!(await b(i)).isDirectory())return;e=await Q(i,{withFileTypes:!0})}catch(i){if(["ENOENT","ENOTDIR"].
|
|
32
|
+
includes(i.code))return;throw i}e.sort((i,s)=>i.name.localeCompare(s.name));for(let i of e){if(i.isSymbolicLink())continue;
|
|
33
|
+
let s=r?`${r}/${i.name}`:i.name;U(n,s)||(i.isDirectory()?yield*G(t,n,s):i.isFile()&&(yield s))}}async function ee(t,n,r){
|
|
34
|
+
let e="",i=1,s=1;function c(E,a){n.run(r,i,s,e.slice(0,E));let o=e.slice(0,a),d=o.lastIndexOf(`
|
|
35
|
+
`);i+=o.split(`
|
|
36
|
+
`).length-1,s=d<0?s+Buffer.byteLength(o):Buffer.byteLength(o.slice(d+1))+1,e=e.slice(a)}for await(let E of t.createReadStream(
|
|
37
|
+
{encoding:"utf8",autoClose:!1})){if(E.includes("\0"))return!1;for(e+=E;e.length>=g;){let a=e.lastIndexOf(`
|
|
38
|
+
`,g-1),o=a>=0?a+1:g;a<0&&/[\uD800-\uDBFF]/u.test(e[o-1])&&(o-=1);let d=a>=0?o:o-B;c(o,d)}}return e&&c(e.length,e.length),
|
|
39
|
+
!0}async function te({sourceRoot:t,directory:n,policy:r}){await J(n,{recursive:!0,mode:448});let e=$(n),i=null,s=w.join(
|
|
40
|
+
n,"status.json");try{i=JSON.parse(await Z(s,"utf8"))}catch(o){if(o.code!=="ENOENT")throw o}let c={state:"building",searchable:!0,
|
|
41
|
+
scanned:0,total:0,changed:0,updatedAt:i?.updatedAt||0},E=0,a=async(o=!1)=>{(o||Date.now()-E>500)&&(E=Date.now(),await y(
|
|
42
|
+
s,JSON.stringify(c),{fileMode:384}))};try{let o=new Map(e.prepare("SELECT id, path, stamp FROM files").all().map(l=>[l.path,
|
|
43
|
+
l])),d=[];await a(!0);for await(let l of G(t,r))d.push(l),c.total+=1,await a();let f=e.prepare("DELETE FROM chunks WHERE\
|
|
44
|
+
file_id = ?"),I=e.prepare("DELETE FROM files WHERE id = ?"),N=e.prepare("INSERT INTO files(path, stamp) VALUES (?, ?) O\
|
|
45
|
+
N CONFLICT(path) DO UPDATE SET stamp=excluded.stamp RETURNING id"),u=e.prepare("INSERT INTO chunks(file_id, line, column\
|
|
46
|
+
, text) VALUES (?, ?, ?, ?)");for(let l of d){let T=o.get(l);o.delete(l);let p;try{let m=w.join(t,l),O=t;for(let X of l.
|
|
47
|
+
split("/").slice(0,-1))if(O=w.join(O,X),!(await b(O)).isDirectory())throw Object.assign(new Error("Source directory chan\
|
|
48
|
+
ged."),{code:"ENOENT"});p=await V(m,_.O_RDONLY|_.O_NOFOLLOW|_.O_NONBLOCK);let h=await p.stat({bigint:!0});if(!h.isFile())
|
|
49
|
+
continue;let R=P(h);if(T?.stamp===R)continue;e.exec("BEGIN IMMEDIATE");let{id:A}=N.get(l,R);f.run(A),await ee(p,u,A)||f.
|
|
50
|
+
run(A),P(await p.stat({bigint:!0}))!==R?e.exec("ROLLBACK"):(e.exec("COMMIT"),c.changed+=1)}catch(m){if(e.isTransaction&&
|
|
51
|
+
e.exec("ROLLBACK"),!["ENOENT","ENOTDIR","ELOOP"].includes(m.code))throw m;T&&(e.exec("BEGIN IMMEDIATE"),f.run(T.id),I.run(
|
|
52
|
+
T.id),e.exec("COMMIT"))}finally{await p?.close(),c.scanned+=1,await a()}}e.exec("BEGIN IMMEDIATE");for(let l of o.values())
|
|
53
|
+
f.run(l.id),I.run(l.id),c.changed+=1;return e.exec("COMMIT"),c.state="ready",c.updatedAt=Date.now(),await a(!0),c}finally{
|
|
54
|
+
e.isTransaction&&e.exec("ROLLBACK"),e.exec("PRAGMA wal_checkpoint(TRUNCATE)"),e.close()}}function ne({directory:t,query:n,
|
|
55
|
+
limit:r}){let e=$(t,!0);try{let i=[...n.toLowerCase()],s=new Set;for(let u=0;u+2<i.length;u+=1)s.add(i.slice(u,u+3).join(
|
|
56
|
+
""));let c=s.size>0&&!/[^\x20-\x7e]/u.test(n),E=e.prepare(`SELECT c.id, f.path, c.line, c.column FROM chunks c JOIN file\
|
|
53
57
|
s f ON f.id=c.file_id
|
|
54
|
-
${
|
|
55
|
-
map(
|
|
56
|
-
|
|
57
|
-
let o
|
|
58
|
-
`).length-1,
|
|
59
|
-
`,T.index);if(
|
|
58
|
+
${c?"WHERE c.id IN (SELECT rowid FROM terms WHERE terms MATCH ?)":""} ORDER BY f.path, c.id`),a=c?E.iterate([...s].
|
|
59
|
+
map(u=>`"${u.replaceAll('"','""')}"`).join(" AND ")):E.iterate(),o=e.prepare("SELECT text FROM chunks WHERE id = ?"),d=new RegExp(
|
|
60
|
+
n.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&"),new RegExp("\\p{Lu}","u").test(n)?"gu":"giu"),f=[],I=new Set,N=Date.now()+4e3;for(let u of a){
|
|
61
|
+
let l=o.get(u.id).text;d.lastIndex=0;let T;for(;T=d.exec(l);){let p=l.slice(0,T.index),m=u.line+p.split(`
|
|
62
|
+
`).length-1,O=`${u.path}:${m}`,h=l.indexOf(`
|
|
63
|
+
`,T.index);if(d.lastIndex=h<0?l.length:h+1,I.has(O))continue;if(I.add(O),f.length===r)return{results:f,truncated:!0};let R=p.
|
|
60
64
|
lastIndexOf(`
|
|
61
|
-
`)+1;f.push({path:
|
|
62
|
-
h).replace(/\r$/u,"").slice(0,
|
|
63
|
-
e.close()}}var
|
|
64
|
-
|
|
65
|
+
`)+1;f.push({path:u.path,line:m,column:(R===0?u.column:1)+Buffer.byteLength(l.slice(R,T.index)),preview:l.slice(R,h<0?void 0:
|
|
66
|
+
h).replace(/\r$/u,"").slice(0,B)})}if(Date.now()>N)return{results:f,truncated:!0}}return{results:f,truncated:!1}}finally{
|
|
67
|
+
e.close()}}var k="";for await(let t of process.stdin)k+=t;var D=JSON.parse(k);try{let t=D.operation==="refresh"?await te(
|
|
68
|
+
D):ne(D);process.stdout.write(JSON.stringify(t))}catch(t){process.stderr.write(String(t?.message||t)),process.exitCode=1}
|