Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a34f0af

Browse files
ci: update server.bundle.mjs, cli.bundle.mjs & session hook bundles
1 parent 09f7d8a commit a34f0af

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

cli.bundle.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ FILE_CONTENT <- paste(FILE_CONTENT, collapse="\\n")
150150
${n}`;case"elixir":return`file_content_path = ${o}
151151
file_path = file_content_path
152152
file_content = File.read!(file_content_path)
153-
${n}`}}}});var Pk={};je(Pk,{BunSQLiteAdapter:()=>Mc,SQLiteBase:()=>Lc,applyWALPragmas:()=>Dc,closeDB:()=>ii,defaultDBPath:()=>Tk,deleteDBFiles:()=>Ek,loadDatabase:()=>Cn});import{createRequire as QN}from"node:module";import{unlinkSync as eA}from"node:fs";import{tmpdir as tA}from"node:os";import{join as rA}from"node:path";function Cn(){if(!jc){let t=QN(import.meta.url);try{let e=t("better-sqlite3");if(!e||typeof e!="function")throw new Error("better-sqlite3 loaded but not usable (Bun compatibility issue)");jc=e}catch{if(!globalThis.Bun)throw new Error("better-sqlite3 failed to load and Bun runtime not detected");let e=["bun","sqlite"].join(":"),r=t(e).Database;jc=function(o,s){let i=new r(o,{readonly:s?.readonly,create:!0});return new Mc(i)}}}return jc}function Dc(t){t.pragma("journal_mode = WAL"),t.pragma("synchronous = NORMAL")}function Ek(t){for(let e of["","-wal","-shm"])try{eA(t+e)}catch{}}function ii(t){try{t.pragma("wal_checkpoint(TRUNCATE)")}catch{}try{t.close()}catch{}}function Tk(t="context-mode"){return rA(tA(),`${t}-${process.pid}.db`)}var Mc,jc,Lc,ai=x(()=>{"use strict";Mc=class{#e;constructor(e){this.#e=e}pragma(e){let n=this.#e.prepare(`PRAGMA ${e}`).all();if(!n||n.length===0)return;if(n.length>1)return n;let o=Object.values(n[0]);return o.length===1?o[0]:n[0]}exec(e){let r="",n=null;for(let s=0;s<e.length;s++){let i=e[s];if(n)r+=i,i===n&&(n=null);else if(i==="'"||i==='"')r+=i,n=i;else if(i===";"){let a=r.trim();a&&this.#e.prepare(a).run(),r=""}else r+=i}let o=r.trim();return o&&this.#e.prepare(o).run(),this}prepare(e){let r=this.#e.prepare(e);return{run:(...n)=>r.run(...n),get:(...n)=>{let o=r.get(...n);return o===null?void 0:o},all:(...n)=>r.all(...n),iterate:(...n)=>r.iterate(...n)}}transaction(e){return this.#e.transaction(e)}close(){this.#e.close()}},jc=null;Lc=class{#e;#t;constructor(e){let r=Cn();this.#e=e,this.#t=new r(e,{timeout:5e3}),Dc(this.#t),this.initSchema(),this.prepareStatements()}get db(){return this.#t}get dbPath(){return this.#e}close(){ii(this.#t)}cleanup(){ii(this.#t),Ek(this.#e)}}});import{readFileSync as nA,readdirSync as Ck,unlinkSync as ph,existsSync as oA,statSync as Ik}from"node:fs";import{tmpdir as zk}from"node:os";import{join as mh}from"node:path";function sA(t,e="AND"){let r=t.replace(/['"(){}[\]*:^~]/g," ").split(/\s+/).filter(n=>n.length>0&&!["AND","OR","NOT","NEAR"].includes(n.toUpperCase()));return r.length===0?'""':r.map(n=>`"${n}"`).join(e==="OR"?" OR ":" ")}function iA(t,e="AND"){let r=t.replace(/["'(){}[\]*:^~]/g,"").trim();if(r.length<3)return"";let n=r.split(/\s+/).filter(o=>o.length>=3);return n.length===0?"":n.map(o=>`"${o}"`).join(e==="OR"?" OR ":" ")}function aA(t,e){if(t.length===0)return e.length;if(e.length===0)return t.length;let r=Array.from({length:e.length+1},(n,o)=>o);for(let n=1;n<=t.length;n++){let o=[n];for(let s=1;s<=e.length;s++)o[s]=t[n-1]===e[s-1]?r[s-1]:1+Math.min(r[s],o[s-1],r[s-1]);r=o}return r[e.length]}function cA(t){return t<=4?1:t<=12?2:3}function fh(){let t=zk(),e=0;try{let r=Ck(t);for(let n of r){let o=n.match(/^context-mode-(\d+)\.db$/);if(!o)continue;let s=parseInt(o[1],10);if(s!==process.pid)try{process.kill(s,0)}catch{let i=mh(t,n);for(let a of["","-wal","-shm"])try{ph(i+a)}catch{}e++}}}catch{}return e}function Nk(t,e){let r=0;try{if(!oA(t))return 0;let n=Date.now()-e*24*60*60*1e3,o=Ck(t).filter(s=>s.endsWith(".db"));for(let s of o)try{let i=mh(t,s);if(Ik(i).mtimeMs<n){for(let c of["","-wal","-shm"])try{ph(i+c)}catch{}r++}}catch{}}catch{}return r}function uA(t,e){let r=[],n=t.indexOf(e);for(;n!==-1;)r.push(n),n=t.indexOf(e,n+1);return r}function lA(t){if(t.length===0)return 1/0;if(t.length===1)return 0;let e=t.map(o=>[...o].sort((s,i)=>s-i)),r=new Array(e.length).fill(0),n=1/0;for(;;){let o=1/0,s=-1/0,i=0;for(let c=0;c<e.length;c++){let u=e[c][r[c]];u<o&&(o=u,i=c),u>s&&(s=u)}let a=s-o;if(a<n&&(n=a),r[i]++,r[i]>=e[i].length)break}return n}var Rk,Ok,Zc,Ak=x(()=>{"use strict";ai();Rk=new Set(["the","and","for","are","but","not","you","all","can","had","her","was","one","our","out","has","his","how","its","may","new","now","old","see","way","who","did","get","got","let","say","she","too","use","will","with","this","that","from","they","been","have","many","some","them","than","each","make","like","just","over","such","take","into","year","your","good","could","would","about","which","their","there","other","after","should","through","also","more","most","only","very","when","what","then","these","those","being","does","done","both","same","still","while","where","here","were","much","update","updates","updated","deps","dev","tests","test","add","added","fix","fixed","run","running","using"]);Ok=4096;Zc=class{#e;#t;#r;#n;#o;#i;#a;#s;#c;#u;#d;#p;#m;#f;#h;#g;#_;#y;#v;#x;#b;#S;#k;#w;#$;constructor(e){let r=Cn();this.#t=e??mh(zk(),`context-mode-${process.pid}.db`),this.#e=new r(this.#t,{timeout:5e3}),Dc(this.#e),this.#R(),this.#O()}cleanup(){try{this.#e.close()}catch{}for(let e of["","-wal","-shm"])try{ph(this.#t+e)}catch{}}#R(){this.#e.exec(`
153+
${n}`}}}});var Pk={};je(Pk,{BunSQLiteAdapter:()=>Mc,SQLiteBase:()=>Lc,applyWALPragmas:()=>Dc,closeDB:()=>ii,defaultDBPath:()=>Tk,deleteDBFiles:()=>Ek,loadDatabase:()=>Cn});import{createRequire as QN}from"node:module";import{unlinkSync as eA}from"node:fs";import{tmpdir as tA}from"node:os";import{join as rA}from"node:path";function Cn(){if(!jc){let t=QN(import.meta.url);try{let e=t("better-sqlite3");if(!e||typeof e!="function")throw new Error("better-sqlite3 loaded but not usable");new e(":memory:").close(),jc=e}catch{if(!globalThis.Bun)throw new Error("better-sqlite3 failed to load and Bun runtime not detected");let e=["bun","sqlite"].join(":"),r=t(e).Database;jc=function(o,s){let i=new r(o,{readonly:s?.readonly,create:!0});return new Mc(i)}}}return jc}function Dc(t){t.pragma("journal_mode = WAL"),t.pragma("synchronous = NORMAL")}function Ek(t){for(let e of["","-wal","-shm"])try{eA(t+e)}catch{}}function ii(t){try{t.pragma("wal_checkpoint(TRUNCATE)")}catch{}try{t.close()}catch{}}function Tk(t="context-mode"){return rA(tA(),`${t}-${process.pid}.db`)}var Mc,jc,Lc,ai=x(()=>{"use strict";Mc=class{#e;constructor(e){this.#e=e}pragma(e){let n=this.#e.prepare(`PRAGMA ${e}`).all();if(!n||n.length===0)return;if(n.length>1)return n;let o=Object.values(n[0]);return o.length===1?o[0]:n[0]}exec(e){let r="",n=null;for(let s=0;s<e.length;s++){let i=e[s];if(n)r+=i,i===n&&(n=null);else if(i==="'"||i==='"')r+=i,n=i;else if(i===";"){let a=r.trim();a&&this.#e.prepare(a).run(),r=""}else r+=i}let o=r.trim();return o&&this.#e.prepare(o).run(),this}prepare(e){let r=this.#e.prepare(e);return{run:(...n)=>r.run(...n),get:(...n)=>{let o=r.get(...n);return o===null?void 0:o},all:(...n)=>r.all(...n),iterate:(...n)=>r.iterate(...n)}}transaction(e){return this.#e.transaction(e)}close(){this.#e.close()}},jc=null;Lc=class{#e;#t;constructor(e){let r=Cn();this.#e=e,this.#t=new r(e,{timeout:5e3}),Dc(this.#t),this.initSchema(),this.prepareStatements()}get db(){return this.#t}get dbPath(){return this.#e}close(){ii(this.#t)}cleanup(){ii(this.#t),Ek(this.#e)}}});import{readFileSync as nA,readdirSync as Ck,unlinkSync as ph,existsSync as oA,statSync as Ik}from"node:fs";import{tmpdir as zk}from"node:os";import{join as mh}from"node:path";function sA(t,e="AND"){let r=t.replace(/['"(){}[\]*:^~]/g," ").split(/\s+/).filter(n=>n.length>0&&!["AND","OR","NOT","NEAR"].includes(n.toUpperCase()));return r.length===0?'""':r.map(n=>`"${n}"`).join(e==="OR"?" OR ":" ")}function iA(t,e="AND"){let r=t.replace(/["'(){}[\]*:^~]/g,"").trim();if(r.length<3)return"";let n=r.split(/\s+/).filter(o=>o.length>=3);return n.length===0?"":n.map(o=>`"${o}"`).join(e==="OR"?" OR ":" ")}function aA(t,e){if(t.length===0)return e.length;if(e.length===0)return t.length;let r=Array.from({length:e.length+1},(n,o)=>o);for(let n=1;n<=t.length;n++){let o=[n];for(let s=1;s<=e.length;s++)o[s]=t[n-1]===e[s-1]?r[s-1]:1+Math.min(r[s],o[s-1],r[s-1]);r=o}return r[e.length]}function cA(t){return t<=4?1:t<=12?2:3}function fh(){let t=zk(),e=0;try{let r=Ck(t);for(let n of r){let o=n.match(/^context-mode-(\d+)\.db$/);if(!o)continue;let s=parseInt(o[1],10);if(s!==process.pid)try{process.kill(s,0)}catch{let i=mh(t,n);for(let a of["","-wal","-shm"])try{ph(i+a)}catch{}e++}}}catch{}return e}function Nk(t,e){let r=0;try{if(!oA(t))return 0;let n=Date.now()-e*24*60*60*1e3,o=Ck(t).filter(s=>s.endsWith(".db"));for(let s of o)try{let i=mh(t,s);if(Ik(i).mtimeMs<n){for(let c of["","-wal","-shm"])try{ph(i+c)}catch{}r++}}catch{}}catch{}return r}function uA(t,e){let r=[],n=t.indexOf(e);for(;n!==-1;)r.push(n),n=t.indexOf(e,n+1);return r}function lA(t){if(t.length===0)return 1/0;if(t.length===1)return 0;let e=t.map(o=>[...o].sort((s,i)=>s-i)),r=new Array(e.length).fill(0),n=1/0;for(;;){let o=1/0,s=-1/0,i=0;for(let c=0;c<e.length;c++){let u=e[c][r[c]];u<o&&(o=u,i=c),u>s&&(s=u)}let a=s-o;if(a<n&&(n=a),r[i]++,r[i]>=e[i].length)break}return n}var Rk,Ok,Zc,Ak=x(()=>{"use strict";ai();Rk=new Set(["the","and","for","are","but","not","you","all","can","had","her","was","one","our","out","has","his","how","its","may","new","now","old","see","way","who","did","get","got","let","say","she","too","use","will","with","this","that","from","they","been","have","many","some","them","than","each","make","like","just","over","such","take","into","year","your","good","could","would","about","which","their","there","other","after","should","through","also","more","most","only","very","when","what","then","these","those","being","does","done","both","same","still","while","where","here","were","much","update","updates","updated","deps","dev","tests","test","add","added","fix","fixed","run","running","using"]);Ok=4096;Zc=class{#e;#t;#r;#n;#o;#i;#a;#s;#c;#u;#d;#p;#m;#f;#h;#g;#_;#y;#v;#x;#b;#S;#k;#w;#$;constructor(e){let r=Cn();this.#t=e??mh(zk(),`context-mode-${process.pid}.db`),this.#e=new r(this.#t,{timeout:5e3}),Dc(this.#e),this.#R(),this.#O()}cleanup(){try{this.#e.close()}catch{}for(let e of["","-wal","-shm"])try{ph(this.#t+e)}catch{}}#R(){this.#e.exec(`
154154
CREATE TABLE IF NOT EXISTS sources (
155155
id INTEGER PRIMARY KEY AUTOINCREMENT,
156156
label TEXT NOT NULL,

hooks/session-db.bundle.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{createRequire as T}from"node:module";import{unlinkSync as g}from"node:fs";import{tmpdir as h}from"node:os";import{join as y}from"node:path";var E=class{#t;constructor(t){this.#t=t}pragma(t){let s=this.#t.prepare(`PRAGMA ${t}`).all();if(!s||s.length===0)return;if(s.length>1)return s;let i=Object.values(s[0]);return i.length===1?i[0]:s[0]}exec(t){let e="",s=null;for(let o=0;o<t.length;o++){let a=t[o];if(s)e+=a,a===s&&(s=null);else if(a==="'"||a==='"')e+=a,s=a;else if(a===";"){let d=e.trim();d&&this.#t.prepare(d).run(),e=""}else e+=a}let i=e.trim();return i&&this.#t.prepare(i).run(),this}prepare(t){let e=this.#t.prepare(t);return{run:(...s)=>e.run(...s),get:(...s)=>{let i=e.get(...s);return i===null?void 0:i},all:(...s)=>e.all(...s),iterate:(...s)=>e.iterate(...s)}}transaction(t){return this.#t.transaction(t)}close(){this.#t.close()}},c=null;function R(){if(!c){let r=T(import.meta.url);try{let t=r("better-sqlite3");if(!t||typeof t!="function")throw new Error("better-sqlite3 loaded but not usable (Bun compatibility issue)");c=t}catch{if(!globalThis.Bun)throw new Error("better-sqlite3 failed to load and Bun runtime not detected");let t=["bun","sqlite"].join(":"),e=r(t).Database;c=function(i,o){let a=new e(i,{readonly:o?.readonly,create:!0});return new E(a)}}}return c}function S(r){r.pragma("journal_mode = WAL"),r.pragma("synchronous = NORMAL")}function v(r){for(let t of["","-wal","-shm"])try{g(r+t)}catch{}}function m(r){try{r.pragma("wal_checkpoint(TRUNCATE)")}catch{}try{r.close()}catch{}}function p(r="context-mode"){return y(h(),`${r}-${process.pid}.db`)}var u=class{#t;#e;constructor(t){let e=R();this.#t=t,this.#e=new e(t,{timeout:5e3}),S(this.#e),this.initSchema(),this.prepareStatements()}get db(){return this.#e}get dbPath(){return this.#t}close(){m(this.#e)}cleanup(){m(this.#e),v(this.#t)}};import{createHash as l}from"node:crypto";import{execFileSync as L}from"node:child_process";function U(){let r=process.env.CONTEXT_MODE_SESSION_SUFFIX;if(r!==void 0)return r?`__${r}`:"";try{let t=process.cwd(),e=L("git",["worktree","list","--porcelain"],{encoding:"utf-8",timeout:2e3,stdio:["ignore","pipe","ignore"]}).split(/\r?\n/).find(s=>s.startsWith("worktree "))?.replace("worktree ","")?.trim();if(e&&t!==e)return`__${l("sha256").update(t).digest("hex").slice(0,8)}`}catch{}return""}var N=1e3,f=5,n={insertEvent:"insertEvent",getEvents:"getEvents",getEventsByType:"getEventsByType",getEventsByPriority:"getEventsByPriority",getEventsByTypeAndPriority:"getEventsByTypeAndPriority",getEventCount:"getEventCount",checkDuplicate:"checkDuplicate",evictLowestPriority:"evictLowestPriority",updateMetaLastEvent:"updateMetaLastEvent",ensureSession:"ensureSession",getSessionStats:"getSessionStats",incrementCompactCount:"incrementCompactCount",upsertResume:"upsertResume",getResume:"getResume",markResumeConsumed:"markResumeConsumed",deleteEvents:"deleteEvents",deleteMeta:"deleteMeta",deleteResume:"deleteResume",getOldSessions:"getOldSessions"},_=class extends u{constructor(t){super(t?.dbPath??p("session"))}stmt(t){return this.stmts.get(t)}initSchema(){try{let e=this.db.pragma("table_xinfo(session_events)").find(s=>s.name==="data_hash");e&&e.hidden!==0&&this.db.exec("DROP TABLE session_events")}catch{}this.db.exec(`
1+
import{createRequire as T}from"node:module";import{unlinkSync as g}from"node:fs";import{tmpdir as h}from"node:os";import{join as y}from"node:path";var E=class{#t;constructor(t){this.#t=t}pragma(t){let s=this.#t.prepare(`PRAGMA ${t}`).all();if(!s||s.length===0)return;if(s.length>1)return s;let i=Object.values(s[0]);return i.length===1?i[0]:s[0]}exec(t){let e="",s=null;for(let o=0;o<t.length;o++){let a=t[o];if(s)e+=a,a===s&&(s=null);else if(a==="'"||a==='"')e+=a,s=a;else if(a===";"){let d=e.trim();d&&this.#t.prepare(d).run(),e=""}else e+=a}let i=e.trim();return i&&this.#t.prepare(i).run(),this}prepare(t){let e=this.#t.prepare(t);return{run:(...s)=>e.run(...s),get:(...s)=>{let i=e.get(...s);return i===null?void 0:i},all:(...s)=>e.all(...s),iterate:(...s)=>e.iterate(...s)}}transaction(t){return this.#t.transaction(t)}close(){this.#t.close()}},c=null;function R(){if(!c){let r=T(import.meta.url);try{let t=r("better-sqlite3");if(!t||typeof t!="function")throw new Error("better-sqlite3 loaded but not usable");new t(":memory:").close(),c=t}catch{if(!globalThis.Bun)throw new Error("better-sqlite3 failed to load and Bun runtime not detected");let t=["bun","sqlite"].join(":"),e=r(t).Database;c=function(i,o){let a=new e(i,{readonly:o?.readonly,create:!0});return new E(a)}}}return c}function S(r){r.pragma("journal_mode = WAL"),r.pragma("synchronous = NORMAL")}function v(r){for(let t of["","-wal","-shm"])try{g(r+t)}catch{}}function m(r){try{r.pragma("wal_checkpoint(TRUNCATE)")}catch{}try{r.close()}catch{}}function p(r="context-mode"){return y(h(),`${r}-${process.pid}.db`)}var u=class{#t;#e;constructor(t){let e=R();this.#t=t,this.#e=new e(t,{timeout:5e3}),S(this.#e),this.initSchema(),this.prepareStatements()}get db(){return this.#e}get dbPath(){return this.#t}close(){m(this.#e)}cleanup(){m(this.#e),v(this.#t)}};import{createHash as l}from"node:crypto";import{execFileSync as L}from"node:child_process";function U(){let r=process.env.CONTEXT_MODE_SESSION_SUFFIX;if(r!==void 0)return r?`__${r}`:"";try{let t=process.cwd(),e=L("git",["worktree","list","--porcelain"],{encoding:"utf-8",timeout:2e3,stdio:["ignore","pipe","ignore"]}).split(/\r?\n/).find(s=>s.startsWith("worktree "))?.replace("worktree ","")?.trim();if(e&&t!==e)return`__${l("sha256").update(t).digest("hex").slice(0,8)}`}catch{}return""}var N=1e3,f=5,n={insertEvent:"insertEvent",getEvents:"getEvents",getEventsByType:"getEventsByType",getEventsByPriority:"getEventsByPriority",getEventsByTypeAndPriority:"getEventsByTypeAndPriority",getEventCount:"getEventCount",checkDuplicate:"checkDuplicate",evictLowestPriority:"evictLowestPriority",updateMetaLastEvent:"updateMetaLastEvent",ensureSession:"ensureSession",getSessionStats:"getSessionStats",incrementCompactCount:"incrementCompactCount",upsertResume:"upsertResume",getResume:"getResume",markResumeConsumed:"markResumeConsumed",deleteEvents:"deleteEvents",deleteMeta:"deleteMeta",deleteResume:"deleteResume",getOldSessions:"getOldSessions"},_=class extends u{constructor(t){super(t?.dbPath??p("session"))}stmt(t){return this.stmts.get(t)}initSchema(){try{let e=this.db.pragma("table_xinfo(session_events)").find(s=>s.name==="data_hash");e&&e.hidden!==0&&this.db.exec("DROP TABLE session_events")}catch{}this.db.exec(`
22
CREATE TABLE IF NOT EXISTS session_events (
33
id INTEGER PRIMARY KEY AUTOINCREMENT,
44
session_id TEXT NOT NULL,

0 commit comments

Comments
 (0)