@precisionutilityguild/liquid-shadow 1.0.5 → 1.0.7
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/README.md +6 -6
- package/dist/data/migrations/000_baseline.sql +38 -0
- package/dist/data/migrations/010_type_graph_edges.sql +27 -0
- package/dist/data/migrations/011_handoff_embeddings.sql +2 -0
- package/dist/data/migrations/012_ember_state.sql +18 -0
- package/dist/entry/cli/index.js +525 -573
- package/dist/entry/ember/index.js +545 -0
- package/dist/entry/mcp/server.js +505 -350
- package/dist/index.js +490 -337
- package/dist/logic/domain/embeddings/worker.js +1 -1
- package/dist/skills/shadow_audit/SKILL.md +3 -0
- package/dist/skills/shadow_continue/SKILL.md +18 -10
- package/dist/skills/shadow_mission/SKILL.md +11 -8
- package/dist/skills/shadow_onboard/SKILL.md +15 -11
- package/dist/skills/shadow_sync/SKILL.md +1 -1
- package/dist/skills/shadow_synthesize/SKILL.md +7 -6
- package/dist/skills/shadow_understand/SKILL.md +19 -13
- package/dist/web-manifest.json +35 -28
- package/package.json +2 -2
- package/skills/shadow_audit/SKILL.md +3 -0
- package/skills/shadow_continue/SKILL.md +18 -10
- package/skills/shadow_mission/SKILL.md +11 -8
- package/skills/shadow_onboard/SKILL.md +15 -11
- package/skills/shadow_sync/SKILL.md +1 -1
- package/skills/shadow_synthesize/SKILL.md +7 -6
- package/skills/shadow_understand/SKILL.md +19 -13
package/dist/entry/cli/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var Oc=Object.create;var Gi=Object.defineProperty;var Fc=Object.getOwnPropertyDescriptor;var Wc=Object.getOwnPropertyNames;var Hc=Object.getPrototypeOf,zc=Object.prototype.hasOwnProperty;var Uc=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var Z=(s,e)=>()=>(s&&(e=s(s=0)),e);var jc=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),qi=(s,e)=>{for(var t in e)Gi(s,t,{get:e[t],enumerable:!0})},Bc=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Wc(e))!zc.call(s,i)&&i!==t&&Gi(s,i,{get:()=>e[i],enumerable:!(n=Fc(e,i))||n.enumerable});return s};var Gc=(s,e,t)=>(t=s!=null?Oc(Hc(s)):{},Bc(e||!s||!s.__esModule?Gi(t,"default",{value:s,enumerable:!0}):t,s));import qc from"pino";var Vc,Jc,S,q=Z(()=>{"use strict";Vc={10:"TRACE",20:"DEBUG",30:"INFO",40:"WARN",50:"ERROR",60:"FATAL"},Jc=qc({level:process.env.LOG_LEVEL||"warn",base:{service:"liquid-shadow"},formatters:{level(s,e){return{level:s,severity:Vc[e]??"INFO"}}},transport:{target:"pino-pretty",options:{colorize:!0,translateTime:"HH:MM:ss",destination:2,levelKey:"severity",messageKey:"message"}}}),S=Jc});import Et from"fs";import xn from"path";import{fileURLToPath as Qc}from"url";function el(){let s=Zc;if(Et.readdirSync(s).some(n=>n.match(/^\d{3}_.*\.sql$/)))return s;let t=xn.resolve(s,"../../data/migrations");return Et.existsSync(t)&&Et.readdirSync(t).some(n=>n.match(/^\d{3}_.*\.sql$/))?t:s}function tl(s){s.exec(`
|
|
3
3
|
CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
4
4
|
version INTEGER PRIMARY KEY,
|
|
5
5
|
name TEXT NOT NULL,
|
|
6
6
|
applied_at REAL DEFAULT (unixepoch())
|
|
7
7
|
);
|
|
8
|
-
`)}function
|
|
8
|
+
`)}function nl(s){tl(s);let e=s.prepare("SELECT version FROM schema_migrations ORDER BY version").all();return new Set(e.map(t=>t.version))}function il(s){return Et.readdirSync(s).filter(t=>t.match(/^\d{3}_.*\.sql$/)&&!t.startsWith("000_")).sort().map(t=>{let n=t.match(/^(\d{3})_(.+)\.sql$/),i=parseInt(n[1],10),r=n[2],a=Et.readFileSync(xn.join(s,t),"utf-8").split(/^-- DOWN$/m);return{version:i,name:r,up:a[0].trim(),down:a[1]?.trim()}})}function sl(s,e){st.info({version:e.version,name:e.name},"Applying migration"),s.transaction(()=>{s.exec(e.up),s.prepare("INSERT INTO schema_migrations (version, name) VALUES (?, ?)").run(e.version,e.name)})(),st.info({version:e.version},"Migration applied successfully")}function rl(s,e,t){let n=xn.join(e,"000_baseline.sql");if(!Et.existsSync(n)){st.warn("000_baseline.sql not found \u2014 falling back to incremental migrations");return}st.info("Fresh database detected \u2014 applying consolidated baseline schema");let i=Et.readFileSync(n,"utf-8");s.transaction(()=>{s.exec(i);let r=s.prepare("INSERT OR IGNORE INTO schema_migrations (version, name) VALUES (?, ?)");for(let o of t)r.run(o.version,o.name)})(),st.info({stamped:t.length},"Baseline applied \u2014 incremental migrations stamped")}function tr(s){let e=nl(s),t=el(),n=il(t);if(e.size===0){rl(s,t,n);return}let i=n.filter(r=>!e.has(r.version));if(i.length===0){st.debug("No pending migrations");return}st.info({count:i.length},"Running pending migrations");for(let r of i)sl(s,r);st.info("All migrations complete")}var st,Xc,Zc,nr=Z(()=>{"use strict";q();st=S.child({module:"migrations"}),Xc=Qc(import.meta.url),Zc=xn.dirname(Xc)});import ol from"better-sqlite3";import vn from"path";import Ji from"fs";import ir from"crypto";import al from"os";function Rn(s){let e=al.homedir(),t=vn.join(e,".mcp-liquid-shadow"),n=vn.join(t,"dbs");Ji.existsSync(n)||Ji.mkdirSync(n,{recursive:!0});let i=ir.createHash("sha256").update(s).digest("hex").substring(0,12),o=`${vn.basename(s).replace(/[^a-zA-Z0-9-_]/g,"_")}_${i}.db`;return vn.join(n,o)}function cl(s,e){let t=e||Rn(s);Qe.debug({repoPath:s,dbPath:t},"Initializing database");let n=new ol(t);return n.pragma("journal_mode = WAL"),n.pragma("busy_timeout = 5000"),tr(n),Tn.set(s,t),rt.set(t,n),Qe.debug({repoPath:s,dbPath:t},"Database initialized successfully"),n}function Nt(s){return ir.createHash("sha256").update(s,"utf8").digest("hex")}function sr(s,e){return e?Nt(s)!==e:!0}function Te(s){let e=Tn.get(s)||Rn(s),t=rt.get(e);if(t){if(t.open)return t;rt.delete(e)}let n=cl(s);return rt.set(e,n),n}function Xe(s){let e=Rn(s);if(!Ji.existsSync(e))return!1;try{let t=Te(s);return t.prepare(`
|
|
9
9
|
SELECT value FROM index_metadata
|
|
10
10
|
WHERE key = 'index_completed'
|
|
11
|
-
`).get()?.value==="true"?!0:
|
|
11
|
+
`).get()?.value==="true"?!0:t.prepare("SELECT COUNT(*) as count FROM files").get().count>0}catch(t){return Qe.debug({repoPath:s,error:t},"Error checking index status"),!1}}function Yi(s,e){let t=Te(s),n=t.prepare("INSERT OR REPLACE INTO index_metadata (key, value, updated_at) VALUES (?, ?, unixepoch())");t.transaction(()=>{n.run("index_completed","true"),n.run("last_indexed_at",Date.now().toString()),e&&n.run("last_indexed_commit",e)})(),Qe.debug({repoPath:s,commitSha:e},"Repository marked as indexed")}function nn(s){try{return Te(s).prepare(`
|
|
12
12
|
SELECT value FROM index_metadata
|
|
13
13
|
WHERE key = 'last_indexed_commit'
|
|
14
|
-
`).get()?.value||null}catch(e){return
|
|
14
|
+
`).get()?.value||null}catch(e){return Qe.debug({repoPath:s,error:e},"Error getting last indexed commit"),null}}function kn(s){let e=Tn.get(s)||Rn(s),t=rt.get(e);t&&(t.open&&(Qe.debug({repoPath:s,dbPath:e},"Closing database connection"),t.close()),rt.delete(e)),Tn.delete(s)}function rr(){for(let[s,e]of rt.entries())try{e.open&&(Qe.debug({dbPath:s},"Closing database connection"),e.close())}catch(t){Qe.error({dbPath:s,err:t},"Error closing database execution")}rt.clear()}var Qe,rt,Tn,or,Ze=Z(()=>{"use strict";q();nr();Qe=S.child({module:"db"});rt=new Map,Tn=new Map;process.on("exit",()=>rr());or=s=>{Qe.debug({signal:s},"Received termination signal, closing databases"),rr(),process.exit(0)};process.on("SIGINT",()=>or("SIGINT"));process.on("SIGTERM",()=>or("SIGTERM"))});var ae,Ue=Z(()=>{"use strict";ae=class{db;constructor(e){this.db=e}get database(){return this.db}all(e,...t){return this.db.prepare(e).all(...t)}get(e,...t){return this.db.prepare(e).get(...t)}run(e,...t){return this.db.prepare(e).run(...t).changes}insert(e,...t){return this.db.prepare(e).run(...t).lastInsertRowid}transaction(e){return this.db.transaction(e)()}}});function pl(s,e){if(!s)return!1;let t=s.trim();return!t||ll.has(t.toLowerCase())||e.has(t)?!1:/^[A-Za-z_$][A-Za-z0-9_$.]*$/.test(t)}function ul(s){return s.split(/[,|&]/).map(e=>e.trim()).filter(Boolean)}function dl(s){let e=s.replace(/^[({\[]+/,"").replace(/[)}\]]+$/,"").replace(/^readonly\s+/,"").trim();return e&&e.match(/^([A-Za-z_$][A-Za-z0-9_$.]*)/)?.[1]||null}function ml(s){let e=[],t=0,n="",i=!1;for(let r of s){if(r==="<"&&(t++,t===1)){i=!0,n="";continue}if(r===">"&&(t>0&&t--,t===0&&i)){i=!1,n.trim()&&e.push(n),n="";continue}i&&(n+=r)}return e}function hl(s){let e=new Set;for(let t of s){let n=t.split(",").map(i=>i.trim());for(let i of n){let r=i.match(/^([A-Za-z_$][A-Za-z0-9_$]*)/);r?.[1]&&e.add(r[1])}}return e}function Ki(s,e){let t=[];for(let n of ul(s)){let i=dl(n);i&&pl(i,e)&&t.push(i)}return t}function ar(s){if(!s)return[];let e=s.replace(/\s+/g," ").trim();if(!e)return[];let t=ml(e),n=hl(t),i=[],r=new Set,o=(l,p,u)=>{let d=`${l}:${p}`;r.has(d)||(r.add(d),i.push({relationship:l,targetName:p,...u?{metadata:u}:{}}))},a=e.match(/\bextends\s+(.+?)(?=\bimplements\b|\{|=|$)/);if(a?.[1]){let l=Ki(a[1],n);for(let p of l)o("extends",p,a[1].trim())}let c=e.match(/\bimplements\s+(.+?)(?=\{|=|$)/);if(c?.[1]){let l=Ki(c[1],n);for(let p of l)o("implements",p,c[1].trim())}for(let l of t){let p=/([A-Za-z_$][A-Za-z0-9_$]*)\s+extends\s+([^,>]+)/g,u=null;for(;(u=p.exec(l))!==null;){let d=u[2]?.trim();if(!d)continue;let h=Ki(d,n);for(let m of h)o("constrained_by",m,d)}}return i}var ll,cr=Z(()=>{"use strict";ll=new Set(["any","unknown","never","void","null","undefined","string","number","boolean","symbol","object","bigint","readonly","keyof","infer","extends","implements","class","interface","type","function","new"])});import fl from"path";var Cn,lr=Z(()=>{"use strict";Ue();cr();Cn=class extends ae{findByPath(e){return this.get("SELECT * FROM files WHERE path = ?",e)}findAll(e){let t="SELECT * FROM files ORDER BY path ASC";return e&&(t+=` LIMIT ${e}`),this.all(t)}getAllPaths(){return this.all("SELECT path FROM files").map(t=>t.path)}findInSubPath(e,t){let n=fl.resolve(e,t),i=n.endsWith("/")?n:n+"/";return this.all(`
|
|
15
15
|
SELECT * FROM files
|
|
16
16
|
WHERE (path LIKE ? OR path = ?)
|
|
17
17
|
ORDER BY path ASC
|
|
18
|
-
`,`${
|
|
18
|
+
`,`${i}%`,n)}findWithEmbeddings(){return this.all("SELECT * FROM files WHERE embedding IS NOT NULL")}findFts(e,t=10){return this.all(`
|
|
19
19
|
SELECT files.*, files_fts.rank
|
|
20
20
|
FROM files_fts
|
|
21
21
|
JOIN files ON files.rowid = files_fts.rowid
|
|
22
22
|
WHERE files_fts MATCH ?
|
|
23
23
|
ORDER BY rank
|
|
24
24
|
LIMIT ?
|
|
25
|
-
`,e,
|
|
25
|
+
`,e,t)}findByPathKeywords(e,t=10){let n=e.map(()=>"LOWER(path) LIKE ?").join(" OR ");return this.all(`
|
|
26
26
|
SELECT * FROM files
|
|
27
|
-
WHERE ${
|
|
27
|
+
WHERE ${n}
|
|
28
28
|
LIMIT ?
|
|
29
|
-
`,...e.map(
|
|
29
|
+
`,...e.map(i=>`%${i}%`),t)}findContentFts(e,t=50){let n=this.buildContentFtsQuery(e);return n?this.all(`
|
|
30
30
|
SELECT
|
|
31
31
|
files.*,
|
|
32
32
|
bm25(content_fts, 0.2, 1.0) AS bm25_rank
|
|
@@ -35,7 +35,7 @@ var lx=Object.create;var pc=Object.defineProperty;var ux=Object.getOwnPropertyDe
|
|
|
35
35
|
WHERE content_fts MATCH ?
|
|
36
36
|
ORDER BY bm25_rank ASC
|
|
37
37
|
LIMIT ?
|
|
38
|
-
`,
|
|
38
|
+
`,n,Math.max(1,Math.min(t,1e3))):[]}getContent(e){return this.get("SELECT content FROM file_content WHERE file_path = ?",e)?.content}findContentByToken(e,t=10){return this.all(`
|
|
39
39
|
SELECT file_path
|
|
40
40
|
FROM content_fts
|
|
41
41
|
WHERE content_fts MATCH ?
|
|
@@ -43,28 +43,28 @@ var lx=Object.create;var pc=Object.defineProperty;var ux=Object.getOwnPropertyDe
|
|
|
43
43
|
AND file_path NOT LIKE '%/test/%'
|
|
44
44
|
AND file_path NOT LIKE '%.spec.%'
|
|
45
45
|
LIMIT ?
|
|
46
|
-
`,`"${e.replace(/[^a-zA-Z0-9_\/]/g," ")}"`,
|
|
46
|
+
`,`"${e.replace(/[^a-zA-Z0-9_\/]/g," ")}"`,t).map(i=>i.file_path)}findSynapses(e){let t="SELECT * FROM event_synapses WHERE 1=1",n=[];if(e.type&&(t+=" AND type = ?",n.push(e.type)),e.name){let i=e.name;i.startsWith("/")&&(i=i.substring(1)),i.endsWith("/")&&(i=i.substring(0,i.length-1)),i.length>0&&(t+=" AND (name LIKE ? OR name LIKE ? OR name = ?)",n.push(`${i}%`),n.push(`%/${i}%`),n.push(e.name))}return e.direction&&(t+=" AND direction = ?",n.push(e.direction)),t+=` LIMIT ${e.limit||50}`,this.all(t,...n)}exists(e){return!!this.get("SELECT 1 FROM files WHERE path = ?",e)}update(e,t){let n=Object.keys(t);if(n.length===0)return;let i=n.map(o=>`${o} = ?`).join(", "),r=Object.values(t);r.push(e),this.run(`UPDATE files SET ${i} WHERE path = ?`,...r)}getStats(){let e=this.get(`
|
|
47
47
|
SELECT
|
|
48
48
|
COUNT(*) as total,
|
|
49
49
|
SUM(CASE WHEN summary IS NOT NULL AND summary != '' THEN 1 ELSE 0 END) as withSummary
|
|
50
50
|
FROM files
|
|
51
|
-
`);return{total:e?.total||0,withSummary:e?.withSummary||0}}getGravityMap(e=[],
|
|
51
|
+
`);return{total:e?.total||0,withSummary:e?.withSummary||0}}getGravityMap(e=[],t){let n={},i=`
|
|
52
52
|
SELECT ws.file_path, m.name as mission_name, m.status
|
|
53
53
|
FROM working_set ws
|
|
54
54
|
JOIN missions m ON ws.mission_id = m.id
|
|
55
55
|
WHERE (
|
|
56
|
-
(m.status IN ('in-progress', 'verifying') ${
|
|
56
|
+
(m.status IN ('in-progress', 'verifying') ${t?"AND m.git_branch = ?":""})
|
|
57
57
|
OR m.id IN (${e.length>0?e.join(","):"-1"})
|
|
58
58
|
)
|
|
59
59
|
AND ws.file_path IS NOT NULL
|
|
60
|
-
`,
|
|
60
|
+
`,r=[];t&&r.push(t);let o=this.all(i,...r);for(let l of o){n[l.file_path]||(n[l.file_path]={score:1,reasons:[]});let p=l.status==="in-progress"||l.status==="verifying"?1:.5;n[l.file_path].score+=p;let u=l.status==="in-progress"||l.status==="verifying"?"Working Set":"Lineage Bleed";n[l.file_path].reasons.push(`${u}: ${l.mission_name}`)}let a=Math.floor(Date.now()/1e3)-86400,c=this.all(`
|
|
61
61
|
SELECT file_path, type, mission_id
|
|
62
62
|
FROM intent_logs
|
|
63
63
|
WHERE (created_at > ? OR mission_id IN (${e.length>0?e.join(","):"-1"}))
|
|
64
64
|
AND file_path IS NOT NULL
|
|
65
65
|
ORDER BY created_at DESC
|
|
66
66
|
LIMIT 100
|
|
67
|
-
`,a);for(let l of c){
|
|
67
|
+
`,a);for(let l of c){n[l.file_path]||(n[l.file_path]={score:1,reasons:[]});let p=l.mission_id?e.includes(l.mission_id):!1,u=p?.1:.2;n[l.file_path].score<5&&(n[l.file_path].score+=u);let d=p?`Lineage Intent: ${l.type}`:`Recent Intent: ${l.type}`;!n[l.file_path].reasons.includes(d)&&n[l.file_path].reasons.length<5&&n[l.file_path].reasons.push(d)}return n}getCount(){return this.get("SELECT COUNT(*) as count FROM files")?.count||0}getTopDirectories(e,t=8){return this.all(`
|
|
68
68
|
SELECT
|
|
69
69
|
SUBSTR(path, LENGTH(?) + 2,
|
|
70
70
|
INSTR(SUBSTR(path, LENGTH(?) + 2), '/') - 1
|
|
@@ -81,13 +81,13 @@ var lx=Object.create;var pc=Object.defineProperty;var ux=Object.getOwnPropertyDe
|
|
|
81
81
|
GROUP BY root
|
|
82
82
|
ORDER BY total_files DESC
|
|
83
83
|
LIMIT ?
|
|
84
|
-
`,e,e,e,
|
|
84
|
+
`,e,e,e,t)}hasFilesPattern(e){return!!this.get("SELECT 1 FROM files WHERE path LIKE ? LIMIT 1",e)}findPackageJsonChildren(e){return this.all(`
|
|
85
85
|
SELECT
|
|
86
86
|
path,
|
|
87
87
|
SUBSTR(path, LENGTH(?) + 2) as relPath
|
|
88
88
|
FROM files
|
|
89
89
|
WHERE path LIKE ? || '/%/package.json'
|
|
90
|
-
`,e,e)}deletePaths(e){if(e.length===0)return;let
|
|
90
|
+
`,e,e)}deletePaths(e){if(e.length===0)return;let t=this.db.prepare("DELETE FROM files WHERE path = ?");this.db.transaction(i=>{for(let r of i)t.run(r)})(e)}updateMtime(e,t){this.run("UPDATE files SET mtime = ? WHERE path = ?",t,e)}batchSaveIndexResults(e,t,n,i){let r=this.db.prepare("DELETE FROM exports WHERE file_path = ?"),o=this.db.prepare("DELETE FROM imports WHERE file_path = ?"),a=this.db.prepare("DELETE FROM configs WHERE file_path = ?"),c=this.db.prepare("DELETE FROM file_content WHERE file_path = ?"),l=this.db.prepare("DELETE FROM event_synapses WHERE file_path = ?"),p=this.db.prepare("DELETE FROM type_graph_edges WHERE file_path = ?"),u=this.db.prepare("INSERT INTO exports (file_path, name, kind, signature, doc, start_line, end_line, classification, capabilities, parent_id, embedding) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"),d=this.db.prepare("INSERT INTO imports (file_path, module_specifier, imported_symbols, resolved_path) VALUES (?, ?, ?, ?)"),h=this.db.prepare("INSERT INTO configs (file_path, key, value, kind) VALUES (?, ?, ?, ?)"),m=this.db.prepare("INSERT INTO file_content (file_path, content) VALUES (?, ?)"),f=this.db.prepare("INSERT INTO event_synapses (file_path, type, name, direction, line_number, code_snippet) VALUES (?, ?, ?, ?, ?, ?)"),_=this.db.prepare("INSERT INTO type_graph_edges (file_path, source_symbol_id, source_symbol_name, target_symbol_name, relationship, line_number, metadata) VALUES (?, ?, ?, ?, ?, ?, ?)"),g=this.db.prepare(`
|
|
91
91
|
INSERT INTO files (path, mtime, last_scanned_at, classification, summary, embedding, content_hash)
|
|
92
92
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
93
93
|
ON CONFLICT(path) DO UPDATE SET
|
|
@@ -97,36 +97,42 @@ var lx=Object.create;var pc=Object.defineProperty;var ux=Object.getOwnPropertyDe
|
|
|
97
97
|
summary=excluded.summary,
|
|
98
98
|
embedding=excluded.embedding,
|
|
99
99
|
content_hash=excluded.content_hash
|
|
100
|
-
`),
|
|
100
|
+
`),b=this.db.transaction(x=>{for(let R of x){let{meta:k,exports:D,imports:U,configs:P,events:E,content:T,classification:I,summary:M,embedding:N,contentHash:$}=R;r.run(k.path),o.run(k.path),a.run(k.path),c.run(k.path),l.run(k.path),p.run(k.path);let W=$??(T&&n?n(T):null);if(g.run(k.path,k.mtime,Date.now(),I||"Unknown",M||"",N?JSON.stringify(N):null,W),D){let L=(A,H,F)=>{for(let v of H){let C=v.embedding?JSON.stringify(v.embedding):null,B=u.run(A,v.name,v.kind,v.signature,v.doc||"",v.line,v.endLine||v.line,v.classification||"Other",v.capabilities||"[]",F,C),j=Number(B.lastInsertRowid);if(Number.isFinite(j)){let J=ar(v.signature);for(let z of J)z.targetName!==v.name&&_.run(A,j,v.name,z.targetName,z.relationship,v.line,z.metadata||null)}v.members&&v.members.length>0&&L(A,v.members,B.lastInsertRowid)}};L(k.path,D,null)}if(U)for(let L of U){let A=L.resolved_path!==void 0?L.resolved_path:i?.(L.module,k.path,t)??"";d.run(k.path,L.module,L.name,A)}if(P)for(let L of P)h.run(k.path,L.key,L.value,L.kind);if(T!==void 0&&m.run(k.path,T),E)for(let L of E)f.run(k.path,L.type,L.name,L.direction,L.line,L.snippet)}}),w=500;for(let x=0;x<e.length;x+=w)b(e.slice(x,x+w))}getLatestScanTime(){return this.get("SELECT MAX(last_scanned_at) as t FROM files")?.t||null}buildContentFtsQuery(e){let t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9_]+/).map(r=>r.trim()).filter(r=>r.length>=2).slice(0,12);if(t.length===0)return"";if(t.length===1)return`${t[0]}*`;let n=`"${t.join(" ")}"`,i=t.map(r=>`${r}*`).join(" OR ");return`${n} OR ${i}`}}});var In,pr=Z(()=>{"use strict";Ue();In=class s extends ae{static HTTP_METHOD_EXPORTS=new Set(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"]);findByNameAndFile(e,t){return this.all("SELECT * FROM exports WHERE file_path = ? AND name = ?",t,e)}findByNameGlobal(e){return this.all("SELECT * FROM exports WHERE name = ?",e)}findAtLine(e,t){return this.get(`
|
|
101
101
|
SELECT * FROM exports
|
|
102
102
|
WHERE file_path = ? AND start_line <= ? AND end_line >= ?
|
|
103
103
|
ORDER BY (end_line - start_line) ASC -- Get innermost symbol
|
|
104
104
|
LIMIT 1
|
|
105
|
-
`,e,
|
|
105
|
+
`,e,t,t)}findById(e){return this.get("SELECT * FROM exports WHERE id = ?",e)}findHydratedById(e){let t=this.findById(e);if(!t)return;let n=this.all(`
|
|
106
106
|
SELECT id, mission_id, type, content, created_at, confidence, is_crystallized, crystal_id
|
|
107
107
|
FROM intent_logs
|
|
108
108
|
WHERE symbol_id = ?
|
|
109
109
|
ORDER BY created_at DESC
|
|
110
110
|
LIMIT 10
|
|
111
|
-
`,e),
|
|
111
|
+
`,e),r=this.get("SELECT COUNT(*) as count FROM intent_logs WHERE symbol_id = ?",e)?.count||0,o=this.all(`
|
|
112
112
|
SELECT m.id, m.name, m.status
|
|
113
113
|
FROM missions m
|
|
114
114
|
JOIN working_set ws ON ws.mission_id = m.id
|
|
115
115
|
WHERE ws.symbol_id = ?
|
|
116
116
|
AND m.status IN ('in-progress', 'planned', 'verifying')
|
|
117
117
|
GROUP BY m.id
|
|
118
|
-
`,e);return{...
|
|
118
|
+
`,e);return{...t,recent_intents:n,intent_log_count:r,active_missions:o}}findRoutesByCapability(e){return this.all(`
|
|
119
119
|
SELECT name, file_path, signature
|
|
120
120
|
FROM exports
|
|
121
121
|
WHERE kind = 'HTTP Route'
|
|
122
122
|
AND capabilities LIKE ?
|
|
123
|
-
`,`%${e}%`)}findRoutesByToken(e,
|
|
123
|
+
`,`%${e}%`)}findRoutesByToken(e,t=5){return this.all(`
|
|
124
124
|
SELECT *
|
|
125
125
|
FROM exports
|
|
126
126
|
WHERE (kind = 'HTTP Route' OR classification = 'Service Boundary')
|
|
127
127
|
AND (name LIKE ? OR signature LIKE ?)
|
|
128
128
|
LIMIT ?
|
|
129
|
-
`,`%${e}%`,`%${e}%`,
|
|
129
|
+
`,`%${e}%`,`%${e}%`,t)}findByFile(e){return this.all("SELECT * FROM exports WHERE file_path = ? ORDER BY start_line ASC",e)}findByFiles(e){if(e.length===0)return[];let t=e.map(()=>"?").join(", ");return this.all(`SELECT * FROM exports WHERE file_path IN (${t}) ORDER BY file_path, start_line ASC`,...e)}findWithEmbeddings(e=5e3){return this.all(`
|
|
130
|
+
SELECT *
|
|
131
|
+
FROM exports
|
|
132
|
+
WHERE embedding IS NOT NULL
|
|
133
|
+
ORDER BY file_path, start_line
|
|
134
|
+
LIMIT ?
|
|
135
|
+
`,e)}findSiblings(e){return this.all(`
|
|
130
136
|
SELECT name, kind, signature, start_line, end_line,
|
|
131
137
|
parent_id, id,
|
|
132
138
|
(SELECT name FROM exports WHERE id = e.parent_id) as parent_name
|
|
@@ -134,7 +140,7 @@ var lx=Object.create;var pc=Object.defineProperty;var ux=Object.getOwnPropertyDe
|
|
|
134
140
|
WHERE file_path = ?
|
|
135
141
|
AND parent_id IS NULL
|
|
136
142
|
ORDER BY start_line ASC
|
|
137
|
-
`,e)}findByName(e,
|
|
143
|
+
`,e)}findByName(e,t=20){return this.all("SELECT * FROM exports WHERE name = ? LIMIT ?",e,t)}findClassByName(e){return this.get("SELECT * FROM exports WHERE name = ? AND kind = 'ClassDeclaration' LIMIT 1",e)}findDefinitionCandidates(e,t){let n=[e],i=`
|
|
138
144
|
SELECT e.id, e.name, e.kind, e.start_line, e.end_line, e.signature, e.doc,
|
|
139
145
|
f.path as file_path, e.classification, e.capabilities,
|
|
140
146
|
p.name as parent_name, p.kind as parent_kind
|
|
@@ -142,12 +148,12 @@ var lx=Object.create;var pc=Object.defineProperty;var ux=Object.getOwnPropertyDe
|
|
|
142
148
|
JOIN files f ON e.file_path = f.path
|
|
143
149
|
LEFT JOIN exports p ON e.parent_id = p.id
|
|
144
150
|
WHERE e.name = ?
|
|
145
|
-
`;return
|
|
151
|
+
`;return t&&(i+=" AND f.path = ?",n.push(t)),i+=`
|
|
146
152
|
ORDER BY
|
|
147
153
|
CASE WHEN e.parent_id IS NULL THEN 0 ELSE 1 END,
|
|
148
154
|
CASE WHEN e.kind = 'ExportSpecifier' THEN 2 ELSE 0 END
|
|
149
155
|
LIMIT 10
|
|
150
|
-
`,this.all(
|
|
156
|
+
`,this.all(i,...n)}findMemberCandidates(e,t,n){let i=[e,t],r=`
|
|
151
157
|
SELECT e.id, e.name, e.kind, e.start_line, e.end_line, e.signature, e.doc,
|
|
152
158
|
f.path as file_path, e.classification, e.capabilities,
|
|
153
159
|
p.name as parent_name, p.kind as parent_kind
|
|
@@ -155,12 +161,12 @@ var lx=Object.create;var pc=Object.defineProperty;var ux=Object.getOwnPropertyDe
|
|
|
155
161
|
JOIN files f ON e.file_path = f.path
|
|
156
162
|
LEFT JOIN exports p ON e.parent_id = p.id
|
|
157
163
|
WHERE p.name = ? AND e.name = ?
|
|
158
|
-
`;return
|
|
164
|
+
`;return n&&(r+=" AND f.path = ?",i.push(n)),r+=`
|
|
159
165
|
ORDER BY
|
|
160
166
|
CASE WHEN e.parent_id IS NULL THEN 0 ELSE 1 END,
|
|
161
167
|
CASE WHEN e.kind = 'ExportSpecifier' THEN 2 ELSE 0 END
|
|
162
168
|
LIMIT 10
|
|
163
|
-
`,this.all(
|
|
169
|
+
`,this.all(r,...i)}findPotentialParents(e){return this.all(`
|
|
164
170
|
SELECT name, kind, file_path
|
|
165
171
|
FROM exports
|
|
166
172
|
WHERE kind IN ('ClassDeclaration', 'ClassExpression', 'TsInterfaceDeclaration')
|
|
@@ -168,27 +174,27 @@ var lx=Object.create;var pc=Object.defineProperty;var ux=Object.getOwnPropertyDe
|
|
|
168
174
|
SELECT rowid FROM content_fts WHERE content MATCH ?
|
|
169
175
|
)
|
|
170
176
|
LIMIT 3
|
|
171
|
-
`,`"${e}"`)}findFuzzyCandidates(e){let
|
|
177
|
+
`,`"${e}"`)}findFuzzyCandidates(e){let t=e.charAt(0).toLowerCase();return this.all(`
|
|
172
178
|
SELECT DISTINCT name FROM exports
|
|
173
179
|
WHERE parent_id IS NULL
|
|
174
180
|
AND (name LIKE ? OR name LIKE ? OR ABS(LENGTH(name) - LENGTH(?)) <= 5)
|
|
175
181
|
ORDER BY ABS(LENGTH(name) - LENGTH(?)) ASC
|
|
176
182
|
LIMIT 1000
|
|
177
|
-
`,
|
|
183
|
+
`,t+"%","%"+t+"%",e,e)}findTopLevelByFile(e){return this.all(`
|
|
178
184
|
SELECT * FROM exports
|
|
179
185
|
WHERE file_path = ? AND parent_id IS NULL
|
|
180
186
|
ORDER BY start_line ASC
|
|
181
|
-
`,e)}findFts(e,
|
|
187
|
+
`,e)}findFts(e,t=20){return this.all(`
|
|
182
188
|
SELECT e.*
|
|
183
189
|
FROM exports e
|
|
184
190
|
JOIN exports_fts ON e.id = exports_fts.rowid
|
|
185
191
|
WHERE exports_fts MATCH ?
|
|
186
192
|
LIMIT ?
|
|
187
|
-
`,e,
|
|
193
|
+
`,e,t)}findByPartialName(e,t=20){return this.all(`
|
|
188
194
|
SELECT * FROM exports
|
|
189
195
|
WHERE lower(name) LIKE ?
|
|
190
196
|
LIMIT ?
|
|
191
|
-
`,`%${e.toLowerCase()}%`,
|
|
197
|
+
`,`%${e.toLowerCase()}%`,t)}getAllNames(e=5e3){return this.all("SELECT DISTINCT name FROM exports WHERE parent_id IS NULL LIMIT ?",e).map(n=>n.name)}countByFile(e){return this.get("SELECT COUNT(*) as count FROM exports WHERE file_path = ?",e)?.count||0}findDeadExports(e={}){let{limit:t=50,includeTests:n=!1,includeMigrations:i=!1,includeFixtures:r=!1,excludePatterns:o=[],confidenceThreshold:a="all"}=e,c=[];n||(c.push("e.file_path NOT LIKE '%/test/%'"),c.push("e.file_path NOT LIKE '%/tests/%'"),c.push("e.file_path NOT LIKE '%/__tests__/%'"),c.push("e.file_path NOT LIKE '%.spec.%'"),c.push("e.file_path NOT LIKE '%.test.%'")),i||(c.push("e.file_path NOT LIKE '%/migrations/%'"),c.push("e.file_path NOT LIKE '%/migration/%'"),c.push("e.file_path NOT LIKE '%Migration.%'")),r||(c.push("e.file_path NOT LIKE '%/__fixtures__/%'"),c.push("e.file_path NOT LIKE '%/__mocks__/%'"),c.push("e.file_path NOT LIKE '%/fixtures/%'"),c.push("e.file_path NOT LIKE '%/mocks/%'"),c.push("e.file_path NOT LIKE '%.fixture.%'"),c.push("e.file_path NOT LIKE '%.mock.%'"));for(let m of o){let f=m.replace(/\*\*/g,"%").replace(/\*/g,"%").replace(/\?/g,"_");c.push(`e.file_path NOT LIKE '${f}'`)}let l=c.length>0?`AND ${c.join(" AND ")}`:"",d=this.all(`
|
|
192
198
|
SELECT e.name, e.kind, e.file_path, e.start_line
|
|
193
199
|
FROM exports e
|
|
194
200
|
WHERE e.kind IN (
|
|
@@ -209,23 +215,23 @@ var lx=Object.create;var pc=Object.defineProperty;var ux=Object.getOwnPropertyDe
|
|
|
209
215
|
AND NOT EXISTS (SELECT 1 FROM imports i WHERE i.resolved_path = e.file_path AND i.imported_symbols LIKE '%*%')
|
|
210
216
|
ORDER BY e.file_path, e.start_line
|
|
211
217
|
LIMIT ?
|
|
212
|
-
`,
|
|
218
|
+
`,t*2).filter(m=>!this.isFrameworkEntrypointExport(m)).map(m=>{let{confidence:f,reason:_}=this.scoreDeadExportConfidence(m);return{...m,confidence:f,reason:_}}),h=d;return a==="high"?h=d.filter(m=>m.confidence==="high"):a==="medium"&&(h=d.filter(m=>m.confidence==="high"||m.confidence==="medium")),h.slice(0,t)}scoreDeadExportConfidence(e){let t=e.file_path.toLowerCase(),n=e.name;return t.includes("/index.")||t.endsWith("index.ts")||t.endsWith("index.js")?{confidence:"low",reason:"Barrel/index file - likely re-export"}:e.kind==="TsInterfaceDeclaration"||e.kind==="TsTypeAliasDeclaration"?{confidence:"medium",reason:"Type definition - may be used externally"}:t.includes("/entry/")||t.includes("/bin/")||t.includes("main.")||t.includes("server.")||t.includes("cli.")?{confidence:"medium",reason:"Entry point - may be invoked externally"}:(t.includes("/components/")||t.endsWith(".tsx")||t.endsWith(".jsx"))&&/^[A-Z][A-Za-z0-9_]*$/.test(n)?{confidence:"medium",reason:"Component export - may be used by runtime composition"}:(t.includes("/contexts/")||t.includes("/context/"))&&(/Provider$/.test(n)||n.startsWith("use"))?{confidence:"medium",reason:"Context/provider export - may be wired dynamically"}:n.startsWith("create")||n.endsWith("Factory")||n.endsWith("Builder")?{confidence:"medium",reason:"Factory/builder pattern - may be used dynamically"}:n.startsWith("use")&&n.length>3?{confidence:"medium",reason:"Hook pattern - may be used in components"}:{confidence:"high",reason:"No detected usage"}}isFrameworkEntrypointExport(e){let n=e.file_path.toLowerCase().replace(/\\/g,"/"),i=e.name;return!!(/(^|\/)(src\/)?app\/.*\/route\.(t|j)sx?$/.test(n)&&s.HTTP_METHOD_EXPORTS.has(i)||/(^|\/)(src\/)?app\/.*\/(page|layout|loading|error|not-found|default|template)\.(t|j)sx?$/.test(n)||/(^|\/)(src\/)?middleware\.(t|j)sx?$/.test(n)||n.includes("/routes/")&&["loader","action","meta","headers"].includes(i))}getGravityMap(e=[],t){let n={},i=`
|
|
213
219
|
SELECT ws.symbol_id, m.name as mission_name, m.status
|
|
214
220
|
FROM working_set ws
|
|
215
221
|
JOIN missions m ON ws.mission_id = m.id
|
|
216
222
|
WHERE (
|
|
217
|
-
(m.status IN ('in-progress', 'verifying') ${
|
|
223
|
+
(m.status IN ('in-progress', 'verifying') ${t?"AND m.git_branch = ?":""})
|
|
218
224
|
OR m.id IN (${e.length>0?e.join(","):"-1"})
|
|
219
225
|
)
|
|
220
226
|
AND ws.symbol_id IS NOT NULL
|
|
221
|
-
`,
|
|
227
|
+
`,r=[];t&&r.push(t);let o=this.all(i,...r);for(let l of o){n[l.symbol_id]||(n[l.symbol_id]={score:1,reasons:[]});let p=l.status==="in-progress"||l.status==="verifying"?1:.5;n[l.symbol_id].score+=p;let u=l.status==="in-progress"||l.status==="verifying"?"Working Set":"Lineage Bleed";n[l.symbol_id].reasons.push(`${u}: ${l.mission_name}`)}let a=Math.floor(Date.now()/1e3)-86400,c=this.all(`
|
|
222
228
|
SELECT symbol_id, type, mission_id
|
|
223
229
|
FROM intent_logs
|
|
224
230
|
WHERE (created_at > ? OR mission_id IN (${e.length>0?e.join(","):"-1"}))
|
|
225
231
|
AND symbol_id IS NOT NULL
|
|
226
232
|
ORDER BY created_at DESC
|
|
227
233
|
LIMIT 200
|
|
228
|
-
`,a);for(let l of c){
|
|
234
|
+
`,a);for(let l of c){n[l.symbol_id]||(n[l.symbol_id]={score:1,reasons:[]});let p=l.mission_id?e.includes(l.mission_id):!1,u=p?.1:.2;n[l.symbol_id].score<5&&(n[l.symbol_id].score+=u);let d=p?`Lineage Intent: ${l.type}`:`Recent Intent: ${l.type}`;!n[l.symbol_id].reasons.includes(d)&&n[l.symbol_id].reasons.length<5&&n[l.symbol_id].reasons.push(d)}return n}getCount(){return this.get("SELECT COUNT(*) as count FROM exports")?.count||0}getKindDistribution(e=5){return this.all(`
|
|
229
235
|
SELECT kind, COUNT(*) as c
|
|
230
236
|
FROM exports
|
|
231
237
|
WHERE kind IS NOT NULL AND kind != ''
|
|
@@ -238,7 +244,33 @@ var lx=Object.create;var pc=Object.defineProperty;var ux=Object.getOwnPropertyDe
|
|
|
238
244
|
OR name LIKE ?
|
|
239
245
|
OR name LIKE ?
|
|
240
246
|
LIMIT 10
|
|
241
|
-
`,e,`%.${e}`,`%::${e}`)}}
|
|
247
|
+
`,e,`%.${e}`,`%::${e}`)}findTypeGraphEdges(e,t={}){let{filePath:n,direction:i="both",relationship:r,limit:o=50}=t,a=Math.max(1,Math.min(o,500)),c=[];if(i==="both"||i==="outbound"){let l=`
|
|
248
|
+
SELECT
|
|
249
|
+
id,
|
|
250
|
+
file_path,
|
|
251
|
+
source_symbol_id,
|
|
252
|
+
source_symbol_name,
|
|
253
|
+
target_symbol_name,
|
|
254
|
+
relationship,
|
|
255
|
+
line_number,
|
|
256
|
+
metadata,
|
|
257
|
+
'outbound' AS direction
|
|
258
|
+
FROM type_graph_edges
|
|
259
|
+
WHERE source_symbol_name = ?
|
|
260
|
+
`,p=[e];n&&(l+=" AND file_path = ?",p.push(n)),r&&(l+=" AND relationship = ?",p.push(r)),l+=" ORDER BY file_path ASC, line_number ASC, target_symbol_name ASC LIMIT ?",p.push(a),c.push(...this.all(l,...p))}if(i==="both"||i==="inbound"){let l=`
|
|
261
|
+
SELECT
|
|
262
|
+
id,
|
|
263
|
+
file_path,
|
|
264
|
+
source_symbol_id,
|
|
265
|
+
source_symbol_name,
|
|
266
|
+
target_symbol_name,
|
|
267
|
+
relationship,
|
|
268
|
+
line_number,
|
|
269
|
+
metadata,
|
|
270
|
+
'inbound' AS direction
|
|
271
|
+
FROM type_graph_edges
|
|
272
|
+
WHERE target_symbol_name = ?
|
|
273
|
+
`,p=[e];r&&(l+=" AND relationship = ?",p.push(r)),l+=" ORDER BY file_path ASC, line_number ASC, source_symbol_name ASC LIMIT ?",p.push(a),c.push(...this.all(l,...p))}return c.slice(0,a)}findTypeGraphEdgesBySymbolId(e,t={}){let n=this.findById(e);return n?this.findTypeGraphEdges(n.name,{...t,filePath:n.file_path}):[]}}});var ur,dr=Z(()=>{"use strict";ur=`
|
|
242
274
|
WITH RECURSIVE dependency_chain AS (
|
|
243
275
|
-- Base case: Direct dependents of the target symbol
|
|
244
276
|
-- Meaning: Files that import the file where the symbol is defined
|
|
@@ -289,37 +321,37 @@ SELECT DISTINCT
|
|
|
289
321
|
dc.imported_symbols
|
|
290
322
|
FROM dependency_chain dc
|
|
291
323
|
ORDER BY dc.depth, dc.consumer_path;
|
|
292
|
-
`});var
|
|
324
|
+
`});var Ln,mr=Z(()=>{"use strict";Ue();dr();Ln=class extends ae{findByFile(e){return this.all("SELECT * FROM imports WHERE file_path = ?",e)}findByFiles(e){if(e.length===0)return[];let t=e.map(()=>"?").join(", ");return this.all(`SELECT * FROM imports WHERE file_path IN (${t}) ORDER BY file_path`,...e)}getAllResolved(){return this.all(`
|
|
293
325
|
SELECT * FROM imports
|
|
294
326
|
WHERE resolved_path IS NOT NULL AND resolved_path != ''
|
|
295
|
-
`)}findDependents(e){return this.all("SELECT * FROM imports WHERE resolved_path = ?",e)}countByFile(e){return this.get("SELECT COUNT(*) as count FROM imports WHERE file_path = ?",e)?.count||0}countDependents(e){return this.get("SELECT COUNT(*) as count FROM imports WHERE resolved_path = ?",e)?.count||0}getImportsForFile(e){return this.all("SELECT module_specifier, imported_symbols, resolved_path FROM imports WHERE file_path = ?",e)}findImportSource(e,
|
|
327
|
+
`)}findDependents(e){return this.all("SELECT * FROM imports WHERE resolved_path = ?",e)}countByFile(e){return this.get("SELECT COUNT(*) as count FROM imports WHERE file_path = ?",e)?.count||0}countDependents(e){return this.get("SELECT COUNT(*) as count FROM imports WHERE resolved_path = ?",e)?.count||0}getImportsForFile(e){return this.all("SELECT module_specifier, imported_symbols, resolved_path FROM imports WHERE file_path = ?",e)}findImportSource(e,t){return this.get(`
|
|
296
328
|
SELECT *
|
|
297
329
|
FROM imports
|
|
298
330
|
WHERE file_path = ?
|
|
299
331
|
AND (imported_symbols LIKE ? OR imported_symbols = '*')
|
|
300
332
|
LIMIT 1
|
|
301
|
-
`,e,`%${
|
|
333
|
+
`,e,`%${t}%`)}findProxies(e){return this.all(`
|
|
302
334
|
SELECT i.file_path
|
|
303
335
|
FROM imports i
|
|
304
336
|
JOIN exports e ON i.file_path = e.file_path
|
|
305
337
|
WHERE i.resolved_path = ?
|
|
306
338
|
AND (e.kind = 'ExportAllDeclaration' OR e.kind = 'ExportMapping')
|
|
307
|
-
`,e)}findVerifiedDependents(e,
|
|
339
|
+
`,e)}findVerifiedDependents(e,t){if(e.length===0)return[];let n=e.map(()=>"?").join(", ");return this.all(`
|
|
308
340
|
SELECT i.file_path, i.imported_symbols, f.classification, f.summary
|
|
309
341
|
FROM imports i
|
|
310
342
|
JOIN files f ON i.file_path = f.path
|
|
311
|
-
WHERE i.resolved_path IN (${
|
|
343
|
+
WHERE i.resolved_path IN (${n})
|
|
312
344
|
AND (i.imported_symbols LIKE ? OR i.imported_symbols = '' OR i.imported_symbols = '*')
|
|
313
345
|
LIMIT 10
|
|
314
|
-
`,...e,`%${
|
|
346
|
+
`,...e,`%${t}%`)}countVerifiedDependents(e,t){if(e.length===0)return 0;let n=e.map(()=>"?").join(", ");return this.get(`
|
|
315
347
|
SELECT COUNT(*) as count FROM imports
|
|
316
|
-
WHERE resolved_path IN (${
|
|
348
|
+
WHERE resolved_path IN (${n})
|
|
317
349
|
AND (imported_symbols LIKE ? OR imported_symbols = '' OR imported_symbols = '*')
|
|
318
|
-
`,...e,`%${
|
|
350
|
+
`,...e,`%${t}%`)?.count||0}findImpactDependents(e,t,n){return this.all(ur,e,t,n,t)}getCount(){return this.get("SELECT COUNT(*) as count FROM imports")?.count||0}}});import{fileURLToPath as gl}from"node:url";import{dirname as Qi,join as fr,resolve as yl}from"node:path";import{existsSync as bl}from"node:fs";function El(){let s=hr;for(;s!==Qi(s);){if(bl(fr(s,"package.json")))return s;s=Qi(s)}return yl(hr,"..","..")}function _e(...s){return fr(El(),...s)}var _l,hr,St=Z(()=>{"use strict";_l=gl(import.meta.url),hr=Qi(_l)});import{Worker as Sl}from"node:worker_threads";import{cpus as wl}from"node:os";import{fileURLToPath as xl}from"node:url";import{dirname as vl,join as gr}from"node:path";import{existsSync as yr}from"node:fs";function Tl(){if(_r.endsWith(".ts")){let e=gr(br,"worker.ts");if(yr(e))return e}let s=gr(br,"worker.js");return yr(s)?s:_e("dist/logic/domain/embeddings/worker.js")}function Ot(s){return Dt||(Dt=new sn(s)),Dt}async function $n(){Dt&&(await Dt.shutdown(),Dt=null)}var _r,br,sn,Dt,Er=Z(()=>{"use strict";q();St();_r=xl(import.meta.url),br=vl(_r);sn=class{workers=[];taskQueue=[];pendingTasks=new Map;taskIdCounter=0;initialized=!1;initPromise;shutdownRequested=!1;numWorkers;cacheDir;initTimeout;constructor(e={}){this.numWorkers=e.numWorkers??Math.max(1,Math.min(2,wl().length-1)),this.cacheDir=e.cacheDir??"./.cache",this.initTimeout=e.initTimeout??6e4}async initialize(){if(!this.initialized)return this.initPromise?this.initPromise:(this.initPromise=this._doInitialize(),this.initPromise)}async _doInitialize(){let e;try{S.info({numWorkers:this.numWorkers},"Initializing embedding worker pool");let t=new Promise((n,i)=>{e=setTimeout(()=>i(new Error(`Worker pool initialization timed out after ${this.initTimeout}ms`)),this.initTimeout)});if(await Promise.race([this._initializeWorkers(),t]),e&&clearTimeout(e),this.shutdownRequested){this.initialized=!1,this.initPromise=void 0,S.debug("Initialization completed but shutdown was requested");return}this.initialized=!0,S.info({numWorkers:this.workers.length},"Embedding worker pool ready")}catch(t){throw e&&clearTimeout(e),this.initPromise=void 0,this.initialized=!1,await this.shutdown(),t}}async _initializeWorkers(){let e=Tl();S.debug({workerPath:e},"Resolved worker path");let t=[];for(let n=0;n<this.numWorkers;n++)n>0&&await new Promise(i=>setTimeout(i,25)),t.push(this.createWorker(e,n));await Promise.all(t)}async createWorker(e,t){return new Promise((n,i)=>{let r=setTimeout(()=>{i(new Error(`Worker ${t} initialization timed out`))},this.initTimeout),o=new Sl(e,{workerData:{cacheDir:this.cacheDir},execArgv:process.execArgv}),a={worker:o,busy:!1,currentTaskId:null};o.on("message",c=>{if(c.type==="ready"){if(clearTimeout(r),this.shutdownRequested){S.debug({workerIndex:t},"Worker ready but shutdown requested, terminating"),o.terminate().catch(()=>{}),n();return}this.workers.push(a),S.debug({workerIndex:t},"Worker ready"),n()}else c.type==="result"&&c.id?this.handleTaskComplete(a,c.id,c.embeddings||[]):c.type==="error"&&c.id&&this.handleTaskError(a,c.id,new Error(c.error||"Unknown error"))}),o.on("error",c=>{if(clearTimeout(r),S.error({err:c,workerIndex:t},"Worker error"),a.currentTaskId&&this.handleTaskError(a,a.currentTaskId,c),!this.initialized){i(c);return}let l=this.workers.indexOf(a);l!==-1&&this.workers.splice(l,1),!this.shutdownRequested&&this.initialized&&this.createWorker(e,t).catch(p=>{S.error({err:p},"Failed to replace crashed worker")})}),o.on("exit",c=>{c!==0&&!this.shutdownRequested&&S.warn({workerIndex:t,code:c},"Worker exited unexpectedly")})})}handleTaskComplete(e,t,n){let i=this.pendingTasks.get(t);i&&(this.pendingTasks.delete(t),i.resolve(n)),e.busy=!1,e.currentTaskId=null,this.processQueue()}handleTaskError(e,t,n){let i=this.pendingTasks.get(t);i&&(this.pendingTasks.delete(t),i.reject(n)),e.busy=!1,e.currentTaskId=null,this.processQueue()}processQueue(){if(this.taskQueue.length===0)return;let e=this.workers.find(n=>!n.busy);if(!e)return;let t=this.taskQueue.shift();t&&(e.busy=!0,e.currentTaskId=t.id,this.pendingTasks.set(t.id,t),e.worker.postMessage({type:"embed",id:t.id,texts:t.texts}))}async generateEmbeddings(e,t=128,n){if(this.initialized||await this.initialize(),e.length===0)return[];let i=[];for(let l=0;l<e.length;l+=t)i.push(e.slice(l,l+t));let r=new Array(i.length),o=0,a=i.map((l,p)=>new Promise((u,d)=>{let m={id:`task_${++this.taskIdCounter}`,texts:l,resolve:f=>{if(r[p]=f,o++,n){let _=Math.min(o*t,e.length);n(_,e.length)}u()},reject:f=>{if(r[p]=new Array(l.length).fill(null),o++,S.warn({err:f,chunkIndex:p},"Chunk embedding failed"),n){let _=Math.min(o*t,e.length);n(_,e.length)}u()}};this.taskQueue.push(m),this.processQueue()}));await Promise.all(a);let c=[];for(let l of r)c.push(...l);return S.info({total:e.length,successful:c.filter(l=>l!==null).length,workers:this.workers.length},"Parallel embedding generation complete"),c}get workerCount(){return this.workers.length}get busyWorkers(){return this.workers.filter(e=>e.busy).length}get queueSize(){return this.taskQueue.length}get isInitialized(){return this.initialized}async shutdown(){if(this.shutdownRequested=!0,this.initPromise)try{await this.initPromise}catch{}if(!this.initialized&&this.workers.length===0){this.shutdownRequested=!1,this.initPromise=void 0;return}S.info({numWorkers:this.workers.length},"Shutting down embedding worker pool");let e=this.workers.map(t=>new Promise(n=>{t.worker.postMessage({type:"shutdown"}),t.worker.once("exit",()=>n()),setTimeout(()=>{t.worker.terminate().then(()=>n())},5e3)}));await Promise.all(e),this.workers=[],this.taskQueue=[],this.pendingTasks.clear(),this.initialized=!1,this.shutdownRequested=!1,S.info("Embedding worker pool shutdown complete")}},Dt=null});var ot={};qi(ot,{EmbeddingPriorityQueue:()=>Zi,EmbeddingWorkerPool:()=>sn,cosineSimilarity:()=>Mn,generateEmbedding:()=>ts,generateEmbeddingsBatch:()=>ns,getDefaultPool:()=>Ot,setUseWorkerThreads:()=>Pn,shutdownDefaultPool:()=>$n});async function Rl(){return rn||(rn=await import("@xenova/transformers"),rn.env.cacheDir="./.cache",rn.env.allowLocalModels=!0),rn}function Pn(s){es=s,S.info({useWorkerThreads:s},"Worker thread mode updated")}function Sr(s=!1){let e=(on||"").toLowerCase(),t={};return on&&(t.dtype=on),s?(t.quantized=!1,t):(e==="fp32"||e==="fp16"||e==="float32"||e==="float16"?t.quantized=!1:e.startsWith("q")&&(t.quantized=!0),t)}async function kl(){S.info({model:An,dtype:on},"Loading embedding model...");let{pipeline:s}=await Rl(),e=Sr(!1);try{return await s("feature-extraction",An,e)}catch(t){let n=t?.message||"";if(!(n.includes("/onnx/model_quantized.onnx")||n.includes("model_quantized.onnx")))throw t;return S.warn({model:An,dtype:on},"Quantized ONNX artifact missing, retrying with unquantized ONNX"),await s("feature-extraction",An,Sr(!0))}}async function xr(){return Xi||(Xi=kl()),Xi}async function ts(s){try{let t=await(await xr())(s,{pooling:"mean",normalize:!0});return Array.from(t.data)}catch(e){return S.error({err:e},"Failed to generate embedding"),null}}async function ns(s,e=wr,t){return s.length===0?[]:es?Ot().generateEmbeddings(s,e,t):vr(s,e,t)}async function vr(s,e,t){let n=new Array(s.length).fill(null),i=await xr();for(let r=0;r<s.length;r+=e){let o=Math.min(r+e,s.length),a=s.slice(r,o);try{let c=await i(a,{pooling:"mean",normalize:!0}),[l,p]=c.dims;for(let u=0;u<l;u++){let d=u*p,h=d+p;n[r+u]=Array.from(c.data.slice(d,h))}}catch(c){S.error({err:c,batchStart:r,batchEnd:o},"Single-threaded batch embedding failed, falling back to sequential for this chunk");for(let l=0;l<a.length;l++)try{let p=a[l];if(!p||p.trim().length===0)continue;let u=await i(p,{pooling:"mean",normalize:!0});n[r+l]=Array.from(u.data)}catch{n[r+l]=null}}t&&t(o,s.length)}return S.debug({total:s.length,successful:n.filter(r=>r!==null).length},"Batch embedding complete"),n}function Mn(s,e){let t=0,n=0,i=0;for(let r=0;r<s.length;r++)t+=s[r]*e[r],n+=s[r]*s[r],i+=e[r]*e[r];return t/(Math.sqrt(n)*Math.sqrt(i))}var An,on,rn,wr,es,Xi,Zi,Ae=Z(()=>{"use strict";q();Er();An=process.env.EMBEDDING_MODEL??"Xenova/all-MiniLM-L6-v2",on=process.env.EMBEDDING_DTYPE??"fp32",rn=null;wr=128,es=!1;Xi=null;Zi=class{queue=[];processing=!1;results=new Map;enqueue(e){this.queue.push(e),this.queue.sort((t,n)=>n.priority-t.priority)}enqueueMany(e){this.queue.push(...e),this.queue.sort((t,n)=>n.priority-t.priority)}get size(){return this.queue.length}get isProcessing(){return this.processing}getResult(e){return this.results.get(e)}async processQueue(e=wr,t){if(this.processing)return S.warn("Queue processing already in progress"),this.results;this.processing=!0;let n=this.queue.length;try{es?await this.processQueueParallel(e,n,t):await this.processQueueSequential(e,n,t)}finally{this.processing=!1}return this.results}async processQueueSequential(e,t,n){for(;this.queue.length>0;){let i=this.queue.splice(0,e),r=i.map(a=>a.text),o=await vr(r,r.length);if(i.forEach((a,c)=>{this.results.set(a.id,o[c])}),n){let a=t-this.queue.length;n(a,t)}}}async processQueueParallel(e,t,n){let i=this.queue.splice(0),r=i.map(c=>c.text),a=await Ot().generateEmbeddings(r,e,(c,l)=>{n&&n(c,l)});i.forEach((c,l)=>{this.results.set(c.id,a[l])})}clear(){this.queue=[],this.results.clear()}}});var Nn,Tr=Z(()=>{"use strict";Ue();Nn=class extends ae{findById(e){return this.get("SELECT * FROM missions WHERE id = ?",e)}findByIds(e){if(e.length===0)return[];let t=e.map(()=>"?").join(", ");return this.all(`SELECT * FROM missions WHERE id IN (${t})`,...e)}findActive(e){let t="SELECT * FROM missions WHERE status IN ('in-progress', 'planned', 'verifying')",n=[];return e&&(t+=" AND git_branch = ?",n.push(e)),t+=` ORDER BY
|
|
319
351
|
CASE WHEN status = 'in-progress' THEN 0 WHEN status = 'verifying' THEN 1 ELSE 2 END,
|
|
320
|
-
created_at ASC`,this.all(
|
|
352
|
+
created_at ASC`,this.all(t,...n)}findAll(e){let t="SELECT * FROM missions",n=[];return e&&(t+=" WHERE status = ?",n.push(e)),t+=` ORDER BY
|
|
321
353
|
CASE WHEN status = 'in-progress' THEN 0 WHEN status = 'verifying' THEN 1 ELSE 2 END,
|
|
322
|
-
created_at ASC`,this.all(
|
|
354
|
+
created_at ASC`,this.all(t,...n)}findRecentCompleted(e=3){return this.all(`
|
|
323
355
|
SELECT * FROM missions
|
|
324
356
|
WHERE status = 'completed'
|
|
325
357
|
ORDER BY updated_at DESC, id DESC
|
|
@@ -327,7 +359,43 @@ ORDER BY dc.depth, dc.consumer_path;
|
|
|
327
359
|
`,e)}create(e){return this.insert(`
|
|
328
360
|
INSERT INTO missions (name, goal, strategy_graph, status, git_branch, commit_sha, parent_id, verification_context, outcome_contract)
|
|
329
361
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
330
|
-
`,e.name,e.goal,e.strategy_graph,e.status,e.git_branch,e.commit_sha,e.parent_id,e.verification_context,e.outcome_contract)}addArtifact(e,
|
|
362
|
+
`,e.name,e.goal,e.strategy_graph,e.status,e.git_branch,e.commit_sha,e.parent_id,e.verification_context,e.outcome_contract)}addArtifact(e,t,n,i){this.run("INSERT INTO mission_artifacts (mission_id, type, identifier, metadata) VALUES (?, ?, ?, ?)",e,t,n,i?JSON.stringify(i):null)}getArtifacts(e){return this.all("SELECT * FROM mission_artifacts WHERE mission_id = ?",e)}update(e,t){let n=Object.keys(t);if(n.length===0)return;let i=n.map(o=>`${o} = ?`).join(", "),r=Object.values(t);r.push(e),this.run(`UPDATE missions SET ${i}, updated_at = unixepoch() WHERE id = ?`,...r)}updateStatus(e,t,n){n?this.run("UPDATE missions SET status = ?, updated_at = unixepoch(), commit_sha = ? WHERE id = ?",t,n,e):this.run("UPDATE missions SET status = ?, updated_at = unixepoch() WHERE id = ?",t,e)}getWorkingSet(e){let t=this.all(`
|
|
363
|
+
SELECT file_path, type, source_priority, created_at
|
|
364
|
+
FROM (
|
|
365
|
+
SELECT
|
|
366
|
+
ws.file_path,
|
|
367
|
+
COALESCE(ws.type, 'file') AS type,
|
|
368
|
+
0 AS source_priority,
|
|
369
|
+
ws.created_at
|
|
370
|
+
FROM working_set ws
|
|
371
|
+
WHERE ws.mission_id = ?
|
|
372
|
+
|
|
373
|
+
UNION ALL
|
|
374
|
+
|
|
375
|
+
SELECT
|
|
376
|
+
il.file_path,
|
|
377
|
+
'intent' AS type,
|
|
378
|
+
1 AS source_priority,
|
|
379
|
+
il.created_at
|
|
380
|
+
FROM intent_logs il
|
|
381
|
+
WHERE il.mission_id = ?
|
|
382
|
+
AND il.file_path IS NOT NULL
|
|
383
|
+
|
|
384
|
+
UNION ALL
|
|
385
|
+
|
|
386
|
+
SELECT
|
|
387
|
+
e.file_path,
|
|
388
|
+
'symbol' AS type,
|
|
389
|
+
2 AS source_priority,
|
|
390
|
+
il.created_at
|
|
391
|
+
FROM intent_logs il
|
|
392
|
+
JOIN exports e ON e.id = il.symbol_id
|
|
393
|
+
WHERE il.mission_id = ?
|
|
394
|
+
AND e.file_path IS NOT NULL
|
|
395
|
+
)
|
|
396
|
+
WHERE file_path IS NOT NULL
|
|
397
|
+
ORDER BY source_priority ASC, created_at DESC, file_path ASC
|
|
398
|
+
`,e,e,e),n=new Map;for(let i of t)!i.file_path||n.has(i.file_path)||n.set(i.file_path,{file_path:i.file_path,type:i.type||"file"});return[...n.values()]}clearWorkingSet(e){this.run("DELETE FROM working_set WHERE mission_id = ?",e)}addToWorkingSet(e,t,n="file"){this.run("INSERT OR IGNORE INTO files (path, mtime, last_scanned_at) VALUES (?, unixepoch(), unixepoch())",t),this.run("INSERT INTO working_set (mission_id, file_path, type) VALUES (?, ?, ?)",e,t,n)}findColdMissions(e,t=10){return this.all(`
|
|
331
399
|
SELECT m.id, COUNT(il.id) as log_count
|
|
332
400
|
FROM missions m
|
|
333
401
|
LEFT JOIN intent_logs il ON il.mission_id = m.id
|
|
@@ -335,23 +403,23 @@ ORDER BY dc.depth, dc.consumer_path;
|
|
|
335
403
|
AND m.status != 'distilled'
|
|
336
404
|
GROUP BY m.id
|
|
337
405
|
HAVING log_count > ?
|
|
338
|
-
`,e,
|
|
406
|
+
`,e,t).map(i=>i.id)}getStats(){let e=this.get(`
|
|
339
407
|
SELECT
|
|
340
408
|
COUNT(*) as total,
|
|
341
409
|
SUM(CASE WHEN status='completed' THEN 1 ELSE 0 END) as completed,
|
|
342
410
|
SUM(CASE WHEN status IN ('in-progress', 'planned', 'verifying') THEN 1 ELSE 0 END) as active
|
|
343
411
|
FROM missions
|
|
344
|
-
`);return{total:e?.total||0,completed:e?.completed||0,active:e?.active||0}}getAnalytics(){let e=this.getStats(),
|
|
412
|
+
`);return{total:e?.total||0,completed:e?.completed||0,active:e?.active||0}}getAnalytics(){let e=this.getStats(),t=e.total>0?Math.round(e.completed/e.total*100):0,n=this.get(`
|
|
345
413
|
SELECT AVG(updated_at - created_at) AS avg_duration
|
|
346
414
|
FROM missions
|
|
347
415
|
WHERE status = 'completed' AND updated_at > created_at
|
|
348
|
-
`),
|
|
416
|
+
`),i=n?.avg_duration!=null?Math.round(n.avg_duration):null,r=Math.floor(Date.now()/1e3)-168*3600,o=Math.floor(Date.now()/1e3)-720*3600,a=this.get("SELECT COUNT(*) AS n FROM missions WHERE status = 'completed' AND updated_at >= ?",r),c=this.get("SELECT COUNT(*) AS n FROM missions WHERE status = 'completed' AND updated_at >= ?",o),l=a?.n??0,p=c?.n??0,u=`${l} completed in last 7 days, ${p} in last 30 days.`;if(i!=null){let d=Math.round(i/60);u+=` Avg mission duration: ${d} min.`}return{completionRate:t,averageDurationSeconds:i,completedLast7Days:l,completedLast30Days:p,velocityNote:u}}suspendByBranch(e){return this.run(`UPDATE missions
|
|
349
417
|
SET status = 'suspended', updated_at = unixepoch()
|
|
350
|
-
WHERE git_branch = ? AND status IN ('in-progress', '
|
|
418
|
+
WHERE git_branch = ? AND status IN ('in-progress', 'verifying')`,e)}resumeByBranch(e){return this.run(`UPDATE missions
|
|
351
419
|
SET status = 'in-progress', updated_at = unixepoch()
|
|
352
|
-
WHERE git_branch = ? AND status = 'suspended'`,e)}findMergedMissions(e,
|
|
420
|
+
WHERE git_branch = ? AND status = 'suspended'`,e)}findMergedMissions(e,t){if(t.length===0)return[];let n=t.filter(r=>r!==e);if(n.length===0)return[];let i=n.map(()=>"?").join(",");return this.all(`SELECT * FROM missions
|
|
353
421
|
WHERE status IN ('in-progress', 'planned', 'verifying', 'suspended')
|
|
354
|
-
AND git_branch IN (${
|
|
422
|
+
AND git_branch IN (${i})`,...n)}findByCommitShas(e){if(e.length===0)return[];let t=e.map(()=>"?").join(",");return this.all(`SELECT * FROM missions WHERE commit_sha IN (${t})`,...e)}findByParentId(e){return this.all("SELECT * FROM missions WHERE parent_id = ?",e)}hasChildren(e){return!!this.get("SELECT 1 FROM missions WHERE parent_id = ? LIMIT 1",e)}hasNoSteps(e){if(!e.strategy_graph)return!0;try{let t=JSON.parse(e.strategy_graph),n=t?.steps??t;return!Array.isArray(n)||n.length===0}catch{return!0}}findParentOnlyIds(e){return e.filter(t=>t.parent_id!=null||!this.hasChildren(t.id)?!1:this.hasNoSteps(t)).map(t=>t.id)}createLink(e,t,n,i,r){this.db.exec(`
|
|
355
423
|
CREATE TABLE IF NOT EXISTS cross_repo_links (
|
|
356
424
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
357
425
|
mission_id INTEGER NOT NULL,
|
|
@@ -366,11 +434,11 @@ ORDER BY dc.depth, dc.consumer_path;
|
|
|
366
434
|
`),this.run(`
|
|
367
435
|
INSERT INTO cross_repo_links (mission_id, linked_repo_path, linked_mission_id, relationship, direction)
|
|
368
436
|
VALUES (?, ?, ?, ?, ?)
|
|
369
|
-
`,e,
|
|
437
|
+
`,e,t,n,i,r)}getLinks(e){try{return this.all(`
|
|
370
438
|
SELECT linked_repo_path, linked_mission_id, relationship, direction
|
|
371
439
|
FROM cross_repo_links
|
|
372
440
|
WHERE mission_id = ?
|
|
373
|
-
`,e)}catch{return[]}}findLastMission(){return this.get("SELECT * FROM missions ORDER BY updated_at DESC, id DESC LIMIT 1")}findActiveByPriority(){return this.get("SELECT * FROM missions WHERE status IN ('in-progress', 'active', 'verifying') ORDER BY CASE WHEN status = 'in-progress' THEN 0 ELSE 1 END, created_at ASC LIMIT 1")}
|
|
441
|
+
`,e)}catch{return[]}}findLastMission(){return this.get("SELECT * FROM missions ORDER BY updated_at DESC, id DESC LIMIT 1")}findActiveByPriority(){return this.get("SELECT * FROM missions WHERE status IN ('in-progress', 'active', 'verifying') ORDER BY CASE WHEN status = 'in-progress' THEN 0 ELSE 1 END, created_at ASC LIMIT 1")}addHandoff(e,t){let n=JSON.stringify(t),i=e??0,r=this.insert("INSERT INTO mission_artifacts (mission_id, type, identifier, metadata) VALUES (?, ?, ?, ?)",i,"handoff",t.kind,n),o=[`[handoff:${t.kind}]`,...t.findings.map(a=>a.statement),...t.risks.map(a=>a.description),...t.gaps].filter(Boolean).join(" ");return Promise.resolve().then(()=>(Ae(),ot)).then(({generateEmbedding:a})=>a(o)).then(a=>{a&&this.run("UPDATE mission_artifacts SET embedding = ? WHERE id = ?",JSON.stringify(a),r)}).catch(()=>{}),r}getHandoffs(e,t,n=20){let i=["type = 'handoff'"],r=[];e!==void 0&&(i.push("mission_id = ?"),r.push(e??0)),t&&(i.push("identifier = ?"),r.push(t));let o=`SELECT * FROM mission_artifacts WHERE ${i.join(" AND ")} ORDER BY created_at DESC LIMIT ?`;return r.push(n),this.all(o,...r)}async findSemanticHandoffs(e,t=5){let{cosineSimilarity:n}=await Promise.resolve().then(()=>(Ae(),ot)),i=this.all("SELECT * FROM mission_artifacts WHERE type = 'handoff' AND embedding IS NOT NULL"),r=[];for(let o of i)try{let a=JSON.parse(o.embedding),c=n(e,a);c>.3&&r.push({...o,similarity:c})}catch{}return r.sort((o,a)=>a.similarity-o.similarity).slice(0,t)}}});var Dn,Rr=Z(()=>{"use strict";Ue();q();Dn=class s extends ae{findByMission(e,t=50){return this.all(`
|
|
374
442
|
SELECT
|
|
375
443
|
id, mission_id, symbol_id, file_path, type, content, confidence,
|
|
376
444
|
symbol_name, signature, commit_sha, is_crystallized, crystal_id,
|
|
@@ -379,7 +447,7 @@ ORDER BY dc.depth, dc.consumer_path;
|
|
|
379
447
|
WHERE mission_id = ?
|
|
380
448
|
ORDER BY created_at DESC
|
|
381
449
|
LIMIT ?
|
|
382
|
-
`,e,
|
|
450
|
+
`,e,t)}findRecentDecisionActivity(e=10){return this.all(`
|
|
383
451
|
SELECT
|
|
384
452
|
id, mission_id, symbol_id, file_path, type, content, confidence,
|
|
385
453
|
symbol_name, signature, commit_sha, is_crystallized, crystal_id,
|
|
@@ -388,10 +456,10 @@ ORDER BY dc.depth, dc.consumer_path;
|
|
|
388
456
|
WHERE type IN ('decision', 'system', 'fix', 'heritage', 'adr')
|
|
389
457
|
ORDER BY created_at DESC
|
|
390
458
|
LIMIT ?
|
|
391
|
-
`,e)}create(e){let
|
|
459
|
+
`,e)}create(e){let t=this.insert(`
|
|
392
460
|
INSERT INTO intent_logs (mission_id, symbol_id, file_path, type, content, confidence, symbol_name, signature, commit_sha)
|
|
393
461
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
394
|
-
`,e.mission_id,e.symbol_id,e.file_path,e.type,e.content,e.confidence,e.symbol_name,e.signature,e.commit_sha);return
|
|
462
|
+
`,e.mission_id,e.symbol_id,e.file_path,e.type,e.content,e.confidence,e.symbol_name,e.signature,e.commit_sha);return s.EMBEDDABLE_TYPES.has(e.type)&&this.generateAndStoreEmbedding(Number(t),e).catch(n=>{S.debug({err:n,intentLogId:t},"Failed to generate intent log embedding")}),t}static EMBEDDABLE_TYPES=new Set(["decision","discovery","fix","blocker","note","heritage","crystal"]);static buildEmbeddingText(e){let t=[`[${e.type}]`];return e.symbol_name&&t.push(`symbol: ${e.symbol_name}`),e.file_path&&t.push(`file: ${e.file_path.split("/").pop()}`),t.push(e.content),t.join(" ")}async generateAndStoreEmbedding(e,t){let{generateEmbedding:n}=await Promise.resolve().then(()=>(Ae(),ot)),i=s.buildEmbeddingText(t),r=await n(i);r&&this.run("UPDATE intent_logs SET embedding = ? WHERE id = ?",JSON.stringify(r),e)}findWithEmbeddings(){return this.all("SELECT * FROM intent_logs WHERE embedding IS NOT NULL AND type NOT IN ('system', 'lapsed')")}async findSemanticMatches(e,t,n){let{cosineSimilarity:i}=await Promise.resolve().then(()=>(Ae(),ot)),r=this.findWithEmbeddings();if(r.length>5e3)return S.warn({count:r.length},"Intent log count exceeds brute-force vector scan limit (5000). Skipping semantic recall."),[];let o=[];for(let a of r)if(!(n&&a.symbol_id===n))try{let c=JSON.parse(a.embedding),l=i(e,c);l>.25&&o.push({id:a.id,mission_id:a.mission_id,type:a.type,content:a.content,symbol_name:a.symbol_name,file_path:a.file_path,similarity:l,created_at:a.created_at})}catch{}return o.sort((a,c)=>c.similarity-a.similarity).slice(0,t)}delete(e){this.run("DELETE FROM intent_logs WHERE id = ?",e)}update(e,t){let n=Object.keys(t);if(n.length===0)return;let i=n.map(o=>`${o} = ?`).join(", "),r=Object.values(t);r.push(e),this.run(`UPDATE intent_logs SET ${i} WHERE id = ?`,...r)}findRepairableOrphans(){return this.all(`
|
|
395
463
|
SELECT id, file_path, symbol_name, signature
|
|
396
464
|
FROM intent_logs
|
|
397
465
|
WHERE symbol_id IS NULL AND symbol_name IS NOT NULL
|
|
@@ -413,10 +481,10 @@ ORDER BY dc.depth, dc.consumer_path;
|
|
|
413
481
|
type = 'lapsed',
|
|
414
482
|
content = 'Lapsed: ' || content
|
|
415
483
|
WHERE id = ?
|
|
416
|
-
`,e)}importHeritage(e,
|
|
484
|
+
`,e)}importHeritage(e,t,n,i){this.run(`
|
|
417
485
|
INSERT INTO intent_logs (type, content, commit_sha, created_at, confidence, mission_id)
|
|
418
486
|
VALUES ('heritage', ?, ?, ?, ?, NULL)
|
|
419
|
-
`,e,
|
|
487
|
+
`,e,t,n,i)}countByType(e){return this.get("SELECT COUNT(*) as count FROM intent_logs WHERE type = ?",e)?.count||0}findRawByMission(e){return this.all(`SELECT
|
|
420
488
|
id, mission_id, symbol_id, file_path, type, content, confidence,
|
|
421
489
|
symbol_name, signature, commit_sha, is_crystallized, crystal_id,
|
|
422
490
|
created_at
|
|
@@ -429,63 +497,64 @@ ORDER BY dc.depth, dc.consumer_path;
|
|
|
429
497
|
created_at
|
|
430
498
|
FROM intent_logs
|
|
431
499
|
WHERE mission_id = ? AND type = 'crystal'
|
|
432
|
-
ORDER BY created_at DESC LIMIT 1`,e)}crystallize(e,
|
|
433
|
-
VALUES (?, 'crystal', ?, 1.0, 0, NULL, NULL, NULL, NULL, NULL)`,e,
|
|
500
|
+
ORDER BY created_at DESC LIMIT 1`,e)}crystallize(e,t){return this.transaction(()=>{let n=this.insert(`INSERT INTO intent_logs (mission_id, type, content, confidence, is_crystallized, symbol_id, file_path, symbol_name, signature, commit_sha)
|
|
501
|
+
VALUES (?, 'crystal', ?, 1.0, 0, NULL, NULL, NULL, NULL, NULL)`,e,t);return this.run(`UPDATE intent_logs
|
|
434
502
|
SET is_crystallized = 1, crystal_id = ?
|
|
435
503
|
WHERE mission_id = ? AND is_crystallized = 0 AND id != ?
|
|
436
|
-
AND type NOT IN ('adr', 'system', 'crystal', 'lapsed')`,
|
|
504
|
+
AND type NOT IN ('adr', 'system', 'crystal', 'lapsed')`,n,e,n),n})}findRawBySymbol(e){return this.all(`SELECT * FROM intent_logs
|
|
437
505
|
WHERE symbol_id = ? AND mission_id IS NULL AND is_crystallized = 0
|
|
438
506
|
AND type NOT IN ('adr', 'system', 'crystal', 'lapsed')
|
|
439
|
-
ORDER BY created_at ASC`,e)}crystallizeBySymbol(e,
|
|
440
|
-
VALUES (NULL, ?, 'crystal', ?, 1.0, 0, NULL, NULL, NULL, NULL)`,e,
|
|
507
|
+
ORDER BY created_at ASC`,e)}crystallizeBySymbol(e,t){return this.transaction(()=>{let n=this.insert(`INSERT INTO intent_logs (mission_id, symbol_id, type, content, confidence, is_crystallized, file_path, symbol_name, signature, commit_sha)
|
|
508
|
+
VALUES (NULL, ?, 'crystal', ?, 1.0, 0, NULL, NULL, NULL, NULL)`,e,t);return this.run(`UPDATE intent_logs
|
|
441
509
|
SET is_crystallized = 1, crystal_id = ?
|
|
442
510
|
WHERE symbol_id = ? AND mission_id IS NULL AND is_crystallized = 0 AND id != ?
|
|
443
|
-
AND type NOT IN ('adr', 'system', 'crystal', 'lapsed')`,
|
|
511
|
+
AND type NOT IN ('adr', 'system', 'crystal', 'lapsed')`,n,e,n),n})}countByMissions(e){if(e.length===0)return{};let t=e.map(()=>"?").join(","),n=this.all(`SELECT mission_id, COUNT(*) as cnt
|
|
444
512
|
FROM intent_logs
|
|
445
|
-
WHERE mission_id IN (${
|
|
513
|
+
WHERE mission_id IN (${t})
|
|
446
514
|
AND type NOT IN ('system', 'adr', 'lapsed')
|
|
447
|
-
GROUP BY mission_id`,...e),
|
|
515
|
+
GROUP BY mission_id`,...e),i={};for(let r of n)i[r.mission_id]=r.cnt;return i}findMissionsWithBlockers(e){if(e.length===0)return new Set;let t=e.map(()=>"?").join(","),n=this.all(`SELECT DISTINCT mission_id
|
|
448
516
|
FROM intent_logs
|
|
449
|
-
WHERE mission_id IN (${
|
|
450
|
-
AND type = 'blocker'`,...e);return new Set(
|
|
517
|
+
WHERE mission_id IN (${t})
|
|
518
|
+
AND type = 'blocker'`,...e);return new Set(n.map(i=>i.mission_id))}findByMissionPreferCrystal(e,t=50){let n=this.findCrystalByMission(e);if(n){let i=this.all(`SELECT
|
|
451
519
|
id, mission_id, symbol_id, file_path, type, content, confidence,
|
|
452
520
|
symbol_name, signature, commit_sha, is_crystallized, crystal_id,
|
|
453
521
|
created_at
|
|
454
522
|
FROM intent_logs
|
|
455
523
|
WHERE mission_id = ? AND is_crystallized = 0 AND type NOT IN ('adr', 'system', 'crystal', 'lapsed')
|
|
456
524
|
AND created_at > ?
|
|
457
|
-
ORDER BY created_at DESC LIMIT ?`,e,
|
|
525
|
+
ORDER BY created_at DESC LIMIT ?`,e,n.created_at,t-1);return[n,...i]}return this.findByMission(e,t)}async findSemanticTheme(e,t,n=200){let{cosineSimilarity:i}=await Promise.resolve().then(()=>(Ae(),ot)),r=this.findWithEmbeddings(),o=[];for(let a of r)if(s.EMBEDDABLE_TYPES.has(a.type)&&!(t&&a.mission_id!==null&&!t.includes(a.mission_id)))try{let c=JSON.parse(a.embedding),l=i(e,c);l>.35&&o.push({...a,_similarity:l})}catch{}return o.sort((a,c)=>c._similarity-a._similarity).slice(0,n).map(({_similarity:a,...c})=>c)}crystallizeTheme(e,t,n){return this.transaction(()=>{let i=this.insert(`INSERT INTO intent_logs (mission_id, type, content, confidence, is_crystallized, symbol_id, file_path, symbol_name, signature, commit_sha)
|
|
526
|
+
VALUES (NULL, 'crystal', ?, 1.0, 0, NULL, NULL, NULL, NULL, NULL)`,n);if(t.length>0){let r=t.map(()=>"?").join(",");this.run(`UPDATE intent_logs SET is_crystallized = 1, crystal_id = ? WHERE id IN (${r})`,i,...t)}return i})}async backfillEmbeddings(e=64,t){let{generateEmbeddingsBatch:n}=await Promise.resolve().then(()=>(Ae(),ot)),i=[...s.EMBEDDABLE_TYPES].map(p=>`'${p}'`).join(","),r=this.all(`SELECT * FROM intent_logs WHERE embedding IS NULL AND type IN (${i})`);if(r.length===0)return 0;let o=r.map(p=>s.buildEmbeddingText(p)),a=await n(o,e,t),c=this.db.prepare("UPDATE intent_logs SET embedding = ? WHERE id = ?"),l=0;return this.transaction(()=>{for(let p=0;p<r.length;p++)a[p]&&(c.run(JSON.stringify(a[p]),r[p].id),l++)}),S.info({total:r.length,embedded:l},"Intent log embedding backfill complete"),l}}});var On,kr=Z(()=>{"use strict";Ue();On=class extends ae{findByKey(e,t=20){return this.all(`
|
|
458
527
|
SELECT file_path, key, value, kind
|
|
459
528
|
FROM configs
|
|
460
529
|
WHERE key LIKE ? OR value LIKE ?
|
|
461
530
|
LIMIT ?
|
|
462
|
-
`,`%${e}%`,`%${e}%`,
|
|
531
|
+
`,`%${e}%`,`%${e}%`,t)}findByKind(e,t=50){let n="SELECT key, value, kind, file_path FROM configs",i=[];return e&&(n+=" WHERE kind = ?",i.push(e)),n+=" LIMIT ?",i.push(t),this.all(n,...i)}findEnvValue(e){return this.get("SELECT value FROM configs WHERE key LIKE ? OR key = ? LIMIT 1",`%:env:${e}`,e)?.value}countByKind(e){return this.get("SELECT COUNT(*) as count FROM configs WHERE kind = ?",e)?.count||0}getAll(){return this.all("SELECT key, value, kind, file_path FROM configs")}}});var Fn,Cr=Z(()=>{"use strict";Ue();Fn=class extends ae{search(e,t=10){return this.all(`
|
|
463
532
|
SELECT file_path, snippet(content_fts, 1, '<b>', '</b>', '...', 20) as snippet
|
|
464
533
|
FROM content_fts
|
|
465
534
|
WHERE content_fts MATCH ?
|
|
466
535
|
LIMIT ?
|
|
467
|
-
`,e,
|
|
468
|
-
WHERE query LIKE ? ORDER BY created_at DESC LIMIT ?`,`${e}%`,
|
|
536
|
+
`,e,t)}}});var Ir,Wn,Lr=Z(()=>{"use strict";Ue();Ir=500,Wn=class extends ae{record(e,t,n=null){this.run("INSERT INTO search_history (query, mode, branch) VALUES (?, ?, ?)",e,t,n),this.pruneIfNeeded()}findRecent(e=20){return this.all("SELECT id, query, mode, branch, created_at FROM search_history ORDER BY created_at DESC LIMIT ?",e)}findRecentByQueryPrefix(e,t=10){return e.trim()?this.all(`SELECT id, query, mode, branch, created_at FROM search_history
|
|
537
|
+
WHERE query LIKE ? ORDER BY created_at DESC LIMIT ?`,`${e}%`,t):this.findRecent(t)}pruneIfNeeded(){(this.get("SELECT COUNT(*) as count FROM search_history")?.count??0)<=Ir||this.run(`DELETE FROM search_history WHERE id NOT IN (
|
|
469
538
|
SELECT id FROM search_history ORDER BY created_at DESC LIMIT ?
|
|
470
|
-
)`,
|
|
539
|
+
)`,Ir)}}});var Hn,$r=Z(()=>{"use strict";Ue();Hn=class extends ae{getSection(e){return this.get("SELECT section, data, updated_at FROM hologram_snapshot WHERE section = ?",e)}getAllSections(){return this.all("SELECT section, data, updated_at FROM hologram_snapshot ORDER BY section")}upsertSection(e,t){this.run(`
|
|
471
540
|
INSERT INTO hologram_snapshot (section, data, updated_at)
|
|
472
541
|
VALUES (?, ?, unixepoch())
|
|
473
542
|
ON CONFLICT(section) DO UPDATE SET
|
|
474
543
|
data = excluded.data,
|
|
475
544
|
updated_at = excluded.updated_at
|
|
476
|
-
`,e,r)}deleteSection(e){this.run("DELETE FROM hologram_snapshot WHERE section = ?",e)}deleteAll(){this.run("DELETE FROM hologram_snapshot")}hasSection(e){return(this.get("SELECT COUNT(*) as count FROM hologram_snapshot WHERE section = ?",e)?.count??0)>0}}});var L,X=be(()=>{"use strict";dt();Qf();eh();rh();gc();hh();gh();yh();vh();_h();L=class{static repositoryCache=new Map;static getInstance(e){let r=this.repositoryCache.get(e);if(r){let o=We(e),s=r.files?.database,a=!r.intentLogs||!r.searchHistory||!r.missions||!r.hologram;if(s===o&&o.open&&!a)return r;this.repositoryCache.delete(e)}let i=We(e),t={files:new no(i),exports:new ro(i),imports:new io(i),missions:new Xr(i),intentLogs:new po(i),configs:new mo(i),content:new fo(i),searchHistory:new ho(i),hologram:new go(i)};return this.repositoryCache.set(e,t),t}static closeInstance(e){this.repositoryCache.delete(e),Yr(e)}static clearCache(e){this.repositoryCache.delete(e)}}});var $h=hx((FT,_c)=>{var bo=process||{},xh=bo.argv||[],yo=bo.env||{},Jx=!(yo.NO_COLOR||xh.includes("--no-color"))&&(!!yo.FORCE_COLOR||xh.includes("--color")||bo.platform==="win32"||(bo.stdout||{}).isTTY&&yo.TERM!=="dumb"||!!yo.CI),qx=(n,e,r=n)=>i=>{let t=""+i,o=t.indexOf(e,n.length);return~o?n+Vx(t,e,r,o)+e:n+t+e},Vx=(n,e,r,i)=>{let t="",o=0;do t+=n.substring(o,i)+r,o=i+e.length,i=n.indexOf(e,o);while(~i);return t+n.substring(o)},Sh=(n=Jx)=>{let e=n?qx:()=>String;return{isColorSupported:n,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};_c.exports=Sh();_c.exports.createColors=Sh});var Ao,Oo,pg,Mo,mg,fg,hg,gg,yg,bg,vg,_g,xg,Sg,ui,jo,$g,wg,Oc=be(()=>{"use strict";Ao=[/\/pages\/(?!_)[^/]+\.(tsx?|jsx?)$/i,/\/pages\/.*\/index\.(tsx?|jsx?)$/i,/\/app\/.*\/page\.(tsx?|jsx?)$/i,/\/app\/.*\/layout\.(tsx?|jsx?)$/i,/\/app\/api\/.*\/route\.(ts|js)$/i,/\/pages\/api\/.*\.(ts|js)$/i],Oo=[/\.(routes?|router|controller|handler|endpoint|api)\.(ts|js|tsx|jsx)$/i,/\/routes?\//i,/\/controllers?\//i,/index\.(ts|js|tsx|jsx)$/i],pg=[/\/components?\/.*\.(tsx|jsx)$/i,/\/features?\/.*\.(tsx|jsx)$/i,/\/views?\/.*\.(tsx|jsx)$/i,/\/screens?\/.*\.(tsx|jsx)$/i,/\/widgets?\/.*\.(tsx|jsx)$/i],Mo=[/\.(service|usecase|interactor|manager|facade)\.(ts|js)$/i,/\/services?\//i,/\/usecases?\//i,/\/domain\//i,/\/business\//i],mg=[/\/mcp\/handlers?\/[^/]+\.(ts|js)$/i,/\/mcp\/tools?\/[^/]+\.(ts|js)$/i,/\/mcp\/server\.(ts|js)$/i,/\/mcp\/index\.(ts|js)$/i],fg=[/\/mcp\/utils?\.(ts|js)$/i,/\/mcp\/schemas?\.(ts|js)$/i,/\/mcp\/resources?\.(ts|js)$/i],hg=[/\/commands?\/[^/]+\.(ts|js|py|php)$/i,/\/cli\/[^/]+\.(ts|js|py|php)$/i,/\/bin\/[^/]+\.(ts|js|py|php)$/i,/cli\.(ts|js|py|php)$/i,/main\.(ts|js|py|php)$/i],gg=[/\/parser\/[^/]+\.(ts|js)$/i,/\/ast\/[^/]+\.(ts|js)$/i,/\.(parser|visitor|walker|transformer)\.(ts|js)$/i],yg=[/\/core\/[^/]+\.(ts|js)$/i,/\/engine\/[^/]+\.(ts|js)$/i,/\/processing\/[^/]+\.(ts|js)$/i,/\/analysis\/[^/]+\.(ts|js)$/i,/\.(analyzer|processor|scanner|indexer|resolver)\.(ts|js)$/i],bg=[/\/ui\/[^/]+\.(ts|js|tsx|jsx)$/i,/\/display\/[^/]+\.(ts|js)$/i,/\/output\/[^/]+\.(ts|js)$/i,/\.(formatter|renderer|printer)\.(ts|js)$/i],vg=[/\/stores?\//i,/\/slices?\//i,/\/reducers?\//i,/\/atoms?\//i,/\/selectors?\//i,/\.(store|slice|reducer|atom|selector)\.(ts|js)$/i,/.*Slice\.(ts|js)$/i,/.*Store\.(ts|js)$/i],_g=[/\/hooks?\//i,/\/contexts?\//i,/\/providers?\//i,/use[A-Z].*\.(ts|js)$/,/.*Context\.(ts|tsx|js|jsx)$/i,/.*Provider\.(ts|tsx|js|jsx)$/i],xg=[/\/schemas?\//i,/\/validations?\//i,/\.(schema|validation|validator)\.(ts|js)$/i],Sg=[/\.(types?|dto|interface|interfaces)\.(ts|js)$/i,/types\.ts$/i,/\/types?\//i,/\/dtos?\//i,/\/interfaces?\//i,/\/contracts?\//i,/\.d\.ts$/i],ui=[/\.(model|entity|schema|repository|repo|dao|migration|query|mutation|resolver|connection|db)\.(ts|js)$/i,/queries\.(ts|js)$/i,/mutations\.(ts|js)$/i,/resolvers\.(ts|js)$/i,/connection\.(ts|js)$/i,/\/models?\//i,/\/entities?\//i,/\/repositories?\//i,/\/repos?\//i,/\/data\//i,/\/database\//i,/\/prisma\//i,/\/drizzle\//i,/\/api\/.*client\.(ts|js|tsx)$/i,/(^|\/)[A-Z0-9_-]*API\.(tsx?|js|jsx)$/],jo=[/\.(util|utils|helper|helpers|lib|common|shared)\.(ts|js)$/i,/\/utils?\//i,/\/helpers?\//i,/\/lib\//i,/\/common\//i,/\/shared\//i],$g=["express","fastify","koa","hapi","restify","next","nuxt","gatsby","remix","@nestjs/common","@nestjs/core","react-router","vue-router","@angular/router","zod","joi","yup","valibot","superstruct"],wg=["prisma","@prisma/client","typeorm","sequelize","mongoose","drizzle-orm","knex","pg","mysql","sqlite","better-sqlite3","mongodb","redis","ioredis","zustand","redux","recoil","jotai","mobx"]});var Fo,Eg,Uo,Ig,Mc=be(()=>{"use strict";Fo=[/urls\.py$/i,/wsgi\.py$/i,/asgi\.py$/i,/manage\.py$/i,/main\.py$/i,/app\.py$/i,/\/endpoints?\/.*\.py$/i,/\/commands?\/.*\.py$/i],Eg=[/views\.py$/i,/forms\.py$/i,/serializers\.py$/i,/admin\.py$/i,/apps\.py$/i,/tasks\.py$/i,/middlewares?\.py$/i,/signals?\.py$/i,/context_processors\.py$/i],Uo=[/models\.py$/i,/\/models\/.*\.py$/i,/\/migrations\/.*\.py$/i,/schema\.py$/i,/documents\.py$/i],Ig=["django.urls","django.http","flask","fastapi","chalice","tornado"]});var Zo,Pg,Ho,Rg,jc=be(()=>{"use strict";Zo=[/\/routes?\/.*\.php$/i,/\/controllers?\/.*\.php$/i,/index\.php$/i,/server\.php$/i,/artisan$/i,/console$/i],Pg=[/\/services?\/.*\.php$/i,/\/providers?\/.*\.php$/i,/\/middleware\/.*\.php$/i,/\/jobs?\/.*\.php$/i,/\/listeners?\/.*\.php$/i,/\/events?\/.*\.php$/i,/\/observers?\/.*\.php$/i,/\/console\/commands\/.*\.php$/i,/\/actions?\/.*\.php$/i,/\/traits?\/.*\.php$/i,/\/concerns?\/.*\.php$/i,/\/contracts?\/.*\.php$/i],Ho=[/\/models?\/.*\.php$/i,/\/eloquent\/.*\.php$/i,/\/migrations?\/.*\.php$/i,/\/seeders?\/.*\.php$/i,/\/factories?\/.*\.php$/i,/\/repositories?\/.*\.php$/i,/\/resources?\/.*\.php$/i],Rg=["laravel","symfony","slim","cakephp","codeigniter"]});import Ng from"path";function Yt(n,e,r){let i=[],t="Unknown",o=0;r||(r=LS(n,e));let{inDegree:s,outDegree:a}=r,c=(p,f,m,h)=>{for(let v of p)if(v.test(n))return i.push(`${h}: ${v.source}`),t=f,o+=m,!0;return!1},l=!1;if(l||(l=c(Ao,"Entry",45,"Next.js entry")),l||(l=c(mg,"Entry",40,"MCP handler")),l||(l=c(hg,"Entry",40,"CLI command")),l||(l=c(ui,"Data",45,"Data layer/Repository")),l||(l=c(vg,"Data",35,"State management")),l||(l=c(pg,"Logic",40,"React component")),l||(l=c(Mo,"Logic",35,"Logic pattern")),l||(l=c(gg,"Logic",35,"Parser/AST")),l||(l=c(yg,"Logic",35,"Core module")),l||(l=c(bg,"Logic",30,"UI layer")),l||(l=c(Sg,"Types",35,"Type definition")),l||(l=c(Fo,"Entry",40,"Python Entry")),l||(l=c(Uo,"Data",40,"Python Data")),l||(l=c(Eg,"Logic",35,"Python Logic")),l||(l=c(Zo,"Entry",40,"PHP Entry")),l||(l=c(Ho,"Data",40,"PHP Data")),l||(l=c(Pg,"Logic",35,"PHP Logic")),l||(l=c(_g,"Logic",35,"Hook/Context")),!l){for(let p of fg)if(p.test(n)){i.push(`MCP utility: ${p.source}`),/schemas?/i.test(n)?t="Types":/resources?/i.test(n)?t="Data":t="Utility",o+=35,l=!0;break}}l||c(xg,"Data",35,"Schema definition")&&(l=!0),l||(c(ui,"Data",30,"Path matches data pattern")||c(jo,"Utility",25,"Path matches utility pattern")||c(Oo,"Entry",30,"Path matches entry pattern"))&&(l=!0);for(let p of Fc)if(p.test(n)){i.push(`Test file: ${p.source}`),t="Test",o=50,l=!0;break}l||c(Uc,"Infrastructure",40,"Infrastructure")&&(l=!0);for(let p of DS)p.test(n)&&(i.push(`Monorepo component: ${p.source}`),/\/apps\/[^/]+\/src\/pages\//i.test(n)&&(i.push("Monorepo App Entry"),t==="Unknown"&&(t="Entry"),o+=20),/\/packages\/[^/]+\/src\//i.test(n)&&(o+=10));let d=e.imports.getImportsForFile(n).map(p=>p.module_specifier.toLowerCase());for(let p of wg)if(d.some(f=>f.includes(p))){i.push(`Imports JS data library: ${p}`),(t==="Unknown"||t==="Data")&&(t="Data",o+=25);break}for(let p of Ig)if(d.some(f=>f.includes(p))){i.push(`Imports Python framework: ${p}`),(t==="Unknown"||t==="Entry")&&(t="Entry",o+=20);break}for(let p of Rg)if(d.some(f=>f.includes(p))){i.push(`Imports PHP framework: ${p}`),(t==="Unknown"||t==="Entry")&&(t="Entry",o+=20);break}for(let p of $g)if(d.some(f=>f.includes(p))){i.push(`Imports JS framework: ${p}`),(t==="Unknown"||t==="Entry")&&(t="Entry",o+=20);break}if(s===0&&a>0&&(i.push("Entry point: nothing imports this file (in-degree=0)"),t==="Unknown"?(t="Entry",o+=30):t==="Entry"&&(o+=15)),s>5&&a<=2&&(i.push(`High reuse: ${s} files import this (candidate for Utility)`),t==="Unknown"?(t="Utility",o+=25):t==="Utility"&&(o+=10)),t==="Unknown"&&s>0&&a>0){let p=s/(s+a);p>.3&&p<.7&&(i.push(`Balanced traffic: in=${s}, out=${a} (likely Logic layer)`),t="Logic",o+=25)}return t==="Unknown"&&(i.push("No strong classification signals detected"),o=10),o=Math.min(o,100),{layer:t,confidence:o,signals:i}}function LS(n,e){let r=e.imports.countDependents(n),i=e.imports.countByFile(n);return{inDegree:r,outDegree:i}}function Ge(n,e){let r=n.files.getAllPaths().map(m=>({path:m})),i=new Map,t={Entry:[],Logic:[],Data:[],Utility:[],Infrastructure:[],Test:[],Types:[],Unknown:[]};for(let m of r){let h=Yt(m.path,n);i.set(m.path,h),t[h.layer].push({path:m.path,classification:h})}let o={Entry:Kt(t.Entry,e),Logic:Kt(t.Logic,e),Data:Kt(t.Data,e),Utility:Kt(t.Utility,e),Infrastructure:Kt(t.Infrastructure,e),Test:Kt(t.Test,e),Types:Kt(t.Types,e),Unknown:Kt(t.Unknown,e)},s={};r.forEach(m=>{let h=Ng.extname(m.path).toLowerCase();h&&(s[h]=(s[h]||0)+1)});let a={".ts":"TypeScript",".tsx":"Typescript (React)",".js":"JavaScript",".jsx":"JavaScript (React)",".py":"Python",".php":"PHP",".go":"Go",".rs":"Rust",".java":"Java",".cs":"C#",".rb":"Ruby",".vue":"Vue"},c={};Object.entries(s).forEach(([m,h])=>{let v=a[m];v&&(c[v]=(c[v]||0)+h)});let l=Object.entries(c).sort((m,h)=>h[1]-m[1]),u=l.length>0?l[0][0]:"Unknown",{pattern:d,patternConfidence:p,insights:f}=AS(o,r.length,n);return{pattern:d,patternConfidence:p,layers:o,insights:f,primaryStack:u}}function Kt(n,e){return n.sort((r,i)=>i.classification.confidence-r.classification.confidence),{count:n.length,topFiles:n.slice(0,5).map(r=>({path:Ng.relative(e,r.path),confidence:r.classification.confidence,signals:r.classification.signals.slice(0,2)}))}}function AS(n,e,r){let i=[],t="Unknown",o=0,s=n.Entry.count/e*100,a=n.Logic.count/e*100,c=n.Data.count/e*100,l=n.Utility.count/e*100,u=n.Unknown.count/e*100;s>5&&a>10&&c>5&&u<40?(t="Layered",o=60+Math.min(30,(100-u)/3),i.push(`Clear layer separation: Entry (${s.toFixed(1)}%), Logic (${a.toFixed(1)}%), Data (${c.toFixed(1)}%)`)):l>20?(t="Modular",o=50+l/2,i.push(`High shared module usage: ${l.toFixed(1)}% utility files`)):u>60&&(t="Monolithic",o=40+u/4,i.push(`Limited architectural structure: ${u.toFixed(1)}% files with unclear layer assignment`));let d=r.configs.countByKind("Service");return d>3&&(t="Microservices",o=55+d*5,i.push(`Detected ${d} service definitions (likely microservices)`)),n.Entry.count===0&&i.push("\u26A0\uFE0F No clear entry points detected - consider adding route/controller files"),n.Data.count===0&&i.push("\u26A0\uFE0F No data layer detected - repository may not use traditional ORM patterns"),l>30&&i.push(`High utility concentration (${l.toFixed(1)}%) - good reusability`),{pattern:t,patternConfidence:Math.min(100,o),insights:i}}var Fc,Uc,DS,ht=be(()=>{"use strict";Oc();Mc();jc();Fc=[/\.(test|spec)\.(ts|tsx|js|jsx)$/i,/tests?\.py$/i,/\/__tests__\//i,/\/tests?\//i,/\.e2e\.(ts|js)$/i,/\.integration\.(ts|js)$/i],Uc=[/Dockerfile/i,/docker-compose/i,/\.ya?ml$/i,/nginx\.conf/i,/\/infra\//i,/\/deploy\//i,/\/k8s\//i,/\/kubernetes\//i,/\/terraform\//i,/\/ansible\//i,/package\.json/i,/tsconfig.*\.json/i,/\.env/i],DS=[/\/apps\/[^/]+\//i,/\/services\/[^/]+\//i,/\/packages\/[^/]+\//i,/\/backends\/[^/]+\//i,/\/backends_python\/[^/]+\//i]});var Zg={};et(Zg,{HologramService:()=>pe});var yt,pe,Je=be(()=>{"use strict";X();ht();J();yt=$.child({module:"hologram"}),pe=class{repos;repoPath;constructor(e){this.repoPath=e,this.repos=L.getInstance(e)}updateTopography(e){yt.debug({repoPath:this.repoPath},"Updating topography snapshot");let r=Object.values(e.layers).reduce((o,s)=>o+s.count,0),i={};for(let[o,s]of Object.entries(e.layers)){let a=r>0?s.count/r*100:0;i[o]={count:s.count,percentage:Math.round(a*10)/10,topFiles:s.topFiles.slice(0,3).map(c=>({path:c.path,confidence:c.confidence}))}}let t={pattern:e.pattern,patternConfidence:e.patternConfidence,layerDistribution:i,insights:e.insights,updatedAt:Date.now()};this.repos.hologram.upsertSection("topography",JSON.stringify(t)),yt.info({repoPath:this.repoPath},"Topography snapshot updated")}refreshTopography(){let e=Ge(this.repos,this.repoPath);this.updateTopography(e)}updateGravityZones(e){yt.debug({repoPath:this.repoPath,count:e.length},"Updating gravity zones");let r={hotspots:e.slice(0,50),updatedAt:Date.now()};this.repos.hologram.upsertSection("gravity",JSON.stringify(r)),yt.info({repoPath:this.repoPath},"Gravity zones updated")}updateGhostBridges(e){yt.debug({repoPath:this.repoPath,count:e.length},"Updating ghost bridges");let r={bridges:e.slice(0,20),updatedAt:Date.now()};this.repos.hologram.upsertSection("ghosts",JSON.stringify(r)),yt.info({repoPath:this.repoPath},"Ghost bridges updated")}getSnapshot(){let e=this.repos.hologram.getAllSections(),r={metadata:{repoPath:this.repoPath,lastUpdated:Date.now(),version:"1.0.0"}};for(let i of e)try{let t=JSON.parse(i.data);switch(i.section){case"topography":r.topography=t;break;case"gravity":r.gravity=t;break;case"ghosts":r.ghosts=t;break}}catch(t){yt.error({repoPath:this.repoPath,section:i.section,error:t},"Failed to parse hologram section")}return r}getSection(e){let r=this.repos.hologram.getSection(e);if(!r)return null;try{return JSON.parse(r.data)}catch(i){return yt.error({repoPath:this.repoPath,section:e,error:i},"Failed to parse section"),null}}computeGravityZones(){yt.debug({repoPath:this.repoPath},"Computing gravity zones from import graph");let e=this.repos.files.getAllPaths(),r=new Map;for(let t of e){let o=Yt(t,this.repos);if(o.layer==="Test"||o.layer==="Unknown")continue;let s=this.repos.exports.findByFile(t);if(s.length===0)continue;let a=this.repos.imports.countDependents(t),c=this.repos.imports.countByFile(t),l=a*2+c;if(l>0){let u=s.find(p=>p.kind!=="TsTypeAliasDeclaration"&&p.kind!=="TsInterfaceDeclaration")||s[0],d=`${t}::${u.name}`;r.set(d,{symbol:u.name,filePath:t,inDegree:a,outDegree:c,gravity:l})}}let i=Array.from(r.values()).sort((t,o)=>o.gravity-t.gravity).slice(0,50);return yt.info({repoPath:this.repoPath,count:i.length},"Gravity zones computed"),i}isInitialized(){return this.repos.hologram.getAllSections().length>0}clear(){this.repos.hologram.deleteAll(),yt.info({repoPath:this.repoPath},"Hologram cleared")}}});var Qv={};et(Qv,{GraphExporterService:()=>Va});var Xv,Va,Qm=be(()=>{"use strict";X();J();Xv=$.child({module:"graph-exporter"}),Va=class{constructor(e){this.repoPath=e;this.repos=L.getInstance(e)}repos;async generateGraph(e={}){let{includeCompleted:r=!0,format:i="mermaid",focusMissionId:t,depth:o=10,limit:s=100}=e;Xv.info({focusMissionId:t,depth:o,format:i,includeCompleted:r},"Generating mission graph");let a=this.buildMissionTree(t,r,o,s);return i==="json"?JSON.stringify(a,null,2):this.generateMermaidDiagram(a)}buildMissionTree(e,r,i,t){let o;if(e){let c=this.repos.missions.findById(e);o=c?[c]:[]}else o=this.repos.missions.findAll().filter(l=>!l.parent_id),r||(o=o.filter(l=>l.status!=="completed"));let s=0,a=[];for(let c of o){if(s>=t)break;let l=this.buildNode(c,r,i,1,{count:s,max:t});l&&(a.push(l),s+=this.countNodes(l))}return a}buildNode(e,r,i,t,o){if(t>i||o.count>=o.max)return null;let s;if(e.strategy_graph)try{let u=JSON.parse(e.strategy_graph);s=this.parseStrategySteps(u)}catch(u){Xv.debug({missionId:e.id,err:u},"Failed to parse strategy graph")}let a={id:e.id,name:e.name,status:e.status,goal:e.goal,branch:e.git_branch||void 0,children:[],steps:s},c=this.repos.missions.findByParentId(e.id),l=r?c:c.filter(u=>u.status!=="completed");for(let u of l){if(o.count>=o.max)break;let d=this.buildNode(u,r,i,t+1,o);d&&(a.children.push(d),o.count++)}return a}parseStrategySteps(e){let r=[];return Array.isArray(e)?e.map((i,t)=>({id:i.id||`step-${t}`,description:i.description||i.content||i.name||`Step ${t+1}`,status:i.status,dependencies:i.dependencies||i.deps})):e.steps&&Array.isArray(e.steps)?this.parseStrategySteps(e.steps):typeof e=="object"?Object.entries(e).map(([i,t])=>({id:i,description:t.description||t.content||i,status:t.status,dependencies:t.dependencies||t.deps})):r}countNodes(e){let r=1;for(let i of e.children)r+=this.countNodes(i);return r}generateMermaidDiagram(e){let r=["graph TD"];for(let i of e)this.addMermaidNode(i,r);return r.join(`
|
|
477
|
-
`)}addMermaidNode(e,
|
|
478
|
-
`),
|
|
479
|
-
${
|
|
480
|
-
${
|
|
481
|
-
${
|
|
545
|
+
`,e,t)}deleteSection(e){this.run("DELETE FROM hologram_snapshot WHERE section = ?",e)}deleteAll(){this.run("DELETE FROM hologram_snapshot")}hasSection(e){return(this.get("SELECT COUNT(*) as count FROM hologram_snapshot WHERE section = ?",e)?.count??0)>0}}});var O,V=Z(()=>{"use strict";Ze();lr();pr();mr();Tr();Rr();kr();Cr();Lr();$r();O=class{static repositoryCache=new Map;static getInstance(e){let t=this.repositoryCache.get(e);if(t){let r=Te(e),o=t.files?.database,a=!t.intentLogs||!t.searchHistory||!t.missions||!t.hologram;if(o===r&&r.open&&!a)return t;this.repositoryCache.delete(e)}let n=Te(e),i={files:new Cn(n),exports:new In(n),imports:new Ln(n),missions:new Nn(n),intentLogs:new Dn(n),configs:new On(n),content:new Fn(n),searchHistory:new Wn(n),hologram:new Hn(n)};return this.repositoryCache.set(e,i),i}static closeInstance(e){this.repositoryCache.delete(e),kn(e)}static clearCache(e){this.repositoryCache.delete(e)}}});var Mr=jc((gh,is)=>{var Un=process||{},Ar=Un.argv||[],zn=Un.env||{},Cl=!(zn.NO_COLOR||Ar.includes("--no-color"))&&(!!zn.FORCE_COLOR||Ar.includes("--color")||Un.platform==="win32"||(Un.stdout||{}).isTTY&&zn.TERM!=="dumb"||!!zn.CI),Il=(s,e,t=s)=>n=>{let i=""+n,r=i.indexOf(e,s.length);return~r?s+Ll(i,e,t,r)+e:s+i+e},Ll=(s,e,t,n)=>{let i="",r=0;do i+=s.substring(r,n)+t,r=n+e.length,n=s.indexOf(e,r);while(~n);return i+s.substring(r)},Pr=(s=Cl)=>{let e=s?Il:()=>String;return{isColorSupported:s,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};is.exports=Pr();is.exports.createColors=Pr});var ai,ci,Co,li,Io,Lo,$o,Ao,Po,Mo,No,Do,Oo,Fo,mn,pi,Wo,Ho,ys=Z(()=>{"use strict";ai=[/\/pages\/(?!_)[^/]+\.(tsx?|jsx?)$/i,/\/pages\/.*\/index\.(tsx?|jsx?)$/i,/\/app\/.*\/page\.(tsx?|jsx?)$/i,/\/app\/.*\/layout\.(tsx?|jsx?)$/i,/\/app\/api\/.*\/route\.(ts|js)$/i,/\/pages\/api\/.*\.(ts|js)$/i],ci=[/\.(routes?|router|controller|handler|endpoint|api)\.(ts|js|tsx|jsx)$/i,/\/routes?\//i,/\/controllers?\//i,/index\.(ts|js|tsx|jsx)$/i],Co=[/\/components?\/.*\.(tsx|jsx)$/i,/\/features?\/.*\.(tsx|jsx)$/i,/\/views?\/.*\.(tsx|jsx)$/i,/\/screens?\/.*\.(tsx|jsx)$/i,/\/widgets?\/.*\.(tsx|jsx)$/i],li=[/\.(service|usecase|interactor|manager|facade)\.(ts|js)$/i,/\/services?\//i,/\/usecases?\//i,/\/domain\//i,/\/business\//i],Io=[/\/mcp\/handlers?\/[^/]+\.(ts|js)$/i,/\/mcp\/tools?\/[^/]+\.(ts|js)$/i,/\/mcp\/server\.(ts|js)$/i,/\/mcp\/index\.(ts|js)$/i],Lo=[/\/mcp\/utils?\.(ts|js)$/i,/\/mcp\/schemas?\.(ts|js)$/i,/\/mcp\/resources?\.(ts|js)$/i],$o=[/\/commands?\/[^/]+\.(ts|js|py|php)$/i,/\/cli\/[^/]+\.(ts|js|py|php)$/i,/\/bin\/[^/]+\.(ts|js|py|php)$/i,/cli\.(ts|js|py|php)$/i,/main\.(ts|js|py|php)$/i],Ao=[/\/parser\/[^/]+\.(ts|js)$/i,/\/ast\/[^/]+\.(ts|js)$/i,/\.(parser|visitor|walker|transformer)\.(ts|js)$/i],Po=[/\/core\/[^/]+\.(ts|js)$/i,/\/engine\/[^/]+\.(ts|js)$/i,/\/processing\/[^/]+\.(ts|js)$/i,/\/analysis\/[^/]+\.(ts|js)$/i,/\.(analyzer|processor|scanner|indexer|resolver)\.(ts|js)$/i],Mo=[/\/ui\/[^/]+\.(ts|js|tsx|jsx)$/i,/\/display\/[^/]+\.(ts|js)$/i,/\/output\/[^/]+\.(ts|js)$/i,/\.(formatter|renderer|printer)\.(ts|js)$/i],No=[/\/stores?\//i,/\/slices?\//i,/\/reducers?\//i,/\/atoms?\//i,/\/selectors?\//i,/\.(store|slice|reducer|atom|selector)\.(ts|js)$/i,/.*Slice\.(ts|js)$/i,/.*Store\.(ts|js)$/i],Do=[/\/hooks?\//i,/\/contexts?\//i,/\/providers?\//i,/use[A-Z].*\.(ts|js)$/,/.*Context\.(ts|tsx|js|jsx)$/i,/.*Provider\.(ts|tsx|js|jsx)$/i],Oo=[/\/schemas?\//i,/\/validations?\//i,/\.(schema|validation|validator)\.(ts|js)$/i],Fo=[/\.(types?|dto|interface|interfaces)\.(ts|js)$/i,/types\.ts$/i,/\/types?\//i,/\/dtos?\//i,/\/interfaces?\//i,/\/contracts?\//i,/\.d\.ts$/i],mn=[/\.(model|entity|schema|repository|repo|dao|migration|query|mutation|resolver|connection|db)\.(ts|js)$/i,/queries\.(ts|js)$/i,/mutations\.(ts|js)$/i,/resolvers\.(ts|js)$/i,/connection\.(ts|js)$/i,/\/models?\//i,/\/entities?\//i,/\/repositories?\//i,/\/repos?\//i,/\/data\//i,/\/database\//i,/\/prisma\//i,/\/drizzle\//i,/\/api\/.*client\.(ts|js|tsx)$/i,/(^|\/)[A-Z0-9_-]*API\.(tsx?|js|jsx)$/],pi=[/\.(util|utils|helper|helpers|lib|common|shared)\.(ts|js)$/i,/\/utils?\//i,/\/helpers?\//i,/\/lib\//i,/\/common\//i,/\/shared\//i],Wo=["express","fastify","koa","hapi","restify","next","nuxt","gatsby","remix","@nestjs/common","@nestjs/core","react-router","vue-router","@angular/router","zod","joi","yup","valibot","superstruct"],Ho=["prisma","@prisma/client","typeorm","sequelize","mongoose","drizzle-orm","knex","pg","mysql","sqlite","better-sqlite3","mongodb","redis","ioredis","zustand","redux","recoil","jotai","mobx"]});var ui,Uo,di,jo,bs=Z(()=>{"use strict";ui=[/urls\.py$/i,/wsgi\.py$/i,/asgi\.py$/i,/manage\.py$/i,/main\.py$/i,/app\.py$/i,/\/endpoints?\/.*\.py$/i,/\/commands?\/.*\.py$/i],Uo=[/views\.py$/i,/forms\.py$/i,/serializers\.py$/i,/admin\.py$/i,/apps\.py$/i,/tasks\.py$/i,/middlewares?\.py$/i,/signals?\.py$/i,/context_processors\.py$/i],di=[/models\.py$/i,/\/models\/.*\.py$/i,/\/migrations\/.*\.py$/i,/schema\.py$/i,/documents\.py$/i],jo=["django.urls","django.http","flask","fastapi","chalice","tornado"]});var mi,Go,hi,qo,_s=Z(()=>{"use strict";mi=[/\/routes?\/.*\.php$/i,/\/controllers?\/.*\.php$/i,/index\.php$/i,/server\.php$/i,/artisan$/i,/console$/i],Go=[/\/services?\/.*\.php$/i,/\/providers?\/.*\.php$/i,/\/middleware\/.*\.php$/i,/\/jobs?\/.*\.php$/i,/\/listeners?\/.*\.php$/i,/\/events?\/.*\.php$/i,/\/observers?\/.*\.php$/i,/\/console\/commands\/.*\.php$/i,/\/actions?\/.*\.php$/i,/\/traits?\/.*\.php$/i,/\/concerns?\/.*\.php$/i,/\/contracts?\/.*\.php$/i],hi=[/\/models?\/.*\.php$/i,/\/eloquent\/.*\.php$/i,/\/migrations?\/.*\.php$/i,/\/seeders?\/.*\.php$/i,/\/factories?\/.*\.php$/i,/\/repositories?\/.*\.php$/i,/\/resources?\/.*\.php$/i],qo=["laravel","symfony","slim","cakephp","codeigniter"]});import Jo from"path";function Ct(s,e,t){let n=[],i="Unknown",r=0;t||(t=Rp(s,e));let{inDegree:o,outDegree:a}=t,c=(d,h,m,f)=>{for(let _ of d)if(_.test(s))return n.push(`${f}: ${_.source}`),i=h,r+=m,!0;return!1},l=!1;if(l||(l=c(ai,"Entry",45,"Next.js entry")),l||(l=c(Io,"Entry",40,"MCP handler")),l||(l=c($o,"Entry",40,"CLI command")),l||(l=c(mn,"Data",45,"Data layer/Repository")),l||(l=c(No,"Data",35,"State management")),l||(l=c(Co,"Logic",40,"React component")),l||(l=c(li,"Logic",35,"Logic pattern")),l||(l=c(Ao,"Logic",35,"Parser/AST")),l||(l=c(Po,"Logic",35,"Core module")),l||(l=c(Mo,"Logic",30,"UI layer")),l||(l=c(Fo,"Types",35,"Type definition")),l||(l=c(ui,"Entry",40,"Python Entry")),l||(l=c(di,"Data",40,"Python Data")),l||(l=c(Uo,"Logic",35,"Python Logic")),l||(l=c(mi,"Entry",40,"PHP Entry")),l||(l=c(hi,"Data",40,"PHP Data")),l||(l=c(Go,"Logic",35,"PHP Logic")),l||(l=c(Do,"Logic",35,"Hook/Context")),!l){for(let d of Lo)if(d.test(s)){n.push(`MCP utility: ${d.source}`),/schemas?/i.test(s)?i="Types":/resources?/i.test(s)?i="Data":i="Utility",r+=35,l=!0;break}}l||c(Oo,"Data",35,"Schema definition")&&(l=!0),l||(c(mn,"Data",30,"Path matches data pattern")||c(pi,"Utility",25,"Path matches utility pattern")||c(ci,"Entry",30,"Path matches entry pattern"))&&(l=!0);for(let d of Es)if(d.test(s)){n.push(`Test file: ${d.source}`),i="Test",r=50,l=!0;break}l||c(Ss,"Infrastructure",40,"Infrastructure")&&(l=!0);for(let d of Tp)d.test(s)&&(n.push(`Monorepo component: ${d.source}`),/\/apps\/[^/]+\/src\/pages\//i.test(s)&&(n.push("Monorepo App Entry"),i==="Unknown"&&(i="Entry"),r+=20),/\/packages\/[^/]+\/src\//i.test(s)&&(r+=10));let u=e.imports.getImportsForFile(s).map(d=>d.module_specifier.toLowerCase());for(let d of Ho)if(u.some(h=>h.includes(d))){n.push(`Imports JS data library: ${d}`),(i==="Unknown"||i==="Data")&&(i="Data",r+=25);break}for(let d of jo)if(u.some(h=>h.includes(d))){n.push(`Imports Python framework: ${d}`),(i==="Unknown"||i==="Entry")&&(i="Entry",r+=20);break}for(let d of qo)if(u.some(h=>h.includes(d))){n.push(`Imports PHP framework: ${d}`),(i==="Unknown"||i==="Entry")&&(i="Entry",r+=20);break}for(let d of Wo)if(u.some(h=>h.includes(d))){n.push(`Imports JS framework: ${d}`),(i==="Unknown"||i==="Entry")&&(i="Entry",r+=20);break}if(o===0&&a>0&&(n.push("Entry point: nothing imports this file (in-degree=0)"),i==="Unknown"?(i="Entry",r+=30):i==="Entry"&&(r+=15)),o>5&&a<=2&&(n.push(`High reuse: ${o} files import this (candidate for Utility)`),i==="Unknown"?(i="Utility",r+=25):i==="Utility"&&(r+=10)),i==="Unknown"&&o>0&&a>0){let d=o/(o+a);d>.3&&d<.7&&(n.push(`Balanced traffic: in=${o}, out=${a} (likely Logic layer)`),i="Logic",r+=25)}return i==="Unknown"&&(n.push("No strong classification signals detected"),r=10),r=Math.min(r,100),{layer:i,confidence:r,signals:n}}function Rp(s,e){let t=e.imports.countDependents(s),n=e.imports.countByFile(s);return{inDegree:t,outDegree:n}}function mt(s,e){let t=s.files.getAllPaths().map(m=>({path:m})),n=new Map,i={Entry:[],Logic:[],Data:[],Utility:[],Infrastructure:[],Test:[],Types:[],Unknown:[]};for(let m of t){let f=Ct(m.path,s);n.set(m.path,f),i[f.layer].push({path:m.path,classification:f})}let r={Entry:dt(i.Entry,e),Logic:dt(i.Logic,e),Data:dt(i.Data,e),Utility:dt(i.Utility,e),Infrastructure:dt(i.Infrastructure,e),Test:dt(i.Test,e),Types:dt(i.Types,e),Unknown:dt(i.Unknown,e)},o={};t.forEach(m=>{let f=Jo.extname(m.path).toLowerCase();f&&(o[f]=(o[f]||0)+1)});let a={".ts":"TypeScript",".tsx":"Typescript (React)",".js":"JavaScript",".jsx":"JavaScript (React)",".py":"Python",".php":"PHP",".go":"Go",".rs":"Rust",".java":"Java",".cs":"C#",".rb":"Ruby",".vue":"Vue"},c={};Object.entries(o).forEach(([m,f])=>{let _=a[m];_&&(c[_]=(c[_]||0)+f)});let l=Object.entries(c).sort((m,f)=>f[1]-m[1]),p=l.length>0?l[0][0]:"Unknown",{pattern:u,patternConfidence:d,insights:h}=kp(r,t.length,s);return{pattern:u,patternConfidence:d,layers:r,insights:h,primaryStack:p}}function dt(s,e){return s.sort((t,n)=>n.classification.confidence-t.classification.confidence),{count:s.length,topFiles:s.slice(0,5).map(t=>({path:Jo.relative(e,t.path),confidence:t.classification.confidence,signals:t.classification.signals.slice(0,2)}))}}function kp(s,e,t){let n=[],i="Unknown",r=0,o=s.Entry.count/e*100,a=s.Logic.count/e*100,c=s.Data.count/e*100,l=s.Utility.count/e*100,p=s.Unknown.count/e*100;o>5&&a>10&&c>5&&p<40?(i="Layered",r=60+Math.min(30,(100-p)/3),n.push(`Clear layer separation: Entry (${o.toFixed(1)}%), Logic (${a.toFixed(1)}%), Data (${c.toFixed(1)}%)`)):l>20?(i="Modular",r=50+l/2,n.push(`High shared module usage: ${l.toFixed(1)}% utility files`)):p>60&&(i="Monolithic",r=40+p/4,n.push(`Limited architectural structure: ${p.toFixed(1)}% files with unclear layer assignment`));let u=t.configs.countByKind("Service");return u>3&&(i="Microservices",r=55+u*5,n.push(`Detected ${u} service definitions (likely microservices)`)),s.Entry.count===0&&n.push("\u26A0\uFE0F No clear entry points detected - consider adding route/controller files"),s.Data.count===0&&n.push("\u26A0\uFE0F No data layer detected - repository may not use traditional ORM patterns"),l>30&&n.push(`High utility concentration (${l.toFixed(1)}%) - good reusability`),{pattern:i,patternConfidence:Math.min(100,r),insights:n}}var Es,Ss,Tp,It=Z(()=>{"use strict";ys();bs();_s();Es=[/\.(test|spec)\.(ts|tsx|js|jsx)$/i,/tests?\.py$/i,/\/__tests__\//i,/\/tests?\//i,/\.e2e\.(ts|js)$/i,/\.integration\.(ts|js)$/i],Ss=[/Dockerfile/i,/docker-compose/i,/\.ya?ml$/i,/nginx\.conf/i,/\/infra\//i,/\/deploy\//i,/\/k8s\//i,/\/kubernetes\//i,/\/terraform\//i,/\/ansible\//i,/package\.json/i,/tsconfig.*\.json/i,/\.env/i],Tp=[/\/apps\/[^/]+\//i,/\/services\/[^/]+\//i,/\/packages\/[^/]+\//i,/\/backends\/[^/]+\//i,/\/backends_python\/[^/]+\//i]});function wu(s){try{return JSON.stringify(s)}catch{return String(s)}}function At(s){if(s instanceof Error)return s.message;if(typeof s=="string")return s;if(s&&typeof s=="object"&&"message"in s){let e=s.message;if(typeof e=="string"&&e.trim())return e}return wu(s)}function ye(s){if(s instanceof Error){let e;return"cause"in s&&s.cause!==void 0&&(e=At(s.cause)),{errorName:s.name||"Error",errorMessage:s.message,errorStack:s.stack,...e?{errorCause:e}:{}}}return s&&typeof s=="object"?{errorName:s.constructor?.name||"Object",errorMessage:At(s)}:{errorName:typeof s,errorMessage:At(s)}}var gn=Z(()=>{"use strict"});var wa={};qi(wa,{HologramService:()=>Se});var Oe,Se,Gt=Z(()=>{"use strict";V();It();q();gn();Oe=S.child({module:"hologram"}),Se=class{repos;repoPath;constructor(e){this.repoPath=e,this.repos=O.getInstance(e)}updateTopography(e){Oe.debug({repoPath:this.repoPath},"Updating topography snapshot");let t=Object.values(e.layers).reduce((r,o)=>r+o.count,0),n={};for(let[r,o]of Object.entries(e.layers)){let a=t>0?o.count/t*100:0;n[r]={count:o.count,percentage:Math.round(a*10)/10,topFiles:o.topFiles.slice(0,3).map(c=>({path:c.path,confidence:c.confidence}))}}let i={pattern:e.pattern,patternConfidence:e.patternConfidence,layerDistribution:n,insights:e.insights,updatedAt:Date.now()};this.repos.hologram.upsertSection("topography",JSON.stringify(i)),Oe.info({repoPath:this.repoPath},"Topography snapshot updated")}refreshTopography(){let e=mt(this.repos,this.repoPath);this.updateTopography(e)}updateGravityZones(e){Oe.debug({repoPath:this.repoPath,count:e.length},"Updating gravity zones");let t={hotspots:e.slice(0,50),updatedAt:Date.now()};this.repos.hologram.upsertSection("gravity",JSON.stringify(t)),Oe.info({repoPath:this.repoPath},"Gravity zones updated")}updateGhostBridges(e){Oe.debug({repoPath:this.repoPath,count:e.length},"Updating ghost bridges");let t={bridges:e.slice(0,20),updatedAt:Date.now()};this.repos.hologram.upsertSection("ghosts",JSON.stringify(t)),Oe.info({repoPath:this.repoPath},"Ghost bridges updated")}getSnapshot(){let e=this.repos.hologram.getAllSections(),t={metadata:{repoPath:this.repoPath,lastUpdated:Date.now(),version:"1.0.0"}};for(let n of e)try{let i=JSON.parse(n.data);switch(n.section){case"topography":t.topography=i;break;case"gravity":t.gravity=i;break;case"ghosts":t.ghosts=i;break}}catch(i){Oe.debug({repoPath:this.repoPath,section:n.section,...ye(i)},"Skipping malformed hologram section")}return t}getSection(e){let t=this.repos.hologram.getSection(e);if(!t)return null;try{return JSON.parse(t.data)}catch(n){return Oe.debug({repoPath:this.repoPath,section:e,...ye(n)},"Skipping malformed hologram section"),null}}computeGravityZones(){Oe.debug({repoPath:this.repoPath},"Computing gravity zones from import graph");let e=this.repos.files.getAllPaths(),t=new Map;for(let i of e){let r=Ct(i,this.repos);if(r.layer==="Test"||r.layer==="Unknown")continue;let o=this.repos.exports.findByFile(i);if(o.length===0)continue;let a=this.repos.imports.countDependents(i),c=this.repos.imports.countByFile(i),l=a*2+c;if(l>0){let p=o.find(d=>d.kind!=="TsTypeAliasDeclaration"&&d.kind!=="TsInterfaceDeclaration")||o[0],u=`${i}::${p.name}`;t.set(u,{symbol:p.name,filePath:i,inDegree:a,outDegree:c,gravity:l})}}let n=Array.from(t.values()).sort((i,r)=>r.gravity-i.gravity).slice(0,50);return Oe.info({repoPath:this.repoPath,count:n.length},"Gravity zones computed"),n}isInitialized(){return this.repos.hologram.getAllSections().length>0}clear(){this.repos.hologram.deleteAll(),Oe.info({repoPath:this.repoPath},"Hologram cleared")}}});var pc={};qi(pc,{GraphExporterService:()=>Vs});var lc,Vs,uc=Z(()=>{"use strict";V();q();lc=S.child({module:"graph-exporter"}),Vs=class{constructor(e){this.repoPath=e;this.repos=O.getInstance(e)}repos;async generateGraph(e={}){let{includeCompleted:t=!0,format:n="mermaid",focusMissionId:i,depth:r=10,limit:o=100}=e;lc.info({focusMissionId:i,depth:r,format:n,includeCompleted:t},"Generating mission graph");let a=this.buildMissionTree(i,t,r,o);return n==="json"?JSON.stringify(a,null,2):this.generateMermaidDiagram(a)}buildMissionTree(e,t,n,i){let r;if(e){let c=this.repos.missions.findById(e);r=c?[c]:[]}else r=this.repos.missions.findAll().filter(l=>!l.parent_id),t||(r=r.filter(l=>l.status!=="completed"));let o=0,a=[];for(let c of r){if(o>=i)break;let l=this.buildNode(c,t,n,1,{count:o,max:i});l&&(a.push(l),o+=this.countNodes(l))}return a}buildNode(e,t,n,i,r){if(i>n||r.count>=r.max)return null;let o;if(e.strategy_graph)try{let p=JSON.parse(e.strategy_graph);o=this.parseStrategySteps(p)}catch(p){lc.debug({missionId:e.id,err:p},"Failed to parse strategy graph")}let a={id:e.id,name:e.name,status:e.status,goal:e.goal,branch:e.git_branch||void 0,children:[],steps:o},c=this.repos.missions.findByParentId(e.id),l=t?c:c.filter(p=>p.status!=="completed");for(let p of l){if(r.count>=r.max)break;let u=this.buildNode(p,t,n,i+1,r);u&&(a.children.push(u),r.count++)}return a}parseStrategySteps(e){let t=[];return Array.isArray(e)?e.map((n,i)=>({id:n.id||`step-${i}`,description:n.description||n.content||n.name||`Step ${i+1}`,status:n.status,dependencies:n.dependencies||n.deps})):e.steps&&Array.isArray(e.steps)?this.parseStrategySteps(e.steps):typeof e=="object"?Object.entries(e).map(([n,i])=>({id:n,description:i.description||i.content||n,status:i.status,dependencies:i.dependencies||i.deps})):t}countNodes(e){let t=1;for(let n of e.children)t+=this.countNodes(n);return t}generateMermaidDiagram(e){let t=["graph TD"];for(let n of e)this.addMermaidNode(n,t);return t.join(`
|
|
546
|
+
`)}addMermaidNode(e,t,n){let i=`M${e.id}`,r=this.getStatusIcon(e.status),o=this.getStatusClass(e.status),a=`${r} ${e.name}`;if(t.push(` ${i}["${this.escapeMermaid(a)}"]:::${o}`),n&&t.push(` ${n} --> ${i}`),e.steps&&e.steps.length>0&&e.steps.length<=10)for(let c of e.steps){let l=`S${e.id}_${c.id}`,p=c.status||"pending",u=this.getStatusIcon(p),d=this.getStatusClass(p),h=`${u} ${c.description}`;if(t.push(` ${l}["${this.escapeMermaid(h)}"]:::${d}`),t.push(` ${i} -.-> ${l}`),c.dependencies&&c.dependencies.length>0)for(let m of c.dependencies){let f=`S${e.id}_${m}`;t.push(` ${f} --> ${l}`)}}for(let c of e.children)this.addMermaidNode(c,t,i);n||(t.push(""),t.push(" classDef completed fill:#90EE90,stroke:#2E8B57,stroke-width:2px"),t.push(" classDef inProgress fill:#87CEEB,stroke:#4682B4,stroke-width:2px"),t.push(" classDef planned fill:#FFE4B5,stroke:#DAA520,stroke-width:2px"),t.push(" classDef suspended fill:#D3D3D3,stroke:#808080,stroke-width:2px"),t.push(" classDef failed fill:#FFB6C1,stroke:#DC143C,stroke-width:2px"),t.push(" classDef pending fill:#FFF8DC,stroke:#B8860B,stroke-width:1px"))}getStatusIcon(e){return{completed:"\u2713","in-progress":"\u26A1",planned:"\u{1F4CB}",suspended:"\u23F8",failed:"\u2717",pending:"\u25CB",verifying:"\u{1F50D}"}[e]||"\u25CB"}getStatusClass(e){return{completed:"completed","in-progress":"inProgress",planned:"planned",suspended:"suspended",failed:"failed",pending:"pending",verifying:"inProgress"}[e]||"pending"}escapeMermaid(e){return e.replace(/"/g,"#quot;").replace(/\n/g," ").replace(/\[/g,"#91;").replace(/]/g,"#93;").slice(0,100)}}});import"dotenv/config";import{Cli as Yd}from"clerc";q();import Xs from"fs";import Yc from"path";import Zs from"js-yaml";var er={ignore:[],include:[],maxDepth:10},Kc=[{name:".liquid-shadow.yaml",parse:s=>Zs.load(s)??{}},{name:".liquid-shadow.yml",parse:s=>Zs.load(s)??{}},{name:".ls.json",parse:s=>JSON.parse(s)},{name:".liquid-shadow.json",parse:s=>JSON.parse(s)},{name:".ls.rc",parse:s=>JSON.parse(s)},{name:".liquid-shadow.rc",parse:s=>JSON.parse(s)}];function Ke(s){for(let{name:e,parse:t}of Kc){let n=Yc.join(s,e);if(Xs.existsSync(n))try{let i=Xs.readFileSync(n,"utf8"),r=t(i);return S.debug({repoPath:s,configFile:e},"Loaded repository configuration"),{...er,...r}}catch(i){S.error({repoPath:s,file:e,err:i},"Failed to parse configuration file")}}return er}function Vi(s,e){let n=Ke(s).cli??{};return{dir:e.dir??n.dir??".",level:e.level??n.level,deep:e.deep!==void 0?e.deep:n.deep}}V();import Al from"path";var ue=Gc(Mr(),1);import*as je from"@clack/prompts";var K={red:ue.default.red,green:ue.default.green,yellow:ue.default.yellow,blue:ue.default.blue,magenta:ue.default.magenta,cyan:ue.default.cyan,white:ue.default.white,gray:ue.default.gray,bold:ue.default.bold,dim:ue.default.dim,italic:ue.default.italic,underline:ue.default.underline,inverse:ue.default.inverse},at=s=>s.replace(/\x1b\[[0-9;]*m/g,""),pe=s=>je.intro(ue.default.bgCyan(ue.default.black(ue.default.bold(` ${s} `)))),Pe=s=>je.outro(ue.default.cyan(s)),se=(s,e,t="blue")=>{let n=e.split(`
|
|
547
|
+
`),i=at(s),r=Math.max(i.length+4,...n.map(c=>at(c).length))+2,o="\u2500".repeat(r),a=K[t];console.log(a(`\u250C${o}\u2510`)),console.log(a("\u2502 ")+K.bold(s).padEnd(r+(s.length-i.length)-1)+a("\u2502")),console.log(a(`\u251C${o}\u2524`)),n.forEach(c=>{let l=at(c),p=" ".repeat(r-l.length-1);console.log(a("\u2502 ")+c+p+a("\u2502"))}),console.log(a(`\u2514${o}\u2518`))},jn=(s,e)=>{let t=s.map((i,r)=>Math.max(at(i).length,...e.map(o=>at(o[r]||"").length))+2),n=K.cyan("\u2502");console.log(n),console.log(n+" "+s.map((i,r)=>K.bold(K.cyan(i)).padEnd(t[r]+(i.length-at(i).length))).join(K.gray(" "))+" "),e.forEach(i=>{console.log(n+" "+i.map((r,o)=>(r||"").padEnd(t[o]+(r.length-at(r).length))).join(K.gray(" "))+" ")}),console.log(n)},Nr=(s,e="\u2022")=>{s.forEach(t=>{console.log(`${K.cyan("\u2502")} ${K.cyan(e)} ${t}`)})},Bn=(s,e=40)=>{let t=Math.max(...s.map(i=>i.value)),n=Math.max(...s.map(i=>at(i.label).length));console.log(K.cyan("\u2502")),s.forEach(i=>{let r=Math.round(i.value/t*e),o="\u2588".repeat(r)+K.dim("\u2591".repeat(e-r)),a=i.color?K[i.color]:K.cyan,c=i.label.padEnd(n);console.log(`${K.cyan("\u2502")} ${K.bold(c)} ${a(o)} ${K.white(i.value.toString())}`)}),console.log(K.cyan("\u2502"))},ss=(s,e="")=>{s.forEach((t,n)=>{let i=n===s.length-1,r=i?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",o=t.color?K[t.color]:t.children?K.blue:K.white,a=t.info?` ${K.gray(`(${t.info})`)}`:"";if(console.log(`${K.cyan("\u2502")} ${e}${K.gray(r)}${o(t.name)}${a}`),t.children&&t.children.length>0){let c=e+(i?" ":"\u2502 ");ss(t.children,c)}})},Re=()=>je.spinner();async function Gn(s,e,t){if(e.length===0)return;let n=await je.select({message:s,options:e.map(i=>({value:i.value,label:i.label,...i.hint!=null&&{hint:i.hint}})),...t?.limit!=null&&{maxItems:t.limit}});if(!je.isCancel(n))return n}var $l=s=>{console.error("");let e=s instanceof Error?s.message:String(s);console.error(` ${K.red("\u2716")} ${K.bold("Error: ")} ${e}`),s instanceof Error&&"cause"in s&&console.error(` ${K.dim("Cause: "+String(s.cause))}`),console.error(""),process.exit(1)},Y=async s=>{try{await s()}catch(e){$l(e)}},y=K;Ae();Ze();q();async function Q(s){S.debug("Performing graceful shutdown...");try{await $n()}catch(e){S.error({err:e},"Error shutting down worker pool")}try{s&&kn(s)}catch(e){S.error({err:e},"Error closing database")}S.debug("Shutdown complete")}async function Dr(s){let e=Al.resolve(s);try{await Y(async()=>{pe("\u{1F311} Liquid Shadow: Scouting Report");let t=O.getInstance(e),n=Ke(e),i=n.ignore&&n.ignore.length>0,r=t.files.getCount(),o=t.exports.getCount(),a=t.files.getLatestScanTime(),c=t.exports.getKindDistribution(5);se("Intelligence Summary",`${y.bold("\u{1F4E1} Topology")}: ${y.cyan(r.toString())} files mapped
|
|
548
|
+
${y.bold("\u{1F9E9} Symbols")}: ${y.cyan(o.toString())} exports detected
|
|
549
|
+
${y.bold("\u{1F552} Last Sync")}: ${a?y.yellow(new Date(a).toLocaleString()):y.red("Never")}
|
|
550
|
+
${y.bold("\u2699\uFE0F Config")}: ${i?y.green("Custom Intelligence"):y.gray("Standard Sieve")}`,"blue"),c.length>0&&(console.log(""),console.log(` ${y.bold("Symbol Distribution (Top 5)")}`),Bn(c.map(l=>({label:l.kind,value:l.c,color:"cyan"})),30)),console.log(""),console.log(` ${y.dim("Pro-tip: Try")} ${y.bold(y.cyan("liquid-shadow dashboard"))} ${y.dim("for the full tactical view.")}`),console.log(""),Pe("Scouting complete.")})}finally{await Q(e)}}V();Ze();import jr from"path";var rs=class{startTime=Date.now();indexRuns=0;indexCacheHits=0;lastIndexDurationMs=null;lastIndexCompletedAt=null;lastRunPhases=[];queryCount=0;lastQueryLatencyMs=null;recentLatencySumMs=0;recentLatencyCount=0;recentLatencies=[];searchHistoryFailureCount=0;recordIndexStart(){this.indexRuns+=1}recordIndexCacheHit(){this.indexCacheHits+=1}recordIndexEnd(e){this.lastIndexDurationMs=e,this.lastIndexCompletedAt=Date.now()}recordIndexPhase(e,t){this.lastRunPhases.push({phase:e,durationMs:t})}clearIndexPhases(){this.lastRunPhases=[]}recordQueryStart(){let e=performance.now();return()=>{this.queryCount+=1;let t=performance.now()-e;if(this.lastQueryLatencyMs=t,this.recentLatencies.push(t),this.recentLatencies.length>100){let n=this.recentLatencies.shift();this.recentLatencySumMs=this.recentLatencySumMs-n+t}else this.recentLatencySumMs+=t,this.recentLatencyCount=this.recentLatencies.length}}recordSearchHistoryFailure(){this.searchHistoryFailureCount+=1}getSnapshot(){let e=this.recentLatencies.length,t=e>0?this.recentLatencies.reduce((n,i)=>n+i,0)/e:null;return{index:{runs:this.indexRuns,cacheHits:this.indexCacheHits,lastDurationMs:this.lastIndexDurationMs,lastCompletedAt:this.lastIndexCompletedAt,lastRunPhases:[...this.lastRunPhases]},query:{count:this.queryCount,lastLatencyMs:this.lastQueryLatencyMs,recentLatencySumMs:this.recentLatencySumMs,recentLatencyCount:e,avgLatencyMs:t,searchHistoryFailures:this.searchHistoryFailureCount},uptimeMs:Date.now()-this.startTime}}reset(){this.indexRuns=0,this.indexCacheHits=0,this.lastIndexDurationMs=null,this.lastIndexCompletedAt=null,this.lastRunPhases=[],this.queryCount=0,this.lastQueryLatencyMs=null,this.recentLatencySumMs=0,this.recentLatencyCount=0,this.recentLatencies=[],this.searchHistoryFailureCount=0}},ct=new rs;function Or(){ct.recordIndexStart()}function os(){ct.recordIndexCacheHit()}function Fr(s){ct.recordIndexEnd(s)}function an(s,e){ct.recordIndexPhase(s,e)}function Wr(){ct.clearIndexPhases()}function qn(){return ct.recordQueryStart()}function Ft(){ct.recordSearchHistoryFailure()}function Vn(){return ct.getSnapshot()}q();St();import ee from"fs";import Pl from"os";import Be from"path";var wt=S.child({module:"git-hooks"}),Ml="Generated by liquid-shadow",Nl=1e6,Hr=["post-merge","post-checkout","post-commit"];function Dl(){let s=process.env.LIQUID_SHADOW_CLI_ENTRY;if(s){let t=Be.resolve(s);if(ee.existsSync(t))return t}let e=_e("dist/entry/cli/index.js");return ee.existsSync(e)?e:null}function as(s){return s.includes("liquid-shadow")||s.includes("mcp-liquid-shadow")||s.includes(Ml)}function Ol(){let s=Be.join(Pl.homedir(),".mcp-liquid-shadow","logs"),e=Be.join(s,"post-checkout.log");try{if(!ee.existsSync(e)||ee.statSync(e).size<=Nl)return null;ee.mkdirSync(s,{recursive:!0});let n=`${e}.1`;return ee.existsSync(n)&&ee.unlinkSync(n),ee.renameSync(e,n),null}catch(t){return`Failed to rotate post-checkout.log: ${t}`}}function Fl(s,e){return{"post-merge":`#!/bin/sh
|
|
482
551
|
# Liquid Shadow: Auto-refresh index after merge/pull
|
|
483
552
|
# Generated by liquid-shadow
|
|
484
553
|
|
|
485
554
|
REPO_PATH="$(git rev-parse --show-toplevel)"
|
|
486
555
|
|
|
487
556
|
# Run liquid-shadow sync in background to avoid blocking git operations
|
|
488
|
-
nohup
|
|
557
|
+
nohup "${s}" "${e}" sync "$REPO_PATH" > /dev/null 2>&1 &
|
|
489
558
|
|
|
490
559
|
exit 0
|
|
491
560
|
`,"post-checkout":`#!/bin/sh
|
|
@@ -494,12 +563,19 @@ exit 0
|
|
|
494
563
|
|
|
495
564
|
# Only run on branch checkouts, not file checkouts
|
|
496
565
|
# $3 is 1 for branch checkout, 0 for file checkout
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
566
|
+
[ "$3" = "1" ] || exit 0
|
|
567
|
+
|
|
568
|
+
# Skip no-op checkouts where HEAD does not change
|
|
569
|
+
[ "$1" = "$2" ] && exit 0
|
|
570
|
+
|
|
571
|
+
REPO_PATH="$(git rev-parse --show-toplevel)"
|
|
572
|
+
LOG_DIR="$HOME/.mcp-liquid-shadow/logs"
|
|
573
|
+
LOG_FILE="$LOG_DIR/post-checkout.log"
|
|
574
|
+
|
|
575
|
+
mkdir -p "$LOG_DIR"
|
|
576
|
+
|
|
577
|
+
# Run incremental index in background (force=false default preserves fast-path)
|
|
578
|
+
nohup "${s}" "${e}" index "$REPO_PATH" --deep >> "$LOG_FILE" 2>&1 &
|
|
503
579
|
|
|
504
580
|
exit 0
|
|
505
581
|
`,"post-commit":`#!/bin/sh
|
|
@@ -509,33 +585,33 @@ exit 0
|
|
|
509
585
|
REPO_PATH="$(git rev-parse --show-toplevel)"
|
|
510
586
|
|
|
511
587
|
# Run liquid-shadow sync in background
|
|
512
|
-
nohup
|
|
588
|
+
nohup "${s}" "${e}" sync "$REPO_PATH" > /dev/null 2>&1 &
|
|
513
589
|
|
|
514
590
|
exit 0
|
|
515
|
-
`}
|
|
516
|
-
${
|
|
517
|
-
${
|
|
518
|
-
${
|
|
519
|
-
${
|
|
520
|
-
${
|
|
521
|
-
${
|
|
522
|
-
${
|
|
523
|
-
${
|
|
524
|
-
${
|
|
525
|
-
${
|
|
526
|
-
${
|
|
527
|
-
${
|
|
528
|
-
${
|
|
529
|
-
${
|
|
530
|
-
${
|
|
531
|
-
${
|
|
532
|
-
${
|
|
533
|
-
${
|
|
534
|
-
${
|
|
535
|
-
${
|
|
536
|
-
${
|
|
537
|
-
`),
|
|
538
|
-
`)[0].trim();return r.length>200?r.substring(0,197)+"...":r}function Io(n,e,r){let i=n.toLowerCase(),t=e.toLowerCase();return i.includes("components/")||i.endsWith(".tsx")?"Component":i.startsWith("use")||t.startsWith("use")?"Hook":i.includes("models/")||t.endsWith("model")?"Model":i.includes("services/")||i.includes("controllers/")||i.includes("handlers/")||i.includes("mcp/")||i.endsWith("service.ts")||i.endsWith("controller.ts")||i.endsWith("handler.ts")||t.endsWith("service")||t.endsWith("controller")||t.endsWith("handler")?"Service":i.includes("repositories/")||i.includes("repos/")||i.endsWith("repository.ts")||i.endsWith("repo.ts")||t.endsWith("repository")||t.endsWith("repo")?"Repository":r==="TsInterfaceDeclaration"||r==="TsTypeAliasDeclaration"?"Type Definition":"Other"}function ii(n){let e=[];return/\b(fetch|axios|superagent|got)\s*\(|import\s+.*\b(http|https|node-fetch)\b/i.test(n)&&e.push("Network"),(/\b(knex|prisma|typeorm|mongoose|sequelize|pg|mysql|sqlite3)\b/i.test(n)||/\b(SELECT\s+.*FROM|INSERT\s+INTO|UPDATE\s+.*SET|DELETE\s+FROM)\b/i.test(n)||/\.query\s*\(|\.execute\s*\(/i.test(n)&&/db|database|client|pool/i.test(n))&&e.push("Database"),(/\bfs\./i.test(n)||/\b(readFileSync|writeFileSync|readFile|writeFile|readdir)\b/.test(n)||/import\s+.*\bfs\b/.test(n))&&e.push("File System"),(/\b(localStorage|sessionStorage|indexedDB)\./.test(n)||/\bdocument\.cookie\b/.test(n))&&e.push("Browser Storage"),e}function nt(n,e){if(!n)return"";let r=n.trimStart();for(;/^\/\*[\s\S]*?\*\//.test(r);)r=r.replace(/^\/\*[\s\S]*?\*\/\s*/,"");for(;/^\/\/[^\n]*\n/.test(r);)r=r.replace(/^\/\/[^\n]*\n\s*/,"");if(r=r.replace(/^(?:import[^\n]*\n)+/,"").replace(/^(?:export\s+\{[^}]*\}\s+from\s+['"][^'"]+['"];?\s*\n?)+/,"").trim(),e==="TsInterfaceDeclaration"||e==="TsTypeAliasDeclaration")return r;let i=0,t=0,o=r.length;for(let a=0;a<r.length;a++){let c=r[a];if(c==="(")i++;else if(c===")")i--;else if(c==="<")t++;else if(c===">")t--;else if(c==="{"){if(i===0&&t===0){o=a;break}}else if(c===";"&&i===0&&t===0){o=a;break}else if(c==="="&&r[a+1]===">"&&i===0&&t===0){o=a+2;break}}let s=r.substring(0,o).trim();return s.length>500?s.slice(0,497)+"...":s}function jh(n){let e=[];for(let r of n)r.type==="ImportDeclaration"&&e.push({module:r.source.value,name:r.specifiers.map(i=>i.type==="ImportDefaultSpecifier"?"default":i.type==="ImportNamespaceSpecifier"?"*":i.local?.value||i.imported?.value||"*").join(", ")}),r.type==="ExportAllDeclaration"&&e.push({module:r.source.value,name:"*"}),r.type==="ExportNamedDeclaration"&&r.source&&e.push({module:r.source.value,name:r.specifiers.map(i=>i.type==="ExportSpecifier"?i.orig.value:"*").join(", ")});return e}function tS(n,e){for(let r of n){if((r.type==="FunctionDeclaration"||r.type==="ClassDeclaration")&&(r.identifier?.value||r.id?.value)===e)return r.span;if(r.type==="VariableDeclaration"){for(let i of r.declarations)if(i.id?.type==="Identifier"&&i.id.value===e)return i.span||r.span}if((r.type==="TsTypeAliasDeclaration"||r.type==="TsInterfaceDeclaration"||r.type==="TsEnumDeclaration")&&(r.id?.value||r.identifier?.value)===e)return r.span;if(r.type==="ExportDeclaration"){let i=r.declaration;if(!i)continue;if((i.type==="FunctionDeclaration"||i.type==="ClassDeclaration")&&(i.identifier?.value||i.id?.value)===e)return i.span||r.span;if(i.type==="VariableDeclaration"){for(let t of i.declarations)if(t.id?.type==="Identifier"&&t.id.value===e)return t.span||i.span||r.span}}}return null}function Fh(n,e,r,i,t,o,s,a,c){let l=c??(d=>Eo(d,r)),u=[];for(let d of n){if(d.type==="ExportDeclaration"){let p=d.declaration,f=p.type,m="";f==="VariableDeclaration"?m=p.declarations.map(S=>S.id.value).join("",""):m=p.id?.value||p.identifier?.value||"anonymous";let h=l(d.span.start-e),v=l(d.span.end-e),b=$t(h,o,i),g=a(d.span),x=[];if(d.type==="ExportDeclaration"&&(f==="ClassDeclaration"||f==="ClassExpression")){let S=p.body||[];for(let E of S)if(E.type==="ClassMethod"||E.type==="ClassProperty"){let w=E.key.value;if(!w)continue;let z=l(E.span.start-e),R=l(E.span.end-e),U=a(E.span),I=$t(z,o,i);x.push({name:w,kind:E.type,signature:nt(U,E.type),line:ge(z,t),endLine:ge(R,t),doc:I,classification:E.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else if(f==="FunctionDeclaration"&&p.body?.type==="BlockStatement")x=Tc(p.body.stmts,e,r,i,t,o,a,l);else if(f==="VariableDeclaration"){for(let S of p.declarations)if(S.init&&(S.init.type==="ArrowFunctionExpression"||S.init.type==="FunctionExpression")&&S.init.body?.type==="BlockStatement"){x=Tc(S.init.body.stmts,e,r,i,t,o,a,l);break}}u.push({name:m,kind:f,signature:nt(g,f),line:ge(h,t),endLine:ge(v,t),doc:b,classification:Io(s,m,f),capabilities:JSON.stringify(ii(g)),members:x})}if(d.type==="ExportNamedDeclaration"){for(let p of d.specifiers)if(p.type==="ExportSpecifier"){let f=p.orig.value,m=p.exported?.value||f,v=tS(n,f)||d.span,b=l(v.start-e),g=l(v.end-e),x=$t(b,o,i);u.push({name:m,kind:"ExportSpecifier",signature:`export { ${f} }`,line:ge(b,t),endLine:ge(g,t),doc:x,classification:"Export mapping",capabilities:"[]"})}}if(d.type==="ExportDefaultDeclaration"){let p=l(d.span.start-e),f=l(d.span.end-e),m=$t(p,o,i),h=a(d.span),v=[];if(d.decl.type==="ClassExpression"||d.decl.type==="ClassDeclaration"){let b=d.decl.body||[];for(let g of b)if(g.type==="ClassMethod"||g.type==="ClassProperty"){let x=g.key.value;if(!x)continue;let S=l(g.span.start-e),E=l(g.span.end-e),w=a(g.span),z=$t(S,o,i);v.push({name:x,kind:g.type,signature:nt(w,g.type),line:ge(S,t),endLine:ge(E,t),doc:z,classification:g.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else(d.decl.type==="FunctionExpression"||d.decl.type==="FunctionDeclaration"||d.decl.type==="ArrowFunctionExpression")&&d.decl.body?.type==="BlockStatement"&&(v=Tc(d.decl.body.stmts,e,r,i,t,o,a,l));u.push({name:"default",kind:"DefaultExport",signature:nt(h,"DefaultExport"),line:ge(p,t),endLine:ge(f,t),doc:m,classification:"Default Export",capabilities:JSON.stringify(ii(h)),members:v})}if(d.type==="ExportAllDeclaration"){let p=l(d.span.start-e),f=l(d.span.end-e),m=d.source.value,h=$t(p,o,i);u.push({name:"*",kind:"ExportAllDeclaration",signature:`export * from "${m}"`,line:ge(p,t),endLine:ge(f,t),doc:h,classification:"Re-export",capabilities:"[]"})}}return u}function Tc(n,e,r,i,t,o,s,a){let c=[];for(let l of n){if(l.type==="VariableDeclaration")for(let u of l.declarations){let d=[],p=m=>{if(m.type==="Identifier")d.push({name:m.value,span:m.span});else if(m.type==="ArrayPattern")for(let h of m.elements)h&&p(h);else if(m.type==="ObjectPattern")for(let h of m.properties)h.type==="AssignmentPatternProperty"?d.push({name:h.key.value,span:h.span}):h.type==="KeyValuePatternProperty"&&p(h.value)};p(u.id);let f=u.init&&(u.init.type==="ArrowFunctionExpression"||u.init.type==="FunctionExpression");for(let m of d){let h=f?u.init.span||u.span||m.span:u.span||m.span,v=f?u.init.type:"VariableDeclaration",b=f?"Internal Function":"Internal Variable",g=a(h.start-e),x=a(h.end-e),S=s(h),E=$t(g,o,i);c.push({name:m.name,kind:v,signature:nt(S,v),line:ge(g,t),endLine:ge(x,t),doc:E,classification:b,capabilities:"[]"})}}if(l.type==="FunctionDeclaration"){let u=l.identifier?.value||l.ident?.value||"anonymous",d=a(l.span.start-e),p=a(l.span.end-e),f=s(l.span),m=$t(d,o,i);c.push({name:u,kind:"FunctionDeclaration",signature:nt(f,"FunctionDeclaration"),line:ge(d,t),endLine:ge(p,t),doc:m,classification:"Internal Function",capabilities:"[]"})}if(l.type==="ReturnStatement"&&l.argument?.type==="ObjectExpression")for(let u of l.argument.properties){let d="",p=u.span||u.key?.span||u.ident?.span;if(u.type==="KeyValueProperty"){let f=u.key;d=f?.value||f?.raw||(f?.type==="Identifier"?f.value:"")}else u.type==="MethodProperty"?d=u.key?.value||u.key?.raw||"":u.type==="ShorthandProperty"?d=u.ident?.value||"":u.type==="Identifier"&&(d=u.value||"");if(d&&p){let f=a(p.start-e),m=a(p.end-e),h=s(p),v=$t(f,o,i);c.push({name:d,kind:"ReturnProperty",signature:nt(h,"ReturnProperty"),line:ge(f,t),endLine:ge(m,t),doc:v,classification:"Return Member",capabilities:"[]"})}}if(l.type==="ExpressionStatement"&&l.expression.type==="CallExpression"){let u=l.expression;if(u.callee.type==="MemberExpression"&&(u.callee.property?.value==="on"||u.callee.property?.value==="once")){let d=u.arguments[0]?.expression?.value,p=u.arguments[1]?.expression;if(d&&p&&(p.type==="ArrowFunctionExpression"||p.type==="FunctionExpression")){let f=a(p.span.start-e),m=a(p.span.end-e),h=s(p.span);c.push({name:`on:${d}`,kind:p.type,signature:nt(h,p.type),line:ge(f,t),endLine:ge(m,t),doc:"",classification:"Event Handler",capabilities:"[]"})}}if(u.callee.type==="Identifier"&&u.callee.value==="addRoute"&&u.arguments.length>=3){let d=u.arguments[2].expression;if(d.type==="StringLiteral"){let p=d.value,f=a(u.span.start-e),m=a(u.span.end-e),h=s(u.span);c.push({name:p,kind:"HTTP Route",signature:nt(h,"HTTP Route"),line:ge(f,t),endLine:ge(m,t),doc:"",classification:"Service Boundary",capabilities:JSON.stringify({path:p})})}}}}return c}function Uh(n,e,r,i,t,o){let s=o??(l=>Eo(l,r)),a=[];function c(l){if(!(!l||typeof l!="object")){if(l.type==="CallExpression"){let u=nS(l);if(u){let d=s(l.span.start-e);a.push({...u,line:ge(d,i),snippet:t(l.span)})}}for(let u of Object.keys(l)){if(u==="span")continue;let d=l[u];Array.isArray(d)?d.forEach(c):typeof d=="object"&&c(d)}}}return n.forEach(c),a}function nS(n){let{callee:e,arguments:r}=n;if(!r||r.length===0)return null;if(e.type==="Identifier"&&e.value,e.type==="Identifier"&&e.value==="addRoute"&&r.length>=3){let i=r[2].expression;if(i.type==="StringLiteral")return{type:"api_route",name:i.value,direction:"consume"}}if(e.type==="MemberExpression"&&e.property?.type==="Identifier"){let i=e.property.value;if(i==="emit"&&r[0].expression.type==="StringLiteral")return{type:"socket_event",name:r[0].expression.value,direction:"produce"};if(i==="on"&&r[0].expression.type==="StringLiteral")return{type:"socket_event",name:r[0].expression.value,direction:"consume"};if(["get","post","put","delete","patch"].includes(i)&&r[0].expression.type==="StringLiteral"){let o=r[0].expression.value,s=e.object.type==="Identifier"?e.object.value:"";if(["axios","http","request","appApi","restApi","adminApi","client"].includes(s))return{type:"api_route",name:o,direction:"produce"};if(o.startsWith("/"))return{type:"api_route",name:o,direction:"consume"}}}return e.type==="Identifier"&&e.value==="fetch"&&r[0].expression.type==="StringLiteral"?{type:"api_route",name:r[0].expression.value,direction:"produce"}:null}function oi(n){let{classification:e,capabilities:r,exports:i,fileName:t}=n,o={Network:"API integration",Database:"data persistence","File System":"file I/O operations","Browser Storage":"client-side storage"},s=r.map(m=>o[m]).filter(Boolean).join(" and "),c={Component:(m,h)=>{let v=h.find(g=>g.kind==="FunctionDeclaration"||g.kind==="ClassDeclaration")?.name,b=v?`React component: ${v}`:"React UI component";return m?`${b} with ${m}`:b},Hook:(m,h)=>{let v=h.find(g=>g.name.startsWith("use"))?.name,b=v?`Custom React hook: ${v}`:"Custom React hook";return m?`${b} for ${m}`:b},Service:(m,h)=>{let b=`Service layer: ${h[0]?.name||"Service"}`;return m?`${b} handling ${m}`:b},Repository:(m,h)=>`Data repository: ${h[0]?.name||"Repository"} for ${m||"data access"}`,"Type Definition":(m,h)=>`Type definitions: ${h.slice(0,3).map(b=>b.name).join("")}${h.length>3?"...":""}`,Model:(m,h)=>`Data model: ${h[0]?.name||"Model"}`,"HTTP Route":(m,h)=>{let v=h.filter(b=>b.classification==="Service Boundary");return v.length>0?`API endpoints: ${v.slice(0,3).map(b=>b.name).join("")}`:"API route handler"},"Micro IR (PHP)":(m,h)=>{let v=h.some(g=>g.classification==="Service Boundary"),b=h.find(g=>g.kind==="ClassDeclaration")?.name;return v?"PHP controller with API routes":b?`PHP class: ${b}`:"PHP module"},"Micro IR (Python)":(m,h)=>{let v=h.some(g=>g.classification==="Service Boundary"),b=h.find(g=>g.kind==="ClassDeclaration")?.name;return v?"Python API handler with routes":b?`Python class: ${b}`:"Python module"},"Micro IR (Go/TS) ":(m,h)=>{let v=h.some(g=>g.kind==="TypeDeclaration"),b=h.filter(g=>g.kind==="FunctionDeclaration");return v&&b.length>0?`Go package: types and ${b.length} function(s)`:v?"Go package: type definitions":b.length>0?`Go package: ${b[0].name} and ${b.length} function(s)`:"Go module"},"Micro IR (Rust/TS) ":(m,h)=>{let v=h.find(x=>x.kind==="TraitDeclaration")?.name,b=h.find(x=>x.kind==="StructDeclaration")?.name,g=h.filter(x=>x.kind==="FunctionDeclaration");return v?m.includes("Rust trait")?`Rust module: trait ${v}`:`Rust module: ${v}`:b?`Rust module: struct ${b}`:g.length>0?`Rust module: ${g.length} function(s)`:"Rust module"}}[e];if(c)return c(s,i);if(i.length===0)return t?`Module: ${t}`:"Module with no exports";let l=i.filter(m=>m.kind==="FunctionDeclaration"),u=i.filter(m=>m.kind==="ClassDeclaration"),d=i.filter(m=>m.kind==="TsInterfaceDeclaration"||m.kind==="TsTypeAliasDeclaration"),p=[];if(u.length>0&&p.push(`Class: ${u[0].name}`),l.length>0){let m=l.slice(0,2).map(h=>h.name).join("");p.push(`Functions: ${m}`)}d.length>0&&p.push(`Types: ${d.length}`);let f=p.length>0?p.join(" | "):`Module with ${i.length} export(s)`;return s?`${f} \u2014 ${s}`:f}function Zh(n){let e=new Set;function r(i){if(!(!i||typeof i!="object")){i.typeAnnotation&&Se(i.typeAnnotation,e),(i.type==="TsTypeReference"||i.type==="TsTypeAnnotation")&&Se(i,e);for(let t in i){if(t==="span"||t==="comments"||t==="interpreter")continue;let o=i[t];o&&typeof o=="object"&&(Array.isArray(o)?o.forEach(r):r(o))}}}return n.forEach(i=>r(i)),Array.from(e)}function Se(n,e){if(n){if(n.type==="TsTypeAnnotation"){Se(n.typeAnnotation,e);return}n.type==="TsTypeReference"&&(n.typeName?.type==="Identifier"&&e.add(n.typeName.value),n.typeName?.type==="TsQualifiedName"&&Hh(n.typeName,e),n.typeParams&&Se(n.typeParams,e)),n.type==="TsArrayType"&&Se(n.elementType,e),n.type==="TsUnionType"&&n.types?.forEach(r=>Se(r,e)),n.type==="TsIntersectionType"&&n.types?.forEach(r=>Se(r,e)),n.type==="TsTupleType"&&n.elemTypes?.forEach(r=>Se(r.ty,e)),(n.type==="TsFunctionType"||n.type==="TsConstructorType")&&(n.params?.forEach(r=>Se(r.typeAnnotation,e)),n.typeAnnotation&&Se(n.typeAnnotation,e)),n.type==="TsTypeParameterDeclaration"&&n.params?.forEach(r=>{r.constraint&&Se(r.constraint,e),r.default&&Se(r.default,e)}),n.type==="TsTypeParameterInstantiation"&&n.params?.forEach(r=>Se(r,e)),n.type==="TsMappedType"&&n.typeAnnotation&&Se(n.typeAnnotation,e),n.type==="TsIndexedAccessType"&&(Se(n.objectType,e),Se(n.indexType,e)),n.type==="TsConditionalType"&&(Se(n.checkType,e),Se(n.extendsType,e),Se(n.trueType,e),Se(n.falseType,e)),n.type==="TsTypeLiteral"&&n.members?.forEach(r=>{r.typeAnnotation&&Se(r.typeAnnotation,e)})}}function Hh(n,e){n.type==="TsQualifiedName"?(n.left&&Hh(n.left,e),n.right?.value&&e.add(n.right.value)):n.type==="Identifier"&&e.add(n.value)}import Kh from"path";import Pc from"path";J();oo();import Bh from"path";import rS from"fs";import{fileURLToPath as iS}from"url";import*as En from"web-tree-sitter";var BP=Bh.dirname(iS(import.meta.url)),Wh=$.child({module:"parser:tree-sitter"}),To=class{parser=null;languages=new Map;async ensureInitialized(){if(this.parser)return;let e=En.Parser||En;await e.init(),this.parser=new e}async getLanguage(e){if(this.languages.has(e))return this.languages.get(e);let r=qn("resources","grammars",`tree-sitter-${this.getLangName(e)}.wasm`);if(!rS.existsSync(r))return Wh.warn({grammarPath:r},"Grammar WASM not found"),null;try{let i=await En.Language.load(r);return this.languages.set(e,i),i}catch(i){return Wh.error({err:i,ext:e},"Failed to load language grammar"),null}}getLangName(e){switch(e.toLowerCase()){case".php":return"php";case".py":return"python";case".go":return"go";case".rs":return"rust";default:return""}}getQueries(e){switch(e.toLowerCase()){case".php":return`
|
|
591
|
+
`}}function zr(s){let{repoPath:e,enableAutoRefresh:t=!0,enableSymbolHealing:n=!0}=s,i=Be.join(e,".git","hooks"),r=[],o=[],a=[];if(!ee.existsSync(Be.join(e,".git")))return a.push("Not a git repository"),{installed:r,skipped:o,errors:a};ee.existsSync(i)||ee.mkdirSync(i,{recursive:!0});let c=Dl();if(!c)return a.push(`Unable to resolve CLI entry at install time. Expected ${_e("dist/entry/cli/index.js")} to exist.`),{installed:r,skipped:o,errors:a};let l=Fl(process.execPath,c),p=new Set;if(t&&(p.add("post-merge"),p.add("post-checkout")),n&&p.add("post-commit"),p.has("post-checkout")){let u=Ol();u&&(a.push(u),wt.warn({rotationError:u},"Post-checkout log rotation failed"))}for(let u of p){let d=Be.join(i,u),h=l[u];if(!h){a.push(`No template found for hook: ${u}`);continue}try{if(ee.existsSync(d)){let m=ee.readFileSync(d,"utf-8"),f=as(m);if(f&&m===h){ee.chmodSync(d,493),o.push(u),wt.info({hookName:u},"Hook already installed, skipping");continue}if(!f){let _=`${d}.backup-${Date.now()}`;ee.copyFileSync(d,_),wt.info({hookName:u,backupPath:_},"Backed up existing hook")}}ee.writeFileSync(d,h,{mode:493}),ee.chmodSync(d,493),r.push(u),wt.info({hookName:u},"Installed git hook")}catch(m){a.push(`Failed to install ${u}: ${m}`),wt.error({hookName:u,err:m},"Failed to install hook")}}return{installed:r,skipped:o,errors:a}}function Ur(s){let e=Be.join(s,".git","hooks"),t=[],n=[];if(!ee.existsSync(e))return{removed:t,errors:n};for(let i of Hr){let r=Be.join(e,i);try{if(ee.existsSync(r)){let o=ee.readFileSync(r,"utf-8");as(o)&&(ee.unlinkSync(r),t.push(i),wt.info({hookName:i},"Removed git hook"))}}catch(o){n.push(`Failed to remove ${i}: ${o}`),wt.error({hookName:i,err:o},"Failed to remove hook")}}return{removed:t,errors:n}}function Wl(s,e){let t=Be.join(s,".git","hooks"),n=Be.join(t,e);if(!ee.existsSync(t)||!ee.existsSync(n))return"missing";try{let i=ee.readFileSync(n,"utf-8");return as(i)?(ee.statSync(n).mode&73)!==0?"installed":"disabled":"foreign"}catch{return"foreign"}}function Wt(s){let e=[],t=[],n=[],i=[],r={};for(let a of Hr){let c=Wl(s,a);r[a]=c,c==="installed"&&e.push(a),c==="missing"&&t.push(a),c==="foreign"&&n.push(a),c==="disabled"&&i.push(a)}let o=[...t,...n,...i];return{installed:e,notInstalled:o,missing:t,foreign:n,disabled:i,statuses:r}}async function cs(s){let e=jr.resolve(s);try{await Y(async()=>{pe("Liquid Shadow Intelligence Dashboard");let t=O.getInstance(e),n=Vn(),i=Wt(e),r=t.files.getCount(),o=t.exports.getCount(),a=t.files.getLatestScanTime(),c=t.exports.getKindDistribution(5);if(se("Operational Core",`${y.bold("State")}: ${Xe(e)?y.green("IDENTIFIED (Stable)"):y.red("UNKNOWN (Needs Index)")}
|
|
592
|
+
${y.bold("Repository")}: ${y.cyan(jr.basename(e))}
|
|
593
|
+
${y.bold("Infrastructure")}: ${i.installed.length>0?y.green("Git-Hooked"):y.yellow("Standalone")}
|
|
594
|
+
${y.bold("Last Sync")}: ${a?y.yellow(new Date(a).toLocaleString()):y.red("Never")}`,"blue"),console.log(""),se("Intelligence Density",`${y.bold("Files Target")}: ${y.cyan(r.toString())}
|
|
595
|
+
${y.bold("Symbols Mapped")}: ${y.cyan(o.toString())}
|
|
596
|
+
${y.bold("Graph Edges")}: ${y.cyan(t.imports.getCount().toString())}
|
|
597
|
+
${y.bold("Hotspots")}: ${y.yellow(c.length.toString())}`,"cyan"),n.query.count>0||n.index.runs>0){console.log("");let l=n.index.runs>0?(n.index.cacheHits/n.index.runs*100).toFixed(1):"0.0";se("Reasoning Efficiency",`${y.bold("Query Count")}: ${y.cyan(n.query.count.toString())}
|
|
598
|
+
${y.bold("Avg Latency")}: ${y.yellow(`${n.query.avgLatencyMs?.toFixed(2)||0}ms`)}
|
|
599
|
+
${y.bold("Cache Hit Rate")}: ${y.green(`${l}%`)}`,"green")}c.length>0&&(console.log(""),console.log(` ${y.bold("Intelligence Landscape")}`),Bn(c.map(l=>({label:l.kind,value:l.c,color:"cyan"})),35)),console.log(""),Pe("Liquid Shadow is observing.")})}finally{await Q(e)}}V();Ze();import Hl from"path";async function Br(s){let e=Hl.resolve(s);try{await Y(async()=>{let t=O.getInstance(e),n=Wt(e),i=Vn(),r=Math.floor(i.uptimeMs/1e3),o=Math.floor(r/60),a=Math.floor(o/60),c=a>0?`${a}h ${o%60}m`:o>0?`${o}m ${r%60}s`:`${r}s`,l=i.index.lastCompletedAt?new Date(i.index.lastCompletedAt).toLocaleString():"Never",p=i.index.lastDurationMs?`${(i.index.lastDurationMs/1e3).toFixed(2)}s`:"N/A",u=i.query.avgLatencyMs?`${i.query.avgLatencyMs.toFixed(2)}ms`:"N/A",d=i.query.lastLatencyMs?`${i.query.lastLatencyMs.toFixed(2)}ms`:"N/A",h=i.index.runs>0?(i.index.cacheHits/i.index.runs*100).toFixed(1):"0.0";se("Performance Metrics",`${y.bold("Uptime")}: ${y.cyan(c)}
|
|
600
|
+
${y.bold("Indexed")}: ${Xe(e)?y.green("Yes"):y.red("No")}
|
|
601
|
+
${y.bold("Files")}: ${y.cyan(t.files.getCount().toString())}
|
|
602
|
+
${y.bold("Exports")}: ${y.cyan(t.exports.getCount().toString())}
|
|
603
|
+
${y.bold("Imports")}: ${y.cyan(t.imports.getCount().toString())}
|
|
604
|
+
${y.bold("Last Indexed Commit")}: ${nn(e)?y.yellow(nn(e).substring(0,7)):y.red("None")}
|
|
605
|
+
${y.bold("Git Hooks")}: ${n.installed.length>0?y.green("Installed"):y.yellow("Not Installed")}`,"blue"),console.log(""),se("Index Metrics",`${y.bold("Total Runs")}: ${y.cyan(i.index.runs.toString())}
|
|
606
|
+
${y.bold("Cache Hits")}: ${y.cyan(i.index.cacheHits.toString())}
|
|
607
|
+
${y.bold("Cache Hit Rate")}: ${y.cyan(`${h}%`)}
|
|
608
|
+
${y.bold("Last Duration")}: ${y.yellow(p)}
|
|
609
|
+
${y.bold("Last Completed")}: ${y.yellow(l)}`,"cyan"),i.index.lastRunPhases.length>0&&(console.log(""),console.log(` ${y.bold("Last Index Run Phases:")}`),i.index.lastRunPhases.forEach(m=>{let f=`${(m.durationMs/1e3).toFixed(2)}s`;console.log(` ${y.gray(m.phase.padEnd(20))} ${y.cyan(f)}`)})),console.log(""),se("Query Metrics",`${y.bold("Total Queries")}: ${y.cyan(i.query.count.toString())}
|
|
610
|
+
${y.bold("Avg Latency")}: ${y.yellow(u)}
|
|
611
|
+
${y.bold("Last Latency")}: ${y.yellow(d)}
|
|
612
|
+
${y.bold("Search History Failures")}: ${i.query.searchHistoryFailures>0?y.red(i.query.searchHistoryFailures.toString()):y.green("0")}`,"green")})}finally{await Q(e)}}import Up from"path";q();import ra from"path";import zp from"ignore";import oa from"fs";import Jn from"path";var zl=50;function Yn(s,e,t,n){let i={name:Jn.basename(e)||e,type:"directory",path:e,children:[]};return s.forEach(r=>{let a=Jn.relative(e,r.path).split(Jn.sep),c=i;for(let l=0;l<a.length;l++){let p=a[l];if(n!==void 0&&l>=n)return;let u=l===a.length-1;if(n===1&&l===0&&u)return;let d=n!==void 0&&l===n-1&&!u,h=Jn.join(e,...a.slice(0,l+1)),m=c.children?.find(f=>f.name===p);if(!m){if(c.children&&c.children.length>=zl){c.children.find(g=>g.type==="truncated")||c.children.push({name:"... (truncated) ",type:"truncated",path:"",children:void 0});return}m={name:p,type:u?"file":"directory",path:h,children:u||d?void 0:[],summary:u?{classification:r.classification,summaryText:r.summary,exports:r.exports,imports:r.imports,chunks:r.chunks}:void 0},m.summary&&(t==="structure"||t==="signatures")&&(delete m.summary.chunks,delete m.summary.imports),c.children?.push(m)}c=m}}),i}import Ul from"fast-glob";import qr from"fs";import jl from"ignore";import Vr from"path";var Kn=["**/node_modules/**","**/.git/**","**/dist/**","**/build/**","**/vendor/**","**/.next/**","**/.cache/**","**/coverage/**","**/*.min.js"],Gr=["**/*.{ts,tsx,yaml,yml,php,py,go}","**/*.prisma","**/*.{graphql,gql}","**/Dockerfile*","**/.env*","**/package.json","**/lerna.json","**/turbo.json","**/pnpm-workspace.yaml"],ke={MAX_DEPTH:10,MIN_DEPTH:1,MAX_LIMIT:500,MIN_LIMIT:1,MAX_QUERY_LENGTH:500,DEFAULT_DEPTH:3,DEFAULT_LIMIT:10},ge={FILTERED_QUERY_LIMIT_MULTIPLIER:3,SCORE_BASE:1e3,EXACT_MATCH_BONUS:500,RECENT_FILE_BOOST:80,OLDER_FILE_BOOST:30,RECENT_FILE_THRESHOLD_DAYS:7,OLDER_FILE_THRESHOLD_DAYS:30,FUZZY_MATCH_LIMIT:30,ENABLE_LEXICAL_SCORING:process.env.ENABLE_LEXICAL_SCORING!=="false",LEXICAL_WEIGHT:parseFloat(process.env.LEXICAL_WEIGHT??String(.4)),GRAVITY_STRUCTURAL_WEIGHT:.5},ls={SECONDS_PER_DAY:86400,SECONDS_PER_YEAR:31536e3},Qn={DEFAULT_CONCURRENCY:parseInt(process.env.INDEX_CONCURRENCY??String(5),10)};async function Jr(s,e=[]){let t=jl(),n=Vr.join(s,".gitignore");return qr.existsSync(n)&&t.add(qr.readFileSync(n,"utf8")),e.length>0&&t.add(e),(await Ul(Gr,{cwd:s,absolute:!0,ignore:Kn,stats:!0})).filter(o=>{let a=Vr.relative(s,o.path);return!t.ignores(a)}).map(o=>({path:o.path,mtime:o.stats.mtimeMs}))}import po from"fs";function Yr(s){let e=s.split(`
|
|
613
|
+
`),t=[],n=0;for(let i of e)t.push(n),n+=i.length+1;return t}function te(s,e){for(let t=0;t<e.length;t++)if(e[t+1]>s||t===e.length-1)return t+1;return 1}function Xn(s,e){return e.slice(0,s).toString("utf8").length}function Kr(s){if(s.toString("utf8").length===s.length)return n=>n;let t=new Map;return n=>{let i=t.get(n);return i===void 0&&(i=s.slice(0,n).toString("utf8").length,t.set(n,i)),i}}function Qr(s,e,t){let n=s.start-e,i=s.end-e;return n<0||i>t.length?"":t.slice(n,i).toString("utf8")}function Xr(s){let e=[],t=/\/\*\*[\s\S]*?\*\//g,n;for(;(n=t.exec(s))!==null;)e.push({start:n.index,end:n.index+n[0].length,text:n[0]});return e}function Ge(s,e,t){for(let n of e){if(n.start===s)return n.text;if(n.start>s&&n.start<s+50){let i=t.substring(s,n.start);if(/^\s*$/.test(i))return n.text}if(n.end<=s&&n.end>s-50){let i=t.substring(n.end,s);if(/^\s*$/.test(i))return n.text}}return""}function Zr(s){if(!s)return"";let t=s.replace(/\/\*\*|\*\/|\*/g,"").trim().split(`
|
|
614
|
+
`)[0].trim();return t.length>200?t.substring(0,197)+"...":t}function Zn(s,e,t){let n=s.toLowerCase(),i=e.toLowerCase();return n.includes("components/")||n.endsWith(".tsx")?"Component":n.startsWith("use")||i.startsWith("use")?"Hook":n.includes("models/")||i.endsWith("model")?"Model":n.includes("services/")||n.includes("controllers/")||n.includes("handlers/")||n.includes("mcp/")||n.endsWith("service.ts")||n.endsWith("controller.ts")||n.endsWith("handler.ts")||i.endsWith("service")||i.endsWith("controller")||i.endsWith("handler")?"Service":n.includes("repositories/")||n.includes("repos/")||n.endsWith("repository.ts")||n.endsWith("repo.ts")||i.endsWith("repository")||i.endsWith("repo")?"Repository":t==="TsInterfaceDeclaration"||t==="TsTypeAliasDeclaration"?"Type Definition":"Other"}function cn(s){let e=[];return/\b(fetch|axios|superagent|got)\s*\(|import\s+.*\b(http|https|node-fetch)\b/i.test(s)&&e.push("Network"),(/\b(knex|prisma|typeorm|mongoose|sequelize|pg|mysql|sqlite3)\b/i.test(s)||/\b(SELECT\s+.*FROM|INSERT\s+INTO|UPDATE\s+.*SET|DELETE\s+FROM)\b/i.test(s)||/\.query\s*\(|\.execute\s*\(/i.test(s)&&/db|database|client|pool/i.test(s))&&e.push("Database"),(/\bfs\./i.test(s)||/\b(readFileSync|writeFileSync|readFile|writeFile|readdir)\b/.test(s)||/import\s+.*\bfs\b/.test(s))&&e.push("File System"),(/\b(localStorage|sessionStorage|indexedDB)\./.test(s)||/\bdocument\.cookie\b/.test(s))&&e.push("Browser Storage"),e}function Ce(s,e){if(!s)return"";let t=s.trimStart();for(;/^\/\*[\s\S]*?\*\//.test(t);)t=t.replace(/^\/\*[\s\S]*?\*\/\s*/,"");for(;/^\/\/[^\n]*\n/.test(t);)t=t.replace(/^\/\/[^\n]*\n\s*/,"");if(t=t.replace(/^(?:import[^\n]*\n)+/,"").replace(/^(?:export\s+\{[^}]*\}\s+from\s+['"][^'"]+['"];?\s*\n?)+/,"").trim(),e==="TsInterfaceDeclaration"||e==="TsTypeAliasDeclaration")return t;let n=0,i=0,r=t.length;for(let a=0;a<t.length;a++){let c=t[a];if(c==="(")n++;else if(c===")")n--;else if(c==="<")i++;else if(c===">")i--;else if(c==="{"){if(n===0&&i===0){r=a;break}}else if(c===";"&&n===0&&i===0){r=a;break}else if(c==="="&&t[a+1]===">"&&n===0&&i===0){r=a+2;break}}let o=t.substring(0,r).trim();return o.length>500?o.slice(0,497)+"...":o}function eo(s){let e=[];for(let t of s)t.type==="ImportDeclaration"&&e.push({module:t.source.value,name:t.specifiers.map(n=>n.type==="ImportDefaultSpecifier"?"default":n.type==="ImportNamespaceSpecifier"?"*":n.local?.value||n.imported?.value||"*").join(", ")}),t.type==="ExportAllDeclaration"&&e.push({module:t.source.value,name:"*"}),t.type==="ExportNamedDeclaration"&&t.source&&e.push({module:t.source.value,name:t.specifiers.map(n=>n.type==="ExportSpecifier"?n.orig.value:"*").join(", ")});return e}function Bl(s,e){for(let t of s){if((t.type==="FunctionDeclaration"||t.type==="ClassDeclaration")&&(t.identifier?.value||t.id?.value)===e)return t.span;if(t.type==="VariableDeclaration"){for(let n of t.declarations)if(n.id?.type==="Identifier"&&n.id.value===e)return n.span||t.span}if((t.type==="TsTypeAliasDeclaration"||t.type==="TsInterfaceDeclaration"||t.type==="TsEnumDeclaration")&&(t.id?.value||t.identifier?.value)===e)return t.span;if(t.type==="ExportDeclaration"){let n=t.declaration;if(!n)continue;if((n.type==="FunctionDeclaration"||n.type==="ClassDeclaration")&&(n.identifier?.value||n.id?.value)===e)return n.span||t.span;if(n.type==="VariableDeclaration"){for(let i of n.declarations)if(i.id?.type==="Identifier"&&i.id.value===e)return i.span||n.span||t.span}}}return null}function to(s,e,t,n,i,r,o,a,c){let l=c??(u=>Xn(u,t)),p=[];for(let u of s){if(u.type==="ExportDeclaration"){let d=u.declaration,h=d.type,m="";h==="VariableDeclaration"?m=d.declarations.map(x=>x.id.value).join("",""):m=d.id?.value||d.identifier?.value||"anonymous";let f=l(u.span.start-e),_=l(u.span.end-e),g=Ge(f,r,n),b=a(u.span),w=[];if(u.type==="ExportDeclaration"&&(h==="ClassDeclaration"||h==="ClassExpression")){let x=d.body||[];for(let R of x)if(R.type==="ClassMethod"||R.type==="ClassProperty"){let k=R.key.value;if(!k)continue;let D=l(R.span.start-e),U=l(R.span.end-e),P=a(R.span),E=Ge(D,r,n);w.push({name:k,kind:R.type,signature:Ce(P,R.type),line:te(D,i),endLine:te(U,i),doc:E,classification:R.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else if(h==="FunctionDeclaration"&&d.body?.type==="BlockStatement")w=ps(d.body.stmts,e,t,n,i,r,a,l);else if(h==="VariableDeclaration"){for(let x of d.declarations)if(x.init&&(x.init.type==="ArrowFunctionExpression"||x.init.type==="FunctionExpression")&&x.init.body?.type==="BlockStatement"){w=ps(x.init.body.stmts,e,t,n,i,r,a,l);break}}p.push({name:m,kind:h,signature:Ce(b,h),line:te(f,i),endLine:te(_,i),doc:g,classification:Zn(o,m,h),capabilities:JSON.stringify(cn(b)),members:w})}if(u.type==="ExportNamedDeclaration"){for(let d of u.specifiers)if(d.type==="ExportSpecifier"){let h=d.orig.value,m=d.exported?.value||h,_=Bl(s,h)||u.span,g=l(_.start-e),b=l(_.end-e),w=Ge(g,r,n);p.push({name:m,kind:"ExportSpecifier",signature:`export { ${h} }`,line:te(g,i),endLine:te(b,i),doc:w,classification:"Export mapping",capabilities:"[]"})}}if(u.type==="ExportDefaultDeclaration"){let d=l(u.span.start-e),h=l(u.span.end-e),m=Ge(d,r,n),f=a(u.span),_=[];if(u.decl.type==="ClassExpression"||u.decl.type==="ClassDeclaration"){let g=u.decl.body||[];for(let b of g)if(b.type==="ClassMethod"||b.type==="ClassProperty"){let w=b.key.value;if(!w)continue;let x=l(b.span.start-e),R=l(b.span.end-e),k=a(b.span),D=Ge(x,r,n);_.push({name:w,kind:b.type,signature:Ce(k,b.type),line:te(x,i),endLine:te(R,i),doc:D,classification:b.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else(u.decl.type==="FunctionExpression"||u.decl.type==="FunctionDeclaration"||u.decl.type==="ArrowFunctionExpression")&&u.decl.body?.type==="BlockStatement"&&(_=ps(u.decl.body.stmts,e,t,n,i,r,a,l));p.push({name:"default",kind:"DefaultExport",signature:Ce(f,"DefaultExport"),line:te(d,i),endLine:te(h,i),doc:m,classification:"Default Export",capabilities:JSON.stringify(cn(f)),members:_})}if(u.type==="ExportAllDeclaration"){let d=l(u.span.start-e),h=l(u.span.end-e),m=u.source.value,f=Ge(d,r,n);p.push({name:"*",kind:"ExportAllDeclaration",signature:`export * from "${m}"`,line:te(d,i),endLine:te(h,i),doc:f,classification:"Re-export",capabilities:"[]"})}}return p}function ps(s,e,t,n,i,r,o,a){let c=[];for(let l of s){if(l.type==="VariableDeclaration")for(let p of l.declarations){let u=[],d=m=>{if(m.type==="Identifier")u.push({name:m.value,span:m.span});else if(m.type==="ArrayPattern")for(let f of m.elements)f&&d(f);else if(m.type==="ObjectPattern")for(let f of m.properties)f.type==="AssignmentPatternProperty"?u.push({name:f.key.value,span:f.span}):f.type==="KeyValuePatternProperty"&&d(f.value)};d(p.id);let h=p.init&&(p.init.type==="ArrowFunctionExpression"||p.init.type==="FunctionExpression");for(let m of u){let f=h?p.init.span||p.span||m.span:p.span||m.span,_=h?p.init.type:"VariableDeclaration",g=h?"Internal Function":"Internal Variable",b=a(f.start-e),w=a(f.end-e),x=o(f),R=Ge(b,r,n);c.push({name:m.name,kind:_,signature:Ce(x,_),line:te(b,i),endLine:te(w,i),doc:R,classification:g,capabilities:"[]"})}}if(l.type==="FunctionDeclaration"){let p=l.identifier?.value||l.ident?.value||"anonymous",u=a(l.span.start-e),d=a(l.span.end-e),h=o(l.span),m=Ge(u,r,n);c.push({name:p,kind:"FunctionDeclaration",signature:Ce(h,"FunctionDeclaration"),line:te(u,i),endLine:te(d,i),doc:m,classification:"Internal Function",capabilities:"[]"})}if(l.type==="ReturnStatement"&&l.argument?.type==="ObjectExpression")for(let p of l.argument.properties){let u="",d=p.span||p.key?.span||p.ident?.span;if(p.type==="KeyValueProperty"){let h=p.key;u=h?.value||h?.raw||(h?.type==="Identifier"?h.value:"")}else p.type==="MethodProperty"?u=p.key?.value||p.key?.raw||"":p.type==="ShorthandProperty"?u=p.ident?.value||"":p.type==="Identifier"&&(u=p.value||"");if(u&&d){let h=a(d.start-e),m=a(d.end-e),f=o(d),_=Ge(h,r,n);c.push({name:u,kind:"ReturnProperty",signature:Ce(f,"ReturnProperty"),line:te(h,i),endLine:te(m,i),doc:_,classification:"Return Member",capabilities:"[]"})}}if(l.type==="ExpressionStatement"&&l.expression.type==="CallExpression"){let p=l.expression;if(p.callee.type==="MemberExpression"&&(p.callee.property?.value==="on"||p.callee.property?.value==="once")){let u=p.arguments[0]?.expression?.value,d=p.arguments[1]?.expression;if(u&&d&&(d.type==="ArrowFunctionExpression"||d.type==="FunctionExpression")){let h=a(d.span.start-e),m=a(d.span.end-e),f=o(d.span);c.push({name:`on:${u}`,kind:d.type,signature:Ce(f,d.type),line:te(h,i),endLine:te(m,i),doc:"",classification:"Event Handler",capabilities:"[]"})}}if(p.callee.type==="Identifier"&&p.callee.value==="addRoute"&&p.arguments.length>=3){let u=p.arguments[2].expression;if(u.type==="StringLiteral"){let d=u.value,h=a(p.span.start-e),m=a(p.span.end-e),f=o(p.span);c.push({name:d,kind:"HTTP Route",signature:Ce(f,"HTTP Route"),line:te(h,i),endLine:te(m,i),doc:"",classification:"Service Boundary",capabilities:JSON.stringify({path:d})})}}}}return c}function no(s,e,t,n,i,r){let o=r??(l=>Xn(l,t)),a=[];function c(l){if(!(!l||typeof l!="object")){if(l.type==="CallExpression"){let p=Gl(l);if(p){let u=o(l.span.start-e);a.push({...p,line:te(u,n),snippet:i(l.span)})}}for(let p of Object.keys(l)){if(p==="span")continue;let u=l[p];Array.isArray(u)?u.forEach(c):typeof u=="object"&&c(u)}}}return s.forEach(c),a}function Gl(s){let{callee:e,arguments:t}=s;if(!t||t.length===0)return null;if(e.type==="Identifier"&&e.value,e.type==="Identifier"&&e.value==="addRoute"&&t.length>=3){let n=t[2].expression;if(n.type==="StringLiteral")return{type:"api_route",name:n.value,direction:"consume"}}if(e.type==="MemberExpression"&&e.property?.type==="Identifier"){let n=e.property.value;if(n==="emit"&&t[0].expression.type==="StringLiteral")return{type:"socket_event",name:t[0].expression.value,direction:"produce"};if(n==="on"&&t[0].expression.type==="StringLiteral")return{type:"socket_event",name:t[0].expression.value,direction:"consume"};if(["get","post","put","delete","patch"].includes(n)&&t[0].expression.type==="StringLiteral"){let r=t[0].expression.value,o=e.object.type==="Identifier"?e.object.value:"";if(["axios","http","request","appApi","restApi","adminApi","client"].includes(o))return{type:"api_route",name:r,direction:"produce"};if(r.startsWith("/"))return{type:"api_route",name:r,direction:"consume"}}}return e.type==="Identifier"&&e.value==="fetch"&&t[0].expression.type==="StringLiteral"?{type:"api_route",name:t[0].expression.value,direction:"produce"}:null}function ln(s){let{classification:e,capabilities:t,exports:n,fileName:i}=s,r={Network:"API integration",Database:"data persistence","File System":"file I/O operations","Browser Storage":"client-side storage"},o=t.map(m=>r[m]).filter(Boolean).join(" and "),c={Component:(m,f)=>{let _=f.find(b=>b.kind==="FunctionDeclaration"||b.kind==="ClassDeclaration")?.name,g=_?`React component: ${_}`:"React UI component";return m?`${g} with ${m}`:g},Hook:(m,f)=>{let _=f.find(b=>b.name.startsWith("use"))?.name,g=_?`Custom React hook: ${_}`:"Custom React hook";return m?`${g} for ${m}`:g},Service:(m,f)=>{let g=`Service layer: ${f[0]?.name||"Service"}`;return m?`${g} handling ${m}`:g},Repository:(m,f)=>`Data repository: ${f[0]?.name||"Repository"} for ${m||"data access"}`,"Type Definition":(m,f)=>`Type definitions: ${f.slice(0,3).map(g=>g.name).join("")}${f.length>3?"...":""}`,Model:(m,f)=>`Data model: ${f[0]?.name||"Model"}`,"HTTP Route":(m,f)=>{let _=f.filter(g=>g.classification==="Service Boundary");return _.length>0?`API endpoints: ${_.slice(0,3).map(g=>g.name).join("")}`:"API route handler"},"Micro IR (PHP)":(m,f)=>{let _=f.some(b=>b.classification==="Service Boundary"),g=f.find(b=>b.kind==="ClassDeclaration")?.name;return _?"PHP controller with API routes":g?`PHP class: ${g}`:"PHP module"},"Micro IR (Python)":(m,f)=>{let _=f.some(b=>b.classification==="Service Boundary"),g=f.find(b=>b.kind==="ClassDeclaration")?.name;return _?"Python API handler with routes":g?`Python class: ${g}`:"Python module"},"Micro IR (Go/TS) ":(m,f)=>{let _=f.some(b=>b.kind==="TypeDeclaration"),g=f.filter(b=>b.kind==="FunctionDeclaration");return _&&g.length>0?`Go package: types and ${g.length} function(s)`:_?"Go package: type definitions":g.length>0?`Go package: ${g[0].name} and ${g.length} function(s)`:"Go module"},"Micro IR (Rust/TS) ":(m,f)=>{let _=f.find(w=>w.kind==="TraitDeclaration")?.name,g=f.find(w=>w.kind==="StructDeclaration")?.name,b=f.filter(w=>w.kind==="FunctionDeclaration");return _?m.includes("Rust trait")?`Rust module: trait ${_}`:`Rust module: ${_}`:g?`Rust module: struct ${g}`:b.length>0?`Rust module: ${b.length} function(s)`:"Rust module"}}[e];if(c)return c(o,n);if(n.length===0)return i?`Module: ${i}`:"Module with no exports";let l=n.filter(m=>m.kind==="FunctionDeclaration"),p=n.filter(m=>m.kind==="ClassDeclaration"),u=n.filter(m=>m.kind==="TsInterfaceDeclaration"||m.kind==="TsTypeAliasDeclaration"),d=[];if(p.length>0&&d.push(`Class: ${p[0].name}`),l.length>0){let m=l.slice(0,2).map(f=>f.name).join("");d.push(`Functions: ${m}`)}u.length>0&&d.push(`Types: ${u.length}`);let h=d.length>0?d.join(" | "):`Module with ${n.length} export(s)`;return o?`${h} \u2014 ${o}`:h}function io(s){let e=new Set;function t(n){if(!(!n||typeof n!="object")){n.typeAnnotation&&oe(n.typeAnnotation,e),(n.type==="TsTypeReference"||n.type==="TsTypeAnnotation")&&oe(n,e);for(let i in n){if(i==="span"||i==="comments"||i==="interpreter")continue;let r=n[i];r&&typeof r=="object"&&(Array.isArray(r)?r.forEach(t):t(r))}}}return s.forEach(n=>t(n)),Array.from(e)}function oe(s,e){if(s){if(s.type==="TsTypeAnnotation"){oe(s.typeAnnotation,e);return}s.type==="TsTypeReference"&&(s.typeName?.type==="Identifier"&&e.add(s.typeName.value),s.typeName?.type==="TsQualifiedName"&&so(s.typeName,e),s.typeParams&&oe(s.typeParams,e)),s.type==="TsArrayType"&&oe(s.elementType,e),s.type==="TsUnionType"&&s.types?.forEach(t=>oe(t,e)),s.type==="TsIntersectionType"&&s.types?.forEach(t=>oe(t,e)),s.type==="TsTupleType"&&s.elemTypes?.forEach(t=>oe(t.ty,e)),(s.type==="TsFunctionType"||s.type==="TsConstructorType")&&(s.params?.forEach(t=>oe(t.typeAnnotation,e)),s.typeAnnotation&&oe(s.typeAnnotation,e)),s.type==="TsTypeParameterDeclaration"&&s.params?.forEach(t=>{t.constraint&&oe(t.constraint,e),t.default&&oe(t.default,e)}),s.type==="TsTypeParameterInstantiation"&&s.params?.forEach(t=>oe(t,e)),s.type==="TsMappedType"&&s.typeAnnotation&&oe(s.typeAnnotation,e),s.type==="TsIndexedAccessType"&&(oe(s.objectType,e),oe(s.indexType,e)),s.type==="TsConditionalType"&&(oe(s.checkType,e),oe(s.extendsType,e),oe(s.trueType,e),oe(s.falseType,e)),s.type==="TsTypeLiteral"&&s.members?.forEach(t=>{t.typeAnnotation&&oe(t.typeAnnotation,e)})}}function so(s,e){s.type==="TsQualifiedName"?(s.left&&so(s.left,e),s.right?.value&&e.add(s.right.value)):s.type==="Identifier"&&e.add(s.value)}import uo from"path";import us from"path";q();St();import oo from"path";import ql from"fs";import{fileURLToPath as Vl}from"url";import*as xt from"web-tree-sitter";var Rf=oo.dirname(Vl(import.meta.url)),ro=S.child({module:"parser:tree-sitter"}),ei=class{parser=null;languages=new Map;async ensureInitialized(){if(this.parser)return;let e=xt.Parser||xt;await e.init(),this.parser=new e}async getLanguage(e){if(this.languages.has(e))return this.languages.get(e);let t=_e("resources","grammars",`tree-sitter-${this.getLangName(e)}.wasm`);if(!ql.existsSync(t))return ro.warn({grammarPath:t},"Grammar WASM not found"),null;try{let n=await xt.Language.load(t);return this.languages.set(e,n),n}catch(n){return ro.error({err:n,ext:e},"Failed to load language grammar"),null}}getLangName(e){switch(e.toLowerCase()){case".php":return"php";case".py":return"python";case".go":return"go";case".rs":return"rust";default:return""}}getQueries(e){switch(e.toLowerCase()){case".php":return`
|
|
539
615
|
(function_definition name: (name) @name) @func
|
|
540
616
|
(class_declaration name: (name) @name) @class
|
|
541
617
|
(interface_declaration name: (name) @name) @interface
|
|
@@ -559,112 +635,276 @@ ${_.bold("Search History Failures")}: ${t.query.searchHistoryFailures>0?_.red(t.
|
|
|
559
635
|
(trait_item name: (_type_identifier) @name) @trait
|
|
560
636
|
(type_item name: (_type_identifier) @name) @type
|
|
561
637
|
(use_declaration argument: (_) @name) @import
|
|
562
|
-
`;default:return""}}mapKind(e,
|
|
563
|
-
`),a=this.getQueries(
|
|
564
|
-
`),
|
|
565
|
-
`).trim(),capabilities:JSON.stringify(
|
|
566
|
-
`).trim(),capabilities:JSON.stringify({attributes:
|
|
567
|
-
`).trim(),capabilities:JSON.stringify({attributes:
|
|
568
|
-
`).trim();if(
|
|
569
|
-
`),
|
|
570
|
-
`).trim()),
|
|
571
|
-
`);for(let l of
|
|
572
|
-
`).length,f=oS(a,p-1);t.push({name:d.name||"anonymous",kind:d.kind||"Unknown",classification:d.classification||"Other",signature:d.signature||u[0],line:p,endLine:f,doc:"",capabilities:JSON.stringify(d.meta||{})})}}let c=oi({classification:`Micro IR (${i.substring(1).toUpperCase()})`,capabilities:[],exports:t.map(l=>({name:l.name,kind:l.kind,classification:l.classification})),fileName:Pc.basename(e)});return{exports:t,imports:[],classification:`Micro IR (${i.substring(1).toUpperCase()})`,summary:c||"Module",parseStatus:t.length>0?"success":"partial"}}};J();import*as Rc from"@swc/core";function Jh(n){if(!n||typeof n!="object")return!1;let e=n;return typeof e.parse=="function"&&typeof e.parseSync=="function"}function aS(){if(Jh(Rc))return Rc;let n=Rc;if(Jh(n.default))return n.default;throw new Error("SWC runtime unavailable: couldn't resolve parse/parseSync from @swc/core exports")}var qh=aS();function si(n,e,r){return qh.parse(n,e,r)}function No(n,e,r){return qh.parseSync(n,e,r)}var zc=new zo;async function Xn(n){let e=Kh.extname(n);if(zc.supports(e)&&e!==".ts"&&e!==".tsx")try{let o=await Vh.promises.readFile(n,"utf-8");return{...await zc.parse(n,o),content:o}}catch(o){return $.error({filePath:n,error:o.message},"HeuristicParser failed"),{exports:[],imports:[],classification:"Unknown",summary:"",content:"",parseStatus:"failed",parseError:o.message}}let r;try{r=await Vh.promises.readFile(n)}catch(o){return{exports:[],imports:[],classification:"Error",summary:"",content:"",parseStatus:"failed",parseError:`File read error: ${o.message}`}}let i=r.toString("utf8"),t=Dh(i);try{let o=n.endsWith(".tsx"),s=n.endsWith(".d.ts")||n.endsWith(".d.tsx"),a,c={syntax:"typescript",tsx:o,decorators:!0,comments:!0};if(s)try{a=No(i,c)}catch{a=No(i,{...c,isModule:!1})}else a=No(i,c);let l=a.span.start,u=Lh(r),d=Oh(i),p=E=>Ah(E,l,r),f=jh(a.body),m=Zh(a.body);m.length>0&&$.debug({filePath:n,count:m.length},"Extracted type references"),m.forEach(E=>{f.push({module:"__type_reference__",name:E})});let h=Fh(a.body,l,r,i,t,d,n,p,u),v=Uh(a.body,l,r,t,p,u),b=Io(n,"","Module"),x=d.length>0&&i.slice(0,d[0].start).trim().length===0?d[0].text:h.find(E=>E.doc)?.doc||"",S=Mh(x);if(!S&&h.length>0){let E=ii(i);S=oi({classification:b,capabilities:E,exports:h.map(w=>({name:w.name,kind:w.kind,classification:w.classification})),fileName:Kh.basename(n)})}return{exports:h,imports:f,events:v,classification:b,summary:S,content:i,parseStatus:"success"}}catch(o){$.warn({filePath:n,error:o.message},"SWC parsing failed, using heuristic fallback");try{let s=await zc.parse(n,i);return{...s,content:i,classification:s.classification+" (Degraded)",parseStatus:"partial",parseError:`SWC failed, used heuristic fallback: ${o.message}`}}catch(s){return $.error({filePath:n,error:s.message},"All parsing strategies failed"),{exports:[],imports:[],classification:"Error",summary:"",content:i,parseStatus:"failed",parseError:`All parsing strategies failed: ${s.message}`}}}}import Co from"path";var cS=50;function ai(n,e,r,i){let t={name:Co.basename(e)||e,type:"directory",path:e,children:[]};return n.forEach(o=>{let a=Co.relative(e,o.path).split(Co.sep),c=t;for(let l=0;l<a.length;l++){let u=a[l];if(i!==void 0&&l>=i)return;let d=l===a.length-1;if(i===1&&l===0&&d)return;let p=i!==void 0&&l===i-1&&!d,f=Co.join(e,...a.slice(0,l+1)),m=c.children?.find(h=>h.name===u);if(!m){if(c.children&&c.children.length>=cS){c.children.find(b=>b.type==="truncated")||c.children.push({name:"... (truncated) ",type:"truncated",path:"",children:void 0});return}m={name:u,type:d?"file":"directory",path:f,children:d||p?void 0:[],summary:d?{classification:o.classification,summaryText:o.summary,exports:o.exports,imports:o.imports,chunks:o.chunks}:void 0},m.summary&&(r==="structure"||r==="signatures")&&(delete m.summary.chunks,delete m.summary.imports),c.children?.push(m)}c=m}}),t}J();import Zc from"p-limit";dt();import Hc from"path";import OS from"fs";import MS from"os";import ft from"path";import nr from"fs";import{loadConfig as dS,createMatchPath as pS}from"tsconfig-paths";import Jt from"path";import ci from"fs";var qt=class extends Error{constructor(r,i,t){super(i);this.code=r;this.cause=t;this.name="FileSystemError"}};function Yh(n){let e;try{e=ci.statSync(n).isDirectory()?n:Jt.dirname(n)}catch(r){throw r.code==="ENOENT"?new qt("FILE_NOT_FOUND",`Start path does not exist: ${n}`,r):r.code==="EACCES"||r.code==="EPERM"?new qt("PERMISSION_DENIED",`Permission denied accessing: ${n}`,r):new qt("UNKNOWN",`Failed to access path: ${n}`,r)}for(;e!==Jt.dirname(e);){let r=Jt.join(e,"tsconfig.json");if(ci.existsSync(r))return e;e=Jt.dirname(e)}return null}function Xh(n){let e;try{e=ci.statSync(n).isDirectory()?n:Jt.dirname(n)}catch(r){throw r.code==="ENOENT"?new qt("FILE_NOT_FOUND",`Start path does not exist: ${n}`,r):r.code==="EACCES"||r.code==="EPERM"?new qt("PERMISSION_DENIED",`Permission denied accessing: ${n}`,r):new qt("UNKNOWN",`Failed to access path: ${n}`,r)}for(;e!==Jt.dirname(e);){let r=Jt.join(e,"package.json");if(ci.existsSync(r))try{if(JSON.parse(ci.readFileSync(r,"utf8")).workspaces)return e}catch{}e=Jt.dirname(e)}return null}import Qn from"path";import In from"fs";function Qh(n,e){let r=new Map,i=e.workspaces||[];for(let t of i){let o=t.replace("/*",""),s=Qn.join(n,o);if(!In.existsSync(s))continue;let a=In.readdirSync(s);for(let c of a){let l=Qn.join(s,c,"package.json");if(In.existsSync(l))try{let u=JSON.parse(In.readFileSync(l,"utf8"));u.name&&r.set(u.name,{name:u.name,path:Qn.dirname(l),main:u.main||"dist/index.js"})}catch{}}}return r}function eg(n){let e=new Map;try{let r=JSON.parse(In.readFileSync(n,"utf8")),i={...r.dependencies,...r.devDependencies};for(let[t,o]of Object.entries(i))if(typeof o=="string"&&o.startsWith("file:")){let s=o.substring(5),a=Qn.dirname(n),c=Qn.resolve(a,s),l=Qn.join(c,"package.json");if(In.existsSync(l))try{let u=JSON.parse(In.readFileSync(l,"utf8"));e.set(t,{name:t,path:c,main:u.main||"dist/index.js"})}catch{}}}catch{}return e}import tg from"path";import mt from"fs";var lS=[".ts",".tsx",".d.ts",".js",".jsx"];function rt(n){let e=tg.extname(n);if(e===".js"||e===".jsx"){let r=n.slice(0,-e.length),i=e===".jsx"?[".tsx",".ts"]:[".ts",".tsx"];for(let t of i){let o=r+t;if(mt.existsSync(o)&&mt.statSync(o).isFile())return o}if(mt.existsSync(n)&&mt.statSync(n).isFile())return n}if(mt.existsSync(n)&&mt.statSync(n).isFile())return n;for(let r of lS){let i=n+r;if(mt.existsSync(i)&&mt.statSync(i).isFile())return i}if(mt.existsSync(n)&&mt.statSync(n).isDirectory())for(let r of[".ts",".tsx",".js",".jsx"]){let i=tg.join(n,"index"+r);if(mt.existsSync(i))return i}return""}import er from"path";import uS from"fs";function Do(n,e,r){if(n.startsWith(".")){let t=er.dirname(e),o=er.resolve(t,n),s=rt(o);return s?{resolved:!0,resolvedPath:s}:{resolved:!1,error:`File not found at relative path: ${o}`,suggestion:"Check if the file exists and has a supported extension (.ts, .tsx, .js, .jsx)"}}let i=tr(e);if(i){if(i.matchPath){let o=i.matchPath(n);if(o){let s=rt(o);return s?{resolved:!0,resolvedPath:s}:{resolved:!1,error:`Path alias matched to '${o}' but file does not exist`,suggestion:"Check if the target file exists or if the alias mapping in tsconfig.json is correct"}}}if(!n.startsWith("@")){let o=er.resolve(i.baseUrl,n),s=rt(o);if(s)return{resolved:!0,resolvedPath:s}}let t=i.workspacePackages.get(n);if(t){let o=er.join(t.path,"src/index.ts");if(uS.existsSync(o))return{resolved:!0,resolvedPath:o};let s=er.join(t.path,t.main),a=rt(s);return a?{resolved:!0,resolvedPath:a}:{resolved:!1,error:`Workspace package '${n}' found at ${t.path} but entry point not found`,suggestion:`Check main field in ${er.join(t.path,"package.json")}`}}}else return{resolved:!1,error:"No tsconfig.json found",suggestion:"Ensure a tsconfig.json exists in the project root or parent directories"};return n.startsWith("@")?{resolved:!1,error:`Path alias '${n}' not found in tsconfig.json paths`,suggestion:'Check tsconfig.json "paths" configuration'}:{resolved:!1,error:"Module not found (treated as external) ",suggestion:"Install dependency or check import path"}}var Lo=new Map;function tr(n){let e=Yh(n);if(!e)return null;if(Lo.has(e))return Lo.get(e)||null;let r=dS(e);if(r.resultType==="failed")return Lo.set(e,null),null;let i=r,t=i.absoluteBaseUrl;!t&&i.paths&&Object.keys(i.paths).length>0&&(t=i.configFileAbsolutePath?ft.dirname(i.configFileAbsolutePath):e);let o=pS(t,i.paths,i.mainFields,i.addMatchAll),s=Xh(e),a=new Map;if(s){let d=ft.join(s,"package.json");if(nr.existsSync(d))try{let p=JSON.parse(nr.readFileSync(d,"utf8"));a=Qh(s,p)}catch{}}let c=ft.join(e,"package.json");nr.existsSync(c)&&eg(c).forEach((p,f)=>a.set(f,p));let l={baseUrl:t||"",paths:i.paths,matchPath:o,workspacePackages:a,imports:new Map},u=ft.join(e,"package.json");if(nr.existsSync(u))try{let d=JSON.parse(nr.readFileSync(u,"utf8"));if(d.imports){for(let[p,f]of Object.entries(d.imports))if(typeof f=="string"||typeof f=="object"&&f!==null){let m=f;Array.isArray(f)&&(m=f[0]),typeof m=="object"&&(m=m.default||m.node),typeof m=="string"&&l.imports.set(p,m)}}}catch{}return Lo.set(e,l),l}function Vt(n,e,r){if(!n)return"";if(n.includes(".")&&!n.startsWith(".")&&!n.startsWith("/")&&!n.endsWith(".js")&&!n.endsWith(".ts")&&!n.endsWith(".json")){let t=n.split(".")[0];if(t&&t!==n){let o=Vt(t,e,r);if(o)return o}}if(n.startsWith(".")){let t=ft.dirname(e),o=ft.resolve(t,n);return rt(o)}let i=tr(e);if(i){let t=i.matchPath(n);if(t)return rt(t);if(!n.startsWith("@")||n.startsWith("@/")){let s=ft.resolve(i.baseUrl,n),a=rt(s);if(a)return a}for(let[s,a]of i.imports.entries())if(s.includes("*")){let c="^"+s.replace(/[\\^$+.()|[\]{}]/g,"\\$&").replace(/\*/g,"(.*)")+"$",l=new RegExp(c),u=n.match(l);if(u){let d=u[1],p=a.replace("*",d),f=ft.resolve(i.baseUrl,p);return rt(f)}}else if(s===n){let c=ft.resolve(i.baseUrl,a);return rt(c)}let o=i.workspacePackages.get(n);if(o){let s=ft.join(o.path,"src/index.ts");if(nr.existsSync(s))return s;let a=ft.join(o.path,o.main),c=rt(a);if(c)return c}}return""}import mS from"fs";import fS from"path";import rg from"js-yaml";function ng(n){let e=fS.basename(n),r=mS.readFileSync(n,"utf8"),i=[];if(e.endsWith(".prisma"))return{...bS(r,n),content:r};if(e.endsWith(".graphql")||e.endsWith(".gql"))return{...vS(r,n),content:r};let t="Configuration";return e==="lerna.json"?{...xS(r,n),content:r}:e==="turbo.json"?{...SS(r,n),content:r}:e==="pnpm-workspace.yaml"?{...$S(r,n),content:r}:(e.includes("Dockerfile")?(t="Infrastructure (Docker) ",hS(r,i)):e.endsWith(".yaml")||e.endsWith(".yml")?(t="Infrastructure (YAML) ",gS(r,i)):e.startsWith(".env")?(t="Configuration (Env) ",yS(r,i)):e==="package.json"&&(t="Project Manifest",_S(r,i)),{configs:i,classification:t,content:r})}function hS(n,e){let r=n.split(`
|
|
573
|
-
`);for(let
|
|
574
|
-
`);for(let
|
|
575
|
-
`):[]}catch{return[]}}function
|
|
576
|
-
`).some(
|
|
577
|
-
`).some(
|
|
578
|
-
`).map(
|
|
579
|
-
`).filter(Boolean);for(let
|
|
580
|
-
`).filter(Boolean);
|
|
581
|
-
`).length:0,r=Ag(n?.exports),i=0,t=0,o=0,s=0;for(let a of r){let c=Dg(a?.line??a?.start_line),l=Dg(a?.endLine??a?.end_line??c);if(!c||!l||l<c||e>0&&l>e){t++;continue}i++,l>c&&s++,e>0&&c===e&&l===e&&o++}return{total:r.length,valid:i,invalid:t,eofCollapsed:o,multiLine:s,lineCount:e}}function US(n){let e=Og(n);if(e.total===0||e.lineCount===0)return!1;if(e.invalid>0)return!0;let r=e.eofCollapsed/e.total;return e.eofCollapsed>=3&&r>=.5||e.total>=2&&e.eofCollapsed===e.total}function Lg(n){let e=Og(n);return e.valid*2+e.multiLine*2-e.eofCollapsed*3-e.invalid*4}async function ee(n,e=FS,r=!1,i=!0,t){let o=L.getInstance(n),s=o.files.database,a=Rt(n),c=a.concurrency??e;if(Eh(),!r&&Oe(n)){let b=Jn(n),g=it(n);if(b&&!Lc(n,b))return So(),$.debug({repoPath:n,commit:g},"Index is current, skipping re-index (fast-path)"),s}tr(n);let l=o.files.findAll(),u=new Map(l.map(b=>[b.path,{mtime:b.mtime,hash:b.content_hash}])),d=Date.now();t?.({phase:"scan",current:0,total:0,message:"Scanning repository..."});let p=await Ic(n,a.ignore),f=new Map(p.map(b=>[b.path,b.mtime])),m=l.filter(b=>!f.has(b.path)).map(b=>b.path),h=l.length===0,v=[];if(r||h)v.push(...p);else{let b=p.filter(E=>{let w=u.get(E.path);return!w||w.mtime!==E.mtime}),g=Zc(c*4),x=b.map(E=>g(async()=>{let w=u.get(E.path);if(!w||!w.hash)return E;try{let z=await OS.promises.readFile(E.path,"utf8");return hc(z,w.hash)?E:(o.files.updateMtime(E.path,E.mtime),null)}catch{return null}})),S=await Promise.all(x);v.push(...S.filter(E=>E!==null))}if(m.length===0&&v.length===0){So();let b=it(n);return to(n,b||void 0),s}if(h?$.info({totalFiles:p.length},"Starting initial repository indexing..."):$.info({toDelete:m.length,toProcess:v.length},"Syncing repository updates..."),m.length>0&&o.files.deletePaths(m),v.length>0){Th(),i?(ti(!0),xn().initialize().catch(()=>{})):ti(!1);let b=/\.(ts|tsx|php|py|go|js|jsx|mjs|cjs)$/,g=[],x=[];for(let C of v)b.test(Hc.basename(C.path))?g.push(C):x.push(C);let S=0,E=v.length,w=!1,z=ug();try{await z.initialize(),w=!0,$.info({workers:z.workerCount},"Parser worker pool active")}catch(C){$.warn({err:C},"Parser worker pool failed to initialize, falling back to main-thread parsing"),w=!1}let R=async(C,W)=>{let q=W;if(w&&US(W))try{let Q=await Xn(C.path);Lg(Q)>Lg(W)&&($.warn({filePath:C.path},"Detected suspicious worker parse ranges; using main-thread parse output"),q=Q)}catch(Q){$.warn({filePath:C.path,err:Q instanceof Error?Q.message:String(Q)},"Main-thread parse retry failed after suspicious worker parse")}let B=q.imports?.map(Q=>({...Q,resolved_path:Vt(Q.module,C.path,n)})),H=q.content?_n(q.content):null;return S++,(S%50===0||S===E)&&$.info({completed:S,total:E},"Parsing files..."),t?.({phase:"parse",current:S,total:E,message:`Parsing ${Hc.basename(C.path)}`}),{meta:C,...q,imports:B,embedding:null,kind:"code",contentHash:H}},U;if(w)U=g.map(C=>z.parseFile(C.path).then(W=>R(C,W),W=>(S++,$.error({path:C.path,error:W},"Worker parse failed"),{meta:C,exports:[],imports:[],content:"",kind:"error"})));else{let C=h?Math.max(c,Math.min(jS-1,16)):c,W=Zc(C);U=g.map(q=>W(async()=>{try{let B=await Xn(q.path);return R(q,B)}catch(B){return S++,$.error({path:q.path,error:B},"Failed to parse file"),{meta:q,exports:[],imports:[],content:"",kind:"error"}}}))}let I=Zc(c),T=x.map(C=>I(async()=>{try{let W=ng(C.path),q=W.content?_n(W.content):null;return S++,(S%50===0||S===E)&&$.info({completed:S,total:E},"Parsing configs..."),t?.({phase:"parse",current:S,total:E,message:`Parsing config ${Hc.basename(C.path)}`}),{meta:C,...W,embedding:null,kind:"config",contentHash:q}}catch(W){return S++,$.error({path:C.path,error:W},"Failed to parse config"),{meta:C,exports:[],imports:[],content:"",kind:"error"}}}));$.info({total:E,codeFiles:g.length,configFiles:x.length,useParserPool:w},"Phase 1: Parsing all files...");let N=Date.now(),F=(await Promise.all([...U,...T])).filter(Boolean),D=Date.now()-N;if(ri("parse",D),$.info({count:F.length,time:`${(D/1e3).toFixed(1)}s`},"Phase 1 complete"),w&&dg().catch(()=>{}),s.pragma("synchronous = NORMAL"),s.pragma("cache_size = -64000"),i){let C=[];F.forEach((le,fe)=>{"summary"in le&&le.summary&&C.push({fileIdx:fe,text:le.summary})}),$.info("Phase 2+3: Generating embeddings + persisting in parallel..."),t?.({phase:"embed",current:0,total:F.length,message:"Generating embeddings..."});let W=Date.now(),q=(async()=>{if(C.length>0){$.info({count:C.length}," \u2192 Generating file summary embeddings...");let le=C.map(se=>se.text),fe=await lo(le,256);return $.info({count:C.length}," \u2713 File summaries complete"),fe}return[]})();t?.({phase:"persist",current:0,total:F.length,message:"Saving to database..."});let B=Date.now();o.files.batchSaveIndexResults(F,n,_n,Vt);let H=Date.now()-B;ri("persist",H),$.info({time:`${(H/1e3).toFixed(1)}s`},"Structural persist complete");let Q=await q,V=Date.now()-W;if(ri("embed",V),$.info({time:`${(V/1e3).toFixed(1)}s`},"Embeddings complete"),Q.length>0){let le=s.prepare("UPDATE files SET embedding = ? WHERE path = ?"),fe=s.transaction(K=>{for(let G of K)le.run(G.embedding?JSON.stringify(G.embedding):null,G.path)}),se=C.map((K,G)=>({path:F[K.fileIdx].meta.path,embedding:Q[G]}));fe(se),$.info({count:se.length},"Embedding column updated")}let re=await o.intentLogs.backfillEmbeddings(64);re>0&&$.info({count:re}," \u2713 Intent log embeddings backfilled")}else{t?.({phase:"persist",current:0,total:F.length,message:"Saving to database..."});let C=Date.now();o.files.batchSaveIndexResults(F,n,_n,Vt),ri("persist",Date.now()-C)}s.pragma("synchronous = FULL"),s.pragma("cache_size = -2000")}if(h||v.length>0){let b=it(n);to(n,b||void 0)}if((v.length>0||m.length>0)&&new Ce(n).detectAndRepairShifts(),h||i)try{new Rn(n).analyzeHeritage(50)}catch(b){$.warn({err:b.message},"Heritage sync deferred")}return Ih(Date.now()-d),t?.({phase:"complete",current:v.length,total:v.length,message:"Indexing complete"}),s}J();import Mg from"path";import ZS from"ignore";import jg from"fs";X();async function zn(n,e=ko.DEFAULT_CONCURRENCY,r="detailed",i,t){$.info({repo:n,level:r,subPath:i},"Ensuring cache is up-to-date..."),await ee(n,e);let{files:o,exports:s,imports:a}=L.getInstance(n),c=i?o.findInSubPath(n,i):o.findAll(),l=Rt(n),u=ZS(),d=Mg.join(n,".gitignore");if(jg.existsSync(d)&&u.add(jg.readFileSync(d,"utf8")),l.ignore&&l.ignore.length>0&&u.add(l.ignore),u.add(wo),c=c.filter(g=>{let x=Mg.relative(n,g.path);return!u.ignores(x)}),$.info({count:c.length},"Fetching data from DB..."),r==="lite"){let g=c.map(x=>({path:x.path,mtime:x.mtime}));return ai(g,n,r,t)}if(r==="summaries"){let g=c.map(x=>({path:x.path,mtime:x.mtime,classification:x.classification||void 0,summary:x.summary||void 0}));return ai(g,n,r,t)}let p=c.map(g=>g.path),f=s.findByFiles(p),m=r==="detailed"?a.findByFiles(p):[],h=new Map;for(let g of f){let x=h.get(g.file_path)||[];x.push(g),h.set(g.file_path,x)}let v=new Map;for(let g of m){let x=v.get(g.file_path)||[];x.push(g),v.set(g.file_path,x)}let b=c.map(g=>{let S=(h.get(g.path)||[]).map(w=>({name:w.name,kind:w.kind,signature:w.signature,line:w.start_line}));r==="structure"?S=S.map(w=>({name:w.name,kind:w.kind,line:w.line})):r==="signatures"&&(S=S.map(w=>({name:w.name,kind:w.kind,signature:w.signature,line:w.line})));let E=[];return r==="detailed"&&(E=(v.get(g.path)||[]).map(z=>({module:z.module_specifier,resolved_path:z.resolved_path}))),{path:g.path,mtime:g.mtime,classification:g.classification||void 0,summary:g.summary||void 0,exports:S,imports:E.length>0?E:void 0,chunks:[]}});return $.info({count:b.length},"Building hierarchical project tree..."),ai(b,n,r,t)}Nt();X();X();var Nn=class n{static extractKeywords(e){if(!e)return[];let r=new Set(["the","and","for","with","from","this","that","into","onto","http","https","www","com","org","net","api"]),t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9_]+/).map(o=>o.trim()).filter(o=>o.length>2&&!r.has(o));return Array.from(new Set(t))}static calculateKeywordCoverageFromKeywords(e,r){if(!e||!r||r.length===0)return 0;let i=e.toLowerCase();return r.filter(o=>i.includes(o)).length/r.length}static calculateKeywordCoverage(e,r){return n.calculateKeywordCoverageFromKeywords(e,n.extractKeywords(r))}static extractSnippet(e,r,i=300){if(!e||!r)return"";let t=n.extractKeywords(r);if(t.length===0)return e.slice(0,i)+"...";let o=e.split(`
|
|
582
|
-
|
|
583
|
-
`).
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
638
|
+
`;default:return""}}mapKind(e,t){if(e==="import")return"ImportDeclaration";if(t===".php"){if(e==="func")return"FunctionDeclaration";if(e==="class")return"ClassDeclaration";if(e==="interface")return"InterfaceDeclaration";if(e==="trait")return"TraitDeclaration";if(e==="method")return"MethodDeclaration"}if(t===".py"){if(e==="func")return"FunctionDeclaration";if(e==="class")return"ClassDeclaration"}if(t===".go"){if(e==="func")return"FunctionDeclaration";if(e==="type")return"TypeDeclaration"}if(t===".rs"){if(e==="func")return"FunctionDeclaration";if(e==="struct")return"StructDeclaration";if(e==="enum")return"EnumDeclaration";if(e==="trait")return"TraitDeclaration";if(e==="type")return"TypeDeclaration"}return"Unknown"}mapClassification(e){return e==="import"?"Dependency":e==="func"||e==="method"?"Function":e==="class"||e==="interface"||e==="trait"||e==="struct"||e==="enum"||e==="type"?"Class":"Other"}async parse(e,t){await this.ensureInitialized();let n=oo.extname(e).toLowerCase(),i=await this.getLanguage(n);if(!i||!this.parser)return[];this.parser.setLanguage(i);let r=this.parser.parse(t),o=t.split(`
|
|
639
|
+
`),a=this.getQueries(n);if(!a)return[];let l=new xt.Query(i,a).matches(r.rootNode),p=[];for(let u of l){let d=u.captures.find(f=>f.name==="name")?.node,h=u.captures[0].node,m=u.captures[0].name;if(d){let f=h.startPosition.row+1,_=h.endPosition.row+1,g=o[h.startPosition.row].trim();p.push({name:d.text,kind:this.mapKind(m,n),classification:this.mapClassification(m),signature:g,line:f,endLine:_,doc:"",capabilities:"{}"})}}return p}};var ti=class{parse(e,t=!1){let n=[],i=[],r=e.split(`
|
|
640
|
+
`),o="",a="",c=0,l=0,p=-1,u=-1,d=[],h=[],m=!1,f=t?"api":"",_="",g=/^namespace\s+([a-zA-Z0-9_\\]+);/,b=/^(?:abstract\s+)?(?:readonly\s+)?class\s+([a-zA-Z0-9_]+)/,w=/^interface\s+([a-zA-Z0-9_]+)/,x=/^trait\s+([a-zA-Z0-9_]+)/,R=/^(?:public|protected|private|static|\s)*function\s+([a-zA-Z0-9_]+)\s*\(/,k=/^use\s+([a-zA-Z0-9_\\]+)(?:\s+as\s+([a-zA-Z0-9_]+))?;/,D=/^#\[([a-zA-Z0-9_\\]+)(?:\((.*)\))?\]/,U=/(?:Route::|router->|\$router->|->)(get|post|put|delete|patch|match)\s*\(\s*(?:uri\s*:\s*)?['"]([^'"]+)['"]/,P=/->prefix\s*\(\s*(?:prefix\s*:\s*)?['"]([^'"]+)['"]/;for(let E=0;E<r.length;E++){let T=r[E].trim();if(!T)continue;let I=(T.match(/{/g)||[]).length,M=(T.match(/}/g)||[]).length,N=l;if(l+=I-M,a&&l<=u){let z=n.find(G=>G.name===a&&G.line===c);z&&(z.endLine=E+1),a="",u=-1}if(o&&l<=p){let z=n.find(G=>G.name===o&&(G.kind==="ClassDeclaration"||G.kind==="TraitDeclaration"||G.kind==="InterfaceDeclaration"));z&&(z.endLine=E+1),o="",p=-1}let $=T.match(P);if($&&(f=$[1]),T.includes("});")&&(f=""),T.startsWith("/**")){m=!0,h=[];continue}if(m){T.endsWith("*/")?m=!1:h.push(T.replace(/^\*\s?/,""));continue}let W=T.match(D);if(W){d.push(W[1]);continue}let L=T.match(g);if(L){_=L[1]||"",d=[],h=[];continue}let A=T.match(b);if(A){o=A[1],p=l-I;let z={attributes:d};_&&(z.namespace=_),n.push({name:o,kind:"ClassDeclaration",classification:"Class",signature:`class ${o}`,line:E+1,endLine:E+1,doc:h.join(`
|
|
641
|
+
`).trim(),capabilities:JSON.stringify(z),members:[]}),d=[],h=[];continue}let H=T.match(w);if(H){let z=H[1];o=z,p=l-I,n.push({name:z,kind:"InterfaceDeclaration",classification:"Interface",signature:`interface ${z}`,line:E+1,endLine:E+1,doc:h.join(`
|
|
642
|
+
`).trim(),capabilities:JSON.stringify({attributes:d}),members:[]}),d=[],h=[];continue}let F=T.match(x);if(F){let z=F[1];o=z,p=l-I,n.push({name:z,kind:"TraitDeclaration",classification:"Trait",signature:`trait ${z}`,line:E+1,endLine:E+1,doc:h.join(`
|
|
643
|
+
`).trim(),capabilities:JSON.stringify({attributes:d}),members:[]}),d=[],h=[];continue}let v=T.match(R);if(v){let z=v[1],G=!!o;a=z,c=E+1,u=l-I;let we=!1,xe={};for(let le of d)le.toLowerCase().includes("route")&&(we=!0,xe={type:"route",method:"GET",path:"/"});let he=h.join(`
|
|
644
|
+
`).trim();if(we){let le=xe.path||"/";n.push({name:le,kind:"HTTP Route",classification:"Service Boundary",signature:`Function: ${z}`,line:E+1,endLine:E+1,doc:he,capabilities:JSON.stringify({type:"route",handler:o?`${o}@${z}`:z,...xe})}),i.push({type:"api_route",name:le,direction:"consume",line:E+1,snippet:T})}n.push({name:z,kind:G?"MethodDeclaration":"FunctionDeclaration",classification:G?"Method":"Function",signature:`${G?o+":: ":""}${z}`,line:E+1,endLine:E+1,doc:he,capabilities:JSON.stringify({attributes:d})}),d=[],h=[];continue}let C=T.match(k);if(C){let z=C[1]||"",G=C[2]||z.split("\\").pop()||"";n.push({name:G,kind:"ImportSpecifier",classification:"Dependency",signature:`use ${z}`,line:E+1,endLine:E+1,doc:"",capabilities:JSON.stringify({type:"use",namespace:z})}),d=[],h=[];continue}let B=T.match(U);if(B){let z=B[1].toUpperCase(),G=B[2];if(T.includes("Route::")||T.includes("router->")||T.includes("action")||T.includes(",")&&!T.includes("view(")){if(f){let re=f.startsWith("/")?f:`/${f}`,He=G.startsWith("/")?G:`/${G}`;G=(re+He).replace(/\/+/g,"/")}let xe=null,he=T.match(/\[\s*([a-zA-Z0-9_]+)::class\s*,\s*['"]([^'"]+)['"]\s*\]/);if(he)xe=`${he[1]}@${he[2]}`;else if(T.includes("::class")){let re=T.match(/([a-zA-Z0-9_]+)::class/);re&&(xe=re[1])}let le=T;!T.endsWith(");")&&E+1<r.length&&(le+=" "+r[E+1].trim(),!le.endsWith(");")&&E+2<r.length&&(le+=" "+r[E+2].trim())),n.push({name:G,kind:"HTTP Route",classification:"Service Boundary",signature:le,line:E+1,endLine:E+1,doc:"",capabilities:JSON.stringify({type:"route",method:z,path:G,handler:xe})}),i.push({type:"api_route",name:G,direction:"consume",line:E+1,snippet:le,method:z,url:G}),h=[];continue}}let j=/(?:\$client|client|Http)::(get|post|put|delete|patch|request)\s*\(\s*(?:url\s*:\s*)?([^,)]+)|(?:\$client|client)->(request|get|post|put|delete|patch)\s*\(\s*([^,)]+)/,J=T.match(j);if(J){let z=(J[1]||J[3]).toUpperCase(),G=(J[2]||J[4]).trim();(G.startsWith("'")&&G.endsWith("'")||G.startsWith('"')&&G.endsWith('"'))&&(G=G.substring(1,G.length-1)),i.push({type:"api_route",name:G,direction:"produce",line:E+1,snippet:T,method:z,url:G})}!T.startsWith("#[")&&!T.startsWith("//")&&!T.startsWith("*")&&!m&&(d=[],h=[])}return{nodes:n,events:i}}};var ni=class{currentRoutePrefix="";parse(e){this.currentRoutePrefix="";let t=[],n=[],i=e.split(`
|
|
645
|
+
`),r=[{indent:-1,name:"root",type:"root"}],o=[],a=/^class\s+([a-zA-Z0-9_]+)/,c=/^async\s+def\s+([a-zA-Z0-9_]+)|^def\s+([a-zA-Z0-9_]+)/,l=/^(?:from\s+([a-zA-Z0-9_\.]+)\s+import|import\s+([a-zA-Z0-9_\.]+))/,p=/^@(.*)/;function u(g){return g.trim().split(/[.(]/)[0]?.trim()||g}function d(g){let b=g.decorators.map(x=>u(x.raw)),w={decorators:g.decorators,decoratorNames:b};return g.async===!0&&(w.async=!0),JSON.stringify(w)}let h=!1,m="",f=[],_=[];for(let g=0;g<i.length;g++){let b=i[g],w=b.trim();if(!w||w.startsWith("#"))continue;let x=/^([a-zA-Z0-9_]+)\s*=\s*(?:APIRouter|Blueprint)\s*\(\s*(?:prefix\s*=\s*)?['"]([^'"]+)['"]/,R=w.match(x);if(R&&(this.currentRoutePrefix=R[2]),h){if(w.endsWith(m)||w.includes(m)){h=!1;let A=w.replace(m,"").trim();A&&f.push(A);let H=r[r.length-1];H.node&&(H.node.doc=f.join(`
|
|
646
|
+
`).trim()),f=[]}else f.push(w);continue}let k=b.search(/\S/),D=b.trim(),U=D.match(/^(['"]{3})/);if(U){let A=U[1],H=r[r.length-1];if(H.node&&!H.node.doc){if(D.substring(3).includes(A)){let F=D.replace(new RegExp(A,"g"),"").trim();H.node.doc=F}else{h=!0,m=A;let F=D.substring(3).trim();F&&f.push(F)}continue}}for(;r.length>1&&r[r.length-1].indent>=k;)r.pop();let P=r[r.length-1],E=D.match(p);if(E){o.push({raw:E[1].trim(),line:g+1});continue}let T=D.match(a);if(T){let A=T[1],H={name:A,kind:"ClassDeclaration",classification:"Class",signature:`class ${A}`,line:g+1,endLine:g+1,doc:"",capabilities:d({decorators:o}),members:[]};_.push(H),P.node?(P.node.members||(P.node.members=[]),P.node.members.push(H)):t.push(H),r.push({indent:k,name:A,type:"class",node:H}),o=[];continue}let I=D.match(c);if(I){let A=!!I[1],H=I[1]||I[2],F=P.type==="class",v=!1,C={};for(let G of o)if(G.raw.match(/(?:app|router)\.(get|post|put|delete|patch)/)){v=!0;let xe=["get","post","put","delete","patch"].find(re=>G.raw.toLowerCase().includes(`.${re}`))?.toUpperCase()||"GET",he=G.raw.match(/['"]([^'"]+)['"]/),le=he?he[1]:"/";if(this.currentRoutePrefix){let re=this.currentRoutePrefix.endsWith("/")?this.currentRoutePrefix.slice(0,-1):this.currentRoutePrefix,He=le.startsWith("/")?le:`/${le}`;le=re+He}C={type:"route",method:xe,path:le}}if(v){let G=C.path||"",we={name:G||H,kind:"HTTP Route",classification:"Service Boundary",signature:`Function: ${H}`,line:g+1,endLine:g+1,doc:"",capabilities:JSON.stringify({handler:F?`${P.name}.${H}`:H,async:A,...C})};_.push(we),t.push(we),n.push({type:"api_route",name:G,direction:"consume",line:g+1,snippet:D})}let B=o.some(G=>G.raw==="staticmethod"),j=o.some(G=>G.raw==="classmethod"),J=`${A?"async ":""}${F?(B?"@staticmethod ":j?"@classmethod ":"")+P.name+".":""}${H}`,z={name:H,kind:A&&F?"AsyncMethodDeclaration":A?"AsyncFunctionDeclaration":F?"MethodDeclaration":"FunctionDeclaration",classification:F?B||j?"Static Method":"Method":"Function",signature:J,line:g+1,endLine:g+1,doc:"",capabilities:d({decorators:o,async:A}),members:[]};_.push(z),P.node?(P.node.members||(P.node.members=[]),P.node.members.push(z)):t.push(z),r.push({indent:k,name:H,type:"function",node:z}),o=[];continue}let M=/^(?:path|re_path|url)\s*\(\s*['"]([^'"]+)['"]/,N=D.match(M);if(N){let A=N[1].replace(/^\^/,""),H={name:A,kind:"HTTP Route",classification:"Service Boundary",signature:D.trim(),line:g+1,endLine:g+1,doc:"",capabilities:JSON.stringify({type:"route",method:"GET",path:A})};_.push(H),t.push(H),n.push({type:"api_route",name:A,direction:"consume",line:g+1,snippet:D});continue}let $=/(?:requests|httpx|client|http)\.(get|post|put|delete|patch|request)\s*\(\s*(?:url\s*:\s*)?([^,)]+)/,W=D.match($);if(W){let A=W[1].toUpperCase(),H=W[2].trim();(H.startsWith("'")&&H.endsWith("'")||H.startsWith('"')&&H.endsWith('"'))&&(H=H.substring(1,H.length-1)),n.push({type:"api_route",name:H,direction:"produce",line:g+1,snippet:D,method:A,url:H})}let L=D.match(l);if(L){let A=L[1]||L[2],H={name:A,kind:"ImportSpecifier",classification:"Dependency",signature:`import ${A}`,line:g+1,endLine:g+1,doc:"",capabilities:JSON.stringify({type:"import",module:A})};_.push(H),t.push(H),o=[];continue}o=[],P.node&&(P.node.endLine=g+1)}return{nodes:_,events:n}}};function Jl(s,e){let t=0,n=!1;for(let i=e;i<s.length;i++){let r=s[i];for(let o of r)if(o==="{")t++,n=!0;else if(o==="}"&&(t--,n&&t<=0))return i+1;if(!n&&i>e&&/[;}]$/.test(r.trim()))return i+1}return Math.min(s.length,e+41)}var ao=[{extension:[".php"],rules:[]},{extension:[".py"],rules:[]},{extension:[".go"],rules:[{regex:/func\s+([a-zA-Z0-9_]+)\(/g,onMatch:s=>({name:s[1],kind:"FunctionDeclaration",classification:"Function",signature:s[0]})},{regex:/func\s+\([^\)]+\)\s+([a-zA-Z0-9_]+)\(/g,onMatch:s=>({name:s[1],kind:"MethodDeclaration",classification:"Method",signature:s[0]})},{regex:/import\s+['"]([^'"]+)['"]/g,onMatch:s=>({name:s[1],kind:"ImportSpecifier",classification:"Dependency",signature:s[0],meta:{type:"import",path:s[1]}})}]},{extension:[".rs"],rules:[{regex:/fn\s+([a-zA-Z0-9_]+)\s*\(/g,onMatch:s=>({name:s[1],kind:"FunctionDeclaration",classification:"Function",signature:s[0]})},{regex:/struct\s+([a-zA-Z0-9_]+)/g,onMatch:s=>({name:s[1],kind:"StructDeclaration",classification:"Class",signature:s[0]})},{regex:/enum\s+([a-zA-Z0-9_]+)/g,onMatch:s=>({name:s[1],kind:"EnumDeclaration",classification:"Class",signature:s[0]})},{regex:/trait\s+([a-zA-Z0-9_]+)/g,onMatch:s=>({name:s[1],kind:"TraitDeclaration",classification:"Class",signature:s[0]})},{regex:/use\s+([a-zA-Z0-9_:]+(?:\s+as\s+[a-zA-Z0-9_]+)?);/g,onMatch:s=>({name:s[1].trim(),kind:"ImportDeclaration",classification:"Dependency",signature:s[0],meta:{type:"import",path:s[1].trim()}})}]},{extension:[".ts",".tsx",".js",".jsx",".mjs",".cjs"],rules:[{regex:/(?:export\s+)?(?:async\s+)?function\s+([a-zA-Z0-9_]+)\s*\(/g,onMatch:s=>({name:s[1],kind:"FunctionDeclaration",classification:"Function"})},{regex:/(?:export\s+)?class\s+([a-zA-Z0-9_]+)/g,onMatch:s=>({name:s[1],kind:"ClassDeclaration",classification:"Class"})},{regex:/(?:export\s+)?interface\s+([a-zA-Z0-9_]+)/g,onMatch:s=>({name:s[1],kind:"InterfaceDeclaration",classification:"Interface"})},{regex:/(?:export\s+)?const\s+([a-zA-Z0-9_]+)\s*=/g,onMatch:s=>({name:s[1],kind:"VariableDeclaration",classification:"Constant"})},{regex:/import\s+.*\s+from\s+['"]([^'"]+)['"]/g,onMatch:s=>({name:s[1],kind:"ImportDeclaration",classification:"Dependency",meta:{path:s[1]}})}]}];function Yl(s,e){let t=[];if(s===".go"&&e.some(n=>n.kind==="TypeDeclaration")&&t.push("Go type"),s===".rs"&&(e.some(n=>n.kind==="TraitDeclaration")&&t.push("Rust trait"),e.some(n=>n.kind==="StructDeclaration")&&t.push("Rust struct"),e.some(n=>n.kind==="EnumDeclaration")&&t.push("Rust enum")),s===".py"){for(let n of e)if(n.capabilities)try{if(JSON.parse(n.capabilities).decoratorNames?.length){t.push("Python decorators");break}}catch{}e.some(n=>n.kind==="AsyncFunctionDeclaration"||n.kind==="AsyncMethodDeclaration")&&t.push("Async")}return t}var ii=class{phpParser=new ti;pythonParser=new ni;treeSitterParser=new ei;supports(e){return ao.some(t=>t.extension.includes(e.toLowerCase()))}async parse(e,t){let n=us.extname(e).toLowerCase(),i=[],r=[];if(n===".php"||n===".py"||n===".go"||n===".rs"){if(n===".py"){let l=this.pythonParser.parse(t);i=l.nodes,r=l.events}else if(n===".php"){let l=e.toLowerCase().endsWith("api.php"),p=this.phpParser.parse(t,l);i=p.nodes,r=p.events}else try{i=await this.treeSitterParser.parse(e,t)}catch{}if(i.length>0){let l=n===".php"?"Micro IR (PHP/TS) ":n===".py"?"Micro IR (Python/TS) ":n===".go"?"Micro IR (Go/TS) ":"Micro IR (Rust/TS) ",p=i.filter(m=>m.classification!=="Dependency"),u=i.filter(m=>m.classification==="Dependency"),d=Yl(n,i),h=ln({classification:l,capabilities:d,exports:p.map(m=>({name:m.name,kind:m.kind,classification:m.classification})),fileName:us.basename(e)});return{exports:p,imports:u.map(m=>({module:m.name,name:m.name,kind:m.kind,classification:m.classification})),events:r,classification:l,summary:h||`${n.substring(1).toUpperCase()} module`,parseStatus:"success"}}}let o=ao.find(l=>l.extension.includes(n));if(!o)return{exports:[],imports:[],classification:"Unknown",summary:"",parseStatus:"failed",parseError:`Unsupported file extension: ${n}`};let a=t.split(`
|
|
647
|
+
`);for(let l of o.rules){l.regex.lastIndex=0;let p;for(;(p=l.regex.exec(t))!==null;){let u=l.onMatch(p),d=t.substring(0,p.index).split(`
|
|
648
|
+
`).length,h=Jl(a,d-1);i.push({name:u.name||"anonymous",kind:u.kind||"Unknown",classification:u.classification||"Other",signature:u.signature||p[0],line:d,endLine:h,doc:"",capabilities:JSON.stringify(u.meta||{})})}}let c=ln({classification:`Micro IR (${n.substring(1).toUpperCase()})`,capabilities:[],exports:i.map(l=>({name:l.name,kind:l.kind,classification:l.classification})),fileName:us.basename(e)});return{exports:i,imports:[],classification:`Micro IR (${n.substring(1).toUpperCase()})`,summary:c||"Module",parseStatus:i.length>0?"success":"partial"}}};q();import*as ds from"@swc/core";function co(s){if(!s||typeof s!="object")return!1;let e=s;return typeof e.parse=="function"&&typeof e.parseSync=="function"}function Kl(){if(co(ds))return ds;let s=ds;if(co(s.default))return s.default;throw new Error("SWC runtime unavailable: couldn't resolve parse/parseSync from @swc/core exports")}var lo=Kl();function ms(s,e,t){return lo.parse(s,e,t)}function si(s,e,t){return lo.parseSync(s,e,t)}var hs=new ii;async function pn(s){let e=uo.extname(s);if(hs.supports(e)&&e!==".ts"&&e!==".tsx")try{let r=await po.promises.readFile(s,"utf-8");return{...await hs.parse(s,r),content:r}}catch(r){return S.error({filePath:s,error:r.message},"HeuristicParser failed"),{exports:[],imports:[],classification:"Unknown",summary:"",content:"",parseStatus:"failed",parseError:r.message}}let t;try{t=await po.promises.readFile(s)}catch(r){return{exports:[],imports:[],classification:"Error",summary:"",content:"",parseStatus:"failed",parseError:`File read error: ${r.message}`}}let n=t.toString("utf8"),i=Yr(n);try{let r=s.endsWith(".tsx"),o=s.endsWith(".d.ts")||s.endsWith(".d.tsx"),a,c={syntax:"typescript",tsx:r,decorators:!0,comments:!0};if(o)try{a=si(n,c)}catch{a=si(n,{...c,isModule:!1})}else a=si(n,c);let l=a.span.start,p=Kr(t),u=Xr(n),d=R=>Qr(R,l,t),h=eo(a.body),m=io(a.body);m.length>0&&S.debug({filePath:s,count:m.length},"Extracted type references"),m.forEach(R=>{h.push({module:"__type_reference__",name:R})});let f=to(a.body,l,t,n,i,u,s,d,p),_=no(a.body,l,t,i,d,p),g=Zn(s,"","Module"),w=u.length>0&&n.slice(0,u[0].start).trim().length===0?u[0].text:f.find(R=>R.doc)?.doc||"",x=Zr(w);if(!x&&f.length>0){let R=cn(n);x=ln({classification:g,capabilities:R,exports:f.map(k=>({name:k.name,kind:k.kind,classification:k.classification})),fileName:uo.basename(s)})}return{exports:f,imports:h,events:_,classification:g,summary:x,content:n,parseStatus:"success"}}catch(r){S.warn({filePath:s,error:r.message},"SWC parsing failed, using heuristic fallback");try{let o=await hs.parse(s,n);return{...o,content:n,classification:o.classification+" (Degraded)",parseStatus:"partial",parseError:`SWC failed, used heuristic fallback: ${r.message}`}}catch(o){return S.error({filePath:s,error:o.message},"All parsing strategies failed"),{exports:[],imports:[],classification:"Error",summary:"",content:n,parseStatus:"failed",parseError:`All parsing strategies failed: ${o.message}`}}}}q();import xs from"p-limit";Ze();import vs from"path";import Dp from"fs";import Op from"os";import Ne from"path";import zt from"fs";import{loadConfig as Zl,createMatchPath as ep}from"tsconfig-paths";import lt from"path";import un from"fs";var pt=class extends Error{constructor(t,n,i){super(n);this.code=t;this.cause=i;this.name="FileSystemError"}};function mo(s){let e;try{e=un.statSync(s).isDirectory()?s:lt.dirname(s)}catch(t){throw t.code==="ENOENT"?new pt("FILE_NOT_FOUND",`Start path does not exist: ${s}`,t):t.code==="EACCES"||t.code==="EPERM"?new pt("PERMISSION_DENIED",`Permission denied accessing: ${s}`,t):new pt("UNKNOWN",`Failed to access path: ${s}`,t)}for(;e!==lt.dirname(e);){let t=lt.join(e,"tsconfig.json");if(un.existsSync(t))return e;e=lt.dirname(e)}return null}function ho(s){let e;try{e=un.statSync(s).isDirectory()?s:lt.dirname(s)}catch(t){throw t.code==="ENOENT"?new pt("FILE_NOT_FOUND",`Start path does not exist: ${s}`,t):t.code==="EACCES"||t.code==="EPERM"?new pt("PERMISSION_DENIED",`Permission denied accessing: ${s}`,t):new pt("UNKNOWN",`Failed to access path: ${s}`,t)}for(;e!==lt.dirname(e);){let t=lt.join(e,"package.json");if(un.existsSync(t))try{if(JSON.parse(un.readFileSync(t,"utf8")).workspaces)return e}catch{}e=lt.dirname(e)}return null}import Ht from"path";import vt from"fs";function fo(s,e){let t=new Map,n=e.workspaces||[];for(let i of n){let r=i.replace("/*",""),o=Ht.join(s,r);if(!vt.existsSync(o))continue;let a=vt.readdirSync(o);for(let c of a){let l=Ht.join(o,c,"package.json");if(vt.existsSync(l))try{let p=JSON.parse(vt.readFileSync(l,"utf8"));p.name&&t.set(p.name,{name:p.name,path:Ht.dirname(l),main:p.main||"dist/index.js"})}catch{}}}return t}function go(s){let e=new Map;try{let t=JSON.parse(vt.readFileSync(s,"utf8")),n={...t.dependencies,...t.devDependencies};for(let[i,r]of Object.entries(n))if(typeof r=="string"&&r.startsWith("file:")){let o=r.substring(5),a=Ht.dirname(s),c=Ht.resolve(a,o),l=Ht.join(c,"package.json");if(vt.existsSync(l))try{let p=JSON.parse(vt.readFileSync(l,"utf8"));e.set(i,{name:i,path:c,main:p.main||"dist/index.js"})}catch{}}}catch{}return e}import yo from"path";import Me from"fs";var Ql=[".ts",".tsx",".d.ts",".js",".jsx"];function ut(s){let e=yo.extname(s);if(e===".js"||e===".jsx"){let t=s.slice(0,-e.length),n=e===".jsx"?[".tsx",".ts"]:[".ts",".tsx"];for(let i of n){let r=t+i;if(Me.existsSync(r)&&Me.statSync(r).isFile())return r}if(Me.existsSync(s)&&Me.statSync(s).isFile())return s}if(Me.existsSync(s)&&Me.statSync(s).isFile())return s;for(let t of Ql){let n=s+t;if(Me.existsSync(n)&&Me.statSync(n).isFile())return n}if(Me.existsSync(s)&&Me.statSync(s).isDirectory())for(let t of[".ts",".tsx",".js",".jsx"]){let n=yo.join(s,"index"+t);if(Me.existsSync(n))return n}return""}import{builtinModules as Xl,createRequire as og}from"node:module";var lg=new Set(Xl.map(s=>s.replace(/^node:/,"")));var oi=new Map;function ri(s){let e=mo(s);if(!e)return null;if(oi.has(e))return oi.get(e)||null;let t=Zl(e);if(t.resultType==="failed")return oi.set(e,null),null;let n=t,i=n.absoluteBaseUrl;!i&&n.paths&&Object.keys(n.paths).length>0&&(i=n.configFileAbsolutePath?Ne.dirname(n.configFileAbsolutePath):e);let r=ep(i,n.paths,n.mainFields,n.addMatchAll),o=ho(e),a=new Map;if(o){let u=Ne.join(o,"package.json");if(zt.existsSync(u))try{let d=JSON.parse(zt.readFileSync(u,"utf8"));a=fo(o,d)}catch{}}let c=Ne.join(e,"package.json");zt.existsSync(c)&&go(c).forEach((d,h)=>a.set(h,d));let l={baseUrl:i||"",paths:n.paths,matchPath:r,workspacePackages:a,imports:new Map},p=Ne.join(e,"package.json");if(zt.existsSync(p))try{let u=JSON.parse(zt.readFileSync(p,"utf8"));if(u.imports){for(let[d,h]of Object.entries(u.imports))if(typeof h=="string"||typeof h=="object"&&h!==null){let m=h;Array.isArray(h)&&(m=h[0]),typeof m=="object"&&(m=m.default||m.node),typeof m=="string"&&l.imports.set(d,m)}}}catch{}return oi.set(e,l),l}function Tt(s,e,t){if(!s)return"";if(s.includes(".")&&!s.startsWith(".")&&!s.startsWith("/")&&!s.endsWith(".js")&&!s.endsWith(".ts")&&!s.endsWith(".json")){let i=s.split(".")[0];if(i&&i!==s){let r=Tt(i,e,t);if(r)return r}}if(s.startsWith(".")){let i=Ne.dirname(e),r=Ne.resolve(i,s);return ut(r)}let n=ri(e);if(n){let i=n.matchPath(s);if(i)return ut(i);if(!s.startsWith("@")||s.startsWith("@/")){let o=Ne.resolve(n.baseUrl,s),a=ut(o);if(a)return a}for(let[o,a]of n.imports.entries())if(o.includes("*")){let c="^"+o.replace(/[\\^$+.()|[\]{}]/g,"\\$&").replace(/\*/g,"(.*)")+"$",l=new RegExp(c),p=s.match(l);if(p){let u=p[1],d=a.replace("*",u),h=Ne.resolve(n.baseUrl,d);return ut(h)}}else if(o===s){let c=Ne.resolve(n.baseUrl,a);return ut(c)}let r=n.workspacePackages.get(s);if(r){let o=Ne.join(r.path,"src/index.ts");if(zt.existsSync(o))return o;let a=Ne.join(r.path,r.main),c=ut(a);if(c)return c}}return""}import tp from"fs";import np from"path";import _o from"js-yaml";function bo(s){let e=np.basename(s),t=tp.readFileSync(s,"utf8"),n=[];if(e.endsWith(".prisma"))return{...op(t,s),content:t};if(e.endsWith(".graphql")||e.endsWith(".gql"))return{...ap(t,s),content:t};let i="Configuration";return e==="lerna.json"?{...lp(t,s),content:t}:e==="turbo.json"?{...pp(t,s),content:t}:e==="pnpm-workspace.yaml"?{...up(t,s),content:t}:(e.includes("Dockerfile")?(i="Infrastructure (Docker) ",ip(t,n)):e.endsWith(".yaml")||e.endsWith(".yml")?(i="Infrastructure (YAML) ",sp(t,n)):e.startsWith(".env")?(i="Configuration (Env) ",rp(t,n)):e==="package.json"&&(i="Project Manifest",cp(t,n)),{configs:n,classification:i,content:t})}function ip(s,e){let t=s.split(`
|
|
649
|
+
`);for(let n of t){let i=n.trim();if(i.startsWith("FROM "))e.push({key:"base_image",value:i.substring(5).trim(),kind:"Image"});else if(i.startsWith("EXPOSE "))e.push({key:"port",value:i.substring(7).trim(),kind:"Port"});else if(i.startsWith("ENV ")){let r=i.substring(4).trim().split(/\s+|=/);if(r[0]){let o=r[0],a=r.slice(1).join("= ").trim()||"undefined",c="Env";(o.endsWith("_URI")||o.endsWith("_URL")||o.endsWith("_HOST"))&&(c="Service"),e.push({key:o,value:a,kind:c})}}}}function sp(s,e){try{let t=_o.load(s);if(!t||typeof t!="object")return;if(t.services&&typeof t.services=="object")for(let[i,r]of Object.entries(t.services)){if(!r||typeof r!="object")continue;let o=r;if(e.push({key:`service:${i}`,value:i,kind:"Service"}),o.image&&e.push({key:`service:${i}:image`,value:String(o.image),kind:"Image"}),Array.isArray(o.ports)&&o.ports.forEach(a=>{e.push({key:`service:${i}:port`,value:String(a),kind:"Port"})}),o.environment){if(Array.isArray(o.environment))o.environment.forEach(a=>{let[c,...l]=a.split("= ");c&&l.length>0&&e.push({key:`service:${i}:env:${c}`,value:l.join("= "),kind:"Env"})});else if(typeof o.environment=="object")for(let[a,c]of Object.entries(o.environment))e.push({key:`service:${i}:env:${a}`,value:String(c),kind:"Env"})}if(Array.isArray(o.depends_on))o.depends_on.forEach(a=>{e.push({key:`service:${i}:depends_on`,value:a,kind:"Dependency"})});else if(o.depends_on&&typeof o.depends_on=="object")for(let a of Object.keys(o.depends_on))e.push({key:`service:${i}:depends_on`,value:a,kind:"Dependency"})}let n=(i,r="")=>{if(!(!i||typeof i!="object"||Array.isArray(i)))for(let[o,a]of Object.entries(i)){let c=r?`${r}.${o}`:o;if(t.services&&(c.startsWith("services.")||c==="services")){a&&typeof a=="object"&&!Array.isArray(a)&&n(a,c);continue}if(a&&typeof a=="object"&&!Array.isArray(a))n(a,c);else if(a!=null){let l=String(a);if(l==="[object Object]"||l.includes("[object Object]"))continue;let p="Env",u=/^[a-z0-9_-]+$/i.test(l),d=l.includes("://");o.toLowerCase().includes("service")&&(u||d)&&(p="Service"),o.toLowerCase().includes("image")&&(p="Image"),o.toLowerCase().includes("port")&&(p="Port"),(o.endsWith("_URI")||o.endsWith("_URL")||o.endsWith("_HOST"))&&d&&(p="Service"),e.push({key:c,value:l.length>200?l.substring(0,197)+"...":l,kind:p})}}};n(t)}catch{let n=s.match(/^\s{2}([a-z0-9_-]+):/gm);n&&n.forEach(i=>{let r=i.trim().replace(" : ","");r!=="services"&&r!=="version"&&r!=="volumes"&&r!=="networks"&&e.push({key:"service",value:r,kind:"Service"})})}}function rp(s,e){let t=s.split(`
|
|
650
|
+
`);for(let n of t){let i=n.trim();if(i&&!i.startsWith("#")){let r=i.split("=");if(r[0]){let o=r[0].trim(),a=r.slice(1).join("=");a=a.trim().replace(/^['"](.*)['"]$/,"$1");let c="Env",l=a.includes("://");(o.endsWith("_URI")||o.endsWith("_URL")||o.endsWith("_HOST"))&&l&&(c="Service"),e.push({key:o,value:a,kind:c})}}}}function op(s,e){let t=[],n="Contract (Prisma) ",i=/^model\s+(\w+)/gm,r;for(;(r=i.exec(s))!==null;)t.push({key:"model",value:r[1],kind:"Database Model"});let o=/^enum\s+(\w+)/gm;for(;(r=o.exec(s))!==null;)t.push({key:"enum",value:r[1],kind:"Database Enum"});let a=/provider\s*=\s*"([^"]+)"/,c=s.match(a);return c&&t.push({key:"datasource_provider",value:c[1],kind:"Database Config"}),{classification:n,configs:t,content:s}}function ap(s,e){let t=[],n="Contract (GraphQL) ",i=/^(?:type|input|interface|enum)\s+(\w+)/gm,r;for(;(r=i.exec(s))!==null;){let o=r[0],a="GraphQL Type";o.startsWith("input")&&(a="GraphQL Input"),o.startsWith("interface")&&(a="GraphQL Interface"),o.startsWith("enum")&&(a="GraphQL Enum"),t.push({key:"type_definition",value:r[1],kind:a})}return{classification:n,configs:t,content:s}}function cp(s,e){try{let t=JSON.parse(s);if(t.name&&e.push({key:"name",value:t.name,kind:"Service"}),t.description&&e.push({key:"description",value:t.description,kind:"Env"}),t.workspaces){let r=Array.isArray(t.workspaces)?t.workspaces.join("",""):JSON.stringify(t.workspaces);e.push({key:"workspaces",value:r,kind:"Env"})}if(t.scripts){let r=["start","dev","build","test","docker"];for(let o of Object.keys(t.scripts))r.some(a=>o.includes(a))&&e.push({key:`script:${o}`,value:t.scripts[o],kind:"Env"})}let n={...t.dependencies,...t.devDependencies},i=["react","vue","svelte","angular","next","nuxt","express","fastify","nestjs","remix","vite","webpack","tailwindcss","database"];for(let r of Object.keys(n))if(i.some(o=>r.includes(o))){let o=n[r].replace(/[\^~]/,"");e.push({key:`dep:${r}`,value:o,kind:"Dependency"})}}catch{}}function lp(s,e){let t=[],n="Monorepo (Lerna) ";try{let i=JSON.parse(s);t.push({key:"monorepo_type",value:"lerna",kind:"Monorepo"}),i.version&&t.push({key:"lerna_version",value:i.version,kind:"Monorepo"}),i.packages&&(Array.isArray(i.packages)?i.packages:[i.packages]).forEach(o=>{t.push({key:"package_glob",value:o,kind:"Monorepo"})}),i.npmClient&&t.push({key:"npm_client",value:i.npmClient,kind:"Monorepo"})}catch{}return{configs:t,classification:n,content:s}}function pp(s,e){let t=[],n="Monorepo (Turborepo) ";try{let i=JSON.parse(s);if(t.push({key:"monorepo_type",value:"turborepo",kind:"Monorepo"}),i.pipeline)for(let r of Object.keys(i.pipeline)){t.push({key:`pipeline:${r}`,value:r,kind:"Monorepo"});let o=i.pipeline[r];o.dependsOn&&t.push({key:`pipeline:${r}:depends_on`,value:o.dependsOn.join("",""),kind:"Dependency"})}if(i.tasks)for(let r of Object.keys(i.tasks))t.push({key:`task:${r}`,value:r,kind:"Monorepo"})}catch{}return{configs:t,classification:n,content:s}}function up(s,e){let t=[],n="Monorepo (pnpm) ";try{let i=_o.load(s);t.push({key:"monorepo_type",value:"pnpm",kind:"Monorepo"}),i&&i.packages&&(Array.isArray(i.packages)?i.packages:[i.packages]).forEach(o=>{t.push({key:"package_glob",value:o,kind:"Monorepo"})})}catch{}return{configs:t,classification:n,content:s}}V();Ae();import{execSync as Rt}from"child_process";import dn from"path";import fs from"fs";function me(s){try{if(!fs.existsSync(dn.join(s,".git")))return null;let e=Rt("git rev-parse --abbrev-ref HEAD",{cwd:s,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim();return e==="HEAD"?Rt("git rev-parse --short HEAD",{cwd:s,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim():e.replace(/[\/\\:*"<>|?]/g,"-")}catch{return null}}function De(s){try{return fs.existsSync(dn.join(s,".git"))?Rt("git rev-parse HEAD",{cwd:s,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim():null}catch{return null}}function So(s,e=50){try{let t=Rt(`git rev-list --max-count=${e} HEAD`,{cwd:s,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim();return t?t.split(`
|
|
651
|
+
`):[]}catch{return[]}}function wo(s,e,t){try{return Rt(`git merge-tree --write-tree ${e} ${t}`,{cwd:s,stdio:["ignore","ignore","ignore"]}),!1}catch{return!0}}var dp=new Set([".ts",".tsx",".yaml",".yml",".php",".py",".go",".prisma",".graphql",".gql"]),mp=new Set(["package.json","lerna.json","turbo.json","pnpm-workspace.yaml"]),hp=new Set(["node_modules",".git","dist","build","vendor",".next",".cache","coverage"]);function Eo(s){let e=s.split("/");for(let i of e)if(hp.has(i))return!1;if(s.endsWith(".min.js"))return!1;let t=dn.basename(s);if(t.startsWith("Dockerfile")||t.startsWith(".env")||mp.has(t))return!0;let n=dn.extname(t).toLowerCase();return dp.has(n)}function fp(s){let e=s.trim(),t=e.indexOf(" -> ");if(t!==-1)return e.substring(t+4);let n=e.split(/\s+/);return n.length>=2?n[n.length-1]:e}function xo(s,e){try{if(!fs.existsSync(dn.join(s,".git")))return!0;let t=De(s);if(!t)return!0;if(e&&e!==t){let i=Rt(`git diff --name-only ${e} ${t}`,{cwd:s,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim();if(i&&i.split(`
|
|
652
|
+
`).some(r=>r&&Eo(r)))return!0}let n=Rt("git status --porcelain",{cwd:s,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim();return n?n.split(`
|
|
653
|
+
`).some(i=>i?Eo(fp(i)):!1):!1}catch{return!0}}V();q();import{execSync as vo}from"child_process";var kt=S.child({module:"nano-repair"}),qe=class{intentLogs;exports;missions;repoPath;constructor(e){let{intentLogs:t,exports:n,missions:i}=O.getInstance(e);this.intentLogs=t,this.exports=n,this.missions=i,this.repoPath=e}detectAndRepairShifts(){let e=this.intentLogs.findRepairableOrphans();if(e.length===0)return{repaired:0,failed:0};kt.info({count:e.length},"Detected orphaned intent logs. Attempting recovery...");let t=0,n=0;for(let i of e){let r=this.exports.findByNameAndFile(i.symbol_name,i.file_path);if(r.length>0){let a=r.find(c=>c.signature===i.signature)||r[0];this.intentLogs.update(i.id,{symbol_id:a.id}),kt.info({logId:i.id,symbol:i.symbol_name},"Relinked symbol in same file"),t++;continue}let o=this.exports.findByNameGlobal(i.symbol_name);if(o.length>0){let a=o.filter(c=>c.file_path!==i.file_path);if(a.length>0){let c=a.find(l=>l.signature===i.signature)||a[0];this.intentLogs.update(i.id,{symbol_id:c.id,file_path:c.file_path}),kt.info({logId:i.id,symbol:i.symbol_name,oldPath:i.file_path,newPath:c.file_path},"Detected Nano-Repair Shift (file move)"),t++;continue}}n++}return t>0&&kt.info({repaired:t,failed:n},"Nano-Repair recovery complete"),{repaired:t,failed:n}}syncLifecycle(e={}){let t=e.enableContextPivot===!0,n=e.enableMergeSentinel===!0,i="HEAD";try{i=vo("git rev-parse --abbrev-ref HEAD",{cwd:this.repoPath,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return{suspended:0,resumed:0,completed:0,contextPivotEnabled:t,mergeSentinelEnabled:n}}if(!i)return{suspended:0,resumed:0,completed:0,contextPivotEnabled:t,mergeSentinelEnabled:n};let r=0,o=0;if(t){let c=this.missions.findActive();for(let l of c)l.git_branch&&l.git_branch!==i&&(this.missions.updateStatus(l.id,"suspended"),kt.info({missionId:l.id,branch:l.git_branch,current:i},"Context Pivot: Suspended mission"),r++);o=this.missions.resumeByBranch(i)}let a=0;if(n){let c=[];try{c=vo(`git branch --merged "${i}"`,{cwd:this.repoPath,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
|
|
654
|
+
`).map(p=>p.trim().replace(/^\* /,"")).filter(p=>p&&p!==i)}catch{}if(c.length>0){let l=this.missions.findMergedMissions(i,c);for(let p of l)this.missions.updateStatus(p.id,"completed"),kt.info({missionId:p.id,branch:p.git_branch},"Merge Sentinel: Auto-completed mission"),a++}}return(r>0||o>0||a>0)&&kt.info({suspended:r,resumed:o,completed:a},"Git-Native Lifecycle Sync complete"),{suspended:r,resumed:o,completed:a,contextPivotEnabled:t,mergeSentinelEnabled:n}}};q();St();import{Worker as gp}from"node:worker_threads";import{cpus as yp}from"node:os";import{fileURLToPath as bp}from"node:url";import{dirname as _p,join as Ep}from"node:path";import{existsSync as Sp}from"node:fs";var To=bp(import.meta.url),wp=_p(To),xp=To.endsWith(".ts");function vp(){if(xp)return null;let s=Ep(wp,"worker.js");return Sp(s)?s:_e("dist/logic/parser/worker.js")}var gs=class{workers=[];taskQueue=[];pendingTasks=new Map;taskIdCounter=0;initialized=!1;initPromise;shutdownRequested=!1;numWorkers;initTimeout;constructor(e={}){this.numWorkers=e.numWorkers??Math.max(1,Math.min(4,yp().length-1)),this.initTimeout=e.initTimeout??3e4}async initialize(){if(!this.initialized)return this.initPromise?this.initPromise:(this.initPromise=this._doInitialize(),this.initPromise)}async _doInitialize(){let e;try{S.info({numWorkers:this.numWorkers},"Initializing parser worker pool");let t=new Promise((n,i)=>{e=setTimeout(()=>i(new Error(`Parser pool initialization timed out after ${this.initTimeout}ms`)),this.initTimeout)});if(await Promise.race([this._initializeWorkers(),t]),e&&clearTimeout(e),this.shutdownRequested){this.initialized=!1,this.initPromise=void 0;return}this.initialized=!0,S.info({numWorkers:this.workers.length},"Parser worker pool ready")}catch(t){throw e&&clearTimeout(e),this.initPromise=void 0,this.initialized=!1,await this.shutdown(),t}}async _initializeWorkers(){let e=vp();if(!e)throw new Error("Parser worker pool not available in development mode (tsx). Use main-thread fallback.");S.debug({workerPath:e},"Resolved parser worker path");let t=[];for(let n=0;n<this.numWorkers;n++)t.push(this.createWorker(e,n));await Promise.all(t)}async createWorker(e,t){return new Promise((n,i)=>{let r=setTimeout(()=>{i(new Error(`Parser worker ${t} initialization timed out`))},this.initTimeout),o=new gp(e,{execArgv:process.execArgv}),a={worker:o,busy:!1,currentTaskId:null};o.on("message",c=>{if(c.type==="ready"){if(clearTimeout(r),this.shutdownRequested){o.terminate().catch(()=>{}),n();return}this.workers.push(a),S.debug({workerIndex:t},"Parser worker ready"),n()}else c.type==="result"&&c.id?this.handleTaskComplete(a,c.id,c.result):c.type==="error"&&c.id&&this.handleTaskError(a,c.id,new Error(c.error||"Unknown error"))}),o.on("error",c=>{if(clearTimeout(r),S.error({err:c,workerIndex:t},"Parser worker error"),a.currentTaskId&&this.handleTaskError(a,a.currentTaskId,c),!this.initialized){i(c);return}let l=this.workers.indexOf(a);l!==-1&&this.workers.splice(l,1),!this.shutdownRequested&&this.initialized&&this.createWorker(e,t).catch(p=>{S.error({err:p},"Failed to replace crashed parser worker")})}),o.on("exit",c=>{c!==0&&!this.shutdownRequested&&S.warn({workerIndex:t,code:c},"Parser worker exited unexpectedly")})})}handleTaskComplete(e,t,n){let i=this.pendingTasks.get(t);i&&(this.pendingTasks.delete(t),i.resolve(n)),e.busy=!1,e.currentTaskId=null,this.processQueue()}handleTaskError(e,t,n){let i=this.pendingTasks.get(t);i&&(this.pendingTasks.delete(t),i.reject(n)),e.busy=!1,e.currentTaskId=null,this.processQueue()}processQueue(){if(this.taskQueue.length===0)return;let e=this.workers.find(n=>!n.busy);if(!e)return;let t=this.taskQueue.shift();t&&(e.busy=!0,e.currentTaskId=t.id,this.pendingTasks.set(t.id,t),e.worker.postMessage({type:"parse",id:t.id,filePath:t.filePath}))}async parseFile(e){return this.initialized||await this.initialize(),new Promise((t,n)=>{let r={id:`parse_${++this.taskIdCounter}`,filePath:e,resolve:t,reject:n};this.taskQueue.push(r),this.processQueue()})}get workerCount(){return this.workers.length}get busyWorkers(){return this.workers.filter(e=>e.busy).length}get queueSize(){return this.taskQueue.length}get isInitialized(){return this.initialized}async shutdown(){if(this.shutdownRequested=!0,this.initPromise)try{await this.initPromise}catch{}if(!this.initialized&&this.workers.length===0){this.shutdownRequested=!1,this.initPromise=void 0;return}S.info({numWorkers:this.workers.length},"Shutting down parser worker pool");let e=this.workers.map(t=>new Promise(n=>{t.worker.postMessage({type:"shutdown"}),t.worker.once("exit",()=>n()),setTimeout(()=>{t.worker.terminate().then(()=>n())},5e3)}));await Promise.all(e),this.workers=[],this.taskQueue=[],this.pendingTasks.clear(),this.initialized=!1,this.shutdownRequested=!1,this.initPromise=void 0,S.info("Parser worker pool shutdown complete")}},Ut=null;function Ro(s){return Ut||(Ut=new gs(s)),Ut}async function ko(){Ut&&(await Ut.shutdown(),Ut=null)}V();q();It();ys();bs();_s();import{execSync as Yo}from"child_process";var fi=S.child({module:"heritage-analyzer"}),gi=class{repos;repoPath;constructor(e){this.repos=O.getInstance(e),this.repoPath=e}analyzeHeritage(e=20){try{fi.info({limit:e},"Analyzing repository heritage...");let t=Yo(`git log -n ${e} --pretty=format:"%H|%at|%an|%s"`,{cwd:this.repoPath,encoding:"utf-8"});if(!t)return;let n=t.split(`
|
|
655
|
+
`).filter(Boolean);for(let i of n){let[r,o,a,c]=i.split("|"),l=this.analyzeCommitImpact(r);if(l.significant){let p=Array.from(l.layers).join(", "),u=`Heritage: ${c} (by ${a}). Touched ${l.fileCount} files across [${p}].`;this.repos.intentLogs.importHeritage(u,r,parseInt(o,10),.7),fi.debug({sha:r,subject:c},"Logged heritage move")}}fi.info("Heritage analysis complete.")}catch(t){fi.warn({err:t.message},"Failed to run heritage analysis")}}analyzeCommitImpact(e){let t=new Set,n=0;try{let r=Yo(`git diff-tree --no-commit-id --name-only -r ${e}`,{cwd:this.repoPath,encoding:"utf-8"}).split(`
|
|
656
|
+
`).filter(Boolean);n=r.length;for(let c of r){let l=this.classifyPathOnly(c);l!=="Unknown"&&t.add(l)}let o=t.has("Entry")||t.has("Data")||t.has("Infrastructure"),a=t.size>=2||n>5;return{significant:o||a,layers:t,fileCount:n}}catch{return{significant:!1,layers:t,fileCount:0}}}classifyPathOnly(e){let t=e.startsWith("/")?e:"/"+e;return Es.some(n=>n.test(t))?"Test":ci.some(n=>n.test(t))||ai.some(n=>n.test(t))?"Entry":mn.some(n=>n.test(t))?"Data":pi.some(n=>n.test(t))?"Utility":ui.some(n=>n.test(t))?"Entry":di.some(n=>n.test(t))?"Data":mi.some(n=>n.test(t))?"Entry":hi.some(n=>n.test(t))?"Data":Ss.some(n=>n.test(t))?"Infrastructure":/\.(service|logic|usecase|interactor|manager)\.(ts|js|php|py)$/i.test(t)||li.some(n=>n.test(t))?"Logic":"Unknown"}};Ze();St();import{spawn as Cp}from"node:child_process";import ws from"node:os";import{resolve as Ip}from"node:path";import{existsSync as Ko}from"node:fs";import{fileURLToPath as Lp}from"node:url";import{dirname as $p}from"node:path";var Qo=Lp(import.meta.url),Ap=$p(Qo),Pp=ws.constants.priority.PRIORITY_LOWEST??ws.constants.priority.PRIORITY_LOW;function Mp(){if(Qo.endsWith(".ts"))return null;let s=Ip(Ap,"../../entry/ember/index.js");if(Ko(s))return s;let e=_e("dist/entry/ember/index.js");return Ko(e)?e:null}function Xo(s){try{let t=Te(s).prepare("SELECT key, value FROM ember_state WHERE key IN ('status','progress','pid')").all(),n=new Map(t.map(i=>[i.key,i.value??""]));return{status:n.get("status")??"idle",progress:n.get("progress")??"0/0",pid:n.get("pid")??null}}catch{return{status:"idle",progress:"0/0",pid:null}}}function Np(s,e){let t=Te(s);t.transaction(()=>{let n=t.prepare("INSERT OR REPLACE INTO ember_state (key, value, updated_at) VALUES (?, ?, unixepoch())");n.run("pid",String(e)),n.run("status","running"),n.run("repo_path",s)})()}function Zo(s){let{pid:e}=Xo(s);if(!e)return!1;let t=parseInt(e,10);if(!Number.isFinite(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch{return!1}}function ea(s){let e=Mp();if(!e)return;let t=Cp(process.execPath,[e,s],{detached:!0,stdio:"ignore",env:{...process.env,EMBER_MODE:"1"}});if(t.pid!=null){try{ws.setPriority(t.pid,Pp)}catch{}t.unref(),Np(s,t.pid)}}function yi(s){let{status:e,progress:t}=Xo(s);return{status:e,progress:t}}var Fp=Op.cpus().length||4,Wp=Qn.DEFAULT_CONCURRENCY;function ia(s,e=[]){if(!Array.isArray(s))return e;for(let t of s)!t||typeof t!="object"||(e.push(t),Array.isArray(t.members)&&t.members.length>0&&ia(t.members,e));return e}function ta(s){if(typeof s!="number"||!Number.isFinite(s))return null;let e=Math.trunc(s);return e>0?e:null}function sa(s){let e=typeof s?.content=="string"&&s.content.length>0?s.content.split(`
|
|
657
|
+
`).length:0,t=ia(s?.exports),n=0,i=0,r=0,o=0;for(let a of t){let c=ta(a?.line??a?.start_line),l=ta(a?.endLine??a?.end_line??c);if(!c||!l||l<c||e>0&&l>e){i++;continue}n++,l>c&&o++,e>0&&c===e&&l===e&&r++}return{total:t.length,valid:n,invalid:i,eofCollapsed:r,multiLine:o,lineCount:e}}function Hp(s){let e=sa(s);if(e.total===0||e.lineCount===0)return!1;if(e.invalid>0)return!0;let t=e.eofCollapsed/e.total;return e.eofCollapsed>=3&&t>=.5||e.total>=2&&e.eofCollapsed===e.total}function na(s){let e=sa(s);return e.valid*2+e.multiLine*2-e.eofCollapsed*3-e.invalid*4}async function X(s,e=Wp,t=!1,n=!0,i){let r=O.getInstance(s),o=r.files.database,a=Ke(s),c=a.concurrency??e;if(Or(),!t&&Xe(s)){let g=nn(s),b=De(s);if(g&&!xo(s,g))return os(),S.debug({repoPath:s,commit:b},"Index is current, skipping re-index (fast-path)"),o}ri(s);let l=r.files.findAll(),p=new Map(l.map(g=>[g.path,{mtime:g.mtime,hash:g.content_hash}])),u=Date.now();i?.({phase:"scan",current:0,total:0,message:"Scanning repository..."});let d=await Jr(s,a.ignore),h=new Map(d.map(g=>[g.path,g.mtime])),m=l.filter(g=>!h.has(g.path)).map(g=>g.path),f=l.length===0,_=[];if(t||f)_.push(...d);else{let g=d.filter(R=>{let k=p.get(R.path);return!k||k.mtime!==R.mtime}),b=xs(c*4),w=g.map(R=>b(async()=>{let k=p.get(R.path);if(!k||!k.hash)return R;try{let D=await Dp.promises.readFile(R.path,"utf8");return sr(D,k.hash)?R:(r.files.updateMtime(R.path,R.mtime),null)}catch{return null}})),x=await Promise.all(w);_.push(...x.filter(R=>R!==null))}if(m.length===0&&_.length===0){os();let g=De(s);return Yi(s,g||void 0),o}if(f?S.info({totalFiles:d.length},"Starting initial repository indexing..."):S.info({toDelete:m.length,toProcess:_.length},"Syncing repository updates..."),m.length>0&&r.files.deletePaths(m),_.length>0){Wr(),n?(Pn(!0),Ot().initialize().catch(()=>{})):Pn(!1);let g=/\.(ts|tsx|php|py|go|js|jsx|mjs|cjs)$/,b=[],w=[];for(let $ of _)g.test(vs.basename($.path))?b.push($):w.push($);let x=0,R=_.length,k=!1,D=Ro();try{await D.initialize(),k=!0,S.info({workers:D.workerCount},"Parser worker pool active")}catch($){S.warn({err:$},"Parser worker pool failed to initialize, falling back to main-thread parsing"),k=!1}let U=async($,W)=>{let L=W;if(k&&Hp(W))try{let F=await pn($.path);na(F)>na(W)&&(S.warn({filePath:$.path},"Detected suspicious worker parse ranges; using main-thread parse output"),L=F)}catch(F){S.warn({filePath:$.path,err:F instanceof Error?F.message:String(F)},"Main-thread parse retry failed after suspicious worker parse")}let A=L.imports?.map(F=>({...F,resolved_path:Tt(F.module,$.path,s)})),H=L.content?Nt(L.content):null;return x++,(x%50===0||x===R)&&S.info({completed:x,total:R},"Parsing files..."),i?.({phase:"parse",current:x,total:R,message:`Parsing ${vs.basename($.path)}`}),{meta:$,...L,imports:A,embedding:null,kind:"code",contentHash:H}},P;if(k)P=b.map($=>D.parseFile($.path).then(W=>U($,W),W=>(x++,S.error({path:$.path,error:W},"Worker parse failed"),{meta:$,exports:[],imports:[],content:"",kind:"error"})));else{let $=f?Math.max(c,Math.min(Fp-1,16)):c,W=xs($);P=b.map(L=>W(async()=>{try{let A=await pn(L.path);return U(L,A)}catch(A){return x++,S.error({path:L.path,error:A},"Failed to parse file"),{meta:L,exports:[],imports:[],content:"",kind:"error"}}}))}let E=xs(c),T=w.map($=>E(async()=>{try{let W=bo($.path),L=W.content?Nt(W.content):null;return x++,(x%50===0||x===R)&&S.info({completed:x,total:R},"Parsing configs..."),i?.({phase:"parse",current:x,total:R,message:`Parsing config ${vs.basename($.path)}`}),{meta:$,...W,embedding:null,kind:"config",contentHash:L}}catch(W){return x++,S.error({path:$.path,error:W},"Failed to parse config"),{meta:$,exports:[],imports:[],content:"",kind:"error"}}}));S.info({total:R,codeFiles:b.length,configFiles:w.length,useParserPool:k},"Phase 1: Parsing all files...");let I=Date.now(),M=(await Promise.all([...P,...T])).filter(Boolean),N=Date.now()-I;if(an("parse",N),S.info({count:M.length,time:`${(N/1e3).toFixed(1)}s`},"Phase 1 complete"),k&&ko().catch(()=>{}),o.pragma("synchronous = NORMAL"),o.pragma("cache_size = -64000"),n){let $=[];M.forEach((C,B)=>{"summary"in C&&C.summary&&$.push({fileIdx:B,text:C.summary})}),S.info("Phase 2+3: Generating file-summary embeddings + persisting in parallel..."),i?.({phase:"embed",current:0,total:M.length,message:"Generating embeddings..."});let W=Date.now(),L=(async()=>{let C=[];return $.length>0&&(S.info({count:$.length}," \u2192 Generating file summary embeddings..."),C=await ns($.map(B=>B.text),256),S.info({count:$.length}," \u2713 File summaries complete")),C})();i?.({phase:"persist",current:0,total:M.length,message:"Saving to database..."});let A=Date.now();r.files.batchSaveIndexResults(M,s,Nt,Tt);let H=Date.now()-A;an("persist",H),S.info({time:`${(H/1e3).toFixed(1)}s`},"Structural persist complete");let F=await L,v=Date.now()-W;if(an("embed",v),S.info({time:`${(v/1e3).toFixed(1)}s`},"File-summary embeddings complete"),F.length>0){let C=o.prepare("UPDATE files SET embedding = ? WHERE path = ?"),B=o.transaction(J=>{for(let z of J)C.run(z.embedding?JSON.stringify(z.embedding):null,z.path)}),j=$.map((J,z)=>({path:M[J.fileIdx].meta.path,embedding:F[z]}));B(j),S.info({count:j.length},"File embedding column updated")}}else{i?.({phase:"persist",current:0,total:M.length,message:"Saving to database..."});let $=Date.now();r.files.batchSaveIndexResults(M,s,Nt,Tt),an("persist",Date.now()-$)}o.pragma("synchronous = FULL"),o.pragma("cache_size = -2000")}if(f||_.length>0){let g=De(s);Yi(s,g||void 0)}if(n&&!Zo(s)&&ea(s),(_.length>0||m.length>0)&&new qe(s).detectAndRepairShifts(),f||n)try{new gi(s).analyzeHeritage(50)}catch(g){S.warn({err:g.message},"Heritage sync deferred")}return Fr(Date.now()-u),i?.({phase:"complete",current:_.length,total:_.length,message:"Indexing complete"}),o}V();async function bi(s,e=Qn.DEFAULT_CONCURRENCY,t="detailed",n,i){S.info({repo:s,level:t,subPath:n},"Ensuring cache is up-to-date..."),await X(s,e);let{files:r,exports:o,imports:a}=O.getInstance(s),c=n?r.findInSubPath(s,n):r.findAll(),l=Ke(s),p=zp(),u=ra.join(s,".gitignore");if(oa.existsSync(u)&&p.add(oa.readFileSync(u,"utf8")),l.ignore&&l.ignore.length>0&&p.add(l.ignore),p.add(Kn),c=c.filter(b=>{let w=ra.relative(s,b.path);return!p.ignores(w)}),S.info({count:c.length},"Fetching data from DB..."),t==="lite"){let b=c.map(w=>({path:w.path,mtime:w.mtime}));return Yn(b,s,t,i)}if(t==="summaries"){let b=c.map(w=>({path:w.path,mtime:w.mtime,classification:w.classification||void 0,summary:w.summary||void 0}));return Yn(b,s,t,i)}let d=c.map(b=>b.path),h=o.findByFiles(d),m=t==="detailed"?a.findByFiles(d):[],f=new Map;for(let b of h){let w=f.get(b.file_path)||[];w.push(b),f.set(b.file_path,w)}let _=new Map;for(let b of m){let w=_.get(b.file_path)||[];w.push(b),_.set(b.file_path,w)}let g=c.map(b=>{let x=(f.get(b.path)||[]).map(k=>({name:k.name,kind:k.kind,signature:k.signature,line:k.start_line}));t==="structure"?x=x.map(k=>({name:k.name,kind:k.kind,line:k.line})):t==="signatures"&&(x=x.map(k=>({name:k.name,kind:k.kind,signature:k.signature,line:k.line})));let R=[];return t==="detailed"&&(R=(_.get(b.path)||[]).map(D=>({module:D.module_specifier,resolved_path:D.resolved_path}))),{path:b.path,mtime:b.mtime,classification:b.classification||void 0,summary:b.summary||void 0,exports:x,imports:R.length>0?R:void 0,chunks:[]}});return S.info({count:g.length},"Building hierarchical project tree..."),Yn(g,s,t,i)}async function aa(s,e){let t=Up.resolve(s);try{await Y(async()=>{pe("\u{1F311} Liquid Shadow: Topological Mapping");let n=parseInt(e.depth,10),i=await bi(t,n,"detailed",e.subPath);console.log(` ${y.bold("Root")}: ${y.cyan(t)}`),e.subPath&&console.log(` ${y.bold("Subpath")}: ${y.yellow(e.subPath)}`),console.log("");let r=o=>({name:o.name,info:o.type==="directory"?`${o.children?.length||0} items`:o.size,color:o.type==="directory"?"blue":"white",children:o.children?.map(r)});ss([r(i)]),console.log(""),Pe("Mapping concluded.")})}finally{await Q(t)}}import la from"path";import jp from"fs";q();import ce from"path";import Ts from"fs";var _i=S.child({module:"path-resolver"}),hn=class{repoPath;constructor(e){this.repoPath=ce.isAbsolute(e)?ce.normalize(e):ce.resolve(process.cwd(),e)}resolve(e){if(!e)return this.repoPath;if(e.includes("\0"))throw _i.error({inputPath:e},"Path contains null bytes - possible attack"),new Error("Invalid path: contains null bytes");let t;if(ce.isAbsolute(e)?t=ce.normalize(e):t=ce.join(this.repoPath,e),t=ce.normalize(t),!this.isWithinRoot(t))throw _i.warn({inputPath:e,resolved:t},"Path traversal attempt blocked"),new Error(`Access denied: path '${e}' is outside the repository root`);return t}resolveAndValidate(e){try{let t=this.resolve(e);return Ts.existsSync(t)?t:(_i.debug({inputPath:e,resolved:t},"Path does not exist"),null)}catch(t){return _i.error({inputPath:e,error:t},"Error validating path"),null}}isWithinRoot(e){try{let t=ce.resolve(e),n=ce.resolve(this.repoPath),i=ce.relative(n,t);if(i.startsWith("..")||ce.isAbsolute(i))return!1;if(Ts.existsSync(t)){let o=Ts.realpathSync(t),a=ce.relative(n,o);if(a.startsWith("..")||ce.isAbsolute(a))return!1}return!0}catch{return!1}}getRelative(e){let t=ce.normalize(e);return ce.relative(this.repoPath,t)}resolveBatch(e){return e.map(t=>this.resolve(t))}static normalize(e){return ce.normalize(e)}static isPathWithinRoot(e,t){let n=ce.resolve(e),i=ce.resolve(t),r=ce.relative(n,i);return r===""||!r.startsWith("..")&&!ce.isAbsolute(r)}};function ca(s){return new hn(s)}async function pa(s,e){let t=la.resolve(s);await Y(async()=>{if(pe("\u{1F311} Liquid Shadow: Intelligence Deployment"),console.log(` ${y.bold("Target")}: ${y.cyan(t)}`),console.log(` ${y.bold("Objective")}: ${e.output?y.magenta("Data Extraction"):y.green("Semantic Mapping")}`),console.log(""),!e.output){let i=Re();i.start("Engaging intelligence engines...");let r="",o=a=>{if(a.phase!==r){r=a.phase;let c={scan:"\u{1F4E1} Scanning topography",parse:"\u{1F9E9} Parsing symbols",embed:"\u{1F9E0} Generating vectors",persist:"\u{1F4BE} Hardening index",complete:"\u{1F3C1} Mapping complete"}[a.phase]||a.phase;i.message(`${c}...`)}if(a.total>0&&a.current>0){let c=Math.round(a.current/a.total*100);i.message(`${r==="parse"?"Parsing":"Processing"}: ${a.current}/${a.total} (${c}%)`)}};try{await X(t,void 0,e.force,e.deep??!0,o),i.message("\u{1FA79} Running Nano-Repair healing...");let c=new qe(t).detectAndRepairShifts();i.stop("Intelligence mapping successfully concluded."),console.log(""),console.log(` ${y.bold("Next Steps:")}`),console.log(` ${y.dim("view your repo stats")} -> ${y.bold(y.cyan("liquid-shadow dashboard"))}`),console.log(` ${y.dim("start a chat search")} -> ${y.bold(y.cyan('liquid-shadow search-concept "your query"'))}`),console.log(""),Pe("Liquid Shadow is online.")}catch(a){throw i.stop(`Operation failed: ${a.message}`),a}finally{await Q(t)}return}let n=Re();n.start("Engaging intelligence engines...");try{let i=await bi(t,5,e.level,e.subPath),r=la.resolve(e.output);if((process.env.LIQUID_SHADOW_SANDBOX==="1"||process.env.LIQUID_SHADOW_SANDBOX==="true")&&!hn.isPathWithinRoot(t,r))throw new Error("Sandbox mode: output path must be inside the repository. Set LIQUID_SHADOW_SANDBOX=0 to allow external paths.");jp.writeFileSync(r,JSON.stringify(i,null,2)),n.stop(`Data extraction saved: ${y.bold(y.cyan(r))}`),Pe("Extraction complete.")}catch(i){throw n.stop(`Extraction failed: ${i.message}`),i}finally{await Q(t)}})}import{performance as ua}from"perf_hooks";import Bp from"path";V();async function da(s){let e=Bp.resolve(s);await Y(async()=>{console.log(`
|
|
658
|
+
${y.bold("Performance Benchmark - Liquid Shadow Intelligence")}`),console.log(` ${y.gray("Repository: ")} ${e}`),console.log(` ${y.yellow("Starting fresh index (DB deleted)...")}
|
|
659
|
+
`);let t=ua.now();try{await X(e,10,!0);let n=ua.now()-t,i=O.getInstance(e),r=i.files.getCount(),o=i.exports.getCount(),a=i.exports.getWithEmbeddingsCount();se("Benchmark Results",`${y.bold("Total Time")}: ${n.toFixed(2)}ms (${(n/1e3).toFixed(2)}s)
|
|
660
|
+
${y.bold("Files Processed")}: ${y.cyan(r.toString())}
|
|
661
|
+
${y.bold("Symbols Extracted")}: ${y.cyan(o.toString())}
|
|
662
|
+
${y.bold("Symbols Embedded")}: ${y.cyan(a.toString())} (${(a/o*100).toFixed(1)}%)
|
|
663
|
+
`+"\u2500".repeat(40)+`
|
|
664
|
+
${y.bold("Files/sec")}: ${y.green((r/(n/1e3)).toFixed(2))}
|
|
665
|
+
${y.bold("Symbols/sec")}: ${y.green((o/(n/1e3)).toFixed(2))}
|
|
666
|
+
${y.bold("ms per file")}: ${y.yellow((n/r).toFixed(2))}`,"green")}catch(n){throw console.error(`
|
|
667
|
+
Benchmark failed during execution:`,n),n}finally{await Q(e)}})}import xi from"path";import Ee from"path";import ks from"fs";var Gp=/[\x00-\x1f\x7f]/g,qp=/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g;function Rs(s){if(typeof s!="string")throw new Error("Invalid path: expected string");if(s.includes("\0"))throw new Error("Invalid path: null bytes are not allowed");if(s.replace(Gp,"").length!==s.length)throw new Error("Invalid path: control characters are not allowed");return s.trim()}function Ei(s,e=4096){if(typeof s!="string")return"";let t=s.replace(qp,"").trim();return t.length>e?t.slice(0,e):t}Ze();function Vp(s){let e=Ee.isAbsolute(s)?Ee.normalize(s):Ee.resolve(process.cwd(),s),t=Ee.parse(e).root;for(;e!==t;){if(ks.existsSync(Ee.join(e,".liquid-shadow.db"))||ks.existsSync(Ee.join(e,".git"))||ks.existsSync(Ee.join(e,"package.json")))return e;let n=Ee.dirname(e);if(n===e)break;e=n}return null}function Ve(s){let e=s?.repoPath?String(s.repoPath):void 0,t=s?.filePath?String(s.filePath):void 0;e&&(e=Rs(e)),t&&(t=Rs(t));let n;if(e)Ee.isAbsolute(e)||(e=Ee.resolve(process.cwd(),e)),n=e;else if(t){let o=Ee.resolve(process.cwd(),t);n=Vp(Ee.dirname(o))||process.cwd()}else n=process.cwd();n=Ee.normalize(n);let i=ca(n),r;return t&&(r=i.resolve(t)),{...s,repoPath:n,filePath:r,resolver:i}}V();q();import $t from"fs";import fe from"path";import{Visitor as Jp}from"@swc/core/Visitor.js";var Si=class extends Jp{calls=new Set;apiCalls=[];imports=new Map;axiosInstances=new Map([["axios",""],["http",""],["appApi",""],["restApi",""],["adminApi",""]]);visitImportDeclaration(e){let t=e.source.value;for(let n of e.specifiers)(n.type==="ImportDefaultSpecifier"||n.type==="ImportSpecifier")&&this.imports.set(n.local.value,t);return super.visitImportDeclaration(e)}visitCallExpression(e){if(e.callee.type==="Identifier"){let t=e.callee.value;this.calls.add(t),(t==="axios"||t==="http")&&e.arguments.length>0&&this.extractApiCallFromConfig(e.arguments[0].expression)}else if(e.callee.type==="MemberExpression"){let t=e.callee.property.value,n=r=>{if(!r)return"?";if(r.type==="Identifier")return r.value;if(r.type==="ThisExpression")return"this";if(r.type==="MemberExpression"){let o=n(r.object),a=r.property.value||"?";return`${o}.${a}`}return r.type==="TsNonNullExpression"||r.type==="TsAsExpression"||r.type==="ParenthesisExpression"?n(r.expression):"?"},i=n(e.callee.object);if(i!=="?"&&t){if(this.calls.add(`${i}.${t}`),i==="axios"||i==="http"||this.axiosInstances.has(i)){let r=this.axiosInstances.get(i)||"";this.extractApiCall(t,e.arguments,r)}if((i.toLowerCase().includes("pubsub")||i==="pubSubClient"||i.endsWith(".pubSubClient"))&&t!=="subscribe"){let r=t;if((t==="publish"||t==="publishMessage"||t==="publishTaskByNameAndPayload")&&e.arguments.length>0)for(let o of e.arguments){let a=o.expression;if(a.type==="ObjectExpression"){let c=a.properties.find(l=>l.key?.type==="Identifier"&&(l.key.value==="action"||l.key.value==="type")||l.key?.type==="StringLiteral"&&(l.key.value==="action"||l.key.value==="type"));if(c&&c.value?.type==="StringLiteral"){r=c.value.value;break}}if(a.type==="CallExpression"&&a.callee.type==="MemberExpression"&&a.callee.object.value==="JSON"&&a.callee.property.value==="stringify"&&a.arguments.length>0){let c=a.arguments[0].expression;if(c.type==="ObjectExpression"){let l=c.properties.find(p=>p.key?.type==="Identifier"&&(p.key.value==="action"||p.key.value==="type")||p.key?.type==="StringLiteral"&&(p.key.value==="action"||p.key.value==="type"));if(l&&l.value?.type==="StringLiteral"){r=l.value.value;break}}}}this.apiCalls.push({method:"PUBSUB",url:r})}}}return e.callee.type==="Identifier"&&e.callee.value==="fetch"&&this.extractApiCall("GET",e.arguments),super.visitCallExpression(e)}visitNewExpression(e){return e.callee.type==="Identifier"&&this.calls.add(e.callee.value),super.visitNewExpression(e)}visitVariableDeclarator(e){if(e.init&&e.init.type==="CallExpression"){let t=e.init.callee;if(t.type==="MemberExpression"&&t.property.value==="create"&&t.object.value==="axios"){let i=e.init.arguments[0]?.expression;if(i&&i.type==="ObjectExpression"){let r=i.properties.find(o=>o.key.value==="baseURL");if(r){let o="?";r.value.type==="StringLiteral"?o=r.value.value:r.value.type==="Identifier"&&(o=`\${${r.value.value}}`),e.id.type==="Identifier"&&this.axiosInstances.set(e.id.value,o)}}}}return super.visitVariableDeclarator(e)}extractApiCallFromConfig(e){if(e&&e.type==="ObjectExpression"){let t=e.properties.find(i=>i.key.type==="Identifier"&&i.key.value==="url"||i.key.type==="StringLiteral"&&i.key.value==="url"),n=e.properties.find(i=>i.key.type==="Identifier"&&i.key.value==="method"||i.key.type==="StringLiteral"&&i.key.value==="method");if(t&&t.value){let i=n?.value?.value||"GET",r=this.resolveUrlValue(t.value);r!=="?"&&this.apiCalls.push({method:i.toUpperCase(),url:r})}}}resolveUrlValue(e){return e.type==="StringLiteral"?e.value:e.type==="TemplateLiteral"?e.quasis.map(t=>t.cooked).join("*"):"?"}visitTsType(e){return e}extractApiCall(e,t,n=""){if(t.length>0){let i=t[0].expression,r=this.resolveUrlValue(i);if(r!=="?"){if(n&&n!=="?"){let o=n.endsWith("/")||r.startsWith("/")?"":"/";r=`${n}${o}${r}`}this.apiCalls.push({method:e.toUpperCase(),url:r})}}}},jt=class{calls=new Set;apiCalls=[];imports=new Map;visit(e,t){if(t===".php"){let n=/(?:([a-zA-Z0-9_$->:\(\)]*)?(?:->|::))?([a-zA-Z0-9_]+)\s*\(([\s\S]*?)\)/g,i;for(;(i=n.exec(e))!==null;){let r=i[1]||"",o=i[2],a=i[3];if(this.calls.add(o),r&&!["$this","self","parent"].includes(r)&&this.calls.add(`${r}${r.includes("::")?"::":"->"}${o}`),["save","delete","update","create","first","all","where","get","find"].includes(o)&&r&&!["Log","Route","Cache","Config","Http"].includes(r)&&this.apiCalls.push({method:"DB",url:`${r}->${o}()`}),o==="publish"&&r&&(r.includes("topic")||r.includes("pubSub"))&&this.apiCalls.push({method:"PUBSUB",url:"publish"}),["get","post","put","delete","patch","request"].includes(o)&&(r==="Http"||r==="client"||r.endsWith("request")||r.includes("Client")||!r)){let p=a.match(/(?:url\s*:\s*)?['"]([^'"]+)['"]/),u=p?p[1]:a.split(",")[0].trim()||"unknown";this.apiCalls.push({method:o.toUpperCase(),url:u})}}}else if(t===".py"){let n=/(?:([a-zA-Z0-9_\.]+)\.)?([a-zA-Z0-9_]+)\s*\(([\s\S]*?)\)/g,i;for(;(i=n.exec(e))!==null;){let r=i[1]||"",o=i[2],a=i[3];if(this.calls.add(o),r&&r!=="self"&&r!=="cls"&&this.calls.add(`${r}.${o}`),["save","delete","update","create","first","all","filter","get"].includes(o)&&r&&!["logger","os","sys"].includes(r)&&this.apiCalls.push({method:"DB",url:`${r}.${o}()`}),o==="publish"&&r&&(r.includes("publisher")||r.includes("client"))&&this.apiCalls.push({method:"PUBSUB",url:"publish"}),["get","post","put","delete","patch","request"].includes(o)&&(r==="requests"||r==="httpx"||r==="client"||r==="http"||!r)){let p=a.match(/(?:url\s*:\s*)?['"]([^'"]+)['"]/),u=p?p[1]:a.split(",")[0].trim()||"unknown";this.apiCalls.push({method:o.toUpperCase(),url:u})}}}else if([".ts",".tsx",".js",".jsx"].includes(t)){let n=/import\s+[\s\S]*?from\s+['"](.*?)['"];?/g,i;for(;(i=n.exec(e))!==null;)this.imports.set("*",i[1]);let r=/(?:([a-zA-Z0-9_$]+)\.)?([a-zA-Z0-9_$]+)\s*\(/g,o;for(;(o=r.exec(e))!==null;){let a=o[1],c=o[2];a?(this.calls.add(`${a}.${c}`),(a.toLowerCase().includes("pubsub")||a==="pubSubClient")&&c!=="subscribe"&&this.apiCalls.push({method:"PUBSUB",url:c})):this.calls.add(c)}}else{let n=/\.([a-zA-Z0-9_]+)\s*\(/g,i;for(;(i=n.exec(e))!==null;)this.calls.add(i[1])}if(t===".php"){let n=/use\s+([a-zA-Z0-9_\\]+)(?:\s+as\s+([a-zA-Z0-9_]+))?;/g,i;for(;(i=n.exec(e))!==null;){let r=i[1],o=r.split("\\"),a=i[2]||o[o.length-1];this.imports.set(a,r)}}else if(t===".py"){let n=/from\s+([a-zA-Z0-9_\.]+)\s+import\s+([a-zA-Z0-9_,\s]+)/g,i;for(;(i=n.exec(e))!==null;){let a=i[1];i[2].split(",").map(l=>l.trim()).forEach(l=>{this.imports.set(l,a)})}let r=/^import\s+([a-zA-Z0-9_\.]+)/gm,o;for(;(o=r.exec(e))!==null;){let a=o[1],c=a.split("."),l=c[c.length-1];this.imports.set(l,a)}}}};var Yp=new Set(["api","v1","v2","v3","http","https","localhost","admin","internal","public","private","app","src","get","post","put","delete","patch","user","users","id","search","list","create","update","data"]),Kp=new Set(["GET","POST","PUT","DELETE","PATCH"]),Qp=[/\bRoute::(?:get|post|put|delete|patch)\b/i,/\brouter\.(?:get|post|put|delete|patch)\s*\(/i,/\bapp\.(?:get|post|put|delete|patch)\s*\(/i,/\bfastify\.(?:get|post|put|delete|patch)\s*\(/i,/\baddRoute\s*\(/i,/\bHTTPMethods\.(?:GET|POST|PUT|DELETE|PATCH)\b/i,/\bpath\s*\(/i,/\bre_path\s*\(/i,/@(?:GET|POST|PUT|DELETE|PATCH|Route)\b/i,/@(?:Get|Post|Put|Delete|Patch|RequestMapping)\b/];function Xp(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fn(s){let e=s.split("?")[0].split("#")[0];return e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e}function Cs(s){let e=fn(s).replace(/:[^/]+/g,"__SEG__").replace(/\{[^}]+\}/g,"__SEG__").replace(/\$[^/]+/g,"__SEG__").replace(/\*/g,"__SEG__"),t=Xp(e).replace(/__SEG__/g,"[^/]+");return new RegExp(`^${t}$`)}function ma(s){let e=[/(HTTPMethods\.)?(GET|POST|PUT|DELETE|PATCH)\b/i,/Route::(get|post|put|delete|patch)\b/i,/@(GET|POST|PUT|DELETE|PATCH)\b/i],t;for(let n of e){let i=s.match(n);if(i?.[2]){t=i[2].toUpperCase();break}if(i?.[1]){t=i[1].toUpperCase();break}}return t&&Kp.has(t)?t:null}function Zp(s){return s.replace(/<[^>]+>/g," ")}function eu(s){return Qp.some(e=>e.test(s))}function tu(s){let e=[],t=/['"`]([^'"`]*\/[^'"`]*)['"`]/g,n=null;for(;(n=t.exec(s))!==null;){let i=n[1].trim();i&&e.push(i)}return e}function nu(s){let e=s.replace(/^\^/,"").replace(/\$$/,"");if(e.includes("://"))try{e=new URL(e).pathname}catch{}if(!e.startsWith("/")){let t=e.indexOf("/");if(t===-1)return null;e=e.slice(t)}return fn(e)}function iu(s,e){let t=tu(s);for(let n of t){let i=nu(n);if(!i)continue;let r=Cs(i),o=e.replace(/\*/g,"test-val");if(r.test(o)||!/[:{*$]/.test(i)&&o.startsWith(`${i}/`))return!0}return!1}function su(s,e){if(e)try{let i=JSON.parse(e);if(typeof i.path=="string"&&i.path.startsWith("/"))return fn(i.path)}catch{}let t=/['"]([^'"]+)['"]/g,n=null;for(;(n=t.exec(s))!==null;){let i=n[1].trim();if(i){if(i=i.replace(/^\^/,"").replace(/\$$/,""),!i.startsWith("/")){if(!i.includes("/")&&!i.includes(":"))continue;i=`/${i}`}return fn(i)}}return null}function ru(s,e){let t=s.toLowerCase();return e.reduce((n,i)=>n+(t.includes(i.toLowerCase())?20:0),0)}function ha(s,e,t){let n=e,i=e.match(/\$\{([^}]+)\}/g);if(i)for(let h of i){let m=h.substring(2,h.length-1),f=s.configs.findEnvValue(m);f&&(n=n.replace(h,f))}let r=n.split("?")[0].split("#")[0];try{r.includes("://")&&(r=new URL(r).pathname)}catch{}r=fn(r);let o=t?.toUpperCase(),a=[],c=!1,l=r.replace(/\*/g,"%").replace(/:[^/]+/g,"%").replace(/\{[^}]+\}/g,"%"),p=s.files.findSynapses({type:"api_route",name:l.includes("%")?l:r,direction:"consume",limit:10});for(let h of p)Cs(h.name).test(r.replace(/\*/g,"test-val"))&&(a.push({file_path:h.file_path,start_line:h.line_number||0,signature:`[Synapse] ${h.name}`,score:1e3}),c=!0);let u=r.split(/[^a-zA-Z0-9-_]/).filter(h=>h.length>=3&&!Yp.has(h.toLowerCase())&&!/^\d+$/.test(h));if(u.length>0){let f=[...u].sort((g,b)=>b.length-g.length).slice(0,2).flatMap(g=>s.exports.findRoutesByToken(g,20)),_=new Set;for(let g of f){let b=`${g.file_path}:${g.start_line}:${g.name}`;if(_.has(b))continue;_.add(b);let w=g.signature||g.name||"",x=ma(w);if(o&&x&&o!==x)continue;let R=su(w,g.capabilities);if(o&&!x&&!R)continue;let k=40;if(R){if(!Cs(R).test(r.replace(/\*/g,"test-val")))continue;k+=280,c=!0}o&&x&&o===x&&(k+=120,c=!0),k+=ru(`${w} ${R||""}`,u),a.push({file_path:g.file_path,start_line:g.start_line,signature:`[Boundary] ${w}`,capabilities:g.capabilities||void 0,score:k})}}if(a.length<3&&!c){let h=u.map(m=>m.replace(/[^a-zA-Z0-9_]/g,"")).filter(m=>m.length>0).join(" AND ");if(h.length>0){let m=s.content.search(h);for(let f of m){let _=Zp(f.snippet);if(!eu(_)||!iu(_,r))continue;let g=ma(_);if(o&&g&&g!==o)continue;let b=0,w=f.file_path.toLowerCase(),x=_.toLowerCase();(w.includes("route")||w.includes("controller"))&&(b+=10),(w.includes("src/api")||w.includes("services/api"))&&(b+=5),(x.includes("addroute")||x.includes("@get"))&&(b+=15),(x.includes("axios.")||x.includes("fetch("))&&(b-=10),(w.includes(".spec.")||w.includes(".test."))&&(b-=20),o&&x.includes(o.toLowerCase())&&(b+=20),b>0&&a.push({file_path:f.file_path,start_line:0,signature:`[FTS Match] ${_.replace(/\n/g," ")}`,score:b})}}}let d=new Map;return a.sort((h,m)=>m.score-h.score).forEach(h=>{d.has(h.file_path)||d.set(h.file_path,h)}),Array.from(d.values()).slice(0,c?2:3)}var Is=7,Lt=80,ou=2,au=4,cu=6,lu=3,pu=24,uu=new Set(["publish","publishmessage","publishtaskbynameandpayload"]),du=new Set(["Error","TypeError","RangeError","ReferenceError","SyntaxError","Promise","Map","Set","WeakMap","WeakSet","Date","Array","Object","String","Number","Boolean","RegExp","URL","URLSearchParams"]),mu=new Set(["error","errors","request","response","result","results","value","values","item","data","payload","message","messages","text","description","name","id","type","status","code"]),ga=new Set(["req","res","request","response","error","err","event","item","row","data","value","obj","window","document","console","json","math"]),hu=new Set(["length","size","value","values","name","id","type","status"]),ya=new Set(["push","pop","shift","unshift","slice","splice","map","filter","reduce","reduceRight","forEach","find","findIndex","includes","indexOf","lastIndexOf","every","some","flat","flatMap","fill","copyWithin","entries","keys","values","join","concat","sort","reverse","at","with","toSorted","toReversed","toSpliced","toString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","charAt","charCodeAt","codePointAt","split","substring","substr","trim","trimStart","trimEnd","padStart","padEnd","repeat","replace","replaceAll","match","matchAll","search","toLowerCase","toUpperCase","localeCompare","normalize","startsWith","endsWith","then","catch","finally","get","set","has","delete","clear","size","length","call","apply","bind"]);function fu(s,e){return fe.resolve(s)===fe.resolve(e)}function gu(s){if(du.has(s))return!0;let e=s.trim().toLowerCase();if(!e||e.length<2||/\[|\]|\s/.test(s)||mu.has(e))return!0;let t=s.split(/(?:\.|->|::)+/).filter(Boolean),n=(t.length>0?t[t.length-1]:e).replace(/^\$+/,"");if(hu.has(n.toLowerCase())||ya.has(n))return!0;if(t.length>1){let i=t[0].replace(/^\$+/,"").toLowerCase();if(ga.has(i))return!0}return!1}function $s(s,e){if(e.has(s))return e.get(s)??null;try{let t=$t.readFileSync(s,"utf8");return e.set(s,t),t}catch{return null}}function yu(s){return s<20?Is:s<45?Is-1:Math.max(4,Is-2)}function bu(s,e){let t=s<=2?1:s<=4?.7:.4,n=e<25?1:e<55?.8:.55,i=Math.floor(pu*t*n);return Math.max(lu,i)}function _u(s,e){let t=s.split(`
|
|
668
|
+
`),n=new Map,i=new Map,r=[],o=new Set;for(let a=0;a<t.length;a++){let c=t[a],l=e+a+1,p=c.match(/\b(?:const|let|var)\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*=/),u=c.match(/\b([A-Za-z_$][A-Za-z0-9_$]*)\s*=\s*[^=]/),d=p?.[1]||u?.[1];if(d){n.set(d,l);continue}for(let[h,m]of n.entries()){if(l<=m||!new RegExp(`\\b${ba(h)}\\b`).test(c))continue;let f=i.get(h)||0;if(f>=2)continue;let _=`${h}:${m}->${l}`;o.has(_)||(r.push({symbol:h,fromLine:m,toLine:l}),o.add(_),i.set(h,f+1))}}return r}function fa(s){let e=s.trim();if(!e)return"";let t=e.indexOf("/"),n=t>=0?e.slice(t):e;return n.length>1&&n.endsWith("/")?n.slice(0,-1):n}function ba(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function As(s){let e=s.split(/(?:\.|::|->)+/).filter(Boolean);return e.length>0?e[e.length-1]:s.trim()}function Eu(s,e){let t=0,n=!1;for(let i=e;i<s.length;i++){let r=s[i];for(let a of r)if(a==="{")t++,n=!0;else if(a==="}"&&(t--,n&&t<=0))return{start:e+1,end:i+1};let o=r.trim();if(!n&&/[;}]$/.test(o))return{start:e+1,end:i+1}}return{start:e+1,end:Math.min(s.length,e+40)}}function Ls(s,e,t){let n=As(e);if(!n)return null;try{let i=t?$s(s,t):$t.readFileSync(s,"utf8");if(!i)return null;let r=i.split(`
|
|
669
|
+
`),o=ba(n),a=[new RegExp(`^\\s*(?:export\\s+)?(?:async\\s+)?function\\s+${o}\\b`),new RegExp(`^\\s*(?:(?:public|private|protected|static|readonly|async|abstract|get|set)\\s+)*${o}\\s*(?:<[^>]*>)?\\s*\\(`),new RegExp(`^\\s*(?:(?:public|private|protected|static|readonly|async|abstract)\\s+)*${o}\\s*[:=]\\s*(?:async\\s*)?(?:\\([^)]*\\)\\s*=>|function\\b)`),new RegExp(`^\\s*(?:export\\s+)?class\\s+${o}\\b`)];for(let c=0;c<r.length;c++){let l=r[c];if(l.includes(n)&&a.some(p=>p.test(l)))return Eu(r,c)}}catch{return null}return null}function _a(s,e,t,n){try{let i=n?$s(s,n):$t.readFileSync(s,"utf8");if(!i)return!0;let r=i.split(`
|
|
670
|
+
`);if(e.start<1||e.end<e.start||e.start>r.length||e.end>r.length||!r.slice(e.start-1,e.end).join(`
|
|
671
|
+
`).trim())return!0;if(e.start===e.end){let a=r[e.start-1]?.trim()||"",c=a.replace(/\s+/g,"");if(!c||/^[{}()[\];,]+$/.test(c))return!0;let l=As(t);if(l&&!a.includes(l))return!0}return!1}catch{return!0}}function wi(s,e,t,n){if(e){if(!t)return e;if(_a(s,e,t,n)){let i=Ls(s,t,n);if(i)return i}return e}}function Su(s,e,t){let n=s.exports.findByNameAndFile(t,e);if(n.length>0)return n[0];let i=s.exports.findByFile(e);if(i.length===0)return null;if(t.includes("/")){let a=fa(t),c=i.find(l=>!l?.name||typeof l.name!="string"?!1:fa(l.name)===a);if(c)return c}let r=t.split(/(?:\.|::|->)+/).filter(Boolean);if(r.length>1){let a=r[r.length-1],c=s.exports.findByNameAndFile(a,e);if(c.length===1)return c[0]}return i.find(a=>typeof a?.name=="string"&&(a.name===t||a.name.includes(t)))||null}async function Ea(s){let{repoPath:e,filePath:t,symbolName:n}=Ve(s);if(!t)return{isError:!0,content:[{type:"text",text:"Error: 'filePath' is required."}]};let i=t;await X(e);let r=O.getInstance(e);if(!$t.existsSync(i))return{isError:!0,content:[{type:"text",text:`File not found: ${i}`}]};let o=new Map,a,c=fe.basename(i),l;if(n){let h=As(n),m=Su(r,i,n);if(m){let f=m;a={start:f.start_line,end:f.end_line},c=f.name,l=f.start_line}else{let f=Ls(i,n,o);if(f)a=f,l=f.start,c=h||n;else{let _=r.exports.findByFile(i).map(g=>g.name).filter(g=>!!g).slice(0,10);return{isError:!0,content:[{type:"text",text:`Symbol not found in file: "${n}"
|
|
672
|
+
File: ${fe.relative(e,i)}
|
|
673
|
+
`+(_.length>0?`Top symbols in file: ${_.join(", ")}`:"No indexed symbols found for this file.")}]}}}if(a&&_a(i,a,n,o)){let f=Ls(i,n,o);f&&(S.warn({filePath:i,symbolName:n,start:a.start,end:a.end},"Indexed symbol range appears degenerate; using source-inferred range for flow"),a=f,l=f.start,c===fe.basename(i)&&(c=h||n))}}let p={type:a?"function":"file",name:c,path:fe.relative(e,i),line:l,children:[]},u=new Set;u.add(i+(n?`:${n}`:""));let d={count:0,truncated:!1,pruned:!1};return await Bt(i,p,e,r,u,1,d,o,a),(d.truncated||d.pruned)&&p.children.push({type:"function",name:"\u26A0\uFE0F Trace Pruned",details:`Adaptive trace limits applied (depth/node budget). Current cap: ${Lt} nodes.`,children:[]}),{content:[{type:"text",text:JSON.stringify(p,null,2)}]}}async function Bt(s,e,t,n,i,r,o,a,c){let l=yu(o.count);if(r>l){o.pruned=!0;return}if(o.count>=Lt){o.truncated=!0;return}try{let p=$s(s,a);if(!p)throw new Error(`Unable to read source: ${s}`);let u=p,d=fe.extname(s).toLowerCase(),m=(u.match(/import\s+[\s\S]*?from\s+['"].*?['"];?/gm)||[]).join(`
|
|
674
|
+
`);c&&(u=u.split(`
|
|
675
|
+
`).slice(c.start-1,c.end).join(`
|
|
676
|
+
`));let f;if(d===".ts"||d===".tsx"||d===".js"||d===".jsx"){f=new Si;let P={syntax:"typescript",tsx:s.endsWith(".tsx"),target:"es2020"};try{let E=c?`${m}
|
|
677
|
+
${u}`:u,T=await ms(E,P);f.visitModule(T)}catch{if(c)try{let T=`${m}
|
|
678
|
+
class TraceContext {
|
|
679
|
+
${u}
|
|
680
|
+
}`,I=await ms(T,P);f.visitModule(I)}catch{let I=new jt,M=d;I.visit(u,M),f.calls=I.calls,f.apiCalls=I.apiCalls,f.imports=I.imports}else{let T=new jt;T.visit(u,d),f.calls=T.calls,f.apiCalls=T.apiCalls,f.imports=T.imports}}}else f=new jt,f.visit(u,d);S.info({file:fe.basename(s),calls:f.calls.size,apiCalls:f.apiCalls.length,depth:r},"Analyzed file");let _=Math.max(0,Lt-o.count),g=Math.max(2,Math.min(10,Math.floor(_/(r<=2?3:5)))),b=f.apiCalls.slice(0,g);f.apiCalls.length>g&&(o.pruned=!0);for(let P of b){if(o.count>=Lt)break;if(o.count++,P.method==="PUBSUB"){let M={type:"event_trigger",name:`PubSub Event: ${P.url}`,details:"Detected via PubSub client usage",children:[]};e.children.push(M);let N=P.url.toLowerCase();if(uu.has(N)){M.children.push({type:"subscriber",name:"PubSub fan-out omitted",details:"Generic publish call without concrete event/action; skipping global subscriber expansion to avoid false links.",children:[]});continue}let $=n.exports.findByNameGlobal(P.url).concat(n.exports.findByMethodName(P.url));if(P.url.length>10){let L=P.url.replace(/To[A-Z][a-zA-Z]+$/,"");if(L!==P.url){let A=n.exports.findByNameGlobal(L).concat(n.exports.findByMethodName(L));$.push(...A)}}let W=new Set;for(let L of $.slice(0,au)){if(W.has(L.file_path)||L.file_path===s)continue;if(W.add(L.file_path),o.count>=Lt)break;o.count++;let A={type:"subscriber",name:`${L.name} (${fe.basename(L.file_path)})`,path:fe.relative(t,L.file_path),line:L.start_line,details:"Potential Subscriber / Handler",children:[]};M.children.push(A),$t.existsSync(L.file_path)&&!i.has(L.file_path)&&(i.add(L.file_path),await Bt(L.file_path,A,t,n,i,r+1,o,a))}continue}let E={type:"api_call",name:`${P.method} ${P.url}`,details:"Detected via string literal analysis",children:[]};e.children.push(E);let I=ha(n,P.url,P.method).slice(0,ou);for(let M of I){if(fu(M.file_path,s))continue;if(o.count>=Lt)break;o.count++;let N={type:"route",name:M.signature||"Route Handler",path:M.file_path,line:M.start_line,children:[]};if(E.children.push(N),$t.existsSync(M.file_path)&&!i.has(M.file_path)&&(i.add(M.file_path),await Bt(M.file_path,N,t,n,i,r+1,o,a)),M.capabilities)try{let $=JSON.parse(M.capabilities);if($.handler){let[W,L]=$.handler.split("@");if(W){let H=W.split("\\").pop();if(H){let F=n.exports.findClassByName(H);if(F){let v=n.exports.findByNameAndFile(L||"",F.file_path),C,B=F.start_line;v.length>0&&(C=wi(F.file_path,{start:v[0].start_line,end:v[0].end_line},L||"",a),C||(C={start:v[0].start_line,end:v[0].end_line}),B=C.start);let j={type:"component",name:`${H}${L?" :: "+L:""}`,path:fe.relative(t,F.file_path),line:B,details:"Controller Logic (Macro IR)",children:[]};N.children.push(j),i.has(F.file_path+(L?`:${L}`:""))||(i.add(F.file_path+(L?`:${L}`:"")),await Bt(F.file_path,j,t,n,i,r+1,o,a,C))}}}}}catch{}}}let w=c?c.start-1:0,x=_u(u,w).slice(0,cu);for(let P of x){if(o.count>=Lt)break;o.count++,e.children.push({type:"data_flow",name:`${P.symbol} handoff`,line:P.toLine,details:`assigned @L${P.fromLine} \u2192 used @L${P.toLine}`,children:[]})}let R=f.calls,k=Array.from(R).sort(),D=bu(r,o.count),U=k.slice(0,D);k.length>D&&(o.pruned=!0);for(let P of U)if(f.imports.has(P)){let E=f.imports.get(P);if(!E.startsWith(".")){if(["react","react-dom"].includes(E))continue;e.children.push({type:"function",name:P,details:`External: ${E}`,children:[]});continue}let T=Tt(E,s,t);if(T&&$t.existsSync(T)){let I=n.exports.findByNameAndFile(P,T),M=I.length>0?I[0]:null,N=M?`${T}:${M.name}`:T;if(i.has(N))e.children.push({type:"function",name:P,details:"Circular / Already Visited",path:fe.relative(t,T),line:M?.start_line,children:[]});else{i.add(N);let $={type:M?"component":"file",name:P,details:M?`Imported symbol from ${fe.basename(T)}`:`Imported from ${fe.basename(T)}`,path:fe.relative(t,T),line:M?.start_line,children:[]};e.children.push($);let W=M?wi(T,{start:M.start_line,end:M.end_line},P,a):void 0;await Bt(T,$,t,n,i,r+1,o,a,W)}}}else if(!["log","info","error","warn","print"].includes(P)&&!gu(P)){let E=n.exports.findByNameGlobal(P);if(E.length===0){let T=P.split(/(?:\.|->|::)+/);if(T.length>1){let I=T[0]?.replace(/^\$+/,"").toLowerCase(),M=T[T.length-1];!ya.has(M)&&!(I&&ga.has(I))&&(E=n.exports.findByMethodName(M))}}if(E.length>0){let T=E.find(M=>M.file_path===s),I=T||(E.length===1?E[0]:null);if(I){let M=`${I.file_path}:${I.name}`;if(!i.has(M)){i.add(M);let N={type:"component",name:P,details:`Resolved via global index${T?" (local)":""}`,path:fe.relative(t,I.file_path),line:wi(I.file_path,{start:I.start_line,end:I.end_line},P,a)?.start,children:[]};e.children.push(N);let $=wi(I.file_path,{start:I.start_line,end:I.end_line},P,a)||{start:I.start_line,end:I.end_line};await Bt(I.file_path,N,t,n,i,r+1,o,a,$)}}}}}catch(p){S.error({filePath:s,error:p.message},"Trace analysis failed"),e.children.push({type:"function",name:"Error",details:p.message,children:[]})}}async function Sa(s,e){let t=xi.resolve(e.dir),n=xi.isAbsolute(s)?s:xi.resolve(t,s);await Y(async()=>{pe("Execution Trace");let i=Re();i.start(`Tracing ${y.cyan(e.symbolName||xi.basename(n))}...`);try{let r=await Ea({repoPath:t,filePath:n,symbolName:e.symbolName});i.stop("Trace complete."),r.isError?console.error(y.red(r.content[0].text)):se("Flow Results",r.content[0].text,"magenta")}catch(r){throw i.stop(`Trace failed: ${r.message}`),r}finally{await Q(t)}})}import vu from"path";V();Gt();q();import{execSync as xa}from"child_process";import xu from"path";var vi=S.child({module:"shadow-trace"}),qt=class{intentLogs;exports;repoPath;hologramService;constructor(e){let{intentLogs:t,exports:n}=O.getInstance(e);this.intentLogs=t,this.exports=n,this.repoPath=e,this.hologramService=new Se(e)}analyzeGhostChanges(e){let t=e?`${e}..HEAD`:"HEAD~1..HEAD",n=[];try{let r=xa(`git diff --name-only ${t}`,{cwd:this.repoPath,encoding:"utf-8"}).split(`
|
|
681
|
+
`).filter(o=>o.trim()!=="");if(r.length===0)return;vi.info({files:r.length,range:t},"Initiating Shadow Trace analysis...");for(let o of r){let a=xu.join(this.repoPath,o),l=xa(`git diff -U0 ${t} -- ${o}`,{cwd:this.repoPath,encoding:"utf-8"}).matchAll(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/g);for(let p of l){let u=parseInt(p[2],10),d=this.exports.findAtLine(a,u);d&&(this.intentLogs.create({mission_id:0,file_path:a,symbol_id:d.id,type:"discovery",content:`Shadow Trace: Modified externally in ${t}`,confidence:.8,symbol_name:d.name,signature:d.signature,commit_sha:null}),vi.debug({symbol:d.name},"Logged ghost change"),n.push({from:"external",to:`${o}:${d.name}`,pattern:"git-delta",confidence:.8}))}}n.length>0&&this.hologramService.updateGhostBridges(n),vi.info("Shadow Trace complete.")}catch(i){vi.warn({err:i.message},"Shadow Trace failed: git diff error.")}}};V();import{execSync as Vt}from"child_process";var Ti=class{constructor(e,t="refs/notes/shadow"){this.repoPath=e;this.ref=t}addNote(e,t){try{Vt(`git notes --ref ${this.ref} add -f -m '${t.replace(/'/g,"'\\''")}' ${e}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch(n){throw new Error(`Failed to add git note to ${e}: ${n.message}`)}}getNote(e){try{return Vt(`git notes --ref ${this.ref} show ${e}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return null}}listNotes(){let e=new Map;try{let t=Vt(`git notes --ref ${this.ref} list`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim();if(!t)return e;let n=t.split(`
|
|
682
|
+
`);for(let i of n){let[r,o]=i.split(" ");if(o){let a=this.getNote(o);a&&e.set(o,a)}}}catch{}return e}removeNote(e){try{Vt(`git notes --ref ${this.ref} remove ${e}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch{}}push(e="origin"){try{Vt(`git push ${e} ${this.ref}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch(t){throw new Error(`Failed to push git notes to ${e}: ${t.message}`)}}fetch(e="origin"){try{Vt(`git fetch ${e} ${this.ref}:${this.ref}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch{}}};q();gn();var Jt=S.child({module:"persistence-service"}),Fe=class{gitNotes;repoPath;constructor(e){this.repoPath=e,this.gitNotes=new Ti(e)}async syncMissionToGitNotes(e){let{missions:t,intentLogs:n}=O.getInstance(this.repoPath),i=t.findById(e);if(!i)throw new Error(`Mission ${e} not found`);if(!i.commit_sha){Jt.info({missionId:e},"Skipping Git Notes sync because mission has no commit_sha yet");return}Jt.info({missionId:e,commitSha:i.commit_sha},"Syncing mission to Git Notes");let r=t.getArtifacts(e),o=n.findByMission(e,1e3),a=o.find(p=>p.type==="adr"),c=o.filter(p=>p.type==="decision").map(p=>({content:p.content,symbol_name:p.symbol_name,created_at:p.created_at})),l={version:"1.0",mission:{name:i.name,goal:i.goal,status:i.status,strategy_graph:i.strategy_graph,git_branch:i.git_branch,commit_sha:i.commit_sha,parent_id:i.parent_id,verification_context:i.verification_context,outcome_contract:i.outcome_contract,created_at:i.created_at,updated_at:i.updated_at},artifacts:r,adr:a?a.content:null,decisions:c};this.gitNotes.addNote(i.commit_sha,JSON.stringify(l,null,2))}async syncAllToGitNotes(){let{missions:e}=O.getInstance(this.repoPath),t=e.findActive(),n=e.findRecentCompleted(10),i=[...t,...n];for(let r of i)try{await this.syncMissionToGitNotes(r.id)}catch(o){Jt.error({missionId:r.id,...ye(o)},"Failed to sync mission")}}async recoverFromGitNotes(){let e=this.gitNotes.listNotes(),{missions:t,intentLogs:n}=O.getInstance(this.repoPath),i=0,r=0;for(let[o,a]of e.entries())try{let c=JSON.parse(a);if(c.version!=="1.0")continue;if(t.findByCommitShas([o]).some(d=>d.name===c.mission.name)){Jt.debug({commitSha:o,missionName:c.mission.name},"Mission already exists, skipping recovery");continue}let u=t.create({name:c.mission.name,goal:c.mission.goal,status:c.mission.status,strategy_graph:c.mission.strategy_graph,git_branch:c.mission.git_branch,commit_sha:o,parent_id:c.mission.parent_id,verification_context:c.mission.verification_context,outcome_contract:c.mission.outcome_contract});if(i++,c.adr&&(n.create({mission_id:Number(u),symbol_id:null,file_path:null,type:"adr",content:c.adr,confidence:1,symbol_name:null,signature:null,commit_sha:o}),r++),c.decisions&&c.decisions.length>0)for(let d of c.decisions)n.create({mission_id:Number(u),symbol_id:null,file_path:null,type:"decision",content:d.content,confidence:1,symbol_name:d.symbol_name,signature:null,commit_sha:o}),r++;Jt.info({commitSha:o,missionName:c.mission.name,logsRecovered:r},"Re-hydrated mission from Git Notes")}catch(c){Jt.error({commitSha:o,...ye(c)},"Failed to parse Git Note for recovery")}return{missionsRecovered:i,logsRecovered:r}}};V();It();async function va(s){let{repoPath:e,enableContextPivot:t,enableMergeSentinel:n}=s;try{await X(e),new qt(e).analyzeGhostChanges();let r=new qe(e),o=r.detectAndRepairShifts(),a=r.syncLifecycle({enableContextPivot:t,enableMergeSentinel:n}),l=await new Fe(e).recoverFromGitNotes(),{HologramService:p}=await Promise.resolve().then(()=>(Gt(),wa)),u=new p(e),d=mt(O.getInstance(e),e);u.updateTopography(d);let h=u.computeGravityZones();u.updateGravityZones(h);let m="Shadow Sync complete. Code changes indexed and intent logs updated.";return m+=`
|
|
683
|
+
\u269B\uFE0F Hologram: Refreshed architectural map (${h.length} hotspots).`,o.repaired>0&&(m+=`
|
|
684
|
+
\u2728 Nano-Repair: Fixed ${o.repaired} links.`),m+=`
|
|
685
|
+
\u{1F9ED} Lifecycle: contextPivot=${a.contextPivotEnabled?"on":"off"}, mergeSentinel=${a.mergeSentinelEnabled?"on":"off"}, suspended=${a.suspended}, resumed=${a.resumed}, completed=${a.completed}.`,l.missionsRecovered>0&&(m+=`
|
|
686
|
+
\u{1F9EC} Re-hydration: Recovered ${l.missionsRecovered} missions.`),{content:[{type:"text",text:m}]}}catch(i){return{content:[{type:"text",text:`Error: ${i.message}`}],isError:!0}}}async function Ta(s,e){let t=vu.resolve(s);await Y(async()=>{pe("Shadow Sync");let n=Re();n.start("Synchronizing intelligence lifecycle...");try{let i=await va({repoPath:t,enableContextPivot:e.contextPivot===!0,enableMergeSentinel:e.mergeSentinel===!0});n.stop("Sync complete."),i.isError?console.error(y.red(i.content[0].text)):(console.log(""),console.log(i.content[0].text),console.log(""))}catch(i){throw n.stop(`Sync failed: ${i.message}`),i}finally{await Q(t)}})}It();V();q();Gt();import ka from"path";V();It();Gt();import et from"path";async function Ra(s){let{repoPath:e}=s;await X(e);let t=O.getInstance(e),n=mt(t,e),r=new Se(e).getSnapshot(),o=[],a=[],c=Object.values(n.layers.Entry.topFiles).map(d=>d.path),l=new Set(Object.values(n.layers.Data.topFiles).map(d=>d.path));for(let d of c){let h=et.isAbsolute(d)?d:et.join(e,d),m=t.imports.findByFile(h);for(let f of m)f.resolved_path&&l.has(et.relative(e,f.resolved_path))&&o.push(`\u2694\uFE0F LAYER BYPASS: \`${et.relative(e,d)}\` directly imports Data layer \`${et.relative(e,f.resolved_path)}\`. Should go through Logic.`)}let p=r.gravity?.hotspots||[];for(let d of p){let h=Ct(d.filePath,t);(h.layer==="Utility"||h.layer==="Unknown")&&d.gravity>50&&a.push(`\u{1F6A8} GRAVITY ANOMALY: \`${et.relative(e,d.filePath)}\` has high gravity (${d.gravity.toFixed(0)}) but is classified as ${h.layer}. Consider promoting to Core Logic.`)}for(let d of c){let h=et.isAbsolute(d)?d:et.join(e,d),m=t.exports.findByFile(h);m.length>10&&a.push(`\u{1F388} ENTRY BLOAT: \`${et.relative(e,d)}\` exports ${m.length} symbols. Entry handlers should be thin interfaces.`)}let u=`# \u{1F575}\uFE0F Architectural Scout Report
|
|
687
|
+
|
|
688
|
+
`;return o.length===0&&a.length===0?u+=`\u2705 No significant architectural drift detected. The structure remains "Legit".
|
|
689
|
+
`:(o.length>0&&(u+=`## \u274C Structural Violations
|
|
690
|
+
`,o.forEach(d=>u+=`- ${d}
|
|
691
|
+
`),u+=`
|
|
692
|
+
`),a.length>0&&(u+=`## \u26A0\uFE0F Architectural Warnings
|
|
693
|
+
`,a.forEach(d=>u+=`- ${d}
|
|
694
|
+
`),u+=`
|
|
695
|
+
`)),{content:[{type:"text",text:u}]}}async function Ca(s,e,t){let n=e?ka.resolve(process.cwd(),e):process.cwd();if(s==="init"){S.info('Running full initialization (same as "index --force")...'),await X(n,void 0,!0,!0);return}if(s==="tree"){S.info('For tree view, please use the "tree" command.');return}if(s==="topography"){await X(n);let i=O.getInstance(n),r=mt(i,n);console.log(`
|
|
696
|
+
\u{1F3D7}\uFE0F Architecture Summary for ${ka.basename(n)}
|
|
697
|
+
`),console.log(`Detected Pattern: **${r.pattern}** (Confidence: ${r.patternConfidence.toFixed(0)}%)`),r.insights.length>0&&(console.log(`
|
|
698
|
+
Insights:`),r.insights.forEach(l=>console.log(`- ${l}`))),console.log(`
|
|
699
|
+
Layer Distribution:`);let o=["Entry","Logic","Data","Utility","Infrastructure","Test","Types","Unknown"],a=Object.values(r.layers).reduce((l,p)=>l+p.count,0),c=l=>{switch(l){case"Entry":return"\u{1F6AA}";case"Logic":return"\u2699\uFE0F";case"Data":return"\u{1F4BE}";case"Utility":return"\u{1F527}";case"Infrastructure":return"\u{1F3D7}\uFE0F";case"Test":return"\u{1F9EA}";case"Types":return"\u{1F4DD}";default:return"\u2753"}};o.forEach(l=>{let p=r.layers[l],u=a>0?(p.count/a*100).toFixed(1):"0.0";console.log(`${c(l)} ${l.padEnd(14)} | ${p.count.toString().padStart(5)} files | ${u}%`)}),console.log(`
|
|
700
|
+
Top Files by Layer:`),o.forEach(l=>{let p=r.layers[l];p.count!==0&&(console.log(`
|
|
701
|
+
${c(l)} ${l}`),p.topFiles.forEach(u=>{console.log(` - ${u.path} (${u.confidence}% conf)`),u.signals.length>0&&console.log(` \u2514\u2500 ${u.signals.slice(0,1).join(", ")}`)}))});return}if(s==="scout"){let i=await Ra({repoPath:n});console.log(i.content[0].text);return}if(s==="hologram"){let i=new Se(n);console.log(JSON.stringify(i.getSnapshot(),null,2));return}S.error(`Unknown recon mode: ${s}. Available: init, topography, scout, hologram`)}import _n from"path";V();var ht=class s{static extractKeywords(e){if(!e)return[];let t=new Set(["the","and","for","with","from","this","that","into","onto","http","https","www","com","org","net","api"]),i=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9_]+/).map(r=>r.trim()).filter(r=>r.length>2&&!t.has(r));return Array.from(new Set(i))}static calculateKeywordCoverageFromKeywords(e,t){if(!e||!t||t.length===0)return 0;let n=e.toLowerCase();return t.filter(r=>n.includes(r)).length/t.length}static calculateKeywordCoverage(e,t){return s.calculateKeywordCoverageFromKeywords(e,s.extractKeywords(t))}static extractSnippet(e,t,n=300){if(!e||!t)return"";let i=s.extractKeywords(t);if(i.length===0)return e.slice(0,n)+"...";let r=e.split(`
|
|
702
|
+
`),o=new Array(r.length).fill(0);for(let d=0;d<r.length;d++){let h=r[d].toLowerCase(),m=0,f=0;for(let _ of i)h.includes(_)&&(m++,f++);(h.includes("export ")||h.includes("class ")||h.includes("function ")||h.includes("interface "))&&(m+=1),o[d]=f*10+m}let a=0,c=-1,l=5;for(let d=0;d<=r.length-l;d++){let h=0;for(let m=0;m<l;m++)h+=o[d+m];h>c&&(c=h,a=d)}if(c<=0)return e.slice(0,n).trim()+"...";let u=r.slice(a,a+l).join(`
|
|
703
|
+
`).trim();return a>0&&(u=`...
|
|
704
|
+
`+u),a+l<r.length&&(u=u+`
|
|
705
|
+
...`),u.length>n?u.slice(0,n)+"...":u}static calculateLexicalScore(e,t){if(!e||!t)return 0;let n=s.extractKeywords(t);if(n.length===0)return 0;let i=0,r=e.toLowerCase();for(let o of n)if(r.includes(o)){i+=1;let a=new RegExp(`\\b${o}`,"gi"),c=r.match(a);c&&(i+=Math.min(c.length*.2,2)),new RegExp(`(class|function|export|interface|enum|type)\\s+${o}`,"i").test(e)&&(i+=1.5)}return i/n.length}};Ae();V();q();var ft=S.child({module:"clean-sweep"}),Ps=class{files;intentLogs;constructor(e){let{files:t,intentLogs:n}=O.getInstance(e);this.files=t,this.intentLogs=n}pruneOrphans(){ft.info("Starting orphan pruning...");let e=0,t=0,n=this.intentLogs.findOrphans();ft.info({orphanCount:n.length},"Found orphaned logs");for(let o of n)o.file_path&&this.files.exists(o.file_path)?(this.intentLogs.markAsLapsed(o.id),t++,ft.debug({logId:o.id,symbolName:o.symbol_name},"Converted to lapsed intent")):(this.intentLogs.delete(o.id),e++,ft.debug({logId:o.id},"Deleted orphaned log"));let i=this.intentLogs.findLogsForMissingFiles();for(let o of i)this.intentLogs.delete(o.id),e++;let r=this.intentLogs.findRecentDecisionActivity(1e3).length;return ft.info({deleted:e,converted:t},"Orphan pruning complete"),{deleted:e,converted:t,retained:r}}},Ms=class{lambda;constructor(e=.01){this.lambda=e}calculateScore(e,t){let i=(Math.floor(Date.now()/1e3)-t)/(3600*24),r=Math.exp(-this.lambda*i);return e*r}scoreResults(e){return e.map(t=>({...t,decayed_score:this.calculateScore(t.score,t.created_at)}))}},Ns=class{missions;constructor(e){let{missions:t}=O.getInstance(e);this.missions=t}findColdMissions(){let e=Math.floor(Date.now()/1e3)-604800,t=this.missions.findColdMissions(e,10);return ft.info({count:t.length},"Found cold missions for compaction"),t}markDistilled(e){this.missions.update(e,{status:"distilled"})}},Ri=class{pruner;scorer;compactor;constructor(e){this.pruner=new Ps(e),this.scorer=new Ms,this.compactor=new Ns(e)}runMaintenance(){ft.info("Initiating Clean Sweep maintenance protocol...");let e=this.pruner.pruneOrphans(),t=this.compactor.findColdMissions();return ft.info("Clean Sweep maintenance complete"),{pruning:e,compaction:{eligible:t.length}}}getScorer(){return this.scorer}getCompactor(){return this.compactor}};V();q();var Ia=S.child({module:"lineage-service"}),yn=class{repoPath;constructor(e){this.repoPath=e}getAncestorMissionIds(e=50){try{let t=So(this.repoPath,e);if(t.length===0)return[];let{missions:n}=O.getInstance(this.repoPath),r=n.findByCommitShas(t).map(o=>o.id);return r.length>0&&Ia.debug({count:r.length},"Identified ancestor missions for gravity bleed"),r}catch(t){return Ia.warn({err:t.message},"Failed to identify ancestor missions"),[]}}};var Tu={Solid:1,Liquid:.8,Virtual:.4,Intel:.2,Phantom:.05},We=class{static classify(e,t){let n=e.toLowerCase();if(t?.content){let i=t.content;if(i.includes("describe(")||i.includes("test(")||i.includes("it(")||i.includes("expect(")||i.includes('from "@jest/globals"')||i.includes('from "vitest"'))return"Virtual"}return t?.exports&&(t.exports.some(r=>r.kind==="ClassDeclaration"||r.kind==="Class")||t.exports.length>5),n.includes("/dist/")||n.includes("/build/")||n.includes("/.generated/")||n.includes("/node_modules/")||n.endsWith(".map")||n.endsWith(".log")?"Phantom":n.includes("/test/")||n.includes("/tests/")||n.includes("/__tests__/")||n.includes("/__mocks__/")||n.includes(".spec.")||n.includes(".test.")||n.includes("/e2e/")||n.includes("/test-utils/")?"Virtual":n.includes("/examples/")||n.includes("/fixtures/")||n.includes("/mocks/")||n.includes("/stories/")||n.includes("/samples/")||n.includes("/docs/")?"Intel":n.includes("/src/")||n.includes("/lib/")||n.includes("/app/")||n.includes("/core/")||n.includes("/logic/")||n.includes("/domain/")||n.includes("/services/")||n.includes("/controllers/")||n.includes("/handlers/")||n.includes("/repositories/")||n.includes("/models/")||n.includes("/packages/")&&!n.includes("/packages/config/")||n.includes("/backends/")||t?.exports&&(t.exports.some(i=>i.kind==="ClassDeclaration"||i.kind==="Class")||t.exports.length>5)?"Solid":"Liquid"}static mapClassificationToTier(e){let t=e.toLowerCase();return t==="service"||t==="repository"||t==="model"||t==="controller"||t==="handler"||t==="component"||t==="hook"||t==="titanium"||t==="solid"?"Solid":t==="test"||t==="iron"||t==="virtual"?"Virtual":t==="lead"||t==="intel"?"Intel":t==="ghost"||t==="error"||t==="phantom"?"Phantom":"Liquid"}static getMultiplier(e,t){let n=t?this.mapClassificationToTier(t):this.classify(e);return Tu[n]}};q();function Ru(s,e){let t=[];for(let n=0;n<=e.length;n++)t[n]=[n];for(let n=0;n<=s.length;n++)t[0][n]=n;for(let n=1;n<=e.length;n++)for(let i=1;i<=s.length;i++)e.charAt(n-1)===s.charAt(i-1)?t[n][i]=t[n-1][i-1]:t[n][i]=Math.min(t[n-1][i-1]+1,t[n][i-1]+1,t[n-1][i]+1);return t[e.length][s.length]}function ku(s,e){let t=Ru(s.toLowerCase(),e.toLowerCase()),n=Math.max(s.length,e.length);return Math.round((n-t)/n*100)}function La(s){let e=[],t="";for(let n=0;n<s.length;n++){let i=s[n],r=i>="A"&&i<="Z",o=i>="a"&&i<="z";r&&t.length>0?(e.push(t),t=i):o||r?t+=i:t.length>0&&(e.push(t),t="")}return t.length>0&&e.push(t),e}function Cu(s,e){let t=La(e),n=s.toLowerCase();if(t.map(o=>o[0].toLowerCase()).join("")===n)return!0;let r=0;for(let o of t){if(r>=s.length)break;let a=o.toLowerCase();if(a.startsWith(n.slice(r))){r=s.length;break}a[0]===n[r]&&r++}return r===s.length}function Iu(s,e){return La(e).map(i=>i[0].toLowerCase()).join("")===s.toLowerCase()}function Lu(s,e){let t=s.toLowerCase(),n=e.toLowerCase();if(s===e)return{matchType:"exact",score:100};if(t===n)return{matchType:"exact-case-insensitive",score:98};if(n.startsWith(t))return{matchType:"prefix",score:90+s.length/e.length*8};if(n.endsWith(t))return{matchType:"suffix",score:80+s.length/e.length*8};if(n.includes(t)){let r=s.length/e.length,o=n.indexOf(t)/e.length;return{matchType:"substring",score:70+r*10-o*5}}return Iu(s,e)?{matchType:"acronym",score:75}:Cu(s,e)?{matchType:"camel-case",score:65}:{matchType:"levenshtein",score:ku(s,e)*.6}}function bn(s,e,t=50,n=5){let i=[];for(let r of e){let{matchType:o,score:a}=Lu(s,r);if(a>=t){let l={exact:1e3,"exact-case-insensitive":900,prefix:800,suffix:700,substring:600,acronym:550,"camel-case":500,levenshtein:100}[o]+a;i.push({match:r,score:a,matchType:o,rank:l})}}return i.sort((r,o)=>o.rank!==r.rank?o.rank-r.rank:o.score!==r.score?o.score-r.score:r.match.length-o.match.length),i.slice(0,n)}Gt();var gt=class s{constructor(e){this.repoPath=e}get filesRepo(){return O.getInstance(this.repoPath).files}get exportsRepo(){return O.getInstance(this.repoPath).exports}get intentLogsRepo(){return O.getInstance(this.repoPath).intentLogs}static normalizeFileType(e){if(e==null)return;let t=Array.isArray(e)?e:e.split(",").map(n=>n.trim().replace(/^\./,""));return t.filter(Boolean).length?t:void 0}static matchesFilters(e,t,n,i){if(t.fileType?.length){let r=e.replace(/^.*\./,"").toLowerCase();if(!t.fileType.some(o=>o.toLowerCase()===r))return!1}if(t.layer!=null||t.excludeLayers&&t.excludeLayers.length>0){let r=i!=null?We.mapClassificationToTier(i):We.classify(e);if(t.layer!=null&&r!==t.layer||t.excludeLayers?.includes(r))return!1}return!0}async searchByPath(e,t,n,i,r,o=!1){let a=this.extractPathKeywords(e),c=this.isLikelySymbolQuery(e),l=this.filesRepo.findByPathKeywords(a,Math.min((t??50)*(r?ge.FILTERED_QUERY_LIMIT_MULTIPLIER:1),ke.MAX_LIMIT)).map(b=>({...b,source:"path",keywordHits:this.countPathKeywordHits(b.path,a),relevance:this.scorePathResult(b.path,a,"path",c)}));r&&(l=l.filter(b=>s.matchesFilters(b.path,i,b.mtime,b.classification))),c&&a.length>=3&&(l=l.filter(b=>b.source==="symbol"||b.keywordHits>=2));let p=this.findSymbolBackedPaths(e,a,t*3),u=new Set(l.map(b=>b.path));for(let b of p){if(u.has(b))continue;let w=this.filesRepo.findByPath(b);w&&(r&&!s.matchesFilters(w.path,i,w.mtime,w.classification)||(l.push({...w,source:"symbol",keywordHits:this.countPathKeywordHits(w.path,a),relevance:this.scorePathResult(w.path,a,"symbol",c)}),u.add(b)))}l.sort((b,w)=>w.relevance-b.relevance),r||(l=l.slice(0,Math.min(t*4,ke.MAX_LIMIT)));let d=l.length;if(d===0)return{content:[{type:"text",text:`No indexed files match path/filename: "${e}".
|
|
706
|
+
|
|
707
|
+
If the repo is not indexed, run shadow_recon_onboard then shadow_sync_trace. Otherwise try broader keywords.`}]};let h=b=>b.replace(this.repoPath,"").replace(/^\//,"");if(o){let w=new Se(this.repoPath).getSection("gravity"),x=new Map;if(w?.hotspots)for(let E of w.hotspots){let T=x.get(E.filePath)||0;x.set(E.filePath,T+E.gravity)}let R=l.map(E=>{let T=x.get(E.path)||0,I=E.classification?We.mapClassificationToTier(E.classification):We.classify(E.path);return{...E,gravity:T,layer:I}});R.sort((E,T)=>T.gravity!==E.gravity?T.gravity-E.gravity:T.relevance!==E.relevance?T.relevance-E.relevance:E.path.localeCompare(T.path));let k=R.slice(n,n+t),D=n+t<d;if(k.length===0)return{content:[{type:"text",text:`No results at offset ${n}. Total matches: ${d}.`}]};let U=D?`
|
|
708
|
+
> **Note**: More results available. Use \`offset: ${n+t}\` to see the next page.`:"";return{content:[{type:"text",text:`# Resolved paths: "${e}" (Ranked by Gravity)
|
|
709
|
+
|
|
710
|
+
Showing ${k.length} of ${d} file(s) (offset: ${n}, limit: ${t})${U}
|
|
711
|
+
|
|
712
|
+
`+k.map((E,T)=>{let I=E.gravity>50?" \u269B\uFE0F":E.gravity>0?" \u2022":"",M=E.gravity>0?` [G:${Math.round(E.gravity)}]`:"",N=E.source==="symbol"?" [via symbol]":"";return`${n+T+1}. \`${h(E.path)}\` (${E.layer})${I}${M}${N}`}).join(`
|
|
593
713
|
`)+`
|
|
594
714
|
|
|
595
|
-
> **Legend**: \u269B\uFE0F = High-gravity hotspot (>50), \u2022 = Has gravity, G = Gravity score`}]}}let m=l.slice(
|
|
596
|
-
> **Note**: More results available. Use \`offset: ${
|
|
715
|
+
> **Legend**: \u269B\uFE0F = High-gravity hotspot (>50), \u2022 = Has gravity, G = Gravity score`}]}}let m=l.slice(n,n+t),f=n+t<d;if(m.length===0)return{content:[{type:"text",text:`No results at offset ${n}. Total matches: ${d}.`}]};let _=f?`
|
|
716
|
+
> **Note**: More results available. Use \`offset: ${n+t}\` to see the next page.`:"";return{content:[{type:"text",text:`# Resolved paths: "${e}"
|
|
597
717
|
|
|
598
|
-
Showing ${m.length} of ${
|
|
718
|
+
Showing ${m.length} of ${d} file(s) (offset: ${n}, limit: ${t})${_}
|
|
599
719
|
|
|
600
|
-
`+m.map((
|
|
601
|
-
`)}]}}async searchByConcept(e,
|
|
602
|
-
> **Note**: More results available. Use \`offset: ${
|
|
603
|
-
> _Compact mode: snippets omitted_`:
|
|
720
|
+
`+m.map((b,w)=>{let x=b.source==="symbol"?" [via symbol]":"";return`${n+w+1}. \`${h(b.path)}\`${b.classification?` (${b.classification})`:""}${x}`}).join(`
|
|
721
|
+
`)}]}}async searchByConcept(e,t,n,i,r,o=!1,a){S.info({repoPath:this.repoPath,query:e},"Searching by concept (Semantic Analysis)...");let c=await ts(e),l=x=>x.replace(this.repoPath,"").replace(/^\//,""),p=ht.extractKeywords(e),u=this.classifyConceptQuery(e,p),d=this.getConceptConfidenceFloor(u.profile),h=this.getIntentConfidenceFloor(u.profile),m=Math.min(Math.max((t+n)*2,t),ke.MAX_LIMIT),f=await this.findConceptMatches(e,c,i,r,m,0),_=c?await this.findIntentLogMatches(c,5):[],g=f.filter(x=>(x.score||0)>=d),b=f.filter(x=>(x.score||0)<d),w=_.filter(x=>(x.score||0)>=h);if(g.length>0){let x=g.length,R=g.slice(n,n+t),D=n+t<x?`
|
|
722
|
+
> **Note**: More results available. Use \`offset: ${n+t}\` to see the next page.`:"",U=o?`
|
|
723
|
+
> _Compact mode: snippets omitted_`:x>20&&!o?"\n> \u{1F4A1} **Tip**: Use `compact: true` to reduce output size (omits snippets).":"",P=a&&a>0?`
|
|
724
|
+
> _Adaptive compression enabled under token budget._`:"",E=b.length>0?`
|
|
725
|
+
> _${b.length} lower-confidence candidate(s) were suppressed below the ${Math.round(d*100)}% evidence floor._`:"",T=`# Semantic Concept Search: "${e}"
|
|
604
726
|
|
|
605
|
-
Showing ${
|
|
727
|
+
Showing ${R.length} of ${x} high-confidence file(s) (offset: ${n}, limit: ${t})${D}${U}${P}${E}
|
|
606
728
|
|
|
607
|
-
`,
|
|
608
|
-
|
|
609
|
-
>
|
|
610
|
-
> **Rationale**: ${w.rationale}${N}
|
|
729
|
+
`,M=new Se(this.repoPath).getSection("gravity"),N=new Map;if(M?.hotspots)for(let A of M.hotspots)N.set(A.filePath,A.gravity);let $=R.map((A,H)=>{let F=l(A.path),v=Math.round((A.score||0)*100),B=N.get(A.path)?" \u269B\uFE0F":"";return`${n+H+1}. \`${F}\`${B} (${v}% evidence) - ${A.summary||"No summary"}`}),W=R.map((A,H)=>{let F=l(A.path),v=Math.round((A.score||0)*100),C=N.get(A.path),B=C?" \u269B\uFE0F **CORE**":"",j=C&&C>50?`
|
|
730
|
+
> \u26A0\uFE0F **STRATEGIC RISK**: High-gravity hotspot (${C.toFixed(0)}). Modifications may have significant architectural impact.`:"",J=`## ${n+H+1}. ${F}${B} (${v}% Evidence Match)
|
|
731
|
+
> **Rationale**: ${A.rationale}${j}
|
|
611
732
|
|
|
612
|
-
`+(
|
|
733
|
+
`+(A.snippet?`**Matched Snippet**:
|
|
613
734
|
\`\`\`typescript
|
|
614
|
-
${
|
|
735
|
+
${A.snippet}
|
|
615
736
|
\`\`\`
|
|
616
737
|
|
|
617
|
-
`:"")+`**Summary**: ${
|
|
618
|
-
|
|
619
|
-
`);
|
|
738
|
+
`:"")+`**Summary**: ${A.summary||"No summary available"}
|
|
739
|
+
`;return{index:n+H+1,relativePath:F,matchPct:v,gravity:C,text:J}}),L="";if(o)L=T+$.join(`
|
|
740
|
+
`);else if(a&&a>0){let A=Math.max(80,Math.floor(a*.12)),H=this.estimateTokenCount(T),F=[],v=[];for(let C of W){let B=this.estimateTokenCount(C.text),j=H+B<=a-A;if(F.length<2||j)F.push(C.text),H+=B;else{let J=C.gravity?" \u269B\uFE0F":"";v.push(`${C.index}. \`${C.relativePath}\`${J} (${C.matchPct}% Evidence Match)`)}}L=T+F.join(`
|
|
741
|
+
`),v.length>0&&(L+=`
|
|
742
|
+
|
|
743
|
+
### Folded Lower-Relevance Matches (${v.length})
|
|
744
|
+
_Expanded blocks omitted to stay within token budget._
|
|
745
|
+
`+v.join(`
|
|
746
|
+
`))}else L=T+W.map(A=>A.text).join(`
|
|
747
|
+
`);if(w.length>0){let A=`
|
|
620
748
|
|
|
621
749
|
---
|
|
622
|
-
## Intent Vectors (${
|
|
750
|
+
## Intent Vectors (${w.length} matching decision(s))
|
|
623
751
|
|
|
624
|
-
|
|
625
|
-
> ${
|
|
752
|
+
`+w.map((F,v)=>{let C=Math.round((F.score||0)*100),B=F.symbolName?` \`${F.symbolName}\``:"",j=F.missionId?` [Mission #${F.missionId}]`:"",J=F.content.length>200?F.content.slice(0,200)+"...":F.content;return o?`${v+1}. **[${F.type}]**${B}${j} (${C}%) - ${J}`:`### ${v+1}. [${F.type}]${B}${j} (${C}% Evidence Match)
|
|
753
|
+
> ${J}
|
|
626
754
|
`}).join(`
|
|
627
|
-
`)
|
|
755
|
+
`),H=`
|
|
756
|
+
|
|
757
|
+
---
|
|
758
|
+
## Intent Vectors (${w.length} matching decision(s))
|
|
628
759
|
|
|
629
|
-
|
|
760
|
+
`+w.slice(0,2).map((F,v)=>{let C=Math.round((F.score||0)*100),B=F.symbolName?` \`${F.symbolName}\``:"",j=F.missionId?` [Mission #${F.missionId}]`:"";return`${v+1}. **[${F.type}]**${B}${j} (${C}%)`}).join(`
|
|
761
|
+
`)+(w.length>2?`
|
|
762
|
+
> Additional intent matches folded by token budget.`:"");a&&a>0&&this.estimateTokenCount(L+A)>a?L+=H:L+=A}return{content:[{type:"text",text:L}]}}if(n===0){let x=this.filesRepo.getStats(),R=e.toLowerCase().split(/\s+/),k=this.filesRepo.findByPathKeywords(R,t);if(r&&(k=k.filter(D=>s.matchesFilters(D.path,i,D.mtime,D.classification))),k.length>0)return{content:[{type:"text",text:`# Concept Search: "${e}"
|
|
630
763
|
|
|
631
|
-
|
|
764
|
+
\u26A0\uFE0F No high-confidence semantic matches cleared the ${Math.round(d*100)}% evidence floor (${x.withSummary}/${x.total} summaries indexed).
|
|
632
765
|
|
|
633
|
-
|
|
634
|
-
`)}]}}return{content:[{type:"text",text:`No files found matching concept: "${e}"
|
|
766
|
+
Found ${k.length} file(s) with matching paths:
|
|
635
767
|
|
|
636
|
-
|
|
768
|
+
`+k.map((U,P)=>`${P+1}. \`${l(U.path)}\` (${U.classification||"Unknown"})`).join(`
|
|
769
|
+
`)}]};if(b.length>0){let D=b.slice(0,Math.min(3,t)).map((U,P)=>{let E=Math.round((U.score||0)*100);return`${P+1}. \`${l(U.path)}\` (${E}% evidence) - ${U.summary||"No summary"}`}).join(`
|
|
770
|
+
`);return{content:[{type:"text",text:`# Semantic Concept Search: "${e}"
|
|
771
|
+
|
|
772
|
+
No high-confidence semantic matches cleared the evidence floor (${Math.round(d*100)}% required for ${u.profile} queries).
|
|
773
|
+
|
|
774
|
+
Low-confidence candidates were suppressed instead of being presented as relevant matches:
|
|
775
|
+
${D?`
|
|
776
|
+
${D}
|
|
777
|
+
|
|
778
|
+
`:`
|
|
779
|
+
`}Try adding distinctive identifiers, narrowing the concept, or using shadow_search_symbol({ query: "${e}", repoPath }).`}]}}}return{content:[{type:"text",text:`No high-confidence files found matching concept: "${e}"
|
|
780
|
+
|
|
781
|
+
Try a symbol search: shadow_search_symbol({ query: "${e}", repoPath })`}]}}async searchBySymbol(e,t,n,i,r,o="any"){let a=e.toLowerCase(),c=E=>E.replace(this.repoPath,"").replace(/^\//,""),l=this.buildFtsQuery(e,o),p;try{p=this.exportsRepo.findFts(l,t+50)}catch{p=this.exportsRepo.findByPartialName(e,t+50)}if(p.length===0){let E=this.exportsRepo.getAllNames(5e3),T=e.trim().split(/\s+/).filter(M=>M.length>0);if(T.length>1){let M=new Map;for(let $ of T){let W=bn($,E,40,20);for(let L of W){let A=M.get(L.match);A?(A.terms.push($),A.bestScore=Math.max(A.bestScore,L.score)):M.set(L.match,{terms:[$],bestScore:L.score})}}let N=Array.from(M.entries()).sort(($,W)=>W[1].terms.length!==$[1].terms.length?W[1].terms.length-$[1].terms.length:W[1].bestScore-$[1].bestScore).slice(0,10);if(N.length>0){let $=N.map(([W,L])=>{let A=L.terms.join(", ");return` \u2022 \`${W}\` (matches: ${A}, ${Math.round(L.bestScore)}%)`}).join(`
|
|
637
782
|
`);return{content:[{type:"text",text:`No symbols found matching all terms: "${e}"
|
|
638
783
|
|
|
639
784
|
**Partial matches:**
|
|
640
|
-
${
|
|
785
|
+
${$}
|
|
641
786
|
|
|
642
|
-
\u{1F4A1} Try searching for individual terms, or use shadow_search_concept for semantic search.`}]}}}else{let
|
|
787
|
+
\u{1F4A1} Try searching for individual terms, or use shadow_search_concept for semantic search.`}]}}}else{let M=bn(e,E,50,5);if(M.length>0){let N=M.map($=>` \u2022 \`${$.match}\` (${Math.round($.score)}% ${$.matchType} match)`).join(`
|
|
643
788
|
`);return{content:[{type:"text",text:`No symbols found matching: "${e}"
|
|
644
789
|
|
|
645
790
|
**Did you mean?**
|
|
646
|
-
${
|
|
791
|
+
${N}
|
|
647
792
|
|
|
648
793
|
\u{1F4A1} Try shadow_search_symbol with fuzzy, or shadow_search_concept for semantic search.`}]}}}return{content:[{type:"text",text:`No symbols found matching: "${e}"
|
|
649
794
|
|
|
650
|
-
\u{1F4A1} Try shadow_search_symbol (fuzzy) or shadow_search_concept for semantic search.`}]}}
|
|
651
|
-
`);
|
|
652
|
-
`).trim()}let
|
|
795
|
+
\u{1F4A1} Try shadow_search_symbol (fuzzy) or shadow_search_concept for semantic search.`}]}}r&&(p=p.filter(E=>{let T=this.filesRepo.findByPath(E.file_path);return s.matchesFilters(E.file_path,i,T?.mtime,T?.classification)}));let u=new yn(this.repoPath),d=new Se(this.repoPath),h=u.getAncestorMissionIds(),m=me(this.repoPath)||void 0,f=this.exportsRepo.getGravityMap(h,m),_=d.getSection("gravity"),g=new Map;if(_?.hotspots)for(let E of _.hotspots)g.set(`${E.filePath}::${E.symbol}`,E.gravity);let b="\u{1F525}",w="\u26A1",x="\u269B\uFE0F",R=p.map((E,T)=>{let I=f[E.id],M=g.get(`${E.file_path}::${E.name}`),N=this.filesRepo.findByPath(E.file_path),$=We.getMultiplier(E.file_path,N?.classification),W=(ge.SCORE_BASE-T)*$;I&&(W+=I.score*ge.SCORE_BASE),M&&(W+=M*ge.SCORE_BASE*ge.GRAVITY_STRUCTURAL_WEIGHT),E.name.toLowerCase()===a&&(W+=ge.EXACT_MATCH_BONUS*$);let L=N?.mtime;if(L!=null){let H=L>1e10?L/1e3:L,F=(Date.now()/1e3-H)/ls.SECONDS_PER_DAY;F<ge.RECENT_FILE_THRESHOLD_DAYS?W+=ge.RECENT_FILE_BOOST:F<ge.OLDER_FILE_THRESHOLD_DAYS&&(W+=ge.OLDER_FILE_BOOST)}let A=[];return I&&A.push(...I.reasons),M&&A.push(`Structural Hotspot (Gravity: ${M.toFixed(1)})`),{...E,activeGravity:I,structuralGravity:M,sortScore:W,reasons:A}}).sort((E,T)=>T.sortScore-E.sortScore).slice(n,n+t),k=p.length,D=n+t<k,U=R.map((E,T)=>{let I=c(E.file_path),M=this.filesRepo.getContent(E.file_path),N="";if(M){let L=M.split(`
|
|
796
|
+
`);N=L.slice(Math.max(0,E.start_line-2),Math.min(L.length,E.start_line+3)).join(`
|
|
797
|
+
`).trim()}let $=[];E.activeGravity&&(E.activeGravity.reasons.some(L=>L.includes("Working Set"))?$.push(b):E.activeGravity.reasons.some(L=>L.includes("Recent Intent"))&&$.push(w)),E.structuralGravity&&$.push(x);let W=$.length>0?` ${$.join("")}`:"";return{relPath:I,name:E.name,kind:E.kind,signature:E.signature,line:E.start_line,snippet:N,badgeStr:W,gravityReasons:E.reasons}});return{content:[{type:"text",text:`# Symbol Search Results: "${e}"
|
|
653
798
|
|
|
654
|
-
Showing ${
|
|
799
|
+
Showing ${U.length} matching symbol(s)${D?` (use offset=${n+t} for more)`:""}:
|
|
655
800
|
|
|
656
|
-
`+
|
|
657
|
-
**File**: \`${
|
|
658
|
-
`;return
|
|
659
|
-
`),
|
|
660
|
-
`),
|
|
801
|
+
`+U.map((E,T)=>{let I=`## ${n+T+1}. \`${E.name}\` (${E.kind})${E.badgeStr}
|
|
802
|
+
**File**: \`${E.relPath}:${E.line}\`
|
|
803
|
+
`;return E.gravityReasons&&(I+=`> *${E.gravityReasons.join(", ")}*
|
|
804
|
+
`),E.signature&&(I+=`**Signature**: \`${E.signature}\`
|
|
805
|
+
`),E.snippet&&(I+=`
|
|
661
806
|
\`\`\`typescript
|
|
662
|
-
${
|
|
807
|
+
${E.snippet}
|
|
663
808
|
\`\`\`
|
|
664
|
-
`),
|
|
665
|
-
`)}]}}async findConceptMatches(e,
|
|
666
|
-
${
|
|
667
|
-
${W||""}`,v),V=b.has(N.path),re=1;if(W){let Kr=/\b(class|function|const|let|var|enum)\s+\w+/.test(W);if(/export\s+/.test(W)&&!Kr){let cx=W.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"");/\b(class|function|const|let|var|enum)\s+\w+/.test(cx)||(re=.1)}}let le=V?.08:q>0||Q>0||D?.14:m?.22:.18;if(C&&F<=le&&!D)continue;if(f.length>0&&q===0&&!D){if(m){if(!V&&(H===0&&Q===0&&F<.4||H<=1&&Q===0&&F<.34||H===1&&F<.3))continue}else if(H===0&&F<.24)continue}if(m&&!V&&Q===0&&H<=1&&F<.3&&!D||t&&!n.matchesFilters(N.path,i,N.mtime,N.classification))continue;let fe=N.mtime>2e9?Math.floor(N.mtime/1e3):N.mtime,se=Math.floor(Date.now()/1e3)-Ec.SECONDS_PER_YEAR,K=gt.getMultiplier(N.path,N.classification),G=C?l.calculateScore(F,fe||se):0,Ne=T.fusedScore*60,Ee=(Ne+G*.2)*K,He=p[N.path],Pe=N.classification?gt.mapClassificationToTier(N.classification):gt.classify(N.path,{content:W??void 0}),$e=`vector_rank: ${this.formatRank(T.vectorRank)} | fts_rank: ${this.formatRank(T.ftsRank)} | fused_score: ${T.fusedScore.toFixed(6)} | Similarity: ${(F*100).toFixed(0)}%, Tier: ${Pe}${K!==1?` (${K}x)`:""}`;if(V&&($e+=" | SymbolHint"),q>0&&(Ee+=q*Me.LEXICAL_WEIGHT,$e+=` | Lexical: +${q.toFixed(1)}`),f.length>0)if(B>0){let Kr=m?B*.45:B*.35;Ee+=Kr,$e+=` | Keywords: ${(B*100).toFixed(0)}%`}else $e+=" | Keywords: 0%",m&&!D&&(Ee*=.55,$e+=" (penalty)");if(v.length>0)if(Q>0){let Kr=m?Q*.8:Q*.35;Ee+=Kr,$e+=` | Phrases: ${(Q*100).toFixed(0)}%`}else m&&!D&&(Ee*=.72,$e+=" | Phrases: 0% (penalty)");He&&(Ee+=He.score,$e+=` | \u{1F525} Gravity: +${He.score.toFixed(1)} (${He.reasons.join(", ")})`),m&&this.isGenericConceptPath(N.path)&&H<=1&&Q===0&&!D&&(Ee*=.75,$e+=" | Generic path penalty"),re<1&&(Ee*=re,$e+=` | \u{1F4C9} Barrel: x${re}`);let Vr=W?Nn.extractSnippet(W,e):void 0,ax=Math.max(F,Math.min(1,Ne));R.push({path:N.path,summary:N.summary||"",score:ax,fusedScore:T.fusedScore,vectorRank:T.vectorRank,ftsRank:T.ftsRank,decayedScore:Ee,rationale:$e,snippet:Vr}),U.set(N.path,{lexicalScore:q,keywordCoverage:B,matchedKeywordCount:H,phraseCoverage:Q})}if(R.length>0&&f.length>0){let T=this.exportsRepo.findByFiles(R.map(F=>F.path)),N=new Map;for(let F of T){let D=N.get(F.file_path)??[];D.push(F.name),N.set(F.file_path,D)}for(let F of R){let D=this.calculateIdentifierOverlap(f,N.get(F.path)??[]);if(D>0){let C=m?D*.8:D*.25;F.decayedScore=(F.decayedScore||0)+C,F.rationale+=` | Symbols: ${(D*100).toFixed(0)}%`}else m&&this.isGenericConceptPath(F.path)&&(F.decayedScore=(F.decayedScore||0)*.82,F.rationale+=" | Symbols: 0% (generic penalty)")}}let I=new Map;for(let T of R){let N=T.path.split("/").pop()?.split(".")[0].replace(/(Controller|Service|Repository|Component|View|Page|Handler|Wrapper|Client|DTO|Interface)$/i,"").toLowerCase();N&&N.length>3&&(I.has(N)||I.set(N,[]),I.get(N).push(T))}for(let[T,N]of I.entries())if(new Set(N.map(D=>D.path.split(".").pop())).size>1)for(let D of N)D.decayedScore=(D.decayedScore||0)+.15,D.rationale+=` | \u{1F310} Polyglot Flow: +0.15 (Linked via '${T}')`;if(m&&R.length>1){let T=Math.min(Math.max(o*4,Me.FILTERED_QUERY_LIMIT_MULTIPLIER*20),R.length),N=[...R].sort((D,C)=>(C.decayedScore||0)-(D.decayedScore||0)).slice(0,T),F=this.computeBm25LikeConfirmation(N.map(D=>D.path),f);for(let D of N){let C=F.get(D.path)||0,W=U.get(D.path);if(C>0){let q=Math.min(.95,C*.18);D.decayedScore=(D.decayedScore||0)+q,D.rationale+=` | LexConfirm: +${q.toFixed(2)}`}else W&&W.matchedKeywordCount<=1&&W.phraseCoverage===0&&W.lexicalScore===0&&(D.decayedScore=(D.decayedScore||0)*.85,D.rationale+=" | LexConfirm: 0 (penalty)")}}return R.sort((T,N)=>(N.decayedScore||0)-(T.decayedScore||0)),R.slice(s,s+Math.min(o,he.MAX_LIMIT))}async findIntentLogMatches(e,r){return(await this.intentLogsRepo.findSemanticMatches(e,r)).map(t=>({id:t.id,missionId:t.mission_id,type:t.type,content:t.content,symbolName:t.symbol_name,filePath:t.file_path,score:t.similarity,decayedScore:t.similarity,rationale:`Similarity: ${(t.similarity*100).toFixed(0)}%`,createdAt:t.created_at}))}buildFtsQuery(e,r){let i=e.trim();if(!i.includes(" "))return`"${i}" OR ${i}*`;let t=i.split(/\s+/).filter(o=>o.length>0);switch(r){case"exact":return`"${i}"`;case"all":return t.map(o=>`${o}*`).join(" ");default:return t.map(o=>`${o}*`).join(" OR ")}}extractPathKeywords(e){let r=e.trim();if(!r)return[];let i=r.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9_\/.-]+/).map(o=>o.trim()).filter(o=>o.length>=2),t=new Set;t.add(r.toLowerCase());for(let o of i)t.add(o);return Array.from(t)}isLikelySymbolQuery(e){let r=e.trim();return!r||/[\/\\]/.test(r)?!1:/^[a-z]+(?:[A-Z][a-z0-9]+)+$/.test(r)||!r.includes(" ")&&/[A-Z]/.test(r)}countPathKeywordHits(e,r){let i=e.toLowerCase(),t=r.filter(s=>s.length>=3),o=0;for(let s of t)i.includes(s.toLowerCase())&&(o+=1);return o}scorePathResult(e,r,i,t){let s=this.countPathKeywordHits(e,r)*10;i==="symbol"&&(s+=25);let a=e.toLowerCase(),c=a.includes("/.env")||a.endsWith(".env")||a.endsWith(".yml")||a.endsWith(".yaml")||a.endsWith(".json")||a.endsWith(".md");return t&&c&&(s-=20),t&&a.includes("/tests/")&&(s-=15),s}findSymbolBackedPaths(e,r,i){let t=e.trim().toLowerCase();if(!t)return[];if(/[\/\\]/.test(t))return[];let o=Array.from(new Set([t,...r])).filter(c=>c.length>=3).slice(0,6);if(o.length===0)return[];let s=o.flatMap(c=>{let l=c===t?Math.min(i,60):Math.min(i,30);return this.exportsRepo.findByPartialName(c,l)}),a=new Map;for(let c of s){let l=c.name.toLowerCase(),u=0;l===t&&(u+=6),l.startsWith(t)&&(u+=4),l.includes(t)&&(u+=3);for(let p of r)p.length>=3&&l.includes(p)&&(u+=1);if(u===0)continue;let d=a.get(c.file_path)||0;u>d&&a.set(c.file_path,u)}return Array.from(a.entries()).sort((c,l)=>l[1]-c[1]).slice(0,Math.min(i,he.MAX_LIMIT)).map(([c])=>c)}rrfMerge(e,r,i){let t=new Map,o=1.2,s=.8;for(let a of e){let c=t.get(a.path)||{path:a.path,row:a.row,vectorRank:null,ftsRank:null,fusedScore:0};c.vectorRank=a.rank,c.fusedScore+=o/(i+a.rank),t.set(a.path,c)}for(let a of r){let c=t.get(a.path)||{path:a.path,row:a.row,vectorRank:null,ftsRank:null,fusedScore:0};c.ftsRank=a.rank,c.fusedScore+=s/(i+a.rank),t.set(a.path,c)}return Array.from(t.values()).sort((a,c)=>c.fusedScore-a.fusedScore)}formatRank(e){return e==null?"none":String(e)}extractOrderedConceptTerms(e){return e?e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9_]+/).map(r=>r.trim()).filter(r=>r.length>=3):[]}buildNgrams(e,r,i){if(e.length<r)return[];let t=[];for(let o=r;o<=i&&!(e.length<o);o++)for(let s=0;s<=e.length-o;s++)t.push(e.slice(s,s+o).join(" "));return Array.from(new Set(t))}calculatePhraseCoverage(e,r){if(!e||r.length===0)return 0;let i=e.toLowerCase(),t=0;for(let o of r)i.includes(o)&&(t+=1);return t/r.length}calculateIdentifierOverlap(e,r){if(e.length===0||r.length===0)return 0;let i=new Set(e.map(s=>s.toLowerCase())),t=new Set;for(let s of r){let a=s.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9_]+/).map(c=>c.trim()).filter(c=>c.length>=3);for(let c of a)t.add(c)}let o=0;for(let s of i)t.has(s)&&(o+=1);return o/i.size}isGenericConceptPath(e){let r=e.toLowerCase();return/(?:^|\/)(index|utils?|helpers?|common|shared|types?|constants?|models?)(?:\/|\.|$)/.test(r)}computeBm25LikeConfirmation(e,r){let i=Array.from(new Set(r.map(d=>d.toLowerCase()).filter(d=>d.length>=3)));if(e.length===0||i.length===0)return new Map;let t=new Set(i),o=[],s=new Map;for(let d of e){let f=(this.filesRepo.getContent(d)??"").toLowerCase().split(/[^a-z0-9_]+/).map(h=>h.trim()).filter(Boolean),m=new Map;for(let h of f)t.has(h)&&m.set(h,(m.get(h)||0)+1);for(let h of i)(m.get(h)||0)>0&&s.set(h,(s.get(h)||0)+1);o.push({path:d,frequencies:m,length:Math.max(f.length,1)})}let a=o.reduce((d,p)=>d+p.length,0)/Math.max(o.length,1),c=1.2,l=.75,u=new Map;for(let d of o){let p=0;for(let f of i){let m=d.frequencies.get(f)||0;if(m===0)continue;let h=s.get(f)||0,v=Math.log(1+(o.length-h+.5)/(h+.5)),b=m*(c+1)/(m+c*(1-l+l*(d.length/Math.max(a,1))));p+=v*b}u.set(d.path,p)}return u}collectConceptSymbolHintPaths(e,r){let i=Array.from(new Set(e.filter(o=>o.length>=4&&!this.isLowSignalConceptKeyword(o)))).slice(0,6);if(i.length===0)return new Set;let t=new Map;for(let o of i){let s=this.exportsRepo.findByPartialName(o,Math.min(r,80));for(let a of s){let c=a.name.toLowerCase(),l=0;c===o&&(l+=3),c.startsWith(o)&&(l+=2),c.includes(o)&&(l+=1),l!==0&&t.set(a.file_path,(t.get(a.file_path)||0)+l)}}return new Set(Array.from(t.entries()).sort((o,s)=>s[1]-o[1]).slice(0,Math.min(r,he.MAX_LIMIT)).map(([o])=>o))}isLowSignalConceptKeyword(e){return new Set(["type","types","data","update","create","list","item","value","model","helper"]).has(e.toLowerCase())}};Je();ht();function Dn(n){let{fileType:e,layer:r}=n,i={fileType:ot.normalizeFileType(e),layer:r},t=!!(i.fileType?.length||i.layer!=null);return{filters:i,hasFilters:t}}X();Je();import{Visitor as VS}from"@swc/core/Visitor.js";var or=class extends VS{calls=new Set;apiCalls=[];imports=new Map;axiosInstances=new Map([["axios",""],["http",""],["appApi",""],["restApi",""],["adminApi",""]]);visitImportDeclaration(e){let r=e.source.value;for(let i of e.specifiers)(i.type==="ImportDefaultSpecifier"||i.type==="ImportSpecifier")&&this.imports.set(i.local.value,r);return super.visitImportDeclaration(e)}visitCallExpression(e){if(e.callee.type==="Identifier"){let r=e.callee.value;this.calls.add(r),(r==="axios"||r==="http")&&e.arguments.length>0&&this.extractApiCallFromConfig(e.arguments[0].expression)}else if(e.callee.type==="MemberExpression"){let r=e.callee.property.value,i=o=>{if(!o)return"?";if(o.type==="Identifier")return o.value;if(o.type==="ThisExpression")return"this";if(o.type==="MemberExpression"){let s=i(o.object),a=o.property.value||"?";return`${s}.${a}`}return o.type==="TsNonNullExpression"||o.type==="TsAsExpression"||o.type==="ParenthesisExpression"?i(o.expression):"?"},t=i(e.callee.object);if(t!=="?"&&r){if(this.calls.add(`${t}.${r}`),t==="axios"||t==="http"||this.axiosInstances.has(t)){let o=this.axiosInstances.get(t)||"";this.extractApiCall(r,e.arguments,o)}if((t.toLowerCase().includes("pubsub")||t==="pubSubClient"||t.endsWith(".pubSubClient"))&&r!=="subscribe"){let o=r;if((r==="publish"||r==="publishMessage"||r==="publishTaskByNameAndPayload")&&e.arguments.length>0)for(let s of e.arguments){let a=s.expression;if(a.type==="ObjectExpression"){let c=a.properties.find(l=>l.key?.type==="Identifier"&&(l.key.value==="action"||l.key.value==="type")||l.key?.type==="StringLiteral"&&(l.key.value==="action"||l.key.value==="type"));if(c&&c.value?.type==="StringLiteral"){o=c.value.value;break}}if(a.type==="CallExpression"&&a.callee.type==="MemberExpression"&&a.callee.object.value==="JSON"&&a.callee.property.value==="stringify"&&a.arguments.length>0){let c=a.arguments[0].expression;if(c.type==="ObjectExpression"){let l=c.properties.find(u=>u.key?.type==="Identifier"&&(u.key.value==="action"||u.key.value==="type")||u.key?.type==="StringLiteral"&&(u.key.value==="action"||u.key.value==="type"));if(l&&l.value?.type==="StringLiteral"){o=l.value.value;break}}}}this.apiCalls.push({method:"PUBSUB",url:o})}}}return e.callee.type==="Identifier"&&e.callee.value==="fetch"&&this.extractApiCall("GET",e.arguments),super.visitCallExpression(e)}visitNewExpression(e){return e.callee.type==="Identifier"&&this.calls.add(e.callee.value),super.visitNewExpression(e)}visitVariableDeclarator(e){if(e.init&&e.init.type==="CallExpression"){let r=e.init.callee;if(r.type==="MemberExpression"&&r.property.value==="create"&&r.object.value==="axios"){let t=e.init.arguments[0]?.expression;if(t&&t.type==="ObjectExpression"){let o=t.properties.find(s=>s.key.value==="baseURL");if(o){let s="?";o.value.type==="StringLiteral"?s=o.value.value:o.value.type==="Identifier"&&(s=`\${${o.value.value}}`),e.id.type==="Identifier"&&this.axiosInstances.set(e.id.value,s)}}}}return super.visitVariableDeclarator(e)}extractApiCallFromConfig(e){if(e&&e.type==="ObjectExpression"){let r=e.properties.find(t=>t.key.type==="Identifier"&&t.key.value==="url"||t.key.type==="StringLiteral"&&t.key.value==="url"),i=e.properties.find(t=>t.key.type==="Identifier"&&t.key.value==="method"||t.key.type==="StringLiteral"&&t.key.value==="method");if(r&&r.value){let t=i?.value?.value||"GET",o=this.resolveUrlValue(r.value);o!=="?"&&this.apiCalls.push({method:t.toUpperCase(),url:o})}}}resolveUrlValue(e){return e.type==="StringLiteral"?e.value:e.type==="TemplateLiteral"?e.quasis.map(r=>r.cooked).join("*"):"?"}visitTsType(e){return e}extractApiCall(e,r,i=""){if(r.length>0){let t=r[0].expression,o=this.resolveUrlValue(t);if(o!=="?"){if(i&&i!=="?"){let s=i.endsWith("/")||o.startsWith("/")?"":"/";o=`${i}${s}${o}`}this.apiCalls.push({method:e.toUpperCase(),url:o})}}}},Qt=class{calls=new Set;apiCalls=[];imports=new Map;visit(e,r){if(r===".php"){let i=/(?:([a-zA-Z0-9_$->:\(\)]*)?(?:->|::))?([a-zA-Z0-9_]+)\s*\(([\s\S]*?)\)/g,t;for(;(t=i.exec(e))!==null;){let o=t[1]||"",s=t[2],a=t[3];if(this.calls.add(s),o&&!["$this","self","parent"].includes(o)&&this.calls.add(`${o}${o.includes("::")?"::":"->"}${s}`),["save","delete","update","create","first","all","where","get","find"].includes(s)&&o&&!["Log","Route","Cache","Config","Http"].includes(o)&&this.apiCalls.push({method:"DB",url:`${o}->${s}()`}),s==="publish"&&o&&(o.includes("topic")||o.includes("pubSub"))&&this.apiCalls.push({method:"PUBSUB",url:"publish"}),["get","post","put","delete","patch","request"].includes(s)&&(o==="Http"||o==="client"||o.endsWith("request")||o.includes("Client")||!o)){let u=a.match(/(?:url\s*:\s*)?['"]([^'"]+)['"]/),d=u?u[1]:a.split(",")[0].trim()||"unknown";this.apiCalls.push({method:s.toUpperCase(),url:d})}}}else if(r===".py"){let i=/(?:([a-zA-Z0-9_\.]+)\.)?([a-zA-Z0-9_]+)\s*\(([\s\S]*?)\)/g,t;for(;(t=i.exec(e))!==null;){let o=t[1]||"",s=t[2],a=t[3];if(this.calls.add(s),o&&o!=="self"&&o!=="cls"&&this.calls.add(`${o}.${s}`),["save","delete","update","create","first","all","filter","get"].includes(s)&&o&&!["logger","os","sys"].includes(o)&&this.apiCalls.push({method:"DB",url:`${o}.${s}()`}),s==="publish"&&o&&(o.includes("publisher")||o.includes("client"))&&this.apiCalls.push({method:"PUBSUB",url:"publish"}),["get","post","put","delete","patch","request"].includes(s)&&(o==="requests"||o==="httpx"||o==="client"||o==="http"||!o)){let u=a.match(/(?:url\s*:\s*)?['"]([^'"]+)['"]/),d=u?u[1]:a.split(",")[0].trim()||"unknown";this.apiCalls.push({method:s.toUpperCase(),url:d})}}}else if([".ts",".tsx",".js",".jsx"].includes(r)){let i=/import\s+[\s\S]*?from\s+['"](.*?)['"];?/g,t;for(;(t=i.exec(e))!==null;)this.imports.set("*",t[1]);let o=/(?:([a-zA-Z0-9_$]+)\.)?([a-zA-Z0-9_$]+)\s*\(/g,s;for(;(s=o.exec(e))!==null;){let a=s[1],c=s[2];a?(this.calls.add(`${a}.${c}`),(a.toLowerCase().includes("pubsub")||a==="pubSubClient")&&c!=="subscribe"&&this.apiCalls.push({method:"PUBSUB",url:c})):this.calls.add(c)}}else{let i=/\.([a-zA-Z0-9_]+)\s*\(/g,t;for(;(t=i.exec(e))!==null;)this.calls.add(t[1])}if(r===".php"){let i=/use\s+([a-zA-Z0-9_\\]+)(?:\s+as\s+([a-zA-Z0-9_]+))?;/g,t;for(;(t=i.exec(e))!==null;){let o=t[1],s=o.split("\\"),a=t[2]||s[s.length-1];this.imports.set(a,o)}}else if(r===".py"){let i=/from\s+([a-zA-Z0-9_\.]+)\s+import\s+([a-zA-Z0-9_,\s]+)/g,t;for(;(t=i.exec(e))!==null;){let a=t[1];t[2].split(",").map(l=>l.trim()).forEach(l=>{this.imports.set(l,a)})}let o=/^import\s+([a-zA-Z0-9_\.]+)/gm,s;for(;(s=o.exec(e))!==null;){let a=s[1],c=a.split("."),l=c[c.length-1];this.imports.set(l,a)}}}};J();import o$ from"path";J();dt();import KS from"better-sqlite3";import sr from"path";import Hg from"fs";import YS from"os";import XS from"crypto";var QS=$.child({module:"fusion-connection"}),Go=5,e$=1,Wg=["files","exports","imports","configs","schema_migrations"],Jo=class{fusionDb;attachedRepos=new Map;fusionDbPath;name;constructor(e){this.name=e.name,this.fusionDbPath=this.getFusionDbPath(e.name),QS.info({name:e.name,path:this.fusionDbPath},"Initializing fused index connection");let r=sr.dirname(this.fusionDbPath);Hg.existsSync(r)||Hg.mkdirSync(r,{recursive:!0}),this.fusionDb=new KS(this.fusionDbPath),this.fusionDb.pragma("journal_mode = WAL"),this.fusionDb.pragma("busy_timeout = 5000"),this.initFusionSchema();for(let i of e.repoPaths)this.attachRepo(i)}getFusionDbPath(e){let r=YS.homedir(),i=sr.join(r,".mcp-liquid-shadow","fused"),t=e.replace(/[^a-zA-Z0-9-_]/g,"_");return sr.join(i,`${t}.db`)}initFusionSchema(){this.fusionDb.exec(`
|
|
809
|
+
`),I}).join(`
|
|
810
|
+
`)}]}}async findConceptMatches(e,t,n,i,r,o=0){let a=me(this.repoPath)||void 0,l=new Ri(this.repoPath).getScorer(),u=new yn(this.repoPath).getAncestorMissionIds(),d=this.filesRepo.getGravityMap(u,a),h=ht.extractKeywords(e),m=h.length>=3,f=this.extractOrderedConceptTerms(e),_=this.buildNgrams(f,2,3),g=this.classifyConceptQuery(e,h),b=m?this.collectConceptSymbolHintPaths(h,Math.max(r*10,100)):new Set,w=Math.min(Math.max((r+o)*g.channelMultiplier,ge.FILTERED_QUERY_LIMIT_MULTIPLIER*20),ke.MAX_LIMIT),x=Math.min(Math.max(w*4,200),4e3),[R,k,D]=await Promise.all([Promise.resolve(t?this.filesRepo.findWithEmbeddings():[]),Promise.resolve(this.filesRepo.findContentFts(e,w)),Promise.resolve(t?this.exportsRepo.findWithEmbeddings(x):[])]),U=[];if(t){for(let v of R)try{let C=JSON.parse(v.embedding),B=Mn(t,C);U.push({row:v,similarity:B,vectorRank:0})}catch{}U.sort((v,C)=>C.similarity-v.similarity);for(let v=0;v<U.length;v++)U[v].vectorRank=v+1}let P=[];if(t){for(let v of D)if(v.embedding)try{let C=JSON.parse(v.embedding),B=Mn(t,C);if(B<=0)continue;P.push({row:v,similarity:B,symbolVectorRank:0})}catch{}P.sort((v,C)=>C.similarity-v.similarity);for(let v=0;v<P.length;v++)P[v].symbolVectorRank=v+1}let E=new Map;for(let v of R)E.set(v.path,v);for(let v of k)E.has(v.path)||E.set(v.path,v);let T=new Map,I=[],M=new Set;for(let v of P.slice(0,x)){let C=v.row.file_path,B=T.get(C);if((!B||v.similarity>B.similarity)&&T.set(C,{similarity:v.similarity,symbolRank:v.symbolVectorRank,symbolName:v.row.name}),M.has(C))continue;let j=E.get(C);j||(j=this.filesRepo.findByPath(C),j&&E.set(C,j)),j&&(I.push({path:C,rank:v.symbolVectorRank,score:v.similarity,row:j,symbolName:v.row.name}),M.add(C))}let N=this.rrfMerge(U.slice(0,w).map(v=>({path:v.row.path,rank:v.vectorRank,score:v.similarity,row:v.row})),k.slice(0,w).map((v,C)=>({path:v.path,rank:C+1,bm25Rank:v.bm25_rank,row:v})),g.rrfK,{vectorWeight:g.vectorWeight,ftsWeight:g.ftsWeight,symbolWeight:g.symbolWeight,symbolResults:I.slice(0,w)});if(N.length===0)return[];let $=new Map;for(let v of U)$.set(v.row.path,v.similarity);let W=Math.min(N.length,Math.max(r*g.lexicalWindowMultiplier,40)),L=new Set(N.slice(0,W).map(v=>v.path)),A=[],H=new Map;for(let v of N){let C=v.row,B=$.get(C.path)||0,j=T.get(C.path),J=j?.similarity||0,z=Math.max(B,J),G=v.ftsRank!==null,we=v.symbolVectorRank!==null||!!j,xe=v.vectorRank!==null||we,he=b.has(C.path),le=L.has(C.path)||G||he||we;if(!le&&v.fusedScore<g.earlyRejectThreshold&&z<.18&&!i)continue;let re=le?this.filesRepo.getContent(C.path):null,He=ge.ENABLE_LEXICAL_SCORING&&re?ht.calculateLexicalScore(re,e):0,Mt=re?ht.calculateKeywordCoverageFromKeywords(re,h):0,_t=h.length>0?Math.round(Mt*h.length):0,ze=this.calculatePhraseCoverage(`${C.path}
|
|
811
|
+
${C.summary||""}
|
|
812
|
+
${re||""}`,_),Sn=1;if(re){let tn=/\b(class|function|const|let|var|enum)\s+\w+/.test(re);if(/export\s+/.test(re)&&!tn){let Dc=re.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"");/\b(class|function|const|let|var|enum)\s+\w+/.test(Dc)||(Sn=.1)}}let Lc=he?.08:we?.1:He>0||ze>0||G?.14:m?.22:.18;if(xe&&z<=Lc&&!G)continue;if(h.length>0&&He===0&&!G){if(m){if(!he&&(_t===0&&ze===0&&z<.4||_t<=1&&ze===0&&z<.34||_t===1&&z<.3))continue}else if(_t===0&&z<.24)continue}if(m&&!he&&ze===0&&_t<=1&&z<.3&&!G||i&&!s.matchesFilters(C.path,n,C.mtime,C.classification))continue;let $c=C.mtime>2e9?Math.floor(C.mtime/1e3):C.mtime,Ac=Math.floor(Date.now()/1e3)-ls.SECONDS_PER_YEAR,Bi=We.getMultiplier(C.path,C.classification),Pc=xe?l.calculateScore(z,$c||Ac):0,Ye=(v.fusedScore*60+Pc*.2)*Bi,wn=d[C.path],Mc=C.classification?We.mapClassificationToTier(C.classification):We.classify(C.path,{content:re??void 0}),ve=`vector_rank: ${this.formatRank(v.vectorRank)} | symbol_vector_rank: ${this.formatRank(v.symbolVectorRank)} | fts_rank: ${this.formatRank(v.ftsRank)} | fused_score: ${v.fusedScore.toFixed(6)} | query_profile: ${g.profile} | Similarity: ${(z*100).toFixed(0)}%, Tier: ${Mc}${Bi!==1?` (${Bi}x)`:""}`;if(he&&(ve+=" | SymbolHint"),j&&(ve+=` | SymbolVec: ${j.symbolName}`),He>0&&(Ye+=He*ge.LEXICAL_WEIGHT,ve+=` | Lexical: +${He.toFixed(1)}`),h.length>0)if(Mt>0){let tn=m?Mt*.45:Mt*.35;Ye+=tn,ve+=` | Keywords: ${(Mt*100).toFixed(0)}%`}else ve+=" | Keywords: 0%",m&&!G&&(Ye*=.55,ve+=" (penalty)");if(_.length>0)if(ze>0){let tn=m?ze*.8:ze*.35;Ye+=tn,ve+=` | Phrases: ${(ze*100).toFixed(0)}%`}else m&&!G&&(Ye*=.72,ve+=" | Phrases: 0% (penalty)");wn&&(Ye+=wn.score,ve+=` | \u{1F525} Gravity: +${wn.score.toFixed(1)} (${wn.reasons.join(", ")})`),m&&this.isGenericConceptPath(C.path)&&_t<=1&&ze===0&&!G&&(Ye*=.75,ve+=" | Generic path penalty"),Sn<1&&(Ye*=Sn,ve+=` | \u{1F4C9} Barrel: x${Sn}`);let Nc=re?ht.extractSnippet(re,e):void 0;A.push({path:C.path,summary:C.summary||"",score:z,fusedScore:v.fusedScore,vectorRank:v.vectorRank,ftsRank:v.ftsRank,decayedScore:Ye,rationale:ve,snippet:Nc}),H.set(C.path,{lexicalScore:He,keywordCoverage:Mt,matchedKeywordCount:_t,phraseCoverage:ze,similarity:z,hasFtsSignal:G,hasSymbolHint:he,hasSymbolVectorSignal:we,lexicalConfirm:0,identifierOverlap:0,isGenericPath:this.isGenericConceptPath(C.path)})}if(A.length>0&&h.length>0){let v=this.exportsRepo.findByFiles(A.map(B=>B.path)),C=new Map;for(let B of v){let j=C.get(B.file_path)??[];j.push(B.name),C.set(B.file_path,j)}for(let B of A){let j=this.calculateIdentifierOverlap(h,C.get(B.path)??[]),J=H.get(B.path);if(J&&(J.identifierOverlap=j),j>0){let z=m?j*.8:j*.25;B.decayedScore=(B.decayedScore||0)+z,B.rationale+=` | Symbols: ${(j*100).toFixed(0)}%`}else m&&this.isGenericConceptPath(B.path)&&(B.decayedScore=(B.decayedScore||0)*.82,B.rationale+=" | Symbols: 0% (generic penalty)")}}let F=new Map;for(let v of A){let C=v.path.split("/").pop()?.split(".")[0].replace(/(Controller|Service|Repository|Component|View|Page|Handler|Wrapper|Client|DTO|Interface)$/i,"").toLowerCase();C&&C.length>3&&(F.has(C)||F.set(C,[]),F.get(C).push(v))}for(let[v,C]of F.entries())if(new Set(C.map(j=>j.path.split(".").pop())).size>1)for(let j of C)j.decayedScore=(j.decayedScore||0)+.15,j.rationale+=` | \u{1F310} Polyglot Flow: +0.15 (Linked via '${v}')`;if(m&&A.length>1){let v=Math.min(Math.max(r*4,ge.FILTERED_QUERY_LIMIT_MULTIPLIER*20),A.length),C=[...A].sort((j,J)=>(J.decayedScore||0)-(j.decayedScore||0)).slice(0,v),B=this.computeBm25LikeConfirmation(C.map(j=>j.path),h);for(let j of C){let J=B.get(j.path)||0,z=H.get(j.path);if(z&&(z.lexicalConfirm=J),J>0){let G=Math.min(.95,J*.18);j.decayedScore=(j.decayedScore||0)+G,j.rationale+=` | LexConfirm: +${G.toFixed(2)}`}else z&&z.matchedKeywordCount<=1&&z.phraseCoverage===0&&z.lexicalScore===0&&(j.decayedScore=(j.decayedScore||0)*.85,j.rationale+=" | LexConfirm: 0 (penalty)")}}for(let v of A){let C=H.get(v.path);C&&(v.score=this.calculateConceptEvidenceScore({profile:g.profile,queryKeywordCount:h.length,...C}),v.rationale+=` | Evidence: ${(v.score*100).toFixed(0)}%`)}return A.sort((v,C)=>(C.decayedScore||0)-(v.decayedScore||0)),A.slice(o,o+Math.min(r,ke.MAX_LIMIT))}async findIntentLogMatches(e,t){return(await this.intentLogsRepo.findSemanticMatches(e,t)).map(i=>({id:i.id,missionId:i.mission_id,type:i.type,content:i.content,symbolName:i.symbol_name,filePath:i.file_path,score:i.similarity,decayedScore:i.similarity,rationale:`Similarity: ${(i.similarity*100).toFixed(0)}%`,createdAt:i.created_at}))}buildFtsQuery(e,t){let n=e.trim();if(!n.includes(" "))return`"${n}" OR ${n}*`;let i=n.split(/\s+/).filter(r=>r.length>0);switch(t){case"exact":return`"${n}"`;case"all":return i.map(r=>`${r}*`).join(" ");default:return i.map(r=>`${r}*`).join(" OR ")}}extractPathKeywords(e){let t=e.trim();if(!t)return[];let n=t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9_\/.-]+/).map(r=>r.trim()).filter(r=>r.length>=2),i=new Set;i.add(t.toLowerCase());for(let r of n)i.add(r);return Array.from(i)}isLikelySymbolQuery(e){let t=e.trim();return!t||/[\/\\]/.test(t)?!1:/^[a-z]+(?:[A-Z][a-z0-9]+)+$/.test(t)||!t.includes(" ")&&/[A-Z]/.test(t)}countPathKeywordHits(e,t){let n=e.toLowerCase(),i=t.filter(o=>o.length>=3),r=0;for(let o of i)n.includes(o.toLowerCase())&&(r+=1);return r}scorePathResult(e,t,n,i){let o=this.countPathKeywordHits(e,t)*10;n==="symbol"&&(o+=25);let a=e.toLowerCase(),c=a.includes("/.env")||a.endsWith(".env")||a.endsWith(".yml")||a.endsWith(".yaml")||a.endsWith(".json")||a.endsWith(".md");return i&&c&&(o-=20),i&&a.includes("/tests/")&&(o-=15),o}findSymbolBackedPaths(e,t,n){let i=e.trim().toLowerCase();if(!i)return[];if(/[\/\\]/.test(i))return[];let r=Array.from(new Set([i,...t])).filter(c=>c.length>=3).slice(0,6);if(r.length===0)return[];let o=r.flatMap(c=>{let l=c===i?Math.min(n,60):Math.min(n,30);return this.exportsRepo.findByPartialName(c,l)}),a=new Map;for(let c of o){let l=c.name.toLowerCase(),p=0;l===i&&(p+=6),l.startsWith(i)&&(p+=4),l.includes(i)&&(p+=3);for(let d of t)d.length>=3&&l.includes(d)&&(p+=1);if(p===0)continue;let u=a.get(c.file_path)||0;p>u&&a.set(c.file_path,p)}return Array.from(a.entries()).sort((c,l)=>l[1]-c[1]).slice(0,Math.min(n,ke.MAX_LIMIT)).map(([c])=>c)}rrfMerge(e,t,n,i){let r=new Map,o=i?.vectorWeight??1.2,a=i?.ftsWeight??.8,c=i?.symbolWeight??1.1,l=i?.symbolResults??[];for(let p of e){let u=r.get(p.path)||{path:p.path,row:p.row,vectorRank:null,symbolVectorRank:null,symbolName:null,ftsRank:null,fusedScore:0};u.vectorRank=p.rank,u.fusedScore+=o/(n+p.rank),r.set(p.path,u)}for(let p of t){let u=r.get(p.path)||{path:p.path,row:p.row,vectorRank:null,symbolVectorRank:null,symbolName:null,ftsRank:null,fusedScore:0};u.ftsRank=p.rank,u.fusedScore+=a/(n+p.rank),r.set(p.path,u)}for(let p of l){let u=r.get(p.path)||{path:p.path,row:p.row,vectorRank:null,symbolVectorRank:null,symbolName:null,ftsRank:null,fusedScore:0};u.symbolVectorRank=p.rank,u.symbolName=p.symbolName,u.fusedScore+=c/(n+p.rank),r.set(p.path,u)}return Array.from(r.values()).sort((p,u)=>u.fusedScore-p.fusedScore)}formatRank(e){return e==null?"none":String(e)}getConceptConfidenceFloor(e){switch(e){case"identifier-heavy":return .33;case"lexical-heavy":return .38;case"semantic-exploratory":return .3;default:return .35}}getIntentConfidenceFloor(e){return Math.max(.28,this.getConceptConfidenceFloor(e)-.05)}calculateConceptEvidenceScore(e){let t=Math.min(1,e.lexicalConfirm/Math.max(1,e.queryKeywordCount*1.5)),n=e.profile==="semantic-exploratory"?.72:.58,i=e.profile==="lexical-heavy"?.16:.12,r=e.profile==="identifier-heavy"?.12:.08,o=e.similarity*n+Math.min(1,e.lexicalScore)*.08+e.keywordCoverage*.1+e.phraseCoverage*i+e.identifierOverlap*r+t*.08;return e.hasFtsSignal&&(o+=.04),e.hasSymbolHint?o+=.03:e.hasSymbolVectorSignal&&(o+=.02),e.matchedKeywordCount===0&&e.phraseCoverage===0&&e.lexicalScore===0?o*=e.hasFtsSignal||e.hasSymbolVectorSignal?.72:.6:e.matchedKeywordCount<=1&&e.phraseCoverage===0&&e.identifierOverlap===0&&(o*=.88),e.isGenericPath&&e.matchedKeywordCount<=1&&e.phraseCoverage===0&&e.identifierOverlap===0&&(o*=.85),e.queryKeywordCount===0&&(o*=.75),Math.max(0,Math.min(.97,o))}estimateTokenCount(e){return e?Math.ceil(e.length/4):0}classifyConceptQuery(e,t){let n=e.trim(),i=t.length,r=/\b[a-z]+[A-Z][A-Za-z0-9]*\b/.test(n),o=/\b[a-z0-9]+_[a-z0-9_]+\b/i.test(n),a=/[/.:#()]/.test(n),c=i<=1&&!n.includes(" "),l=n.includes('"')||i>=5&&n.split(/\s+/).length>=6;return r||o||a&&i>=2?{profile:"identifier-heavy",rrfK:45,vectorWeight:1,ftsWeight:.75,symbolWeight:1.45,channelMultiplier:5,lexicalWindowMultiplier:5,earlyRejectThreshold:.012}:l?{profile:"lexical-heavy",rrfK:55,vectorWeight:.95,ftsWeight:1.3,symbolWeight:1,channelMultiplier:7,lexicalWindowMultiplier:8,earlyRejectThreshold:.008}:c||i<=2?{profile:"semantic-exploratory",rrfK:70,vectorWeight:1.35,ftsWeight:.6,symbolWeight:.9,channelMultiplier:4,lexicalWindowMultiplier:4,earlyRejectThreshold:.018}:{profile:"balanced",rrfK:60,vectorWeight:1.15,ftsWeight:.9,symbolWeight:1.2,channelMultiplier:6,lexicalWindowMultiplier:6,earlyRejectThreshold:.01}}extractOrderedConceptTerms(e){return e?e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9_]+/).map(t=>t.trim()).filter(t=>t.length>=3):[]}buildNgrams(e,t,n){if(e.length<t)return[];let i=[];for(let r=t;r<=n&&!(e.length<r);r++)for(let o=0;o<=e.length-r;o++)i.push(e.slice(o,o+r).join(" "));return Array.from(new Set(i))}calculatePhraseCoverage(e,t){if(!e||t.length===0)return 0;let n=e.toLowerCase(),i=0;for(let r of t)n.includes(r)&&(i+=1);return i/t.length}calculateIdentifierOverlap(e,t){if(e.length===0||t.length===0)return 0;let n=new Set(e.map(o=>o.toLowerCase())),i=new Set;for(let o of t){let a=o.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9_]+/).map(c=>c.trim()).filter(c=>c.length>=3);for(let c of a)i.add(c)}let r=0;for(let o of n)i.has(o)&&(r+=1);return r/n.size}isGenericConceptPath(e){let t=e.toLowerCase();return/(?:^|\/)(index|utils?|helpers?|common|shared|types?|constants?|models?)(?:\/|\.|$)/.test(t)}computeBm25LikeConfirmation(e,t){let n=Array.from(new Set(t.map(u=>u.toLowerCase()).filter(u=>u.length>=3)));if(e.length===0||n.length===0)return new Map;let i=new Set(n),r=[],o=new Map;for(let u of e){let h=(this.filesRepo.getContent(u)??"").toLowerCase().split(/[^a-z0-9_]+/).map(f=>f.trim()).filter(Boolean),m=new Map;for(let f of h)i.has(f)&&m.set(f,(m.get(f)||0)+1);for(let f of n)(m.get(f)||0)>0&&o.set(f,(o.get(f)||0)+1);r.push({path:u,frequencies:m,length:Math.max(h.length,1)})}let a=r.reduce((u,d)=>u+d.length,0)/Math.max(r.length,1),c=1.2,l=.75,p=new Map;for(let u of r){let d=0;for(let h of n){let m=u.frequencies.get(h)||0;if(m===0)continue;let f=o.get(h)||0,_=Math.log(1+(r.length-f+.5)/(f+.5)),g=m*(c+1)/(m+c*(1-l+l*(u.length/Math.max(a,1))));d+=_*g}p.set(u.path,d)}return p}collectConceptSymbolHintPaths(e,t){let n=Array.from(new Set(e.filter(r=>r.length>=4&&!this.isLowSignalConceptKeyword(r)))).slice(0,6);if(n.length===0)return new Set;let i=new Map;for(let r of n){let o=this.exportsRepo.findByPartialName(r,Math.min(t,80));for(let a of o){let c=a.name.toLowerCase(),l=0;c===r&&(l+=3),c.startsWith(r)&&(l+=2),c.includes(r)&&(l+=1),l!==0&&i.set(a.file_path,(i.get(a.file_path)||0)+l)}}return new Set(Array.from(i.entries()).sort((r,o)=>o[1]-r[1]).slice(0,Math.min(t,ke.MAX_LIMIT)).map(([r])=>r))}isLowSignalConceptKeyword(e){return new Set(["type","types","data","update","create","list","item","value","model","helper"]).has(e.toLowerCase())}};q();V();function ki(s){let{fileType:e,layer:t}=s,n={fileType:gt.normalizeFileType(e),layer:t},i=!!(n.fileType?.length||n.layer!=null);return{filters:n,hasFilters:i}}async function $a(s){let e=Ei(s.query??""),t={...s,query:e},n=qn();try{let{repoPath:i}=Ve(t),{query:r,limit:o=ke.DEFAULT_LIMIT,offset:a=0,compact:c=!1,tokenBudget:l}=t;await X(i);let{filters:p,hasFilters:u}=ki(t),h=await new gt(i).searchByConcept(r,o,a,p,u,c,l);try{let m=yi(i);if(m.status==="running"){let[f,_]=m.progress.split("/").map(Number),g=_>0?Math.round(f/_*100):0,b=`\u26A0\uFE0F Symbol embeddings still warming (${m.progress}, ${g}%) \u2014 symbol-level results may be incomplete. File-level results are fully available.
|
|
813
|
+
|
|
814
|
+
`;h.content?.[0]?.type==="text"&&(h.content[0].text=b+h.content[0].text)}}catch{}return $u(i,r,"concept"),n(),h}catch(i){return S.error({error:i,args:s},"Concept Search failed"),n(),await Ft(),{content:[{type:"text",text:`Concept Search failed: ${i instanceof Error?i.message:String(i)}`}],isError:!0}}}function $u(s,e,t){try{let n=O.getInstance(s),i=me(s);n.searchHistory.record(e,t,i)}catch(n){let i=me(s);S.error({module:"search",repoPath:s,query:e,mode:t,error:n instanceof Error?n.message:String(n),branch:i},"Failed to record search history"),Ft()}}q();V();async function Ds(s){let e=Ei(s.query??""),t={...s,query:e},n=qn();try{let{repoPath:i}=Ve(t),{query:r,limit:o=ke.DEFAULT_LIMIT,offset:a=0,matchMode:c="any"}=t;await X(i);let{filters:l,hasFilters:p}=ki(t),d=await new gt(i).searchBySymbol(r,o,a,l,p,c);return Au(i,r,"symbol"),n(),d}catch(i){return S.error({error:i,args:s},"Symbol Search failed"),n(),await Ft(),{content:[{type:"text",text:`Symbol Search failed: ${i instanceof Error?i.message:String(i)}`}],isError:!0}}}function Au(s,e,t){try{let n=O.getInstance(s),i=me(s);n.searchHistory.record(e,t,i)}catch(n){let i=me(s);S.error({module:"search",repoPath:s,query:e,mode:t,error:n instanceof Error?n.message:String(n),branch:i},"Failed to record search history"),Ft()}}V();q();import Yt from"path";function Aa(s,e){let t=s.findContentByToken(e,100);return{count:t.length,files:t}}async function Pa(s){let{repoPath:e,query:t,key:n="",kind:i,limit:r=50,showUsage:o=!1}=s,a=n||t;if(!a&&!i)return{content:[{type:"text",text:'Error: Either "key" or "kind" parameter is required.'}]};await X(e);let c=O.getInstance(e),{configs:l,files:p}=c;if(a){S.info({repoPath:e,key:a},"Searching for config key in DB...");let m=l.findByKey(a,r);if(m.length===0)return{content:[{type:"text",text:`No configuration found for key: ${a}`}]};if(o){let g=m.map(R=>{let k=Aa(p,R.key),D=k.count===0?"\u26A0\uFE0F ORPHANED":`\u2713 ${k.count} usage(s)`;return{file:Yt.relative(e,R.file_path),key:R.key,value:R.value,kind:R.kind,usageCount:k.count,usageFiles:k.files.slice(0,5).map(U=>Yt.relative(e,U)),status:D}});g.sort((R,k)=>R.usageCount===0&&k.usageCount>0?-1:k.usageCount===0&&R.usageCount>0?1:R.usageCount-k.usageCount);let b=g.filter(R=>R.usageCount===0).length;return{content:[{type:"text",text:(b>0?`# Configuration Search: "${a}" (with Usage Analysis)
|
|
815
|
+
|
|
816
|
+
\u26A0\uFE0F **${b} orphaned var(s)** (defined but never used in code)
|
|
817
|
+
|
|
818
|
+
Found ${m.length} match(es):
|
|
819
|
+
|
|
820
|
+
`:`# Configuration Search: "${a}" (with Usage Analysis)
|
|
821
|
+
|
|
822
|
+
Found ${m.length} match(es), all in use:
|
|
823
|
+
|
|
824
|
+
`)+g.map(R=>{let k=`## ${R.file} (${R.kind}) ${R.status}
|
|
825
|
+
**${R.key}**: \`${R.value}\``;return R.usageCount>0&&R.usageFiles.length>0&&(k+=`
|
|
826
|
+
> Used in: ${R.usageFiles.map(D=>`\`${D}\``).join(", ")}${R.usageCount>5?` (+${R.usageCount-5} more)`:""}`),k}).join(`
|
|
827
|
+
|
|
828
|
+
`)}]}}let f=m.map(g=>({file:Yt.relative(e,g.file_path),key:g.key,value:g.value,kind:g.kind}));return{content:[{type:"text",text:`# Configuration Search: "${a}"
|
|
829
|
+
|
|
830
|
+
Found ${m.length} match(es):
|
|
831
|
+
|
|
832
|
+
`+f.map(g=>`## ${g.file} (${g.kind})
|
|
833
|
+
**${g.key}**: \`${g.value}\``).join(`
|
|
834
|
+
|
|
835
|
+
`)+"\n\n> \u{1F4A1} **Tip**: Use `showUsage: true` to see usage counts and identify orphaned vars."}]}}let u=l.findByKind(i||null,r);if(o){let m=u.map(b=>{let w=Aa(p,b.key);return{file:Yt.relative(e,b.file_path),key:b.key,value:b.value,kind:b.kind,usageCount:w.count,usageFiles:w.files.slice(0,3).map(x=>Yt.relative(e,x)),status:w.count===0?"ORPHANED":"in-use"}});m.sort((b,w)=>b.usageCount===0&&w.usageCount>0?-1:w.usageCount===0&&b.usageCount>0?1:b.usageCount-w.usageCount);let f=m.filter(b=>b.usageCount===0).length,_=m.length,g=`# Config Discovery (${i||"all"}) with Usage Analysis
|
|
836
|
+
|
|
837
|
+
`;return g+=`**Summary**: ${_} config(s) found, ${f} orphaned
|
|
838
|
+
|
|
839
|
+
`,f>0&&(g+=`## \u26A0\uFE0F Orphaned (${f})
|
|
840
|
+
`,g+=m.filter(b=>b.usageCount===0).map(b=>`- \`${b.key}\` in ${b.file}`).join(`
|
|
841
|
+
`),g+=`
|
|
842
|
+
|
|
843
|
+
`),g+=`## \u2713 In Use (${_-f})
|
|
844
|
+
`,g+=m.filter(b=>b.usageCount>0).map(b=>{let w=b.usageFiles.length>0?`, used in ${b.usageFiles.map(x=>`\`${x}\``).join(", ")}${b.usageCount>3?` (+${b.usageCount-3} more)`:""}`:"";return`- \`${b.key}\`=\`${b.value}\` in \`${b.file}\` (${b.usageCount} usages${w})`}).join(`
|
|
845
|
+
`),u.length===r&&(g+=`
|
|
846
|
+
|
|
847
|
+
> Results limited to ${r} entries. Use the 'limit' parameter to see more.`),{content:[{type:"text",text:g}]}}let d=u.map(m=>({...m,file:Yt.relative(e,m.file_path)})),h=JSON.stringify(d,null,2);return u.length===r&&(h=`Results limited to ${r} entries. Use the 'limit' parameter to see more.
|
|
848
|
+
|
|
849
|
+
`+h),h+="\n\n> \u{1F4A1} **Tip**: Use `showUsage: true` to see usage counts and identify orphaned vars.",{content:[{type:"text",text:h}]}}V();It();import Pu from"fs";import Ma from"path";var Mu=new Set(["ClassDeclaration","FunctionDeclaration","TsInterfaceDeclaration","TsTypeAliasDeclaration","TsEnumDeclaration","VariableDeclaration"]);function Na(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Os(s,e,t){let n=t.trim();return!!(!n||n.length>8e3||/^\w{1,4}\s+['"].*['"];?$/.test(n)&&!n.startsWith("export ")||n.includes(`
|
|
850
|
+
import `)&&!n.startsWith("import ")||e&&Mu.has(e)&&s&&!new RegExp(`\\b${Na(s)}\\b`).test(n))}function Nu(s,e){let t=Math.max(0,(s.start_line||1)-1),n=Math.min(e.length,Math.max(t+1,(s.end_line||s.start_line||1)+1,t+120)),i=e.slice(t,n).join(`
|
|
851
|
+
`),r=Ce(i,s.kind);return r?r.length>800?`${r.slice(0,797)}...`:r:s.signature||""}function Du(s,e,t){if(!s)return null;let n=Na(s),i=[];e==="TsTypeAliasDeclaration"&&i.push(new RegExp(`^\\s*export\\s+type\\s+${n}\\b`)),e==="TsInterfaceDeclaration"&&i.push(new RegExp(`^\\s*export\\s+interface\\s+${n}\\b`)),e==="FunctionDeclaration"&&i.push(new RegExp(`^\\s*(?:export\\s+)?(?:async\\s+)?function\\s+${n}\\b`)),e==="ClassDeclaration"&&i.push(new RegExp(`^\\s*(?:export\\s+)?(?:abstract\\s+)?class\\s+${n}\\b`)),e==="VariableDeclaration"&&i.push(new RegExp(`^\\s*(?:export\\s+)?(?:const|let|var)\\s+${n}\\b`)),i.push(new RegExp(`\\b${n}\\b`));for(let r of i)for(let o=0;o<t.length;o++)if(r.test(t[o]))return o+1;return null}function Ou(s,e,t){let n=Math.max(0,s-1);if(e==="TsTypeAliasDeclaration"||e==="VariableDeclaration"||e==="TsEnumDeclaration"){for(let i=n;i<t.length;i++){if(t[i].includes(";"))return i+1;if(/^\s*export\s+(type|interface|class|function|const|let|var)\b/.test(t[i])&&i>n)return i}return Math.min(t.length,s+20)}if(e==="TsInterfaceDeclaration"||e==="ClassDeclaration"||e==="FunctionDeclaration"){let i=0,r=!1;for(let o=n;o<t.length;o++){let a=t[o];for(let c of a)c==="{"?(i+=1,r=!0):c==="}"&&(i-=1);if(r&&i<=0)return o+1}return Math.min(t.length,s+120)}return Math.min(t.length,s+40)}function Fu(s){return Array.isArray(s)?s.filter(e=>e.module!=="__type_reference__"):s}function Wu(s,e){return s?e==="TsTypeAliasDeclaration"?`type ${s}`:e==="TsInterfaceDeclaration"?`interface ${s}`:e==="FunctionDeclaration"?`function ${s}()`:e==="ClassDeclaration"?`class ${s}`:e==="VariableDeclaration"?`const ${s}`:`${e||"symbol"} ${s}`:e||"symbol"}function Hu(s,e){if(!s||e!=="TsTypeAliasDeclaration"&&e!=="TsInterfaceDeclaration")return s;let t=s.indexOf(`
|
|
852
|
+
export `);return t<=0?s:s.slice(0,t).trim()}async function Ci(s){let{repoPath:e,filePath:t}=Ve(s);if(!t)return{content:[{type:"text",text:"Error: filePath is required"}],isError:!0};let n=s.detailLevel||"signatures";await X(e);let{files:i,exports:r}=O.getInstance(e),o=i.findByPath(t),a=Ma.basename(t),c=/\.(ts|tsx|php|py|go)$/.test(a),l;c?l=await pn(t):l={exports:r.findByFile(t),imports:[]};let p=null;if(c)try{p=Pu.readFileSync(t,"utf8").split(`
|
|
853
|
+
`)}catch{p=null}Array.isArray(l.exports)&&p&&(l.exports=l.exports.map(m=>{let f=typeof m.signature=="string"?m.signature:"",_=m.start_line??m.line??1,g=m.end_line??m.endLine??_;if(Os(m.name||"",m.kind,f)){let w=Du(m.name||"",m.kind,p),x=w??_,R=w?Ou(x,m.kind,p):g,k=Nu({name:m.name||"",kind:m.kind,signature:f,start_line:x,end_line:R},p),D=Hu(k,m.kind),U=Os(m.name||"",m.kind,D)?Wu(m.name||"",m.kind):D;return{...m,signature:U,start_line:x,end_line:R,line:x,endLine:R,members:Array.isArray(m.members)?m.members.filter(P=>{let E=typeof P.signature=="string"?P.signature:"";return!Os(P.name||"",P.kind,E)}):m.members}}return m})),l.imports=Fu(l.imports),n==="structure"?(l.exports=l.exports.map(m=>{let f={name:m.name,kind:m.kind,line:m.start_line,classification:m.classification};return m.members&&m.members.length>0?{...f,members:m.members.map(_=>({name:`${m.name}.${_.name}`,kind:_.kind,line:_.start_line}))}:f}),delete l.imports):n==="signatures"&&(l.exports=l.exports.map(m=>{let f={name:m.name,kind:m.kind,signature:m.signature,line:m.start_line,classification:m.classification,capabilities:JSON.parse(m.capabilities||"[]")};return m.members&&m.members.length>0?{...f,members:m.members.map(_=>({name:`${m.name}.${_.name}`,kind:_.kind,signature:_.signature,line:_.start_line}))}:f}),delete l.imports);let u=Ma.relative(e,t),d=l.exports?.length||0,h="";return n==="structure"&&d>0?h=`
|
|
854
|
+
|
|
855
|
+
\u{1F4A1} Showing ${d} symbol names. For full signatures: shadow_inspect_file({ filePath: "${u}", detailLevel: "signatures" })`:n==="signatures"&&d>0&&(h=`
|
|
856
|
+
|
|
857
|
+
\u{1F4A1} Showing ${d} complete signatures. To inspect a specific symbol: shadow_inspect_symbol({ symbolName: "...", context: "full" })`),{content:[{type:"text",text:JSON.stringify({...l,fileDescription:o?.summary||"",classification:o?.classification&&o.classification!=="Unknown"?o.classification:Ct(t,O.getInstance(e)).layer},null,2)+h}]}}V();import Da from"path";import zu from"fs";function Uu(s,e,t){let n=s.split(`
|
|
858
|
+
`),i=[],r=0;for(let u=0;u<Math.min(n.length,50);u++){let d=n[u].trim();if(d.startsWith("import ")||d.startsWith("from ")||d.startsWith("export ")&&d.includes(" from "))r=u+1;else if(d&&!d.startsWith("//")&&!d.startsWith("/*")&&!d.startsWith("*")&&d!==""&&r>0)break}r>0&&(i.push(...n.slice(0,r)),i.push(""));let o=[...t].sort((u,d)=>u.startLine-d.startLine),a=0,c=0;for(let u of o)if(u.isTarget){i.push(`// \u2501\u2501\u2501 REQUESTED: ${u.name} \u2501\u2501\u2501`);let d=n.slice(u.startLine-1,u.endLine);i.push(...d),i.push("// \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),i.push(""),c++}else{let d=u.signature||ju(n,u.startLine-1,u.kind);d&&(i.push(`${d}`),i.push(` /* implementation: ${u.lineCount} lines */`),i.push(""),a++)}let l=o[o.length-1];if(l)for(let u=l.endLine;u<n.length;u++){let d=n[u].trim();if(d==="}"||d==="};"){i.push(n[u]);break}else if(d&&!d.startsWith("//"))break}return{foldedSource:i.join(`
|
|
859
|
+
`),totalOriginalLines:n.length,foldedToLines:i.length,siblingsShown:c,siblingsFolded:a}}function ju(s,e,t){let n=s[e];if(t.includes("Function")||t.includes("Method")||t.includes("Arrow")){let i="";for(let r=e;r<Math.min(e+5,s.length);r++)if(i+=s[r],i.includes("{")||i.includes("=>")){let o=i.indexOf("{");o>0&&(i=i.substring(0,o).trim());break}return i.trim()}return n}function Bu(s,e=","){let t=[],n="",i=0,r=0,o=0,a=0,c=null,l=!1;for(let u of s){if(c){if(n+=u,l){l=!1;continue}if(u==="\\"){l=!0;continue}u===c&&(c=null);continue}if(u==='"'||u==="'"||u==="`"){c=u,n+=u;continue}if(u==="("?i++:u===")"?i=Math.max(0,i-1):u==="{"?r++:u==="}"?r=Math.max(0,r-1):u==="["?o++:u==="]"?o=Math.max(0,o-1):u==="<"?a++:u===">"&&(a=Math.max(0,a-1)),u===e&&i===0&&r===0&&o===0&&a===0){let d=n.trim();d&&t.push(d),n="";continue}n+=u}let p=n.trim();return p&&t.push(p),t}function Gu(s){let e=s.indexOf("(");if(e<0)return null;let t=0;for(let n=e;n<s.length;n++){let i=s[n];if(i==="("&&t++,i===")"&&(t--,t===0))return{start:e,end:n}}return null}function Ii(s,e){let t=0,n=0,i=0,r=0,o=null,a=!1;for(let c=0;c<s.length;c++){let l=s[c];if(o){a?a=!1:l==="\\"?a=!0:l===o&&(o=null);continue}if(l==='"'||l==="'"||l==="`"){o=l;continue}if(l==="("?t++:l===")"?t=Math.max(0,t-1):l==="{"?n++:l==="}"?n=Math.max(0,n-1):l==="["?i++:l==="]"?i=Math.max(0,i-1):l==="<"?r++:l===">"&&(r=Math.max(0,r-1)),l===e&&t===0&&n===0&&i===0&&r===0)return c}return-1}function qu(s){let t=s.trim(),n=!1;t.startsWith("...")&&(n=!0,t=t.slice(3).trim());let i=Ii(t,"="),r=i>=0,o=r?t.slice(0,i).trim():t,a=r?t.slice(i+1).trim():void 0,c=Ii(o,":"),l=(c>=0?o.slice(0,c):o).replace(/^(?:readonly\s+)?(?:public|private|protected)\s+/,"").trim(),p=l.includes("?"),u=l.replace(/\?/g,"").trim(),d=c>=0&&o.slice(c+1).trim()||null;return{name:u||"(anonymous)",type:d,optional:p,rest:n,hasDefault:r,...a?{defaultValue:a}:{}}}function Vu(s,e){let t=s.slice(e+1).trim();if(!t)return null;let n=t.indexOf("=>");if(n>=0){let r=t.slice(0,n).trim(),o=Ii(r,":");if(o>=0){let c=r.slice(o+1).trim();if(c)return c}return t.slice(n+2).replace(/\{.*$/,"").trim()||null}let i=Ii(t,":");return i>=0&&t.slice(i+1).replace(/\{.*$/,"").trim()||null}function Ju(s){let e=s.trim();if(!e)return[];if(e==="*")return["*"];if(e.startsWith("[")&&e.endsWith("]"))try{let n=JSON.parse(e);if(Array.isArray(n))return n.map(i=>String(i).trim()).filter(Boolean).map(i=>i.replace(/^['"`]|['"`]$/g,""))}catch{}return e.replace(/^\{|\}$/g,"").split(",").map(n=>n.trim()).filter(Boolean).map(n=>n.replace(/^type\s+/,"")).map(n=>n.split(/\s+as\s+/i)[0]?.trim()||n).map(n=>n.replace(/^['"`]|['"`]$/g,""))}function Yu(s,e,t){let n=s?.replace(/\s+/g," ").trim()||null,r=n?.match(/\b(public|private|protected)\b/)?.[1]||null,a=(n?.match(/\bfunction\s*\*?\s+([A-Za-z_$][A-Za-z0-9_$]*)/)||n?.match(/\bclass\s+([A-Za-z_$][A-Za-z0-9_$]*)/)||n?.match(/^(?:export\s+)?(?:async\s+)?([A-Za-z_$][A-Za-z0-9_$]*)\s*(?:<[^>]*>)?\s*\(/))?.[1]||e,c=n?Gu(n):null,l=n&&c?n.slice(c.start+1,c.end):"",p=l?Bu(l).map(qu):[],u=n&&c?Vu(n,c.end):null,d=n?.match(/(?:function\s+[A-Za-z_$][A-Za-z0-9_$]*|[A-Za-z_$][A-Za-z0-9_$]*)\s*(<[^>]+>)\s*\(/);return{raw:s,normalized:n,symbol:a,kind:t,visibility:r,isStatic:/\bstatic\b/.test(n||""),isAsync:/\basync\b/.test(n||""),isGenerator:/function\s*\*/.test(n||"")||/\*\s*[A-Za-z_$][A-Za-z0-9_$]*\s*\(/.test(n||""),isArrowFunction:/=>/.test(n||""),typeParameters:d?.[1]||null,parameters:p,parameterCount:p.length,returnType:u}}function Ku(s,e,t=5){let n=new Map;for(let o of s){let a=n.get(o.file_path)||{classification:o.classification||null,importedSymbols:new Set,wildcard:!1},c=Ju(o.imported_symbols);(c.length===0||c.includes("*"))&&(a.wildcard=!0);for(let l of c)a.importedSymbols.add(l);!a.classification&&o.classification&&(a.classification=o.classification),n.set(o.file_path,a)}let i=Array.from(n.entries()).map(([o,a])=>({file:Da.relative(e,o),classification:a.classification,importedSymbols:a.importedSymbols.size>0?Array.from(a.importedSymbols).sort():["*"],wildcard:a.wildcard})),r=i.slice(0,Math.max(1,t));return{totalVerifiedCallers:i.length,showing:r.length,wildcardCallers:i.filter(o=>o.wildcard).length,topCallers:r.map(({wildcard:o,...a})=>a)}}async function Kt(s){let{repoPath:e,filePath:t,resolver:n}=Ve(s),i=String(s.symbolName),r=s.context||"definition";if(t&&!n.isWithinRoot(t))return{content:[{type:"text",text:`Error: Access denied. Path ${t} is outside the repository root.`}],isError:!0};await X(e);let o=O.getInstance(e),a=[];if(i.includes(".")){let[E,T]=i.split(".");a=o.exports.findMemberCandidates(E,T,t)}else a=o.exports.findDefinitionCandidates(i,t);if(a.length===0){let E=o.exports.findPotentialParents(i);if(E.length>0){let N=E.map($=>`\`${$.name}\` (in ${n.getRelative($.file_path)})`).join(", ");return{content:[{type:"text",text:`Symbol "${i}" not found as a top-level export.
|
|
860
|
+
However, it likely exists inside: ${N}.
|
|
861
|
+
Try: shadow_inspect_symbol({ symbolName: "${E[0].name}", context: "full" }) to see the class body.`}]}}let I=o.exports.findFuzzyCandidates(i).map(N=>N.name),M=bn(i,I,50,3);if(M.length>0){let N=M.map($=>` \u2022 \`${$.match}\` (${$.score}% match)`).join(`
|
|
862
|
+
`);return{content:[{type:"text",text:`Error: Symbol "${i}" not found in the index.
|
|
863
|
+
|
|
864
|
+
Suggestions:
|
|
865
|
+
${N}
|
|
866
|
+
|
|
867
|
+
Next steps:
|
|
868
|
+
\u2022 Search semantically: shadow_search_concept({ query: "${i}" })
|
|
869
|
+
\u2022 Verify repository is indexed: shadow_sync_index({ repoPath: "${e}" })`}]}}return{content:[{type:"text",text:`Error: Symbol "${i}" not found in the index.
|
|
870
|
+
|
|
871
|
+
Next steps:
|
|
872
|
+
\u2022 Search for it: shadow_search_concept({ query: "${i}" })
|
|
873
|
+
\u2022 Try with file path: shadow_inspect_symbol({ symbolName: "${i}", filePath: "..." })
|
|
874
|
+
`}]}}let c=a[0];if(c.kind==="ExportSpecifier"||c.kind==="ExportAllDeclaration"){let E=o.imports.findImportSource(c.file_path,i);if(E&&E.resolved_path)return Kt({...s,filePath:E.resolved_path})}let l=zu.readFileSync(c.file_path,"utf8"),p=l.split(`
|
|
875
|
+
`),u=c.end_line-c.start_line+1,d=150,h,m=!1,f=null;if(r==="definition"&&u>d){let T=o.exports.findSiblings(c.file_path).map(I=>({name:I.name,kind:I.kind,signature:I.signature||"",startLine:I.start_line,endLine:I.end_line,lineCount:I.end_line-I.start_line+1,isTarget:I.name===c.name&&I.start_line===c.start_line,parentName:I.parent_name}));if(T.length>1){f=Uu(l,{name:c.name,startLine:c.start_line,endLine:c.end_line},T);let I=n.getRelative(c.file_path);h=f.foldedSource+`
|
|
876
|
+
|
|
877
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
878
|
+
\u{1F4CA} Semantic Fold Applied (context: "definition")
|
|
879
|
+
|
|
880
|
+
Original file: ${f.totalOriginalLines} lines
|
|
881
|
+
Folded view: ${f.foldedToLines} lines
|
|
882
|
+
Target Symbol: ${c.name}
|
|
883
|
+
\u{1F4A1} Need more context?
|
|
884
|
+
\u2022 Full symbol + dependencies + usage: shadow_inspect_symbol({ symbolName: "${c.name}", context: "full" })
|
|
885
|
+
\u2022 ALL symbols in this file: shadow_inspect_file({ filePath: "${I}", detailLevel: "signatures" })
|
|
886
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`,m=!0}else h=p.slice(c.start_line-1,c.start_line-1+d).join(`
|
|
887
|
+
`)+`
|
|
888
|
+
|
|
889
|
+
... (truncated ${u-d} lines)`,m=!0}else h=p.slice(c.start_line-1,c.end_line).join(`
|
|
890
|
+
`);let _=c.parent_name?`${c.parent_name}.${c.name}`:c.name,g=o.exports.findHydratedById(c.id),b=c.parent_name||c.name,w=o.imports.findProxies(c.file_path).map(E=>E.file_path),x=Array.from(new Set([c.file_path,...w])),R=o.imports.findVerifiedDependents(x,b),k=Ku(R,e),D=Yu(c.signature,_,c.kind),U={name:_,kind:c.kind,signature:D,file:n.getRelative(c.file_path),startLine:c.start_line,endLine:c.end_line,totalLines:u,...m&&{truncated:!0,previewLines:d},classification:c.classification,callerSummary:k,source:h};if(g&&g.recent_intents&&g.recent_intents.length>0){let E={},T=Date.now();for(let I of g.recent_intents){if(I.is_crystallized&&I.type!=="crystal")continue;let M=I.created_at;M<1e10&&(M*=1e3);let N=new Date(M).getTime(),$=T-N,W="just now";if($>0){let L=Math.floor($/1e3),A=Math.floor(L/60),H=Math.floor(A/60),F=Math.floor(H/24);F>0?W=`${F}d ago`:H>0?W=`${H}h ago`:A>0?W=`${A}m ago`:W=`${L}s ago`}E[I.type]||(E[I.type]=[]),E[I.type].push(`[${W}] ${I.content}`)}U.intelligence={working_set_of:g.active_missions.map(I=>`Mission #${I.id}: ${I.name}`),total_intents:g.intent_log_count,recent_activity:E}}else g&&(U.intelligence={working_set_of:g.active_missions.map(E=>`Mission #${E.id}: ${E.name}`),total_intents:g.intent_log_count,recent_activity:null});try{let{generateEmbedding:E}=await Promise.resolve().then(()=>(Ae(),ot)),T=`Symbol: ${U.name}
|
|
891
|
+
Signature: ${c.signature||""}
|
|
892
|
+
File: ${U.file}`,I=await E(T);if(I){let M=o.intentLogs.findSemanticMatches(I,3,c.id),N=new Promise(W=>setTimeout(()=>W([]),100)),$=await Promise.race([M,N]);$&&$.length>0&&(U.intelligence||(U.intelligence={}),U.intelligence.related_knowledge=$.map(W=>({type:W.type,content:W.content,from_symbol:W.symbol_name,similarity:`${(W.similarity*100).toFixed(0)}%`})))}}catch{}if(r==="definition")return{content:[{type:"text",text:JSON.stringify(U,null,2)}]};let P={definition:U,dependencies:o.imports.getImportsForFile(c.file_path).map(E=>({module:E.module_specifier,symbols:E.imported_symbols,relativePath:E.resolved_path?Da.relative(e,E.resolved_path):null})),callerSummary:k};return P.verifiedUsages=k.topCallers,{content:[{type:"text",text:JSON.stringify(P,null,2)}]}}async function Oa(s,e){let t=_n.resolve(e.dir);await Y(async()=>{pe("Semantic Concept Search");let n=Re();n.start(`Analyzing intent: "${y.bold(s)}"...`);try{let i=await $a({repoPath:t,query:s});n.stop("Analysis complete.");let r=i.content[0].text;if(r.includes("Found")){let a=r.split("## ").slice(1).map(c=>{let[l,...p]=c.split(`
|
|
893
|
+
|
|
894
|
+
`),[u,d]=l.split(" ( "),h=(u??"").replace(/^\d+\.\s*/,"").trim(),m=p.find(f=>f.startsWith("**Summary**: "))?.replace("**Summary**: ","")||"";return{name:h,matchPct:d??"",summaryLine:m}});if(a.forEach(({name:c,matchPct:l,summaryLine:p})=>{se(`${y.green(c)} ${y.dim("("+(l||""))}`,p,"blue"),console.log("")}),e.interactive&&a.length>1){let c=await Gn("Inspect a file",a.map(l=>({value:{name:l.name},label:l.name,hint:l.summaryLine.slice(0,50)})),{limit:15});if(c){let l=c.name.startsWith(t)?c.name:_n.join(t,c.name),p=await Ci({repoPath:t,filePath:l});p.content?.[0]&&(console.log(""),se(y.bold("File summary"),p.content[0].text,"cyan"))}}}else console.log(r)}catch(i){throw n.stop(`Search failed: ${i.message}`),i}finally{await Q(t)}})}async function Fa(s,e){let t=_n.resolve(e.dir);await Y(async()=>{pe("Symbol Search");let n=Re();n.start(`Searching symbols: "${y.bold(s)}"...`);try{let i=await Ds({repoPath:t,query:s});n.stop("Search complete.");let r=i.content[0].text;try{let o=JSON.parse(r);if(Array.isArray(o)){if(console.log(""),jn(["Symbol","Kind","File","Line"],o.map(a=>[y.bold(y.green(a.name)),y.dim(a.kind??""),y.cyan(a.file??""),y.yellow(String(a.line??""))])),e.interactive&&o.length>1){let a=o.map(l=>({value:l,label:l.name,hint:`${l.file??""}:${l.line??""}`})),c=await Gn("Inspect symbol",a,{limit:15});if(c){let l=await Kt({repoPath:t,symbolName:c.name});l.content?.[0]&&(console.log(""),se(y.bold(c.name),l.content[0].text,"cyan"))}}}else console.log(r)}catch{console.log(r)}}catch(i){throw n.stop(`Search failed: ${i.message}`),i}finally{await Q(t)}})}async function Wa(s,e){let t=_n.resolve(e.dir);await Y(async()=>{pe("Fuzzy Symbol Search");let n=Re();n.start(`Fuzzy matching: "${y.bold(s)}"...`);try{let i=await Ds({repoPath:t,query:s});n.stop("Search complete.");let r=i.content[0].text;if(r.includes("## ")){let a=r.split("## ").slice(1).map(c=>{let l=c.split(`
|
|
895
|
+
`),p=l[0],u=l.find(g=>g.startsWith("**Match**:"))||"",d=l.find(g=>g.startsWith("**File**:"))||"",h=p.match(/`([^`]+)`/),m=h?h[1]:"",f=u.match(/\*\*Match\*\*: (.+) \((\d+)% confidence\)/),_=d.match(/`([^:]+):(\d+)`/);return{symbolName:m,file:_?_[1]:"",line:_?_[2]:"",matchType:f?f[1]:"",confidence:f?f[2]:""}});if(console.log(""),console.log(y.dim(`Found ${a.length} fuzzy match(es):`)),console.log(""),a.forEach((c,l)=>{console.log(`${y.dim(`${l+1}.`)} ${y.bold(y.green(c.symbolName))} ${y.dim(`(${c.matchType}, ${c.confidence}% match)`)}`),console.log(` ${y.cyan(c.file)}:${y.yellow(c.line)}`),console.log("")}),e.interactive&&a.length>1){let c=await Gn("Inspect symbol",a.map(l=>({value:l,label:l.symbolName,hint:`${l.file}:${l.line}`})),{limit:15});if(c){let l=await Kt({repoPath:t,symbolName:c.symbolName});l.content?.[0]&&(console.log(""),se(y.bold(c.symbolName),l.content[0].text,"cyan"))}}}else console.log(r)}catch(i){throw n.stop(`Search failed: ${i.message}`),i}finally{await Q(t)}})}async function Ha(s,e){let t=_n.resolve(e.dir);await Y(async()=>{pe("Config Search");let n=Re();n.start(`Searching config: ${y.bold(s||"all")}...`);try{let i=await Pa({repoPath:t,key:s,kind:e.kind});n.stop("Search complete."),se("\u2699\uFE0F Results",i.content[0].text,"yellow")}finally{await Q(t)}})}q();var Fs=S.child({module:"mcp:tools:env:hooks"});async function Li(s){let{repoPath:e,action:t,enableAutoRefresh:n,enableSymbolHealing:i}=s;if(t==="install"){Fs.info({repoPath:e,enableAutoRefresh:n,enableSymbolHealing:i},"Installing git hooks");let r=zr({repoPath:e,enableAutoRefresh:n??!0,enableSymbolHealing:i??!0}),o=["# Git Hooks Installation","",`## Installed (${r.installed.length})`,r.installed.length>0?r.installed.map(a=>`- \`${a}\``).join(`
|
|
896
|
+
`):"- None","",`## \u23ED\uFE0F Skipped (${r.skipped.length})`,r.skipped.length>0?r.skipped.map(a=>`- \`${a}\` (already installed)`).join(`
|
|
897
|
+
`):"- None",""];return r.errors.length>0&&(o.push(`## Errors (${r.errors.length})`),o.push(r.errors.map(a=>`- ${a}`).join(`
|
|
898
|
+
`)),o.push("")),o.push("---"),o.push("**What happens now?**"),(n??!0)&&o.push("- After `git pull` or `git checkout`: Index auto-refreshes in background"),(i??!0)&&o.push("- After `git commit`: Symbol shift detection runs automatically"),{content:[{type:"text",text:o.join(`
|
|
899
|
+
`)}]}}if(t==="remove"){Fs.info({repoPath:e},"Uninstalling git hooks");let r=Ur(e),o=["# Git Hooks Uninstallation","",`## Removed (${r.removed.length})`,r.removed.length>0?r.removed.map(a=>`- \`${a}\``).join(`
|
|
900
|
+
`):"- None",""];return r.errors.length>0&&(o.push(`## Errors (${r.errors.length})`),o.push(r.errors.map(a=>`- ${a}`).join(`
|
|
901
|
+
`))),{content:[{type:"text",text:o.join(`
|
|
902
|
+
`)}]}}if(t==="status"){Fs.info({repoPath:e},"Checking git hooks status");let r=Wt(e),o=r.statuses["post-checkout"];return{content:[{type:"text",text:["# Git Hooks Status","",`## Installed (${r.installed.length})`,r.installed.length>0?r.installed.map(c=>`- \`${c}\``).join(`
|
|
903
|
+
`):"- None","",`## Missing (${r.missing.length})`,r.missing.length>0?r.missing.map(c=>`- \`${c}\``).join(`
|
|
904
|
+
`):"- None","",`## Foreign (${r.foreign.length})`,r.foreign.length>0?r.foreign.map(c=>`- \`${c}\` (non-Liquid hook content)`).join(`
|
|
905
|
+
`):"- None","",`## Disabled (${r.disabled.length})`,r.disabled.length>0?r.disabled.map(c=>`- \`${c}\` (not executable)`).join(`
|
|
906
|
+
`):"- None","","---",`**Post-checkout status**: \`${o}\``,o==="installed"?"**Branch-switch delta reindex**: active":"**Branch-switch delta reindex**: inactive",'**To install hooks**: Use `shadow_env_hooks({ action: "install" })`'].join(`
|
|
907
|
+
`)}]}}return{content:[{type:"text",text:`Unknown action: ${t}`}],isError:!0}}async function za(s){let[e,t="."]=s;if(!e||!["install","uninstall","status"].includes(e)){console.log(""),console.log(` ${y.bold("Usage: ")} liquid-shadow hooks <install|uninstall|status> [path]`),console.log(""),console.log(` ${y.bold("Commands: ")}`),console.log(` ${y.cyan("install")} Install git hooks for automatic index refresh and symbol healing`),console.log(` ${y.cyan("uninstall")} Remove installed git hooks`),console.log(` ${y.cyan("status")} Check git hooks installation status`),console.log(""),console.log(` ${y.bold("Examples: ")}`),console.log(" liquid-shadow hooks install ."),console.log(" liquid-shadow hooks status /path/to/repo"),console.log("");return}await Y(async()=>{let n=Uc("path").resolve(t);switch(e){case"install":{let i=await Li({repoPath:n,action:"install",enableAutoRefresh:!0,enableSymbolHealing:!0});if(console.log(""),console.log(` ${y.green("\u2714")} ${y.bold("Git hooks installed successfully")}`),console.log(""),i.content&&i.content[0])try{let r=JSON.parse(i.content[0].text);console.log(` ${y.bold("Installed hooks: ")}`),r.hooks.forEach(o=>{console.log(` ${y.cyan("\u2022")} ${o}`)}),console.log("")}catch{console.log(i.content[0].text)}break}case"uninstall":{await Li({repoPath:n,action:"remove"}),console.log(""),console.log(` ${y.green("\u2714")} ${y.bold("Git hooks uninstalled successfully")}`),console.log("");break}case"status":{let i=await Li({repoPath:n,action:"status"});if(console.log(""),console.log(` ${y.bold("Git Hooks Status")}`),console.log(""),i.content&&i.content[0])try{let r=JSON.parse(i.content[0].text);r.installed&&r.installed.length>0?(console.log(` ${y.green("\u2714")} Installed hooks:`),r.installed.forEach(o=>{console.log(` ${y.cyan("\u2022")} ${o}`)})):console.log(` ${y.yellow("\u26A0")} No hooks installed`),r.missing&&r.missing.length>0&&(console.log(""),console.log(` ${y.dim("Missing hooks: ")}`),r.missing.forEach(o=>{console.log(` ${y.dim("\u2022")} ${o}`)}))}catch{console.log(i.content[0].text)}console.log("");break}}})}V();q();import Qu from"path";import Xu from"fs";var Ua=S.child({module:"mcp:tools:workspace:list"});async function ja(s){let{repoPaths:e,status:t,limit:n,summarize:i=!1}=s;Ua.info({repoCount:e.length,status:t,summarize:i},"Getting workspace missions");let r=[];for(let a of e)if(Xu.existsSync(a))try{let{missions:c}=O.getInstance(a),l=c.findAll(t);for(let p of l){let u=c.getLinks(p.id);r.push({...p,repo_path:a,repo_name:Qu.basename(a),cross_repo_links:u})}}catch(c){Ua.error({error:c,repoPath:a},"Failed to query repo missions")}if(r.sort((a,c)=>{let l=d=>d==="in-progress"?0:d==="verifying"?1:2,p=l(a.status),u=l(c.status);return p!==u?p-u:(a.created_at||0)-(c.created_at||0)}),i||r.length>50&&!n){let a=n||20,c=r.slice(0,a),l=r.reduce((u,d)=>(u[d.status]=(u[d.status]||0)+1,u),{}),p=r.reduce((u,d)=>(u[d.repo_name]=(u[d.repo_name]||0)+1,u),{});return{content:[{type:"text",text:JSON.stringify({summary:{total_missions:r.length,by_status:l,by_repo:p,showing_top:a},top_missions:c,hint:`Showing top ${a} of ${r.length} missions. Use limit to adjust or summarize:false for full list.`},null,2)}]}}let o=n?r.slice(0,n):r;return{content:[{type:"text",text:JSON.stringify({total_missions:r.length,showing:o.length,missions:o},null,2)}]}}V();q();var Zu=S.child({module:"mcp:tools:workspace:link"});async function Ba(s){let{parentRepoPath:e,parentMissionId:t,childRepoPath:n,childMissionId:i,relationship:r="related"}=s;Zu.info({parentRepoPath:e,childRepoPath:n},"Linking cross-repo missions");let{missions:o}=O.getInstance(e),{missions:a}=O.getInstance(n);try{let c=o.findById(t),l=a.findById(i);if(!c)throw new Error(`Parent mission ${t} not found`);if(!l)throw new Error(`Child mission ${i} not found`);return o.createLink(t,n,i,r,"parent"),a.createLink(i,e,t,r,"child"),{content:[{type:"text",text:JSON.stringify({status:"linked",relationship:r},null,2)}]}}catch(c){throw new Error(`Failed to link: ${c.message}`)}}q();import cd from"path";q();Ze();import ed from"better-sqlite3";import Qt from"path";import Ga from"fs";import td from"os";import nd from"crypto";var qa=S.child({module:"fusion-connection"}),$i=5,id=1,Va=["files","exports","imports","configs","schema_migrations"],Ws=3,Ai=class{fusionDb;attachedRepos=new Map;fusionDbPath;name;constructor(e){this.name=e.name,this.fusionDbPath=this.getFusionDbPath(e.name),qa.info({name:e.name,path:this.fusionDbPath},"Initializing fused index connection");let t=Qt.dirname(this.fusionDbPath);Ga.existsSync(t)||Ga.mkdirSync(t,{recursive:!0}),this.fusionDb=new ed(this.fusionDbPath),this.fusionDb.pragma("journal_mode = WAL"),this.fusionDb.pragma("busy_timeout = 5000"),this.initFusionSchema();for(let n of e.repoPaths)this.attachRepo(n)}getFusionDbPath(e){let t=td.homedir(),n=Qt.join(t,".mcp-liquid-shadow","fused"),i=e.replace(/[^a-zA-Z0-9-_]/g,"_");return Qt.join(n,`${i}.db`)}initFusionSchema(){this.fusionDb.exec(`
|
|
668
908
|
CREATE TABLE IF NOT EXISTS fused_repos (
|
|
669
909
|
alias TEXT PRIMARY KEY,
|
|
670
910
|
repo_path TEXT NOT NULL UNIQUE,
|
|
@@ -698,375 +938,64 @@ ${W||""}`,v),V=b.has(N.path),re=1;if(W){let Kr=/\b(class|function|const|let|var|
|
|
|
698
938
|
|
|
699
939
|
CREATE INDEX IF NOT EXISTS idx_virtual_edges_source ON virtual_edges(source_repo, source_file_path);
|
|
700
940
|
CREATE INDEX IF NOT EXISTS idx_virtual_edges_target ON virtual_edges(target_repo, target_file_path);
|
|
701
|
-
`),this.fusionDb.prepare("INSERT OR REPLACE INTO fused_metadata (key, value, updated_at) VALUES ('schema_version', ?, unixepoch())").run(
|
|
702
|
-
VALUES (?, ?, ?, ?, unixepoch(), unixepoch())`).run(
|
|
941
|
+
`),this.fusionDb.prepare("INSERT OR REPLACE INTO fused_metadata (key, value, updated_at) VALUES ('schema_version', ?, unixepoch())").run(id.toString())}attachRepo(e){let t=Qt.resolve(e);if(this.attachedRepos.has(t))return;if(!Xe(t))throw new Error(`Repository "${t}" is not indexed. Run shadow_recon_onboard({ repoPath: "${t}" }) then shadow_sync_trace({ repoPath: "${t}" }).`);let n=Te(t),i=n.name;this.validateSchemaCompatibility(n,t);let r=this.getSchemaVersion(n),o=this.generateAlias(t);for(let a=1;a<=Ws;a++)try{this.fusionDb.exec(`ATTACH DATABASE '${i}' AS ${o}`);let c={alias:o,repoPath:t,dbPath:i,schemaVersion:r,attached:!0};this.attachedRepos.set(t,c),this.fusionDb.prepare(`INSERT OR REPLACE INTO fused_repos (alias, repo_path, db_path, schema_version, attached_at, last_validated_at)
|
|
942
|
+
VALUES (?, ?, ?, ?, unixepoch(), unixepoch())`).run(o,t,i,r);return}catch(c){if(this.isLockContentionError(c)&&a<Ws){qa.warn({repoPath:t,attempt:a,maxAttempts:Ws},"Attach failed due to lock contention; retrying");continue}throw c}}checkHealth(){let e=[];for(let t of this.attachedRepos.values())try{this.fusionDb.prepare(`SELECT 1 FROM ${t.alias}.files LIMIT 1`).get(),e.push({alias:t.alias,repoPath:t.repoPath,accessible:!0})}catch(n){e.push({alias:t.alias,repoPath:t.repoPath,accessible:!1,error:n instanceof Error?n.message:String(n)})}return{healthy:e.every(t=>t.accessible),repos:e}}detachRepo(e){let t=Qt.resolve(e),n=this.attachedRepos.get(t);n&&(this.fusionDb.exec(`DETACH DATABASE ${n.alias}`),this.attachedRepos.delete(t),this.fusionDb.prepare("DELETE FROM fused_repos WHERE repo_path = ?").run(t))}refreshRepo(e){this.detachRepo(e),this.attachRepo(e)}refreshAll(){let e=Array.from(this.attachedRepos.keys());for(let t of e)this.refreshRepo(t)}validateSchemas(){let e=Array.from(this.attachedRepos.values()).map(t=>{let n=Te(t.repoPath),i=Va.filter(o=>!this.checkTableExists(n,o)),r=this.getSchemaVersion(n);return{alias:t.alias,repoPath:t.repoPath,schemaVersion:r,compatible:r>=$i&&i.length===0,missingTables:i}});return{valid:e.every(t=>t.compatible),minVersion:$i,repos:e}}getAttachedRepos(){return Array.from(this.attachedRepos.values())}prepare(e){return this.fusionDb.prepare(e)}exec(e){this.fusionDb.exec(e)}close(){for(let e of this.attachedRepos.values())try{this.fusionDb.exec(`DETACH DATABASE ${e.alias}`)}catch{}this.attachedRepos.clear(),this.fusionDb.open&&this.fusionDb.close()}generateAlias(e){let t=Qt.basename(e).replace(/[^a-zA-Z0-9]/g,"_").toLowerCase(),n=nd.createHash("sha256").update(e).digest("hex").substring(0,6);return`repo_${t}_${n}`}getSchemaVersion(e){try{return e.prepare("SELECT MAX(version) as version FROM schema_migrations").get()?.version||0}catch{return 0}}validateSchemaCompatibility(e,t){let n=this.getSchemaVersion(e);if(n<$i)throw new Error(`Schema version mismatch for ${t}. Expected >= ${$i}, got ${n}.`);let i=Va.filter(r=>!this.checkTableExists(e,r));if(i.length>0)throw new Error(`Missing tables in ${t}: ${i.join(", ")}`)}checkTableExists(e,t){try{return!!e.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name=?").get(t)}catch{return!1}}isLockContentionError(e){let t=e instanceof Error?e.message.toLowerCase():String(e).toLowerCase();return t.includes("locked")||t.includes("busy")}get nameValue(){return this.name}get dbPath(){return this.fusionDbPath}};q();var yt=S.child({module:"edge-scanner"});function Hs(s){let e=s.split("?")[0].split("#")[0];return e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e}function sd(s){if(!s)return null;try{let e=JSON.parse(s);return e.path||e.name||null}catch{return null}}function rd(s,e){let t=Hs(s),n=Hs(e);if(t===n)return!0;let i=n.replace(/:[^/]+/g,"[^/]+").replace(/\{[^}]+\}/g,"[^/]+").replace(/\$[^/]+/g,"[^/]+");return new RegExp(`^${i}$`).test(t)}function od(s){yt.info("Starting HTTP gap detection scan");let e=s.getAttachedRepos();if(e.length<2)return yt.warn("Need at least 2 repos for cross-repo dependency detection"),0;let t=[];for(let r of e)try{let o=`
|
|
703
943
|
SELECT id, name, file_path, capabilities
|
|
704
|
-
FROM ${
|
|
944
|
+
FROM ${r.alias}.exports
|
|
705
945
|
WHERE kind = 'HTTP Route'
|
|
706
|
-
`,a=
|
|
946
|
+
`,a=s.executeRawQuery(o);for(let c of a){let l=sd(c.capabilities)||c.name;l&&l.startsWith("/")&&t.push({repo:r.alias,repoPath:r.repoPath,filePath:c.file_path,symbolId:c.id,routePath:l})}}catch(o){yt.warn({repo:r.alias,error:o},"Failed to query backend routes")}yt.debug({count:t.length},"Found backend routes");let n=[];for(let r of e)try{let o=`
|
|
707
947
|
SELECT file_path, name
|
|
708
|
-
FROM ${
|
|
948
|
+
FROM ${r.alias}.event_synapses
|
|
709
949
|
WHERE type = 'api_route' AND direction = 'produce'
|
|
710
|
-
`,a=
|
|
711
|
-
`));let
|
|
950
|
+
`,a=s.executeRawQuery(o);for(let c of a){let l=Hs(c.name);l&&l.startsWith("/")&&n.push({repo:r.alias,repoPath:r.repoPath,filePath:c.file_path,routePath:l})}}catch(o){yt.warn({repo:r.alias,error:o},"Failed to query frontend API calls")}yt.debug({count:n.length},"Found frontend API calls");let i=0;for(let r of n)for(let o of t)if(r.repoPath!==o.repoPath&&rd(r.routePath,o.routePath))try{s.addVirtualEdge({sourceRepo:r.repoPath,sourceFilePath:r.filePath,targetRepo:o.repoPath,targetFilePath:o.filePath,targetSymbolId:o.symbolId,relationship:"api_call",metadata:{frontendPath:r.routePath,backendPath:o.routePath,method:o.method},confidence:1}),i++}catch(a){yt.debug({source:r.filePath,target:o.filePath,error:a},"Skipped duplicate edge")}return yt.info({edgesCreated:i,backendRoutes:t.length,frontendCalls:n.length},"HTTP gap detection scan completed"),i}function Ja(s){let e=od(s);return{httpGaps:e,totalEdges:e}}q();var ad=S.child({module:"fusion-index-service"}),Pi=class{constructor(e){this.connection=e}executeFederatedQuery(e,...t){return this.connection.prepare(e).all(...t).map(r=>{let{_repo_alias:o,_repo_path:a,...c}=r;return{repo:o,repoPath:a,data:c}})}executeRawQuery(e,...t){return this.connection.prepare(e).all(...t)}buildAdvancedQuery(e){let t=this.connection.getAttachedRepos();if(t.length===0)throw new Error("No repositories attached");let{table:n,tableAlias:i,columns:r,joins:o,where:a,groupBy:c,having:l,orderBy:p,limit:u,offset:d}=e,h=i||n.charAt(0),m=r.join(", "),_=t.map(g=>{let b=`${g.alias}.${n} ${h}`,w="";o&&o.length>0&&(w=o.map(D=>{let U=D.alias||D.table.charAt(0);return`${D.type} JOIN ${g.alias}.${D.table} ${U} ON ${D.on}`}).join(`
|
|
951
|
+
`));let x=a?`WHERE ${a}`:"",R=c&&c.length>0?`GROUP BY ${c.join(", ")}`:"",k=l?`HAVING ${l}`:"";return`SELECT '${g.alias}' as _repo_alias, '${g.repoPath}' as _repo_path, ${m} FROM ${b} ${w} ${x} ${R} ${k}`.trim()}).join(`
|
|
712
952
|
UNION ALL
|
|
713
|
-
`);return
|
|
714
|
-
SELECT '${
|
|
715
|
-
FROM ${
|
|
716
|
-
JOIN ${
|
|
717
|
-
WHERE ${
|
|
953
|
+
`);return p&&(_=`SELECT * FROM (${_}) AS federated_results ORDER BY ${p}`),u!==void 0&&(_+=` LIMIT ${u}`),d!==void 0&&(_+=` OFFSET ${d}`),_}buildFtsQuery(e,t,n,i,r=50){let o=this.connection.getAttachedRepos();if(o.length===0)throw new Error("No repositories attached");let a=n.replace(/"/g,'""'),c=i.map(p=>`c.${p}`).join(", ");return`${o.map(p=>`
|
|
954
|
+
SELECT '${p.alias}' as _repo_alias, '${p.repoPath}' as _repo_path, ${c}, bm25(${p.alias}.${e}) as _fts_rank
|
|
955
|
+
FROM ${p.alias}.${e} fts
|
|
956
|
+
JOIN ${p.alias}.${t} c ON fts.rowid = c.id
|
|
957
|
+
WHERE ${p.alias}.${e} MATCH '"${a}"'`).join(`
|
|
718
958
|
UNION ALL
|
|
719
|
-
`)} ORDER BY _fts_rank LIMIT ${
|
|
959
|
+
`)} ORDER BY _fts_rank LIMIT ${r}`}buildCrossRepoImportsQuery(){let e=this.connection.getAttachedRepos();if(e.length<2)throw new Error("Cross-repo analysis requires at least 2 attached repositories");let t=[];for(let n of e)for(let i of e)n.alias!==i.alias&&t.push(`
|
|
720
960
|
SELECT
|
|
721
|
-
'${
|
|
961
|
+
'${n.alias}' as source_repo, '${n.repoPath}' as source_repo_path,
|
|
722
962
|
i.file_path as source_file, i.module_specifier, i.imported_symbols,
|
|
723
|
-
'${
|
|
963
|
+
'${i.alias}' as target_repo, '${i.repoPath}' as target_repo_path,
|
|
724
964
|
f.path as target_file
|
|
725
|
-
FROM ${
|
|
726
|
-
JOIN ${
|
|
727
|
-
WHERE i.resolved_path IS NOT NULL`);return
|
|
965
|
+
FROM ${n.alias}.imports i
|
|
966
|
+
JOIN ${i.alias}.files f ON i.resolved_path = f.path
|
|
967
|
+
WHERE i.resolved_path IS NOT NULL`);return t.join(`
|
|
728
968
|
UNION ALL
|
|
729
|
-
`)}buildUnionQuery(e,
|
|
969
|
+
`)}buildUnionQuery(e,t,n){let i=this.connection.getAttachedRepos();if(i.length===0)throw new Error("No repositories attached");let r=t.join(", "),o=n?` WHERE ${n}`:"";return i.map(a=>`SELECT '${a.alias}' as _repo_alias, '${a.repoPath}' as _repo_path, ${r} FROM ${a.alias}.${e}${o}`).join(`
|
|
730
970
|
UNION ALL
|
|
731
|
-
`)}searchExports(e,
|
|
971
|
+
`)}searchExports(e,t=50){let n=this.buildUnionQuery("exports",["id","name","kind","file_path","signature"],"name LIKE ?")+` LIMIT ${t*this.connection.getAttachedRepos().length}`,i=Array(this.connection.getAttachedRepos().length).fill(`%${e}%`);return this.executeFederatedQuery(n,...i)}searchFiles(e,t=50){let n=this.buildUnionQuery("files",["path","classification","content_hash"],"path LIKE ?")+` LIMIT ${t*this.connection.getAttachedRepos().length}`,i=Array(this.connection.getAttachedRepos().length).fill(`%${e}%`);return this.executeFederatedQuery(n,...i)}getVirtualEdges(e,t){let n="SELECT * FROM virtual_edges WHERE 1=1",i=[];return e&&(n+=" AND source_repo = ?",i.push(e)),t&&(n+=" AND target_repo = ?",i.push(t)),this.connection.prepare(n).all(...i)}addVirtualEdge(e){return this.connection.prepare(`
|
|
732
972
|
INSERT INTO virtual_edges
|
|
733
973
|
(source_repo, source_file_path, source_symbol_id, target_repo, target_file_path, target_symbol_id, relationship, metadata, confidence, updated_at)
|
|
734
974
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, unixepoch())
|
|
735
|
-
`).run(e.sourceRepo,e.sourceFilePath,e.sourceSymbolId||null,e.targetRepo,e.targetFilePath,e.targetSymbolId||null,e.relationship,e.metadata?JSON.stringify(e.metadata):null,e.confidence??1).lastInsertRowid}scanEdges(){return i$.info({name:this.connection.nameValue},"Starting edge scan"),Bg(this)}getAttachedRepos(){return this.connection.getAttachedRepos()}get name(){return this.connection.nameValue}};var Gg=$.child({module:"fused-index"}),Ko=class{connection;service;configName;constructor(e){this.configName=e.name,this.connection=new Jo(e),this.service=new qo(this.connection)}attachRepo(e){this.connection.attachRepo(e)}detachRepo(e){this.connection.detachRepo(e)}refreshRepo(e){this.connection.refreshRepo(e)}getAttachedRepos(){return this.connection.getAttachedRepos()}checkHealth(){return this.connection.checkHealth()}close(){this.connection.close(),Gg.info({name:this.configName},"Fused index closed")}getStatus(){let e=this.service.executeRawQuery("SELECT COUNT(*) as count FROM virtual_edges");return{name:this.connection.nameValue,path:this.connection.dbPath,attachedRepos:this.connection.getAttachedRepos().length,repos:this.connection.getAttachedRepos(),virtualEdgesCount:e[0]?.count||0}}searchExports(e,r=50){return this.service.searchExports(e,r)}searchFiles(e,r=50){return this.service.searchFiles(e,r)}getVirtualEdges(e,r){return this.service.getVirtualEdges(e,r)}addVirtualEdge(e){return this.service.addVirtualEdge(e)}scanEdges(){return this.service.scanEdges()}buildUnionQuery(e,r,i){return this.service.buildUnionQuery(e,r,i)}executeFederatedQuery(e,...r){return this.service.executeFederatedQuery(e,...r)}executeRawQuery(e,...r){return this.service.executeRawQuery(e,...r)}buildAdvancedQuery(e){return this.service.buildAdvancedQuery(e)}buildFtsQuery(e,r,i,t,o){return this.service.buildFtsQuery(e,r,i,t,o)}buildCrossRepoImportsQuery(){return this.service.buildCrossRepoImportsQuery()}refreshAll(){this.connection.refreshAll()}validateSchemas(){return Gg.debug({name:this.configName},"Delegating validateSchemas"),this.connection.validateSchemas()}},Vo=new Map;function Jc(n){let e=Vo.get(n.name);if(e){let i=new Set(e.getAttachedRepos().map(s=>s.repoPath)),t=new Set(n.repoPaths.map(s=>o$.resolve(s)));if(i.size===t.size&&[...i].every(s=>t.has(s)))return e;e.close(),Vo.delete(n.name)}let r=new Ko(n);return Vo.set(n.name,r),r}function qc(){return Array.from(Vo.keys())}import Dt from"path";import Vc from"fs";var ar=class{constructor(e){this.repoPath=e}async analyze(e,r={}){let{filePath:i,depth:t=3,limit:o=50,offset:s=0}=r,a=L.getInstance(this.repoPath),c=i?a.exports.findByNameAndFile(e,i):a.exports.findByNameGlobal(e);if(c.length===0)return[];let l=[];for(let u of c){let d=a.imports.findImpactDependents(u.file_path,`%${e}%`,t),p=[],f=new Set;for(let S of d){let E=Dt.relative(this.repoPath,S.consumer_path);if(f.has(E))continue;let w=`Imports ${S.imported_symbols}`,z=await this.verifySymbolUsage(S.consumer_path,u.name);z?w+=" (\u2705 Verified Call)":w+=" (\u26A0\uFE0F Potential Import - Usage not statically detected)",f.add(E),p.push({type:"IMPORT",file:E,depth:S.depth,details:w,verified:z})}let m=a.exports.findRoutesByCapability(e);u.kind==="HTTP Route"&&m.push({name:u.name,file_path:u.file_path,signature:u.signature});for(let S of m){let w=S.name.split("/").filter(R=>R.length>3&&!R.includes("{")&&!R.includes("$")&&!R.includes("<")).sort((R,U)=>U.length-R.length)[0];if(!w||["admin","api","user","users","update","create","delete","list","index","show","store"].includes(w.toLowerCase()))continue;let z=a.files.findContentByToken(w,10);for(let R of z){let U=Dt.relative(this.repoPath,R);!f.has(U)&&R!==u.file_path&&(f.add(U),p.push({type:"API_USAGE",file:U,depth:2,details:`Likely calls route ${S.name} (matched token '${w}')`,verified:!1}))}}let h=a.files.findContentByToken(e,20);for(let S of h){let E=Dt.relative(this.repoPath,S);!f.has(E)&&S!==u.file_path&&(f.add(E),p.push({type:"POTENTIAL_USAGE",file:E,depth:2,details:`Contains keyword '${e}' (Dynamic/Implicit usage)`,verified:!0}))}u.kind==="HTTP Route"&&await this.addCrossRepoImpact(p,f,u),p.sort((S,E)=>S.verified&&!E.verified?-1:!S.verified&&E.verified?1:S.depth!==E.depth?S.depth-E.depth:S.file.localeCompare(E.file));let v=p.length,b=p.slice(s,s+o),g=s+o<v,x=this.calculateRiskScore(u,v,p);l.push({symbol:e,definedIn:Dt.relative(this.repoPath,u.file_path),riskScore:x,impact:b,pagination:{total:v,offset:s,limit:o,hasMore:g}})}return l}async verifySymbolUsage(e,r){try{if(!Vc.existsSync(e))return!1;let i=Vc.readFileSync(e,"utf8"),t=Dt.extname(e).toLowerCase(),o=new Set;if(t===".ts"||t===".tsx"||t===".js"||t===".jsx"){let s=new or;try{let a=await si(i,{syntax:"typescript",tsx:e.endsWith(".tsx"),target:"es2020"});s.visitModule(a),o=s.calls}catch{return i.includes(r)}}else{let s=new Qt;s.visit(i,t),o=s.calls}if(o.has(r))return!0;for(let s of o){if(s===r)return!0;let a=s.split(/(?:\.|->|::)+/),c=a[a.length-1],l=r.split(/(?:\.|->|::)+/),u=l[l.length-1];if(c===u)return!0}return!1}catch{return!1}}async addCrossRepoImpact(e,r,i){try{let t=qc();for(let o of t)try{let a=(await import("os")).homedir(),c=Dt.join(a,".mcp-liquid-shadow","fused"),l=o.replace(/[^a-zA-Z0-9-_]/g,"_"),u=Dt.join(c,`${l}.db`);if(!Vc.existsSync(u))continue;let d=(await import("better-sqlite3")).default,p=new d(u),f=p.prepare("SELECT source_repo, source_file_path, relationship, metadata FROM virtual_edges WHERE target_repo = ? AND target_file_path = ? AND relationship = 'api_call'").all(this.repoPath,i.file_path);p.close();for(let m of f){let h=Dt.relative(m.source_repo,m.source_file_path),v=`${m.source_repo}:${h}`;r.has(v)||(r.add(v),e.push({type:"CROSS_REPO_API_CALL",file:v,depth:1,details:`Cross-repo API call from ${Dt.basename(m.source_repo)}`,verified:!0}))}}catch{continue}}catch{}}calculateRiskScore(e,r,i){let a=(new pe(this.repoPath).getSnapshot().gravity?.hotspots||[]).find(p=>p.filePath===e.file_path&&p.symbol===e.name)?.gravity||0,c=i.filter(p=>p.type==="CROSS_REPO_API_CALL").length,l=a/50+r/15+c*2,u="LOW",d="Peripheral symbol with limited usage.";return l>=8?(u="CRITICAL",d=`Core architectural pillar (Gravity: ${a.toFixed(0)}). Modification will destabilize ${r} dependents.`):l>=4?(u="HIGH",d=`High-gravity symbol with significant blast radius (${r} files).`):l>=1.5&&(u="MEDIUM",d="Standard library symbol with moderate dependency chain."),{score:Math.min(10,Math.round(l*10)/10),level:u,rationale:d}}};X();var Yo=class n{constructor(e){this.intentLogs=e}static RECENCY_HALF_LIFE_HOURS=48;static WEIGHTS={recency:.4,activity:.3,statusBoost:.2,blockerBoost:.1};score(e){if(e.length===0)return[];let r=Math.floor(Date.now()/1e3),i=e.map(c=>c.id),t=this.intentLogs.countByMissions(i),o=this.intentLogs.findMissionsWithBlockers(i),s=Math.max(1,...Object.values(t));return e.map(c=>{let l=this.computeRecency(c.updated_at,r),u=(t[c.id]||0)/s,d=this.computeStatusBoost(c.status),p=o.has(c.id)?1:0,f=n.WEIGHTS,m=l*f.recency+u*f.activity+d*f.statusBoost+p*f.blockerBoost;return{mission:c,score:Math.round(m*1e3)/1e3,breakdown:{recency:Math.round(l*1e3)/1e3,activity:Math.round(u*1e3)/1e3,blockerBoost:p,statusBoost:d}}}).sort((c,l)=>l.score-c.score)}computeRecency(e,r){let i=Math.max(0,(r-e)/3600);return Math.pow(.5,i/n.RECENCY_HALF_LIFE_HOURS)}computeStatusBoost(e){switch(e){case"in-progress":return 1;case"verifying":return .8;case"planned":return .4;default:return 0}}};X();Je();J();import{execSync as Jg}from"child_process";import s$ from"path";var Xo=$.child({module:"shadow-trace"}),Lt=class{intentLogs;exports;repoPath;hologramService;constructor(e){let{intentLogs:r,exports:i}=L.getInstance(e);this.intentLogs=r,this.exports=i,this.repoPath=e,this.hologramService=new pe(e)}analyzeGhostChanges(e){let r=e?`${e}..HEAD`:"HEAD~1..HEAD",i=[];try{let o=Jg(`git diff --name-only ${r}`,{cwd:this.repoPath,encoding:"utf-8"}).split(`
|
|
736
|
-
`).filter(s=>s.trim()!=="");if(o.length===0)return;Xo.info({files:o.length,range:r},"Initiating Shadow Trace analysis...");for(let s of o){let a=s$.join(this.repoPath,s),l=Jg(`git diff -U0 ${r} -- ${s}`,{cwd:this.repoPath,encoding:"utf-8"}).matchAll(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/g);for(let u of l){let d=parseInt(u[2],10),p=this.exports.findAtLine(a,d);p&&(this.intentLogs.create({mission_id:0,file_path:a,symbol_id:p.id,type:"discovery",content:`Shadow Trace: Modified externally in ${r}`,confidence:.8,symbol_name:p.name,signature:p.signature,commit_sha:null}),Xo.debug({symbol:p.name},"Logged ghost change"),i.push({from:"external",to:`${s}:${p.name}`,pattern:"git-delta",confidence:.8}))}}i.length>0&&this.hologramService.updateGhostBridges(i),Xo.info("Shadow Trace complete.")}catch(t){Xo.warn({err:t.message},"Shadow Trace failed: git diff error.")}}};X();J();var a$=$.child({module:"collision-service"}),Qo=class{repoPath;constructor(e){this.repoPath=e}async analyzePotentialCollisions(){let e=Te(this.repoPath);if(!e)return[];let{missions:r,intentLogs:i}=L.getInstance(this.repoPath),t=r.findActive().filter(a=>a.git_branch&&a.git_branch!==e),o=[],s=new Set;for(let a of t){let c=a.git_branch;if(s.has(c))continue;s.add(c),a$.info({branch:c,currentBranch:e},"Checking predictive collisions"),Dc(this.repoPath,e,c)&&o.push({branch:c,type:"file",description:`Background merge-tree detected a file-level conflict between '${e}' and '${c}'.`});let u=r.findActive(e),d=new Set;for(let m of u)r.getWorkingSet(m.id).forEach(h=>d.add(h.file_path));let f=r.getWorkingSet(a.id).filter(m=>d.has(m.file_path));f.length>0&&o.push({branch:c,type:"intent",description:`Logical conflict: Mission '${a.name}' on '${c}' is modifying files you are currently working on.`,conflictingFiles:f.map(m=>m.file_path)})}return o}};var cr=class{constructor(e){this.repoPath=e}async getBriefing(e={}){let{missionId:r,scope:i="mission",altitude:t,activeMissionsLimit:o,recentActivityLimit:s,compact:a}=e,c=a??(t==="orbit"||t==="atmosphere"),l=s??(t==="orbit"?0:t==="ground"?20:10),{missions:u,intentLogs:d}=L.getInstance(this.repoPath),p=it(this.repoPath),f=Te(this.repoPath);return i==="project"?this.getProjectBriefing({altitude:t,activeMissionsLimit:o,recentActivityLimit:l,compact:c,currentBranch:f,currentCommit:p}):this.getMissionBriefing({missionId:r,altitude:t,recentActivityLimit:l,currentBranch:f,currentCommit:p})}async getProjectBriefing(e){let{repoPath:r}=this,{missions:i,intentLogs:t}=L.getInstance(r),{altitude:o,activeMissionsLimit:s,recentActivityLimit:a,compact:c,currentBranch:l,currentCommit:u}=e,d=i.findActive(l||void 0),p=d.length;s&&d.length>s&&(d=d.slice(0,s));let f=i.findParentOnlyIds(d),m=new Set(f),h=d.filter(D=>!m.has(D.id)),b=new Yo(t).score(h),g=.15,x=3,S=c&&b.length>x?b.filter((D,C)=>C<x||D.score>=g):b,E=S.map(D=>D.mission),w=new Map(S.map(D=>[D.mission.id,D.score])),z=D=>({id:D.id,name:D.name,goal:D.goal,status:D.status,relevance:w.get(D.id)});if(o==="orbit")return{scope:"project",altitude:"orbit",counts:i.getStats(),next_work_candidates:E.map(z),meta:{current_branch:l,activeMissionsTotal:p}};let R={},U=[];for(let D of d)D.parent_id!=null?(R[D.parent_id]||(R[D.parent_id]=[]),R[D.parent_id].push(D)):U.push(D);let I=i.findRecentCompleted(5).map(z),T=a>0?t.findRecentDecisionActivity(a):void 0,N=f.map(D=>{let C=d.find(q=>q.id===D);return{parent:c?{...C,strategy_graph:void 0,verification_context:void 0}:C,children:R[D]??[]}}),F=U.filter(D=>!m.has(D.id));return{scope:"project",altitude:o||"atmosphere",counts:i.getStats(),analytics:i.getAnalytics(),hierarchy:N.length>0?N:void 0,standalone_active:F.length>0?F:void 0,active_missions:N.length===0?c?d.map(D=>({...D,strategy_graph:void 0})):d:void 0,next_work_candidates:E.map(z),recent_completed:I,recent_activity:T,meta:{current_branch:l,current_commit:u,activeMissionsTotal:p,active_limit_applied:!!s,relevance_filtered:S.length<b.length?{shown:S.length,total:b.length}:void 0}}}async getMissionBriefing(e){let{repoPath:r}=this,{missions:i,intentLogs:t}=L.getInstance(r),{missionId:o,altitude:s,recentActivityLimit:a,currentBranch:c,currentCommit:l}=e,u;if(o?u=i.findById(o):u=i.findActive(c||void 0)[0],!u)return null;let d=null;try{u.strategy_graph&&(d=JSON.parse(u.strategy_graph))}catch{}if(s==="orbit")return{altitude:"orbit",mission:{id:u.id,name:u.name,goal:u.goal,status:u.status,last_updated:new Date(u.updated_at*1e3).toISOString()},strategy_snapshot:d};let p="No external shadow changes detected.";try{new Lt(r).analyzeGhostChanges(u.commit_sha||void 0),p="Shadow Trace completed: Checked for external modifications."}catch{}let f={repaired:0,failed:0};try{f=new Ce(r).detectAndRepairShifts()}catch{}let m={altitude:s||"atmosphere",mission:{id:u.id,name:u.name,goal:u.goal,status:u.status,last_updated:new Date(u.updated_at*1e3).toISOString(),git_branch:u.git_branch,commit_sha:u.commit_sha,outcome_contract:u.outcome_contract},artifacts:i.getArtifacts(u.id),shadow_trace:{ghost_analysis:p,symbols_repaired:f.repaired,symbols_missing:f.failed},context:{current_commit:l,working_set:i.getWorkingSet(u.id).map(h=>h.file_path)},strategy_snapshot:d,recent_activity:s==="ground"?t.findByMission(u.id,a||20):t.findByMissionPreferCrystal(u.id,15),ancestor_activity_summary:[],predictive_collisions:[]};try{let h=new Qo(r);m.predictive_collisions=await h.analyzePotentialCollisions()}catch{}if(u.parent_id){let h=s==="ground"?t.findByMission(u.parent_id,5):t.findByMissionPreferCrystal(u.parent_id,3);m.ancestor_activity_summary=h.map(v=>({type:v.type,content:v.content,date:new Date(v.created_at*1e3).toISOString()}))}return m}};var qg=[{name:"shadow_recon_onboard",description:"Initial onboarding for a repository. Indexes all files, extracts symbols, and detects services.",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository root"}},required:["repoPath"]}},{name:"shadow_recon_topography",description:"Analyze architectural layers (Entry/Logic/Data/Utility). Returns layer breakdown and architectural insights.",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository root"}},required:["repoPath"]}},{name:"shadow_recon_scout",description:"(Expert) Detect architectural drift, pattern violations, and gravity anomalies.",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository root"}},required:["repoPath"]}},{name:"shadow_recon_tree",description:"Generate hierarchical file tree with file classifications and export summaries.",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository root"},subPath:{type:"string",description:"Relative path to focus tree on a specific subdirectory"},maxDepth:{type:"number",description:"Maximum directory depth to traverse"}},required:["repoPath"]}},{name:"shadow_recon_hologram",description:"Get the project hologram (persistent architectural snapshot) and gravity zones.",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository root"},compact:{type:"boolean",description:"Omit large arrays (gravity.hotspots) for lighter output"}},required:["repoPath"]}},{name:"shadow_search_concept",description:"Semantic/Vector-based intent search across file purpose and logic.",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository"},query:{type:"string",description:"Search term or semantic intent"},limit:{type:"number",description:"Max results (default 10)"},offset:{type:"number",description:"Pagination offset"},compact:{type:"boolean",description:"Return compact output (no snippets)"},fileType:{type:"string",description:"Filter by extension(s)"},layer:{type:"string",enum:["Solid","Liquid","Virtual","Intel","Phantom"]},includeTests:{type:"boolean",description:"Include test files (Virtual)"}},required:["repoPath","query"]}},{name:"shadow_search_symbol",description:"Exact and fuzzy code symbol matching (classes, functions, methods).",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository"},query:{type:"string",description:"Symbol name or partial name"},limit:{type:"number",description:"Max results"},offset:{type:"number",description:"Pagination offset"},fileType:{type:"string",description:"Filter by extension(s)"},matchMode:{type:"string",enum:["any","all","exact"],description:"Match mode for multi-word queries: 'any' (OR, default), 'all' (AND), 'exact' (phrase)"}},required:["repoPath","query"]}},{name:"shadow_search_config",description:"Environment and configuration discovery (ENV, Ports, Docker, YAML).",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository"},query:{type:"string",description:"Search term for values/keys"},key:{type:"string",description:"Specific config key match"},kind:{type:"string",enum:["Service","Image","Port","Env"]},limit:{type:"number"},showUsage:{type:"boolean",description:"Cross-reference with code to show usage counts and identify orphaned vars (defined but never used)"}},required:["repoPath"]}},{name:"shadow_search_path",description:"Filename-keyword resolution using the search index.",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository"},query:{type:"string",description:"Filename part or path keyword"},limit:{type:"number"},ranked:{type:"boolean",description:"Sort results by gravity (high-import files first) and show layer classification (Entry/Logic/Data)"}},required:["repoPath","query"]}},{name:"shadow_analyze_impact",description:"Calculate blast radius and Strategic Risk Scoring of changing a symbol.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},symbolName:{type:"string",description:"Symbol to analyze"},filePath:{type:"string",description:"Specific file where symbol is defined"},depth:{type:"number",description:"Traversal depth (default 3)"},limit:{type:"number",description:"Max results per symbol (default 50)"},offset:{type:"number",description:"Pagination offset"}},required:["repoPath","symbolName"]}},{name:"shadow_analyze_flow",description:"Execution call-chain tracing (AST-based) for a specific function/method.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},filePath:{type:"string",description:"File to start trace from"},symbolName:{type:"string",description:"Function/method name"}},required:["repoPath","filePath"]}},{name:"shadow_analyze_deps",description:"Direct file import/export mapping and dependency graph inspection.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},filePath:{type:"string"},direction:{type:"string",enum:["imports","imported_by"]}},required:["repoPath","filePath","direction"]}},{name:"shadow_analyze_debt",description:"Recursive dead-code detection and circular import identification. For dead-code mode: excludes migrations and fixtures by default, returns results with confidence scoring.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},mode:{type:"string",enum:["dead-code","circular-deps"]},limit:{type:"number"},includeTests:{type:"boolean"},excludePatterns:{type:"array",items:{type:"string"},description:"Custom glob patterns to exclude (e.g., '**/migrations/**')"},includeMigrations:{type:"boolean",description:"Include migration files (default: false)"},includeFixtures:{type:"boolean",description:"Include fixture/mock files (default: false)"},confidenceThreshold:{type:"string",enum:["all","high","medium"],description:"Filter by confidence: 'all' (default), 'high' (likely dead), 'medium' (possibly intentional)"}},required:["repoPath","mode"]}}];var Vg=[{name:"shadow_ops_plan",description:"Create a new development mission or strategic initiative with goals and strategy.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},name:{type:"string",description:"Mission name"},goal:{type:"string",description:"Objective and success criteria"},strategy:{type:"string",description:"JSON strategy (steps DAG)"},parentId:{type:"number",description:"ID of parent mission"},outcomeContract:{type:"string",description:"Success verification contract"},templateId:{type:"string",enum:["refactoring","feature","bug-fix"]},templateVars:{type:"object",description:"Template variables"}},required:["repoPath"]}},{name:"shadow_ops_track",description:"Update mission step status, record progress, and track completion.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},missionId:{type:"number"},stepId:{type:"string"},status:{type:"string",enum:["pending","in-progress","completed","failed","skipped"]},contextPivot:{type:"string",description:"Rationale for status change"},updates:{type:"array",items:{type:"object",properties:{stepId:{type:"string"},status:{type:"string"},contextPivot:{type:"string"}}}}},required:["repoPath","missionId"]}},{name:"shadow_ops_log",description:"Record architectural decisions, discoveries, or blockers to the intent log.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},missionId:{type:"number",description:"Mission to attach this log to. Optional \u2014 if omitted, auto-resolves to the active mission or logs as standalone."},type:{type:"string",enum:["decision","blocker","discovery","fix"]},content:{type:"string"},filePath:{type:"string",description:"File path to associate with this log"},symbolName:{type:"string",description:"Symbol related to this intent"},standalone:{type:"boolean",description:"If true, log is anchored to symbolName only (no mission). Requires symbolName."}},required:["repoPath","type","content"]}},{name:"shadow_ops_briefing",description:"Active situational awareness - Get details on missions, decisions, and next steps.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},missionId:{type:"number",description:"Optional specific mission ID"},scope:{type:"string",enum:["mission","project"]},altitude:{type:"string",enum:["orbit","atmosphere","ground"],description:"Zoom level: orbit (~200 tokens, counts+candidates only), atmosphere (strategy+crystals, default), ground (raw logs+working set)"},includeGroupedByParent:{type:"boolean"},activeMissionsLimit:{type:"number",description:"Limit active missions in output"},recentActivityLimit:{type:"number",description:"Limit recent activity logs"},compact:{type:"boolean",description:"Omit strategy_graph JSON for lighter output"}},required:["repoPath"]}},{name:"shadow_ops_synthesize",description:"Distill mission context and logs into an Architectural Decision Record (ADR).",inputSchema:{type:"object",properties:{repoPath:{type:"string"},missionId:{type:"number"}},required:["repoPath","missionId"]}},{name:"shadow_ops_chronicle",description:"Archive feed of the repository narrative (initiatives and standalones).",inputSchema:{type:"object",properties:{repoPath:{type:"string"},format:{type:"string",enum:["markdown","json"]},limit:{type:"number"},offset:{type:"number"},since:{type:"number"},until:{type:"number"}},required:["repoPath"]}},{name:"shadow_ops_context",description:'Session-start bundle in one call: hologram + chronicle (last 5) + briefing summary (counts, next_work_candidates). Use for "new chat, give me the world" without multiple round-trips.',inputSchema:{type:"object",properties:{repoPath:{type:"string"},compact:{type:"boolean",description:"Return lighter payload (omit full hologram.gravity.hotspots, strategy_graph)"}},required:["repoPath"]}},{name:"shadow_ops_health",description:"System health metrics and intelligence index status.",inputSchema:{type:"object",properties:{repoPath:{type:"string"}},required:["repoPath"]}},{name:"shadow_ops_crystallize",description:"Compress a mission's intent logs into a single crystal summary. Raw logs are marked as absorbed and replaced by one dense crystal node for token-efficient briefings.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},missionId:{type:"number"}},required:["repoPath","missionId"]}},{name:"shadow_ops_graph",description:"Visualize mission lineage and dependencies.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},missionId:{type:"number"},depth:{type:"number"},limit:{type:"number"},format:{type:"string",enum:["mermaid","json"]}},required:["repoPath"]}},{name:"shadow_working_set_check",description:"Checks which files are in active mission working sets to detect parallel editing conflicts.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},filePaths:{type:"array",items:{type:"string"}}},required:["repoPath","filePaths"]}},{name:"shadow_inspect_symbol",description:"Dense code retrieval for a single symbol with semantic folding and usage context.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},symbolName:{type:"string"},filePath:{type:"string"},context:{type:"string",enum:["definition","full"]}},required:["repoPath","symbolName"]}},{name:"shadow_inspect_file",description:"Token-efficient summary of ALL symbols and exports in a file.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},filePath:{type:"string"},detailLevel:{type:"string",enum:["structure","signatures","summaries","detailed"]}},required:["repoPath","filePath"]}},{name:"shadow_sync_trace",description:"Full lifecycle synchronization - Repairs index, analyzes changes, and re-hydrates state.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},sinceCommit:{type:"string"}},required:["repoPath"]}},{name:"shadow_sync_index",description:"Incremental code re-indexing to reflect latest file changes.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},deep:{type:"boolean",description:"Force full rebuild"}},required:["repoPath"]}},{name:"shadow_sync_repair",description:"NanoRepair only - Heals broken intent links and symbol shifts.",inputSchema:{type:"object",properties:{repoPath:{type:"string"}},required:["repoPath"]}},{name:"shadow_env_hooks",description:"Install and manage Git hooks for automated intelligence maintenance.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},action:{type:"string",enum:["install","remove","status"]},enableAutoRefresh:{type:"boolean"},enableSymbolHealing:{type:"boolean"}},required:["repoPath","action"]}},{name:"shadow_env_diagnose",description:"Missions and intelligence toolset health check.",inputSchema:{type:"object",properties:{repoPath:{type:"string"}},required:["repoPath"]}},{name:"shadow_workspace_list",description:"Federated view of active missions across multiple repositories.",inputSchema:{type:"object",properties:{repoPaths:{type:"array",items:{type:"string"}},status:{type:"string"}},required:["repoPaths"]}},{name:"shadow_workspace_link",description:"Establish intent-level dependencies between missions in different repos.",inputSchema:{type:"object",properties:{parentRepoPath:{type:"string"},parentMissionId:{type:"number"},childRepoPath:{type:"string"},childMissionId:{type:"number"},relationship:{type:"string"}},required:["parentRepoPath","parentMissionId","childRepoPath","childMissionId","relationship"]}},{name:"shadow_workspace_fuse",description:"Create unified cross-repo search indices using SQLite fusion.",inputSchema:{type:"object",properties:{repoPaths:{type:"array",items:{type:"string"}},name:{type:"string"}},required:["repoPaths"]}}];var y={};et(y,{$brand:()=>es,$input:()=>hd,$output:()=>fd,NEVER:()=>Kc,TimePrecision:()=>vd,ZodAny:()=>cm,ZodArray:()=>pm,ZodBase64:()=>Ia,ZodBase64URL:()=>Ta,ZodBigInt:()=>Mr,ZodBigIntFormat:()=>za,ZodBoolean:()=>Or,ZodCIDRv4:()=>ka,ZodCIDRv6:()=>Ea,ZodCUID:()=>ba,ZodCUID2:()=>va,ZodCatch:()=>Dm,ZodCodec:()=>ja,ZodCustom:()=>Hi,ZodCustomStringFormat:()=>Lr,ZodDate:()=>Mi,ZodDefault:()=>Tm,ZodDiscriminatedUnion:()=>fm,ZodE164:()=>Pa,ZodEmail:()=>ha,ZodEmoji:()=>ga,ZodEnum:()=>Cr,ZodError:()=>Lk,ZodExactOptional:()=>km,ZodFile:()=>$m,ZodFirstPartyTypeKind:()=>Gm,ZodFunction:()=>Hm,ZodGUID:()=>Ci,ZodIPv4:()=>$a,ZodIPv6:()=>wa,ZodISODate:()=>la,ZodISODateTime:()=>ca,ZodISODuration:()=>da,ZodISOTime:()=>ua,ZodIntersection:()=>hm,ZodIssueCode:()=>Ok,ZodJWT:()=>Ra,ZodKSUID:()=>Sa,ZodLazy:()=>Fm,ZodLiteral:()=>Sm,ZodMAC:()=>tm,ZodMap:()=>_m,ZodNaN:()=>Am,ZodNanoID:()=>ya,ZodNever:()=>um,ZodNonOptional:()=>Oa,ZodNull:()=>sm,ZodNullable:()=>Im,ZodNumber:()=>Ar,ZodNumberFormat:()=>Zn,ZodObject:()=>Fi,ZodOptional:()=>Aa,ZodPipe:()=>Ma,ZodPrefault:()=>Rm,ZodPromise:()=>Zm,ZodReadonly:()=>Om,ZodRealError:()=>Ke,ZodRecord:()=>Zi,ZodSet:()=>xm,ZodString:()=>Dr,ZodStringFormat:()=>ce,ZodSuccess:()=>Cm,ZodSymbol:()=>im,ZodTemplateLiteral:()=>jm,ZodTransform:()=>wm,ZodTuple:()=>ym,ZodType:()=>te,ZodULID:()=>_a,ZodURL:()=>Oi,ZodUUID:()=>It,ZodUndefined:()=>om,ZodUnion:()=>Ui,ZodUnknown:()=>lm,ZodVoid:()=>dm,ZodXID:()=>xa,ZodXor:()=>mm,_ZodString:()=>fa,_default:()=>Pm,_function:()=>Tv,any:()=>sv,array:()=>ji,base64:()=>Hb,base64url:()=>Wb,bigint:()=>tv,boolean:()=>rm,catch:()=>Lm,check:()=>Pv,cidrv4:()=>Ub,cidrv6:()=>Zb,clone:()=>je,codec:()=>kv,coerce:()=>Jm,config:()=>xe,core:()=>Mt,cuid:()=>Cb,cuid2:()=>Db,custom:()=>Rv,date:()=>cv,decode:()=>qp,decodeAsync:()=>Kp,describe:()=>zv,discriminatedUnion:()=>fv,e164:()=>Bb,email:()=>$b,emoji:()=>zb,encode:()=>Jp,encodeAsync:()=>Vp,endsWith:()=>$r,enum:()=>Da,exactOptional:()=>Em,file:()=>xv,flattenError:()=>_i,float32:()=>Yb,float64:()=>Xb,formatError:()=>xi,fromJSONSchema:()=>Mv,function:()=>Tv,getErrorMap:()=>jk,globalRegistry:()=>De,gt:()=>kt,gte:()=>Fe,guid:()=>wb,hash:()=>Kb,hex:()=>Vb,hostname:()=>qb,httpUrl:()=>Rb,includes:()=>xr,instanceof:()=>Cv,int:()=>ma,int32:()=>Qb,int64:()=>nv,intersection:()=>gm,ipv4:()=>Mb,ipv6:()=>Fb,iso:()=>Nr,json:()=>Lv,jwt:()=>Gb,keyof:()=>lv,ksuid:()=>Ob,lazy:()=>Um,length:()=>Fn,literal:()=>_v,locales:()=>Pi,looseObject:()=>pv,looseRecord:()=>gv,lowercase:()=>vr,lt:()=>wt,lte:()=>Xe,mac:()=>jb,map:()=>yv,maxLength:()=>jn,maxSize:()=>cn,meta:()=>Nv,mime:()=>wr,minLength:()=>Ot,minSize:()=>Et,multipleOf:()=>an,nan:()=>wv,nanoid:()=>Nb,nativeEnum:()=>vv,negative:()=>Xs,never:()=>Na,nonnegative:()=>ea,nonoptional:()=>Nm,nonpositive:()=>Qs,normalize:()=>kr,null:()=>am,nullable:()=>Li,nullish:()=>Sv,number:()=>nm,object:()=>uv,optional:()=>Di,overwrite:()=>vt,parse:()=>Hp,parseAsync:()=>Wp,partialRecord:()=>hv,pipe:()=>Ai,positive:()=>Ys,prefault:()=>zm,preprocess:()=>Av,prettifyError:()=>cl,promise:()=>Iv,property:()=>ta,readonly:()=>Mm,record:()=>vm,refine:()=>Wm,regex:()=>br,regexes:()=>at,registry:()=>Rs,safeDecode:()=>Xp,safeDecodeAsync:()=>em,safeEncode:()=>Yp,safeEncodeAsync:()=>Qp,safeParse:()=>Bp,safeParseAsync:()=>Gp,set:()=>bv,setErrorMap:()=>Mk,size:()=>Mn,slugify:()=>Pr,startsWith:()=>Sr,strictObject:()=>dv,string:()=>pa,stringFormat:()=>Jb,stringbool:()=>Dv,success:()=>$v,superRefine:()=>Bm,symbol:()=>iv,templateLiteral:()=>Ev,toJSONSchema:()=>oa,toLowerCase:()=>Ir,toUpperCase:()=>Tr,transform:()=>La,treeifyError:()=>al,trim:()=>Er,tuple:()=>bm,uint32:()=>ev,uint64:()=>rv,ulid:()=>Lb,undefined:()=>ov,union:()=>Ca,unknown:()=>Un,uppercase:()=>_r,url:()=>Pb,util:()=>M,uuid:()=>kb,uuidv4:()=>Eb,uuidv6:()=>Ib,uuidv7:()=>Tb,void:()=>av,xid:()=>Ab,xor:()=>mv});var Mt={};et(Mt,{$ZodAny:()=>Au,$ZodArray:()=>Uu,$ZodAsyncError:()=>bt,$ZodBase64:()=>Eu,$ZodBase64URL:()=>Iu,$ZodBigInt:()=>$s,$ZodBigIntFormat:()=>Nu,$ZodBoolean:()=>ki,$ZodCIDRv4:()=>$u,$ZodCIDRv6:()=>wu,$ZodCUID:()=>du,$ZodCUID2:()=>pu,$ZodCatch:()=>od,$ZodCheck:()=>me,$ZodCheckBigIntFormat:()=>Ul,$ZodCheckEndsWith:()=>Ql,$ZodCheckGreaterThan:()=>gs,$ZodCheckIncludes:()=>Yl,$ZodCheckLengthEquals:()=>Jl,$ZodCheckLessThan:()=>hs,$ZodCheckLowerCase:()=>Vl,$ZodCheckMaxLength:()=>Bl,$ZodCheckMaxSize:()=>Zl,$ZodCheckMimeType:()=>tu,$ZodCheckMinLength:()=>Gl,$ZodCheckMinSize:()=>Hl,$ZodCheckMultipleOf:()=>jl,$ZodCheckNumberFormat:()=>Fl,$ZodCheckOverwrite:()=>nu,$ZodCheckProperty:()=>eu,$ZodCheckRegex:()=>ql,$ZodCheckSizeEquals:()=>Wl,$ZodCheckStartsWith:()=>Xl,$ZodCheckStringFormat:()=>gr,$ZodCheckUpperCase:()=>Kl,$ZodCodec:()=>Ii,$ZodCustom:()=>md,$ZodCustomStringFormat:()=>Ru,$ZodDate:()=>Fu,$ZodDefault:()=>td,$ZodDiscriminatedUnion:()=>Wu,$ZodE164:()=>Tu,$ZodEmail:()=>au,$ZodEmoji:()=>lu,$ZodEncodeError:()=>tn,$ZodEnum:()=>Vu,$ZodError:()=>vi,$ZodExactOptional:()=>Qu,$ZodFile:()=>Yu,$ZodFunction:()=>ud,$ZodGUID:()=>ou,$ZodIPv4:()=>_u,$ZodIPv6:()=>xu,$ZodISODate:()=>yu,$ZodISODateTime:()=>gu,$ZodISODuration:()=>vu,$ZodISOTime:()=>bu,$ZodIntersection:()=>Bu,$ZodJWT:()=>Pu,$ZodKSUID:()=>hu,$ZodLazy:()=>pd,$ZodLiteral:()=>Ku,$ZodMAC:()=>Su,$ZodMap:()=>Ju,$ZodNaN:()=>sd,$ZodNanoID:()=>uu,$ZodNever:()=>Mu,$ZodNonOptional:()=>rd,$ZodNull:()=>Lu,$ZodNullable:()=>ed,$ZodNumber:()=>Ss,$ZodNumberFormat:()=>zu,$ZodObject:()=>Sy,$ZodObjectJIT:()=>Zu,$ZodOptional:()=>ks,$ZodPipe:()=>ad,$ZodPrefault:()=>nd,$ZodPromise:()=>dd,$ZodReadonly:()=>cd,$ZodRealError:()=>Ve,$ZodRecord:()=>Gu,$ZodRegistry:()=>Ps,$ZodSet:()=>qu,$ZodString:()=>On,$ZodStringFormat:()=>ae,$ZodSuccess:()=>id,$ZodSymbol:()=>Cu,$ZodTemplateLiteral:()=>ld,$ZodTransform:()=>Xu,$ZodTuple:()=>ws,$ZodType:()=>Y,$ZodULID:()=>mu,$ZodURL:()=>cu,$ZodUUID:()=>su,$ZodUndefined:()=>Du,$ZodUnion:()=>Ei,$ZodUnknown:()=>Ou,$ZodVoid:()=>ju,$ZodXID:()=>fu,$ZodXor:()=>Hu,$brand:()=>es,$constructor:()=>k,$input:()=>hd,$output:()=>fd,Doc:()=>wi,JSONSchema:()=>xb,JSONSchemaGenerator:()=>sa,NEVER:()=>Kc,TimePrecision:()=>vd,_any:()=>Fd,_array:()=>Jd,_base64:()=>Js,_base64url:()=>qs,_bigint:()=>Cd,_boolean:()=>zd,_catch:()=>Ik,_check:()=>_b,_cidrv4:()=>Bs,_cidrv6:()=>Gs,_coercedBigint:()=>Dd,_coercedBoolean:()=>Nd,_coercedDate:()=>Bd,_coercedNumber:()=>kd,_coercedString:()=>yd,_cuid:()=>Ms,_cuid2:()=>js,_custom:()=>Vd,_date:()=>Wd,_decode:()=>ss,_decodeAsync:()=>cs,_default:()=>wk,_discriminatedUnion:()=>pk,_e164:()=>Vs,_email:()=>zs,_emoji:()=>As,_encode:()=>os,_encodeAsync:()=>as,_endsWith:()=>$r,_enum:()=>bk,_file:()=>qd,_float32:()=>Id,_float64:()=>Td,_gt:()=>kt,_gte:()=>Fe,_guid:()=>Ri,_includes:()=>xr,_int:()=>Ed,_int32:()=>Pd,_int64:()=>Ld,_intersection:()=>mk,_ipv4:()=>Hs,_ipv6:()=>Ws,_isoDate:()=>xd,_isoDateTime:()=>_d,_isoDuration:()=>$d,_isoTime:()=>Sd,_jwt:()=>Ks,_ksuid:()=>Zs,_lazy:()=>zk,_length:()=>Fn,_literal:()=>_k,_lowercase:()=>vr,_lt:()=>wt,_lte:()=>Xe,_mac:()=>bd,_map:()=>gk,_max:()=>Xe,_maxLength:()=>jn,_maxSize:()=>cn,_mime:()=>wr,_min:()=>Fe,_minLength:()=>Ot,_minSize:()=>Et,_multipleOf:()=>an,_nan:()=>Gd,_nanoid:()=>Os,_nativeEnum:()=>vk,_negative:()=>Xs,_never:()=>Zd,_nonnegative:()=>ea,_nonoptional:()=>kk,_nonpositive:()=>Qs,_normalize:()=>kr,_null:()=>jd,_nullable:()=>$k,_number:()=>wd,_optional:()=>Sk,_overwrite:()=>vt,_parse:()=>pr,_parseAsync:()=>mr,_pipe:()=>Tk,_positive:()=>Ys,_promise:()=>Nk,_property:()=>ta,_readonly:()=>Pk,_record:()=>hk,_refine:()=>Kd,_regex:()=>br,_safeDecode:()=>us,_safeDecodeAsync:()=>ps,_safeEncode:()=>ls,_safeEncodeAsync:()=>ds,_safeParse:()=>fr,_safeParseAsync:()=>hr,_set:()=>yk,_size:()=>Mn,_slugify:()=>Pr,_startsWith:()=>Sr,_string:()=>gd,_stringFormat:()=>Rr,_stringbool:()=>ep,_success:()=>Ek,_superRefine:()=>Yd,_symbol:()=>Od,_templateLiteral:()=>Rk,_toLowerCase:()=>Ir,_toUpperCase:()=>Tr,_transform:()=>xk,_trim:()=>Er,_tuple:()=>fk,_uint32:()=>Rd,_uint64:()=>Ad,_ulid:()=>Fs,_undefined:()=>Md,_union:()=>uk,_unknown:()=>Ud,_uppercase:()=>_r,_url:()=>zi,_uuid:()=>Ns,_uuidv4:()=>Cs,_uuidv6:()=>Ds,_uuidv7:()=>Ls,_void:()=>Hd,_xid:()=>Us,_xor:()=>dk,clone:()=>je,config:()=>xe,createStandardJSONSchemaMethod:()=>zr,createToJSONSchemaMethod:()=>tp,decode:()=>L$,decodeAsync:()=>O$,describe:()=>Xd,encode:()=>D$,encodeAsync:()=>A$,extractDefs:()=>un,finalize:()=>dn,flattenError:()=>_i,formatError:()=>xi,globalConfig:()=>pi,globalRegistry:()=>De,initializeContext:()=>ln,isValidBase64:()=>ku,isValidBase64URL:()=>by,isValidJWT:()=>vy,locales:()=>Pi,meta:()=>Qd,parse:()=>rs,parseAsync:()=>is,prettifyError:()=>cl,process:()=>oe,regexes:()=>at,registry:()=>Rs,safeDecode:()=>j$,safeDecodeAsync:()=>U$,safeEncode:()=>M$,safeEncodeAsync:()=>F$,safeParse:()=>ll,safeParseAsync:()=>ul,toDotPath:()=>ey,toJSONSchema:()=>oa,treeifyError:()=>al,util:()=>M,version:()=>ru});var Kc=Object.freeze({status:"aborted"});function k(n,e,r){function i(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(n))return;a._zod.traits.add(n),e(a,c);let l=s.prototype,u=Object.keys(l);for(let d=0;d<u.length;d++){let p=u[d];p in a||(a[p]=l[p].bind(a))}}let t=r?.Parent??Object;class o extends t{}Object.defineProperty(o,"name",{value:n});function s(a){var c;let l=r?.Parent?new o:this;i(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(s,"init",{value:i}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(n)}),Object.defineProperty(s,"name",{value:n}),s}var es=Symbol("zod_brand"),bt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},tn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}},pi={};function xe(n){return n&&Object.assign(pi,n),pi}var M={};et(M,{BIGINT_FORMAT_RANGES:()=>sl,Class:()=>Xc,NUMBER_FORMAT_RANGES:()=>ol,aborted:()=>sn,allowsEval:()=>tl,assert:()=>p$,assertEqual:()=>c$,assertIs:()=>u$,assertNever:()=>d$,assertNotEqual:()=>l$,assignProp:()=>rn,base64ToUint8Array:()=>Yg,base64urlToUint8Array:()=>P$,cached:()=>ur,captureStackTrace:()=>ns,cleanEnum:()=>T$,cleanRegex:()=>hi,clone:()=>je,cloneDef:()=>f$,createTransparentProxy:()=>_$,defineLazy:()=>ne,esc:()=>ts,escapeRegex:()=>st,extend:()=>$$,finalizeIssue:()=>qe,floatSafeRemainder:()=>Qc,getElementAtPath:()=>h$,getEnumValues:()=>fi,getLengthableOrigin:()=>bi,getParsedType:()=>v$,getSizableOrigin:()=>yi,hexToUint8Array:()=>z$,isObject:()=>Ln,isPlainObject:()=>on,issue:()=>dr,joinValues:()=>P,jsonStringifyReplacer:()=>lr,merge:()=>k$,mergeDefs:()=>At,normalizeParams:()=>j,nullish:()=>nn,numKeys:()=>b$,objectClone:()=>m$,omit:()=>S$,optionalKeys:()=>il,parsedType:()=>O,partial:()=>E$,pick:()=>x$,prefixIssues:()=>Ye,primitiveTypes:()=>rl,promiseAllObject:()=>g$,propertyKeyTypes:()=>gi,randomString:()=>y$,required:()=>I$,safeExtend:()=>w$,shallowClone:()=>nl,slugify:()=>el,stringifyPrimitive:()=>A,uint8ArrayToBase64:()=>Xg,uint8ArrayToBase64url:()=>R$,uint8ArrayToHex:()=>N$,unwrapMessage:()=>mi});function c$(n){return n}function l$(n){return n}function u$(n){}function d$(n){throw new Error("Unexpected value in exhaustive check")}function p$(n){}function fi(n){let e=Object.values(n).filter(i=>typeof i=="number");return Object.entries(n).filter(([i,t])=>e.indexOf(+i)===-1).map(([i,t])=>t)}function P(n,e="|"){return n.map(r=>A(r)).join(e)}function lr(n,e){return typeof e=="bigint"?e.toString():e}function ur(n){return{get value(){{let r=n();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function nn(n){return n==null}function hi(n){let e=n.startsWith("^")?1:0,r=n.endsWith("$")?n.length-1:n.length;return n.slice(e,r)}function Qc(n,e){let r=(n.toString().split(".")[1]||"").length,i=e.toString(),t=(i.split(".")[1]||"").length;if(t===0&&/\d?e-\d?/.test(i)){let c=i.match(/\d?e-(\d?)/);c?.[1]&&(t=Number.parseInt(c[1]))}let o=r>t?r:t,s=Number.parseInt(n.toFixed(o).replace(".","")),a=Number.parseInt(e.toFixed(o).replace(".",""));return s%a/10**o}var Kg=Symbol("evaluating");function ne(n,e,r){let i;Object.defineProperty(n,e,{get(){if(i!==Kg)return i===void 0&&(i=Kg,i=r()),i},set(t){Object.defineProperty(n,e,{value:t})},configurable:!0})}function m$(n){return Object.create(Object.getPrototypeOf(n),Object.getOwnPropertyDescriptors(n))}function rn(n,e,r){Object.defineProperty(n,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function At(...n){let e={};for(let r of n){let i=Object.getOwnPropertyDescriptors(r);Object.assign(e,i)}return Object.defineProperties({},e)}function f$(n){return At(n._zod.def)}function h$(n,e){return e?e.reduce((r,i)=>r?.[i],n):n}function g$(n){let e=Object.keys(n),r=e.map(i=>n[i]);return Promise.all(r).then(i=>{let t={};for(let o=0;o<e.length;o++)t[e[o]]=i[o];return t})}function y$(n=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let i=0;i<n;i++)r+=e[Math.floor(Math.random()*e.length)];return r}function ts(n){return JSON.stringify(n)}function el(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var ns="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function Ln(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var tl=ur(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let n=Function;return new n(""),!0}catch{return!1}});function on(n){if(Ln(n)===!1)return!1;let e=n.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(Ln(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function nl(n){return on(n)?{...n}:Array.isArray(n)?[...n]:n}function b$(n){let e=0;for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&e++;return e}var v$=n=>{let e=typeof n;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(n)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(n)?"array":n===null?"null":n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?"promise":typeof Map<"u"&&n instanceof Map?"map":typeof Set<"u"&&n instanceof Set?"set":typeof Date<"u"&&n instanceof Date?"date":typeof File<"u"&&n instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},gi=new Set(["string","number","symbol"]),rl=new Set(["string","number","bigint","boolean","symbol","undefined"]);function st(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function je(n,e,r){let i=new n._zod.constr(e??n._zod.def);return(!e||r?.parent)&&(i._zod.parent=n),i}function j(n){let e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function _$(n){let e;return new Proxy({},{get(r,i,t){return e??(e=n()),Reflect.get(e,i,t)},set(r,i,t,o){return e??(e=n()),Reflect.set(e,i,t,o)},has(r,i){return e??(e=n()),Reflect.has(e,i)},deleteProperty(r,i){return e??(e=n()),Reflect.deleteProperty(e,i)},ownKeys(r){return e??(e=n()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,i){return e??(e=n()),Reflect.getOwnPropertyDescriptor(e,i)},defineProperty(r,i,t){return e??(e=n()),Reflect.defineProperty(e,i,t)}})}function A(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function il(n){return Object.keys(n).filter(e=>n[e]._zod.optin==="optional"&&n[e]._zod.optout==="optional")}var ol={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},sl={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function x$(n,e){let r=n._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o=At(n._zod.def,{get shape(){let s={};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(s[a]=r.shape[a])}return rn(this,"shape",s),s},checks:[]});return je(n,o)}function S$(n,e){let r=n._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=At(n._zod.def,{get shape(){let s={...n._zod.def.shape};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete s[a]}return rn(this,"shape",s),s},checks:[]});return je(n,o)}function $$(n,e){if(!on(e))throw new Error("Invalid input to extend: expected a plain object");let r=n._zod.def.checks;if(r&&r.length>0){let o=n._zod.def.shape;for(let s in e)if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let t=At(n._zod.def,{get shape(){let o={...n._zod.def.shape,...e};return rn(this,"shape",o),o}});return je(n,t)}function w$(n,e){if(!on(e))throw new Error("Invalid input to safeExtend: expected a plain object");let r=At(n._zod.def,{get shape(){let i={...n._zod.def.shape,...e};return rn(this,"shape",i),i}});return je(n,r)}function k$(n,e){let r=At(n._zod.def,{get shape(){let i={...n._zod.def.shape,...e._zod.def.shape};return rn(this,"shape",i),i},get catchall(){return e._zod.def.catchall},checks:[]});return je(n,r)}function E$(n,e,r){let t=e._zod.def.checks;if(t&&t.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=At(e._zod.def,{get shape(){let a=e._zod.def.shape,c={...a};if(r)for(let l in r){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);r[l]&&(c[l]=n?new n({type:"optional",innerType:a[l]}):a[l])}else for(let l in a)c[l]=n?new n({type:"optional",innerType:a[l]}):a[l];return rn(this,"shape",c),c},checks:[]});return je(e,s)}function I$(n,e,r){let i=At(e._zod.def,{get shape(){let t=e._zod.def.shape,o={...t};if(r)for(let s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=new n({type:"nonoptional",innerType:t[s]}))}else for(let s in t)o[s]=new n({type:"nonoptional",innerType:t[s]});return rn(this,"shape",o),o}});return je(e,i)}function sn(n,e=0){if(n.aborted===!0)return!0;for(let r=e;r<n.issues.length;r++)if(n.issues[r]?.continue!==!0)return!0;return!1}function Ye(n,e){return e.map(r=>{var i;return(i=r).path??(i.path=[]),r.path.unshift(n),r})}function mi(n){return typeof n=="string"?n:n?.message}function qe(n,e,r){let i={...n,path:n.path??[]};if(!n.message){let t=mi(n.inst?._zod.def?.error?.(n))??mi(e?.error?.(n))??mi(r.customError?.(n))??mi(r.localeError?.(n))??"Invalid input";i.message=t}return delete i.inst,delete i.continue,e?.reportInput||delete i.input,i}function yi(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}function bi(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function O(n){let e=typeof n;switch(e){case"number":return Number.isNaN(n)?"nan":"number";case"object":{if(n===null)return"null";if(Array.isArray(n))return"array";let r=n;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return e}function dr(...n){let[e,r,i]=n;return typeof e=="string"?{message:e,code:"custom",input:r,inst:i}:{...e}}function T$(n){return Object.entries(n).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function Yg(n){let e=atob(n),r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return r}function Xg(n){let e="";for(let r=0;r<n.length;r++)e+=String.fromCharCode(n[r]);return btoa(e)}function P$(n){let e=n.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-e.length%4)%4);return Yg(e+r)}function R$(n){return Xg(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function z$(n){let e=n.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(e.length/2);for(let i=0;i<e.length;i+=2)r[i/2]=Number.parseInt(e.slice(i,i+2),16);return r}function N$(n){return Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join("")}var Xc=class{constructor(...e){}};var Qg=(n,e)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),n.message=JSON.stringify(e,lr,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},vi=k("$ZodError",Qg),Ve=k("$ZodError",Qg,{Parent:Error});function _i(n,e=r=>r.message){let r={},i=[];for(let t of n.issues)t.path.length>0?(r[t.path[0]]=r[t.path[0]]||[],r[t.path[0]].push(e(t))):i.push(e(t));return{formErrors:i,fieldErrors:r}}function xi(n,e=r=>r.message){let r={_errors:[]},i=t=>{for(let o of t.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(s=>i({issues:s}));else if(o.code==="invalid_key")i({issues:o.issues});else if(o.code==="invalid_element")i({issues:o.issues});else if(o.path.length===0)r._errors.push(e(o));else{let s=r,a=0;for(;a<o.path.length;){let c=o.path[a];a===o.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(e(o))):s[c]=s[c]||{_errors:[]},s=s[c],a++}}};return i(n),r}function al(n,e=r=>r.message){let r={errors:[]},i=(t,o=[])=>{var s,a;for(let c of t.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(l=>i({issues:l},c.path));else if(c.code==="invalid_key")i({issues:c.issues},c.path);else if(c.code==="invalid_element")i({issues:c.issues},c.path);else{let l=[...o,...c.path];if(l.length===0){r.errors.push(e(c));continue}let u=r,d=0;for(;d<l.length;){let p=l[d],f=d===l.length-1;typeof p=="string"?(u.properties??(u.properties={}),(s=u.properties)[p]??(s[p]={errors:[]}),u=u.properties[p]):(u.items??(u.items=[]),(a=u.items)[p]??(a[p]={errors:[]}),u=u.items[p]),f&&u.errors.push(e(c)),d++}}};return i(n),r}function ey(n){let e=[],r=n.map(i=>typeof i=="object"?i.key:i);for(let i of r)typeof i=="number"?e.push(`[${i}]`):typeof i=="symbol"?e.push(`[${JSON.stringify(String(i))}]`):/[^\w$]/.test(i)?e.push(`[${JSON.stringify(i)}]`):(e.length&&e.push("."),e.push(i));return e.join("")}function cl(n){let e=[],r=[...n.issues].sort((i,t)=>(i.path??[]).length-(t.path??[]).length);for(let i of r)e.push(`\u2716 ${i.message}`),i.path?.length&&e.push(` \u2192 at ${ey(i.path)}`);return e.join(`
|
|
737
|
-
`)}var pr=n=>(e,r,i,t)=>{let o=i?Object.assign(i,{async:!1}):{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new bt;if(s.issues.length){let a=new(t?.Err??n)(s.issues.map(c=>qe(c,o,xe())));throw ns(a,t?.callee),a}return s.value},rs=pr(Ve),mr=n=>async(e,r,i,t)=>{let o=i?Object.assign(i,{async:!0}):{async:!0},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(t?.Err??n)(s.issues.map(c=>qe(c,o,xe())));throw ns(a,t?.callee),a}return s.value},is=mr(Ve),fr=n=>(e,r,i)=>{let t=i?{...i,async:!1}:{async:!1},o=e._zod.run({value:r,issues:[]},t);if(o instanceof Promise)throw new bt;return o.issues.length?{success:!1,error:new(n??vi)(o.issues.map(s=>qe(s,t,xe())))}:{success:!0,data:o.value}},ll=fr(Ve),hr=n=>async(e,r,i)=>{let t=i?Object.assign(i,{async:!0}):{async:!0},o=e._zod.run({value:r,issues:[]},t);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new n(o.issues.map(s=>qe(s,t,xe())))}:{success:!0,data:o.value}},ul=hr(Ve),os=n=>(e,r,i)=>{let t=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return pr(n)(e,r,t)},D$=os(Ve),ss=n=>(e,r,i)=>pr(n)(e,r,i),L$=ss(Ve),as=n=>async(e,r,i)=>{let t=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return mr(n)(e,r,t)},A$=as(Ve),cs=n=>async(e,r,i)=>mr(n)(e,r,i),O$=cs(Ve),ls=n=>(e,r,i)=>{let t=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return fr(n)(e,r,t)},M$=ls(Ve),us=n=>(e,r,i)=>fr(n)(e,r,i),j$=us(Ve),ds=n=>async(e,r,i)=>{let t=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return hr(n)(e,r,t)},F$=ds(Ve),ps=n=>async(e,r,i)=>hr(n)(e,r,i),U$=ps(Ve);var at={};et(at,{base64:()=>El,base64url:()=>ms,bigint:()=>Nl,boolean:()=>Dl,browserEmail:()=>V$,cidrv4:()=>wl,cidrv6:()=>kl,cuid:()=>dl,cuid2:()=>pl,date:()=>Tl,datetime:()=>Rl,domain:()=>X$,duration:()=>yl,e164:()=>Il,email:()=>vl,emoji:()=>_l,extendedDuration:()=>Z$,guid:()=>bl,hex:()=>Q$,hostname:()=>Y$,html5Email:()=>G$,idnEmail:()=>q$,integer:()=>Cl,ipv4:()=>xl,ipv6:()=>Sl,ksuid:()=>hl,lowercase:()=>Ol,mac:()=>$l,md5_base64:()=>tw,md5_base64url:()=>nw,md5_hex:()=>ew,nanoid:()=>gl,null:()=>Ll,number:()=>fs,rfc5322Email:()=>J$,sha1_base64:()=>iw,sha1_base64url:()=>ow,sha1_hex:()=>rw,sha256_base64:()=>aw,sha256_base64url:()=>cw,sha256_hex:()=>sw,sha384_base64:()=>uw,sha384_base64url:()=>dw,sha384_hex:()=>lw,sha512_base64:()=>mw,sha512_base64url:()=>fw,sha512_hex:()=>pw,string:()=>zl,time:()=>Pl,ulid:()=>ml,undefined:()=>Al,unicodeEmail:()=>ty,uppercase:()=>Ml,uuid:()=>An,uuid4:()=>H$,uuid6:()=>W$,uuid7:()=>B$,xid:()=>fl});var dl=/^[cC][^\s-]{8,}$/,pl=/^[0-9a-z]+$/,ml=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,fl=/^[0-9a-vA-V]{20}$/,hl=/^[A-Za-z0-9]{27}$/,gl=/^[a-zA-Z0-9_-]{21}$/,yl=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Z$=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,bl=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,An=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,H$=An(4),W$=An(6),B$=An(7),vl=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,G$=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,J$=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,ty=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,q$=ty,V$=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,K$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function _l(){return new RegExp(K$,"u")}var xl=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Sl=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,$l=n=>{let e=st(n??":");return new RegExp(`^(?:[0-9A-F]{2}${e}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${e}){5}[0-9a-f]{2}$`)},wl=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,kl=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,El=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ms=/^[A-Za-z0-9_-]*$/,Y$=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,X$=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Il=/^\+[1-9]\d{6,14}$/,ny="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Tl=new RegExp(`^${ny}$`);function ry(n){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${e}`:n.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${n.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Pl(n){return new RegExp(`^${ry(n)}$`)}function Rl(n){let e=ry({precision:n.precision}),r=["Z"];n.local&&r.push(""),n.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let i=`${e}(?:${r.join("|")})`;return new RegExp(`^${ny}T(?:${i})$`)}var zl=n=>{let e=n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},Nl=/^-?\d+n?$/,Cl=/^-?\d+$/,fs=/^-?\d+(?:\.\d+)?$/,Dl=/^(?:true|false)$/i,Ll=/^null$/i;var Al=/^undefined$/i;var Ol=/^[^A-Z]*$/,Ml=/^[^a-z]*$/,Q$=/^[0-9a-fA-F]*$/;function Si(n,e){return new RegExp(`^[A-Za-z0-9+/]{${n}}${e}$`)}function $i(n){return new RegExp(`^[A-Za-z0-9_-]{${n}}$`)}var ew=/^[0-9a-fA-F]{32}$/,tw=Si(22,"=="),nw=$i(22),rw=/^[0-9a-fA-F]{40}$/,iw=Si(27,"="),ow=$i(27),sw=/^[0-9a-fA-F]{64}$/,aw=Si(43,"="),cw=$i(43),lw=/^[0-9a-fA-F]{96}$/,uw=Si(64,""),dw=$i(64),pw=/^[0-9a-fA-F]{128}$/,mw=Si(86,"=="),fw=$i(86);var me=k("$ZodCheck",(n,e)=>{var r;n._zod??(n._zod={}),n._zod.def=e,(r=n._zod).onattach??(r.onattach=[])}),oy={number:"number",bigint:"bigint",object:"date"},hs=k("$ZodCheckLessThan",(n,e)=>{me.init(n,e);let r=oy[typeof e.value];n._zod.onattach.push(i=>{let t=i._zod.bag,o=(e.inclusive?t.maximum:t.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<o&&(e.inclusive?t.maximum=e.value:t.exclusiveMaximum=e.value)}),n._zod.check=i=>{(e.inclusive?i.value<=e.value:i.value<e.value)||i.issues.push({origin:r,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:i.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),gs=k("$ZodCheckGreaterThan",(n,e)=>{me.init(n,e);let r=oy[typeof e.value];n._zod.onattach.push(i=>{let t=i._zod.bag,o=(e.inclusive?t.minimum:t.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>o&&(e.inclusive?t.minimum=e.value:t.exclusiveMinimum=e.value)}),n._zod.check=i=>{(e.inclusive?i.value>=e.value:i.value>e.value)||i.issues.push({origin:r,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:i.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),jl=k("$ZodCheckMultipleOf",(n,e)=>{me.init(n,e),n._zod.onattach.push(r=>{var i;(i=r._zod.bag).multipleOf??(i.multipleOf=e.value)}),n._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):Qc(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:n,continue:!e.abort})}}),Fl=k("$ZodCheckNumberFormat",(n,e)=>{me.init(n,e),e.format=e.format||"float64";let r=e.format?.includes("int"),i=r?"int":"number",[t,o]=ol[e.format];n._zod.onattach.push(s=>{let a=s._zod.bag;a.format=e.format,a.minimum=t,a.maximum=o,r&&(a.pattern=Cl)}),n._zod.check=s=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:i,format:e.format,code:"invalid_type",continue:!1,input:a,inst:n});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:i,inclusive:!0,continue:!e.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:i,inclusive:!0,continue:!e.abort});return}}a<t&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:t,inclusive:!0,inst:n,continue:!e.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:n,continue:!e.abort})}}),Ul=k("$ZodCheckBigIntFormat",(n,e)=>{me.init(n,e);let[r,i]=sl[e.format];n._zod.onattach.push(t=>{let o=t._zod.bag;o.format=e.format,o.minimum=r,o.maximum=i}),n._zod.check=t=>{let o=t.value;o<r&&t.issues.push({origin:"bigint",input:o,code:"too_small",minimum:r,inclusive:!0,inst:n,continue:!e.abort}),o>i&&t.issues.push({origin:"bigint",input:o,code:"too_big",maximum:i,inclusive:!0,inst:n,continue:!e.abort})}}),Zl=k("$ZodCheckMaxSize",(n,e)=>{var r;me.init(n,e),(r=n._zod.def).when??(r.when=i=>{let t=i.value;return!nn(t)&&t.size!==void 0}),n._zod.onattach.push(i=>{let t=i._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<t&&(i._zod.bag.maximum=e.maximum)}),n._zod.check=i=>{let t=i.value;t.size<=e.maximum||i.issues.push({origin:yi(t),code:"too_big",maximum:e.maximum,inclusive:!0,input:t,inst:n,continue:!e.abort})}}),Hl=k("$ZodCheckMinSize",(n,e)=>{var r;me.init(n,e),(r=n._zod.def).when??(r.when=i=>{let t=i.value;return!nn(t)&&t.size!==void 0}),n._zod.onattach.push(i=>{let t=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>t&&(i._zod.bag.minimum=e.minimum)}),n._zod.check=i=>{let t=i.value;t.size>=e.minimum||i.issues.push({origin:yi(t),code:"too_small",minimum:e.minimum,inclusive:!0,input:t,inst:n,continue:!e.abort})}}),Wl=k("$ZodCheckSizeEquals",(n,e)=>{var r;me.init(n,e),(r=n._zod.def).when??(r.when=i=>{let t=i.value;return!nn(t)&&t.size!==void 0}),n._zod.onattach.push(i=>{let t=i._zod.bag;t.minimum=e.size,t.maximum=e.size,t.size=e.size}),n._zod.check=i=>{let t=i.value,o=t.size;if(o===e.size)return;let s=o>e.size;i.issues.push({origin:yi(t),...s?{code:"too_big",maximum:e.size}:{code:"too_small",minimum:e.size},inclusive:!0,exact:!0,input:i.value,inst:n,continue:!e.abort})}}),Bl=k("$ZodCheckMaxLength",(n,e)=>{var r;me.init(n,e),(r=n._zod.def).when??(r.when=i=>{let t=i.value;return!nn(t)&&t.length!==void 0}),n._zod.onattach.push(i=>{let t=i._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<t&&(i._zod.bag.maximum=e.maximum)}),n._zod.check=i=>{let t=i.value;if(t.length<=e.maximum)return;let s=bi(t);i.issues.push({origin:s,code:"too_big",maximum:e.maximum,inclusive:!0,input:t,inst:n,continue:!e.abort})}}),Gl=k("$ZodCheckMinLength",(n,e)=>{var r;me.init(n,e),(r=n._zod.def).when??(r.when=i=>{let t=i.value;return!nn(t)&&t.length!==void 0}),n._zod.onattach.push(i=>{let t=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>t&&(i._zod.bag.minimum=e.minimum)}),n._zod.check=i=>{let t=i.value;if(t.length>=e.minimum)return;let s=bi(t);i.issues.push({origin:s,code:"too_small",minimum:e.minimum,inclusive:!0,input:t,inst:n,continue:!e.abort})}}),Jl=k("$ZodCheckLengthEquals",(n,e)=>{var r;me.init(n,e),(r=n._zod.def).when??(r.when=i=>{let t=i.value;return!nn(t)&&t.length!==void 0}),n._zod.onattach.push(i=>{let t=i._zod.bag;t.minimum=e.length,t.maximum=e.length,t.length=e.length}),n._zod.check=i=>{let t=i.value,o=t.length;if(o===e.length)return;let s=bi(t),a=o>e.length;i.issues.push({origin:s,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:i.value,inst:n,continue:!e.abort})}}),gr=k("$ZodCheckStringFormat",(n,e)=>{var r,i;me.init(n,e),n._zod.onattach.push(t=>{let o=t._zod.bag;o.format=e.format,e.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(e.pattern))}),e.pattern?(r=n._zod).check??(r.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:e.format,input:t.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(i=n._zod).check??(i.check=()=>{})}),ql=k("$ZodCheckRegex",(n,e)=>{gr.init(n,e),n._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),Vl=k("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=Ol),gr.init(n,e)}),Kl=k("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=Ml),gr.init(n,e)}),Yl=k("$ZodCheckIncludes",(n,e)=>{me.init(n,e);let r=st(e.includes),i=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=i,n._zod.onattach.push(t=>{let o=t._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(i)}),n._zod.check=t=>{t.value.includes(e.includes,e.position)||t.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:t.value,inst:n,continue:!e.abort})}}),Xl=k("$ZodCheckStartsWith",(n,e)=>{me.init(n,e);let r=new RegExp(`^${st(e.prefix)}.*`);e.pattern??(e.pattern=r),n._zod.onattach.push(i=>{let t=i._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),n._zod.check=i=>{i.value.startsWith(e.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:i.value,inst:n,continue:!e.abort})}}),Ql=k("$ZodCheckEndsWith",(n,e)=>{me.init(n,e);let r=new RegExp(`.*${st(e.suffix)}$`);e.pattern??(e.pattern=r),n._zod.onattach.push(i=>{let t=i._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),n._zod.check=i=>{i.value.endsWith(e.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:i.value,inst:n,continue:!e.abort})}});function iy(n,e,r){n.issues.length&&e.issues.push(...Ye(r,n.issues))}var eu=k("$ZodCheckProperty",(n,e)=>{me.init(n,e),n._zod.check=r=>{let i=e.schema._zod.run({value:r.value[e.property],issues:[]},{});if(i instanceof Promise)return i.then(t=>iy(t,r,e.property));iy(i,r,e.property)}}),tu=k("$ZodCheckMimeType",(n,e)=>{me.init(n,e);let r=new Set(e.mime);n._zod.onattach.push(i=>{i._zod.bag.mime=e.mime}),n._zod.check=i=>{r.has(i.value.type)||i.issues.push({code:"invalid_value",values:e.mime,input:i.value.type,inst:n,continue:!e.abort})}}),nu=k("$ZodCheckOverwrite",(n,e)=>{me.init(n,e),n._zod.check=r=>{r.value=e.tx(r.value)}});var wi=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let i=e.split(`
|
|
738
|
-
|
|
739
|
-
`))}};var ru={major:4,minor:3,patch:6};var Y=k("$ZodType",(n,e)=>{var r;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=ru;let i=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&i.unshift(n);for(let t of i)for(let o of t._zod.onattach)o(n);if(i.length===0)(r=n._zod).deferred??(r.deferred=[]),n._zod.deferred?.push(()=>{n._zod.run=n._zod.parse});else{let t=(s,a,c)=>{let l=sn(s),u;for(let d of a){if(d._zod.def.when){if(!d._zod.def.when(s))continue}else if(l)continue;let p=s.issues.length,f=d._zod.check(s);if(f instanceof Promise&&c?.async===!1)throw new bt;if(u||f instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await f,s.issues.length!==p&&(l||(l=sn(s,p)))});else{if(s.issues.length===p)continue;l||(l=sn(s,p))}}return u?u.then(()=>s):s},o=(s,a,c)=>{if(sn(s))return s.aborted=!0,s;let l=t(a,i,c);if(l instanceof Promise){if(c.async===!1)throw new bt;return l.then(u=>n._zod.parse(u,c))}return n._zod.parse(l,c)};n._zod.run=(s,a)=>{if(a.skipChecks)return n._zod.parse(s,a);if(a.direction==="backward"){let l=n._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return l instanceof Promise?l.then(u=>o(u,s,a)):o(l,s,a)}let c=n._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new bt;return c.then(l=>t(l,i,a))}return t(c,i,a)}}ne(n,"~standard",()=>({validate:t=>{try{let o=ll(n,t);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return ul(n,t).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),On=k("$ZodString",(n,e)=>{Y.init(n,e),n._zod.pattern=[...n?._zod.bag?.patterns??[]].pop()??zl(n._zod.bag),n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:n}),r}}),ae=k("$ZodStringFormat",(n,e)=>{gr.init(n,e),On.init(n,e)}),ou=k("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=bl),ae.init(n,e)}),su=k("$ZodUUID",(n,e)=>{if(e.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(i===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=An(i))}else e.pattern??(e.pattern=An());ae.init(n,e)}),au=k("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=vl),ae.init(n,e)}),cu=k("$ZodURL",(n,e)=>{ae.init(n,e),n._zod.check=r=>{try{let i=r.value.trim(),t=new URL(i);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(t.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:r.value,inst:n,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(t.protocol.endsWith(":")?t.protocol.slice(0,-1):t.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:n,continue:!e.abort})),e.normalize?r.value=t.href:r.value=i;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:n,continue:!e.abort})}}}),lu=k("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=_l()),ae.init(n,e)}),uu=k("$ZodNanoID",(n,e)=>{e.pattern??(e.pattern=gl),ae.init(n,e)}),du=k("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=dl),ae.init(n,e)}),pu=k("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=pl),ae.init(n,e)}),mu=k("$ZodULID",(n,e)=>{e.pattern??(e.pattern=ml),ae.init(n,e)}),fu=k("$ZodXID",(n,e)=>{e.pattern??(e.pattern=fl),ae.init(n,e)}),hu=k("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=hl),ae.init(n,e)}),gu=k("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=Rl(e)),ae.init(n,e)}),yu=k("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=Tl),ae.init(n,e)}),bu=k("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=Pl(e)),ae.init(n,e)}),vu=k("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=yl),ae.init(n,e)}),_u=k("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=xl),ae.init(n,e),n._zod.bag.format="ipv4"}),xu=k("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=Sl),ae.init(n,e),n._zod.bag.format="ipv6",n._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:n,continue:!e.abort})}}}),Su=k("$ZodMAC",(n,e)=>{e.pattern??(e.pattern=$l(e.delimiter)),ae.init(n,e),n._zod.bag.format="mac"}),$u=k("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=wl),ae.init(n,e)}),wu=k("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=kl),ae.init(n,e),n._zod.check=r=>{let i=r.value.split("/");try{if(i.length!==2)throw new Error;let[t,o]=i;if(!o)throw new Error;let s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${t}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:n,continue:!e.abort})}}});function ku(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}var Eu=k("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=El),ae.init(n,e),n._zod.bag.contentEncoding="base64",n._zod.check=r=>{ku(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:n,continue:!e.abort})}});function by(n){if(!ms.test(n))return!1;let e=n.replace(/[-_]/g,i=>i==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return ku(r)}var Iu=k("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=ms),ae.init(n,e),n._zod.bag.contentEncoding="base64url",n._zod.check=r=>{by(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:n,continue:!e.abort})}}),Tu=k("$ZodE164",(n,e)=>{e.pattern??(e.pattern=Il),ae.init(n,e)});function vy(n,e=null){try{let r=n.split(".");if(r.length!==3)return!1;let[i]=r;if(!i)return!1;let t=JSON.parse(atob(i));return!("typ"in t&&t?.typ!=="JWT"||!t.alg||e&&(!("alg"in t)||t.alg!==e))}catch{return!1}}var Pu=k("$ZodJWT",(n,e)=>{ae.init(n,e),n._zod.check=r=>{vy(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:n,continue:!e.abort})}}),Ru=k("$ZodCustomStringFormat",(n,e)=>{ae.init(n,e),n._zod.check=r=>{e.fn(r.value)||r.issues.push({code:"invalid_format",format:e.format,input:r.value,inst:n,continue:!e.abort})}}),Ss=k("$ZodNumber",(n,e)=>{Y.init(n,e),n._zod.pattern=n._zod.bag.pattern??fs,n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}let t=r.value;if(typeof t=="number"&&!Number.isNaN(t)&&Number.isFinite(t))return r;let o=typeof t=="number"?Number.isNaN(t)?"NaN":Number.isFinite(t)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:t,inst:n,...o?{received:o}:{}}),r}}),zu=k("$ZodNumberFormat",(n,e)=>{Fl.init(n,e),Ss.init(n,e)}),ki=k("$ZodBoolean",(n,e)=>{Y.init(n,e),n._zod.pattern=Dl,n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=!!r.value}catch{}let t=r.value;return typeof t=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:t,inst:n}),r}}),$s=k("$ZodBigInt",(n,e)=>{Y.init(n,e),n._zod.pattern=Nl,n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:n}),r}}),Nu=k("$ZodBigIntFormat",(n,e)=>{Ul.init(n,e),$s.init(n,e)}),Cu=k("$ZodSymbol",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value;return typeof t=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:t,inst:n}),r}}),Du=k("$ZodUndefined",(n,e)=>{Y.init(n,e),n._zod.pattern=Al,n._zod.values=new Set([void 0]),n._zod.optin="optional",n._zod.optout="optional",n._zod.parse=(r,i)=>{let t=r.value;return typeof t>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:t,inst:n}),r}}),Lu=k("$ZodNull",(n,e)=>{Y.init(n,e),n._zod.pattern=Ll,n._zod.values=new Set([null]),n._zod.parse=(r,i)=>{let t=r.value;return t===null||r.issues.push({expected:"null",code:"invalid_type",input:t,inst:n}),r}}),Au=k("$ZodAny",(n,e)=>{Y.init(n,e),n._zod.parse=r=>r}),Ou=k("$ZodUnknown",(n,e)=>{Y.init(n,e),n._zod.parse=r=>r}),Mu=k("$ZodNever",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:n}),r)}),ju=k("$ZodVoid",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value;return typeof t>"u"||r.issues.push({expected:"void",code:"invalid_type",input:t,inst:n}),r}}),Fu=k("$ZodDate",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=new Date(r.value)}catch{}let t=r.value,o=t instanceof Date;return o&&!Number.isNaN(t.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:t,...o?{received:"Invalid Date"}:{},inst:n}),r}});function ay(n,e,r){n.issues.length&&e.issues.push(...Ye(r,n.issues)),e.value[r]=n.value}var Uu=k("$ZodArray",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value;if(!Array.isArray(t))return r.issues.push({expected:"array",code:"invalid_type",input:t,inst:n}),r;r.value=Array(t.length);let o=[];for(let s=0;s<t.length;s++){let a=t[s],c=e.element._zod.run({value:a,issues:[]},i);c instanceof Promise?o.push(c.then(l=>ay(l,r,s))):ay(c,r,s)}return o.length?Promise.all(o).then(()=>r):r}});function xs(n,e,r,i,t){if(n.issues.length){if(t&&!(r in i))return;e.issues.push(...Ye(r,n.issues))}n.value===void 0?r in i&&(e.value[r]=void 0):e.value[r]=n.value}function _y(n){let e=Object.keys(n.shape);for(let i of e)if(!n.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);let r=il(n.shape);return{...n,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}}function xy(n,e,r,i,t,o){let s=[],a=t.keySet,c=t.catchall._zod,l=c.def.type,u=c.optout==="optional";for(let d in e){if(a.has(d))continue;if(l==="never"){s.push(d);continue}let p=c.run({value:e[d],issues:[]},i);p instanceof Promise?n.push(p.then(f=>xs(f,r,d,e,u))):xs(p,r,d,e,u)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:e,inst:o}),n.length?Promise.all(n).then(()=>r):r}var Sy=k("$ZodObject",(n,e)=>{if(Y.init(n,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){let a=e.shape;Object.defineProperty(e,"shape",{get:()=>{let c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}let i=ur(()=>_y(e));ne(n._zod,"propValues",()=>{let a=e.shape,c={};for(let l in a){let u=a[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(let d of u.values)c[l].add(d)}}return c});let t=Ln,o=e.catchall,s;n._zod.parse=(a,c)=>{s??(s=i.value);let l=a.value;if(!t(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:n}),a;a.value={};let u=[],d=s.shape;for(let p of s.keys){let f=d[p],m=f._zod.optout==="optional",h=f._zod.run({value:l[p],issues:[]},c);h instanceof Promise?u.push(h.then(v=>xs(v,a,p,l,m))):xs(h,a,p,l,m)}return o?xy(u,l,a,c,i.value,n):u.length?Promise.all(u).then(()=>a):a}}),Zu=k("$ZodObjectJIT",(n,e)=>{Sy.init(n,e);let r=n._zod.parse,i=ur(()=>_y(e)),t=p=>{let f=new wi(["shape","payload","ctx"]),m=i.value,h=x=>{let S=ts(x);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};f.write("const input = payload.value;");let v=Object.create(null),b=0;for(let x of m.keys)v[x]=`key_${b++}`;f.write("const newResult = {};");for(let x of m.keys){let S=v[x],E=ts(x),z=p[x]?._zod?.optout==="optional";f.write(`const ${S} = ${h(x)};`),z?f.write(`
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
`):f.write(`
|
|
758
|
-
if (${S}.issues.length) {
|
|
759
|
-
payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
|
|
760
|
-
...iss,
|
|
761
|
-
path: iss.path ? [${E}, ...iss.path] : [${E}]
|
|
762
|
-
})));
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
if (${S}.value === undefined) {
|
|
766
|
-
if (${E} in input) {
|
|
767
|
-
newResult[${E}] = undefined;
|
|
768
|
-
}
|
|
769
|
-
} else {
|
|
770
|
-
newResult[${E}] = ${S}.value;
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
`)}f.write("payload.value = newResult;"),f.write("return payload;");let g=f.compile();return(x,S)=>g(p,x,S)},o,s=Ln,a=!pi.jitless,l=a&&tl.value,u=e.catchall,d;n._zod.parse=(p,f)=>{d??(d=i.value);let m=p.value;return s(m)?a&&l&&f?.async===!1&&f.jitless!==!0?(o||(o=t(e.shape)),p=o(p,f),u?xy([],m,p,f,d,n):p):r(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:n}),p)}});function cy(n,e,r,i){for(let o of n)if(o.issues.length===0)return e.value=o.value,e;let t=n.filter(o=>!sn(o));return t.length===1?(e.value=t[0].value,t[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:n.map(o=>o.issues.map(s=>qe(s,i,xe())))}),e)}var Ei=k("$ZodUnion",(n,e)=>{Y.init(n,e),ne(n._zod,"optin",()=>e.options.some(t=>t._zod.optin==="optional")?"optional":void 0),ne(n._zod,"optout",()=>e.options.some(t=>t._zod.optout==="optional")?"optional":void 0),ne(n._zod,"values",()=>{if(e.options.every(t=>t._zod.values))return new Set(e.options.flatMap(t=>Array.from(t._zod.values)))}),ne(n._zod,"pattern",()=>{if(e.options.every(t=>t._zod.pattern)){let t=e.options.map(o=>o._zod.pattern);return new RegExp(`^(${t.map(o=>hi(o.source)).join("|")})$`)}});let r=e.options.length===1,i=e.options[0]._zod.run;n._zod.parse=(t,o)=>{if(r)return i(t,o);let s=!1,a=[];for(let c of e.options){let l=c._zod.run({value:t.value,issues:[]},o);if(l instanceof Promise)a.push(l),s=!0;else{if(l.issues.length===0)return l;a.push(l)}}return s?Promise.all(a).then(c=>cy(c,t,n,o)):cy(a,t,n,o)}});function ly(n,e,r,i){let t=n.filter(o=>o.issues.length===0);return t.length===1?(e.value=t[0].value,e):(t.length===0?e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:n.map(o=>o.issues.map(s=>qe(s,i,xe())))}):e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:[],inclusive:!1}),e)}var Hu=k("$ZodXor",(n,e)=>{Ei.init(n,e),e.inclusive=!1;let r=e.options.length===1,i=e.options[0]._zod.run;n._zod.parse=(t,o)=>{if(r)return i(t,o);let s=!1,a=[];for(let c of e.options){let l=c._zod.run({value:t.value,issues:[]},o);l instanceof Promise?(a.push(l),s=!0):a.push(l)}return s?Promise.all(a).then(c=>ly(c,t,n,o)):ly(a,t,n,o)}}),Wu=k("$ZodDiscriminatedUnion",(n,e)=>{e.inclusive=!1,Ei.init(n,e);let r=n._zod.parse;ne(n._zod,"propValues",()=>{let t={};for(let o of e.options){let s=o._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(let[a,c]of Object.entries(s)){t[a]||(t[a]=new Set);for(let l of c)t[a].add(l)}}return t});let i=ur(()=>{let t=e.options,o=new Map;for(let s of t){let a=s._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let c of a){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,s)}}return o});n._zod.parse=(t,o)=>{let s=t.value;if(!Ln(s))return t.issues.push({code:"invalid_type",expected:"object",input:s,inst:n}),t;let a=i.value.get(s?.[e.discriminator]);return a?a._zod.run(t,o):e.unionFallback?r(t,o):(t.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,input:s,path:[e.discriminator],inst:n}),t)}}),Bu=k("$ZodIntersection",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value,o=e.left._zod.run({value:t,issues:[]},i),s=e.right._zod.run({value:t,issues:[]},i);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([c,l])=>uy(r,c,l)):uy(r,o,s)}});function iu(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(on(n)&&on(e)){let r=Object.keys(e),i=Object.keys(n).filter(o=>r.indexOf(o)!==-1),t={...n,...e};for(let o of i){let s=iu(n[o],e[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};t[o]=s.data}return{valid:!0,data:t}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let i=0;i<n.length;i++){let t=n[i],o=e[i],s=iu(t,o);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function uy(n,e,r){let i=new Map,t;for(let a of e.issues)if(a.code==="unrecognized_keys"){t??(t=a);for(let c of a.keys)i.has(c)||i.set(c,{}),i.get(c).l=!0}else n.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)i.has(c)||i.set(c,{}),i.get(c).r=!0;else n.issues.push(a);let o=[...i].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(o.length&&t&&n.issues.push({...t,keys:o}),sn(n))return n;let s=iu(e.value,r.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return n.value=s.data,n}var ws=k("$ZodTuple",(n,e)=>{Y.init(n,e);let r=e.items;n._zod.parse=(i,t)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:n,expected:"tuple",code:"invalid_type"}),i;i.value=[];let s=[],a=[...r].reverse().findIndex(u=>u._zod.optin!=="optional"),c=a===-1?0:r.length-a;if(!e.rest){let u=o.length>r.length,d=o.length<c-1;if(u||d)return i.issues.push({...u?{code:"too_big",maximum:r.length,inclusive:!0}:{code:"too_small",minimum:r.length},input:o,inst:n,origin:"array"}),i}let l=-1;for(let u of r){if(l++,l>=o.length&&l>=c)continue;let d=u._zod.run({value:o[l],issues:[]},t);d instanceof Promise?s.push(d.then(p=>ys(p,i,l))):ys(d,i,l)}if(e.rest){let u=o.slice(r.length);for(let d of u){l++;let p=e.rest._zod.run({value:d,issues:[]},t);p instanceof Promise?s.push(p.then(f=>ys(f,i,l))):ys(p,i,l)}}return s.length?Promise.all(s).then(()=>i):i}});function ys(n,e,r){n.issues.length&&e.issues.push(...Ye(r,n.issues)),e.value[r]=n.value}var Gu=k("$ZodRecord",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value;if(!on(t))return r.issues.push({expected:"record",code:"invalid_type",input:t,inst:n}),r;let o=[],s=e.keyType._zod.values;if(s){r.value={};let a=new Set;for(let l of s)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){a.add(typeof l=="number"?l.toString():l);let u=e.valueType._zod.run({value:t[l],issues:[]},i);u instanceof Promise?o.push(u.then(d=>{d.issues.length&&r.issues.push(...Ye(l,d.issues)),r.value[l]=d.value})):(u.issues.length&&r.issues.push(...Ye(l,u.issues)),r.value[l]=u.value)}let c;for(let l in t)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:t,inst:n,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(t)){if(a==="__proto__")continue;let c=e.keyType._zod.run({value:a,issues:[]},i);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&fs.test(a)&&c.issues.length){let d=e.keyType._zod.run({value:Number(a),issues:[]},i);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){e.mode==="loose"?r.value[a]=t[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>qe(d,i,xe())),input:a,path:[a],inst:n});continue}let u=e.valueType._zod.run({value:t[a],issues:[]},i);u instanceof Promise?o.push(u.then(d=>{d.issues.length&&r.issues.push(...Ye(a,d.issues)),r.value[c.value]=d.value})):(u.issues.length&&r.issues.push(...Ye(a,u.issues)),r.value[c.value]=u.value)}}return o.length?Promise.all(o).then(()=>r):r}}),Ju=k("$ZodMap",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value;if(!(t instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:t,inst:n}),r;let o=[];r.value=new Map;for(let[s,a]of t){let c=e.keyType._zod.run({value:s,issues:[]},i),l=e.valueType._zod.run({value:a,issues:[]},i);c instanceof Promise||l instanceof Promise?o.push(Promise.all([c,l]).then(([u,d])=>{dy(u,d,r,s,t,n,i)})):dy(c,l,r,s,t,n,i)}return o.length?Promise.all(o).then(()=>r):r}});function dy(n,e,r,i,t,o,s){n.issues.length&&(gi.has(typeof i)?r.issues.push(...Ye(i,n.issues)):r.issues.push({code:"invalid_key",origin:"map",input:t,inst:o,issues:n.issues.map(a=>qe(a,s,xe()))})),e.issues.length&&(gi.has(typeof i)?r.issues.push(...Ye(i,e.issues)):r.issues.push({origin:"map",code:"invalid_element",input:t,inst:o,key:i,issues:e.issues.map(a=>qe(a,s,xe()))})),r.value.set(n.value,e.value)}var qu=k("$ZodSet",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value;if(!(t instanceof Set))return r.issues.push({input:t,inst:n,expected:"set",code:"invalid_type"}),r;let o=[];r.value=new Set;for(let s of t){let a=e.valueType._zod.run({value:s,issues:[]},i);a instanceof Promise?o.push(a.then(c=>py(c,r))):py(a,r)}return o.length?Promise.all(o).then(()=>r):r}});function py(n,e){n.issues.length&&e.issues.push(...n.issues),e.value.add(n.value)}var Vu=k("$ZodEnum",(n,e)=>{Y.init(n,e);let r=fi(e.entries),i=new Set(r);n._zod.values=i,n._zod.pattern=new RegExp(`^(${r.filter(t=>gi.has(typeof t)).map(t=>typeof t=="string"?st(t):t.toString()).join("|")})$`),n._zod.parse=(t,o)=>{let s=t.value;return i.has(s)||t.issues.push({code:"invalid_value",values:r,input:s,inst:n}),t}}),Ku=k("$ZodLiteral",(n,e)=>{if(Y.init(n,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(e.values);n._zod.values=r,n._zod.pattern=new RegExp(`^(${e.values.map(i=>typeof i=="string"?st(i):i?st(i.toString()):String(i)).join("|")})$`),n._zod.parse=(i,t)=>{let o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:e.values,input:o,inst:n}),i}}),Yu=k("$ZodFile",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value;return t instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:t,inst:n}),r}}),Xu=k("$ZodTransform",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{if(i.direction==="backward")throw new tn(n.constructor.name);let t=e.transform(r.value,r);if(i.async)return(t instanceof Promise?t:Promise.resolve(t)).then(s=>(r.value=s,r));if(t instanceof Promise)throw new bt;return r.value=t,r}});function my(n,e){return n.issues.length&&e===void 0?{issues:[],value:void 0}:n}var ks=k("$ZodOptional",(n,e)=>{Y.init(n,e),n._zod.optin="optional",n._zod.optout="optional",ne(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ne(n._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${hi(r.source)})?$`):void 0}),n._zod.parse=(r,i)=>{if(e.innerType._zod.optin==="optional"){let t=e.innerType._zod.run(r,i);return t instanceof Promise?t.then(o=>my(o,r.value)):my(t,r.value)}return r.value===void 0?r:e.innerType._zod.run(r,i)}}),Qu=k("$ZodExactOptional",(n,e)=>{ks.init(n,e),ne(n._zod,"values",()=>e.innerType._zod.values),ne(n._zod,"pattern",()=>e.innerType._zod.pattern),n._zod.parse=(r,i)=>e.innerType._zod.run(r,i)}),ed=k("$ZodNullable",(n,e)=>{Y.init(n,e),ne(n._zod,"optin",()=>e.innerType._zod.optin),ne(n._zod,"optout",()=>e.innerType._zod.optout),ne(n._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${hi(r.source)}|null)$`):void 0}),ne(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),n._zod.parse=(r,i)=>r.value===null?r:e.innerType._zod.run(r,i)}),td=k("$ZodDefault",(n,e)=>{Y.init(n,e),n._zod.optin="optional",ne(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(r,i)=>{if(i.direction==="backward")return e.innerType._zod.run(r,i);if(r.value===void 0)return r.value=e.defaultValue,r;let t=e.innerType._zod.run(r,i);return t instanceof Promise?t.then(o=>fy(o,e)):fy(t,e)}});function fy(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}var nd=k("$ZodPrefault",(n,e)=>{Y.init(n,e),n._zod.optin="optional",ne(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(r,i)=>(i.direction==="backward"||r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,i))}),rd=k("$ZodNonOptional",(n,e)=>{Y.init(n,e),ne(n._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(i=>i!==void 0)):void 0}),n._zod.parse=(r,i)=>{let t=e.innerType._zod.run(r,i);return t instanceof Promise?t.then(o=>hy(o,n)):hy(t,n)}});function hy(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}var id=k("$ZodSuccess",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{if(i.direction==="backward")throw new tn("ZodSuccess");let t=e.innerType._zod.run(r,i);return t instanceof Promise?t.then(o=>(r.value=o.issues.length===0,r)):(r.value=t.issues.length===0,r)}}),od=k("$ZodCatch",(n,e)=>{Y.init(n,e),ne(n._zod,"optin",()=>e.innerType._zod.optin),ne(n._zod,"optout",()=>e.innerType._zod.optout),ne(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(r,i)=>{if(i.direction==="backward")return e.innerType._zod.run(r,i);let t=e.innerType._zod.run(r,i);return t instanceof Promise?t.then(o=>(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>qe(s,i,xe()))},input:r.value}),r.issues=[]),r)):(r.value=t.value,t.issues.length&&(r.value=e.catchValue({...r,error:{issues:t.issues.map(o=>qe(o,i,xe()))},input:r.value}),r.issues=[]),r)}}),sd=k("$ZodNaN",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:n,expected:"nan",code:"invalid_type"}),r)}),ad=k("$ZodPipe",(n,e)=>{Y.init(n,e),ne(n._zod,"values",()=>e.in._zod.values),ne(n._zod,"optin",()=>e.in._zod.optin),ne(n._zod,"optout",()=>e.out._zod.optout),ne(n._zod,"propValues",()=>e.in._zod.propValues),n._zod.parse=(r,i)=>{if(i.direction==="backward"){let o=e.out._zod.run(r,i);return o instanceof Promise?o.then(s=>bs(s,e.in,i)):bs(o,e.in,i)}let t=e.in._zod.run(r,i);return t instanceof Promise?t.then(o=>bs(o,e.out,i)):bs(t,e.out,i)}});function bs(n,e,r){return n.issues.length?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},r)}var Ii=k("$ZodCodec",(n,e)=>{Y.init(n,e),ne(n._zod,"values",()=>e.in._zod.values),ne(n._zod,"optin",()=>e.in._zod.optin),ne(n._zod,"optout",()=>e.out._zod.optout),ne(n._zod,"propValues",()=>e.in._zod.propValues),n._zod.parse=(r,i)=>{if((i.direction||"forward")==="forward"){let o=e.in._zod.run(r,i);return o instanceof Promise?o.then(s=>vs(s,e,i)):vs(o,e,i)}else{let o=e.out._zod.run(r,i);return o instanceof Promise?o.then(s=>vs(s,e,i)):vs(o,e,i)}}});function vs(n,e,r){if(n.issues.length)return n.aborted=!0,n;if((r.direction||"forward")==="forward"){let t=e.transform(n.value,n);return t instanceof Promise?t.then(o=>_s(n,o,e.out,r)):_s(n,t,e.out,r)}else{let t=e.reverseTransform(n.value,n);return t instanceof Promise?t.then(o=>_s(n,o,e.in,r)):_s(n,t,e.in,r)}}function _s(n,e,r,i){return n.issues.length?(n.aborted=!0,n):r._zod.run({value:e,issues:n.issues},i)}var cd=k("$ZodReadonly",(n,e)=>{Y.init(n,e),ne(n._zod,"propValues",()=>e.innerType._zod.propValues),ne(n._zod,"values",()=>e.innerType._zod.values),ne(n._zod,"optin",()=>e.innerType?._zod?.optin),ne(n._zod,"optout",()=>e.innerType?._zod?.optout),n._zod.parse=(r,i)=>{if(i.direction==="backward")return e.innerType._zod.run(r,i);let t=e.innerType._zod.run(r,i);return t instanceof Promise?t.then(gy):gy(t)}});function gy(n){return n.value=Object.freeze(n.value),n}var ld=k("$ZodTemplateLiteral",(n,e)=>{Y.init(n,e);let r=[];for(let i of e.parts)if(typeof i=="object"&&i!==null){if(!i._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);let t=i._zod.pattern instanceof RegExp?i._zod.pattern.source:i._zod.pattern;if(!t)throw new Error(`Invalid template literal part: ${i._zod.traits}`);let o=t.startsWith("^")?1:0,s=t.endsWith("$")?t.length-1:t.length;r.push(t.slice(o,s))}else if(i===null||rl.has(typeof i))r.push(st(`${i}`));else throw new Error(`Invalid template literal part: ${i}`);n._zod.pattern=new RegExp(`^${r.join("")}$`),n._zod.parse=(i,t)=>typeof i.value!="string"?(i.issues.push({input:i.value,inst:n,expected:"string",code:"invalid_type"}),i):(n._zod.pattern.lastIndex=0,n._zod.pattern.test(i.value)||i.issues.push({input:i.value,inst:n,code:"invalid_format",format:e.format??"template_literal",pattern:n._zod.pattern.source}),i)}),ud=k("$ZodFunction",(n,e)=>(Y.init(n,e),n._def=e,n._zod.def=e,n.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...i){let t=n._def.input?rs(n._def.input,i):i,o=Reflect.apply(r,this,t);return n._def.output?rs(n._def.output,o):o}},n.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...i){let t=n._def.input?await is(n._def.input,i):i,o=await Reflect.apply(r,this,t);return n._def.output?await is(n._def.output,o):o}},n._zod.parse=(r,i)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:n}),r):(n._def.output&&n._def.output._zod.def.type==="promise"?r.value=n.implementAsync(r.value):r.value=n.implement(r.value),r),n.input=(...r)=>{let i=n.constructor;return Array.isArray(r[0])?new i({type:"function",input:new ws({type:"tuple",items:r[0],rest:r[1]}),output:n._def.output}):new i({type:"function",input:r[0],output:n._def.output})},n.output=r=>{let i=n.constructor;return new i({type:"function",input:n._def.input,output:r})},n)),dd=k("$ZodPromise",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>Promise.resolve(r.value).then(t=>e.innerType._zod.run({value:t,issues:[]},i))}),pd=k("$ZodLazy",(n,e)=>{Y.init(n,e),ne(n._zod,"innerType",()=>e.getter()),ne(n._zod,"pattern",()=>n._zod.innerType?._zod?.pattern),ne(n._zod,"propValues",()=>n._zod.innerType?._zod?.propValues),ne(n._zod,"optin",()=>n._zod.innerType?._zod?.optin??void 0),ne(n._zod,"optout",()=>n._zod.innerType?._zod?.optout??void 0),n._zod.parse=(r,i)=>n._zod.innerType._zod.run(r,i)}),md=k("$ZodCustom",(n,e)=>{me.init(n,e),Y.init(n,e),n._zod.parse=(r,i)=>r,n._zod.check=r=>{let i=r.value,t=e.fn(i);if(t instanceof Promise)return t.then(o=>yy(o,r,i,n));yy(t,r,i,n)}});function yy(n,e,r,i){if(!n){let t={code:"custom",input:r,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(t.params=i._zod.def.params),e.issues.push(dr(t))}}var Pi={};et(Pi,{ar:()=>$y,az:()=>wy,be:()=>Ey,bg:()=>Iy,ca:()=>Ty,cs:()=>Py,da:()=>Ry,de:()=>zy,en:()=>Es,eo:()=>Ny,es:()=>Cy,fa:()=>Dy,fi:()=>Ly,fr:()=>Ay,frCA:()=>Oy,he:()=>My,hu:()=>jy,hy:()=>Uy,id:()=>Zy,is:()=>Hy,it:()=>Wy,ja:()=>By,ka:()=>Gy,kh:()=>Jy,km:()=>Is,ko:()=>qy,lt:()=>Ky,mk:()=>Yy,ms:()=>Xy,nl:()=>Qy,no:()=>eb,ota:()=>tb,pl:()=>rb,ps:()=>nb,pt:()=>ib,ru:()=>sb,sl:()=>ab,sv:()=>cb,ta:()=>lb,th:()=>ub,tr:()=>db,ua:()=>pb,uk:()=>Ts,ur:()=>mb,uz:()=>fb,vi:()=>hb,yo:()=>bb,zhCN:()=>gb,zhTW:()=>yb});var gw=()=>{let n={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function e(t){return n[t]??null}let r={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${t.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`:`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${o}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`}case"invalid_value":return t.values.length===1?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${A(t.values[0])}`:`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${t.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${t.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${t.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${t.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${t.minimum.toString()} ${s.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${t.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${t.prefix}"`:o.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${o.suffix}"`:o.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${o.includes}"`:o.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${o.pattern}`:`${r[o.format]??t.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${t.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${t.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${t.keys.length>1?"\u0629":""}: ${P(t.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${t.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${t.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function $y(){return{localeError:gw()}}var yw=()=>{let n={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function e(t){return n[t]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${t.expected}, daxil olan ${a}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${o}, daxil olan ${a}`}case"invalid_value":return t.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${A(t.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${t.origin??"d\u0259y\u0259r"} ${o}${t.maximum.toString()} ${s.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${t.origin??"d\u0259y\u0259r"} ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${t.origin} ${o}${t.minimum.toString()} ${s.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${t.origin} ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${o.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:o.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${o.suffix}" il\u0259 bitm\u0259lidir`:o.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${o.includes}" daxil olmal\u0131d\u0131r`:o.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${o.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${r[o.format]??t.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${t.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${t.keys.length>1?"lar":""}: ${P(t.keys,", ")}`;case"invalid_key":return`${t.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${t.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function wy(){return{localeError:yw()}}function ky(n,e,r,i){let t=Math.abs(n),o=t%10,s=t%100;return s>=11&&s<=19?i:o===1?e:o>=2&&o<=4?r:i}var bw=()=>{let n={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function e(t){return n[t]??null}let r={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},i={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${t.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${o}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`}case"invalid_value":return t.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${A(t.values[0])}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);if(s){let a=Number(t.maximum),c=ky(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${t.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${o}${t.maximum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${t.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);if(s){let a=Number(t.minimum),c=ky(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${t.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${o}${t.minimum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${t.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${r[o.format]??t.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${t.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${t.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${P(t.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${t.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${t.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function Ey(){return{localeError:bw()}}var vw=()=>{let n={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function e(t){return n[t]??null}let r={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${t.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`}case"invalid_value":return t.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${A(t.values[0])}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${t.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${t.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${t.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${t.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${t.minimum.toString()} ${s.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${t.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;if(o.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${o.prefix}"`;if(o.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${o.suffix}"`;if(o.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${o.includes}"`;if(o.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${o.pattern}`;let s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return o.format==="emoji"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="datetime"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="date"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),o.format==="time"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="duration"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${s} ${r[o.format]??t.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${t.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${t.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${t.keys.length>1?"\u043E\u0432\u0435":""}: ${P(t.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${t.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${t.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};function Iy(){return{localeError:vw()}}var _w=()=>{let n={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function e(t){return n[t]??null}let r={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${t.expected}, s'ha rebut ${a}`:`Tipus inv\xE0lid: s'esperava ${o}, s'ha rebut ${a}`}case"invalid_value":return t.values.length===1?`Valor inv\xE0lid: s'esperava ${A(t.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${P(t.values," o ")}`;case"too_big":{let o=t.inclusive?"com a m\xE0xim":"menys de",s=e(t.origin);return s?`Massa gran: s'esperava que ${t.origin??"el valor"} contingu\xE9s ${o} ${t.maximum.toString()} ${s.unit??"elements"}`:`Massa gran: s'esperava que ${t.origin??"el valor"} fos ${o} ${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?"com a m\xEDnim":"m\xE9s de",s=e(t.origin);return s?`Massa petit: s'esperava que ${t.origin} contingu\xE9s ${o} ${t.minimum.toString()} ${s.unit}`:`Massa petit: s'esperava que ${t.origin} fos ${o} ${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${o.prefix}"`:o.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${o.suffix}"`:o.format==="includes"?`Format inv\xE0lid: ha d'incloure "${o.includes}"`:o.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${o.pattern}`:`Format inv\xE0lid per a ${r[o.format]??t.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${t.divisor}`;case"unrecognized_keys":return`Clau${t.keys.length>1?"s":""} no reconeguda${t.keys.length>1?"s":""}: ${P(t.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${t.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${t.origin}`;default:return"Entrada inv\xE0lida"}}};function Ty(){return{localeError:_w()}}var xw=()=>{let n={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function e(t){return n[t]??null}let r={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"},i={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${t.expected}, obdr\u017Eeno ${a}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${o}, obdr\u017Eeno ${a}`}case"invalid_value":return t.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${A(t.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${t.origin??"hodnota"} mus\xED m\xEDt ${o}${t.maximum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${t.origin??"hodnota"} mus\xED b\xFDt ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${t.origin??"hodnota"} mus\xED m\xEDt ${o}${t.minimum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${t.origin??"hodnota"} mus\xED b\xFDt ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${o.prefix}"`:o.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${o.suffix}"`:o.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${o.includes}"`:o.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${o.pattern}`:`Neplatn\xFD form\xE1t ${r[o.format]??t.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${t.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${P(t.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${t.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${t.origin}`;default:return"Neplatn\xFD vstup"}}};function Py(){return{localeError:xw()}}var Sw=()=>{let n={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function e(t){return n[t]??null}let r={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},i={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Ugyldigt input: forventede instanceof ${t.expected}, fik ${a}`:`Ugyldigt input: forventede ${o}, fik ${a}`}case"invalid_value":return t.values.length===1?`Ugyldig v\xE6rdi: forventede ${A(t.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin),a=i[t.origin]??t.origin;return s?`For stor: forventede ${a??"value"} ${s.verb} ${o} ${t.maximum.toString()} ${s.unit??"elementer"}`:`For stor: forventede ${a??"value"} havde ${o} ${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin),a=i[t.origin]??t.origin;return s?`For lille: forventede ${a} ${s.verb} ${o} ${t.minimum.toString()} ${s.unit}`:`For lille: forventede ${a} havde ${o} ${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Ugyldig streng: skal starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: skal ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: skal indeholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${r[o.format]??t.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${t.divisor}`;case"unrecognized_keys":return`${t.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${P(t.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${t.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${t.origin}`;default:return"Ugyldigt input"}}};function Ry(){return{localeError:Sw()}}var $w=()=>{let n={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function e(t){return n[t]??null}let r={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"},i={nan:"NaN",number:"Zahl",array:"Array"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${t.expected}, erhalten ${a}`:`Ung\xFCltige Eingabe: erwartet ${o}, erhalten ${a}`}case"invalid_value":return t.values.length===1?`Ung\xFCltige Eingabe: erwartet ${A(t.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Zu gro\xDF: erwartet, dass ${t.origin??"Wert"} ${o}${t.maximum.toString()} ${s.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${t.origin??"Wert"} ${o}${t.maximum.toString()} ist`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Zu klein: erwartet, dass ${t.origin} ${o}${t.minimum.toString()} ${s.unit} hat`:`Zu klein: erwartet, dass ${t.origin} ${o}${t.minimum.toString()} ist`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Ung\xFCltiger String: muss mit "${o.prefix}" beginnen`:o.format==="ends_with"?`Ung\xFCltiger String: muss mit "${o.suffix}" enden`:o.format==="includes"?`Ung\xFCltiger String: muss "${o.includes}" enthalten`:o.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${o.pattern} entsprechen`:`Ung\xFCltig: ${r[o.format]??t.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${t.divisor} sein`;case"unrecognized_keys":return`${t.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${P(t.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${t.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${t.origin}`;default:return"Ung\xFCltige Eingabe"}}};function zy(){return{localeError:$w()}}var ww=()=>{let n={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(t){return n[t]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return`Invalid input: expected ${o}, received ${a}`}case"invalid_value":return t.values.length===1?`Invalid input: expected ${A(t.values[0])}`:`Invalid option: expected one of ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Too big: expected ${t.origin??"value"} to have ${o}${t.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${t.origin??"value"} to be ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Too small: expected ${t.origin} to have ${o}${t.minimum.toString()} ${s.unit}`:`Too small: expected ${t.origin} to be ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.format]??t.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${t.divisor}`;case"unrecognized_keys":return`Unrecognized key${t.keys.length>1?"s":""}: ${P(t.keys,", ")}`;case"invalid_key":return`Invalid key in ${t.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${t.origin}`;default:return"Invalid input"}}};function Es(){return{localeError:ww()}}var kw=()=>{let n={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function e(t){return n[t]??null}let r={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"},i={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${t.expected}, ricevi\u011Dis ${a}`:`Nevalida enigo: atendi\u011Dis ${o}, ricevi\u011Dis ${a}`}case"invalid_value":return t.values.length===1?`Nevalida enigo: atendi\u011Dis ${A(t.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Tro granda: atendi\u011Dis ke ${t.origin??"valoro"} havu ${o}${t.maximum.toString()} ${s.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${t.origin??"valoro"} havu ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Tro malgranda: atendi\u011Dis ke ${t.origin} havu ${o}${t.minimum.toString()} ${s.unit}`:`Tro malgranda: atendi\u011Dis ke ${t.origin} estu ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${o.prefix}"`:o.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${o.suffix}"`:o.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${o.includes}"`:o.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${o.pattern}`:`Nevalida ${r[o.format]??t.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${t.divisor}`;case"unrecognized_keys":return`Nekonata${t.keys.length>1?"j":""} \u015Dlosilo${t.keys.length>1?"j":""}: ${P(t.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${t.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${t.origin}`;default:return"Nevalida enigo"}}};function Ny(){return{localeError:kw()}}var Ew=()=>{let n={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function e(t){return n[t]??null}let r={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${t.expected}, recibido ${a}`:`Entrada inv\xE1lida: se esperaba ${o}, recibido ${a}`}case"invalid_value":return t.values.length===1?`Entrada inv\xE1lida: se esperaba ${A(t.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin),a=i[t.origin]??t.origin;return s?`Demasiado grande: se esperaba que ${a??"valor"} tuviera ${o}${t.maximum.toString()} ${s.unit??"elementos"}`:`Demasiado grande: se esperaba que ${a??"valor"} fuera ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin),a=i[t.origin]??t.origin;return s?`Demasiado peque\xF1o: se esperaba que ${a} tuviera ${o}${t.minimum.toString()} ${s.unit}`:`Demasiado peque\xF1o: se esperaba que ${a} fuera ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${o.prefix}"`:o.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${o.suffix}"`:o.format==="includes"?`Cadena inv\xE1lida: debe incluir "${o.includes}"`:o.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${o.pattern}`:`Inv\xE1lido ${r[o.format]??t.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${t.divisor}`;case"unrecognized_keys":return`Llave${t.keys.length>1?"s":""} desconocida${t.keys.length>1?"s":""}: ${P(t.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${i[t.origin]??t.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${i[t.origin]??t.origin}`;default:return"Entrada inv\xE1lida"}}};function Cy(){return{localeError:Ew()}}var Iw=()=>{let n={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function e(t){return n[t]??null}let r={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${t.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`:`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${o} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return t.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${A(t.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${P(t.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${t.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${t.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${t.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${t.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${t.origin} \u0628\u0627\u06CC\u062F ${o}${t.minimum.toString()} ${s.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${t.origin} \u0628\u0627\u06CC\u062F ${o}${t.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:o.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:o.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${o.includes}" \u0628\u0627\u0634\u062F`:o.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${o.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${r[o.format]??t.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${t.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${t.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${P(t.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${t.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${t.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function Dy(){return{localeError:Iw()}}var Tw=()=>{let n={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function e(t){return n[t]??null}let r={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Virheellinen tyyppi: odotettiin instanceof ${t.expected}, oli ${a}`:`Virheellinen tyyppi: odotettiin ${o}, oli ${a}`}case"invalid_value":return t.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${A(t.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Liian suuri: ${s.subject} t\xE4ytyy olla ${o}${t.maximum.toString()} ${s.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Liian pieni: ${s.subject} t\xE4ytyy olla ${o}${t.minimum.toString()} ${s.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${o.prefix}"`:o.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${o.suffix}"`:o.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${o.includes}"`:o.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${o.pattern}`:`Virheellinen ${r[o.format]??t.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${t.divisor} monikerta`;case"unrecognized_keys":return`${t.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${P(t.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};function Ly(){return{localeError:Tw()}}var Pw=()=>{let n={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function e(t){return n[t]??null}let r={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},i={nan:"NaN",number:"nombre",array:"tableau"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Entr\xE9e invalide : instanceof ${t.expected} attendu, ${a} re\xE7u`:`Entr\xE9e invalide : ${o} attendu, ${a} re\xE7u`}case"invalid_value":return t.values.length===1?`Entr\xE9e invalide : ${A(t.values[0])} attendu`:`Option invalide : une valeur parmi ${P(t.values,"|")} attendue`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Trop grand : ${t.origin??"valeur"} doit ${s.verb} ${o}${t.maximum.toString()} ${s.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${t.origin??"valeur"} doit \xEAtre ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Trop petit : ${t.origin} doit ${s.verb} ${o}${t.minimum.toString()} ${s.unit}`:`Trop petit : ${t.origin} doit \xEAtre ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au mod\xE8le ${o.pattern}`:`${r[o.format]??t.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${t.divisor}`;case"unrecognized_keys":return`Cl\xE9${t.keys.length>1?"s":""} non reconnue${t.keys.length>1?"s":""} : ${P(t.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${t.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${t.origin}`;default:return"Entr\xE9e invalide"}}};function Ay(){return{localeError:Pw()}}var Rw=()=>{let n={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function e(t){return n[t]??null}let r={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Entr\xE9e invalide : attendu instanceof ${t.expected}, re\xE7u ${a}`:`Entr\xE9e invalide : attendu ${o}, re\xE7u ${a}`}case"invalid_value":return t.values.length===1?`Entr\xE9e invalide : attendu ${A(t.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"\u2264":"<",s=e(t.origin);return s?`Trop grand : attendu que ${t.origin??"la valeur"} ait ${o}${t.maximum.toString()} ${s.unit}`:`Trop grand : attendu que ${t.origin??"la valeur"} soit ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?"\u2265":">",s=e(t.origin);return s?`Trop petit : attendu que ${t.origin} ait ${o}${t.minimum.toString()} ${s.unit}`:`Trop petit : attendu que ${t.origin} soit ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${o.pattern}`:`${r[o.format]??t.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${t.divisor}`;case"unrecognized_keys":return`Cl\xE9${t.keys.length>1?"s":""} non reconnue${t.keys.length>1?"s":""} : ${P(t.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${t.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${t.origin}`;default:return"Entr\xE9e invalide"}}};function Oy(){return{localeError:Rw()}}var zw=()=>{let n={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},e={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},r=l=>l?n[l]:void 0,i=l=>{let u=r(l);return u?u.label:l??n.unknown.label},t=l=>`\u05D4${i(l)}`,o=l=>(r(l)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",s=l=>l?e[l]??null:null,a={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},c={nan:"NaN"};return l=>{switch(l.code){case"invalid_type":{let u=l.expected,d=c[u??""]??i(u),p=O(l.input),f=c[p]??n[p]?.label??p;return/^[A-Z]/.test(l.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${l.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${f}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${d}, \u05D4\u05EA\u05E7\u05D1\u05DC ${f}`}case"invalid_value":{if(l.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${A(l.values[0])}`;let u=l.values.map(f=>A(f));if(l.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u[0]} \u05D0\u05D5 ${u[1]}`;let d=u[u.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u.slice(0,-1).join(", ")} \u05D0\u05D5 ${d}`}case"too_big":{let u=s(l.origin),d=t(l.origin??"value");if(l.origin==="string")return`${u?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.maximum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(l.origin==="number"){let m=l.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${l.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(l.origin==="array"||l.origin==="set"){let m=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",h=l.inclusive?`${l.maximum} ${u?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${l.maximum} ${u?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let p=l.inclusive?"<=":"<",f=o(l.origin??"value");return u?.unit?`${u.longLabel} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${l.maximum.toString()} ${u.unit}`:`${u?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${l.maximum.toString()}`}case"too_small":{let u=s(l.origin),d=t(l.origin??"value");if(l.origin==="string")return`${u?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.minimum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(l.origin==="number"){let m=l.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${l.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(l.origin==="array"||l.origin==="set"){let m=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(l.minimum===1&&l.inclusive){let v=(l.origin==="set","\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${v}`}let h=l.inclusive?`${l.minimum} ${u?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${l.minimum} ${u?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let p=l.inclusive?">=":">",f=o(l.origin??"value");return u?.unit?`${u.shortLabel} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${l.minimum.toString()} ${u.unit}`:`${u?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${l.minimum.toString()}`}case"invalid_format":{let u=l;if(u.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${u.prefix}"`;if(u.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${u.suffix}"`;if(u.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${u.includes}"`;if(u.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${u.pattern}`;let d=a[u.format],p=d?.label??u.format,m=(d?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${p} \u05DC\u05D0 ${m}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${l.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${l.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${l.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${P(l.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${t(l.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function My(){return{localeError:zw()}}var Nw=()=>{let n={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function e(t){return n[t]??null}let r={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"},i={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${t.expected}, a kapott \xE9rt\xE9k ${a}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${o}, a kapott \xE9rt\xE9k ${a}`}case"invalid_value":return t.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${A(t.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`T\xFAl nagy: ${t.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${o}${t.maximum.toString()} ${s.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${t.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${t.origin} m\xE9rete t\xFAl kicsi ${o}${t.minimum.toString()} ${s.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${t.origin} t\xFAl kicsi ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\xC9rv\xE9nytelen string: "${o.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:o.format==="ends_with"?`\xC9rv\xE9nytelen string: "${o.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:o.format==="includes"?`\xC9rv\xE9nytelen string: "${o.includes}" \xE9rt\xE9ket kell tartalmaznia`:o.format==="regex"?`\xC9rv\xE9nytelen string: ${o.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${r[o.format]??t.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${t.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${t.keys.length>1?"s":""}: ${P(t.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${t.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${t.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function jy(){return{localeError:Nw()}}function Fy(n,e,r){return Math.abs(n)===1?e:r}function yr(n){if(!n)return"";let e=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],r=n[n.length-1];return n+(e.includes(r)?"\u0576":"\u0568")}var Cw=()=>{let n={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function e(t){return n[t]??null}let r={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},i={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${t.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`:`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${o}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`}case"invalid_value":return t.values.length===1?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${A(t.values[1])}`:`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);if(s){let a=Number(t.maximum),c=Fy(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${yr(t.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${t.maximum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${yr(t.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);if(s){let a=Number(t.minimum),c=Fy(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${yr(t.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${t.minimum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${yr(t.origin)} \u056C\u056B\u0576\u056B ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${o.prefix}"-\u0578\u057E`:o.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${o.suffix}"-\u0578\u057E`:o.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${o.includes}"`:o.format==="regex"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${o.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${r[o.format]??t.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${t.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${t.keys.length>1?"\u0576\u0565\u0580":""}. ${P(t.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${yr(t.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${yr(t.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function Uy(){return{localeError:Cw()}}var Dw=()=>{let n={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function e(t){return n[t]??null}let r={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Input tidak valid: diharapkan instanceof ${t.expected}, diterima ${a}`:`Input tidak valid: diharapkan ${o}, diterima ${a}`}case"invalid_value":return t.values.length===1?`Input tidak valid: diharapkan ${A(t.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Terlalu besar: diharapkan ${t.origin??"value"} memiliki ${o}${t.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: diharapkan ${t.origin??"value"} menjadi ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Terlalu kecil: diharapkan ${t.origin} memiliki ${o}${t.minimum.toString()} ${s.unit}`:`Terlalu kecil: diharapkan ${t.origin} menjadi ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`String tidak valid: harus dimulai dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak valid: harus berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak valid: harus menyertakan "${o.includes}"`:o.format==="regex"?`String tidak valid: harus sesuai pola ${o.pattern}`:`${r[o.format]??t.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${t.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${t.keys.length>1?"s":""}: ${P(t.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${t.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${t.origin}`;default:return"Input tidak valid"}}};function Zy(){return{localeError:Dw()}}var Lw=()=>{let n={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"}};function e(t){return n[t]??null}let r={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",jwt:"JWT",template_literal:"gildi"},i={nan:"NaN",number:"n\xFAmer",array:"fylki"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera instanceof ${t.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera ${o}`}case"invalid_value":return t.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${A(t.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${t.origin??"gildi"} hafi ${o}${t.maximum.toString()} ${s.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${t.origin??"gildi"} s\xE9 ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${t.origin} hafi ${o}${t.minimum.toString()} ${s.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${t.origin} s\xE9 ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${o.prefix}"`:o.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${o.suffix}"`:o.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${o.includes}"`:o.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${o.pattern}`:`Rangt ${r[o.format]??t.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${t.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${t.keys.length>1?"ir lyklar":"ur lykill"}: ${P(t.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${t.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${t.origin}`;default:return"Rangt gildi"}}};function Hy(){return{localeError:Lw()}}var Aw=()=>{let n={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function e(t){return n[t]??null}let r={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"numero",array:"vettore"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Input non valido: atteso instanceof ${t.expected}, ricevuto ${a}`:`Input non valido: atteso ${o}, ricevuto ${a}`}case"invalid_value":return t.values.length===1?`Input non valido: atteso ${A(t.values[0])}`:`Opzione non valida: atteso uno tra ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Troppo grande: ${t.origin??"valore"} deve avere ${o}${t.maximum.toString()} ${s.unit??"elementi"}`:`Troppo grande: ${t.origin??"valore"} deve essere ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Troppo piccolo: ${t.origin} deve avere ${o}${t.minimum.toString()} ${s.unit}`:`Troppo piccolo: ${t.origin} deve essere ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Stringa non valida: deve iniziare con "${o.prefix}"`:o.format==="ends_with"?`Stringa non valida: deve terminare con "${o.suffix}"`:o.format==="includes"?`Stringa non valida: deve includere "${o.includes}"`:o.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${o.pattern}`:`Invalid ${r[o.format]??t.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${t.divisor}`;case"unrecognized_keys":return`Chiav${t.keys.length>1?"i":"e"} non riconosciut${t.keys.length>1?"e":"a"}: ${P(t.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${t.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${t.origin}`;default:return"Input non valido"}}};function Wy(){return{localeError:Aw()}}var Ow=()=>{let n={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function e(t){return n[t]??null}let r={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},i={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${t.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${o}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return t.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${A(t.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${P(t.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let o=t.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",s=e(t.origin);return s?`\u5927\u304D\u3059\u304E\u308B\u5024: ${t.origin??"\u5024"}\u306F${t.maximum.toString()}${s.unit??"\u8981\u7D20"}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${t.origin??"\u5024"}\u306F${t.maximum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let o=t.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",s=e(t.origin);return s?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${t.origin}\u306F${t.minimum.toString()}${s.unit}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${t.origin}\u306F${t.minimum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${o.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${r[o.format]??t.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${t.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${t.keys.length>1?"\u7FA4":""}: ${P(t.keys,"\u3001")}`;case"invalid_key":return`${t.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${t.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function By(){return{localeError:Ow()}}var Mw=()=>{let n={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function e(t){return n[t]??null}let r={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",json_string:"JSON \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},i={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${t.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${o}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`}case"invalid_value":return t.values.length===1?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${A(t.values[0])}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${P(t.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${t.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${s.verb} ${o}${t.maximum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${t.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${t.origin} ${s.verb} ${o}${t.minimum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${t.origin} \u10D8\u10E7\u10DD\u10E1 ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.prefix}"-\u10D8\u10D7`:o.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.suffix}"-\u10D8\u10D7`:o.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${o.includes}"-\u10E1`:o.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${o.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${r[o.format]??t.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${t.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${t.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${P(t.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${t.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${t.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};function Gy(){return{localeError:Mw()}}var jw=()=>{let n={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function e(t){return n[t]??null}let r={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},i={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${t.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`:`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${o} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`}case"invalid_value":return t.values.length===1?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${A(t.values[0])}`:`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${t.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${t.maximum.toString()} ${s.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${t.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${t.origin} ${o} ${t.minimum.toString()} ${s.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${t.origin} ${o} ${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${o.prefix}"`:o.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${o.suffix}"`:o.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${o.includes}"`:o.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${o.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${r[o.format]??t.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${t.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${P(t.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${t.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${t.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};function Is(){return{localeError:jw()}}function Jy(){return Is()}var Fw=()=>{let n={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function e(t){return n[t]??null}let r={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${t.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${o}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`}case"invalid_value":return t.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${A(t.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${P(t.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let o=t.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",s=o==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=e(t.origin),c=a?.unit??"\uC694\uC18C";return a?`${t.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${t.maximum.toString()}${c} ${o}${s}`:`${t.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${t.maximum.toString()} ${o}${s}`}case"too_small":{let o=t.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",s=o==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=e(t.origin),c=a?.unit??"\uC694\uC18C";return a?`${t.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${t.minimum.toString()}${c} ${o}${s}`:`${t.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${t.minimum.toString()} ${o}${s}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:o.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${o.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${r[o.format]??t.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${t.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${P(t.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${t.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${t.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function qy(){return{localeError:Fw()}}var Ti=n=>n.charAt(0).toUpperCase()+n.slice(1);function Vy(n){let e=Math.abs(n),r=e%10,i=e%100;return i>=11&&i<=19||r===0?"many":r===1?"one":"few"}var Uw=()=>{let n={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function e(t,o,s,a){let c=n[t]??null;return c===null?c:{unit:c.unit[o],verb:c.verb[a][s?"inclusive":"notInclusive"]}}let r={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",jwt:"JWT",template_literal:"\u012Fvestis"},i={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Gautas tipas ${a}, o tik\u0117tasi - instanceof ${t.expected}`:`Gautas tipas ${a}, o tik\u0117tasi - ${o}`}case"invalid_value":return t.values.length===1?`Privalo b\u016Bti ${A(t.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${P(t.values,"|")} pasirinkim\u0173`;case"too_big":{let o=i[t.origin]??t.origin,s=e(t.origin,Vy(Number(t.maximum)),t.inclusive??!1,"smaller");if(s?.verb)return`${Ti(o??t.origin??"reik\u0161m\u0117")} ${s.verb} ${t.maximum.toString()} ${s.unit??"element\u0173"}`;let a=t.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${Ti(o??t.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${t.maximum.toString()} ${s?.unit}`}case"too_small":{let o=i[t.origin]??t.origin,s=e(t.origin,Vy(Number(t.minimum)),t.inclusive??!1,"bigger");if(s?.verb)return`${Ti(o??t.origin??"reik\u0161m\u0117")} ${s.verb} ${t.minimum.toString()} ${s.unit??"element\u0173"}`;let a=t.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${Ti(o??t.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${t.minimum.toString()} ${s?.unit}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${o.prefix}"`:o.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${o.suffix}"`:o.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${o.includes}"`:o.format==="regex"?`Eilut\u0117 privalo atitikti ${o.pattern}`:`Neteisingas ${r[o.format]??t.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${t.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${t.keys.length>1?"i":"as"} rakt${t.keys.length>1?"ai":"as"}: ${P(t.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let o=i[t.origin]??t.origin;return`${Ti(o??t.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function Ky(){return{localeError:Uw()}}var Zw=()=>{let n={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function e(t){return n[t]??null}let r={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},i={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${t.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${o}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`}case"invalid_value":return t.values.length===1?`Invalid input: expected ${A(t.values[0])}`:`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${t.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${o}${t.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${t.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${t.origin} \u0434\u0430 \u0438\u043C\u0430 ${o}${t.minimum.toString()} ${s.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${t.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${o.pattern}`:`Invalid ${r[o.format]??t.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${t.divisor}`;case"unrecognized_keys":return`${t.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${P(t.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${t.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${t.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function Yy(){return{localeError:Zw()}}var Hw=()=>{let n={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function e(t){return n[t]??null}let r={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"nombor"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Input tidak sah: dijangka instanceof ${t.expected}, diterima ${a}`:`Input tidak sah: dijangka ${o}, diterima ${a}`}case"invalid_value":return t.values.length===1?`Input tidak sah: dijangka ${A(t.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Terlalu besar: dijangka ${t.origin??"nilai"} ${s.verb} ${o}${t.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: dijangka ${t.origin??"nilai"} adalah ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Terlalu kecil: dijangka ${t.origin} ${s.verb} ${o}${t.minimum.toString()} ${s.unit}`:`Terlalu kecil: dijangka ${t.origin} adalah ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`String tidak sah: mesti bermula dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak sah: mesti mengandungi "${o.includes}"`:o.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${o.pattern}`:`${r[o.format]??t.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${t.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${P(t.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${t.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${t.origin}`;default:return"Input tidak sah"}}};function Xy(){return{localeError:Hw()}}var Ww=()=>{let n={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function e(t){return n[t]??null}let r={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"},i={nan:"NaN",number:"getal"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Ongeldige invoer: verwacht instanceof ${t.expected}, ontving ${a}`:`Ongeldige invoer: verwacht ${o}, ontving ${a}`}case"invalid_value":return t.values.length===1?`Ongeldige invoer: verwacht ${A(t.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin),a=t.origin==="date"?"laat":t.origin==="string"?"lang":"groot";return s?`Te ${a}: verwacht dat ${t.origin??"waarde"} ${o}${t.maximum.toString()} ${s.unit??"elementen"} ${s.verb}`:`Te ${a}: verwacht dat ${t.origin??"waarde"} ${o}${t.maximum.toString()} is`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin),a=t.origin==="date"?"vroeg":t.origin==="string"?"kort":"klein";return s?`Te ${a}: verwacht dat ${t.origin} ${o}${t.minimum.toString()} ${s.unit} ${s.verb}`:`Te ${a}: verwacht dat ${t.origin} ${o}${t.minimum.toString()} is`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Ongeldige tekst: moet met "${o.prefix}" beginnen`:o.format==="ends_with"?`Ongeldige tekst: moet op "${o.suffix}" eindigen`:o.format==="includes"?`Ongeldige tekst: moet "${o.includes}" bevatten`:o.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${o.pattern}`:`Ongeldig: ${r[o.format]??t.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${t.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${t.keys.length>1?"s":""}: ${P(t.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${t.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${t.origin}`;default:return"Ongeldige invoer"}}};function Qy(){return{localeError:Ww()}}var Bw=()=>{let n={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function e(t){return n[t]??null}let r={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"tall",array:"liste"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Ugyldig input: forventet instanceof ${t.expected}, fikk ${a}`:`Ugyldig input: forventet ${o}, fikk ${a}`}case"invalid_value":return t.values.length===1?`Ugyldig verdi: forventet ${A(t.values[0])}`:`Ugyldig valg: forventet en av ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`For stor(t): forventet ${t.origin??"value"} til \xE5 ha ${o}${t.maximum.toString()} ${s.unit??"elementer"}`:`For stor(t): forventet ${t.origin??"value"} til \xE5 ha ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`For lite(n): forventet ${t.origin} til \xE5 ha ${o}${t.minimum.toString()} ${s.unit}`:`For lite(n): forventet ${t.origin} til \xE5 ha ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${r[o.format]??t.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${t.divisor}`;case"unrecognized_keys":return`${t.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${P(t.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${t.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${t.origin}`;default:return"Ugyldig input"}}};function eb(){return{localeError:Bw()}}var Gw=()=>{let n={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function e(t){return n[t]??null}let r={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"},i={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`F\xE2sit giren: umulan instanceof ${t.expected}, al\u0131nan ${a}`:`F\xE2sit giren: umulan ${o}, al\u0131nan ${a}`}case"invalid_value":return t.values.length===1?`F\xE2sit giren: umulan ${A(t.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Fazla b\xFCy\xFCk: ${t.origin??"value"}, ${o}${t.maximum.toString()} ${s.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${t.origin??"value"}, ${o}${t.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Fazla k\xFC\xE7\xFCk: ${t.origin}, ${o}${t.minimum.toString()} ${s.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${t.origin}, ${o}${t.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let o=t;return o.format==="starts_with"?`F\xE2sit metin: "${o.prefix}" ile ba\u015Flamal\u0131.`:o.format==="ends_with"?`F\xE2sit metin: "${o.suffix}" ile bitmeli.`:o.format==="includes"?`F\xE2sit metin: "${o.includes}" ihtiv\xE2 etmeli.`:o.format==="regex"?`F\xE2sit metin: ${o.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${r[o.format]??t.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${t.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${t.keys.length>1?"s":""}: ${P(t.keys,", ")}`;case"invalid_key":return`${t.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${t.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function tb(){return{localeError:Gw()}}var Jw=()=>{let n={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function e(t){return n[t]??null}let r={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${t.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${o} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return t.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${A(t.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${P(t.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${t.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${t.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${t.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${t.maximum.toString()} \u0648\u064A`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${t.origin} \u0628\u0627\u06CC\u062F ${o}${t.minimum.toString()} ${s.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${t.origin} \u0628\u0627\u06CC\u062F ${o}${t.minimum.toString()} \u0648\u064A`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:o.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:o.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${o.includes}" \u0648\u0644\u0631\u064A`:o.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${o.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${r[o.format]??t.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${t.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${t.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${P(t.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${t.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${t.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function nb(){return{localeError:Jw()}}var qw=()=>{let n={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function e(t){return n[t]??null}let r={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"},i={nan:"NaN",number:"liczba",array:"tablica"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${t.expected}, otrzymano ${a}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${o}, otrzymano ${a}`}case"invalid_value":return t.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${A(t.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${t.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${t.maximum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${t.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${t.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${t.minimum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${t.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${o.prefix}"`:o.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${o.suffix}"`:o.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${o.includes}"`:o.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${o.pattern}`:`Nieprawid\u0142ow(y/a/e) ${r[o.format]??t.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${t.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${t.keys.length>1?"s":""}: ${P(t.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${t.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${t.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function rb(){return{localeError:qw()}}var Vw=()=>{let n={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function e(t){return n[t]??null}let r={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",number:"n\xFAmero",null:"nulo"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Tipo inv\xE1lido: esperado instanceof ${t.expected}, recebido ${a}`:`Tipo inv\xE1lido: esperado ${o}, recebido ${a}`}case"invalid_value":return t.values.length===1?`Entrada inv\xE1lida: esperado ${A(t.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperada uma das ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Muito grande: esperado que ${t.origin??"valor"} tivesse ${o}${t.maximum.toString()} ${s.unit??"elementos"}`:`Muito grande: esperado que ${t.origin??"valor"} fosse ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Muito pequeno: esperado que ${t.origin} tivesse ${o}${t.minimum.toString()} ${s.unit}`:`Muito pequeno: esperado que ${t.origin} fosse ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${o.prefix}"`:o.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${o.suffix}"`:o.format==="includes"?`Texto inv\xE1lido: deve incluir "${o.includes}"`:o.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${o.pattern}`:`${r[o.format]??t.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${t.divisor}`;case"unrecognized_keys":return`Chave${t.keys.length>1?"s":""} desconhecida${t.keys.length>1?"s":""}: ${P(t.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${t.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${t.origin}`;default:return"Campo inv\xE1lido"}}};function ib(){return{localeError:Vw()}}function ob(n,e,r,i){let t=Math.abs(n),o=t%10,s=t%100;return s>=11&&s<=19?i:o===1?e:o>=2&&o<=4?r:i}var Kw=()=>{let n={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function e(t){return n[t]??null}let r={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${t.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`}case"invalid_value":return t.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${A(t.values[0])}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);if(s){let a=Number(t.maximum),c=ob(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${t.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${t.maximum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${t.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);if(s){let a=Number(t.minimum),c=ob(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${t.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${t.minimum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${t.origin} \u0431\u0443\u0434\u0435\u0442 ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${r[o.format]??t.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${t.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${t.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${t.keys.length>1?"\u0438":""}: ${P(t.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${t.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${t.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};function sb(){return{localeError:Kw()}}var Yw=()=>{let n={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function e(t){return n[t]??null}let r={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"},i={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${t.expected}, prejeto ${a}`:`Neveljaven vnos: pri\u010Dakovano ${o}, prejeto ${a}`}case"invalid_value":return t.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${A(t.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Preveliko: pri\u010Dakovano, da bo ${t.origin??"vrednost"} imelo ${o}${t.maximum.toString()} ${s.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${t.origin??"vrednost"} ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Premajhno: pri\u010Dakovano, da bo ${t.origin} imelo ${o}${t.minimum.toString()} ${s.unit}`:`Premajhno: pri\u010Dakovano, da bo ${t.origin} ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${o.prefix}"`:o.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${o.suffix}"`:o.format==="includes"?`Neveljaven niz: mora vsebovati "${o.includes}"`:o.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${o.pattern}`:`Neveljaven ${r[o.format]??t.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${t.divisor}`;case"unrecognized_keys":return`Neprepoznan${t.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${P(t.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${t.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${t.origin}`;default:return"Neveljaven vnos"}}};function ab(){return{localeError:Yw()}}var Xw=()=>{let n={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function e(t){return n[t]??null}let r={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"},i={nan:"NaN",number:"antal",array:"lista"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${t.expected}, fick ${a}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${o}, fick ${a}`}case"invalid_value":return t.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${A(t.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`F\xF6r stor(t): f\xF6rv\xE4ntade ${t.origin??"v\xE4rdet"} att ha ${o}${t.maximum.toString()} ${s.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${t.origin??"v\xE4rdet"} att ha ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`F\xF6r lite(t): f\xF6rv\xE4ntade ${t.origin??"v\xE4rdet"} att ha ${o}${t.minimum.toString()} ${s.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${t.origin??"v\xE4rdet"} att ha ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${o.prefix}"`:o.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${o.suffix}"`:o.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${o.includes}"`:o.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${o.pattern}"`:`Ogiltig(t) ${r[o.format]??t.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${t.divisor}`;case"unrecognized_keys":return`${t.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${P(t.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${t.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${t.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function cb(){return{localeError:Xw()}}var Qw=()=>{let n={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function e(t){return n[t]??null}let r={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${t.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${o}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`}case"invalid_value":return t.values.length===1?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${A(t.values[0])}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${P(t.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${t.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${t.maximum.toString()} ${s.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${t.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${t.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${t.origin} ${o}${t.minimum.toString()} ${s.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${t.origin} ${o}${t.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${o.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${r[o.format]??t.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${t.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${t.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${P(t.keys,", ")}`;case"invalid_key":return`${t.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${t.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};function lb(){return{localeError:Qw()}}var ek=()=>{let n={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function e(t){return n[t]??null}let r={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},i={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${t.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`:`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${o} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`}case"invalid_value":return t.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${A(t.values[0])}`:`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",s=e(t.origin);return s?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${t.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${t.maximum.toString()} ${s.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${t.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",s=e(t.origin);return s?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${t.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${t.minimum.toString()} ${s.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${t.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${o.prefix}"`:o.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${o.suffix}"`:o.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${o.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:o.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${o.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${r[o.format]??t.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${t.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${P(t.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${t.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${t.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function ub(){return{localeError:ek()}}var tk=()=>{let n={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function e(t){return n[t]??null}let r={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${t.expected}, al\u0131nan ${a}`:`Ge\xE7ersiz de\u011Fer: beklenen ${o}, al\u0131nan ${a}`}case"invalid_value":return t.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${A(t.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\xC7ok b\xFCy\xFCk: beklenen ${t.origin??"de\u011Fer"} ${o}${t.maximum.toString()} ${s.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${t.origin??"de\u011Fer"} ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\xC7ok k\xFC\xE7\xFCk: beklenen ${t.origin} ${o}${t.minimum.toString()} ${s.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${t.origin} ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Ge\xE7ersiz metin: "${o.prefix}" ile ba\u015Flamal\u0131`:o.format==="ends_with"?`Ge\xE7ersiz metin: "${o.suffix}" ile bitmeli`:o.format==="includes"?`Ge\xE7ersiz metin: "${o.includes}" i\xE7ermeli`:o.format==="regex"?`Ge\xE7ersiz metin: ${o.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${r[o.format]??t.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${t.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${t.keys.length>1?"lar":""}: ${P(t.keys,", ")}`;case"invalid_key":return`${t.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${t.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function db(){return{localeError:tk()}}var nk=()=>{let n={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function e(t){return n[t]??null}let r={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${t.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${o}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`}case"invalid_value":return t.values.length===1?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${A(t.values[0])}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${t.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${s.verb} ${o}${t.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${t.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${t.origin} ${s.verb} ${o}${t.minimum.toString()} ${s.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${t.origin} \u0431\u0443\u0434\u0435 ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${r[o.format]??t.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${t.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${t.keys.length>1?"\u0456":""}: ${P(t.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${t.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${t.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};function Ts(){return{localeError:nk()}}function pb(){return Ts()}var rk=()=>{let n={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function e(t){return n[t]??null}let r={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},i={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${t.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${o} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return t.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${A(t.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${P(t.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${t.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${o}${t.maximum.toString()} ${s.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${t.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${o}${t.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${t.origin} \u06A9\u06D2 ${o}${t.minimum.toString()} ${s.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${t.origin} \u06A9\u0627 ${o}${t.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${o.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${r[o.format]??t.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${t.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${t.keys.length>1?"\u0632":""}: ${P(t.keys,"\u060C ")}`;case"invalid_key":return`${t.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${t.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function mb(){return{localeError:rk()}}var ik=()=>{let n={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"}};function e(t){return n[t]??null}let r={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",jwt:"JWT",template_literal:"kirish"},i={nan:"NaN",number:"raqam",array:"massiv"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${t.expected}, qabul qilingan ${a}`:`Noto\u2018g\u2018ri kirish: kutilgan ${o}, qabul qilingan ${a}`}case"invalid_value":return t.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${A(t.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Juda katta: kutilgan ${t.origin??"qiymat"} ${o}${t.maximum.toString()} ${s.unit} ${s.verb}`:`Juda katta: kutilgan ${t.origin??"qiymat"} ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Juda kichik: kutilgan ${t.origin} ${o}${t.minimum.toString()} ${s.unit} ${s.verb}`:`Juda kichik: kutilgan ${t.origin} ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${o.prefix}" bilan boshlanishi kerak`:o.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${o.suffix}" bilan tugashi kerak`:o.format==="includes"?`Noto\u2018g\u2018ri satr: "${o.includes}" ni o\u2018z ichiga olishi kerak`:o.format==="regex"?`Noto\u2018g\u2018ri satr: ${o.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${r[o.format]??t.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${t.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${t.keys.length>1?"lar":""}: ${P(t.keys,", ")}`;case"invalid_key":return`${t.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${t.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};function fb(){return{localeError:ik()}}var ok=()=>{let n={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function e(t){return n[t]??null}let r={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},i={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${t.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${o}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`}case"invalid_value":return t.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${A(t.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${t.origin??"gi\xE1 tr\u1ECB"} ${s.verb} ${o}${t.maximum.toString()} ${s.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${t.origin??"gi\xE1 tr\u1ECB"} ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${t.origin} ${s.verb} ${o}${t.minimum.toString()} ${s.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${t.origin} ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${o.prefix}"`:o.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${o.suffix}"`:o.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${o.includes}"`:o.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${o.pattern}`:`${r[o.format]??t.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${t.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${P(t.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${t.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${t.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function hb(){return{localeError:ok()}}var sk=()=>{let n={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function e(t){return n[t]??null}let r={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"},i={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${t.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${o}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`}case"invalid_value":return t.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${A(t.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${t.origin??"\u503C"} ${o}${t.maximum.toString()} ${s.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${t.origin??"\u503C"} ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${t.origin} ${o}${t.minimum.toString()} ${s.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${t.origin} ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.prefix}" \u5F00\u5934`:o.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.suffix}" \u7ED3\u5C3E`:o.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${o.pattern}`:`\u65E0\u6548${r[o.format]??t.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${t.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${P(t.keys,", ")}`;case"invalid_key":return`${t.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${t.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function gb(){return{localeError:sk()}}var ak=()=>{let n={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function e(t){return n[t]??null}let r={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${t.expected}\uFF0C\u4F46\u6536\u5230 ${a}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${o}\uFF0C\u4F46\u6536\u5230 ${a}`}case"invalid_value":return t.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${A(t.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${t.origin??"\u503C"} \u61C9\u70BA ${o}${t.maximum.toString()} ${s.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${t.origin??"\u503C"} \u61C9\u70BA ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${t.origin} \u61C9\u70BA ${o}${t.minimum.toString()} ${s.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${t.origin} \u61C9\u70BA ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.prefix}" \u958B\u982D`:o.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.suffix}" \u7D50\u5C3E`:o.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${o.pattern}`:`\u7121\u6548\u7684 ${r[o.format]??t.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${t.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${t.keys.length>1?"\u5011":""}\uFF1A${P(t.keys,"\u3001")}`;case"invalid_key":return`${t.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${t.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function yb(){return{localeError:ak()}}var ck=()=>{let n={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"}};function e(t){return n[t]??null}let r={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},i={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=O(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${t.expected}, \xE0m\u1ECD\u0300 a r\xED ${a}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${o}, \xE0m\u1ECD\u0300 a r\xED ${a}`}case"invalid_value":return t.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${A(t.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${P(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${t.origin??"iye"} ${s.verb} ${o}${t.maximum} ${s.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${t.maximum}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${t.origin} ${s.verb} ${o}${t.minimum} ${s.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${t.minimum}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${o.prefix}"`:o.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${o.suffix}"`:o.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${o.includes}"`:o.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${o.pattern}`:`A\u1E63\xEC\u1E63e: ${r[o.format]??t.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${t.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${P(t.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${t.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${t.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};function bb(){return{localeError:ck()}}var vb,fd=Symbol("ZodOutput"),hd=Symbol("ZodInput"),Ps=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){let i=r[0];return this._map.set(e,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let i={...this.get(r)??{}};delete i.id;let t={...i,...this._map.get(e)};return Object.keys(t).length?t:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Rs(){return new Ps}(vb=globalThis).__zod_globalRegistry??(vb.__zod_globalRegistry=Rs());var De=globalThis.__zod_globalRegistry;function gd(n,e){return new n({type:"string",...j(e)})}function yd(n,e){return new n({type:"string",coerce:!0,...j(e)})}function zs(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...j(e)})}function Ri(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...j(e)})}function Ns(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...j(e)})}function Cs(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...j(e)})}function Ds(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...j(e)})}function Ls(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...j(e)})}function zi(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...j(e)})}function As(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...j(e)})}function Os(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...j(e)})}function Ms(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...j(e)})}function js(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...j(e)})}function Fs(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...j(e)})}function Us(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...j(e)})}function Zs(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...j(e)})}function Hs(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...j(e)})}function Ws(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...j(e)})}function bd(n,e){return new n({type:"string",format:"mac",check:"string_format",abort:!1,...j(e)})}function Bs(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...j(e)})}function Gs(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...j(e)})}function Js(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...j(e)})}function qs(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...j(e)})}function Vs(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...j(e)})}function Ks(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...j(e)})}var vd={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function _d(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...j(e)})}function xd(n,e){return new n({type:"string",format:"date",check:"string_format",...j(e)})}function Sd(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...j(e)})}function $d(n,e){return new n({type:"string",format:"duration",check:"string_format",...j(e)})}function wd(n,e){return new n({type:"number",checks:[],...j(e)})}function kd(n,e){return new n({type:"number",coerce:!0,checks:[],...j(e)})}function Ed(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...j(e)})}function Id(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"float32",...j(e)})}function Td(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"float64",...j(e)})}function Pd(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"int32",...j(e)})}function Rd(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"uint32",...j(e)})}function zd(n,e){return new n({type:"boolean",...j(e)})}function Nd(n,e){return new n({type:"boolean",coerce:!0,...j(e)})}function Cd(n,e){return new n({type:"bigint",...j(e)})}function Dd(n,e){return new n({type:"bigint",coerce:!0,...j(e)})}function Ld(n,e){return new n({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...j(e)})}function Ad(n,e){return new n({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...j(e)})}function Od(n,e){return new n({type:"symbol",...j(e)})}function Md(n,e){return new n({type:"undefined",...j(e)})}function jd(n,e){return new n({type:"null",...j(e)})}function Fd(n){return new n({type:"any"})}function Ud(n){return new n({type:"unknown"})}function Zd(n,e){return new n({type:"never",...j(e)})}function Hd(n,e){return new n({type:"void",...j(e)})}function Wd(n,e){return new n({type:"date",...j(e)})}function Bd(n,e){return new n({type:"date",coerce:!0,...j(e)})}function Gd(n,e){return new n({type:"nan",...j(e)})}function wt(n,e){return new hs({check:"less_than",...j(e),value:n,inclusive:!1})}function Xe(n,e){return new hs({check:"less_than",...j(e),value:n,inclusive:!0})}function kt(n,e){return new gs({check:"greater_than",...j(e),value:n,inclusive:!1})}function Fe(n,e){return new gs({check:"greater_than",...j(e),value:n,inclusive:!0})}function Ys(n){return kt(0,n)}function Xs(n){return wt(0,n)}function Qs(n){return Xe(0,n)}function ea(n){return Fe(0,n)}function an(n,e){return new jl({check:"multiple_of",...j(e),value:n})}function cn(n,e){return new Zl({check:"max_size",...j(e),maximum:n})}function Et(n,e){return new Hl({check:"min_size",...j(e),minimum:n})}function Mn(n,e){return new Wl({check:"size_equals",...j(e),size:n})}function jn(n,e){return new Bl({check:"max_length",...j(e),maximum:n})}function Ot(n,e){return new Gl({check:"min_length",...j(e),minimum:n})}function Fn(n,e){return new Jl({check:"length_equals",...j(e),length:n})}function br(n,e){return new ql({check:"string_format",format:"regex",...j(e),pattern:n})}function vr(n){return new Vl({check:"string_format",format:"lowercase",...j(n)})}function _r(n){return new Kl({check:"string_format",format:"uppercase",...j(n)})}function xr(n,e){return new Yl({check:"string_format",format:"includes",...j(e),includes:n})}function Sr(n,e){return new Xl({check:"string_format",format:"starts_with",...j(e),prefix:n})}function $r(n,e){return new Ql({check:"string_format",format:"ends_with",...j(e),suffix:n})}function ta(n,e,r){return new eu({check:"property",property:n,schema:e,...j(r)})}function wr(n,e){return new tu({check:"mime_type",mime:n,...j(e)})}function vt(n){return new nu({check:"overwrite",tx:n})}function kr(n){return vt(e=>e.normalize(n))}function Er(){return vt(n=>n.trim())}function Ir(){return vt(n=>n.toLowerCase())}function Tr(){return vt(n=>n.toUpperCase())}function Pr(){return vt(n=>el(n))}function Jd(n,e,r){return new n({type:"array",element:e,...j(r)})}function uk(n,e,r){return new n({type:"union",options:e,...j(r)})}function dk(n,e,r){return new n({type:"union",options:e,inclusive:!1,...j(r)})}function pk(n,e,r,i){return new n({type:"union",options:r,discriminator:e,...j(i)})}function mk(n,e,r){return new n({type:"intersection",left:e,right:r})}function fk(n,e,r,i){let t=r instanceof Y,o=t?i:r,s=t?r:null;return new n({type:"tuple",items:e,rest:s,...j(o)})}function hk(n,e,r,i){return new n({type:"record",keyType:e,valueType:r,...j(i)})}function gk(n,e,r,i){return new n({type:"map",keyType:e,valueType:r,...j(i)})}function yk(n,e,r){return new n({type:"set",valueType:e,...j(r)})}function bk(n,e,r){let i=Array.isArray(e)?Object.fromEntries(e.map(t=>[t,t])):e;return new n({type:"enum",entries:i,...j(r)})}function vk(n,e,r){return new n({type:"enum",entries:e,...j(r)})}function _k(n,e,r){return new n({type:"literal",values:Array.isArray(e)?e:[e],...j(r)})}function qd(n,e){return new n({type:"file",...j(e)})}function xk(n,e){return new n({type:"transform",transform:e})}function Sk(n,e){return new n({type:"optional",innerType:e})}function $k(n,e){return new n({type:"nullable",innerType:e})}function wk(n,e,r){return new n({type:"default",innerType:e,get defaultValue(){return typeof r=="function"?r():nl(r)}})}function kk(n,e,r){return new n({type:"nonoptional",innerType:e,...j(r)})}function Ek(n,e){return new n({type:"success",innerType:e})}function Ik(n,e,r){return new n({type:"catch",innerType:e,catchValue:typeof r=="function"?r:()=>r})}function Tk(n,e,r){return new n({type:"pipe",in:e,out:r})}function Pk(n,e){return new n({type:"readonly",innerType:e})}function Rk(n,e,r){return new n({type:"template_literal",parts:e,...j(r)})}function zk(n,e){return new n({type:"lazy",getter:e})}function Nk(n,e){return new n({type:"promise",innerType:e})}function Vd(n,e,r){let i=j(r);return i.abort??(i.abort=!0),new n({type:"custom",check:"custom",fn:e,...i})}function Kd(n,e,r){return new n({type:"custom",check:"custom",fn:e,...j(r)})}function Yd(n){let e=_b(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(dr(i,r.value,e._zod.def));else{let t=i;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=r.value),t.inst??(t.inst=e),t.continue??(t.continue=!e._zod.def.abort),r.issues.push(dr(t))}},n(r.value,r)));return e}function _b(n,e){let r=new me({check:"custom",...j(e)});return r._zod.check=n,r}function Xd(n){let e=new me({check:"describe"});return e._zod.onattach=[r=>{let i=De.get(r)??{};De.add(r,{...i,description:n})}],e._zod.check=()=>{},e}function Qd(n){let e=new me({check:"meta"});return e._zod.onattach=[r=>{let i=De.get(r)??{};De.add(r,{...i,...n})}],e._zod.check=()=>{},e}function ep(n,e){let r=j(e),i=r.truthy??["true","1","yes","on","y","enabled"],t=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(i=i.map(f=>typeof f=="string"?f.toLowerCase():f),t=t.map(f=>typeof f=="string"?f.toLowerCase():f));let o=new Set(i),s=new Set(t),a=n.Codec??Ii,c=n.Boolean??ki,l=n.String??On,u=new l({type:"string",error:r.error}),d=new c({type:"boolean",error:r.error}),p=new a({type:"pipe",in:u,out:d,transform:((f,m)=>{let h=f;return r.case!=="sensitive"&&(h=h.toLowerCase()),o.has(h)?!0:s.has(h)?!1:(m.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...s],input:m.value,inst:p,continue:!1}),{})}),reverseTransform:((f,m)=>f===!0?i[0]||"true":t[0]||"false"),error:r.error});return p}function Rr(n,e,r,i={}){let t=j(i),o={...j(i),check:"string_format",type:"string",format:e,fn:typeof r=="function"?r:a=>r.test(a),...t};return r instanceof RegExp&&(o.pattern=r),new n(o)}function ln(n){let e=n?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:n?.metadata??De,target:e,unrepresentable:n?.unrepresentable??"throw",override:n?.override??(()=>{}),io:n?.io??"output",counter:0,seen:new Map,cycles:n?.cycles??"ref",reused:n?.reused??"inline",external:n?.external??void 0}}function oe(n,e,r={path:[],schemaPath:[]}){var i;let t=n._zod.def,o=e.seen.get(n);if(o)return o.count++,r.schemaPath.includes(n)&&(o.cycle=r.path),o.schema;let s={schema:{},count:1,cycle:void 0,path:r.path};e.seen.set(n,s);let a=n._zod.toJSONSchema?.();if(a)s.schema=a;else{let u={...r,schemaPath:[...r.schemaPath,n],path:r.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,s.schema,u);else{let p=s.schema,f=e.processors[t.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${t.type}`);f(n,e,p,u)}let d=n._zod.parent;d&&(s.ref||(s.ref=d),oe(d,e,u),e.seen.get(d).isParent=!0)}let c=e.metadataRegistry.get(n);return c&&Object.assign(s.schema,c),e.io==="input"&&Ue(n)&&(delete s.schema.examples,delete s.schema.default),e.io==="input"&&s.schema._prefault&&((i=s.schema).default??(i.default=s.schema._prefault)),delete s.schema._prefault,e.seen.get(n).schema}function un(n,e){let r=n.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=new Map;for(let s of n.seen.entries()){let a=n.metadataRegistry.get(s[0])?.id;if(a){let c=i.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,s[0])}}let t=s=>{let a=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let d=n.external.registry.get(s[0])?.id,p=n.external.uri??(m=>m);if(d)return{ref:p(d)};let f=s[1].defId??s[1].schema.id??`schema${n.counter++}`;return s[1].defId=f,{defId:f,ref:`${p("__shared")}#/${a}/${f}`}}if(s[1]===r)return{ref:"#"};let l=`#/${a}/`,u=s[1].schema.id??`__schema${n.counter++}`;return{defId:u,ref:l+u}},o=s=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:l}=t(s);a.def={...a.schema},l&&(a.defId=l);let u=a.schema;for(let d in u)delete u[d];u.$ref=c};if(n.cycles==="throw")for(let s of n.seen.entries()){let a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
774
|
-
|
|
775
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of n.seen.entries()){let a=s[1];if(e===s[0]){o(s);continue}if(n.external){let l=n.external.registry.get(s[0])?.id;if(e!==s[0]&&l){o(s);continue}}if(n.metadataRegistry.get(s[0])?.id){o(s);continue}if(a.cycle){o(s);continue}if(a.count>1&&n.reused==="ref"){o(s);continue}}}function dn(n,e){let r=n.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let a=n.seen.get(s);if(a.ref===null)return;let c=a.def??a.schema,l={...c},u=a.ref;if(a.ref=null,u){i(u);let p=n.seen.get(u),f=p.schema;if(f.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(f)):Object.assign(c,f),Object.assign(c,l),s._zod.parent===u)for(let h in c)h==="$ref"||h==="allOf"||h in l||delete c[h];if(f.$ref&&p.def)for(let h in c)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(c[h])===JSON.stringify(p.def[h])&&delete c[h]}let d=s._zod.parent;if(d&&d!==u){i(d);let p=n.seen.get(d);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(let f in c)f==="$ref"||f==="allOf"||f in p.def&&JSON.stringify(c[f])===JSON.stringify(p.def[f])&&delete c[f]}n.override({zodSchema:s,jsonSchema:c,path:a.path??[]})};for(let s of[...n.seen.entries()].reverse())i(s[0]);let t={};if(n.target==="draft-2020-12"?t.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?t.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?t.$schema="http://json-schema.org/draft-04/schema#":n.target,n.external?.uri){let s=n.external.registry.get(e)?.id;if(!s)throw new Error("Schema is missing an `id` property");t.$id=n.external.uri(s)}Object.assign(t,r.def??r.schema);let o=n.external?.defs??{};for(let s of n.seen.entries()){let a=s[1];a.def&&a.defId&&(o[a.defId]=a.def)}n.external||Object.keys(o).length>0&&(n.target==="draft-2020-12"?t.$defs=o:t.definitions=o);try{let s=JSON.parse(JSON.stringify(t));return Object.defineProperty(s,"~standard",{value:{...e["~standard"],jsonSchema:{input:zr(e,"input",n.processors),output:zr(e,"output",n.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Ue(n,e){let r=e??{seen:new Set};if(r.seen.has(n))return!1;r.seen.add(n);let i=n._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Ue(i.element,r);if(i.type==="set")return Ue(i.valueType,r);if(i.type==="lazy")return Ue(i.getter(),r);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return Ue(i.innerType,r);if(i.type==="intersection")return Ue(i.left,r)||Ue(i.right,r);if(i.type==="record"||i.type==="map")return Ue(i.keyType,r)||Ue(i.valueType,r);if(i.type==="pipe")return Ue(i.in,r)||Ue(i.out,r);if(i.type==="object"){for(let t in i.shape)if(Ue(i.shape[t],r))return!0;return!1}if(i.type==="union"){for(let t of i.options)if(Ue(t,r))return!0;return!1}if(i.type==="tuple"){for(let t of i.items)if(Ue(t,r))return!0;return!!(i.rest&&Ue(i.rest,r))}return!1}var tp=(n,e={})=>r=>{let i=ln({...r,processors:e});return oe(n,i),un(i,n),dn(i,n)},zr=(n,e,r={})=>i=>{let{libraryOptions:t,target:o}=i??{},s=ln({...t??{},target:o,io:e,processors:r});return oe(n,s),un(s,n),dn(s,n)};var Ck={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},np=(n,e,r,i)=>{let t=r;t.type="string";let{minimum:o,maximum:s,format:a,patterns:c,contentEncoding:l}=n._zod.bag;if(typeof o=="number"&&(t.minLength=o),typeof s=="number"&&(t.maxLength=s),a&&(t.format=Ck[a]??a,t.format===""&&delete t.format,a==="time"&&delete t.format),l&&(t.contentEncoding=l),c&&c.size>0){let u=[...c];u.length===1?t.pattern=u[0].source:u.length>1&&(t.allOf=[...u.map(d=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},rp=(n,e,r,i)=>{let t=r,{minimum:o,maximum:s,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=n._zod.bag;typeof a=="string"&&a.includes("int")?t.type="integer":t.type="number",typeof u=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(t.minimum=u,t.exclusiveMinimum=!0):t.exclusiveMinimum=u),typeof o=="number"&&(t.minimum=o,typeof u=="number"&&e.target!=="draft-04"&&(u>=o?delete t.minimum:delete t.exclusiveMinimum)),typeof l=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(t.maximum=l,t.exclusiveMaximum=!0):t.exclusiveMaximum=l),typeof s=="number"&&(t.maximum=s,typeof l=="number"&&e.target!=="draft-04"&&(l<=s?delete t.maximum:delete t.exclusiveMaximum)),typeof c=="number"&&(t.multipleOf=c)},ip=(n,e,r,i)=>{r.type="boolean"},op=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},sp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},ap=(n,e,r,i)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},cp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},lp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},up=(n,e,r,i)=>{r.not={}},dp=(n,e,r,i)=>{},pp=(n,e,r,i)=>{},mp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},fp=(n,e,r,i)=>{let t=n._zod.def,o=fi(t.entries);o.every(s=>typeof s=="number")&&(r.type="number"),o.every(s=>typeof s=="string")&&(r.type="string"),r.enum=o},hp=(n,e,r,i)=>{let t=n._zod.def,o=[];for(let s of t.values)if(s===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(s))}else o.push(s);if(o.length!==0)if(o.length===1){let s=o[0];r.type=s===null?"null":typeof s,e.target==="draft-04"||e.target==="openapi-3.0"?r.enum=[s]:r.const=s}else o.every(s=>typeof s=="number")&&(r.type="number"),o.every(s=>typeof s=="string")&&(r.type="string"),o.every(s=>typeof s=="boolean")&&(r.type="boolean"),o.every(s=>s===null)&&(r.type="null"),r.enum=o},gp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},yp=(n,e,r,i)=>{let t=r,o=n._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");t.type="string",t.pattern=o.source},bp=(n,e,r,i)=>{let t=r,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:c}=n._zod.bag;s!==void 0&&(o.minLength=s),a!==void 0&&(o.maxLength=a),c?c.length===1?(o.contentMediaType=c[0],Object.assign(t,o)):(Object.assign(t,o),t.anyOf=c.map(l=>({contentMediaType:l}))):Object.assign(t,o)},vp=(n,e,r,i)=>{r.type="boolean"},_p=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},xp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Sp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},$p=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},wp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},kp=(n,e,r,i)=>{let t=r,o=n._zod.def,{minimum:s,maximum:a}=n._zod.bag;typeof s=="number"&&(t.minItems=s),typeof a=="number"&&(t.maxItems=a),t.type="array",t.items=oe(o.element,e,{...i,path:[...i.path,"items"]})},Ep=(n,e,r,i)=>{let t=r,o=n._zod.def;t.type="object",t.properties={};let s=o.shape;for(let l in s)t.properties[l]=oe(s[l],e,{...i,path:[...i.path,"properties",l]});let a=new Set(Object.keys(s)),c=new Set([...a].filter(l=>{let u=o.shape[l]._zod;return e.io==="input"?u.optin===void 0:u.optout===void 0}));c.size>0&&(t.required=Array.from(c)),o.catchall?._zod.def.type==="never"?t.additionalProperties=!1:o.catchall?o.catchall&&(t.additionalProperties=oe(o.catchall,e,{...i,path:[...i.path,"additionalProperties"]})):e.io==="output"&&(t.additionalProperties=!1)},ra=(n,e,r,i)=>{let t=n._zod.def,o=t.inclusive===!1,s=t.options.map((a,c)=>oe(a,e,{...i,path:[...i.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=s:r.anyOf=s},Ip=(n,e,r,i)=>{let t=n._zod.def,o=oe(t.left,e,{...i,path:[...i.path,"allOf",0]}),s=oe(t.right,e,{...i,path:[...i.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];r.allOf=c},Tp=(n,e,r,i)=>{let t=r,o=n._zod.def;t.type="array";let s=e.target==="draft-2020-12"?"prefixItems":"items",a=e.target==="draft-2020-12"||e.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((p,f)=>oe(p,e,{...i,path:[...i.path,s,f]})),l=o.rest?oe(o.rest,e,{...i,path:[...i.path,a,...e.target==="openapi-3.0"?[o.items.length]:[]]}):null;e.target==="draft-2020-12"?(t.prefixItems=c,l&&(t.items=l)):e.target==="openapi-3.0"?(t.items={anyOf:c},l&&t.items.anyOf.push(l),t.minItems=c.length,l||(t.maxItems=c.length)):(t.items=c,l&&(t.additionalItems=l));let{minimum:u,maximum:d}=n._zod.bag;typeof u=="number"&&(t.minItems=u),typeof d=="number"&&(t.maxItems=d)},Pp=(n,e,r,i)=>{let t=r,o=n._zod.def;t.type="object";let s=o.keyType,c=s._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){let u=oe(o.valueType,e,{...i,path:[...i.path,"patternProperties","*"]});t.patternProperties={};for(let d of c)t.patternProperties[d.source]=u}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(t.propertyNames=oe(o.keyType,e,{...i,path:[...i.path,"propertyNames"]})),t.additionalProperties=oe(o.valueType,e,{...i,path:[...i.path,"additionalProperties"]});let l=s._zod.values;if(l){let u=[...l].filter(d=>typeof d=="string"||typeof d=="number");u.length>0&&(t.required=u)}},Rp=(n,e,r,i)=>{let t=n._zod.def,o=oe(t.innerType,e,i),s=e.seen.get(n);e.target==="openapi-3.0"?(s.ref=t.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},zp=(n,e,r,i)=>{let t=n._zod.def;oe(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType},Np=(n,e,r,i)=>{let t=n._zod.def;oe(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType,r.default=JSON.parse(JSON.stringify(t.defaultValue))},Cp=(n,e,r,i)=>{let t=n._zod.def;oe(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType,e.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(t.defaultValue)))},Dp=(n,e,r,i)=>{let t=n._zod.def;oe(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType;let s;try{s=t.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},Lp=(n,e,r,i)=>{let t=n._zod.def,o=e.io==="input"?t.in._zod.def.type==="transform"?t.out:t.in:t.out;oe(o,e,i);let s=e.seen.get(n);s.ref=o},Ap=(n,e,r,i)=>{let t=n._zod.def;oe(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType,r.readOnly=!0},Op=(n,e,r,i)=>{let t=n._zod.def;oe(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType},ia=(n,e,r,i)=>{let t=n._zod.def;oe(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType},Mp=(n,e,r,i)=>{let t=n._zod.innerType;oe(t,e,i);let o=e.seen.get(n);o.ref=t},na={string:np,number:rp,boolean:ip,bigint:op,symbol:sp,null:ap,undefined:cp,void:lp,never:up,any:dp,unknown:pp,date:mp,enum:fp,literal:hp,nan:gp,template_literal:yp,file:bp,success:vp,custom:_p,function:xp,transform:Sp,map:$p,set:wp,array:kp,object:Ep,union:ra,intersection:Ip,tuple:Tp,record:Pp,nullable:Rp,nonoptional:zp,default:Np,prefault:Cp,catch:Dp,pipe:Lp,readonly:Ap,promise:Op,optional:ia,lazy:Mp};function oa(n,e){if("_idmap"in n){let i=n,t=ln({...e,processors:na}),o={};for(let c of i._idmap.entries()){let[l,u]=c;oe(u,t)}let s={},a={registry:i,uri:e?.uri,defs:o};t.external=a;for(let c of i._idmap.entries()){let[l,u]=c;un(t,u),s[l]=dn(t,u)}if(Object.keys(o).length>0){let c=t.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:o}}return{schemas:s}}let r=ln({...e,processors:na});return oe(n,r),un(r,n),dn(r,n)}var sa=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(e){this.ctx.counter=e}get seen(){return this.ctx.seen}constructor(e){let r=e?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=ln({processors:na,target:r,...e?.metadata&&{metadata:e.metadata},...e?.unrepresentable&&{unrepresentable:e.unrepresentable},...e?.override&&{override:e.override},...e?.io&&{io:e.io}})}process(e,r={path:[],schemaPath:[]}){return oe(e,this.ctx,r)}emit(e,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),un(this.ctx,e);let i=dn(this.ctx,e),{"~standard":t,...o}=i;return o}};var xb={};var Ni={};et(Ni,{ZodAny:()=>cm,ZodArray:()=>pm,ZodBase64:()=>Ia,ZodBase64URL:()=>Ta,ZodBigInt:()=>Mr,ZodBigIntFormat:()=>za,ZodBoolean:()=>Or,ZodCIDRv4:()=>ka,ZodCIDRv6:()=>Ea,ZodCUID:()=>ba,ZodCUID2:()=>va,ZodCatch:()=>Dm,ZodCodec:()=>ja,ZodCustom:()=>Hi,ZodCustomStringFormat:()=>Lr,ZodDate:()=>Mi,ZodDefault:()=>Tm,ZodDiscriminatedUnion:()=>fm,ZodE164:()=>Pa,ZodEmail:()=>ha,ZodEmoji:()=>ga,ZodEnum:()=>Cr,ZodExactOptional:()=>km,ZodFile:()=>$m,ZodFunction:()=>Hm,ZodGUID:()=>Ci,ZodIPv4:()=>$a,ZodIPv6:()=>wa,ZodIntersection:()=>hm,ZodJWT:()=>Ra,ZodKSUID:()=>Sa,ZodLazy:()=>Fm,ZodLiteral:()=>Sm,ZodMAC:()=>tm,ZodMap:()=>_m,ZodNaN:()=>Am,ZodNanoID:()=>ya,ZodNever:()=>um,ZodNonOptional:()=>Oa,ZodNull:()=>sm,ZodNullable:()=>Im,ZodNumber:()=>Ar,ZodNumberFormat:()=>Zn,ZodObject:()=>Fi,ZodOptional:()=>Aa,ZodPipe:()=>Ma,ZodPrefault:()=>Rm,ZodPromise:()=>Zm,ZodReadonly:()=>Om,ZodRecord:()=>Zi,ZodSet:()=>xm,ZodString:()=>Dr,ZodStringFormat:()=>ce,ZodSuccess:()=>Cm,ZodSymbol:()=>im,ZodTemplateLiteral:()=>jm,ZodTransform:()=>wm,ZodTuple:()=>ym,ZodType:()=>te,ZodULID:()=>_a,ZodURL:()=>Oi,ZodUUID:()=>It,ZodUndefined:()=>om,ZodUnion:()=>Ui,ZodUnknown:()=>lm,ZodVoid:()=>dm,ZodXID:()=>xa,ZodXor:()=>mm,_ZodString:()=>fa,_default:()=>Pm,_function:()=>Tv,any:()=>sv,array:()=>ji,base64:()=>Hb,base64url:()=>Wb,bigint:()=>tv,boolean:()=>rm,catch:()=>Lm,check:()=>Pv,cidrv4:()=>Ub,cidrv6:()=>Zb,codec:()=>kv,cuid:()=>Cb,cuid2:()=>Db,custom:()=>Rv,date:()=>cv,describe:()=>zv,discriminatedUnion:()=>fv,e164:()=>Bb,email:()=>$b,emoji:()=>zb,enum:()=>Da,exactOptional:()=>Em,file:()=>xv,float32:()=>Yb,float64:()=>Xb,function:()=>Tv,guid:()=>wb,hash:()=>Kb,hex:()=>Vb,hostname:()=>qb,httpUrl:()=>Rb,instanceof:()=>Cv,int:()=>ma,int32:()=>Qb,int64:()=>nv,intersection:()=>gm,ipv4:()=>Mb,ipv6:()=>Fb,json:()=>Lv,jwt:()=>Gb,keyof:()=>lv,ksuid:()=>Ob,lazy:()=>Um,literal:()=>_v,looseObject:()=>pv,looseRecord:()=>gv,mac:()=>jb,map:()=>yv,meta:()=>Nv,nan:()=>wv,nanoid:()=>Nb,nativeEnum:()=>vv,never:()=>Na,nonoptional:()=>Nm,null:()=>am,nullable:()=>Li,nullish:()=>Sv,number:()=>nm,object:()=>uv,optional:()=>Di,partialRecord:()=>hv,pipe:()=>Ai,prefault:()=>zm,preprocess:()=>Av,promise:()=>Iv,readonly:()=>Mm,record:()=>vm,refine:()=>Wm,set:()=>bv,strictObject:()=>dv,string:()=>pa,stringFormat:()=>Jb,stringbool:()=>Dv,success:()=>$v,superRefine:()=>Bm,symbol:()=>iv,templateLiteral:()=>Ev,transform:()=>La,tuple:()=>bm,uint32:()=>ev,uint64:()=>rv,ulid:()=>Lb,undefined:()=>ov,union:()=>Ca,unknown:()=>Un,url:()=>Pb,uuid:()=>kb,uuidv4:()=>Eb,uuidv6:()=>Ib,uuidv7:()=>Tb,void:()=>av,xid:()=>Ab,xor:()=>mv});var aa={};et(aa,{endsWith:()=>$r,gt:()=>kt,gte:()=>Fe,includes:()=>xr,length:()=>Fn,lowercase:()=>vr,lt:()=>wt,lte:()=>Xe,maxLength:()=>jn,maxSize:()=>cn,mime:()=>wr,minLength:()=>Ot,minSize:()=>Et,multipleOf:()=>an,negative:()=>Xs,nonnegative:()=>ea,nonpositive:()=>Qs,normalize:()=>kr,overwrite:()=>vt,positive:()=>Ys,property:()=>ta,regex:()=>br,size:()=>Mn,slugify:()=>Pr,startsWith:()=>Sr,toLowerCase:()=>Ir,toUpperCase:()=>Tr,trim:()=>Er,uppercase:()=>_r});var Nr={};et(Nr,{ZodISODate:()=>la,ZodISODateTime:()=>ca,ZodISODuration:()=>da,ZodISOTime:()=>ua,date:()=>Fp,datetime:()=>jp,duration:()=>Zp,time:()=>Up});var ca=k("ZodISODateTime",(n,e)=>{gu.init(n,e),ce.init(n,e)});function jp(n){return _d(ca,n)}var la=k("ZodISODate",(n,e)=>{yu.init(n,e),ce.init(n,e)});function Fp(n){return xd(la,n)}var ua=k("ZodISOTime",(n,e)=>{bu.init(n,e),ce.init(n,e)});function Up(n){return Sd(ua,n)}var da=k("ZodISODuration",(n,e)=>{vu.init(n,e),ce.init(n,e)});function Zp(n){return $d(da,n)}var Sb=(n,e)=>{vi.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:r=>xi(n,r)},flatten:{value:r=>_i(n,r)},addIssue:{value:r=>{n.issues.push(r),n.message=JSON.stringify(n.issues,lr,2)}},addIssues:{value:r=>{n.issues.push(...r),n.message=JSON.stringify(n.issues,lr,2)}},isEmpty:{get(){return n.issues.length===0}}})},Lk=k("ZodError",Sb),Ke=k("ZodError",Sb,{Parent:Error});var Hp=pr(Ke),Wp=mr(Ke),Bp=fr(Ke),Gp=hr(Ke),Jp=os(Ke),qp=ss(Ke),Vp=as(Ke),Kp=cs(Ke),Yp=ls(Ke),Xp=us(Ke),Qp=ds(Ke),em=ps(Ke);var te=k("ZodType",(n,e)=>(Y.init(n,e),Object.assign(n["~standard"],{jsonSchema:{input:zr(n,"input"),output:zr(n,"output")}}),n.toJSONSchema=tp(n,{}),n.def=e,n.type=e.type,Object.defineProperty(n,"_def",{value:e}),n.check=(...r)=>n.clone(M.mergeDefs(e,{checks:[...e.checks??[],...r.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0}),n.with=n.check,n.clone=(r,i)=>je(n,r,i),n.brand=()=>n,n.register=((r,i)=>(r.add(n,i),n)),n.parse=(r,i)=>Hp(n,r,i,{callee:n.parse}),n.safeParse=(r,i)=>Bp(n,r,i),n.parseAsync=async(r,i)=>Wp(n,r,i,{callee:n.parseAsync}),n.safeParseAsync=async(r,i)=>Gp(n,r,i),n.spa=n.safeParseAsync,n.encode=(r,i)=>Jp(n,r,i),n.decode=(r,i)=>qp(n,r,i),n.encodeAsync=async(r,i)=>Vp(n,r,i),n.decodeAsync=async(r,i)=>Kp(n,r,i),n.safeEncode=(r,i)=>Yp(n,r,i),n.safeDecode=(r,i)=>Xp(n,r,i),n.safeEncodeAsync=async(r,i)=>Qp(n,r,i),n.safeDecodeAsync=async(r,i)=>em(n,r,i),n.refine=(r,i)=>n.check(Wm(r,i)),n.superRefine=r=>n.check(Bm(r)),n.overwrite=r=>n.check(vt(r)),n.optional=()=>Di(n),n.exactOptional=()=>Em(n),n.nullable=()=>Li(n),n.nullish=()=>Di(Li(n)),n.nonoptional=r=>Nm(n,r),n.array=()=>ji(n),n.or=r=>Ca([n,r]),n.and=r=>gm(n,r),n.transform=r=>Ai(n,La(r)),n.default=r=>Pm(n,r),n.prefault=r=>zm(n,r),n.catch=r=>Lm(n,r),n.pipe=r=>Ai(n,r),n.readonly=()=>Mm(n),n.describe=r=>{let i=n.clone();return De.add(i,{description:r}),i},Object.defineProperty(n,"description",{get(){return De.get(n)?.description},configurable:!0}),n.meta=(...r)=>{if(r.length===0)return De.get(n);let i=n.clone();return De.add(i,r[0]),i},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=r=>r(n),n)),fa=k("_ZodString",(n,e)=>{On.init(n,e),te.init(n,e),n._zod.processJSONSchema=(i,t,o)=>np(n,i,t,o);let r=n._zod.bag;n.format=r.format??null,n.minLength=r.minimum??null,n.maxLength=r.maximum??null,n.regex=(...i)=>n.check(br(...i)),n.includes=(...i)=>n.check(xr(...i)),n.startsWith=(...i)=>n.check(Sr(...i)),n.endsWith=(...i)=>n.check($r(...i)),n.min=(...i)=>n.check(Ot(...i)),n.max=(...i)=>n.check(jn(...i)),n.length=(...i)=>n.check(Fn(...i)),n.nonempty=(...i)=>n.check(Ot(1,...i)),n.lowercase=i=>n.check(vr(i)),n.uppercase=i=>n.check(_r(i)),n.trim=()=>n.check(Er()),n.normalize=(...i)=>n.check(kr(...i)),n.toLowerCase=()=>n.check(Ir()),n.toUpperCase=()=>n.check(Tr()),n.slugify=()=>n.check(Pr())}),Dr=k("ZodString",(n,e)=>{On.init(n,e),fa.init(n,e),n.email=r=>n.check(zs(ha,r)),n.url=r=>n.check(zi(Oi,r)),n.jwt=r=>n.check(Ks(Ra,r)),n.emoji=r=>n.check(As(ga,r)),n.guid=r=>n.check(Ri(Ci,r)),n.uuid=r=>n.check(Ns(It,r)),n.uuidv4=r=>n.check(Cs(It,r)),n.uuidv6=r=>n.check(Ds(It,r)),n.uuidv7=r=>n.check(Ls(It,r)),n.nanoid=r=>n.check(Os(ya,r)),n.guid=r=>n.check(Ri(Ci,r)),n.cuid=r=>n.check(Ms(ba,r)),n.cuid2=r=>n.check(js(va,r)),n.ulid=r=>n.check(Fs(_a,r)),n.base64=r=>n.check(Js(Ia,r)),n.base64url=r=>n.check(qs(Ta,r)),n.xid=r=>n.check(Us(xa,r)),n.ksuid=r=>n.check(Zs(Sa,r)),n.ipv4=r=>n.check(Hs($a,r)),n.ipv6=r=>n.check(Ws(wa,r)),n.cidrv4=r=>n.check(Bs(ka,r)),n.cidrv6=r=>n.check(Gs(Ea,r)),n.e164=r=>n.check(Vs(Pa,r)),n.datetime=r=>n.check(jp(r)),n.date=r=>n.check(Fp(r)),n.time=r=>n.check(Up(r)),n.duration=r=>n.check(Zp(r))});function pa(n){return gd(Dr,n)}var ce=k("ZodStringFormat",(n,e)=>{ae.init(n,e),fa.init(n,e)}),ha=k("ZodEmail",(n,e)=>{au.init(n,e),ce.init(n,e)});function $b(n){return zs(ha,n)}var Ci=k("ZodGUID",(n,e)=>{ou.init(n,e),ce.init(n,e)});function wb(n){return Ri(Ci,n)}var It=k("ZodUUID",(n,e)=>{su.init(n,e),ce.init(n,e)});function kb(n){return Ns(It,n)}function Eb(n){return Cs(It,n)}function Ib(n){return Ds(It,n)}function Tb(n){return Ls(It,n)}var Oi=k("ZodURL",(n,e)=>{cu.init(n,e),ce.init(n,e)});function Pb(n){return zi(Oi,n)}function Rb(n){return zi(Oi,{protocol:/^https?$/,hostname:at.domain,...M.normalizeParams(n)})}var ga=k("ZodEmoji",(n,e)=>{lu.init(n,e),ce.init(n,e)});function zb(n){return As(ga,n)}var ya=k("ZodNanoID",(n,e)=>{uu.init(n,e),ce.init(n,e)});function Nb(n){return Os(ya,n)}var ba=k("ZodCUID",(n,e)=>{du.init(n,e),ce.init(n,e)});function Cb(n){return Ms(ba,n)}var va=k("ZodCUID2",(n,e)=>{pu.init(n,e),ce.init(n,e)});function Db(n){return js(va,n)}var _a=k("ZodULID",(n,e)=>{mu.init(n,e),ce.init(n,e)});function Lb(n){return Fs(_a,n)}var xa=k("ZodXID",(n,e)=>{fu.init(n,e),ce.init(n,e)});function Ab(n){return Us(xa,n)}var Sa=k("ZodKSUID",(n,e)=>{hu.init(n,e),ce.init(n,e)});function Ob(n){return Zs(Sa,n)}var $a=k("ZodIPv4",(n,e)=>{_u.init(n,e),ce.init(n,e)});function Mb(n){return Hs($a,n)}var tm=k("ZodMAC",(n,e)=>{Su.init(n,e),ce.init(n,e)});function jb(n){return bd(tm,n)}var wa=k("ZodIPv6",(n,e)=>{xu.init(n,e),ce.init(n,e)});function Fb(n){return Ws(wa,n)}var ka=k("ZodCIDRv4",(n,e)=>{$u.init(n,e),ce.init(n,e)});function Ub(n){return Bs(ka,n)}var Ea=k("ZodCIDRv6",(n,e)=>{wu.init(n,e),ce.init(n,e)});function Zb(n){return Gs(Ea,n)}var Ia=k("ZodBase64",(n,e)=>{Eu.init(n,e),ce.init(n,e)});function Hb(n){return Js(Ia,n)}var Ta=k("ZodBase64URL",(n,e)=>{Iu.init(n,e),ce.init(n,e)});function Wb(n){return qs(Ta,n)}var Pa=k("ZodE164",(n,e)=>{Tu.init(n,e),ce.init(n,e)});function Bb(n){return Vs(Pa,n)}var Ra=k("ZodJWT",(n,e)=>{Pu.init(n,e),ce.init(n,e)});function Gb(n){return Ks(Ra,n)}var Lr=k("ZodCustomStringFormat",(n,e)=>{Ru.init(n,e),ce.init(n,e)});function Jb(n,e,r={}){return Rr(Lr,n,e,r)}function qb(n){return Rr(Lr,"hostname",at.hostname,n)}function Vb(n){return Rr(Lr,"hex",at.hex,n)}function Kb(n,e){let r=e?.enc??"hex",i=`${n}_${r}`,t=at[i];if(!t)throw new Error(`Unrecognized hash format: ${i}`);return Rr(Lr,i,t,e)}var Ar=k("ZodNumber",(n,e)=>{Ss.init(n,e),te.init(n,e),n._zod.processJSONSchema=(i,t,o)=>rp(n,i,t,o),n.gt=(i,t)=>n.check(kt(i,t)),n.gte=(i,t)=>n.check(Fe(i,t)),n.min=(i,t)=>n.check(Fe(i,t)),n.lt=(i,t)=>n.check(wt(i,t)),n.lte=(i,t)=>n.check(Xe(i,t)),n.max=(i,t)=>n.check(Xe(i,t)),n.int=i=>n.check(ma(i)),n.safe=i=>n.check(ma(i)),n.positive=i=>n.check(kt(0,i)),n.nonnegative=i=>n.check(Fe(0,i)),n.negative=i=>n.check(wt(0,i)),n.nonpositive=i=>n.check(Xe(0,i)),n.multipleOf=(i,t)=>n.check(an(i,t)),n.step=(i,t)=>n.check(an(i,t)),n.finite=()=>n;let r=n._zod.bag;n.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),n.isFinite=!0,n.format=r.format??null});function nm(n){return wd(Ar,n)}var Zn=k("ZodNumberFormat",(n,e)=>{zu.init(n,e),Ar.init(n,e)});function ma(n){return Ed(Zn,n)}function Yb(n){return Id(Zn,n)}function Xb(n){return Td(Zn,n)}function Qb(n){return Pd(Zn,n)}function ev(n){return Rd(Zn,n)}var Or=k("ZodBoolean",(n,e)=>{ki.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ip(n,r,i,t)});function rm(n){return zd(Or,n)}var Mr=k("ZodBigInt",(n,e)=>{$s.init(n,e),te.init(n,e),n._zod.processJSONSchema=(i,t,o)=>op(n,i,t,o),n.gte=(i,t)=>n.check(Fe(i,t)),n.min=(i,t)=>n.check(Fe(i,t)),n.gt=(i,t)=>n.check(kt(i,t)),n.gte=(i,t)=>n.check(Fe(i,t)),n.min=(i,t)=>n.check(Fe(i,t)),n.lt=(i,t)=>n.check(wt(i,t)),n.lte=(i,t)=>n.check(Xe(i,t)),n.max=(i,t)=>n.check(Xe(i,t)),n.positive=i=>n.check(kt(BigInt(0),i)),n.negative=i=>n.check(wt(BigInt(0),i)),n.nonpositive=i=>n.check(Xe(BigInt(0),i)),n.nonnegative=i=>n.check(Fe(BigInt(0),i)),n.multipleOf=(i,t)=>n.check(an(i,t));let r=n._zod.bag;n.minValue=r.minimum??null,n.maxValue=r.maximum??null,n.format=r.format??null});function tv(n){return Cd(Mr,n)}var za=k("ZodBigIntFormat",(n,e)=>{Nu.init(n,e),Mr.init(n,e)});function nv(n){return Ld(za,n)}function rv(n){return Ad(za,n)}var im=k("ZodSymbol",(n,e)=>{Cu.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>sp(n,r,i,t)});function iv(n){return Od(im,n)}var om=k("ZodUndefined",(n,e)=>{Du.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>cp(n,r,i,t)});function ov(n){return Md(om,n)}var sm=k("ZodNull",(n,e)=>{Lu.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ap(n,r,i,t)});function am(n){return jd(sm,n)}var cm=k("ZodAny",(n,e)=>{Au.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>dp(n,r,i,t)});function sv(){return Fd(cm)}var lm=k("ZodUnknown",(n,e)=>{Ou.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>pp(n,r,i,t)});function Un(){return Ud(lm)}var um=k("ZodNever",(n,e)=>{Mu.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>up(n,r,i,t)});function Na(n){return Zd(um,n)}var dm=k("ZodVoid",(n,e)=>{ju.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>lp(n,r,i,t)});function av(n){return Hd(dm,n)}var Mi=k("ZodDate",(n,e)=>{Fu.init(n,e),te.init(n,e),n._zod.processJSONSchema=(i,t,o)=>mp(n,i,t,o),n.min=(i,t)=>n.check(Fe(i,t)),n.max=(i,t)=>n.check(Xe(i,t));let r=n._zod.bag;n.minDate=r.minimum?new Date(r.minimum):null,n.maxDate=r.maximum?new Date(r.maximum):null});function cv(n){return Wd(Mi,n)}var pm=k("ZodArray",(n,e)=>{Uu.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>kp(n,r,i,t),n.element=e.element,n.min=(r,i)=>n.check(Ot(r,i)),n.nonempty=r=>n.check(Ot(1,r)),n.max=(r,i)=>n.check(jn(r,i)),n.length=(r,i)=>n.check(Fn(r,i)),n.unwrap=()=>n.element});function ji(n,e){return Jd(pm,n,e)}function lv(n){let e=n._zod.def.shape;return Da(Object.keys(e))}var Fi=k("ZodObject",(n,e)=>{Zu.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Ep(n,r,i,t),M.defineLazy(n,"shape",()=>e.shape),n.keyof=()=>Da(Object.keys(n._zod.def.shape)),n.catchall=r=>n.clone({...n._zod.def,catchall:r}),n.passthrough=()=>n.clone({...n._zod.def,catchall:Un()}),n.loose=()=>n.clone({...n._zod.def,catchall:Un()}),n.strict=()=>n.clone({...n._zod.def,catchall:Na()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=r=>M.extend(n,r),n.safeExtend=r=>M.safeExtend(n,r),n.merge=r=>M.merge(n,r),n.pick=r=>M.pick(n,r),n.omit=r=>M.omit(n,r),n.partial=(...r)=>M.partial(Aa,n,r[0]),n.required=(...r)=>M.required(Oa,n,r[0])});function uv(n,e){let r={type:"object",shape:n??{},...M.normalizeParams(e)};return new Fi(r)}function dv(n,e){return new Fi({type:"object",shape:n,catchall:Na(),...M.normalizeParams(e)})}function pv(n,e){return new Fi({type:"object",shape:n,catchall:Un(),...M.normalizeParams(e)})}var Ui=k("ZodUnion",(n,e)=>{Ei.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ra(n,r,i,t),n.options=e.options});function Ca(n,e){return new Ui({type:"union",options:n,...M.normalizeParams(e)})}var mm=k("ZodXor",(n,e)=>{Ui.init(n,e),Hu.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ra(n,r,i,t),n.options=e.options});function mv(n,e){return new mm({type:"union",options:n,inclusive:!1,...M.normalizeParams(e)})}var fm=k("ZodDiscriminatedUnion",(n,e)=>{Ui.init(n,e),Wu.init(n,e)});function fv(n,e,r){return new fm({type:"union",options:e,discriminator:n,...M.normalizeParams(r)})}var hm=k("ZodIntersection",(n,e)=>{Bu.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Ip(n,r,i,t)});function gm(n,e){return new hm({type:"intersection",left:n,right:e})}var ym=k("ZodTuple",(n,e)=>{ws.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Tp(n,r,i,t),n.rest=r=>n.clone({...n._zod.def,rest:r})});function bm(n,e,r){let i=e instanceof Y,t=i?r:e,o=i?e:null;return new ym({type:"tuple",items:n,rest:o,...M.normalizeParams(t)})}var Zi=k("ZodRecord",(n,e)=>{Gu.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Pp(n,r,i,t),n.keyType=e.keyType,n.valueType=e.valueType});function vm(n,e,r){return new Zi({type:"record",keyType:n,valueType:e,...M.normalizeParams(r)})}function hv(n,e,r){let i=je(n);return i._zod.values=void 0,new Zi({type:"record",keyType:i,valueType:e,...M.normalizeParams(r)})}function gv(n,e,r){return new Zi({type:"record",keyType:n,valueType:e,mode:"loose",...M.normalizeParams(r)})}var _m=k("ZodMap",(n,e)=>{Ju.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>$p(n,r,i,t),n.keyType=e.keyType,n.valueType=e.valueType,n.min=(...r)=>n.check(Et(...r)),n.nonempty=r=>n.check(Et(1,r)),n.max=(...r)=>n.check(cn(...r)),n.size=(...r)=>n.check(Mn(...r))});function yv(n,e,r){return new _m({type:"map",keyType:n,valueType:e,...M.normalizeParams(r)})}var xm=k("ZodSet",(n,e)=>{qu.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>wp(n,r,i,t),n.min=(...r)=>n.check(Et(...r)),n.nonempty=r=>n.check(Et(1,r)),n.max=(...r)=>n.check(cn(...r)),n.size=(...r)=>n.check(Mn(...r))});function bv(n,e){return new xm({type:"set",valueType:n,...M.normalizeParams(e)})}var Cr=k("ZodEnum",(n,e)=>{Vu.init(n,e),te.init(n,e),n._zod.processJSONSchema=(i,t,o)=>fp(n,i,t,o),n.enum=e.entries,n.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));n.extract=(i,t)=>{let o={};for(let s of i)if(r.has(s))o[s]=e.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Cr({...e,checks:[],...M.normalizeParams(t),entries:o})},n.exclude=(i,t)=>{let o={...e.entries};for(let s of i)if(r.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new Cr({...e,checks:[],...M.normalizeParams(t),entries:o})}});function Da(n,e){let r=Array.isArray(n)?Object.fromEntries(n.map(i=>[i,i])):n;return new Cr({type:"enum",entries:r,...M.normalizeParams(e)})}function vv(n,e){return new Cr({type:"enum",entries:n,...M.normalizeParams(e)})}var Sm=k("ZodLiteral",(n,e)=>{Ku.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>hp(n,r,i,t),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function _v(n,e){return new Sm({type:"literal",values:Array.isArray(n)?n:[n],...M.normalizeParams(e)})}var $m=k("ZodFile",(n,e)=>{Yu.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>bp(n,r,i,t),n.min=(r,i)=>n.check(Et(r,i)),n.max=(r,i)=>n.check(cn(r,i)),n.mime=(r,i)=>n.check(wr(Array.isArray(r)?r:[r],i))});function xv(n){return qd($m,n)}var wm=k("ZodTransform",(n,e)=>{Xu.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Sp(n,r,i,t),n._zod.parse=(r,i)=>{if(i.direction==="backward")throw new tn(n.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(M.issue(o,r.value,e));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=n),r.issues.push(M.issue(s))}};let t=e.transform(r.value,r);return t instanceof Promise?t.then(o=>(r.value=o,r)):(r.value=t,r)}});function La(n){return new wm({type:"transform",transform:n})}var Aa=k("ZodOptional",(n,e)=>{ks.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ia(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Di(n){return new Aa({type:"optional",innerType:n})}var km=k("ZodExactOptional",(n,e)=>{Qu.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ia(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Em(n){return new km({type:"optional",innerType:n})}var Im=k("ZodNullable",(n,e)=>{ed.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Rp(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Li(n){return new Im({type:"nullable",innerType:n})}function Sv(n){return Di(Li(n))}var Tm=k("ZodDefault",(n,e)=>{td.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Np(n,r,i,t),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function Pm(n,e){return new Tm({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():M.shallowClone(e)}})}var Rm=k("ZodPrefault",(n,e)=>{nd.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Cp(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function zm(n,e){return new Rm({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():M.shallowClone(e)}})}var Oa=k("ZodNonOptional",(n,e)=>{rd.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>zp(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Nm(n,e){return new Oa({type:"nonoptional",innerType:n,...M.normalizeParams(e)})}var Cm=k("ZodSuccess",(n,e)=>{id.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>vp(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function $v(n){return new Cm({type:"success",innerType:n})}var Dm=k("ZodCatch",(n,e)=>{od.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Dp(n,r,i,t),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function Lm(n,e){return new Dm({type:"catch",innerType:n,catchValue:typeof e=="function"?e:()=>e})}var Am=k("ZodNaN",(n,e)=>{sd.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>gp(n,r,i,t)});function wv(n){return Gd(Am,n)}var Ma=k("ZodPipe",(n,e)=>{ad.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Lp(n,r,i,t),n.in=e.in,n.out=e.out});function Ai(n,e){return new Ma({type:"pipe",in:n,out:e})}var ja=k("ZodCodec",(n,e)=>{Ma.init(n,e),Ii.init(n,e)});function kv(n,e,r){return new ja({type:"pipe",in:n,out:e,transform:r.decode,reverseTransform:r.encode})}var Om=k("ZodReadonly",(n,e)=>{cd.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Ap(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Mm(n){return new Om({type:"readonly",innerType:n})}var jm=k("ZodTemplateLiteral",(n,e)=>{ld.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>yp(n,r,i,t)});function Ev(n,e){return new jm({type:"template_literal",parts:n,...M.normalizeParams(e)})}var Fm=k("ZodLazy",(n,e)=>{pd.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Mp(n,r,i,t),n.unwrap=()=>n._zod.def.getter()});function Um(n){return new Fm({type:"lazy",getter:n})}var Zm=k("ZodPromise",(n,e)=>{dd.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Op(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Iv(n){return new Zm({type:"promise",innerType:n})}var Hm=k("ZodFunction",(n,e)=>{ud.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>xp(n,r,i,t)});function Tv(n){return new Hm({type:"function",input:Array.isArray(n?.input)?bm(n?.input):n?.input??ji(Un()),output:n?.output??Un()})}var Hi=k("ZodCustom",(n,e)=>{md.init(n,e),te.init(n,e),n._zod.processJSONSchema=(r,i,t)=>_p(n,r,i,t)});function Pv(n){let e=new me({check:"custom"});return e._zod.check=n,e}function Rv(n,e){return Vd(Hi,n??(()=>!0),e)}function Wm(n,e={}){return Kd(Hi,n,e)}function Bm(n){return Yd(n)}var zv=Xd,Nv=Qd;function Cv(n,e={}){let r=new Hi({type:"custom",check:"custom",fn:i=>i instanceof n,abort:!0,...M.normalizeParams(e)});return r._zod.bag.Class=n,r._zod.check=i=>{i.value instanceof n||i.issues.push({code:"invalid_type",expected:n.name,input:i.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Dv=(...n)=>ep({Codec:ja,Boolean:Or,String:Dr},...n);function Lv(n){let e=Um(()=>Ca([pa(n),nm(),rm(),am(),ji(e),vm(pa(),e)]));return e}function Av(n,e){return Ai(La(n),e)}var Ok={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function Mk(n){xe({customError:n})}function jk(){return xe().customError}var Gm;Gm||(Gm={});var Z={...Ni,...aa,iso:Nr},Fk=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function Uk(n,e){let r=n.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":e??"draft-2020-12"}function Zk(n,e){if(!n.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=n.slice(1).split("/").filter(Boolean);if(r.length===0)return e.rootSchema;let i=e.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===i){let t=r[1];if(!t||!e.defs[t])throw new Error(`Reference not found: ${n}`);return e.defs[t]}throw new Error(`Reference not found: ${n}`)}function Ov(n,e){if(n.not!==void 0){if(typeof n.not=="object"&&Object.keys(n.not).length===0)return Z.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(n.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(n.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(n.if!==void 0||n.then!==void 0||n.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(n.dependentSchemas!==void 0||n.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(n.$ref){let t=n.$ref;if(e.refs.has(t))return e.refs.get(t);if(e.processing.has(t))return Z.lazy(()=>{if(!e.refs.has(t))throw new Error(`Circular reference not resolved: ${t}`);return e.refs.get(t)});e.processing.add(t);let o=Zk(t,e),s=Le(o,e);return e.refs.set(t,s),e.processing.delete(t),s}if(n.enum!==void 0){let t=n.enum;if(e.version==="openapi-3.0"&&n.nullable===!0&&t.length===1&&t[0]===null)return Z.null();if(t.length===0)return Z.never();if(t.length===1)return Z.literal(t[0]);if(t.every(s=>typeof s=="string"))return Z.enum(t);let o=t.map(s=>Z.literal(s));return o.length<2?o[0]:Z.union([o[0],o[1],...o.slice(2)])}if(n.const!==void 0)return Z.literal(n.const);let r=n.type;if(Array.isArray(r)){let t=r.map(o=>{let s={...n,type:o};return Ov(s,e)});return t.length===0?Z.never():t.length===1?t[0]:Z.union(t)}if(!r)return Z.any();let i;switch(r){case"string":{let t=Z.string();if(n.format){let o=n.format;o==="email"?t=t.check(Z.email()):o==="uri"||o==="uri-reference"?t=t.check(Z.url()):o==="uuid"||o==="guid"?t=t.check(Z.uuid()):o==="date-time"?t=t.check(Z.iso.datetime()):o==="date"?t=t.check(Z.iso.date()):o==="time"?t=t.check(Z.iso.time()):o==="duration"?t=t.check(Z.iso.duration()):o==="ipv4"?t=t.check(Z.ipv4()):o==="ipv6"?t=t.check(Z.ipv6()):o==="mac"?t=t.check(Z.mac()):o==="cidr"?t=t.check(Z.cidrv4()):o==="cidr-v6"?t=t.check(Z.cidrv6()):o==="base64"?t=t.check(Z.base64()):o==="base64url"?t=t.check(Z.base64url()):o==="e164"?t=t.check(Z.e164()):o==="jwt"?t=t.check(Z.jwt()):o==="emoji"?t=t.check(Z.emoji()):o==="nanoid"?t=t.check(Z.nanoid()):o==="cuid"?t=t.check(Z.cuid()):o==="cuid2"?t=t.check(Z.cuid2()):o==="ulid"?t=t.check(Z.ulid()):o==="xid"?t=t.check(Z.xid()):o==="ksuid"&&(t=t.check(Z.ksuid()))}typeof n.minLength=="number"&&(t=t.min(n.minLength)),typeof n.maxLength=="number"&&(t=t.max(n.maxLength)),n.pattern&&(t=t.regex(new RegExp(n.pattern))),i=t;break}case"number":case"integer":{let t=r==="integer"?Z.number().int():Z.number();typeof n.minimum=="number"&&(t=t.min(n.minimum)),typeof n.maximum=="number"&&(t=t.max(n.maximum)),typeof n.exclusiveMinimum=="number"?t=t.gt(n.exclusiveMinimum):n.exclusiveMinimum===!0&&typeof n.minimum=="number"&&(t=t.gt(n.minimum)),typeof n.exclusiveMaximum=="number"?t=t.lt(n.exclusiveMaximum):n.exclusiveMaximum===!0&&typeof n.maximum=="number"&&(t=t.lt(n.maximum)),typeof n.multipleOf=="number"&&(t=t.multipleOf(n.multipleOf)),i=t;break}case"boolean":{i=Z.boolean();break}case"null":{i=Z.null();break}case"object":{let t={},o=n.properties||{},s=new Set(n.required||[]);for(let[c,l]of Object.entries(o)){let u=Le(l,e);t[c]=s.has(c)?u:u.optional()}if(n.propertyNames){let c=Le(n.propertyNames,e),l=n.additionalProperties&&typeof n.additionalProperties=="object"?Le(n.additionalProperties,e):Z.any();if(Object.keys(t).length===0){i=Z.record(c,l);break}let u=Z.object(t).passthrough(),d=Z.looseRecord(c,l);i=Z.intersection(u,d);break}if(n.patternProperties){let c=n.patternProperties,l=Object.keys(c),u=[];for(let p of l){let f=Le(c[p],e),m=Z.string().regex(new RegExp(p));u.push(Z.looseRecord(m,f))}let d=[];if(Object.keys(t).length>0&&d.push(Z.object(t).passthrough()),d.push(...u),d.length===0)i=Z.object({}).passthrough();else if(d.length===1)i=d[0];else{let p=Z.intersection(d[0],d[1]);for(let f=2;f<d.length;f++)p=Z.intersection(p,d[f]);i=p}break}let a=Z.object(t);n.additionalProperties===!1?i=a.strict():typeof n.additionalProperties=="object"?i=a.catchall(Le(n.additionalProperties,e)):i=a.passthrough();break}case"array":{let t=n.prefixItems,o=n.items;if(t&&Array.isArray(t)){let s=t.map(c=>Le(c,e)),a=o&&typeof o=="object"&&!Array.isArray(o)?Le(o,e):void 0;a?i=Z.tuple(s).rest(a):i=Z.tuple(s),typeof n.minItems=="number"&&(i=i.check(Z.minLength(n.minItems))),typeof n.maxItems=="number"&&(i=i.check(Z.maxLength(n.maxItems)))}else if(Array.isArray(o)){let s=o.map(c=>Le(c,e)),a=n.additionalItems&&typeof n.additionalItems=="object"?Le(n.additionalItems,e):void 0;a?i=Z.tuple(s).rest(a):i=Z.tuple(s),typeof n.minItems=="number"&&(i=i.check(Z.minLength(n.minItems))),typeof n.maxItems=="number"&&(i=i.check(Z.maxLength(n.maxItems)))}else if(o!==void 0){let s=Le(o,e),a=Z.array(s);typeof n.minItems=="number"&&(a=a.min(n.minItems)),typeof n.maxItems=="number"&&(a=a.max(n.maxItems)),i=a}else i=Z.array(Z.any());break}default:throw new Error(`Unsupported type: ${r}`)}return n.description&&(i=i.describe(n.description)),n.default!==void 0&&(i=i.default(n.default)),i}function Le(n,e){if(typeof n=="boolean")return n?Z.any():Z.never();let r=Ov(n,e),i=n.type||n.enum!==void 0||n.const!==void 0;if(n.anyOf&&Array.isArray(n.anyOf)){let a=n.anyOf.map(l=>Le(l,e)),c=Z.union(a);r=i?Z.intersection(r,c):c}if(n.oneOf&&Array.isArray(n.oneOf)){let a=n.oneOf.map(l=>Le(l,e)),c=Z.xor(a);r=i?Z.intersection(r,c):c}if(n.allOf&&Array.isArray(n.allOf))if(n.allOf.length===0)r=i?r:Z.any();else{let a=i?r:Le(n.allOf[0],e),c=i?0:1;for(let l=c;l<n.allOf.length;l++)a=Z.intersection(a,Le(n.allOf[l],e));r=a}n.nullable===!0&&e.version==="openapi-3.0"&&(r=Z.nullable(r)),n.readOnly===!0&&(r=Z.readonly(r));let t={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of o)a in n&&(t[a]=n[a]);let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)a in n&&(t[a]=n[a]);for(let a of Object.keys(n))Fk.has(a)||(t[a]=n[a]);return Object.keys(t).length>0&&e.registry.add(r,t),r}function Mv(n,e){if(typeof n=="boolean")return n?Z.any():Z.never();let r=Uk(n,e?.defaultTarget),i=n.$defs||n.definitions||{},t={version:r,defs:i,refs:new Map,processing:new Set,rootSchema:n,registry:e?.registry??De};return Le(n,t)}var Jm={};et(Jm,{bigint:()=>Gk,boolean:()=>Bk,date:()=>Jk,number:()=>Wk,string:()=>Hk});function Hk(n){return yd(Dr,n)}function Wk(n){return kd(Ar,n)}function Bk(n){return Nd(Or,n)}function Gk(n){return Dd(Mr,n)}function Jk(n){return Bd(Mi,n)}xe(Es());var _L=y.object({repoPath:y.string(),mode:y.enum(["init","tree","topography","scout","hologram","tools"]),subPath:y.string().optional(),maxDepth:y.number().int().min(he.MIN_DEPTH).max(he.MAX_DEPTH).optional()}),xL=y.object({repoPath:y.string(),mode:y.enum(["symbol","concept","symbol-fuzzy","config","path"]).default("symbol"),query:y.string().max(he.MAX_QUERY_LENGTH).optional(),key:y.string().optional(),kind:y.enum(["Service","Image","Port","Env"]).optional(),limit:y.number().int().min(he.MIN_LIMIT).max(he.MAX_LIMIT).optional(),offset:y.number().int().min(0).optional(),compact:y.boolean().optional()}).refine(n=>!(n.mode==="concept"&&(!n.query||n.query.trim().length===0)),{message:"Concept search requires a non-empty query",path:["query"]}),SL=y.object({repoPath:y.string(),mode:y.enum(["symbol","file"]),filePath:y.string().optional(),detailLevel:y.enum(["structure","signatures","summaries","detailed"]).optional(),symbolName:y.string().optional(),context:y.enum(["definition","full"]).optional()}),$L=y.object({repoPath:y.string(),mode:y.enum(["impact","deps","flow","dead-code","circular-deps"]),filePath:y.string().optional(),symbolName:y.string().optional(),direction:y.enum(["imports","imported_by"]).optional(),depth:y.number().int().min(he.MIN_DEPTH).max(he.MAX_DEPTH).optional(),limit:y.number().int().min(he.MIN_LIMIT).max(he.MAX_LIMIT).optional(),includeTests:y.boolean().optional()}),wL=y.object({repoPath:y.string(),action:y.enum(["index","repair","trace"]),deep:y.boolean().optional(),sinceCommit:y.string().optional()}),kL=y.object({repoPath:y.string(),action:y.enum(["install","remove","status"]),enableAutoRefresh:y.boolean().optional(),enableSymbolHealing:y.boolean().optional()}),EL=y.object({action:y.enum(["list","link","fuse"]),repoPaths:y.array(y.string()).optional(),name:y.string().optional(),status:y.string().optional(),parentRepoPath:y.string().optional(),parentMissionId:y.number().optional(),childRepoPath:y.string().optional(),childMissionId:y.number().optional(),relationship:y.string().optional()});var qk=[...qg,...Vg];J();J();var Vk=$.child({module:"strategy-normalizer"}),jt=class{static normalize(e){if(!e)return{steps:[]};let r;if(typeof e=="string")try{r=JSON.parse(e)}catch(t){return Vk.warn({strategyInput:e,err:t},"Failed to parse strategy JSON"),{steps:[]}}else r=e;return{steps:this.normalizeSteps(r)}}static normalizeSteps(e){return Array.isArray(e)?e.map((r,i)=>typeof r=="string"?{id:`step-${i}`,description:r,status:"pending"}:typeof r=="object"&&r!==null?{id:r.id||`step-${i}`,description:r.description||r.content||r.name||`Step ${i+1}`,status:r.status||"pending",dependencies:r.dependencies||r.deps,verification:r.verification,...r}:{id:`step-${i}`,description:String(r),status:"pending"}):e.steps&&Array.isArray(e.steps)?this.normalizeSteps(e.steps):typeof e=="object"?Object.entries(e).map(([r,i],t)=>typeof i=="string"?{id:r,description:i,status:"pending"}:typeof i=="object"&&i!==null?{id:r,description:i.description||i.content||i.name||r,status:i.status||"pending",dependencies:i.dependencies||i.deps,verification:i.verification,...i}:{id:r||`step-${t}`,description:String(i),status:"pending"}):[]}static stringify(e){return JSON.stringify(e,null,2)}static validate(e){let r=[];if(!e)return{valid:!0,errors:[]};try{let i=this.normalize(e),t=new Set;for(let o of i.steps)if(t.has(o.id)&&r.push(`Duplicate step ID: ${o.id}`),t.add(o.id),o.dependencies)for(let s of o.dependencies)t.has(s)||r.push(`Step "${o.id}" depends on non-existent step "${s}"`);return{valid:r.length===0,errors:r}}catch(i){return r.push(`Strategy validation failed: ${i instanceof Error?i.message:String(i)}`),{valid:!1,errors:r}}}};J();import qm from"fs";import jv from"path";import Kk from"os";var Yk=[{id:"step-0",description:"Analyze impact: identify dependents and call sites",status:"pending"},{id:"step-1",description:"Implement refactor and update call sites",status:"pending"},{id:"step-2",description:"Run tests and verify behavior; update docs if needed",status:"pending"}],Xk=[{id:"step-0",description:"Capture requirements and acceptance criteria",status:"pending"},{id:"step-1",description:"Implement feature with tests",status:"pending"},{id:"step-2",description:"Integrate and verify end-to-end",status:"pending"}],Qk=[{id:"step-0",description:"Reproduce the bug and document steps",status:"pending"},{id:"step-1",description:"Diagnose root cause and plan fix",status:"pending"},{id:"step-2",description:"Apply fix and add/update regression test",status:"pending"},{id:"step-3",description:"Verify fix and run full test suite",status:"pending"}],Fv=[{id:"refactoring",name:"Refactoring",description:"Impact analysis \u2192 implementation \u2192 verification",defaultGoal:"Refactor {{target}} safely with full impact analysis and verification.",steps:Yk},{id:"feature",name:"Feature",description:"Requirements \u2192 implementation \u2192 testing",defaultGoal:"Implement {{target}} with clear requirements and end-to-end verification.",steps:Xk},{id:"bug-fix",name:"Bug fix",description:"Reproduction \u2192 diagnosis \u2192 fix \u2192 regression test",defaultGoal:"Fix {{target}}: reproduce, diagnose, fix, and add regression test.",steps:Qk}],Vm=new Map(Fv.map(n=>[n.id,n])),Fa=!1;function eE(){if(Fa)return;let n=jv.join(Kk.homedir(),".shadow","templates");if(!qm.existsSync(n)){$.debug({templatesDir:n},"Custom templates directory does not exist"),Fa=!0;return}try{let e=qm.readdirSync(n).filter(r=>r.endsWith(".json"));for(let r of e)try{let i=jv.join(n,r),t=qm.readFileSync(i,"utf8"),o=JSON.parse(t);if(!o.id||!o.name||!o.defaultGoal||!o.steps){$.warn({file:r,template:o},"Invalid custom template structure - skipping");continue}if(!Array.isArray(o.steps)||o.steps.length===0){$.warn({file:r},"Template has no steps - skipping");continue}if(Fv.some(s=>s.id===o.id)){$.warn({file:r,templateId:o.id},"Custom template ID conflicts with built-in - skipping");continue}Vm.set(o.id,o),$.info({file:r,templateId:o.id},"Loaded custom template")}catch(i){$.warn({file:r,error:i},"Failed to load custom template")}Fa=!0}catch(e){$.warn({error:e,templatesDir:n},"Failed to read custom templates directory"),Fa=!0}}function Uv(n){return eE(),Vm.get(n)}function tE(n,e){let r=n;for(let[i,t]of Object.entries(e))r=r.replace(new RegExp(`\\{\\{${i}\\}\\}`,"g"),t);return r}function Km(n,e,r={}){let i=Uv(n);if(!i)throw new Error(`Unknown template: ${n}. Use one of: ${Array.from(Vm.keys()).join(", ")}`);let t=r.target||"scope",o=e||(n==="refactoring"?`Refactor ${t}`:n==="feature"?`Feature: ${t}`:`Fix: ${t}`),s=tE(i.defaultGoal,{...r,target:t}),a=jt.normalize({steps:i.steps}),c=jt.stringify(a);return{name:o,goal:s,strategy:c}}X();X();import{execSync as jr}from"child_process";var Wi=class{constructor(e,r="refs/notes/shadow"){this.repoPath=e;this.ref=r}addNote(e,r){try{jr(`git notes --ref ${this.ref} add -f -m '${r.replace(/'/g,"'\\''")}' ${e}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch(i){throw new Error(`Failed to add git note to ${e}: ${i.message}`)}}getNote(e){try{return jr(`git notes --ref ${this.ref} show ${e}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return null}}listNotes(){let e=new Map;try{let r=jr(`git notes --ref ${this.ref} list`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim();if(!r)return e;let i=r.split(`
|
|
776
|
-
`);for(let t of i){let[o,s]=t.split(" ");if(s){let a=this.getNote(s);a&&e.set(s,a)}}}catch{}return e}removeNote(e){try{jr(`git notes --ref ${this.ref} remove ${e}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch{}}push(e="origin"){try{jr(`git push ${e} ${this.ref}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch(r){throw new Error(`Failed to push git notes to ${e}: ${r.message}`)}}fetch(e="origin"){try{jr(`git fetch ${e} ${this.ref}:${this.ref}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch{}}};J();var Fr=$.child({module:"persistence-service"}),ct=class{gitNotes;repoPath;constructor(e){this.repoPath=e,this.gitNotes=new Wi(e)}async syncMissionToGitNotes(e){let{missions:r,intentLogs:i}=L.getInstance(this.repoPath),t=r.findById(e);if(!t)throw new Error(`Mission ${e} not found`);if(!t.commit_sha){Fr.warn({missionId:e},"Cannot sync mission without commit_sha");return}Fr.info({missionId:e,commitSha:t.commit_sha},"Syncing mission to Git Notes");let o=r.getArtifacts(e),s=i.findByMission(e,1e3),a=s.find(u=>u.type==="adr"),c=s.filter(u=>u.type==="decision").map(u=>({content:u.content,symbol_name:u.symbol_name,created_at:u.created_at})),l={version:"1.0",mission:{name:t.name,goal:t.goal,status:t.status,strategy_graph:t.strategy_graph,git_branch:t.git_branch,commit_sha:t.commit_sha,parent_id:t.parent_id,verification_context:t.verification_context,outcome_contract:t.outcome_contract,created_at:t.created_at,updated_at:t.updated_at},artifacts:o,adr:a?a.content:null,decisions:c};this.gitNotes.addNote(t.commit_sha,JSON.stringify(l,null,2))}async syncAllToGitNotes(){let{missions:e}=L.getInstance(this.repoPath),r=e.findActive(),i=e.findRecentCompleted(10),t=[...r,...i];for(let o of t)try{await this.syncMissionToGitNotes(o.id)}catch(s){Fr.error({missionId:o.id,error:s},"Failed to sync mission")}}async recoverFromGitNotes(){let e=this.gitNotes.listNotes(),{missions:r,intentLogs:i}=L.getInstance(this.repoPath),t=0,o=0;for(let[s,a]of e.entries())try{let c=JSON.parse(a);if(c.version!=="1.0")continue;if(r.findByCommitShas([s]).some(p=>p.name===c.mission.name)){Fr.debug({commitSha:s,missionName:c.mission.name},"Mission already exists, skipping recovery");continue}let d=r.create({name:c.mission.name,goal:c.mission.goal,status:c.mission.status,strategy_graph:c.mission.strategy_graph,git_branch:c.mission.git_branch,commit_sha:s,parent_id:c.mission.parent_id,verification_context:c.mission.verification_context,outcome_contract:c.mission.outcome_contract});if(t++,c.adr&&(i.create({mission_id:Number(d),symbol_id:null,file_path:null,type:"adr",content:c.adr,confidence:1,symbol_name:null,signature:null,commit_sha:s}),o++),c.decisions&&c.decisions.length>0)for(let p of c.decisions)i.create({mission_id:Number(d),symbol_id:null,file_path:null,type:"decision",content:p.content,confidence:1,symbol_name:p.symbol_name,signature:null,commit_sha:s}),o++;Fr.info({commitSha:s,missionName:c.mission.name,logsRecovered:o},"Re-hydrated mission from Git Notes")}catch(c){Fr.error({commitSha:s,error:c},"Failed to parse Git Note for recovery")}return{missionsRecovered:t,logsRecovered:o}}};var Ua=$.child({module:"mcp:tools:ops:plan"});async function Za(n){let{repoPath:e,name:r,goal:i,strategy:t,missionId:o,parentId:s,outcomeContract:a,templateId:c,templateVars:l}=n,{missions:u}=L.getInstance(e),d=Te(e),p=it(e);Ua.info({repoPath:e,name:r,missionId:o,templateId:c},"Planning mission");try{let f=r,m=i,h=t;if(c){let x=Km(c,r,l||{});f=f??x.name,m=m??x.goal,h=h??x.strategy}if(!f||!m)throw new Error("Mission requires name and goal (or templateId with optional templateVars).");let v=null;if(h){let x=jt.normalize(h);v=jt.stringify(x);let S=jt.validate(v);S.valid||Ua.warn({errors:S.errors,strategy:h},"Strategy validation warnings detected")}let b,g;o?(u.update(o,{name:f,goal:m,strategy_graph:v,commit_sha:p,parent_id:s!==void 0?s:void 0,outcome_contract:a}),b=o,g=`Mission "${f}" updated.`):(b=u.create({name:f,goal:m,strategy_graph:v,status:"planned",git_branch:d,commit_sha:p,parent_id:s||null,verification_context:null,outcome_contract:a||null}),g=`Mission "${f}" planned.`);try{await new ct(e).syncMissionToGitNotes(Number(b))}catch(x){Ua.warn({syncError:x,missionId:b},"Git Notes sync deferred")}return{content:[{type:"text",text:JSON.stringify({missionId:b,status:"planned",message:g,strategy_saved:!!h,contract_saved:!!a,from_template:c??void 0,commit:p},null,2)}]}}catch(f){throw Ua.error({error:f,repoPath:e},"Failed to plan mission"),new Error(`Failed to plan mission: ${f instanceof Error?f.message:String(f)}`)}}J();X();X();J();J();var nE=$.child({module:"reasoning-engine"}),Hn=class{analyze(e){nE.debug({logCount:e.length},"Performing reasoning pass over intent logs");let r={context:[],decisions:[],consequences:[],recommendations:[],unclassified:[]};for(let i of e){let t=i.content.toLowerCase(),o=this.matchesContext(t,i.type),s=this.matchesDecision(t,i.type),a=this.matchesConsequence(t,i.type),c=this.matchesRecommendation(t,i.type);o?r.context.push(i.content):s?r.decisions.push(i.content):c?r.recommendations.push(i.content):a?r.consequences.push(i.content):i.type==="decision"?r.decisions.push(i.content):i.type==="discovery"||i.type==="fix"?r.consequences.push(i.content):r.unclassified.push(i.content)}return r}matchesContext(e,r){return["because","since","given","due to","context: ","problem: ","situation:"].some(t=>e.includes(t))||r==="blocker"}matchesDecision(e,r){return["decided","chose","implemented","integrated","using","selected","strategy:"].some(t=>e.includes(t))||r==="decision"}matchesConsequence(e,r){return["results in","enables","allows","impact: ","consequence: ","next steps: ","meaning"].some(t=>e.includes(t))||r==="fix"}matchesRecommendation(e,r){return["should","recommend","suggest","next work","future","consider","strategy advice"].some(t=>e.includes(t))}};var Ha=$.child({module:"briefing-engine"}),Tt=class{intentLogs;missions;reasoningEngine;persistencePivot;constructor(e){let{intentLogs:r,missions:i}=L.getInstance(e);this.intentLogs=r,this.missions=i,this.reasoningEngine=new Hn,this.persistencePivot=new ct(e)}async distillMission(e,r=!0){Ha.info({missionId:e},"Synthesizing mission intelligence into Tactical Briefing...");let i=this.gatherConsolidatedLogs(e);if(i.length===0)return{missionId:e,adr:"No intent logs found for this mission.",metrics:{totalLogs:0,symbolCount:0}};let t=this.reasoningEngine.analyze(i),o=new Set(i.map(a=>a.symbol_name).filter(Boolean)),s=`# Architectural Decision Record: Mission #${e}
|
|
777
|
-
|
|
778
|
-
`;if(s+=`## Summary of Intent
|
|
779
|
-
`,s+=`Collected ${i.length} intent events across ${o.size} symbols.
|
|
780
|
-
|
|
781
|
-
`,t.context.length>0&&(s+=`### Context
|
|
782
|
-
`,t.context.forEach(a=>{s+=`- ${a}
|
|
783
|
-
`}),s+=`
|
|
784
|
-
`),t.decisions.length>0&&(s+=`### Key Decisions
|
|
785
|
-
`,t.decisions.forEach(a=>{s+=`- ${a}
|
|
786
|
-
`}),s+=`
|
|
787
|
-
`),t.consequences.length>0&&(s+=`### Consequences & Evolutions
|
|
788
|
-
`,t.consequences.forEach(a=>{s+=`- ${a}
|
|
789
|
-
`}),s+=`
|
|
790
|
-
`),t.recommendations.length>0&&(s+=`### Strategic Recommendations
|
|
791
|
-
`,t.recommendations.forEach(a=>{s+=`- ${a}
|
|
792
|
-
`}),s+=`
|
|
793
|
-
`),t.unclassified.length>0&&(s+=`### Additional Notes
|
|
794
|
-
`,t.unclassified.forEach(a=>{s+=`- ${a}
|
|
795
|
-
`}),s+=`
|
|
796
|
-
`),s+=`
|
|
975
|
+
`).run(e.sourceRepo,e.sourceFilePath,e.sourceSymbolId||null,e.targetRepo,e.targetFilePath,e.targetSymbolId||null,e.relationship,e.metadata?JSON.stringify(e.metadata):null,e.confidence??1).lastInsertRowid}scanEdges(){return ad.info({name:this.connection.nameValue},"Starting edge scan"),Ja(this)}getAttachedRepos(){return this.connection.getAttachedRepos()}get name(){return this.connection.nameValue}};var Ya=S.child({module:"fused-index"}),Us=class{connection;service;configName;constructor(e){this.configName=e.name,this.connection=new Ai(e),this.service=new Pi(this.connection)}attachRepo(e){this.connection.attachRepo(e)}detachRepo(e){this.connection.detachRepo(e)}refreshRepo(e){this.connection.refreshRepo(e)}getAttachedRepos(){return this.connection.getAttachedRepos()}checkHealth(){return this.connection.checkHealth()}close(){this.connection.close(),Ya.info({name:this.configName},"Fused index closed")}getStatus(){let e=this.service.executeRawQuery("SELECT COUNT(*) as count FROM virtual_edges");return{name:this.connection.nameValue,path:this.connection.dbPath,attachedRepos:this.connection.getAttachedRepos().length,repos:this.connection.getAttachedRepos(),virtualEdgesCount:e[0]?.count||0}}searchExports(e,t=50){return this.service.searchExports(e,t)}searchFiles(e,t=50){return this.service.searchFiles(e,t)}getVirtualEdges(e,t){return this.service.getVirtualEdges(e,t)}addVirtualEdge(e){return this.service.addVirtualEdge(e)}scanEdges(){return this.service.scanEdges()}buildUnionQuery(e,t,n){return this.service.buildUnionQuery(e,t,n)}executeFederatedQuery(e,...t){return this.service.executeFederatedQuery(e,...t)}executeRawQuery(e,...t){return this.service.executeRawQuery(e,...t)}buildAdvancedQuery(e){return this.service.buildAdvancedQuery(e)}buildFtsQuery(e,t,n,i,r){return this.service.buildFtsQuery(e,t,n,i,r)}buildCrossRepoImportsQuery(){return this.service.buildCrossRepoImportsQuery()}refreshAll(){this.connection.refreshAll()}validateSchemas(){return Ya.debug({name:this.configName},"Delegating validateSchemas"),this.connection.validateSchemas()}},zs=new Map;function Ka(s){let e=zs.get(s.name);if(e){let n=new Set(e.getAttachedRepos().map(o=>o.repoPath)),i=new Set(s.repoPaths.map(o=>cd.resolve(o)));if(n.size===i.size&&[...n].every(o=>i.has(o)))return e;e.close(),zs.delete(s.name)}let t=new Us(s);return zs.set(s.name,t),t}q();var ld=S.child({module:"mcp:tools:workspace:fuse"});async function Qa(s){let{repoPaths:e,name:t}=s;ld.info({repoCount:e.length,name:t},"Creating fused workspace index");try{let n=Ka({repoPaths:e,name:t||`workspace-${Date.now()}`});return{content:[{type:"text",text:JSON.stringify({message:"Fused index created",status:n.getStatus()},null,2)}]}}catch(n){throw new Error(`Failed to fuse: ${n.message}`)}}import Mi from"path";async function Xa(s){let[e,...t]=s;if(!e||!["missions","link","fuse"].includes(e)){console.log(""),console.log(` ${y.bold("Usage: ")} liquid-shadow workspace <missions|link> [options]`),console.log(""),console.log(` ${y.bold("Commands: ")}`),console.log(` ${y.cyan("missions")} <paths...> Get unified view of missions across repositories`),console.log(` ${y.cyan("link")} <args...> Link missions across repositories`),console.log(` ${y.cyan("fuse")} <paths...> Create fused index for cross-repo search (use --name for custom name)`),console.log(""),console.log(` ${y.bold("Examples: ")}`),console.log(" liquid-shadow workspace missions /frontend /backend"),console.log(" liquid-shadow workspace link /frontend 5 /backend 12"),console.log(" liquid-shadow workspace fuse /frontend /backend --name my-app"),console.log("");return}await Y(async()=>{switch(e){case"missions":{if(t.length===0){console.error(` ${y.red("\u2716")} Please provide at least one repository path`);return}let n=t.map(r=>Mi.resolve(r)),i=await ja({repoPaths:n});if(console.log(""),console.log(` ${y.bold("Workspace Missions")}`),console.log(""),i.content&&i.content[0]){let r=JSON.parse(i.content[0].text);r.missions&&r.missions.length>0?r.missions.forEach(o=>{console.log(` ${y.cyan("\u2022")} ${y.bold(o.name)} (ID: ${o.id})`),console.log(` ${y.dim("Repo: ")} ${o.repo_path}`),console.log(` ${y.dim("Status: ")} ${o.status}`),console.log(` ${y.dim("Branch: ")} ${o.git_branch||"N/A"}`),o.cross_repo_links&&o.cross_repo_links.length>0&&console.log(` ${y.dim("Links: ")} ${o.cross_repo_links.length} cross-repo link(s)`),console.log("")}):(console.log(` ${y.yellow("\u26A0")} No missions found`),console.log(""))}break}case"link":{if(t.length<4){console.error(""),console.error(` ${y.red("\u2716")} Usage: workspace link <parent-repo> <parent-id> <child-repo> <child-id> [relationship]`),console.error("");return}let[n,i,r,o,a]=t;await Ba({parentRepoPath:Mi.resolve(n),parentMissionId:parseInt(i,10),childRepoPath:Mi.resolve(r),childMissionId:parseInt(o,10),relationship:a}),console.log(""),console.log(` ${y.green("\u2714")} ${y.bold("Missions linked successfully")}`),console.log(` ${y.dim("Parent: ")} ${n} (Mission ${i})`),console.log(` ${y.dim("Child: ")} ${r} (Mission ${o})`),a&&console.log(` ${y.dim("Relationship: ")} ${a}`),console.log("");break}case"fuse":{if(t.length===0){console.error(` ${y.red("\u2716")} Please provide at least one repository path`);return}let n,i=[];for(let o=0;o<t.length;o++)t[o]==="--name"&&o+1<t.length?(n=t[o+1],o++):i.push(Mi.resolve(t[o]));let r=await Qa({repoPaths:i,name:n});if(console.log(""),console.log(` ${y.green("\u2714")} ${y.bold("Fused Index Created")}`),r.content&&r.content[0]){let o=JSON.parse(r.content[0].text);console.log(` ${y.dim("Name: ")} ${o.fused_index.name}`),console.log(` ${y.dim("Path: ")} ${o.fused_index.path}`),console.log(` ${y.dim("Repos: ")} ${o.fused_index.attachedRepos}`),console.log(""),console.log(` ${y.bold("Instructions:")}`),console.log(` ${o.instructions}`)}console.log("");break}}})}q();q();var pd=S.child({module:"strategy-normalizer"}),Ie=class{static normalize(e){if(!e)return{steps:[]};let t;if(typeof e=="string")try{t=JSON.parse(e)}catch(i){return pd.warn({strategyInput:e,err:i},"Failed to parse strategy JSON"),{steps:[]}}else t=e;return{steps:this.normalizeSteps(t)}}static normalizeSteps(e){return Array.isArray(e)?e.map((t,n)=>typeof t=="string"?{id:`step-${n}`,description:t,status:"pending"}:typeof t=="object"&&t!==null?{id:t.id||`step-${n}`,description:t.description||t.content||t.name||`Step ${n+1}`,status:t.status||"pending",dependencies:t.dependencies||t.deps,verification:t.verification,...t}:{id:`step-${n}`,description:String(t),status:"pending"}):e.steps&&Array.isArray(e.steps)?this.normalizeSteps(e.steps):typeof e=="object"?Object.entries(e).map(([t,n],i)=>typeof n=="string"?{id:t,description:n,status:"pending"}:typeof n=="object"&&n!==null?{id:t,description:n.description||n.content||n.name||t,status:n.status||"pending",dependencies:n.dependencies||n.deps,verification:n.verification,...n}:{id:t||`step-${i}`,description:String(n),status:"pending"}):[]}static stringify(e){return JSON.stringify(e,null,2)}static validate(e){let t=[];if(!e)return{valid:!0,errors:[]};try{let n=this.normalize(e),i=new Set;for(let r of n.steps)if(i.has(r.id)&&t.push(`Duplicate step ID: ${r.id}`),i.add(r.id),r.dependencies)for(let o of r.dependencies)i.has(o)||t.push(`Step "${r.id}" depends on non-existent step "${o}"`);return{valid:t.length===0,errors:t}}catch(n){return t.push(`Strategy validation failed: ${n instanceof Error?n.message:String(n)}`),{valid:!1,errors:t}}}};q();import js from"fs";import Za from"path";import ud from"os";var dd=[{id:"step-0",description:"Analyze impact: identify dependents and call sites",status:"pending"},{id:"step-1",description:"Implement refactor and update call sites",status:"pending"},{id:"step-2",description:"Run tests and verify behavior; update docs if needed",status:"pending"}],md=[{id:"step-0",description:"Capture requirements and acceptance criteria",status:"pending"},{id:"step-1",description:"Implement feature with tests",status:"pending"},{id:"step-2",description:"Integrate and verify end-to-end",status:"pending"}],hd=[{id:"step-0",description:"Reproduce the bug and document steps",status:"pending"},{id:"step-1",description:"Diagnose root cause and plan fix",status:"pending"},{id:"step-2",description:"Apply fix and add/update regression test",status:"pending"},{id:"step-3",description:"Verify fix and run full test suite",status:"pending"}],ec=[{id:"refactoring",name:"Refactoring",description:"Impact analysis \u2192 implementation \u2192 verification",defaultGoal:"Refactor {{target}} safely with full impact analysis and verification.",steps:dd},{id:"feature",name:"Feature",description:"Requirements \u2192 implementation \u2192 testing",defaultGoal:"Implement {{target}} with clear requirements and end-to-end verification.",steps:md},{id:"bug-fix",name:"Bug fix",description:"Reproduction \u2192 diagnosis \u2192 fix \u2192 regression test",defaultGoal:"Fix {{target}}: reproduce, diagnose, fix, and add regression test.",steps:hd}],Bs=new Map(ec.map(s=>[s.id,s])),Ni=!1;function fd(){if(Ni)return;let s=Za.join(ud.homedir(),".shadow","templates");if(!js.existsSync(s)){S.debug({templatesDir:s},"Custom templates directory does not exist"),Ni=!0;return}try{let e=js.readdirSync(s).filter(t=>t.endsWith(".json"));for(let t of e)try{let n=Za.join(s,t),i=js.readFileSync(n,"utf8"),r=JSON.parse(i);if(!r.id||!r.name||!r.defaultGoal||!r.steps){S.warn({file:t,template:r},"Invalid custom template structure - skipping");continue}if(!Array.isArray(r.steps)||r.steps.length===0){S.warn({file:t},"Template has no steps - skipping");continue}if(ec.some(o=>o.id===r.id)){S.warn({file:t,templateId:r.id},"Custom template ID conflicts with built-in - skipping");continue}Bs.set(r.id,r),S.info({file:t,templateId:r.id},"Loaded custom template")}catch(n){S.warn({file:t,error:n},"Failed to load custom template")}Ni=!0}catch(e){S.warn({error:e,templatesDir:s},"Failed to read custom templates directory"),Ni=!0}}function gd(s){return fd(),Bs.get(s)}function yd(s,e){let t=s;for(let[n,i]of Object.entries(e))t=t.replace(new RegExp(`\\{\\{${n}\\}\\}`,"g"),i);return t}function tc(s,e,t={}){let n=gd(s);if(!n)throw new Error(`Unknown template: ${s}. Use one of: ${Array.from(Bs.keys()).join(", ")}`);let i=t.target||"scope",r=e||(s==="refactoring"?`Refactor ${i}`:s==="feature"?`Feature: ${i}`:`Fix: ${i}`),o=yd(n.defaultGoal,{...t,target:i}),a=Ie.normalize({steps:n.steps}),c=Ie.stringify(a);return{name:r,goal:o,strategy:c}}V();gn();var En=S.child({module:"mcp:tools:ops:plan"}),bd=["name","goal","strategy","parentId","outcomeContract"],_d="Mission update requires at least one updatable field: name, goal, strategy, parentId, outcomeContract.",Ed="Mission requires name and goal (or templateId with optional templateVars).";async function nc(s){let{repoPath:e,name:t,goal:n,strategy:i,missionId:r,parentId:o,outcomeContract:a,templateId:c,templateVars:l}=s,{missions:p}=O.getInstance(e),u=me(e),d=De(e);En.info({repoPath:e,name:t,missionId:r,templateId:c},"Planning mission");try{let h=t,m=n,f=i;if(!r&&c){let b=tc(c,t,l||{});h=h??b.name,m=m??b.goal,f=f??b.strategy}let _,g;if(r){let b=p.findById(r);if(!b)throw new Error(`Mission ${r} not found.`);let w;if(i!==void 0)if(i){let R=Ie.normalize(i);w=Ie.stringify(R);let k=Ie.validate(w);k.valid||En.warn({errors:k.errors,strategy:i},"Strategy validation warnings detected")}else w=null;let x={commit_sha:d};if(t!==void 0&&(x.name=t),n!==void 0&&(x.goal=n),w!==void 0&&(x.strategy_graph=w),o!==void 0&&(x.parent_id=o),a!==void 0&&(x.outcome_contract=a),Object.keys(x).length===1)throw new Error(_d);p.update(r,{...x}),_=r,g=`Mission "${t??b.name}" updated.`}else{if(!h||!m)throw new Error(Ed);let b=null;if(f){let w=Ie.normalize(f);b=Ie.stringify(w);let x=Ie.validate(b);x.valid||En.warn({errors:x.errors,strategy:f},"Strategy validation warnings detected")}_=p.create({name:h,goal:m,strategy_graph:b,status:"planned",git_branch:u,commit_sha:d,parent_id:o||null,verification_context:null,outcome_contract:a||null}),g=`Mission "${h}" planned.`}try{await new Fe(e).syncMissionToGitNotes(Number(_))}catch(b){En.info({missionId:_,...ye(b)},"Git Notes sync deferred")}return{content:[{type:"text",text:JSON.stringify({missionId:_,status:"planned",message:g,strategy_saved:!!f,contract_saved:!!a,updateable_fields:bd,from_template:c??void 0,commit:d},null,2)}]}}catch(h){let m=At(h);throw En.error({repoPath:e,...ye(h)},"Failed to plan mission"),new Error(`Failed to plan mission: ${m}`)}}q();V();var Di=class s{constructor(e){this.intentLogs=e}static RECENCY_HALF_LIFE_HOURS=48;static WEIGHTS={recency:.4,activity:.3,statusBoost:.2,blockerBoost:.1};score(e){if(e.length===0)return[];let t=Math.floor(Date.now()/1e3),n=e.map(c=>c.id),i=this.intentLogs.countByMissions(n),r=this.intentLogs.findMissionsWithBlockers(n),o=Math.max(1,...Object.values(i));return e.map(c=>{let l=this.computeRecency(c.updated_at,t),p=(i[c.id]||0)/o,u=this.computeStatusBoost(c.status),d=r.has(c.id)?1:0,h=s.WEIGHTS,m=l*h.recency+p*h.activity+u*h.statusBoost+d*h.blockerBoost;return{mission:c,score:Math.round(m*1e3)/1e3,breakdown:{recency:Math.round(l*1e3)/1e3,activity:Math.round(p*1e3)/1e3,blockerBoost:d,statusBoost:u}}}).sort((c,l)=>l.score-c.score)}computeRecency(e,t){let n=Math.max(0,(t-e)/3600);return Math.pow(.5,n/s.RECENCY_HALF_LIFE_HOURS)}computeStatusBoost(e){switch(e){case"in-progress":return 1;case"verifying":return .8;case"planned":return .4;default:return 0}}};V();q();var Sd=S.child({module:"collision-service"}),Oi=class{repoPath;constructor(e){this.repoPath=e}async analyzePotentialCollisions(){let e=me(this.repoPath);if(!e)return[];let{missions:t,intentLogs:n}=O.getInstance(this.repoPath),i=t.findActive().filter(a=>a.git_branch&&a.git_branch!==e),r=[],o=new Set;for(let a of i){let c=a.git_branch;if(o.has(c))continue;o.add(c),Sd.info({branch:c,currentBranch:e},"Checking predictive collisions"),wo(this.repoPath,e,c)&&r.push({branch:c,type:"file",description:`Background merge-tree detected a file-level conflict between '${e}' and '${c}'.`});let p=t.findActive(e),u=new Set;for(let m of p)t.getWorkingSet(m.id).forEach(f=>u.add(f.file_path));let h=t.getWorkingSet(a.id).filter(m=>u.has(m.file_path));h.length>0&&r.push({branch:c,type:"intent",description:`Logical conflict: Mission '${a.name}' on '${c}' is modifying files you are currently working on.`,conflictingFiles:h.map(m=>m.file_path)})}return r}};var Fi=class{constructor(e){this.repoPath=e}async getBriefing(e={}){let{missionId:t,scope:n="mission",altitude:i,activeMissionsLimit:r,recentActivityLimit:o,compact:a}=e,c=a??(i==="orbit"||i==="atmosphere"),l=o??(i==="orbit"?0:i==="ground"?20:10),{missions:p,intentLogs:u}=O.getInstance(this.repoPath),d=De(this.repoPath),h=me(this.repoPath);return n==="project"?this.getProjectBriefing({altitude:i,activeMissionsLimit:r,recentActivityLimit:l,compact:c,currentBranch:h,currentCommit:d}):this.getMissionBriefing({missionId:t,altitude:i,recentActivityLimit:l,currentBranch:h,currentCommit:d})}async getProjectBriefing(e){let{repoPath:t}=this,{missions:n,intentLogs:i}=O.getInstance(t),{altitude:r,activeMissionsLimit:o,recentActivityLimit:a,compact:c,currentBranch:l,currentCommit:p}=e,u=n.findActive(l||void 0),d=u.length;o&&u.length>o&&(u=u.slice(0,o));let h=n.findParentOnlyIds(u),m=new Set(h),f=u.filter(N=>!m.has(N.id)),g=new Di(i).score(f),b=.15,w=3,x=c&&g.length>w?g.filter((N,$)=>$<w||N.score>=b):g,R=x.map(N=>N.mission),k=new Map(x.map(N=>[N.mission.id,N.score])),D=N=>({id:N.id,name:N.name,goal:N.goal,status:N.status,relevance:k.get(N.id)});if(r==="orbit")return{scope:"project",altitude:"orbit",counts:n.getStats(),next_work_candidates:R.map(D),meta:{current_branch:l,activeMissionsTotal:d,ember:this.getEmberLabel(t)}};let U={},P=[];for(let N of u)N.parent_id!=null?(U[N.parent_id]||(U[N.parent_id]=[]),U[N.parent_id].push(N)):P.push(N);let E=n.findRecentCompleted(5).map(D),T=a>0?i.findRecentDecisionActivity(a):void 0,I=h.map(N=>{let $=u.find(L=>L.id===N);return{parent:c?{...$,strategy_graph:void 0,verification_context:void 0}:$,children:U[N]??[]}}),M=P.filter(N=>!m.has(N.id));return{scope:"project",altitude:r||"atmosphere",counts:n.getStats(),analytics:n.getAnalytics(),hierarchy:I.length>0?I:void 0,standalone_active:M.length>0?M:void 0,active_missions:I.length===0?c?u.map(N=>({...N,strategy_graph:void 0})):u:void 0,next_work_candidates:R.map(D),recent_completed:E,recent_activity:T,meta:{current_branch:l,current_commit:p,activeMissionsTotal:d,active_limit_applied:!!o,relevance_filtered:x.length<g.length?{shown:x.length,total:g.length}:void 0,ember:this.getEmberLabel(t)}}}getEmberLabel(e){try{let{status:t,progress:n}=yi(e);if(t==="idle")return;if(t==="done")return"symbols: fully embedded";let[i,r]=n.split("/").map(Number),o=r>0?Math.round(i/r*100):0;return t==="running"?`symbols: warming ${n} (${o}%)`:`symbols: ${t} ${n}`}catch{return}}async getMissionBriefing(e){let{repoPath:t}=this,{missions:n,intentLogs:i}=O.getInstance(t),{missionId:r,altitude:o,recentActivityLimit:a,currentBranch:c,currentCommit:l}=e,p;if(r?p=n.findById(r):p=n.findActive(c||void 0)[0],!p)return null;let u=null;try{p.strategy_graph&&(u=JSON.parse(p.strategy_graph))}catch{}if(o==="orbit")return{altitude:"orbit",mission:{id:p.id,name:p.name,goal:p.goal,status:p.status,last_updated:new Date(p.updated_at*1e3).toISOString()},strategy_snapshot:u};let d="No external shadow changes detected.";try{new qt(t).analyzeGhostChanges(p.commit_sha||void 0),d="Shadow Trace completed: Checked for external modifications."}catch{}let h={repaired:0,failed:0};try{h=new qe(t).detectAndRepairShifts()}catch{}let m=n.getHandoffs(p.id).map(_=>{let g=null;try{g=JSON.parse(_.metadata??"")}catch{}return{artifactId:_.id,kind:_.identifier,confidence:g?.confidence??null,findingsCount:g?.findings?.length??0,risksCount:g?.risks?.length??0,missionsCreated:g?.missionsCreated??[],createdAt:_.created_at}}),f={altitude:o||"atmosphere",mission:{id:p.id,name:p.name,goal:p.goal,status:p.status,last_updated:new Date(p.updated_at*1e3).toISOString(),git_branch:p.git_branch,commit_sha:p.commit_sha,outcome_contract:p.outcome_contract},artifacts:n.getArtifacts(p.id),handoffs:m,shadow_trace:{ghost_analysis:d,symbols_repaired:h.repaired,symbols_missing:h.failed},context:{current_commit:l,working_set:n.getWorkingSet(p.id).map(_=>_.file_path)},strategy_snapshot:u,recent_activity:o==="ground"?i.findByMission(p.id,a||20):i.findByMissionPreferCrystal(p.id,15),ancestor_activity_summary:[],predictive_collisions:[]};try{let _=new Oi(t);f.predictive_collisions=await _.analyzePotentialCollisions()}catch{}if(p.parent_id){let _=o==="ground"?i.findByMission(p.parent_id,5):i.findByMissionPreferCrystal(p.parent_id,3);f.ancestor_activity_summary=_.map(g=>({type:g.type,content:g.content,date:new Date(g.created_at*1e3).toISOString()}))}return f}};var ic=S.child({module:"mcp:tools:ops:briefing"});async function sc(s){let{repoPath:e,scope:t="mission"}=s;ic.info({repoPath:e,missionId:s.missionId,scope:t},"Generating briefing");try{let i=await new Fi(e).getBriefing(s);if(!i&&t==="mission")return{content:[{type:"text",text:"No active missions found. Ready for new assignment."}]};let r;if(t==="project"){let o=i.counts;r=i.next_work_candidates.length===0&&o.active===0?{tool:"shadow_ops_plan",reason:"No open work; create a mission"}:{tool:"shadow_ops_track",reason:"Select a mission from hierarchy or next_work_candidates to execute"}}return{content:[{type:"text",text:JSON.stringify(i,null,2)}],suggestedNext:r}}catch(n){throw ic.error({error:n,repoPath:e},"Failed to generate briefing"),new Error(`Failed to generate briefing: ${n instanceof Error?n.message:String(n)}`)}}q();V();V();q();q();var wd=S.child({module:"reasoning-engine"}),Wi=class{analyze(e){wd.debug({logCount:e.length},"Performing reasoning pass over intent logs");let t={context:[],decisions:[],consequences:[],recommendations:[],unclassified:[],sourceMissions:[]};for(let i of e){let r=i.content.toLowerCase(),o=this.matchesContext(r,i.type),a=this.matchesDecision(r,i.type),c=this.matchesConsequence(r,i.type),l=this.matchesRecommendation(r,i.type);o?t.context.push(i.content):a?t.decisions.push(i.content):l?t.recommendations.push(i.content):c?t.consequences.push(i.content):i.type==="decision"?t.decisions.push(i.content):i.type==="discovery"||i.type==="fix"?t.consequences.push(i.content):t.unclassified.push(i.content)}let n=new Set;for(let i of e)i.mission_id!=null&&n.add(i.mission_id);return t.sourceMissions=[...n],t}matchesContext(e,t){return["because","since","given","due to","context: ","problem: ","situation:"].some(i=>e.includes(i))||t==="blocker"}matchesDecision(e,t){return["decided","chose","implemented","integrated","using","selected","strategy:"].some(i=>e.includes(i))||t==="decision"}matchesConsequence(e,t){return["results in","enables","allows","impact: ","consequence: ","next steps: ","meaning"].some(i=>e.includes(i))||t==="fix"}matchesRecommendation(e,t){return["should","recommend","suggest","next work","future","consider","strategy advice"].some(i=>e.includes(i))}};var Hi=S.child({module:"briefing-engine"}),tt=class{intentLogs;missions;reasoningEngine;persistencePivot;constructor(e){let{intentLogs:t,missions:n}=O.getInstance(e);this.intentLogs=t,this.missions=n,this.reasoningEngine=new Wi,this.persistencePivot=new Fe(e)}async distillMission(e,t=!0){Hi.info({missionId:e},"Synthesizing mission intelligence into Tactical Briefing...");let n=this.gatherConsolidatedLogs(e);if(n.length===0)return{missionId:e,adr:"No intent logs found for this mission.",metrics:{totalLogs:0,symbolCount:0}};let i=this.reasoningEngine.analyze(n),r=new Set(n.map(a=>a.symbol_name).filter(Boolean)),o=`# Architectural Decision Record: Mission #${e}
|
|
976
|
+
|
|
977
|
+
`;if(o+=`## Summary of Intent
|
|
978
|
+
`,o+=`Collected ${n.length} intent events across ${r.size} symbols.
|
|
979
|
+
|
|
980
|
+
`,i.context.length>0&&(o+=`### Context
|
|
981
|
+
`,i.context.forEach(a=>{o+=`- ${a}
|
|
982
|
+
`}),o+=`
|
|
983
|
+
`),i.decisions.length>0&&(o+=`### Key Decisions
|
|
984
|
+
`,i.decisions.forEach(a=>{o+=`- ${a}
|
|
985
|
+
`}),o+=`
|
|
986
|
+
`),i.consequences.length>0&&(o+=`### Consequences & Evolutions
|
|
987
|
+
`,i.consequences.forEach(a=>{o+=`- ${a}
|
|
988
|
+
`}),o+=`
|
|
989
|
+
`),i.recommendations.length>0&&(o+=`### Strategic Recommendations
|
|
990
|
+
`,i.recommendations.forEach(a=>{o+=`- ${a}
|
|
991
|
+
`}),o+=`
|
|
992
|
+
`),i.unclassified.length>0&&(o+=`### Additional Notes
|
|
993
|
+
`,i.unclassified.forEach(a=>{o+=`- ${a}
|
|
994
|
+
`}),o+=`
|
|
995
|
+
`),o+=`
|
|
797
996
|
---
|
|
798
|
-
*Generated by Liquid Shadow Reasoning Engine v1*`,r){this.intentLogs.create({mission_id:e,type:"adr",content:s,confidence:1,symbol_id:null,file_path:null,symbol_name:null,signature:null,commit_sha:null});try{await this.persistencePivot.syncMissionToGitNotes(e),Ha.info({missionId:e},"Tactical Briefing synthesized, archived, and synced to Git Notes.")}catch(a){Ha.error({missionId:e,error:a},"Failed to sync ADR to Git Notes")}}else Ha.info({missionId:e},"Tactical Briefing synthesized (dry-run).");return{missionId:e,adr:s,metrics:{totalLogs:i.length,symbolCount:o.size}}}gatherConsolidatedLogs(e,r=0){let i=this.intentLogs.findByMissionPreferCrystal(e,500);if(r>2)return i;let t=this.missions.findByParentId(e);for(let o of t)i.push(...this.gatherConsolidatedLogs(o.id,r+1));return i.filter(o=>o.type!=="adr"&&o.type!=="system")}};J();import{Visitor as rE}from"@swc/core/Visitor.js";import*as Zv from"@swc/core";var iE=$.child({module:"verification-engine"}),Ym=class extends rE{foundUsage=!1;foundImport=!1;rule;currentFunctionName=null;constructor(e){super(),this.rule=e}visitImportDeclaration(e){return this.rule.type==="import"&&e.source.value===this.rule.target&&(this.foundImport=!0),super.visitImportDeclaration(e)}visitFunctionDeclaration(e){let r=this.currentFunctionName;this.currentFunctionName=e.identifier.value;let i=super.visitFunctionDeclaration(e);return this.currentFunctionName=r,i}visitCallExpression(e){return this.rule.type==="usage"&&e.callee.type==="Identifier"&&e.callee.value===this.rule.target&&(!this.rule.context||this.currentFunctionName===this.rule.context)&&(this.foundUsage=!0),super.visitCallExpression(e)}},Wa=class{async verify(e,r){try{let i=await Zv.parse(e,{syntax:"typescript",tsx:!0,comments:!1}),t=new Ym(r);t.visitProgram(i);let o=!1,s=[];if(r.type==="import")o=t.foundImport,o||s.push(`Required import "${r.target}" not found.`);else if(r.type==="usage"){if(o=t.foundUsage,!o){let a=r.context?` in function "${r.context}"`:"";s.push(`Required usage of "${r.target}"${a} not found.`)}}else r.type==="pattern"&&(o=new RegExp(r.target).test(e),o||s.push(`Required pattern "${r.target}" not found.`));return{passed:o,errors:s}}catch(i){return iE.error({error:i},"Verification failed due to parse error"),{passed:!1,errors:[`Parse error: ${i.message}`]}}}};import Hv from"path";import Ba from"fs";var lt=$.child({module:"mcp:tools:ops:track"});async function Wv(n,e,r){let{missions:i,intentLogs:t}=L.getInstance(n),o=i.findById(e);if(!o?.parent_id)return;let s=i.findByParentId(o.parent_id);if(!s.every(l=>l.status==="completed"))return;let c=i.findById(o.parent_id);if(!(!c||c.status==="completed")){lt.info({parentId:c.id,childCount:s.length},"All children completed \u2014 cascading parent completion"),i.updateStatus(c.id,"completed",r||void 0),i.clearWorkingSet(c.id),t.create({mission_id:c.id,type:"system",content:`Parent auto-completed: all ${s.length} child missions finished`,confidence:1,symbol_id:null,file_path:null,symbol_name:null,signature:null,commit_sha:r});try{await new Tt(n).distillMission(c.id),lt.info({parentId:c.id},"Parent Auto-Synthesis completed")}catch(l){lt.warn({synthesisError:l,parentId:c.id},"Parent Auto-Synthesis deferred")}try{await new ct(n).syncMissionToGitNotes(c.id)}catch(l){lt.warn({syncError:l,parentId:c.id},"Parent Git Notes sync deferred")}await Wv(n,c.id,r)}}async function Ga(n){let{repoPath:e,missionId:r,stepId:i,status:t,contextPivot:o,updates:s,artifacts:a}=n,{missions:c,intentLogs:l}=L.getInstance(e),u=it(e);lt.info({repoPath:e,missionId:r,singleStep:i,batchCount:s?.length,artifactCount:a?.length},"Updating mission status");try{if(a&&Array.isArray(a))for(let f of a)c.addArtifact(r,f.type,f.identifier,f.metadata);let d=[];if(s&&Array.isArray(s)&&d.push(...s),i&&t&&d.push({stepId:i,status:t,contextPivot:o}),t&&!i){if(c.updateStatus(r,t,u||void 0),t==="completed"&&c.clearWorkingSet(r),l.create({mission_id:r,type:"system",content:`Mission status changed to "${t}"`,confidence:1,symbol_id:null,file_path:null,symbol_name:null,signature:null,commit_sha:u}),t==="completed"){try{await new Tt(e).distillMission(r),lt.info({missionId:r},"Auto-Synthesis completed successfully")}catch(f){lt.warn({synthesisError:f,missionId:r},"Auto-Synthesis deferred or failed")}await Wv(e,r,u)}if(!d.length)return{content:[{type:"text",text:JSON.stringify({missionId:r,status:t,message:"Mission status updated successfully.",artifacts_added:a?.length||0,commit:u},null,2)}]}}if(d.length===0&&(!a||a.length===0))throw new Error("No updates provided. Must specify either 'updates', 'stepId'/'status', 'status' (top-level), or 'artifacts'.");let p=[];for(let f of d){let{stepId:m,status:h,contextPivot:v}=f,b=c.findById(r);if(!b)throw new Error(`Mission ID ${r} not found`);let g=JSON.parse(b.strategy_graph||"{}"),x=null;if(Array.isArray(g)?x=g.find(S=>S.id===m):g.nodes&&Array.isArray(g.nodes)?x=g.nodes.find(S=>S.id===m):g.steps?Array.isArray(g.steps)?x=g.steps.find(S=>S.id===m):x=g.steps[m]:g[m]&&(x=g[m]),!x)throw new Error(`Step ID "${m}" not found`);if(h==="completed"&&x.verification){let S=new Wa,E=Array.isArray(x.verification)?x.verification:[x.verification];for(let w of E){let z=w;if(typeof w=="string"&&(z={type:"pattern",target:w}),!z||!z.target){lt.warn({rule:w},"Skipping invalid verification rule (missing target)");continue}let R=z.filePath;if(R&&!Hv.isAbsolute(R)&&(R=Hv.join(e,R)),R){if(!Ba.existsSync(R))throw new Error(`Verification failed: File not found at ${R}`);let U=await S.verify(Ba.readFileSync(R,"utf8"),z);if(!U.passed)throw new Error(`Verification failed: ${U.errors.join("")}`)}else{let U=c.getWorkingSet(r),I=!1;U.length===0&<.warn("No working set files to verify against for rule");for(let T of U){if(!Ba.existsSync(T.file_path))continue;if((await S.verify(Ba.readFileSync(T.file_path,"utf8"),z)).passed){I=!0;break}}if(!I)throw new Error(`Verification failed: Rule "${z.target}" not satisfied in any working set file.`)}}}if(x.status=h,c.update(r,{strategy_graph:JSON.stringify(g),commit_sha:u}),l.create({mission_id:r,type:"system",content:`Step "${m}" updated to "${h}"`,confidence:1,symbol_id:null,file_path:null,symbol_name:null,signature:null,commit_sha:u}),v)try{let S=JSON.parse(v);if(c.clearWorkingSet(r),S.files&&Array.isArray(S.files))for(let E of S.files)c.addToWorkingSet(r,E)}catch(S){lt.warn({error:S},"Failed to apply context pivot")}p.push({stepId:m,status:h})}try{await new ct(e).syncMissionToGitNotes(r)}catch(f){lt.warn({syncError:f,missionId:r},"Git Notes sync deferred")}return{content:[{type:"text",text:JSON.stringify({missionId:r,updates:p,artifacts_added:a?.length||0,message:"Status updated",commit:u},null,2)}]}}catch(d){throw lt.error({error:d,repoPath:e},"Failed to update status"),new Error(`Failed to update status: ${d instanceof Error?d.message:String(d)}`)}}J();var Bv=$.child({module:"mcp:tools:ops:briefing"});async function Ur(n){let{repoPath:e,scope:r="mission"}=n;Bv.info({repoPath:e,missionId:n.missionId,scope:r},"Generating briefing");try{let t=await new cr(e).getBriefing(n);if(!t&&r==="mission")return{content:[{type:"text",text:"No active missions found. Ready for new assignment."}]};let o;if(r==="project"){let s=t.counts;o=t.next_work_candidates.length===0&&s.active===0?{tool:"shadow_ops_plan",reason:"No open work; create a mission"}:{tool:"shadow_ops_track",reason:"Select a mission from hierarchy or next_work_candidates to execute"}}return{content:[{type:"text",text:JSON.stringify(t,null,2)}],suggestedNext:o}}catch(i){throw Bv.error({error:i,repoPath:e},"Failed to generate briefing"),new Error(`Failed to generate briefing: ${i instanceof Error?i.message:String(i)}`)}}X();J();var Gv=$.child({module:"mcp:tools:ops:synthesize"});async function Ja(n){let{repoPath:e,missionId:r}=n;Gv.info({repoPath:e,missionId:r},"Synthesizing mission");let{missions:i}=L.getInstance(e);try{if(!i.findById(r))throw new Error(`Mission ${r} not found`);let s=await new Tt(e).distillMission(r);return{content:[{type:"text",text:JSON.stringify({missionId:r,adr:s.adr,metrics:s.metrics},null,2)}]}}catch(t){throw Gv.error({error:t,repoPath:e},"Failed to synthesize ADR"),new Error(`Failed to synthesize ADR: ${t instanceof Error?t.message:String(t)}`)}}J();X();J();var oE=$.child({module:"narrative-service"}),Ft=class{missions;briefingEngine;repoPath;constructor(e){this.repoPath=e;let{missions:r}=L.getInstance(e);this.missions=r,this.briefingEngine=new Tt(e)}async generateChronicle(e={}){oE.info(e,"Generating Repo Chronicle...");let i=this.missions.findAll().filter(l=>l.parent_id===null&&l.status!=="planned");e.since&&(i=i.filter(l=>l.updated_at>=e.since)),e.until&&(i=i.filter(l=>l.updated_at<=e.until)),i.sort((l,u)=>u.updated_at-l.updated_at);let t=e.offset||0,o=e.limit||10;i=i.slice(t,t+o);let s=[],a=[],c=[];for(let l of i){let u=this.missions.findByParentId(l.id),d=u.length>0,p=await this.briefingEngine.distillMission(l.id,!1);if(d){let f=[];for(let h of u)f.push(await this.mapMissionToEpisode(h));f.unshift(await this.mapMissionToEpisode(l));let m={kind:"initiative",root_mission_id:l.id,title:l.name,strategy_graph:l.strategy_graph?JSON.parse(l.strategy_graph):{},episodes:e.compact?[]:f,synthesized_narrative:e.compact?this.truncateText(p.adr):p.adr||""};s.push(m),c.push(m)}else{let f=await this.mapMissionToEpisode(l,p.adr,e.compact);a.push(f),c.push(f)}}return{repo_path:this.repoPath,generated_at:Date.now(),initiatives:s,unattached_episodes:a,timeline:c}}async mapMissionToEpisode(e,r,i=!1){let t=r;return t||(t=(await this.briefingEngine.distillMission(e.id,!1)).adr),{kind:"episode",mission_id:e.id,title:e.name,goal:e.goal,outcome:e.outcome_contract,intents:[],adr_summary:i?this.truncateText(t):t}}truncateText(e,r=300){return e?e.length<=r?e:e.slice(0,r)+"... (truncated)":""}renderChronicleMarkdown(e){let r=`# Repository Chronicle
|
|
799
|
-
|
|
800
|
-
`;if(r+=`*Generated at ${new Date(e.generated_at).toISOString()}*
|
|
801
|
-
|
|
802
|
-
`,e.timeline&&e.timeline.length>0)for(let i of e.timeline)i.kind==="initiative"?(r+=`### \u{1F9EC} ${i.title} (Mission #${i.root_mission_id})
|
|
803
|
-
`,r+=`${i.synthesized_narrative}
|
|
804
|
-
|
|
805
|
-
`):(r+=`### \u269B\uFE0F ${i.title} (Mission #${i.mission_id})
|
|
806
|
-
`,r+=`${i.adr_summary}
|
|
807
|
-
|
|
808
|
-
`),r+=`---
|
|
809
|
-
`;return r}};var Jv=$.child({module:"mcp:tools:ops:chronicle"});async function qv(n){let{repoPath:e,format:r="markdown",...i}=n,t=new Ft(e);Jv.info({repoPath:e,format:r,filters:i},"Generating Chronicle");try{let o=await t.generateChronicle(i),s={tool:"shadow_ops_briefing",reason:"Current backlog and next work"};return r==="json"?{content:[{type:"text",text:JSON.stringify(o,null,2)}],suggestedNext:s}:{content:[{type:"text",text:t.renderChronicleMarkdown(o)}],suggestedNext:s}}catch(o){throw Jv.error({error:o,repoPath:e},"Failed to generate chronicle"),new Error(`Failed to generate chronicle: ${o instanceof Error?o.message:String(o)}`)}}Je();async function Vv(n){let{repoPath:e,compact:r=!0}=n,t=new pe(e).getSnapshot();r&&t.gravity?.hotspots&&(t={...t,gravity:{...t.gravity,hotspots:t.gravity.hotspots.slice(0,10),_truncated:t.gravity.hotspots.length>10,_totalHotspots:t.gravity.hotspots.length}});let a={...await new Ft(e).generateChronicle({limit:5,compact:r}),initiatives:[],unattached_episodes:[]},l=(await Ur({repoPath:e,scope:"project",altitude:r?"orbit":"atmosphere",compact:r,activeMissionsLimit:r?10:void 0,recentActivityLimit:r?5:10})).content?.[0],u=l&&l.type==="text"?l.text:"{}",d={};try{d=JSON.parse(u)}catch{}let p={counts:d.counts,next_work_candidates:d.next_work_candidates??[],active_count:Array.isArray(d.active_missions)?d.active_missions.length:0};return{content:[{type:"text",text:JSON.stringify({hologram:t,chronicle:a,briefing:p},null,2)}],suggestedNext:{tool:p.next_work_candidates.length>0?"shadow_ops_track":"shadow_ops_plan",reason:p.next_work_candidates.length>0?"Pick one from next_work_candidates and run /continue":"No open work; create a mission"}}}J();dt();import Xm from"path";var Kv=$.child({module:"mcp:tools:ops:health"});async function Yv(n){let e=n.repoPath,r=Xm.isAbsolute(e)?Xm.normalize(e):Xm.resolve(process.cwd(),e);Kv.info({repoPath:r},"Health check");let i=!1,t=!1;try{We(r),i=!0,t=Oe(r)}catch(c){Kv.debug({repoPath:r,error:c},"Health: DB check failed")}let o=wn(),s={status:i?t?"ready":"index_pending":"db_unavailable",database:i,indexed:t,metrics:{index:o.index,query:o.query,uptimeMs:o.uptimeMs}},a=t?{tool:"shadow_recon_hologram",reason:"Architecture overview"}:{tool:"shadow_recon_onboard",reason:"Index the repo first"};return{content:[{type:"text",text:JSON.stringify(s,null,2)}],suggestedNext:a}}X();J();var Bi=$.child({module:"mcp:tools:ops:log"});async function qa(n){let{repoPath:e,missionId:r,type:i,content:t,filePath:o,symbolName:s,standalone:a}=n;Bi.info({repoPath:e,type:i,symbolName:s,standalone:a},"Logging intent");let{missions:c,exports:l,intentLogs:u}=L.getInstance(e);try{let d=r??null;if(a){if(!s)throw new Error('Standalone intent logs must be anchored to a symbol. Please provide "symbolName".');d=null}else if(d){if(!c.findById(d))throw new Error(`Mission ${d} not found. Use shadow_ops_briefing to see available missions.`)}else{let v=c.findActive();v.length>0?(d=v.find(b=>b.status==="in-progress")?.id||v[0].id,Bi.debug({missionId:d},"Auto-resolved to active mission")):(d=null,Bi.debug("No active mission found, logging as system/unlinked intent"))}let p=null,f=null,m=s||null;if(s){let b=(o?l.findByNameAndFile(s,o):l.findByName(s))[0];b?(p=b.id,f=b.signature,m=b.name):Bi.warn({symbolName:s,filePath:o},"Symbol not found for intent linking")}let h=u.create({mission_id:d,symbol_id:p,file_path:o||null,type:i,content:t,confidence:1,symbol_name:m,signature:f,commit_sha:null});return{content:[{type:"text",text:JSON.stringify({logId:h,missionId:d,symbolId:p,status:"logged",message:p?`Intent linked to symbol "${s}"`:"Intent logged (unlinked)"},null,2)}]}}catch(d){throw Bi.error({error:d,repoPath:e},"Failed to log intent"),new Error(`Failed to log intent: ${d instanceof Error?d.message:String(d)}`)}}J();var e_=$.child({module:"mcp:tools:ops:graph"});async function Ka(n){let{repoPath:e,missionId:r,depth:i,limit:t,format:o="mermaid"}=n;e_.info({repoPath:e,missionId:r,format:o},"Generating mission graph");try{let{GraphExporterService:s}=await Promise.resolve().then(()=>(Qm(),Qv));return{content:[{type:"text",text:await new s(e).generateGraph({includeCompleted:!0,format:o,focusMissionId:r,depth:i,limit:t})}]}}catch(s){throw e_.error({error:s,repoPath:e},"Failed to generate mission graph"),new Error(`Failed to generate mission graph: ${s.message}`)}}X();J();var t_=$.child({module:"mcp:tools:ops:crystallize"});async function n_(n){let{repoPath:e,missionId:r,symbolId:i}=n;t_.info({repoPath:e,missionId:r,symbolId:i},"Crystallizing logs");let{intentLogs:t,missions:o,exports:s}=L.getInstance(e);if(typeof r=="number"){let a=o.findById(r);if(!a)throw new Error(`Mission ${r} not found`);let c=t.findRawByMission(r);if(c.length===0){let h=t.findCrystalByMission(r);return{content:[{type:"text",text:JSON.stringify({missionId:r,status:h?"already_crystallized":"no_logs",message:h?"Mission already has a crystal with no new raw logs to absorb.":"No raw intent logs found for this mission.",crystalId:h?.id??null},null,2)}]}}let u=new Hn().analyze(c),d=new Set(c.map(h=>h.symbol_name).filter(Boolean)),p=new Set(c.map(h=>h.type)),f=`[Crystal] Mission #${r}: ${a.name}
|
|
810
|
-
`;f+=`Compressed ${c.length} logs across ${d.size} symbols.
|
|
811
|
-
`,f+=`Types: ${[...p].join(", ")}
|
|
812
|
-
|
|
813
|
-
`,u.decisions.length>0&&(f+=`Decisions: ${u.decisions.join(" | ")}
|
|
814
|
-
`),u.context.length>0&&(f+=`Context: ${u.context.join(" | ")}
|
|
815
|
-
`),u.consequences.length>0&&(f+=`Consequences: ${u.consequences.join(" | ")}
|
|
816
|
-
`),u.recommendations.length>0&&(f+=`Recommendations: ${u.recommendations.join(" | ")}
|
|
817
|
-
`);let m=t.crystallize(r,f.trim());return t_.info({missionId:r,crystalId:m,absorbed:c.length},"Crystallization complete"),{content:[{type:"text",text:JSON.stringify({missionId:r,crystalId:m,absorbed:c.length,symbolsCompressed:d.size,status:"crystallized"},null,2)}]}}if(typeof i=="number"){let a=s.findHydratedById(i);if(!s.findById(i))throw new Error(`Symbol ${i} not found in index`);let l=t.findRawBySymbol(i);if(l.length===0)return{content:[{type:"text",text:JSON.stringify({symbolId:i,status:"no_logs",message:"No raw standalone intent logs found for this symbol."},null,2)}]};let d=new Hn().analyze(l),p=new Set(l.map(h=>h.type)),f=`[Crystal] Symbol #${i}: ${a?.name||"Unknown"}
|
|
818
|
-
`;f+=`Compressed ${l.length} standalone insights.
|
|
819
|
-
`,f+=`Types: ${[...p].join(", ")}
|
|
820
|
-
|
|
821
|
-
`,d.decisions.length>0&&(f+=`Decisions: ${d.decisions.join(" | ")}
|
|
822
|
-
`),d.context.length>0&&(f+=`Context: ${d.context.join(" | ")}
|
|
823
|
-
`);let m=t.crystallizeBySymbol(i,f.trim());return{content:[{type:"text",text:JSON.stringify({symbolId:i,crystalId:m,absorbed:l.length,status:"crystallized"},null,2)}]}}throw new Error("Must provide either missionId or symbolId to crystallize.")}J();X();import Ya from"path";var sE=$.child({module:"mcp:tools:ops:working-set-check"});async function r_(n){let{repoPath:e,filePaths:r}=n,{missions:i}=L.getInstance(e),t=i.findActive(),o=[];for(let s of t){let a=i.getWorkingSet(s.id);for(let c of a)if(r.includes(c.file_path))o.push({file_path:c.file_path,mission_id:s.id,mission_name:s.name});else{let l=Ya.isAbsolute(c.file_path)?c.file_path:Ya.join(e,c.file_path);for(let u of r){let d=Ya.isAbsolute(u)?u:Ya.join(e,u);if(l===d){o.push({file_path:c.file_path,mission_id:s.id,mission_name:s.name});break}}}}return sE.info({repoPath:e,conflictsCount:o.length},"Working set check completed"),{content:[{type:"text",text:JSON.stringify({conflicts:o},null,2)}]}}import Qe from"path";import tf from"fs";J();import ke from"path";import ef from"fs";var Xa=$.child({module:"path-resolver"}),pn=class{repoPath;constructor(e){this.repoPath=ke.isAbsolute(e)?ke.normalize(e):ke.resolve(process.cwd(),e)}resolve(e){if(!e)return this.repoPath;if(e.includes("\0"))throw Xa.error({inputPath:e},"Path contains null bytes - possible attack"),new Error("Invalid path: contains null bytes");let r;if(ke.isAbsolute(e)?r=ke.normalize(e):r=ke.join(this.repoPath,e),r=ke.normalize(r),!this.isWithinRoot(r))throw Xa.warn({inputPath:e,resolved:r},"Path traversal attempt blocked"),new Error(`Access denied: path '${e}' is outside the repository root`);return r}resolveAndValidate(e){try{let r=this.resolve(e);return ef.existsSync(r)?r:(Xa.debug({inputPath:e,resolved:r},"Path does not exist"),null)}catch(r){return Xa.error({inputPath:e,error:r},"Error validating path"),null}}isWithinRoot(e){try{let r=ke.resolve(e),i=ke.resolve(this.repoPath),t=ke.relative(i,r);if(t.startsWith("..")||ke.isAbsolute(t))return!1;if(ef.existsSync(r)){let s=ef.realpathSync(r),a=ke.relative(i,s);if(a.startsWith("..")||ke.isAbsolute(a))return!1}return!0}catch{return!1}}getRelative(e){let r=ke.normalize(e);return ke.relative(this.repoPath,r)}resolveBatch(e){return e.map(r=>this.resolve(r))}static normalize(e){return ke.normalize(e)}static isPathWithinRoot(e,r){let i=ke.resolve(e),t=ke.resolve(r),o=ke.relative(i,t);return o===""||!o.startsWith("..")&&!ke.isAbsolute(o)}};function i_(n){return new pn(n)}var aE=/[\x00-\x1f\x7f]/g,cE=/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g;function Wn(n){if(typeof n!="string")throw new Error("Invalid path: expected string");if(n.includes("\0"))throw new Error("Invalid path: null bytes are not allowed");if(n.replace(aE,"").length!==n.length)throw new Error("Invalid path: control characters are not allowed");return n.trim()}function Bn(n,e=4096){if(typeof n!="string")return"";let r=n.replace(cE,"").trim();return r.length>e?r.slice(0,e):r}dt();var Gi=`
|
|
824
|
-
|
|
825
|
-
To check repository and connection health: shadow_env_diagnose({ repoPath }).`;function mn(n,e,r){return{content:[{type:"text",text:`[${n}] ${e}`}],isError:!0,errorCode:n,errorDetails:r}}function uE(n){let e=Qe.isAbsolute(n)?Qe.normalize(n):Qe.resolve(process.cwd(),n),r=Qe.parse(e).root;for(;e!==r;){if(tf.existsSync(Qe.join(e,".liquid-shadow.db"))||tf.existsSync(Qe.join(e,".git"))||tf.existsSync(Qe.join(e,"package.json")))return e;let i=Qe.dirname(e);if(i===e)break;e=i}return null}function ut(n){let e=n?.repoPath?String(n.repoPath):void 0,r=n?.filePath?String(n.filePath):void 0;e&&(e=Wn(e)),r&&(r=Wn(r));let i;if(e)Qe.isAbsolute(e)||(e=Qe.resolve(process.cwd(),e)),i=e;else if(r){let s=Qe.resolve(process.cwd(),r);i=uE(Qe.dirname(s))||process.cwd()}else i=process.cwd();i=Qe.normalize(i);let t=i_(i),o;return r&&(o=t.resolve(r)),{...n,repoPath:i,filePath:o,resolver:t}}function o_(n,e){if(!Oe(n)){let r=`Repository not indexed yet. Run initial indexing first:
|
|
826
|
-
|
|
827
|
-
1. shadow_recon_onboard({ repoPath: "${n}" }) // one-time
|
|
828
|
-
2. shadow_sync_trace({ repoPath: "${n}" }) // then sync
|
|
829
|
-
|
|
830
|
-
After that, ${e} and other tools will work.`+Gi;return mn("FILE_NOT_FOUND",r,{repoPath:n,toolName:e,requiresIndexing:!0})}return null}J();X();async function Qa(n){let e=Bn(n.query??""),r={...n,query:e},i=$n();try{let{repoPath:t}=ut(r),{query:o,limit:s=he.DEFAULT_LIMIT,offset:a=0,compact:c=!1}=r;await ee(t);let{filters:l,hasFilters:u}=Dn(r),p=await new ot(t).searchByConcept(o,s,a,l,u,c);return dE(t,o,"concept"),i(),p}catch(t){return $.error({error:t,args:n},"Concept Search failed"),i(),await St(),{content:[{type:"text",text:`Concept Search failed: ${t instanceof Error?t.message:String(t)}`}],isError:!0}}}function dE(n,e,r){try{let i=L.getInstance(n),t=Te(n);i.searchHistory.record(e,r,t)}catch(i){let t=Te(n);$.error({module:"search",repoPath:n,query:e,mode:r,error:i instanceof Error?i.message:String(i),branch:t},"Failed to record search history"),St()}}J();X();async function Ji(n){let e=Bn(n.query??""),r={...n,query:e},i=$n();try{let{repoPath:t}=ut(r),{query:o,limit:s=he.DEFAULT_LIMIT,offset:a=0,matchMode:c="any"}=r;await ee(t);let{filters:l,hasFilters:u}=Dn(r),p=await new ot(t).searchBySymbol(o,s,a,l,u,c);return pE(t,o,"symbol"),i(),p}catch(t){return $.error({error:t,args:n},"Symbol Search failed"),i(),await St(),{content:[{type:"text",text:`Symbol Search failed: ${t instanceof Error?t.message:String(t)}`}],isError:!0}}}function pE(n,e,r){try{let i=L.getInstance(n),t=Te(n);i.searchHistory.record(e,r,t)}catch(i){let t=Te(n);$.error({module:"search",repoPath:n,query:e,mode:r,error:i instanceof Error?i.message:String(i),branch:t},"Failed to record search history"),St()}}X();J();import Zr from"path";function s_(n,e){let r=n.findContentByToken(e,100);return{count:r.length,files:r}}async function ec(n){let{repoPath:e,query:r,key:i="",kind:t,limit:o=50,showUsage:s=!1}=n,a=i||r;if(!a&&!t)return{content:[{type:"text",text:'Error: Either "key" or "kind" parameter is required.'}]};await ee(e);let c=L.getInstance(e),{configs:l,files:u}=c;if(a){$.info({repoPath:e,key:a},"Searching for config key in DB...");let m=l.findByKey(a,o);if(m.length===0)return{content:[{type:"text",text:`No configuration found for key: ${a}`}]};if(s){let b=m.map(E=>{let w=s_(u,E.key),z=w.count===0?"\u26A0\uFE0F ORPHANED":`\u2713 ${w.count} usage(s)`;return{file:Zr.relative(e,E.file_path),key:E.key,value:E.value,kind:E.kind,usageCount:w.count,usageFiles:w.files.slice(0,5).map(R=>Zr.relative(e,R)),status:z}});b.sort((E,w)=>E.usageCount===0&&w.usageCount>0?-1:w.usageCount===0&&E.usageCount>0?1:E.usageCount-w.usageCount);let g=b.filter(E=>E.usageCount===0).length;return{content:[{type:"text",text:(g>0?`# Configuration Search: "${a}" (with Usage Analysis)
|
|
831
|
-
|
|
832
|
-
\u26A0\uFE0F **${g} orphaned var(s)** (defined but never used in code)
|
|
833
|
-
|
|
834
|
-
Found ${m.length} match(es):
|
|
835
|
-
|
|
836
|
-
`:`# Configuration Search: "${a}" (with Usage Analysis)
|
|
837
|
-
|
|
838
|
-
Found ${m.length} match(es), all in use:
|
|
839
|
-
|
|
840
|
-
`)+b.map(E=>{let w=`## ${E.file} (${E.kind}) ${E.status}
|
|
841
|
-
**${E.key}**: \`${E.value}\``;return E.usageCount>0&&E.usageFiles.length>0&&(w+=`
|
|
842
|
-
> Used in: ${E.usageFiles.map(z=>`\`${z}\``).join(", ")}${E.usageCount>5?` (+${E.usageCount-5} more)`:""}`),w}).join(`
|
|
843
|
-
|
|
844
|
-
`)}]}}let h=m.map(b=>({file:Zr.relative(e,b.file_path),key:b.key,value:b.value,kind:b.kind}));return{content:[{type:"text",text:`# Configuration Search: "${a}"
|
|
845
|
-
|
|
846
|
-
Found ${m.length} match(es):
|
|
847
|
-
|
|
848
|
-
`+h.map(b=>`## ${b.file} (${b.kind})
|
|
849
|
-
**${b.key}**: \`${b.value}\``).join(`
|
|
850
|
-
|
|
851
|
-
`)+"\n\n> \u{1F4A1} **Tip**: Use `showUsage: true` to see usage counts and identify orphaned vars."}]}}let d=l.findByKind(t||null,o);if(s){let m=d.map(g=>{let x=s_(u,g.key);return{file:Zr.relative(e,g.file_path),key:g.key,value:g.value,kind:g.kind,usageCount:x.count,usageFiles:x.files.slice(0,3).map(S=>Zr.relative(e,S)),status:x.count===0?"ORPHANED":"in-use"}});m.sort((g,x)=>g.usageCount===0&&x.usageCount>0?-1:x.usageCount===0&&g.usageCount>0?1:g.usageCount-x.usageCount);let h=m.filter(g=>g.usageCount===0).length,v=m.length,b=`# Config Discovery (${t||"all"}) with Usage Analysis
|
|
852
|
-
|
|
853
|
-
`;return b+=`**Summary**: ${v} config(s) found, ${h} orphaned
|
|
854
|
-
|
|
855
|
-
`,h>0&&(b+=`## \u26A0\uFE0F Orphaned (${h})
|
|
856
|
-
`,b+=m.filter(g=>g.usageCount===0).map(g=>`- \`${g.key}\` in ${g.file}`).join(`
|
|
857
|
-
`),b+=`
|
|
858
|
-
|
|
859
|
-
`),b+=`## \u2713 In Use (${v-h})
|
|
860
|
-
`,b+=m.filter(g=>g.usageCount>0).map(g=>{let x=g.usageFiles.length>0?`, used in ${g.usageFiles.map(S=>`\`${S}\``).join(", ")}${g.usageCount>3?` (+${g.usageCount-3} more)`:""}`:"";return`- \`${g.key}\`=\`${g.value}\` in \`${g.file}\` (${g.usageCount} usages${x})`}).join(`
|
|
861
|
-
`),d.length===o&&(b+=`
|
|
862
|
-
|
|
863
|
-
> Results limited to ${o} entries. Use the 'limit' parameter to see more.`),{content:[{type:"text",text:b}]}}let p=d.map(m=>({...m,file:Zr.relative(e,m.file_path)})),f=JSON.stringify(p,null,2);return d.length===o&&(f=`Results limited to ${o} entries. Use the 'limit' parameter to see more.
|
|
864
|
-
|
|
865
|
-
`+f),f+="\n\n> \u{1F4A1} **Tip**: Use `showUsage: true` to see usage counts and identify orphaned vars.",{content:[{type:"text",text:f}]}}J();X();async function a_(n){let e=Bn(n.query??""),r={...n,query:e},i=$n();try{let{repoPath:t}=ut(r),{query:o,limit:s=he.DEFAULT_LIMIT,offset:a=0,ranked:c=!1}=r;await ee(t);let{filters:l,hasFilters:u}=Dn(r),p=await new ot(t).searchByPath(o,s,a,l,u,c);return mE(t,o,"path"),i(),p}catch(t){return $.error({error:t,args:n},"Path Search failed"),i(),await St(),{content:[{type:"text",text:`Path Search failed: ${t instanceof Error?t.message:String(t)}`}],isError:!0}}}function mE(n,e,r){try{let i=L.getInstance(n),t=Te(n);i.searchHistory.record(e,r,t)}catch(i){let t=Te(n);$.error({module:"search",repoPath:n,query:e,mode:r,error:i instanceof Error?i.message:String(i),branch:t},"Failed to record search history"),St()}}J();async function c_(n){let{repoPath:e,filePath:r,symbolName:i,depth:t=3,limit:o=50,offset:s=0}=n;await ee(e);try{let c=await new ar(e).analyze(i,{filePath:r,depth:t,limit:o,offset:s});return c.length===0?{content:[{type:"text",text:`Symbol "${i}" not found.`}],isError:!0}:{content:[{type:"text",text:JSON.stringify(c,null,2)}]}}catch(a){return $.error({error:a,args:n},"Impact Analysis failed"),{content:[{type:"text",text:`Impact Analysis failed: ${a instanceof Error?a.message:String(a)}`}],isError:!0}}}X();J();import Gn from"fs";import Ae from"path";var fE=new Set(["api","v1","v2","v3","http","https","localhost","admin","internal","public","private","app","src","get","post","put","delete","patch","user","users","id","search","list","create","update","data"]),hE=new Set(["GET","POST","PUT","DELETE","PATCH"]),gE=[/\bRoute::(?:get|post|put|delete|patch)\b/i,/\brouter\.(?:get|post|put|delete|patch)\s*\(/i,/\bapp\.(?:get|post|put|delete|patch)\s*\(/i,/\bfastify\.(?:get|post|put|delete|patch)\s*\(/i,/\baddRoute\s*\(/i,/\bHTTPMethods\.(?:GET|POST|PUT|DELETE|PATCH)\b/i,/\bpath\s*\(/i,/\bre_path\s*\(/i,/@(?:GET|POST|PUT|DELETE|PATCH|Route)\b/i,/@(?:Get|Post|Put|Delete|Patch|RequestMapping)\b/];function yE(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qi(n){let e=n.split("?")[0].split("#")[0];return e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e}function nf(n){let e=qi(n).replace(/:[^/]+/g,"__SEG__").replace(/\{[^}]+\}/g,"__SEG__").replace(/\$[^/]+/g,"__SEG__").replace(/\*/g,"__SEG__"),r=yE(e).replace(/__SEG__/g,"[^/]+");return new RegExp(`^${r}$`)}function l_(n){let e=[/(HTTPMethods\.)?(GET|POST|PUT|DELETE|PATCH)\b/i,/Route::(get|post|put|delete|patch)\b/i,/@(GET|POST|PUT|DELETE|PATCH)\b/i],r;for(let i of e){let t=n.match(i);if(t?.[2]){r=t[2].toUpperCase();break}if(t?.[1]){r=t[1].toUpperCase();break}}return r&&hE.has(r)?r:null}function bE(n){return n.replace(/<[^>]+>/g," ")}function vE(n){return gE.some(e=>e.test(n))}function _E(n){let e=[],r=/['"`]([^'"`]*\/[^'"`]*)['"`]/g,i=null;for(;(i=r.exec(n))!==null;){let t=i[1].trim();t&&e.push(t)}return e}function xE(n){let e=n.replace(/^\^/,"").replace(/\$$/,"");if(e.includes("://"))try{e=new URL(e).pathname}catch{}if(!e.startsWith("/")){let r=e.indexOf("/");if(r===-1)return null;e=e.slice(r)}return qi(e)}function SE(n,e){let r=_E(n);for(let i of r){let t=xE(i);if(!t)continue;let o=nf(t),s=e.replace(/\*/g,"test-val");if(o.test(s)||!/[:{*$]/.test(t)&&s.startsWith(`${t}/`))return!0}return!1}function $E(n,e){if(e)try{let t=JSON.parse(e);if(typeof t.path=="string"&&t.path.startsWith("/"))return qi(t.path)}catch{}let r=/['"]([^'"]+)['"]/g,i=null;for(;(i=r.exec(n))!==null;){let t=i[1].trim();if(t){if(t=t.replace(/^\^/,"").replace(/\$$/,""),!t.startsWith("/")){if(!t.includes("/")&&!t.includes(":"))continue;t=`/${t}`}return qi(t)}}return null}function wE(n,e){let r=n.toLowerCase();return e.reduce((i,t)=>i+(r.includes(t.toLowerCase())?20:0),0)}function rf(n,e,r){let i=e,t=e.match(/\$\{([^}]+)\}/g);if(t)for(let f of t){let m=f.substring(2,f.length-1),h=n.configs.findEnvValue(m);h&&(i=i.replace(f,h))}let o=i.split("?")[0].split("#")[0];try{o.includes("://")&&(o=new URL(o).pathname)}catch{}o=qi(o);let s=r?.toUpperCase(),a=[],c=!1,l=o.replace(/\*/g,"%").replace(/:[^/]+/g,"%").replace(/\{[^}]+\}/g,"%"),u=n.files.findSynapses({type:"api_route",name:l.includes("%")?l:o,direction:"consume",limit:10});for(let f of u)nf(f.name).test(o.replace(/\*/g,"test-val"))&&(a.push({file_path:f.file_path,start_line:f.line_number||0,signature:`[Synapse] ${f.name}`,score:1e3}),c=!0);let d=o.split(/[^a-zA-Z0-9-_]/).filter(f=>f.length>=3&&!fE.has(f.toLowerCase())&&!/^\d+$/.test(f));if(d.length>0){let h=[...d].sort((b,g)=>g.length-b.length).slice(0,2).flatMap(b=>n.exports.findRoutesByToken(b,20)),v=new Set;for(let b of h){let g=`${b.file_path}:${b.start_line}:${b.name}`;if(v.has(g))continue;v.add(g);let x=b.signature||b.name||"",S=l_(x);if(s&&S&&s!==S)continue;let E=$E(x,b.capabilities);if(s&&!S&&!E)continue;let w=40;if(E){if(!nf(E).test(o.replace(/\*/g,"test-val")))continue;w+=280,c=!0}s&&S&&s===S&&(w+=120,c=!0),w+=wE(`${x} ${E||""}`,d),a.push({file_path:b.file_path,start_line:b.start_line,signature:`[Boundary] ${x}`,capabilities:b.capabilities||void 0,score:w})}}if(a.length<3&&!c){let f=d.map(m=>m.replace(/[^a-zA-Z0-9_]/g,"")).filter(m=>m.length>0).join(" AND ");if(f.length>0){let m=n.content.search(f);for(let h of m){let v=bE(h.snippet);if(!vE(v)||!SE(v,o))continue;let b=l_(v);if(s&&b&&b!==s)continue;let g=0,x=h.file_path.toLowerCase(),S=v.toLowerCase();(x.includes("route")||x.includes("controller"))&&(g+=10),(x.includes("src/api")||x.includes("services/api"))&&(g+=5),(S.includes("addroute")||S.includes("@get"))&&(g+=15),(S.includes("axios.")||S.includes("fetch("))&&(g-=10),(x.includes(".spec.")||x.includes(".test."))&&(g-=20),s&&S.includes(s.toLowerCase())&&(g+=20),g>0&&a.push({file_path:h.file_path,start_line:0,signature:`[FTS Match] ${v.replace(/\n/g," ")}`,score:g})}}}let p=new Map;return a.sort((f,m)=>m.score-f.score).forEach(f=>{p.has(f.file_path)||p.set(f.file_path,f)}),Array.from(p.values()).slice(0,c?2:3)}var kE=4,Vi=50,EE=2,IE=4,TE=new Set(["publish","publishmessage","publishtaskbynameandpayload"]),PE=new Set(["Error","TypeError","RangeError","ReferenceError","SyntaxError","Promise","Map","Set","WeakMap","WeakSet","Date","Array","Object","String","Number","Boolean","RegExp","URL","URLSearchParams"]),RE=new Set(["error","errors","request","response","result","results","value","values","item","data","payload","message","messages","text","description","name","id","type","status","code"]),d_=new Set(["req","res","request","response","error","err","event","item","row","data","value","obj","window","document","console","json","math"]),zE=new Set(["push","pop","shift","unshift","slice","splice","map","filter","reduce","reduceRight","forEach","find","findIndex","includes","indexOf","lastIndexOf","every","some","flat","flatMap","fill","copyWithin","entries","keys","values","join","concat","sort","reverse","at","with","toSorted","toReversed","toSpliced","toString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","charAt","charCodeAt","codePointAt","split","substring","substr","trim","trimStart","trimEnd","padStart","padEnd","repeat","replace","replaceAll","match","matchAll","search","toLowerCase","toUpperCase","localeCompare","normalize","startsWith","endsWith","then","catch","finally","get","set","has","delete","clear","size","length","call","apply","bind"]);function NE(n,e){return Ae.resolve(n)===Ae.resolve(e)}function CE(n){if(PE.has(n))return!0;let e=n.trim().toLowerCase();if(RE.has(e))return!0;let r=n.split(/(?:\.|->|::)+/).filter(Boolean);if(r.length>1){let i=r[0].replace(/^\$+/,"").toLowerCase();if(d_.has(i))return!0}return!1}function u_(n){let e=n.trim();if(!e)return"";let r=e.indexOf("/"),i=r>=0?e.slice(r):e;return i.length>1&&i.endsWith("/")?i.slice(0,-1):i}function DE(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sf(n){let e=n.split(/(?:\.|::|->)+/).filter(Boolean);return e.length>0?e[e.length-1]:n.trim()}function LE(n,e){let r=0,i=!1;for(let t=e;t<n.length;t++){let o=n[t];for(let a of o)if(a==="{")r++,i=!0;else if(a==="}"&&(r--,i&&r<=0))return{start:e+1,end:t+1};let s=o.trim();if(!i&&/[;}]$/.test(s))return{start:e+1,end:t+1}}return{start:e+1,end:Math.min(n.length,e+40)}}function of(n,e){let r=sf(e);if(!r)return null;try{let i=Gn.readFileSync(n,"utf8").split(`
|
|
866
|
-
`),t=DE(r),o=[new RegExp(`^\\s*(?:export\\s+)?(?:async\\s+)?function\\s+${t}\\b`),new RegExp(`^\\s*(?:(?:public|private|protected|static|readonly|async|abstract|get|set)\\s+)*${t}\\s*(?:<[^>]*>)?\\s*\\(`),new RegExp(`^\\s*(?:(?:public|private|protected|static|readonly|async|abstract)\\s+)*${t}\\s*[:=]\\s*(?:async\\s*)?(?:\\([^)]*\\)\\s*=>|function\\b)`),new RegExp(`^\\s*(?:export\\s+)?class\\s+${t}\\b`)];for(let s=0;s<i.length;s++){let a=i[s];if(a.includes(r)&&o.some(c=>c.test(a)))return LE(i,s)}}catch{return null}return null}function p_(n,e,r){try{let i=Gn.readFileSync(n,"utf8").split(`
|
|
867
|
-
`);if(e.start<1||e.end<e.start||e.start>i.length||e.end>i.length||!i.slice(e.start-1,e.end).join(`
|
|
868
|
-
`).trim())return!0;if(e.start===e.end){let o=i[e.start-1]?.trim()||"",s=o.replace(/\s+/g,"");if(!s||/^[{}()[\];,]+$/.test(s))return!0;let a=sf(r);if(a&&!o.includes(a))return!0}return!1}catch{return!0}}function tc(n,e,r){if(e){if(!r)return e;if(p_(n,e,r)){let i=of(n,r);if(i)return i}return e}}function AE(n,e,r){let i=n.exports.findByNameAndFile(r,e);if(i.length>0)return i[0];let t=n.exports.findByFile(e);if(t.length===0)return null;if(r.includes("/")){let a=u_(r),c=t.find(l=>!l?.name||typeof l.name!="string"?!1:u_(l.name)===a);if(c)return c}let o=r.split(/(?:\.|::|->)+/).filter(Boolean);if(o.length>1){let a=o[o.length-1],c=n.exports.findByNameAndFile(a,e);if(c.length===1)return c[0]}return t.find(a=>typeof a?.name=="string"&&(a.name===r||a.name.includes(r)))||null}async function nc(n){let{repoPath:e,filePath:r,symbolName:i}=ut(n);if(!r)return{isError:!0,content:[{type:"text",text:"Error: 'filePath' is required."}]};let t=r;await ee(e);let o=L.getInstance(e);if(!Gn.existsSync(t))return{isError:!0,content:[{type:"text",text:`File not found: ${t}`}]};let s,a=Ae.basename(t),c;if(i){let p=sf(i),f=AE(o,t,i);if(f){let m=f;s={start:m.start_line,end:m.end_line},a=m.name,c=m.start_line}else{let m=of(t,i);if(m)s=m,c=m.start,a=p||i;else{let h=o.exports.findByFile(t).map(v=>v.name).filter(v=>!!v).slice(0,10);return{isError:!0,content:[{type:"text",text:`Symbol not found in file: "${i}"
|
|
869
|
-
File: ${Ae.relative(e,t)}
|
|
870
|
-
`+(h.length>0?`Top symbols in file: ${h.join(", ")}`:"No indexed symbols found for this file.")}]}}}if(s&&p_(t,s,i)){let m=of(t,i);m&&($.warn({filePath:t,symbolName:i,start:s.start,end:s.end},"Indexed symbol range appears degenerate; using source-inferred range for flow"),s=m,c=m.start,a===Ae.basename(t)&&(a=p||i))}}let l={type:s?"function":"file",name:a,path:Ae.relative(e,t),line:c,children:[]},u=new Set;u.add(t+(i?`:${i}`:""));let d={count:0,truncated:!1};return await Hr(t,l,e,o,u,1,d,s),d.truncated&&l.children.push({type:"function",name:"\u26A0\uFE0F Output Truncated",details:`Trace limited to ${Vi} nodes. Use summarize_file on specific files for deeper analysis.`,children:[]}),{content:[{type:"text",text:JSON.stringify(l,null,2)}]}}async function Hr(n,e,r,i,t,o,s,a){if(!(o>kE)){if(s.count>=Vi){s.truncated=!0;return}try{let c=Gn.readFileSync(n,"utf8"),l=Ae.extname(n).toLowerCase(),d=(c.match(/import\s+[\s\S]*?from\s+['"].*?['"];?/gm)||[]).join(`
|
|
871
|
-
`);a&&(c=c.split(`
|
|
872
|
-
`).slice(a.start-1,a.end).join(`
|
|
873
|
-
`));let p;if(l===".ts"||l===".tsx"||l===".js"||l===".jsx"){p=new or;let v={syntax:"typescript",tsx:n.endsWith(".tsx"),target:"es2020"};try{let b=a?`${d}
|
|
874
|
-
${c}`:c,g=await si(b,v);p.visitModule(g)}catch{if(a)try{let g=`${d}
|
|
875
|
-
class TraceContext {
|
|
876
|
-
${c}
|
|
877
|
-
}`,x=await si(g,v);p.visitModule(x)}catch{let x=new Qt,S=l;x.visit(c,S),p.calls=x.calls,p.apiCalls=x.apiCalls,p.imports=x.imports}else{let g=new Qt;g.visit(c,l),p.calls=g.calls,p.apiCalls=g.apiCalls,p.imports=g.imports}}}else p=new Qt,p.visit(c,l);$.info({file:Ae.basename(n),calls:p.calls.size,apiCalls:p.apiCalls.length,depth:o},"Analyzed file");let f=p.apiCalls.slice(0,10);for(let v of f){if(s.count>=Vi)break;if(s.count++,v.method==="PUBSUB"){let S={type:"event_trigger",name:`PubSub Event: ${v.url}`,details:"Detected via PubSub client usage",children:[]};e.children.push(S);let E=v.url.toLowerCase();if(TE.has(E)){S.children.push({type:"subscriber",name:"PubSub fan-out omitted",details:"Generic publish call without concrete event/action; skipping global subscriber expansion to avoid false links.",children:[]});continue}let w=i.exports.findByNameGlobal(v.url).concat(i.exports.findByMethodName(v.url));if(v.url.length>10){let R=v.url.replace(/To[A-Z][a-zA-Z]+$/,"");if(R!==v.url){let U=i.exports.findByNameGlobal(R).concat(i.exports.findByMethodName(R));w.push(...U)}}let z=new Set;for(let R of w.slice(0,IE)){if(z.has(R.file_path)||R.file_path===n)continue;if(z.add(R.file_path),s.count>=Vi)break;s.count++;let U={type:"subscriber",name:`${R.name} (${Ae.basename(R.file_path)})`,path:Ae.relative(r,R.file_path),line:R.start_line,details:"Potential Subscriber / Handler",children:[]};S.children.push(U),Gn.existsSync(R.file_path)&&!t.has(R.file_path)&&(t.add(R.file_path),await Hr(R.file_path,U,r,i,t,o+1,s))}continue}let b={type:"api_call",name:`${v.method} ${v.url}`,details:"Detected via string literal analysis",children:[]};e.children.push(b);let x=rf(i,v.url,v.method).slice(0,EE);for(let S of x){if(NE(S.file_path,n))continue;if(s.count>=Vi)break;s.count++;let E={type:"route",name:S.signature||"Route Handler",path:S.file_path,line:S.start_line,children:[]};if(b.children.push(E),Gn.existsSync(S.file_path)&&!t.has(S.file_path)&&(t.add(S.file_path),await Hr(S.file_path,E,r,i,t,o+1,s)),S.capabilities)try{let w=JSON.parse(S.capabilities);if(w.handler){let[z,R]=w.handler.split("@");if(z){let I=z.split("\\").pop();if(I){let T=i.exports.findClassByName(I);if(T){let N=i.exports.findByNameAndFile(R||"",T.file_path),F,D=T.start_line;N.length>0&&(F=tc(T.file_path,{start:N[0].start_line,end:N[0].end_line},R||""),F||(F={start:N[0].start_line,end:N[0].end_line}),D=F.start);let C={type:"component",name:`${I}${R?" :: "+R:""}`,path:Ae.relative(r,T.file_path),line:D,details:"Controller Logic (Macro IR)",children:[]};E.children.push(C),t.has(T.file_path+(R?`:${R}`:""))||(t.add(T.file_path+(R?`:${R}`:"")),await Hr(T.file_path,C,r,i,t,o+1,s,F))}}}}}catch{}}}let m=p.calls,h=Array.from(m).sort();for(let v of h)if(p.imports.has(v)){let b=p.imports.get(v);if(!b.startsWith(".")){if(["react","react-dom"].includes(b))continue;e.children.push({type:"function",name:v,details:`External: ${b}`,children:[]});continue}let g=Vt(b,n,r);if(g&&Gn.existsSync(g)){let x=i.exports.findByNameAndFile(v,g),S=x.length>0?x[0]:null,E=S?`${g}:${S.name}`:g;if(t.has(E))e.children.push({type:"function",name:v,details:"Circular / Already Visited",path:Ae.relative(r,g),line:S?.start_line,children:[]});else{t.add(E);let w={type:S?"component":"file",name:v,details:S?`Imported symbol from ${Ae.basename(g)}`:`Imported from ${Ae.basename(g)}`,path:Ae.relative(r,g),line:S?.start_line,children:[]};e.children.push(w);let z=S?tc(g,{start:S.start_line,end:S.end_line},v):void 0;await Hr(g,w,r,i,t,o+1,s,z)}}}else if(!["log","info","error","warn","print"].includes(v)&&!CE(v)){let b=i.exports.findByNameGlobal(v);if(b.length===0){let g=v.split(/(?:\.|->|::)+/);if(g.length>1){let x=g[0]?.replace(/^\$+/,"").toLowerCase(),S=g[g.length-1];!zE.has(S)&&!(x&&d_.has(x))&&(b=i.exports.findByMethodName(S))}}if(b.length>0){let g=b.find(S=>S.file_path===n),x=g||(b.length===1?b[0]:null);if(x){let S=`${x.file_path}:${x.name}`;if(!t.has(S)){t.add(S);let E={type:"component",name:v,details:`Resolved via global index${g?" (local)":""}`,path:Ae.relative(r,x.file_path),line:tc(x.file_path,{start:x.start_line,end:x.end_line},v)?.start,children:[]};e.children.push(E);let w=tc(x.file_path,{start:x.start_line,end:x.end_line},v)||{start:x.start_line,end:x.end_line};await Hr(x.file_path,E,r,i,t,o+1,s,w)}}}}}catch(c){$.error({filePath:n,error:c.message},"Trace analysis failed"),e.children.push({type:"function",name:"Error",details:c.message,children:[]})}}}X();import m_ from"path";async function h_(n){let{repoPath:e,filePath:r,direction:i,limit:t,offset:o=0}=n;await ee(e);let{imports:s}=L.getInstance(e);if(i==="imports"){let c=s.findByFile(r).filter(p=>p.module_specifier!=="__type_reference__").map(p=>{let f={module:p.module_specifier,symbols:p.imported_symbols,resolvedPath:p.resolved_path,relativePath:p.resolved_path?m_.relative(e,p.resolved_path):null,isExternal:!p.resolved_path};if(!p.resolved_path){let m=Do(p.module_specifier,r,e);if(!m.resolved)return{...f,resolutionError:m.error,suggestion:m.suggestion}}return f}),l=[...c].sort((p,f)=>(p.relativePath||"").localeCompare(f.relativePath||"")),d={results:f_(l,t,o),total:c.length,offset:o,limit:t||c.length,hasMore:t?o+t<c.length:!1};return{content:[{type:"text",text:JSON.stringify(d,null,2)}]}}else{let c=s.findDependents(r).map(p=>({file:p.file_path,relativePath:m_.relative(e,p.file_path),importStatement:p.module_specifier,importedSymbols:p.imported_symbols})),l=[...c].sort((p,f)=>(p.relativePath||"").localeCompare(f.relativePath||"")),d={results:f_(l,t,o),total:c.length,offset:o,limit:t||c.length,hasMore:t?o+t<c.length:!1};return{content:[{type:"text",text:JSON.stringify(d,null,2)}]}}}function f_(n,e,r=0){return e?n.slice(r,r+e):n.slice(r)}X();import g_ from"path";import OE from"fs";async function y_(n){let{repoPath:e,mode:r,limit:i=50,includeTests:t=!1,includeMigrations:o=!1,includeFixtures:s=!1,excludePatterns:a=[],confidenceThreshold:c="all"}=n;await ee(e);let{exports:l,imports:u}=L.getInstance(e);if(r==="dead-code"){let f=l.findDeadExports({limit:i,includeTests:t,includeMigrations:o,includeFixtures:s,excludePatterns:a,confidenceThreshold:c}).map(x=>({name:x.name,kind:x.kind,file:g_.relative(e,x.file_path),line:x.start_line,confidence:x.confidence,reason:x.reason})),m={high:{},medium:{},low:{}};for(let x of f)m[x.confidence][x.file]||(m[x.confidence][x.file]=[]),m[x.confidence][x.file].push({name:x.name,kind:x.kind,line:x.line,reason:x.reason});let h=[],v=Object.values(m.high).flat().length,b=Object.values(m.medium).flat().length,g=Object.values(m.low).flat().length;return h.push(`# Dead Export Analysis
|
|
878
|
-
`),h.push(`Found ${f.length} potentially unused exports.`),h.push(`- **High confidence** (likely dead): ${v}`),h.push(`- **Medium confidence** (possibly intentional): ${b}`),h.push(`- **Low confidence** (likely intentional): ${g}
|
|
879
|
-
`),v>0&&(h.push(`## High Confidence (Likely Dead)
|
|
880
|
-
`),h.push(JSON.stringify(m.high,null,2))),b>0&&c!=="high"&&(h.push(`
|
|
881
|
-
## Medium Confidence (Possibly Intentional)
|
|
882
|
-
`),h.push(JSON.stringify(m.medium,null,2))),g>0&&c==="all"&&(h.push(`
|
|
883
|
-
## Low Confidence (Likely Intentional)
|
|
884
|
-
`),h.push(JSON.stringify(m.low,null,2))),{content:[{type:"text",text:h.join(`
|
|
885
|
-
`)}]}}else if(r==="circular-deps"){let g=function(w,z){if(h.length>=p)return!1;v.add(w),b.add(w),z.push(w);let R=m.get(w)||new Set;for(let U of R)if(v.has(U)){if(b.has(U)){let I=z.indexOf(U);if(I>=0){let T=z.slice(I);T.push(U),h.push(T)}}}else if(g(U,[...z]))return!0;return b.delete(w),!1};var d=g;let p=typeof i=="number"?i:20,f=u.getAllResolved(),m=new Map;for(let w of f)m.has(w.file_path)||m.set(w.file_path,new Set),m.get(w.file_path).add(w.resolved_path);let h=[],v=new Set,b=new Set;for(let w of m.keys())!v.has(w)&&h.length<p&&g(w,[]);let x=[],S=new Map;for(let w of f){let z=`${w.file_path}|${w.resolved_path}`;S.has(z)||S.set(z,[]),S.get(z).push(w)}for(let w of h){let z=!1;for(let R=0;R<w.length-1;R++){let U=w[R],I=w[R+1],T=S.get(`${U}|${I}`);if(T){for(let N of T)try{let F=OE.readFileSync(U,"utf8"),D=N.module_specifier.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),C=new RegExp(`import\\s+type\\s+.*from\\s+['"]${D}['"]`,"i"),W=new RegExp(`import\\s+\\{.*type\\s+.*\\}.*from\\s+['"]${D}['"]`,"s");if(C.test(F)||W.test(F)){z=!0;break}let q=N.imported_symbols.split(",").map(B=>B.trim());for(let B of q){if(!B||B==="*")continue;let H=B.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`\\(\\s*\\)\\s*=>\\s*${H}`).test(F)){z=!0;break}}}catch{}if(z)break}}z||x.push(w)}let E=x.map((w,z)=>({id:z+1,length:w.length-1,chain:w.map(R=>g_.relative(e,R))}));return{content:[{type:"text",text:`# Circular Dependency Analysis
|
|
886
|
-
|
|
887
|
-
Found ${x.length} circular dependency chain(s).
|
|
888
|
-
|
|
889
|
-
${JSON.stringify(E,null,2)}`}]}}return{isError:!0,content:[{type:"text",text:"Invalid mode"}]}}async function b_(n){let{repoPath:e,subPath:r,maxDepth:i=5}=n,t=5e4,o=[{level:"signatures",depth:i},{level:"summaries",depth:i,meta:{warning:"Export lists omitted for token efficiency.",action:"Use 'shadow_inspect_file' on specific files to see exports."}},{level:"structure",depth:i,meta:{warning:"Detailed signatures omitted due to repo size.",action:"Use 'shadow_inspect_file' on specific files to see details."}},{level:"summaries",depth:2,meta:{warning:"Repository is large. Showing top 2 levels with summaries only.",action:"Use 'shadow_recon_tree' with a 'subPath' to explore deeper."}},{level:"structure",depth:2,meta:{warning:"Repository is large. Showing top 2 levels structure only.",action:"Use 'shadow_recon_tree' with a 'subPath' to explore."}},{level:"lite",depth:1,meta:{warning:"Repository is massive. Showing root files only.",action:"Use 'shadow_recon_tree' with a 'subPath' to explore."}}];for(let s of o){let a=await zn(e,5,s.level,r,s.depth);s.meta&&(a._meta=s.meta);let c=JSON.stringify(a,null,2);if(c.length<=t)return{content:[{type:"text",text:c}]}}return{content:[{type:"text",text:`Warning: The repository at ${r||"root"} is massive (exceeds ${t} chars even at minimal depth).
|
|
890
|
-
Please use 'shadow_recon_tree' with a more specific 'subPath' or use 'shadow_search_symbol' to find what you need.`}]}}Je();async function v_(n){let{repoPath:e,compact:r=!1}=n,t=new pe(e).getSnapshot();if(r&&t.gravity?.hotspots){let o=t.gravity.hotspots.length;t={...t,gravity:{...t.gravity,hotspots:t.gravity.hotspots.slice(0,20),_truncated:o>20,_totalHotspots:o}}}return{content:[{type:"text",text:JSON.stringify(t,null,2)}],suggestedNext:{tool:"shadow_ops_chronicle",reason:"Recent decisions and ADRs"}}}X();ht();Je();function __(n){switch(n){case"Entry":return"\u{1F6AA}";case"Logic":return"\u2699\uFE0F";case"Data":return"\u{1F4BE}";case"Utility":return"\u{1F527}";case"Infrastructure":return"\u{1F3D7}\uFE0F";case"Test":return"\u{1F9EA}";case"Types":return"\u{1F4DD}";case"Unknown":return"\u2753"}}async function x_(n){let{repoPath:e}=n;await ee(e);let r=L.getInstance(e),i=Ge(r,e);new pe(e).updateTopography(i);let o=["Entry","Logic","Data","Utility","Infrastructure","Test","Types","Unknown"],s=`# \u{1F3D7}\uFE0F Architecture Summary
|
|
891
|
-
|
|
892
|
-
`;if(s+=`## Detected Pattern: **${i.pattern}**
|
|
893
|
-
`,s+=`Confidence: ${i.patternConfidence.toFixed(0)}%
|
|
894
|
-
|
|
895
|
-
`,i.insights.length>0){s+=`## Insights
|
|
896
|
-
`;for(let c of i.insights)s+=`- ${c}
|
|
897
|
-
`;s+=`
|
|
898
|
-
`}s+=`## Layer Distribution
|
|
899
|
-
|
|
900
|
-
`,s+=`| Layer | Files | % of Total |
|
|
901
|
-
`,s+=`|-------|------:|:----------:|
|
|
902
|
-
`;let a=o.reduce((c,l)=>c+i.layers[l].count,0);for(let c of o){let l=i.layers[c],u=a>0?(l.count/a*100).toFixed(1):"0.0",d=__(c);s+=`| ${d} ${c} | ${l.count} | ${u}% |
|
|
903
|
-
`}s+=`
|
|
904
|
-
## Top Files by Layer
|
|
905
|
-
|
|
906
|
-
`;for(let c of o){let l=i.layers[c];if(l.count===0)continue;let u=__(c);if(s+=`### ${u} ${c} (${l.count} files)
|
|
907
|
-
`,l.topFiles.length>0)for(let d of l.topFiles)s+=`- \`${d.path}\` (${d.confidence}% conf)
|
|
908
|
-
`,d.signals.length>0&&(s+=` - ${d.signals.join("; ")}
|
|
909
|
-
`);else s+=`- _No files classified with high confidence_
|
|
910
|
-
`;s+=`
|
|
911
|
-
`}return s+=`---
|
|
912
|
-
`,s+=`**Next Steps:**
|
|
913
|
-
`,s+="- Use `shadow_inspect_file` to explore files in each layer\n",s+="- Use `shadow_analyze_flow` to trace execution from Entry \u2192 Logic \u2192 Data\n",s+="- Use `shadow_analyze_deps` to understand layer boundaries\n",{content:[{type:"text",text:s}],suggestedNext:{tool:"shadow_recon_tree",reason:"Explore a subPath or use shadow_inspect_file"}}}X();ht();Je();import Ut from"path";async function rc(n){let{repoPath:e}=n;await ee(e);let r=L.getInstance(e),i=Ge(r,e),o=new pe(e).getSnapshot(),s=[],a=[],c=Object.values(i.layers.Entry.topFiles).map(p=>p.path),l=new Set(Object.values(i.layers.Data.topFiles).map(p=>p.path));for(let p of c){let f=Ut.isAbsolute(p)?p:Ut.join(e,p),m=r.imports.findByFile(f);for(let h of m)h.resolved_path&&l.has(Ut.relative(e,h.resolved_path))&&s.push(`\u2694\uFE0F LAYER BYPASS: \`${Ut.relative(e,p)}\` directly imports Data layer \`${Ut.relative(e,h.resolved_path)}\`. Should go through Logic.`)}let u=o.gravity?.hotspots||[];for(let p of u){let f=Yt(p.filePath,r);(f.layer==="Utility"||f.layer==="Unknown")&&p.gravity>50&&a.push(`\u{1F6A8} GRAVITY ANOMALY: \`${Ut.relative(e,p.filePath)}\` has high gravity (${p.gravity.toFixed(0)}) but is classified as ${f.layer}. Consider promoting to Core Logic.`)}for(let p of c){let f=Ut.isAbsolute(p)?p:Ut.join(e,p),m=r.exports.findByFile(f);m.length>10&&a.push(`\u{1F388} ENTRY BLOAT: \`${Ut.relative(e,p)}\` exports ${m.length} symbols. Entry handlers should be thin interfaces.`)}let d=`# \u{1F575}\uFE0F Architectural Scout Report
|
|
914
|
-
|
|
915
|
-
`;return s.length===0&&a.length===0?d+=`\u2705 No significant architectural drift detected. The structure remains "Legit".
|
|
916
|
-
`:(s.length>0&&(d+=`## \u274C Structural Violations
|
|
917
|
-
`,s.forEach(p=>d+=`- ${p}
|
|
918
|
-
`),d+=`
|
|
919
|
-
`),a.length>0&&(d+=`## \u26A0\uFE0F Architectural Warnings
|
|
920
|
-
`,a.forEach(p=>d+=`- ${p}
|
|
921
|
-
`),d+=`
|
|
922
|
-
`)),{content:[{type:"text",text:d}]}}X();J();import Pt from"path";Je();ht();async function S_(n){let{repoPath:e}=n;$.info({repoPath:e},"Setting up repository..."),$.info({repoPath:e}," Ensuring index is up-to-date...");let r=Date.now();await ee(e,void 0,!1,!0,V=>{let re=V.total>0?Math.round(V.current/V.total*100):0;$.info({phase:V.phase,progress:`${V.current}/${V.total}`,percentage:`${re}%`},V.message||`Indexing progress: ${V.phase}`)});let t=((Date.now()-r)/1e3).toFixed(1);$.info({repoPath:e,indexTime:`${t}s`}," Index check complete"),await Sn();let o=L.getInstance(e);$.info({repoPath:e},"Populating Project Hologram...");let s=new pe(e),a=Ge(o,e);s.updateTopography(a);let c=s.computeGravityZones();s.updateGravityZones(c),$.info({repoPath:e,sections:2},"Project Hologram populated (topography + gravity)");let l=o.files.getCount(),u=o.exports.getCount(),d=o.configs.getAll(),p=o.files.getTopDirectories(e),f=[],m=[],h="Standalone",v=V=>o.files.findPackageJsonChildren(V),b=V=>{let re=Pt.join(V,"package.json"),le=d.filter(G=>G.file_path===re),fe=[],se=G=>le.some(Ne=>Ne.key.startsWith("dep: ")&&Ne.key.includes(G));se("react")&&fe.push("React"),se("vue")&&fe.push("Vue"),se("next")&&fe.push("Next.js"),se("fastify")&&fe.push("Fastify"),se("express")&&fe.push("Express"),se("nestjs")&&fe.push("NestJS"),(se("prisma")||se("typeorm"))&&fe.push("DB");let K=le.find(G=>G.key==="description")?.value||"";return{stack:fe.join(", "),description:K.length>80?K.substring(0,77)+"...":K}},g=Pt.join(e,"apps"),x=Pt.join(e,"packages"),S=Pt.join(e,"services"),E=o.files.hasFilesPattern(g+"/%"),w=o.files.hasFilesPattern(x+"/%"),z=o.files.hasFilesPattern(S+"/%"),R=(V,re)=>{let le=v(V);le.length>0&&(f.push(`| **${re}/ (Directory)** | \uFE0F **DO NOT SUMMARIZE FULL DIR** | |`),le.forEach(fe=>{let se=Pt.dirname(fe.path),K=Pt.basename(se);if(K.startsWith("_")||K.includes("template"))return;let G=Pt.relative(e,se),Ne=b(se);f.push(`| \u2514\u2500 \`${G}\` | ${Ne.stack||"Module"} | ${Ne.description} |`),m.push(G)}))};E||w||z?(h="Monorepo",R(g,"apps"),R(S,"services"),R(x,"packages")):p.forEach(V=>{let re=V.root;if(!re||re.startsWith("."))return;let le=b(Pt.join(e,re));f.push(`| \`${re}/\` | ${le.stack||"Module"} | ${le.description} |`)});let U=Pt.join(e,"package.json"),T=d.find(V=>V.key==="name"&&V.kind==="Service"&&V.file_path===U)?.value||Pt.basename(e),N=d.filter(V=>V.kind==="Service"&&(V.key.startsWith("service:")||V.file==="docker-compose.yml")),F=[...new Set(N.map(V=>V.value).filter(V=>V&&typeof V=="string"&&!V.includes("[object Object]")&&!["postgres","redis","db","worker","undefined"].includes(V.toLowerCase())))],D=F.slice(0,5),C=D.length>0?`Service Cluster: ${D.join(", ")}${F.length>5?` (+${F.length-5} others)`:""}`:"",W=l<100?"small":"large",q=W==="small"?"You can safely use `shadow_recon_tree` to view the full tree.":' **AVOID summarizing large directories like `apps/` or `services/` as a whole.**\n Instead, look for a specific component in the map below and use `shadow_recon_tree({ subPath: "apps/my-app" })` on it.\n\uFE0F **Prefer Search:** Use `shadow_search_symbol` for directly finding symbols.',B="";try{let re=new Ce(e).detectAndRepairShifts(),le=new Lt(e),fe=o.missions.findLastMission();le.analyzeGhostChanges(fe?.commit_sha||void 0),o.intentLogs.countByType("heritage")===0&&new Rn(e).analyzeHeritage(20);let K=o.intentLogs.countByType("heritage"),G=o.intentLogs.countByType("discovery");K>0||G>0||re.repaired>0?B=`
|
|
923
|
-
## Shadow Engine Insights
|
|
924
|
-
`+(K>0?`* **Architectural Heritage**: Bootstrapped ${K} significant historical moves.
|
|
925
|
-
`:"")+(G>0?`* **Recent Changes**: Detected ${G} external modifications.
|
|
926
|
-
`:"")+(re.repaired>0?`* **Symbol Healing**: Automatically repaired ${re.repaired} orphaned intent links.
|
|
927
|
-
`:""):B=`
|
|
928
|
-
## Shadow Engine Status: **Active**
|
|
929
|
-
* **Integrity**: Git River matches Symbol Index.
|
|
930
|
-
* **Heritage**: Ready to track developer intent.
|
|
931
|
-
`}catch(V){B=`
|
|
932
|
-
## Shadow Engine Status: **Offline**
|
|
933
|
-
* Error: ${V instanceof Error?V.message:"Unknown"}
|
|
934
|
-
`}try{let re=new Cn(e).runMaintenance();(re.pruning.deleted>0||re.pruning.converted>0)&&(B+=`
|
|
935
|
-
### Clean Sweep Cycle
|
|
936
|
-
* **Pruned**: ${re.pruning.deleted} orphaned logs deleted, ${re.pruning.converted} converted to lapsed.
|
|
937
|
-
`+(re.compaction.eligible>0?`* **Compaction**: ${re.compaction.eligible} cold missions eligible for briefing synthesis.
|
|
938
|
-
`:""))}catch(V){$.warn({error:V},"Metabolism maintenance failed")}let H="";try{let V=o.missions.findActiveByPriority();V?H=`
|
|
939
|
-
## Active Mission: **${V.name}** (#${V.id})
|
|
940
|
-
* Use \`shadow_ops_briefing\` to resume context.
|
|
941
|
-
`:H=`
|
|
942
|
-
## Mission Status: **Idle**
|
|
943
|
-
* No active mission. Use \`shadow_ops_plan\` to begin task tracking.
|
|
944
|
-
`}catch{}return{content:[{type:"text",text:`
|
|
945
|
-
# Repository Indexed: ${T}
|
|
946
|
-
|
|
947
|
-
\u23F1\uFE0F **Initial deep index completed in ${t}s** (one-time operation - future syncs are instant)
|
|
948
|
-
|
|
949
|
-
## \u{1F3D7}\uFE0F Architecture: ${h}
|
|
950
|
-
${C?`> ${C}
|
|
951
|
-
`:""}
|
|
952
|
-
|
|
953
|
-
${B}
|
|
954
|
-
${H}
|
|
955
|
-
|
|
956
|
-
This is a ${W} repository with ${l} files.
|
|
957
|
-
|
|
958
|
-
## System Overview
|
|
959
|
-
| Statistic | Value |
|
|
960
|
-
|-----------|-------|
|
|
961
|
-
| Total Files | ${l} |
|
|
962
|
-
| Exported Symbols | ${u} |
|
|
963
|
-
| Primary Stack | ${a.primaryStack} |
|
|
964
|
-
|
|
965
|
-
## Component Map
|
|
966
|
-
| Component | Tech Stack | Description |
|
|
967
|
-
|-----------|------------|-------------|
|
|
968
|
-
${f.length>20?f.slice(0,20).join(`
|
|
969
|
-
`)+`
|
|
970
|
-
| ... | ... | (*${f.length-20} more components hidden*) |`:f.join(`
|
|
971
|
-
`)}
|
|
972
|
-
|
|
973
|
-
## Recommended Exploration Strategy
|
|
974
|
-
${q}
|
|
975
|
-
|
|
976
|
-
## \uFE0F Quick Reference
|
|
977
|
-
| Goal | Tool | Example |
|
|
978
|
-
|------|------|---------|
|
|
979
|
-
| Search for code | \`shadow_search_symbol\` | \`shadow_search_symbol({ query: "ProductController" })\` |
|
|
980
|
-
| Explore a *specific* component | \`shadow_recon_tree\` | \`shadow_recon_tree({ subPath: "apps/admin" })\` |
|
|
981
|
-
| Trace data flow | \`shadow_analyze_flow\` | \`shadow_analyze_flow({ filePath: "apps/admin/src/Admin.tsx" })\` |
|
|
982
|
-
| Find config/env | \`shadow_search_config\` | \`shadow_search_config({ key: "DATABASE_URL" })\` |
|
|
983
|
-
|
|
984
|
-
---
|
|
985
|
-
**Ready.** What would you like to investigate first?
|
|
986
|
-
`}]}}X();import $_ from"path";import ME from"fs";function jE(n,e,r){let i=n.split(`
|
|
987
|
-
`),t=[],o=0;for(let d=0;d<Math.min(i.length,50);d++){let p=i[d].trim();if(p.startsWith("import ")||p.startsWith("from ")||p.startsWith("export ")&&p.includes(" from "))o=d+1;else if(p&&!p.startsWith("//")&&!p.startsWith("/*")&&!p.startsWith("*")&&p!==""&&o>0)break}o>0&&(t.push(...i.slice(0,o)),t.push(""));let s=[...r].sort((d,p)=>d.startLine-p.startLine),a=0,c=0;for(let d of s)if(d.isTarget){t.push(`// \u2501\u2501\u2501 REQUESTED: ${d.name} \u2501\u2501\u2501`);let p=i.slice(d.startLine-1,d.endLine);t.push(...p),t.push("// \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),c++}else{let p=d.signature||FE(i,d.startLine-1,d.kind);p&&(t.push(`${p}`),t.push(` /* implementation: ${d.lineCount} lines */`),t.push(""),a++)}let l=s[s.length-1];if(l)for(let d=l.endLine;d<i.length;d++){let p=i[d].trim();if(p==="}"||p==="};"){t.push(i[d]);break}else if(p&&!p.startsWith("//"))break}return{foldedSource:t.join(`
|
|
988
|
-
`),totalOriginalLines:i.length,foldedToLines:t.length,siblingsShown:c,siblingsFolded:a}}function FE(n,e,r){let i=n[e];if(r.includes("Function")||r.includes("Method")||r.includes("Arrow")){let t="";for(let o=e;o<Math.min(e+5,n.length);o++)if(t+=n[o],t.includes("{")||t.includes("=>")){let s=t.indexOf("{");s>0&&(t=t.substring(0,s).trim());break}return t.trim()}return i}async function fn(n){let{repoPath:e,filePath:r,resolver:i}=ut(n),t=String(n.symbolName),o=n.context||"definition";if(r&&!i.isWithinRoot(r))return{content:[{type:"text",text:`Error: Access denied. Path ${r} is outside the repository root.`}],isError:!0};await ee(e);let s=L.getInstance(e),a=[];if(t.includes(".")){let[w,z]=t.split(".");a=s.exports.findMemberCandidates(w,z,r)}else a=s.exports.findDefinitionCandidates(t,r);if(a.length===0){let w=s.exports.findPotentialParents(t);if(w.length>0){let I=w.map(T=>`\`${T.name}\` (in ${i.getRelative(T.file_path)})`).join(", ");return{content:[{type:"text",text:`Symbol "${t}" not found as a top-level export.
|
|
989
|
-
However, it likely exists inside: ${I}.
|
|
990
|
-
Try: shadow_inspect_symbol({ symbolName: "${w[0].name}", context: "full" }) to see the class body.`}]}}let R=s.exports.findFuzzyCandidates(t).map(I=>I.name),U=ir(t,R,50,3);if(U.length>0){let I=U.map(T=>` \u2022 \`${T.match}\` (${T.score}% match)`).join(`
|
|
991
|
-
`);return{content:[{type:"text",text:`Error: Symbol "${t}" not found in the index.
|
|
992
|
-
|
|
993
|
-
Suggestions:
|
|
994
|
-
${I}
|
|
995
|
-
|
|
996
|
-
Next steps:
|
|
997
|
-
\u2022 Search semantically: shadow_search_concept({ query: "${t}" })
|
|
998
|
-
\u2022 Verify repository is indexed: shadow_sync_index({ repoPath: "${e}" })`}]}}return{content:[{type:"text",text:`Error: Symbol "${t}" not found in the index.
|
|
999
|
-
|
|
1000
|
-
Next steps:
|
|
1001
|
-
\u2022 Search for it: shadow_search_concept({ query: "${t}" })
|
|
1002
|
-
\u2022 Try with file path: shadow_inspect_symbol({ symbolName: "${t}", filePath: "..." })
|
|
1003
|
-
`}]}}let c=a[0];if(c.kind==="ExportSpecifier"||c.kind==="ExportAllDeclaration"){let w=s.imports.findImportSource(c.file_path,t);if(w&&w.resolved_path)return fn({...n,filePath:w.resolved_path})}let l=ME.readFileSync(c.file_path,"utf8"),u=l.split(`
|
|
1004
|
-
`),d=c.end_line-c.start_line+1,p=150,f,m=!1,h=null;if(o==="definition"&&d>p){let z=s.exports.findSiblings(c.file_path).map(R=>({name:R.name,kind:R.kind,signature:R.signature||"",startLine:R.start_line,endLine:R.end_line,lineCount:R.end_line-R.start_line+1,isTarget:R.name===c.name&&R.start_line===c.start_line,parentName:R.parent_name}));if(z.length>1){h=jE(l,{name:c.name,startLine:c.start_line,endLine:c.end_line},z);let R=i.getRelative(c.file_path);f=h.foldedSource+`
|
|
1005
|
-
|
|
1006
|
-
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
1007
|
-
\u{1F4CA} Semantic Fold Applied (context: "definition")
|
|
1008
|
-
|
|
1009
|
-
Original file: ${h.totalOriginalLines} lines
|
|
1010
|
-
Folded view: ${h.foldedToLines} lines
|
|
1011
|
-
Target Symbol: ${c.name}
|
|
1012
|
-
\u{1F4A1} Need more context?
|
|
1013
|
-
\u2022 Full symbol + dependencies + usage: shadow_inspect_symbol({ symbolName: "${c.name}", context: "full" })
|
|
1014
|
-
\u2022 ALL symbols in this file: shadow_inspect_file({ filePath: "${R}", detailLevel: "signatures" })
|
|
1015
|
-
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`,m=!0}else f=u.slice(c.start_line-1,c.start_line-1+p).join(`
|
|
1016
|
-
`)+`
|
|
1017
|
-
|
|
1018
|
-
... (truncated ${d-p} lines)`,m=!0}else f=u.slice(c.start_line-1,c.end_line).join(`
|
|
1019
|
-
`);let v=c.parent_name?`${c.parent_name}.${c.name}`:c.name,b=s.exports.findHydratedById(c.id),g={name:v,kind:c.kind,file:i.getRelative(c.file_path),startLine:c.start_line,endLine:c.end_line,totalLines:d,...m&&{truncated:!0,previewLines:p},classification:c.classification,source:f};if(b&&b.recent_intents&&b.recent_intents.length>0){let w={},z=Date.now();for(let R of b.recent_intents){if(R.is_crystallized&&R.type!=="crystal")continue;let U=R.created_at;U<1e10&&(U*=1e3);let I=new Date(U).getTime(),T=z-I,N="just now";if(T>0){let F=Math.floor(T/1e3),D=Math.floor(F/60),C=Math.floor(D/60),W=Math.floor(C/24);W>0?N=`${W}d ago`:C>0?N=`${C}h ago`:D>0?N=`${D}m ago`:N=`${F}s ago`}w[R.type]||(w[R.type]=[]),w[R.type].push(`[${N}] ${R.content}`)}g.intelligence={working_set_of:b.active_missions.map(R=>`Mission #${R.id}: ${R.name}`),total_intents:b.intent_log_count,recent_activity:w}}else b&&(g.intelligence={working_set_of:b.active_missions.map(w=>`Mission #${w.id}: ${w.name}`),total_intents:b.intent_log_count,recent_activity:null});try{let{generateEmbedding:w}=await Promise.resolve().then(()=>(Nt(),ni)),z=`Symbol: ${g.name}
|
|
1020
|
-
Signature: ${c.signature||""}
|
|
1021
|
-
File: ${g.file}`,R=await w(z);if(R){let U=s.intentLogs.findSemanticMatches(R,3,c.id),I=new Promise(N=>setTimeout(()=>N([]),100)),T=await Promise.race([U,I]);T&&T.length>0&&(g.intelligence||(g.intelligence={}),g.intelligence.related_knowledge=T.map(N=>({type:N.type,content:N.content,from_symbol:N.symbol_name,similarity:`${(N.similarity*100).toFixed(0)}%`})))}}catch{}if(o==="definition")return{content:[{type:"text",text:JSON.stringify(g,null,2)}]};let x={definition:g,dependencies:s.imports.getImportsForFile(c.file_path).map(w=>({module:w.module_specifier,symbols:w.imported_symbols,relativePath:w.resolved_path?$_.relative(e,w.resolved_path):null}))},S=[c.file_path],E=s.imports.findVerifiedDependents(S,t);return x.verifiedUsages=E.slice(0,10).map(w=>({file:$_.relative(e,w.file_path),classification:w.classification,importedSymbols:w.imported_symbols})),{content:[{type:"text",text:JSON.stringify(x,null,2)}]}}X();ht();import UE from"fs";import w_ from"path";var ZE=new Set(["ClassDeclaration","FunctionDeclaration","TsInterfaceDeclaration","TsTypeAliasDeclaration","TsEnumDeclaration","VariableDeclaration"]);function k_(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function af(n,e,r){let i=r.trim();return!!(!i||i.length>8e3||/^\w{1,4}\s+['"].*['"];?$/.test(i)&&!i.startsWith("export ")||i.includes(`
|
|
1022
|
-
import `)&&!i.startsWith("import ")||e&&ZE.has(e)&&n&&!new RegExp(`\\b${k_(n)}\\b`).test(i))}function HE(n,e){let r=Math.max(0,(n.start_line||1)-1),i=Math.min(e.length,Math.max(r+1,(n.end_line||n.start_line||1)+1,r+120)),t=e.slice(r,i).join(`
|
|
1023
|
-
`),o=nt(t,n.kind);return o?o.length>800?`${o.slice(0,797)}...`:o:n.signature||""}function WE(n,e,r){if(!n)return null;let i=k_(n),t=[];e==="TsTypeAliasDeclaration"&&t.push(new RegExp(`^\\s*export\\s+type\\s+${i}\\b`)),e==="TsInterfaceDeclaration"&&t.push(new RegExp(`^\\s*export\\s+interface\\s+${i}\\b`)),e==="FunctionDeclaration"&&t.push(new RegExp(`^\\s*(?:export\\s+)?(?:async\\s+)?function\\s+${i}\\b`)),e==="ClassDeclaration"&&t.push(new RegExp(`^\\s*(?:export\\s+)?(?:abstract\\s+)?class\\s+${i}\\b`)),e==="VariableDeclaration"&&t.push(new RegExp(`^\\s*(?:export\\s+)?(?:const|let|var)\\s+${i}\\b`)),t.push(new RegExp(`\\b${i}\\b`));for(let o of t)for(let s=0;s<r.length;s++)if(o.test(r[s]))return s+1;return null}function BE(n,e,r){let i=Math.max(0,n-1);if(e==="TsTypeAliasDeclaration"||e==="VariableDeclaration"||e==="TsEnumDeclaration"){for(let t=i;t<r.length;t++){if(r[t].includes(";"))return t+1;if(/^\s*export\s+(type|interface|class|function|const|let|var)\b/.test(r[t])&&t>i)return t}return Math.min(r.length,n+20)}if(e==="TsInterfaceDeclaration"||e==="ClassDeclaration"||e==="FunctionDeclaration"){let t=0,o=!1;for(let s=i;s<r.length;s++){let a=r[s];for(let c of a)c==="{"?(t+=1,o=!0):c==="}"&&(t-=1);if(o&&t<=0)return s+1}return Math.min(r.length,n+120)}return Math.min(r.length,n+40)}function GE(n){return Array.isArray(n)?n.filter(e=>e.module!=="__type_reference__"):n}function JE(n,e){return n?e==="TsTypeAliasDeclaration"?`type ${n}`:e==="TsInterfaceDeclaration"?`interface ${n}`:e==="FunctionDeclaration"?`function ${n}()`:e==="ClassDeclaration"?`class ${n}`:e==="VariableDeclaration"?`const ${n}`:`${e||"symbol"} ${n}`:e||"symbol"}function qE(n,e){if(!n||e!=="TsTypeAliasDeclaration"&&e!=="TsInterfaceDeclaration")return n;let r=n.indexOf(`
|
|
1024
|
-
export `);return r<=0?n:n.slice(0,r).trim()}async function Wr(n){let{repoPath:e,filePath:r}=ut(n);if(!r)return{content:[{type:"text",text:"Error: filePath is required"}],isError:!0};let i=n.detailLevel||"signatures";await ee(e);let{files:t,exports:o}=L.getInstance(e),s=t.findByPath(r),a=w_.basename(r),c=/\.(ts|tsx|php|py|go)$/.test(a),l;c?l=await Xn(r):l={exports:o.findByFile(r),imports:[]};let u=null;if(c)try{u=UE.readFileSync(r,"utf8").split(`
|
|
1025
|
-
`)}catch{u=null}Array.isArray(l.exports)&&u&&(l.exports=l.exports.map(m=>{let h=typeof m.signature=="string"?m.signature:"",v=m.start_line??m.line??1,b=m.end_line??m.endLine??v;if(af(m.name||"",m.kind,h)){let x=WE(m.name||"",m.kind,u),S=x??v,E=x?BE(S,m.kind,u):b,w=HE({name:m.name||"",kind:m.kind,signature:h,start_line:S,end_line:E},u),z=qE(w,m.kind),R=af(m.name||"",m.kind,z)?JE(m.name||"",m.kind):z;return{...m,signature:R,start_line:S,end_line:E,line:S,endLine:E,members:Array.isArray(m.members)?m.members.filter(U=>{let I=typeof U.signature=="string"?U.signature:"";return!af(U.name||"",U.kind,I)}):m.members}}return m})),l.imports=GE(l.imports),i==="structure"?(l.exports=l.exports.map(m=>{let h={name:m.name,kind:m.kind,line:m.start_line,classification:m.classification};return m.members&&m.members.length>0?{...h,members:m.members.map(v=>({name:`${m.name}.${v.name}`,kind:v.kind,line:v.start_line}))}:h}),delete l.imports):i==="signatures"&&(l.exports=l.exports.map(m=>{let h={name:m.name,kind:m.kind,signature:m.signature,line:m.start_line,classification:m.classification,capabilities:JSON.parse(m.capabilities||"[]")};return m.members&&m.members.length>0?{...h,members:m.members.map(v=>({name:`${m.name}.${v.name}`,kind:v.kind,signature:v.signature,line:v.start_line}))}:h}),delete l.imports);let d=w_.relative(e,r),p=l.exports?.length||0,f="";return i==="structure"&&p>0?f=`
|
|
1026
|
-
|
|
1027
|
-
\u{1F4A1} Showing ${p} symbol names. For full signatures: shadow_inspect_file({ filePath: "${d}", detailLevel: "signatures" })`:i==="signatures"&&p>0&&(f=`
|
|
1028
|
-
|
|
1029
|
-
\u{1F4A1} Showing ${p} complete signatures. To inspect a specific symbol: shadow_inspect_symbol({ symbolName: "...", context: "full" })`),{content:[{type:"text",text:JSON.stringify({...l,fileDescription:s?.summary||"",classification:s?.classification&&s.classification!=="Unknown"?s.classification:Yt(r,L.getInstance(e)).layer},null,2)+f}]}}X();ht();async function ic(n){let{repoPath:e}=n;try{await ee(e),new Lt(e).analyzeGhostChanges();let i=new Ce(e),t=i.detectAndRepairShifts(),o=i.syncLifecycle(),a=await new ct(e).recoverFromGitNotes(),{HologramService:c}=await Promise.resolve().then(()=>(Je(),Zg)),l=new c(e),u=Ge(L.getInstance(e),e);l.updateTopography(u);let d=l.computeGravityZones();l.updateGravityZones(d);let p="Shadow Sync complete. Code changes indexed and intent logs updated.";return p+=`
|
|
1030
|
-
\u269B\uFE0F Hologram: Refreshed architectural map (${d.length} hotspots).`,t.repaired>0&&(p+=`
|
|
1031
|
-
\u2728 Nano-Repair: Fixed ${t.repaired} links.`),a.missionsRecovered>0&&(p+=`
|
|
1032
|
-
\u{1F9EC} Re-hydration: Recovered ${a.missionsRecovered} missions.`),{content:[{type:"text",text:p}]}}catch(r){return{content:[{type:"text",text:`Error: ${r.message}`}],isError:!0}}}Je();async function E_(n){let{repoPath:e,deep:r}=n;try{let i=r===!0;await ee(e,5,i,i);let t=new Ce(e),o=t.detectAndRepairShifts(),s=t.syncLifecycle(),a=new pe(e);a.refreshTopography();let c=a.computeGravityZones();a.updateGravityZones(c);let l=`Repository at ${e} has been ${r?"deeply ":""}re-indexed.`;return o.repaired>0&&(l+=`
|
|
1033
|
-
\u2728 Nano-Repair: Fixed ${o.repaired} links.`),l+=`
|
|
1034
|
-
\u269B\uFE0F Hologram: Refreshed architectural map (${c.length} hotspots).`,{content:[{type:"text",text:l}]}}catch(i){return{content:[{type:"text",text:`Error: ${i.message}`}],isError:!0}}}async function I_(n){let{repoPath:e}=n;try{let i=new Ce(e).detectAndRepairShifts();return{content:[{type:"text",text:JSON.stringify(i,null,2)}]}}catch(r){return{content:[{type:"text",text:`Error tracing shifts: ${r.message}`}],isError:!0}}}J();var cf=$.child({module:"mcp:tools:env:hooks"});async function Br(n){let{repoPath:e,action:r,enableAutoRefresh:i,enableSymbolHealing:t}=n;if(r==="install"){cf.info({repoPath:e,enableAutoRefresh:i,enableSymbolHealing:t},"Installing git hooks");let o=$c({repoPath:e,enableAutoRefresh:i??!0,enableSymbolHealing:t??!0}),s=["# Git Hooks Installation","",`## Installed (${o.installed.length})`,o.installed.length>0?o.installed.map(a=>`- \`${a}\``).join(`
|
|
1035
|
-
`):"- None","",`## \u23ED\uFE0F Skipped (${o.skipped.length})`,o.skipped.length>0?o.skipped.map(a=>`- \`${a}\` (already installed)`).join(`
|
|
1036
|
-
`):"- None",""];return o.errors.length>0&&(s.push(`## Errors (${o.errors.length})`),s.push(o.errors.map(a=>`- ${a}`).join(`
|
|
1037
|
-
`)),s.push("")),s.push("---"),s.push("**What happens now?**"),(i??!0)&&s.push("- After `git pull` or `git checkout`: Index auto-refreshes in background"),(t??!0)&&s.push("- After `git commit`: Symbol shift detection runs automatically"),{content:[{type:"text",text:s.join(`
|
|
1038
|
-
`)}]}}if(r==="remove"){cf.info({repoPath:e},"Uninstalling git hooks");let o=wc(e),s=["# Git Hooks Uninstallation","",`## Removed (${o.removed.length})`,o.removed.length>0?o.removed.map(a=>`- \`${a}\``).join(`
|
|
1039
|
-
`):"- None",""];return o.errors.length>0&&(s.push(`## Errors (${o.errors.length})`),s.push(o.errors.map(a=>`- ${a}`).join(`
|
|
1040
|
-
`))),{content:[{type:"text",text:s.join(`
|
|
1041
|
-
`)}]}}if(r==="status"){cf.info({repoPath:e},"Checking git hooks status");let o=Ct(e);return{content:[{type:"text",text:["# Git Hooks Status","",`## Installed (${o.installed.length})`,o.installed.length>0?o.installed.map(a=>`- \`${a}\``).join(`
|
|
1042
|
-
`):"- None","",`## Not Installed (${o.notInstalled.length})`,o.notInstalled.length>0?o.notInstalled.map(a=>`- \`${a}\``).join(`
|
|
1043
|
-
`):"- None","","---",'**To install hooks**: Use `shadow_env_hooks({ action: "install" })`'].join(`
|
|
1044
|
-
`)}]}}return{content:[{type:"text",text:`Unknown action: ${r}`}],isError:!0}}dt();import oc from"path";import T_ from"fs";J();var VE=$.child({module:"mcp:tools:env:diagnose"});async function P_(n){let{repoPath:e}=n,r=oc.isAbsolute(e)?oc.normalize(e):oc.resolve(process.cwd(),e);VE.info({repoPath:r},"Running MCP diagnose");let i=["# MCP Server Health Check","",`**Repository path**: \`${r}\``,""],t=!1;try{t=T_.statSync(r).isDirectory()}catch{}i.push("## 1. Path"),i.push(t?"\u2705 Directory exists":"\u274C Path missing or not a directory"),i.push("");let o=oc.join(r,".git"),s=t&&T_.existsSync(o);i.push("## 2. Git repository"),i.push(s?"\u2705 `.git` found":"\u274C Not a Git repository (or path invalid)"),i.push("");let a=!1,c=!1;if(t)try{We(r),a=!0,c=Oe(r)}catch{}i.push("## 3. Database & index"),i.push(a?"\u2705 Database connected":"\u274C Database not available"),i.push(c?"\u2705 Repository indexed":"\u26A0\uFE0F Not indexed yet"),i.push("");let l=t?Ct(r):{installed:[],notInstalled:[]};return i.push("## 4. Git hooks"),i.push(l.installed.length>0?`\u2705 Installed: ${l.installed.join(", ")}`:"\u26A0\uFE0F No Shadow hooks installed"),i.push(""),i.push("## 5. Next steps"),t?c?i.push("- Index is ready. Use shadow_search_*, shadow_inspect_*, shadow_analyze_*."):i.push("- Run **shadow_recon_onboard** to populate the index."):i.push("- Use a valid repository path."),{content:[{type:"text",text:i.join(`
|
|
1045
|
-
`)}]}}X();J();import KE from"path";import YE from"fs";var R_=$.child({module:"mcp:tools:workspace:list"});async function sc(n){let{repoPaths:e,status:r,limit:i,summarize:t=!1}=n;R_.info({repoCount:e.length,status:r,summarize:t},"Getting workspace missions");let o=[];for(let a of e)if(YE.existsSync(a))try{let{missions:c}=L.getInstance(a),l=c.findAll(r);for(let u of l){let d=c.getLinks(u.id);o.push({...u,repo_path:a,repo_name:KE.basename(a),cross_repo_links:d})}}catch(c){R_.error({error:c,repoPath:a},"Failed to query repo missions")}if(o.sort((a,c)=>{let l=p=>p==="in-progress"?0:p==="verifying"?1:2,u=l(a.status),d=l(c.status);return u!==d?u-d:(a.created_at||0)-(c.created_at||0)}),t||o.length>50&&!i){let a=i||20,c=o.slice(0,a),l=o.reduce((d,p)=>(d[p.status]=(d[p.status]||0)+1,d),{}),u=o.reduce((d,p)=>(d[p.repo_name]=(d[p.repo_name]||0)+1,d),{});return{content:[{type:"text",text:JSON.stringify({summary:{total_missions:o.length,by_status:l,by_repo:u,showing_top:a},top_missions:c,hint:`Showing top ${a} of ${o.length} missions. Use limit to adjust or summarize:false for full list.`},null,2)}]}}let s=i?o.slice(0,i):o;return{content:[{type:"text",text:JSON.stringify({total_missions:o.length,showing:s.length,missions:s},null,2)}]}}X();J();var XE=$.child({module:"mcp:tools:workspace:link"});async function ac(n){let{parentRepoPath:e,parentMissionId:r,childRepoPath:i,childMissionId:t,relationship:o="related"}=n;XE.info({parentRepoPath:e,childRepoPath:i},"Linking cross-repo missions");let{missions:s}=L.getInstance(e),{missions:a}=L.getInstance(i);try{let c=s.findById(r),l=a.findById(t);if(!c)throw new Error(`Parent mission ${r} not found`);if(!l)throw new Error(`Child mission ${t} not found`);return s.createLink(r,i,t,o,"parent"),a.createLink(t,e,r,o,"child"),{content:[{type:"text",text:JSON.stringify({status:"linked",relationship:o},null,2)}]}}catch(c){throw new Error(`Failed to link: ${c.message}`)}}J();var QE=$.child({module:"mcp:tools:workspace:fuse"});async function cc(n){let{repoPaths:e,name:r}=n;QE.info({repoCount:e.length,name:r},"Creating fused workspace index");try{let i=Jc({repoPaths:e,name:r||`workspace-${Date.now()}`});return{content:[{type:"text",text:JSON.stringify({message:"Fused index created",status:i.getStatus()},null,2)}]}}catch(i){throw new Error(`Failed to fuse: ${i.message}`)}}var lf=y.object({repoPath:y.string(),name:y.string().optional(),goal:y.string().optional(),strategy:y.string().optional(),missionId:y.number().optional(),parentId:y.number().optional(),outcomeContract:y.string().optional(),templateId:y.string().optional(),templateVars:y.record(y.string(),y.string()).optional()}),uf=y.object({repoPath:y.string(),missionId:y.number(),stepId:y.string().optional(),status:y.enum(["pending","in-progress","completed","failed","skipped"]).optional(),contextPivot:y.string().optional(),updates:y.array(y.object({stepId:y.string(),status:y.enum(["pending","in-progress","completed","failed","skipped"]),contextPivot:y.string().optional()})).optional(),artifacts:y.array(y.object({type:y.string(),identifier:y.string(),metadata:y.record(y.string(),y.any()).optional()})).optional()}),df=y.object({repoPath:y.string(),missionId:y.number().optional(),scope:y.enum(["mission","project"]).optional(),altitude:y.enum(["orbit","atmosphere","ground"]).optional(),activeMissionsLimit:y.number().int().positive().optional(),recentActivityLimit:y.number().int().positive().optional(),compact:y.boolean().optional()}),pf=y.object({repoPath:y.string(),missionId:y.number().optional(),type:y.enum(["decision","blocker","discovery","fix"]),content:y.string(),filePath:y.string().optional(),symbolName:y.string().optional(),standalone:y.boolean().optional()}),mf=y.object({repoPath:y.string(),missionId:y.number()}),ff=y.object({repoPath:y.string(),format:y.enum(["markdown","json"]).optional(),limit:y.number().optional(),offset:y.number().optional(),since:y.number().optional(),until:y.number().optional()}),hf=y.object({repoPath:y.string()}),gf=y.object({repoPath:y.string(),compact:y.boolean().optional()}),yf=y.object({repoPath:y.string(),missionId:y.number().optional(),symbolId:y.number().optional()}),bf=y.object({repoPath:y.string(),missionId:y.number().optional(),depth:y.number().optional(),limit:y.number().optional(),format:y.enum(["mermaid","json"]).optional()}),z_=y.object({repoPath:y.string(),filePaths:y.array(y.string())}),vf=y.object({repoPath:y.string(),subPath:y.string().optional(),maxDepth:y.number().int().optional()}),_f=y.object({repoPath:y.string(),compact:y.boolean().optional()}),xf=y.object({repoPath:y.string()}),Sf=y.object({repoPath:y.string()}),$f=y.object({repoPath:y.string()}),wf=y.object({repoPath:y.string(),query:y.string(),limit:y.number().int().optional(),offset:y.number().int().optional(),compact:y.boolean().optional(),fileType:y.string().optional(),layer:y.enum(["Solid","Liquid","Virtual","Intel","Phantom"]).optional()}),kf=y.object({repoPath:y.string(),query:y.string(),limit:y.number().int().optional(),offset:y.number().int().optional(),fileType:y.string().optional(),layer:y.enum(["Solid","Liquid","Virtual","Intel","Phantom"]).optional(),matchMode:y.enum(["any","all","exact"]).optional()}),Ef=y.object({repoPath:y.string(),query:y.string().optional(),key:y.string().optional(),kind:y.enum(["Service","Image","Port","Env"]).optional(),limit:y.number().int().optional(),showUsage:y.boolean().optional()}),If=y.object({repoPath:y.string(),query:y.string(),limit:y.number().int().optional(),offset:y.number().int().optional(),fileType:y.string().optional(),layer:y.enum(["Solid","Liquid","Virtual","Intel","Phantom"]).optional(),ranked:y.boolean().optional()}),Tf=y.object({repoPath:y.string(),filePath:y.string().optional(),symbolName:y.string(),depth:y.number().int().optional(),limit:y.number().int().positive().optional(),offset:y.number().int().nonnegative().optional()}),Pf=y.object({repoPath:y.string(),filePath:y.string(),symbolName:y.string().optional()}),Rf=y.object({repoPath:y.string(),filePath:y.string(),direction:y.enum(["imports","imported_by"]),limit:y.number().int().positive().optional(),offset:y.number().int().nonnegative().optional()}),zf=y.object({repoPath:y.string(),mode:y.enum(["dead-code","circular-deps"]),limit:y.number().int().optional(),includeTests:y.boolean().optional(),excludePatterns:y.array(y.string()).optional(),includeMigrations:y.boolean().optional(),includeFixtures:y.boolean().optional(),confidenceThreshold:y.enum(["all","high","medium"]).optional()}),Nf=y.object({repoPath:y.string(),symbolName:y.string(),filePath:y.string().optional(),context:y.enum(["definition","full"]).optional()}),Cf=y.object({repoPath:y.string(),filePath:y.string(),detailLevel:y.enum(["structure","signatures","summaries","detailed"]).optional()}),Df=y.object({repoPath:y.string()}),Lf=y.object({repoPath:y.string(),deep:y.boolean().optional()}),Af=y.object({repoPath:y.string()}),Of=y.object({repoPath:y.string(),action:y.enum(["install","remove","status"]),enableAutoRefresh:y.boolean().optional(),enableSymbolHealing:y.boolean().optional()}),Mf=y.object({repoPath:y.string()}),jf=y.object({repoPaths:y.array(y.string()),status:y.string().optional(),limit:y.number().int().positive().optional(),summarize:y.boolean().optional()}),Ff=y.object({parentRepoPath:y.string(),parentMissionId:y.number(),childRepoPath:y.string(),childMissionId:y.number(),relationship:y.string()}),Uf=y.object({repoPaths:y.array(y.string()),name:y.string().optional()});J();var eI=["repoPath","filePath","subPath","path","parentRepoPath","childRepoPath"];function lc(n,e){if(!(!n||typeof n!="object"))for(let r in n)typeof n[r]=="string"?["filePath","subPath","path","repoPath","parentRepoPath","childRepoPath"].includes(r)&&(n[r]=e.resolve(n[r])):Array.isArray(n[r])?n[r].forEach(i=>lc(i,e)):typeof n[r]=="object"&&lc(n[r],e)}function N_(n){if(!(!n||typeof n!="object")){for(let e of eI)if(typeof n[e]=="string")try{n[e]=Wn(n[e])}catch(r){throw r}Array.isArray(n.repoPaths)&&(n.repoPaths=n.repoPaths.map(e=>typeof e=="string"?Wn(e):e))}}function C_(n,e){return async r=>{let i=$.child({handler:n});try{N_(r)}catch(t){return i.warn({err:t},"Path sanitization failed"),mn("VALIDATION_ERROR",t.message,{})}try{if(r?.repoPath&&typeof r.repoPath=="string"){let o=new pn(r.repoPath);lc(r,o)}i.info({args:r},"Handling tool call");let t=await e(r);return i.debug("Tool call successful"),t}catch(t){i.error({err:t},"Error in tool handler");let o=t.message?.includes("Access denied"),s=`Handler '${n}' failed: ${t.message}`;return!o&&r?.repoPath&&(s+=Gi),mn(o?"FORBIDDEN":"INTERNAL_ERROR",s,{stack:t.stack})}}}function D_(n,e,r){return async i=>{let t=$.child({handler:n});try{N_(i)}catch(s){return t.warn({err:s},"Path sanitization failed"),mn("VALIDATION_ERROR",s.message,{})}if(i?.repoPath&&typeof i.repoPath=="string"){let s=new pn(i.repoPath);lc(i,s)}t.info({args:i},"Handling tool call with validation");let o=e.safeParse(i);if(!o.success){let s=o.error.issues.map(a=>`${a.path.length>0?`${a.path.join(".")}: `:""}${a.message}`).join(", ");return t.warn({validationIssues:o.error.issues},"Validation failed"),mn("VALIDATION_ERROR",`Validation error: ${s}`,{issues:o.error.issues})}try{let s=await r(o.data);return t.debug("Tool call successful"),s}catch(s){t.error({err:s},"Error in tool handler");let a=s.message?.includes("Access denied"),c=`Handler '${n}' failed: ${s.message}`,l=o.data;return!a&&l?.repoPath&&(c+=Gi),mn(a?"FORBIDDEN":"INTERNAL_ERROR",c,{stack:s.stack})}}}function Gr(n,e){return async r=>{let i=r.repoPath;if(!i)return n(r);let t=o_(i,e);return t||n(r)}}var tI={shadow_ops_plan:{default:Za},shadow_ops_track:{default:Ga},shadow_ops_briefing:{default:Ur},shadow_ops_log:{default:qa},shadow_ops_synthesize:{default:Ja},shadow_ops_chronicle:{default:qv},shadow_ops_context:{default:Gr(Vv,"shadow_ops_context")},shadow_ops_health:{default:Yv},shadow_ops_graph:{default:Ka},shadow_ops_crystallize:{default:n_},shadow_working_set_check:{default:Gr(r_,"shadow_working_set_check")},shadow_recon_tree:{default:b_},shadow_recon_hologram:{default:v_},shadow_recon_topography:{default:x_},shadow_recon_scout:{default:rc},shadow_recon_onboard:{default:S_},shadow_search_concept:{default:Qa},shadow_search_symbol:{default:Ji},shadow_search_config:{default:ec},shadow_search_path:{default:a_},shadow_analyze_impact:{default:c_},shadow_analyze_flow:{default:nc},shadow_analyze_deps:{default:h_},shadow_analyze_debt:{default:y_},shadow_inspect_symbol:{default:Gr(fn,"shadow_inspect_symbol")},shadow_inspect_file:{default:Gr(Wr,"shadow_inspect_file")},shadow_sync_trace:{default:Gr(ic,"shadow_sync_trace")},shadow_sync_index:{default:E_},shadow_sync_repair:{default:Gr(I_,"shadow_sync_repair")},shadow_env_hooks:{default:Br},shadow_env_diagnose:{default:P_},shadow_workspace_list:{default:sc},shadow_workspace_link:{default:ac},shadow_workspace_fuse:{default:cc}},nI={shadow_ops_plan:lf,shadow_ops_track:uf,shadow_ops_briefing:df,shadow_ops_log:pf,shadow_ops_synthesize:mf,shadow_ops_chronicle:ff,shadow_ops_context:gf,shadow_ops_health:hf,shadow_ops_graph:bf,shadow_ops_crystallize:yf,shadow_working_set_check:z_,shadow_recon_tree:vf,shadow_recon_hologram:_f,shadow_recon_topography:xf,shadow_recon_scout:Sf,shadow_recon_onboard:$f,shadow_search_concept:wf,shadow_search_symbol:kf,shadow_search_config:Ef,shadow_search_path:If,shadow_analyze_impact:Tf,shadow_analyze_flow:Pf,shadow_analyze_deps:Rf,shadow_analyze_debt:zf,shadow_inspect_symbol:Nf,shadow_inspect_file:Cf,shadow_sync_trace:Df,shadow_sync_index:Lf,shadow_sync_repair:Af,shadow_env_hooks:Of,shadow_env_diagnose:Mf,shadow_workspace_list:jf,shadow_workspace_link:Ff,shadow_workspace_fuse:Uf},L_=new Map;for(let[n,e]of Object.entries(tI)){let r=nI[n];r?L_.set(n,D_(n,r,async i=>{if(e.default)return e.default(i);let t=i.mode||i.action;if(!t){let s=Object.keys(e);return{content:[{type:"text",text:`Missing required parameter "mode" or "action" for tool ${n}.
|
|
1046
|
-
|
|
1047
|
-
\u{1F4A1} Solution: Specify one of: ${s.join(", ")}`}],isError:!0}}let o=e[t];if(!o){let s=Object.keys(e);return{content:[{type:"text",text:`Invalid mode/action "${t}" for tool ${n}.
|
|
1048
|
-
|
|
1049
|
-
\u{1F4A1} Solution: Use one of these modes: ${s.join(", ")}`}],isError:!0}}return o(i)})):L_.set(n,C_(n,async i=>{if(e.default)return e.default(i);let t=i.mode||i.action;if(!t)throw new Error(`Missing mode/action for tool ${n}`);let o=e[t];if(!o)throw new Error(`Unknown mode/action '${t}' for tool ${n}`);return o(i)}))}X();gc();dt();ht();Je();Qm();async function A_(n,e){let r=rI.resolve(n);try{await ie(async()=>{Ie("\u{1F311} Liquid Shadow: Topological Mapping");let i=parseInt(e.depth,10),t=await zn(r,i,"detailed",e.subPath);console.log(` ${_.bold("Root")}: ${_.cyan(r)}`),e.subPath&&console.log(` ${_.bold("Subpath")}: ${_.yellow(e.subPath)}`),console.log("");let o=s=>({name:s.name,info:s.type==="directory"?`${s.children?.length||0} items`:s.size,color:s.type==="directory"?"blue":"white",children:s.children?.map(o)});xc([o(t)]),console.log(""),pt("Mapping concluded.")})}finally{await de(r)}}import O_ from"path";import iI from"fs";async function M_(n,e){let r=O_.resolve(n);await ie(async()=>{if(Ie("\u{1F311} Liquid Shadow: Intelligence Deployment"),console.log(` ${_.bold("Target")}: ${_.cyan(r)}`),console.log(` ${_.bold("Objective")}: ${e.output?_.magenta("Data Extraction"):_.green("Semantic Mapping")}`),console.log(""),!e.output){let t=tt();t.start("Engaging intelligence engines...");let o="",s=a=>{if(a.phase!==o){o=a.phase;let c={scan:"\u{1F4E1} Scanning topography",parse:"\u{1F9E9} Parsing symbols",embed:"\u{1F9E0} Generating vectors",persist:"\u{1F4BE} Hardening index",complete:"\u{1F3C1} Mapping complete"}[a.phase]||a.phase;t.message(`${c}...`)}if(a.total>0&&a.current>0){let c=Math.round(a.current/a.total*100);t.message(`${o==="parse"?"Parsing":"Processing"}: ${a.current}/${a.total} (${c}%)`)}};try{await ee(r,void 0,e.force,e.deep??!0,s),t.message("\u{1FA79} Running Nano-Repair healing...");let c=new Ce(r).detectAndRepairShifts();t.stop("Intelligence mapping successfully concluded."),console.log(""),console.log(` ${_.bold("Next Steps:")}`),console.log(` ${_.dim("view your repo stats")} -> ${_.bold(_.cyan("liquid-shadow dashboard"))}`),console.log(` ${_.dim("start a chat search")} -> ${_.bold(_.cyan('liquid-shadow search-concept "your query"'))}`),console.log(""),pt("Liquid Shadow is online.")}catch(a){throw t.stop(`Operation failed: ${a.message}`),a}finally{await de(r)}return}let i=tt();i.start("Engaging intelligence engines...");try{let t=await zn(r,5,e.level,e.subPath),o=O_.resolve(e.output);if((process.env.LIQUID_SHADOW_SANDBOX==="1"||process.env.LIQUID_SHADOW_SANDBOX==="true")&&!pn.isPathWithinRoot(r,o))throw new Error("Sandbox mode: output path must be inside the repository. Set LIQUID_SHADOW_SANDBOX=0 to allow external paths.");iI.writeFileSync(o,JSON.stringify(t,null,2)),i.stop(`Data extraction saved: ${_.bold(_.cyan(o))}`),pt("Extraction complete.")}catch(t){throw i.stop(`Extraction failed: ${t.message}`),t}finally{await de(r)}})}import{performance as j_}from"perf_hooks";import oI from"path";X();async function F_(n){let e=oI.resolve(n);await ie(async()=>{console.log(`
|
|
1050
|
-
${_.bold("Performance Benchmark - Liquid Shadow Intelligence")}`),console.log(` ${_.gray("Repository: ")} ${e}`),console.log(` ${_.yellow("Starting fresh index (DB deleted)...")}
|
|
1051
|
-
`);let r=j_.now();try{await ee(e,10,!0);let i=j_.now()-r,t=L.getInstance(e),o=t.files.getCount(),s=t.exports.getCount(),a=t.exports.getWithEmbeddingsCount();_e("Benchmark Results",`${_.bold("Total Time")}: ${i.toFixed(2)}ms (${(i/1e3).toFixed(2)}s)
|
|
1052
|
-
${_.bold("Files Processed")}: ${_.cyan(o.toString())}
|
|
1053
|
-
${_.bold("Symbols Extracted")}: ${_.cyan(s.toString())}
|
|
1054
|
-
${_.bold("Symbols Embedded")}: ${_.cyan(a.toString())} (${(a/s*100).toFixed(1)}%)
|
|
1055
|
-
`+"\u2500".repeat(40)+`
|
|
1056
|
-
${_.bold("Files/sec")}: ${_.green((o/(i/1e3)).toFixed(2))}
|
|
1057
|
-
${_.bold("Symbols/sec")}: ${_.green((s/(i/1e3)).toFixed(2))}
|
|
1058
|
-
${_.bold("ms per file")}: ${_.yellow((i/o).toFixed(2))}`,"green")}catch(i){throw console.error(`
|
|
1059
|
-
Benchmark failed during execution:`,i),i}finally{await de(e)}})}import uc from"path";async function U_(n,e){let r=uc.resolve(e.dir),i=uc.isAbsolute(n)?n:uc.resolve(r,n);await ie(async()=>{Ie("Execution Trace");let t=tt();t.start(`Tracing ${_.cyan(e.symbolName||uc.basename(i))}...`);try{let o=await nc({repoPath:r,filePath:i,symbolName:e.symbolName});t.stop("Trace complete."),o.isError?console.error(_.red(o.content[0].text)):_e("Flow Results",o.content[0].text,"magenta")}catch(o){throw t.stop(`Trace failed: ${o.message}`),o}finally{await de(r)}})}import sI from"path";async function Z_(n,e){let r=sI.resolve(n);await ie(async()=>{Ie("Shadow Sync");let i=tt();i.start("Synchronizing intelligence lifecycle...");try{let t=await ic({repoPath:r});i.stop("Sync complete."),t.isError?console.error(_.red(t.content[0].text)):(console.log(""),console.log(t.content[0].text),console.log(""))}catch(t){throw i.stop(`Sync failed: ${t.message}`),t}finally{await de(r)}})}ht();X();J();Je();import H_ from"path";async function W_(n,e,r){let i=e?H_.resolve(process.cwd(),e):process.cwd();if(n==="init"){$.info('Running full initialization (same as "index --force")...'),await ee(i,void 0,!0,!0);return}if(n==="tree"){$.info('For tree view, please use the "tree" command.');return}if(n==="topography"){await ee(i);let t=L.getInstance(i),o=Ge(t,i);console.log(`
|
|
1060
|
-
\u{1F3D7}\uFE0F Architecture Summary for ${H_.basename(i)}
|
|
1061
|
-
`),console.log(`Detected Pattern: **${o.pattern}** (Confidence: ${o.patternConfidence.toFixed(0)}%)`),o.insights.length>0&&(console.log(`
|
|
1062
|
-
Insights:`),o.insights.forEach(l=>console.log(`- ${l}`))),console.log(`
|
|
1063
|
-
Layer Distribution:`);let s=["Entry","Logic","Data","Utility","Infrastructure","Test","Types","Unknown"],a=Object.values(o.layers).reduce((l,u)=>l+u.count,0),c=l=>{switch(l){case"Entry":return"\u{1F6AA}";case"Logic":return"\u2699\uFE0F";case"Data":return"\u{1F4BE}";case"Utility":return"\u{1F527}";case"Infrastructure":return"\u{1F3D7}\uFE0F";case"Test":return"\u{1F9EA}";case"Types":return"\u{1F4DD}";default:return"\u2753"}};s.forEach(l=>{let u=o.layers[l],d=a>0?(u.count/a*100).toFixed(1):"0.0";console.log(`${c(l)} ${l.padEnd(14)} | ${u.count.toString().padStart(5)} files | ${d}%`)}),console.log(`
|
|
1064
|
-
Top Files by Layer:`),s.forEach(l=>{let u=o.layers[l];u.count!==0&&(console.log(`
|
|
1065
|
-
${c(l)} ${l}`),u.topFiles.forEach(d=>{console.log(` - ${d.path} (${d.confidence}% conf)`),d.signals.length>0&&console.log(` \u2514\u2500 ${d.signals.slice(0,1).join(", ")}`)}))});return}if(n==="scout"){let t=await rc({repoPath:i});console.log(t.content[0].text);return}if(n==="hologram"){let t=new pe(i);console.log(JSON.stringify(t.getSnapshot(),null,2));return}$.error(`Unknown recon mode: ${n}. Available: init, topography, scout, hologram`)}import Ki from"path";async function B_(n,e){let r=Ki.resolve(e.dir);await ie(async()=>{Ie("Semantic Concept Search");let i=tt();i.start(`Analyzing intent: "${_.bold(n)}"...`);try{let t=await Qa({repoPath:r,query:n});i.stop("Analysis complete.");let o=t.content[0].text;if(o.includes("Found")){let a=o.split("## ").slice(1).map(c=>{let[l,...u]=c.split(`
|
|
1066
|
-
|
|
1067
|
-
`),[d,p]=l.split(" ( "),f=(d??"").replace(/^\d+\.\s*/,"").trim(),m=u.find(h=>h.startsWith("**Summary**: "))?.replace("**Summary**: ","")||"";return{name:f,matchPct:p??"",summaryLine:m}});if(a.forEach(({name:c,matchPct:l,summaryLine:u})=>{_e(`${_.green(c)} ${_.dim("("+(l||""))}`,u,"blue"),console.log("")}),e.interactive&&a.length>1){let c=await xo("Inspect a file",a.map(l=>({value:{name:l.name},label:l.name,hint:l.summaryLine.slice(0,50)})),{limit:15});if(c){let l=c.name.startsWith(r)?c.name:Ki.join(r,c.name),u=await Wr({repoPath:r,filePath:l});u.content?.[0]&&(console.log(""),_e(_.bold("File summary"),u.content[0].text,"cyan"))}}}else console.log(o)}catch(t){throw i.stop(`Search failed: ${t.message}`),t}finally{await de(r)}})}async function G_(n,e){let r=Ki.resolve(e.dir);await ie(async()=>{Ie("Symbol Search");let i=tt();i.start(`Searching symbols: "${_.bold(n)}"...`);try{let t=await Ji({repoPath:r,query:n});i.stop("Search complete.");let o=t.content[0].text;try{let s=JSON.parse(o);if(Array.isArray(s)){if(console.log(""),vo(["Symbol","Kind","File","Line"],s.map(a=>[_.bold(_.green(a.name)),_.dim(a.kind??""),_.cyan(a.file??""),_.yellow(String(a.line??""))])),e.interactive&&s.length>1){let a=s.map(l=>({value:l,label:l.name,hint:`${l.file??""}:${l.line??""}`})),c=await xo("Inspect symbol",a,{limit:15});if(c){let l=await fn({repoPath:r,symbolName:c.name});l.content?.[0]&&(console.log(""),_e(_.bold(c.name),l.content[0].text,"cyan"))}}}else console.log(o)}catch{console.log(o)}}catch(t){throw i.stop(`Search failed: ${t.message}`),t}finally{await de(r)}})}async function J_(n,e){let r=Ki.resolve(e.dir);await ie(async()=>{Ie("Fuzzy Symbol Search");let i=tt();i.start(`Fuzzy matching: "${_.bold(n)}"...`);try{let t=await Ji({repoPath:r,query:n});i.stop("Search complete.");let o=t.content[0].text;if(o.includes("## ")){let a=o.split("## ").slice(1).map(c=>{let l=c.split(`
|
|
1068
|
-
`),u=l[0],d=l.find(b=>b.startsWith("**Match**:"))||"",p=l.find(b=>b.startsWith("**File**:"))||"",f=u.match(/`([^`]+)`/),m=f?f[1]:"",h=d.match(/\*\*Match\*\*: (.+) \((\d+)% confidence\)/),v=p.match(/`([^:]+):(\d+)`/);return{symbolName:m,file:v?v[1]:"",line:v?v[2]:"",matchType:h?h[1]:"",confidence:h?h[2]:""}});if(console.log(""),console.log(_.dim(`Found ${a.length} fuzzy match(es):`)),console.log(""),a.forEach((c,l)=>{console.log(`${_.dim(`${l+1}.`)} ${_.bold(_.green(c.symbolName))} ${_.dim(`(${c.matchType}, ${c.confidence}% match)`)}`),console.log(` ${_.cyan(c.file)}:${_.yellow(c.line)}`),console.log("")}),e.interactive&&a.length>1){let c=await xo("Inspect symbol",a.map(l=>({value:l,label:l.symbolName,hint:`${l.file}:${l.line}`})),{limit:15});if(c){let l=await fn({repoPath:r,symbolName:c.symbolName});l.content?.[0]&&(console.log(""),_e(_.bold(c.symbolName),l.content[0].text,"cyan"))}}}else console.log(o)}catch(t){throw i.stop(`Search failed: ${t.message}`),t}finally{await de(r)}})}async function q_(n,e){let r=Ki.resolve(e.dir);await ie(async()=>{Ie("Config Search");let i=tt();i.start(`Searching config: ${_.bold(n||"all")}...`);try{let t=await ec({repoPath:r,key:n,kind:e.kind});i.stop("Search complete."),_e("\u2699\uFE0F Results",t.content[0].text,"yellow")}finally{await de(r)}})}async function V_(n){let[e,r="."]=n;if(!e||!["install","uninstall","status"].includes(e)){console.log(""),console.log(` ${_.bold("Usage: ")} liquid-shadow hooks <install|uninstall|status> [path]`),console.log(""),console.log(` ${_.bold("Commands: ")}`),console.log(` ${_.cyan("install")} Install git hooks for automatic index refresh and symbol healing`),console.log(` ${_.cyan("uninstall")} Remove installed git hooks`),console.log(` ${_.cyan("status")} Check git hooks installation status`),console.log(""),console.log(` ${_.bold("Examples: ")}`),console.log(" liquid-shadow hooks install ."),console.log(" liquid-shadow hooks status /path/to/repo"),console.log("");return}await ie(async()=>{let i=fx("path").resolve(r);switch(e){case"install":{let t=await Br({repoPath:i,action:"install",enableAutoRefresh:!0,enableSymbolHealing:!0});if(console.log(""),console.log(` ${_.green("\u2714")} ${_.bold("Git hooks installed successfully")}`),console.log(""),t.content&&t.content[0])try{let o=JSON.parse(t.content[0].text);console.log(` ${_.bold("Installed hooks: ")}`),o.hooks.forEach(s=>{console.log(` ${_.cyan("\u2022")} ${s}`)}),console.log("")}catch{console.log(t.content[0].text)}break}case"uninstall":{await Br({repoPath:i,action:"remove"}),console.log(""),console.log(` ${_.green("\u2714")} ${_.bold("Git hooks uninstalled successfully")}`),console.log("");break}case"status":{let t=await Br({repoPath:i,action:"status"});if(console.log(""),console.log(` ${_.bold("Git Hooks Status")}`),console.log(""),t.content&&t.content[0])try{let o=JSON.parse(t.content[0].text);o.installed&&o.installed.length>0?(console.log(` ${_.green("\u2714")} Installed hooks:`),o.installed.forEach(s=>{console.log(` ${_.cyan("\u2022")} ${s}`)})):console.log(` ${_.yellow("\u26A0")} No hooks installed`),o.missing&&o.missing.length>0&&(console.log(""),console.log(` ${_.dim("Missing hooks: ")}`),o.missing.forEach(s=>{console.log(` ${_.dim("\u2022")} ${s}`)}))}catch{console.log(t.content[0].text)}console.log("");break}}})}import dc from"path";async function K_(n){let[e,...r]=n;if(!e||!["missions","link","fuse"].includes(e)){console.log(""),console.log(` ${_.bold("Usage: ")} liquid-shadow workspace <missions|link> [options]`),console.log(""),console.log(` ${_.bold("Commands: ")}`),console.log(` ${_.cyan("missions")} <paths...> Get unified view of missions across repositories`),console.log(` ${_.cyan("link")} <args...> Link missions across repositories`),console.log(` ${_.cyan("fuse")} <paths...> Create fused index for cross-repo search (use --name for custom name)`),console.log(""),console.log(` ${_.bold("Examples: ")}`),console.log(" liquid-shadow workspace missions /frontend /backend"),console.log(" liquid-shadow workspace link /frontend 5 /backend 12"),console.log(" liquid-shadow workspace fuse /frontend /backend --name my-app"),console.log("");return}await ie(async()=>{switch(e){case"missions":{if(r.length===0){console.error(` ${_.red("\u2716")} Please provide at least one repository path`);return}let i=r.map(o=>dc.resolve(o)),t=await sc({repoPaths:i});if(console.log(""),console.log(` ${_.bold("Workspace Missions")}`),console.log(""),t.content&&t.content[0]){let o=JSON.parse(t.content[0].text);o.missions&&o.missions.length>0?o.missions.forEach(s=>{console.log(` ${_.cyan("\u2022")} ${_.bold(s.name)} (ID: ${s.id})`),console.log(` ${_.dim("Repo: ")} ${s.repo_path}`),console.log(` ${_.dim("Status: ")} ${s.status}`),console.log(` ${_.dim("Branch: ")} ${s.git_branch||"N/A"}`),s.cross_repo_links&&s.cross_repo_links.length>0&&console.log(` ${_.dim("Links: ")} ${s.cross_repo_links.length} cross-repo link(s)`),console.log("")}):(console.log(` ${_.yellow("\u26A0")} No missions found`),console.log(""))}break}case"link":{if(r.length<4){console.error(""),console.error(` ${_.red("\u2716")} Usage: workspace link <parent-repo> <parent-id> <child-repo> <child-id> [relationship]`),console.error("");return}let[i,t,o,s,a]=r;await ac({parentRepoPath:dc.resolve(i),parentMissionId:parseInt(t,10),childRepoPath:dc.resolve(o),childMissionId:parseInt(s,10),relationship:a}),console.log(""),console.log(` ${_.green("\u2714")} ${_.bold("Missions linked successfully")}`),console.log(` ${_.dim("Parent: ")} ${i} (Mission ${t})`),console.log(` ${_.dim("Child: ")} ${o} (Mission ${s})`),a&&console.log(` ${_.dim("Relationship: ")} ${a}`),console.log("");break}case"fuse":{if(r.length===0){console.error(` ${_.red("\u2716")} Please provide at least one repository path`);return}let i,t=[];for(let s=0;s<r.length;s++)r[s]==="--name"&&s+1<r.length?(i=r[s+1],s++):t.push(dc.resolve(r[s]));let o=await cc({repoPaths:t,name:i});if(console.log(""),console.log(` ${_.green("\u2714")} ${_.bold("Fused Index Created")}`),o.content&&o.content[0]){let s=JSON.parse(o.content[0].text);console.log(` ${_.dim("Name: ")} ${s.fused_index.name}`),console.log(` ${_.dim("Path: ")} ${s.fused_index.path}`),console.log(` ${_.dim("Repos: ")} ${s.fused_index.attachedRepos}`),console.log(""),console.log(` ${_.bold("Instructions:")}`),console.log(` ${s.instructions}`)}console.log("");break}}})}import aI from"path";var ye={..._,box:_e,table:vo,list:wh};async function Y_(n){let[e,...r]=n;if(!e||!["plan","briefing","update","log","synthesize","graph"].includes(e)){console.log(""),console.log(` ${ye.bold("Usage: ")} liquid-shadow mission <action> [options]`),console.log(""),console.log(` ${ye.bold("Actions: ")}`),console.log(` ${ye.cyan("plan")} <repo> <name> <goal> Plan a new mission`),console.log(` ${ye.cyan("update")} <repo> <id> <status> Update mission status`),console.log(` ${ye.cyan("log")} <repo> <id> <type> <msg> Log a mission discovery/intent`),console.log(` ${ye.cyan("briefing")} <repo> [--branch] Get mission briefing`),console.log(` ${ye.cyan("synthesize")} <repo> <id> Distill mission into ADR`),console.log(` ${ye.cyan("graph")} <repo> [id] Generate mission lineage graph`),console.log("");return}await ie(async()=>{let i=r[0]?aI.resolve(r[0]):process.cwd();switch(e){case"plan":{let[t,o,s]=r;if(!o||!s){console.error(` ${ye.red("\u2716")} Usage: mission plan <repo> <name> <goal>`);return}let a=await Za({repoPath:i,name:o,goal:s}),c=JSON.parse(a.content[0].text);console.log(` ${ye.green("\u2714")} Mission planned (ID: ${c.missionId})`);break}case"update":{let[t,o,s]=r;if(!o||!s){console.error(` ${ye.red("\u2716")} Usage: mission update <repo> <id> <status>`);return}await Ga({repoPath:i,missionId:parseInt(o),status:s}),console.log(` ${ye.green("\u2714")} Status updated to ${s}`);break}case"log":{let[t,o,s,...a]=r;if(!o||!s||a.length===0){console.error(` ${ye.red("\u2716")} Usage: mission log <repo> <id> <type> <message>`);return}await qa({repoPath:i,missionId:parseInt(o),type:s,content:a.join(" ")}),console.log(` ${ye.green("\u2714")} Intent logged`);break}case"synthesize":{let[t,o]=r;if(!o){console.error(` ${ye.red("\u2716")} Usage: mission synthesize <repo> <id>`);return}let s=await Ja({repoPath:i,missionId:parseInt(o)});console.log(""),ye.box("Mission Synthesis (ADR)",s.content[0].text,"magenta");break}case"graph":{let[t,o]=r,s=await Ka({repoPath:i,missionId:o?parseInt(o):void 0,format:"mermaid"});console.log(""),console.log(s.content[0].text);break}case"briefing":{let t=await Ur({repoPath:i});if(t.content&&t.content[0]){let o=t.content[0].text;try{let s=JSON.parse(o);if(s.mission){console.log(""),console.log(ye.bold(ye.cyan(` Mission Dashboard: ${s.mission.name} `))),ye.box("Tactical Goal",s.mission.goal,"cyan");let a=s.mission.status==="completed"?"green":s.mission.status==="failed"?"red":"yellow",c=[["Status",ye.bold(ye[a](s.mission.status.toUpperCase()))],["ID",`#${s.mission.id}`],["Branch",s.mission.git_branch||"main"]];ye.table(["Field","Value"],c),s.recent_activity&&s.recent_activity.length>0&&(console.log(` ${ye.bold("Recent Activity:")}`),ye.list(s.recent_activity.slice(0,5).map(l=>`${ye.dim(`[${l.type.toUpperCase()}]`)} ${l.content}`)))}else console.log(o)}catch{console.log(o)}}break}}})}import Zf from"path";async function X_(n){let[e,...r]=n;if(!e||!["symbol","file"].includes(e)){console.log(""),console.log(` ${_.bold("Usage: ")} liquid-shadow inspect <symbol|file> [options]`),console.log(""),console.log(` ${_.bold("Actions: ")}`),console.log(` ${_.cyan("symbol")} <repo> <name> Read source code for a symbol`),console.log(` ${_.cyan("file")} <repo> <path> Get a token-efficient file summary`),console.log("");return}await ie(async()=>{let i=r[0]?Zf.resolve(r[0]):process.cwd();if(e==="symbol"){let t=r[1];if(!t){console.error(` ${_.red("\u2716")} Please provide a symbol name`);return}let o=await fn({repoPath:i,symbolName:t});console.log(""),o.content&&o.content[0]&&console.log(o.content[0].text)}else{let t=r[1];if(!t){console.error(` ${_.red("\u2716")} Please provide a file path`);return}let o=Zf.isAbsolute(t)?t:Zf.join(i,t),s=await Wr({repoPath:i,filePath:o});console.log(""),s.content&&s.content[0]&&console.log(s.content[0].text)}})}var Q_=["index","status","metrics","benchmark","tree","trace","watch","search-config","search-concept","search-symbol","search-fuzzy","hooks","workspace","mission","inspect","completion"],cI=["--help","-h","--version","-v","--dir","-d"],lI={index:["--output","-o","--level","-l","--subPath","--force","--deep"],tree:["--subPath","--depth","-d"],trace:["--dir","-d"],"search-config":["--dir","-d","--kind"],"search-concept":["--dir","-d","--interactive","-i"],"search-symbol":["--dir","-d","--interactive","-i"],"search-fuzzy":["--dir","-d","--interactive","-i"]};function uI(){let n=Object.entries(lI).map(([i,t])=>` ${i}) opts="${t.join(" ")}" ;;`).join(`
|
|
1069
|
-
`),e=Q_.join(" ");return`# Bash completion for liquid-shadow. Usage: source <(liquid-shadow completion bash)
|
|
997
|
+
*Generated by Liquid Shadow Reasoning Engine v1*`,t){this.intentLogs.create({mission_id:e,type:"adr",content:o,confidence:1,symbol_id:null,file_path:null,symbol_name:null,signature:null,commit_sha:null});try{await this.persistencePivot.syncMissionToGitNotes(e),Hi.info({missionId:e},"Tactical Briefing synthesized, archived, and synced to Git Notes.")}catch(a){Hi.error({missionId:e,error:a},"Failed to sync ADR to Git Notes")}}else Hi.info({missionId:e},"Tactical Briefing synthesized (dry-run).");return{missionId:e,adr:o,metrics:{totalLogs:n.length,symbolCount:r.size}}}gatherConsolidatedLogs(e,t=0){let n=this.intentLogs.findByMissionPreferCrystal(e,500);if(t>2)return n;let i=this.missions.findByParentId(e);for(let r of i)n.push(...this.gatherConsolidatedLogs(r.id,t+1));return n.filter(r=>r.type!=="adr"&&r.type!=="system")}};q();import{Visitor as xd}from"@swc/core/Visitor.js";import*as rc from"@swc/core";var vd=S.child({module:"verification-engine"}),Gs=class extends xd{foundUsage=!1;foundImport=!1;rule;currentFunctionName=null;constructor(e){super(),this.rule=e}visitImportDeclaration(e){return this.rule.type==="import"&&e.source.value===this.rule.target&&(this.foundImport=!0),super.visitImportDeclaration(e)}visitFunctionDeclaration(e){let t=this.currentFunctionName;this.currentFunctionName=e.identifier.value;let n=super.visitFunctionDeclaration(e);return this.currentFunctionName=t,n}visitCallExpression(e){return this.rule.type==="usage"&&e.callee.type==="Identifier"&&e.callee.value===this.rule.target&&(!this.rule.context||this.currentFunctionName===this.rule.context)&&(this.foundUsage=!0),super.visitCallExpression(e)}},zi=class{async verify(e,t){try{let n=await rc.parse(e,{syntax:"typescript",tsx:!0,comments:!1}),i=new Gs(t);i.visitProgram(n);let r=!1,o=[];if(t.type==="import")r=i.foundImport,r||o.push(`Required import "${t.target}" not found.`);else if(t.type==="usage"){if(r=i.foundUsage,!r){let a=t.context?` in function "${t.context}"`:"";o.push(`Required usage of "${t.target}"${a} not found.`)}}else t.type==="pattern"&&(r=new RegExp(t.target).test(e),r||o.push(`Required pattern "${t.target}" not found.`));return{passed:r,errors:o}}catch(n){return vd.error({error:n},"Verification failed due to parse error"),{passed:!1,errors:[`Parse error: ${n.message}`]}}}};gn();import oc from"path";import Ui from"fs";var Le=S.child({module:"mcp:tools:ops:track"});function qs(s,e){return oc.isAbsolute(e)?e:oc.join(s,e)}async function ac(s,e,t){let{missions:n,intentLogs:i}=O.getInstance(s),r=n.findById(e);if(!r?.parent_id)return;let o=n.findByParentId(r.parent_id);if(!o.every(l=>l.status==="completed"))return;let c=n.findById(r.parent_id);if(!(!c||c.status==="completed")){Le.info({parentId:c.id,childCount:o.length},"All children completed \u2014 cascading parent completion"),n.updateStatus(c.id,"completed",t||void 0),n.clearWorkingSet(c.id),i.create({mission_id:c.id,type:"system",content:`Parent auto-completed: all ${o.length} child missions finished`,confidence:1,symbol_id:null,file_path:null,symbol_name:null,signature:null,commit_sha:t});try{await new tt(s).distillMission(c.id),Le.info({parentId:c.id},"Parent Auto-Synthesis completed")}catch(l){Le.info({parentId:c.id,...ye(l)},"Parent Auto-Synthesis deferred")}try{await new Fe(s).syncMissionToGitNotes(c.id)}catch(l){Le.info({parentId:c.id,...ye(l)},"Parent Git Notes sync deferred")}await ac(s,c.id,t)}}async function cc(s){let{repoPath:e,missionId:t,stepId:n,status:i,contextPivot:r,updates:o,artifacts:a}=s,{missions:c,intentLogs:l}=O.getInstance(e),p=De(e);Le.info({repoPath:e,missionId:t,singleStep:n,batchCount:o?.length,artifactCount:a?.length},"Updating mission status");try{if(a&&Array.isArray(a))for(let h of a)c.addArtifact(t,h.type,h.identifier,h.metadata);let u=[];if(o&&Array.isArray(o)&&u.push(...o),n&&i&&u.push({stepId:n,status:i,contextPivot:r}),i&&!n){if(c.updateStatus(t,i,p||void 0),i==="completed"&&c.clearWorkingSet(t),l.create({mission_id:t,type:"system",content:`Mission status changed to "${i}"`,confidence:1,symbol_id:null,file_path:null,symbol_name:null,signature:null,commit_sha:p}),i==="completed"){try{await new tt(e).distillMission(t),Le.info({missionId:t},"Auto-Synthesis completed successfully")}catch(h){Le.info({missionId:t,...ye(h)},"Auto-Synthesis deferred or failed")}await ac(e,t,p)}if(!u.length)return{content:[{type:"text",text:JSON.stringify({missionId:t,status:i,message:"Mission status updated successfully.",artifacts_added:a?.length||0,commit:p},null,2)}]}}if(u.length===0&&(!a||a.length===0))throw new Error("No updates provided. Must specify either 'updates', 'stepId'/'status', 'status' (top-level), or 'artifacts'.");let d=[];for(let h of u){let{stepId:m,status:f,contextPivot:_}=h,g=c.findById(t);if(!g)throw new Error(`Mission ID ${t} not found`);let b=JSON.parse(g.strategy_graph||"{}"),w=null;if(Array.isArray(b)?w=b.find(x=>x.id===m):b.nodes&&Array.isArray(b.nodes)?w=b.nodes.find(x=>x.id===m):b.steps?Array.isArray(b.steps)?w=b.steps.find(x=>x.id===m):w=b.steps[m]:b[m]&&(w=b[m]),!w)throw new Error(`Step ID "${m}" not found`);if(f==="completed"&&w.verification){let x=new zi,R=Array.isArray(w.verification)?w.verification:[w.verification];for(let k of R){let D=k;if(typeof k=="string"&&(D={type:"pattern",target:k}),!D||!D.target){Le.warn({rule:k},"Skipping invalid verification rule (missing target)");continue}let U=D.filePath;if(U&&(U=qs(e,U)),U){if(!Ui.existsSync(U))throw new Error(`Verification failed: File not found at ${U}`);let P=await x.verify(Ui.readFileSync(U,"utf8"),D);if(!P.passed)throw new Error(`Verification failed: ${P.errors.join("")}`)}else{let P=c.getWorkingSet(t),E=!1;P.length===0&&Le.warn("No working set files to verify against for rule");for(let T of P){let I=qs(e,T.file_path);if(!Ui.existsSync(I))continue;if((await x.verify(Ui.readFileSync(I,"utf8"),D)).passed){E=!0;break}}if(!E)throw new Error(`Verification failed: Rule "${D.target}" not satisfied in any working set file.`)}}}if(w.status=f,c.update(t,{strategy_graph:JSON.stringify(b),commit_sha:p}),l.create({mission_id:t,type:"system",content:`Step "${m}" updated to "${f}"`,confidence:1,symbol_id:null,file_path:null,symbol_name:null,signature:null,commit_sha:p}),_){let x=_.trim();if(x.startsWith("{")||x.startsWith("["))try{let R=JSON.parse(x);if(R.files&&Array.isArray(R.files)){c.clearWorkingSet(t);for(let k of R.files)c.addToWorkingSet(t,qs(e,k))}}catch(R){Le.warn({error:R},"Failed to apply context pivot")}}d.push({stepId:m,status:f})}try{await new Fe(e).syncMissionToGitNotes(t)}catch(h){Le.info({missionId:t,...ye(h)},"Git Notes sync deferred")}return{content:[{type:"text",text:JSON.stringify({missionId:t,updates:d,artifacts_added:a?.length||0,message:"Status updated",commit:p},null,2)}]}}catch(u){let d=At(u);throw Le.error({repoPath:e,...ye(u)},"Failed to update status"),new Error(`Failed to update status: ${d}`)}}q();var dc=S.child({module:"mcp:tools:ops:graph"});async function mc(s){let{repoPath:e,missionId:t,depth:n,limit:i,format:r="mermaid"}=s;dc.info({repoPath:e,missionId:t,format:r},"Generating mission graph");try{let{GraphExporterService:o}=await Promise.resolve().then(()=>(uc(),pc));return{content:[{type:"text",text:await new o(e).generateGraph({includeCompleted:!0,format:r,focusMissionId:t,depth:n,limit:i})}]}}catch(o){throw dc.error({error:o,repoPath:e},"Failed to generate mission graph"),new Error(`Failed to generate mission graph: ${o.message}`)}}V();q();import hc from"node:path";var Xt=S.child({module:"mcp:tools:ops:log"}),Td=["in-progress","verifying"];function Rd(s){for(let e of Td){let t=s.find(n=>n.status===e);if(t)return t.id}return s[0]?.id??null}function kd(s,e){return e?hc.isAbsolute(e)?e:hc.join(s,e):null}async function fc(s){let{repoPath:e,missionId:t,type:n,content:i,filePath:r,symbolName:o,standalone:a}=s;Xt.info({repoPath:e,type:n,symbolName:o,standalone:a},"Logging intent");let{missions:c,exports:l,intentLogs:p}=O.getInstance(e),u=kd(e,r);try{let d=t??null,h=me(e)||void 0;if(a)d=null,Xt.debug("Standalone intent requested; mission auto-resolution skipped");else if(d){if(!c.findById(d))throw new Error(`Mission ${d} not found. Use shadow_ops_briefing to see available missions.`)}else{let w=c.findActive(h);w.length>0?(d=Rd(w),Xt.debug({missionId:d,currentBranch:h},"Auto-resolved to active mission on current branch")):(d=null,Xt.debug({currentBranch:h},"No active mission found on current branch; logging as system/unlinked intent"))}let m=null,f=null,_=o||null,g=u;if(o){let x=(u?l.findByNameAndFile(o,u):l.findByName(o))[0];x?(m=x.id,f=x.signature,_=x.name,g=x.file_path||g):Xt.warn({symbolName:o,filePath:u??r},"Symbol not found for intent linking")}let b=p.create({mission_id:d,symbol_id:m,file_path:g,type:n,content:i,confidence:1,symbol_name:_,signature:f,commit_sha:null});return d&&g&&c.addToWorkingSet(d,g,m?"symbol":"intent"),{content:[{type:"text",text:JSON.stringify({logId:b,missionId:d,symbolId:m,status:"logged",message:m?`Intent linked to symbol "${o}"`:"Intent logged (unlinked)"},null,2)}]}}catch(d){throw Xt.error({error:d,repoPath:e},"Failed to log intent"),new Error(`Failed to log intent: ${d instanceof Error?d.message:String(d)}`)}}V();q();var gc=S.child({module:"mcp:tools:ops:synthesize"});async function yc(s){let{repoPath:e,missionId:t}=s;gc.info({repoPath:e,missionId:t},"Synthesizing mission");let{missions:n}=O.getInstance(e);try{if(!n.findById(t))throw new Error(`Mission ${t} not found`);let o=await new tt(e).distillMission(t);return{content:[{type:"text",text:JSON.stringify({missionId:t,adr:o.adr,metrics:o.metrics},null,2)}]}}catch(i){throw gc.error({error:i,repoPath:e},"Failed to synthesize ADR"),new Error(`Failed to synthesize ADR: ${i instanceof Error?i.message:String(i)}`)}}import Cd from"path";var ne={...y,box:se,table:jn,list:Nr};async function bc(s){let[e,...t]=s;if(!e||!["plan","briefing","update","log","synthesize","graph"].includes(e)){console.log(""),console.log(` ${ne.bold("Usage: ")} liquid-shadow mission <action> [options]`),console.log(""),console.log(` ${ne.bold("Actions: ")}`),console.log(` ${ne.cyan("plan")} <repo> <name> <goal> Plan a new mission`),console.log(` ${ne.cyan("update")} <repo> <id> <status> Update mission status`),console.log(` ${ne.cyan("log")} <repo> <id> <type> <msg> Log a mission discovery/intent`),console.log(` ${ne.cyan("briefing")} <repo> [--branch] Get mission briefing`),console.log(` ${ne.cyan("synthesize")} <repo> <id> Distill mission into ADR`),console.log(` ${ne.cyan("graph")} <repo> [id] Generate mission lineage graph`),console.log("");return}await Y(async()=>{let n=t[0]?Cd.resolve(t[0]):process.cwd();switch(e){case"plan":{let[i,r,o]=t;if(!r||!o){console.error(` ${ne.red("\u2716")} Usage: mission plan <repo> <name> <goal>`);return}let a=await nc({repoPath:n,name:r,goal:o}),c=JSON.parse(a.content[0].text);console.log(` ${ne.green("\u2714")} Mission planned (ID: ${c.missionId})`);break}case"update":{let[i,r,o]=t;if(!r||!o){console.error(` ${ne.red("\u2716")} Usage: mission update <repo> <id> <status>`);return}await cc({repoPath:n,missionId:parseInt(r),status:o}),console.log(` ${ne.green("\u2714")} Status updated to ${o}`);break}case"log":{let[i,r,o,...a]=t;if(!r||!o||a.length===0){console.error(` ${ne.red("\u2716")} Usage: mission log <repo> <id> <type> <message>`);return}await fc({repoPath:n,missionId:parseInt(r),type:o,content:a.join(" ")}),console.log(` ${ne.green("\u2714")} Intent logged`);break}case"synthesize":{let[i,r]=t;if(!r){console.error(` ${ne.red("\u2716")} Usage: mission synthesize <repo> <id>`);return}let o=await yc({repoPath:n,missionId:parseInt(r)});console.log(""),ne.box("Mission Synthesis (ADR)",o.content[0].text,"magenta");break}case"graph":{let[i,r]=t,o=await mc({repoPath:n,missionId:r?parseInt(r):void 0,format:"mermaid"});console.log(""),console.log(o.content[0].text);break}case"briefing":{let i=await sc({repoPath:n});if(i.content&&i.content[0]){let r=i.content[0].text;try{let o=JSON.parse(r);if(o.mission){console.log(""),console.log(ne.bold(ne.cyan(` Mission Dashboard: ${o.mission.name} `))),ne.box("Tactical Goal",o.mission.goal,"cyan");let a=o.mission.status==="completed"?"green":o.mission.status==="failed"?"red":"yellow",c=[["Status",ne.bold(ne[a](o.mission.status.toUpperCase()))],["ID",`#${o.mission.id}`],["Branch",o.mission.git_branch||"main"]];ne.table(["Field","Value"],c),o.recent_activity&&o.recent_activity.length>0&&(console.log(` ${ne.bold("Recent Activity:")}`),ne.list(o.recent_activity.slice(0,5).map(l=>`${ne.dim(`[${l.type.toUpperCase()}]`)} ${l.content}`)))}else console.log(r)}catch{console.log(r)}}break}}})}import Js from"path";async function _c(s){let[e,...t]=s;if(!e||!["symbol","file"].includes(e)){console.log(""),console.log(` ${y.bold("Usage: ")} liquid-shadow inspect <symbol|file> [options]`),console.log(""),console.log(` ${y.bold("Actions: ")}`),console.log(` ${y.cyan("symbol")} <repo> <name> Read source code for a symbol`),console.log(` ${y.cyan("file")} <repo> <path> Get a token-efficient file summary`),console.log("");return}await Y(async()=>{let n=t[0]?Js.resolve(t[0]):process.cwd();if(e==="symbol"){let i=t[1];if(!i){console.error(` ${y.red("\u2716")} Please provide a symbol name`);return}let r=await Kt({repoPath:n,symbolName:i});console.log(""),r.content&&r.content[0]&&console.log(r.content[0].text)}else{let i=t[1];if(!i){console.error(` ${y.red("\u2716")} Please provide a file path`);return}let r=Js.isAbsolute(i)?i:Js.join(n,i),o=await Ci({repoPath:n,filePath:r});console.log(""),o.content&&o.content[0]&&console.log(o.content[0].text)}})}var Ec=["index","status","metrics","benchmark","tree","trace","watch","search-config","search-concept","search-symbol","search-fuzzy","hooks","workspace","mission","inspect","completion"],Id=["--help","-h","--version","-v","--dir","-d"],Ld={index:["--output","-o","--level","-l","--subPath","--force","--deep"],tree:["--subPath","--depth","-d"],trace:["--dir","-d"],"search-config":["--dir","-d","--kind"],"search-concept":["--dir","-d","--interactive","-i"],"search-symbol":["--dir","-d","--interactive","-i"],"search-fuzzy":["--dir","-d","--interactive","-i"]};function $d(){let s=Object.entries(Ld).map(([n,i])=>` ${n}) opts="${i.join(" ")}" ;;`).join(`
|
|
998
|
+
`),e=Ec.join(" ");return`# Bash completion for liquid-shadow. Usage: source <(liquid-shadow completion bash)
|
|
1070
999
|
_liquid_shadow() {
|
|
1071
1000
|
local cur="\${COMP_WORDS[COMP_CWORD]}"
|
|
1072
1001
|
local words=("\${COMP_WORDS[@]}")
|
|
@@ -1076,10 +1005,10 @@ _liquid_shadow() {
|
|
|
1076
1005
|
if [[ "\${words[$i]}" != -* ]]; then cmd="\${words[$i]}"; break; fi
|
|
1077
1006
|
((i++))
|
|
1078
1007
|
done
|
|
1079
|
-
local opts="${
|
|
1008
|
+
local opts="${Id.join(" ")}"
|
|
1080
1009
|
if [ -n "$cmd" ]; then
|
|
1081
1010
|
case "$cmd" in
|
|
1082
|
-
${
|
|
1011
|
+
${s}
|
|
1083
1012
|
esac
|
|
1084
1013
|
else
|
|
1085
1014
|
COMPREPLY=($(compgen -W "${e}" -- "$cur"))
|
|
@@ -1088,11 +1017,11 @@ ${n}
|
|
|
1088
1017
|
COMPREPLY=($(compgen -W "$opts" -- "$cur"))
|
|
1089
1018
|
}
|
|
1090
1019
|
complete -F _liquid_shadow liquid-shadow
|
|
1091
|
-
`}function
|
|
1020
|
+
`}function Ad(){return`# Zsh completion for liquid-shadow. Usage: source <(liquid-shadow completion zsh)
|
|
1092
1021
|
# Run after compinit (e.g. in .zshrc after compinit)
|
|
1093
1022
|
|
|
1094
1023
|
_liquid_shadow() {
|
|
1095
|
-
local -a cmds; cmds=(${
|
|
1024
|
+
local -a cmds; cmds=(${Ec.map(e=>`'${e}'`).join(" ")})
|
|
1096
1025
|
if [ $CURRENT -eq 2 ]; then
|
|
1097
1026
|
_describe 'command' cmds
|
|
1098
1027
|
return
|
|
@@ -1109,7 +1038,18 @@ _liquid_shadow() {
|
|
|
1109
1038
|
_describe 'flag' fl
|
|
1110
1039
|
}
|
|
1111
1040
|
compdef _liquid_shadow liquid-shadow
|
|
1112
|
-
`}async function
|
|
1041
|
+
`}async function Sc(s){s==="bash"?console.log($d()):s==="zsh"?console.log(Ad()):(console.error("Usage: liquid-shadow completion <bash|zsh>"),console.error("Then: source <(liquid-shadow completion bash) # or zsh"),process.exit(1))}import Pd from"fs";import Md from"path";var Nd=2e3;async function wc(s){let e=Md.resolve(s);await Y(async()=>{pe("Watch mode");let t=Ke(e),n=null,i=()=>{n&&clearTimeout(n),n=setTimeout(async()=>{n=null;try{console.log(""),console.log(y.dim(" Changes detected, reindexing...")),await X(e,5,!1,!0),console.log(y.green(" Reindex complete."))}catch(r){console.error(y.red(" Reindex failed:"),r instanceof Error?r.message:r)}},Nd)};try{Pd.watch(e,{recursive:!0},(r,o)=>{o&&!o.includes("node_modules")&&i()}),console.log(y.cyan(` Watching ${e}`)),console.log(y.dim(" Ignore: "+(t.ignore?.length?t.ignore.join(", "):"default"))),Pe("Ctrl+C to stop"),await new Promise((r,o)=>{process.on("SIGINT",()=>o(new Error("SIGINT"))),process.on("SIGTERM",()=>o(new Error("SIGTERM")))}).catch(()=>{})}finally{n&&clearTimeout(n),await Q(e)}})}V();q();var Dd=S.child({module:"narrative-service"}),ji=class{missions;briefingEngine;repoPath;constructor(e){this.repoPath=e;let{missions:t}=O.getInstance(e);this.missions=t,this.briefingEngine=new tt(e)}async generateChronicle(e={}){Dd.info(e,"Generating Repo Chronicle...");let n=this.missions.findAll().filter(l=>l.parent_id===null&&l.status!=="planned");e.branch&&(n=n.filter(l=>!l.git_branch||l.git_branch===e.branch)),e.since&&(n=n.filter(l=>l.updated_at>=e.since)),e.until&&(n=n.filter(l=>l.updated_at<=e.until)),n.sort((l,p)=>p.updated_at-l.updated_at);let i=e.offset||0,r=e.limit||10;n=n.slice(i,i+r);let o=[],a=[],c=[];for(let l of n){let p=this.missions.findByParentId(l.id),u=p.length>0,d=await this.briefingEngine.distillMission(l.id,!1);if(u){let h=[];for(let f of p)h.push(await this.mapMissionToEpisode(f));h.unshift(await this.mapMissionToEpisode(l));let m={kind:"initiative",root_mission_id:l.id,title:l.name,strategy_graph:l.strategy_graph?JSON.parse(l.strategy_graph):{},episodes:e.compact?[]:h,synthesized_narrative:e.compact?this.truncateText(d.adr):d.adr||""};o.push(m),c.push(m)}else{let h=await this.mapMissionToEpisode(l,d.adr,e.compact);a.push(h),c.push(h)}}return{repo_path:this.repoPath,generated_at:Date.now(),initiatives:o,unattached_episodes:a,timeline:c}}async mapMissionToEpisode(e,t,n=!1){let i=t;return i||(i=(await this.briefingEngine.distillMission(e.id,!1)).adr),{kind:"episode",mission_id:e.id,title:e.name,goal:e.goal,outcome:e.outcome_contract,intents:[],adr_summary:n?this.truncateText(i):i}}truncateText(e,t=300){return e?e.length<=t?e:e.slice(0,t)+"... (truncated)":""}renderChronicleMarkdown(e){let t=`# Repository Chronicle
|
|
1042
|
+
|
|
1043
|
+
`;if(t+=`*Generated at ${new Date(e.generated_at).toISOString()}*
|
|
1044
|
+
|
|
1045
|
+
`,e.timeline&&e.timeline.length>0)for(let n of e.timeline)n.kind==="initiative"?(t+=`### \u{1F9EC} ${n.title} (Mission #${n.root_mission_id})
|
|
1046
|
+
`,t+=`${n.synthesized_narrative}
|
|
1047
|
+
|
|
1048
|
+
`):(t+=`### \u269B\uFE0F ${n.title} (Mission #${n.mission_id})
|
|
1049
|
+
`,t+=`${n.adr_summary}
|
|
1050
|
+
|
|
1051
|
+
`),t+=`---
|
|
1052
|
+
`;return t}};q();import Od from"path";async function xc(s,e){let t=Od.resolve(s||process.cwd()),n=e.format==="json"?"json":"markdown",i=S.child({module:"cli:chronicle",repoPath:t});i.info("Generating repository chronicle...");try{let r=new ji(t),o=await r.generateChronicle({limit:e.limit,offset:e.offset,since:e.since,until:e.until});console.log(n==="json"?JSON.stringify(o,null,2):r.renderChronicleMarkdown(o))}catch(r){i.error({error:r},"Failed to generate chronicle"),console.error(`Error: ${r instanceof Error?r.message:String(r)}`),process.exit(1)}}import bt from"fs";import Zt from"path";import Hd from"os";import $e from"fs";import Je from"path";import Fd from"os";var vc={shadow_audit:'---\nname: audit\ndescription: Perform codebase health audits to identify dead code, circular dependencies, and technical debt. Use when auditing code quality, finding unused code, detecting circular dependencies, or when the user asks about codebase health, technical debt, or code cleanup.\n---\n\n# Codebase Audit\n\nComprehensive health audit using Shadow analyze toolkit.\n\n## \u{1F680} Workflow\n\n1. **Session Context**: `shadow_ops_context` (repoPath) \u2014 **ONE CALL** for hologram + chronicle + briefing. Get architecture baseline.\n2. **Dead Code Detection**: `shadow_analyze_debt` (mode: "dead-code", limit: 100, includeTests: false, repoPath) \u2014 Unused exports.\n3. **Circular Dependencies**: `shadow_analyze_debt` (mode: "circular-deps", limit: 20, repoPath) \u2014 Import cycles.\n4. **Layer Integrity** (optional): `shadow_recon_topography` (repoPath) \u2014 Detailed layer analysis if hologram summary isn\'t enough.\n5. **Log Findings**: `shadow_ops_log` (missionId, type: "discovery", content, repoPath).\n6. **Create Cleanup Mission** (optional): `shadow_ops_plan` (name: "Codebase Cleanup", templateId: "refactoring", templateVars, repoPath).\n\n## \u{1F6E0} Precise Tooling\n\n| Audit Target | Atomic Tool |\n| :------------------- | :------------------------------------------------------------------------------------- |\n| **Session Start** \u{1F680} | `shadow_ops_context` (repoPath) \u2014 **START HERE** for baseline |\n| **Architecture** | `shadow_recon_hologram` (repoPath) \u2014 if you need standalone |\n| **Dead Code** | `shadow_analyze_debt` (mode: "dead-code", limit: 100, **confidenceThreshold: "high"**) |\n| **Circular Deps** | `shadow_analyze_debt` (mode: "circular-deps") |\n| **Layers** | `shadow_recon_topography` \u2014 detailed breakdown if needed |\n| **Config Audit** | `shadow_search_config` (kind: "Env", **showUsage: true**) \u2014 find orphaned env vars |\n| **Event Mesh** | `shadow_analyze_mesh` (repoPath) \u2014 audit all HTTP routes, socket events, pubsub topics |\n| **Type Integrity** | `shadow_analyze_type_graph` (filePath, repoPath) \u2014 interface/type inheritance chains |\n| **Theme Patterns** | `shadow_ops_crystallize_theme` (query, repoPath) \u2014 recurring issues across missions |\n\n## \u{1F4A1} Intelligence Options\n\n- **`shadow_analyze_debt` confidence levels**: Use `confidenceThreshold: "high"` for likely dead code, `"medium"` for possibly intentional (test fixtures, etc.), `"all"` for everything.\n- **`shadow_analyze_debt` exclusion filters**: Use `excludePatterns`, `includeMigrations: false`, `includeFixtures: false` to reduce noise.\n- **`shadow_search_config` with `showUsage: true`**: Cross-references config vars with code to show usage counts and identify orphaned vars (defined but never used).\n\n## \u{1F50D} Health Criteria\n\n- **Critical Issues**: Circular deps in core logic, >50 dead exports, orphaned env vars with secrets\n- **Warning Signs**: Layer violations (Test \u2192 Logic), >20 dead exports, >10 orphaned configs\n- **Good Health**: Clean layers, <10 dead exports, no circular deps, all configs in use\n',shadow_chronicle:`---
|
|
1113
1053
|
name: chronicle
|
|
1114
1054
|
description: Retrieve and analyze the repository's narrative archive as recorded in Git-native memory. Use when you need to understand historical decisions, catch up on repository progress, review recently completed missions, or when the user asks for a project history, changelog, or chronological overview of architectural changes.
|
|
1115
1055
|
---
|
|
@@ -1149,7 +1089,7 @@ Retrieve narrative archive from Git-native memory.
|
|
|
1149
1089
|
- **Progress Reports**: Show what's been done this week
|
|
1150
1090
|
|
|
1151
1091
|
**Note:** Chronicle reads from Git Notes, so it's persistent across branches and clones.
|
|
1152
|
-
`,
|
|
1092
|
+
`,shadow_continue:'---\nname: continue\ndescription: Get briefing, pick one mission from next_work_candidates, then work that mission to completion with all remaining steps in one run. Use when continuing work on missions, executing mission steps, or when the user asks to continue work, finish a mission, or proceed with development tasks.\n---\n\n**In one sentence:** Get briefing (+ optional trace), pick **one mission** from **next_work_candidates** (ranked by relevance), then work that mission to completion \u2014 all remaining steps in one run. Update and log as you go. No status reports; when you\'re done with that mission, it\'s done.\n\n---\n\n## 1. Context\n\n- **Option A (one shot):** `shadow_ops_context` (repoPath) \u2192 returns hologram + chronicle(5) + **briefing** (counts, **next_work_candidates** ranked by relevance). Use when you want architecture + history + backlog in one call at the start of /continue.\n- **Option B:** `shadow_ops_briefing` (scope: "project", repoPath) \u2192 **next_work_candidates** (relevance-ranked), hierarchy, analytics.\n - Use **altitude** to control output density: `orbit` (~200 tokens, counts + candidates only), `atmosphere` (default, strategy + crystals), `ground` (raw logs + working set + collisions).\n- `shadow_sync_trace` (repoPath) only if you care about external changes. Otherwise skip.\n\n## 2. Pick one mission\n\n- **`next_work_candidates`** are ranked by the MissionRelevanceScorer (recency \xD7 0.4 + activity \xD7 0.3 + status \xD7 0.2 + blockers \xD7 0.1). Higher score = more relevant.\n- Choose the top-ranked candidate. Prefer in-progress over planned. Parent-only missions (umbrellas) are already filtered out.\n\n## 3. Work the whole mission\n\n- For that mission, run through **all remaining steps** (not just one):\n - **Surgical Discovery:** `shadow_analyze_flow` (symbolName, filePath, repoPath).\n - **Execute Step**: Set in-progress \u2192 implement \u2192 `shadow_ops_track` (missionId, stepId, status: "completed", contextPivot, repoPath).\n - **Atomic Logging:** At least once per step. `shadow_ops_log` (missionId, type: "decision", content, symbolName, repoPath).\n - **Inter-agent handoff** (multi-agent pipelines only): When handing off findings to another agent, call `shadow_ops_handoff` (missionId, role, summary, findings, repoPath) to persist a typed artifact with embedding. The receiving agent calls `shadow_ops_handoff_read` (missionId, query, repoPath) to semantically retrieve relevant prior handoffs.\n- **Seal the mission**: `shadow_ops_track` (missionId, status: "completed", repoPath).\n - This **auto-triggers**: ADR synthesis, Git Notes persistence, and cascade parent completion (if all sibling missions are also done, the parent auto-completes too).\n - No need to call `shadow_ops_synthesize` separately \u2014 it\'s automatic on completion.\n- **Optional \u2014 Crystallize** (for long-running missions with many logs): `shadow_ops_crystallize` (missionId, repoPath) compresses raw intent logs into a single crystal summary. Useful mid-mission to keep briefings lean.\n- **Optional \u2014 Theme Crystallize** (cross-mission patterns): `shadow_ops_crystallize_theme` (query, repoPath) clusters semantically related intent logs across ALL missions to surface recurring architectural themes. Use when you sense a pattern repeating across missions.\n\n## \u{1F6E0} Precise Tooling\n\n| Action | Atomic Tool | Example |\n| :--------------------- | :----------------------------- | :--------------------------------------------------------------- |\n| **Context (one shot)** | `shadow_ops_context` | repoPath \u2014 hologram + chronicle + briefing |\n| **Briefing** | `shadow_ops_briefing` | scope: "project", altitude: "orbit", repoPath |\n| **Flow Trace** | `shadow_analyze_flow` | symbolName: "handleRequest", filePath, repoPath |\n| **Step Update** | `shadow_ops_track` | missionId: 4, stepId: "s2", status: "completed" |\n| **Intent Log** | `shadow_ops_log` | missionId: 4, type: "fix", content: "..." |\n| **Complete Mission** | `shadow_ops_track` | missionId: 4, status: "completed" \u2014 auto-synthesizes ADR |\n| **Crystallize** | `shadow_ops_crystallize` | missionId: 4 \u2014 compress logs mid-mission |\n| **Theme Crystallize** | `shadow_ops_crystallize_theme` | query: "auth patterns" \u2014 cross-mission semantic clustering |\n| **Handoff (write)** | `shadow_ops_handoff` | missionId, role: "RECON", summary, findings \u2014 persist artifact |\n| **Handoff (read)** | `shadow_ops_handoff_read` | missionId, query: "auth findings" \u2014 semantic retrieval |\n| **Event Mesh** | `shadow_analyze_mesh` | repoPath \u2014 surface all HTTP routes, socket events, pubsub topics |\n| **Type Graph** | `shadow_analyze_type_graph` | filePath, repoPath \u2014 interface/type inheritance map |\n| **Explain Diff** | `shadow_analyze_explain_diff` | fromCommit, toCommit, repoPath \u2014 semantic diff narrative |\n\n_Note: Always use `symbolName` in `shadow_ops_log` to create Liquid Anchors._\n\n## 4. Don\'t\n\n- Don\'t do one step and stop \u2014 /continue is "finish a mission," not "do one step."\n- Don\'t call `shadow_ops_synthesize` after completing \u2014 it\'s automatic on `status: "completed"`.\n- Don\'t long status reports. Don\'t ask "what should I work on?" unless a real tie. Don\'t auto-commit.\n\n---\n\n**Tools:** `shadow_ops_context` (optional start), `shadow_ops_briefing`, `shadow_ops_track`, `shadow_ops_log`, `shadow_ops_crystallize`, `shadow_ops_crystallize_theme`, `shadow_ops_handoff`, `shadow_ops_handoff_read`, `shadow_sync_trace`. For discovery: `shadow_search_*`, `shadow_recon_*`, `shadow_analyze_*` (including `shadow_analyze_mesh`, `shadow_analyze_type_graph`, `shadow_analyze_explain_diff`).\n',shadow_crystallize:`---
|
|
1153
1093
|
name: crystallize
|
|
1154
1094
|
description: Compress a mission's intent logs into a dense crystal summary for token-efficient briefings. Use when a mission has accumulated many raw logs, when briefings are too verbose, or when the user asks about log compression, crystallization, or context reduction.
|
|
1155
1095
|
---
|
|
@@ -1190,7 +1130,7 @@ Compress raw intent logs into a single crystal summary node. The crystal replace
|
|
|
1190
1130
|
- Crystallization is **idempotent**: if no new raw logs exist, it reports \`already_crystallized\`.
|
|
1191
1131
|
- New logs added after crystallization remain as raw until the next crystallize call.
|
|
1192
1132
|
- Raw logs are **not deleted** \u2014 they're marked as absorbed. \`ground\` altitude still shows them.
|
|
1193
|
-
`,
|
|
1133
|
+
`,shadow_mission:`---
|
|
1194
1134
|
name: mission
|
|
1195
1135
|
description: Define the objective, strategy, and success criteria for a new development mission. Use when planning strategic initiatives, creating missions, setting up development goals, or when the user asks about mission planning, strategic alignment, or outcome contracts.
|
|
1196
1136
|
---
|
|
@@ -1215,14 +1155,17 @@ Define the objective, strategy, and success criteria for a new mission. This wor
|
|
|
1215
1155
|
|
|
1216
1156
|
## Precise Tooling
|
|
1217
1157
|
|
|
1218
|
-
| Setup Action | Precise Tool Call | Usage
|
|
1219
|
-
| :-------------------- | :----------------------------------------- |
|
|
1220
|
-
| **Session Start** | \`shadow_ops_context\` | **START HERE** \u2014 hologram + chronicle + briefing in one call
|
|
1221
|
-
| **Establish Plan** | \`shadow_ops_plan\` | Create the mission and strategy.
|
|
1222
|
-
| **Architectural Map** | \`shadow_recon_topography\` | Contextualize the target layers (if context wasn't enough).
|
|
1223
|
-
| **Detailed Briefing** | \`shadow_ops_briefing\` (altitude: "ground") | Full analytics, collisions, working sets.
|
|
1224
|
-
| **Lean Briefing** | \`shadow_ops_briefing\` (altitude: "orbit") | Counts + candidates only (~200 tokens).
|
|
1225
|
-
| **Graph View** | \`shadow_ops_graph\` | Visualize the initiative's hierarchy.
|
|
1158
|
+
| Setup Action | Precise Tool Call | Usage |
|
|
1159
|
+
| :-------------------- | :----------------------------------------- | :-------------------------------------------------------------------------------------------------- |
|
|
1160
|
+
| **Session Start** | \`shadow_ops_context\` | **START HERE** \u2014 hologram + chronicle + briefing in one call |
|
|
1161
|
+
| **Establish Plan** | \`shadow_ops_plan\` | Create the mission and strategy. |
|
|
1162
|
+
| **Architectural Map** | \`shadow_recon_topography\` | Contextualize the target layers (if context wasn't enough). |
|
|
1163
|
+
| **Detailed Briefing** | \`shadow_ops_briefing\` (altitude: "ground") | Full analytics, collisions, working sets. |
|
|
1164
|
+
| **Lean Briefing** | \`shadow_ops_briefing\` (altitude: "orbit") | Counts + candidates only (~200 tokens). |
|
|
1165
|
+
| **Graph View** | \`shadow_ops_graph\` | Visualize the initiative's hierarchy. |
|
|
1166
|
+
| **Theme Patterns** | \`shadow_ops_crystallize_theme\` | Before planning: surface recurring themes across past missions to avoid repeating solved problems. |
|
|
1167
|
+
| **Prior Handoffs** | \`shadow_ops_handoff_read\` | In multi-agent contexts: retrieve typed findings from a prior RECON agent before defining strategy. |
|
|
1168
|
+
| **Event Mesh** | \`shadow_analyze_mesh\` | When planning event-driven or API work: map all HTTP routes, socket events, pubsub topics. |
|
|
1226
1169
|
|
|
1227
1170
|
_Note: **Always start with \`shadow_ops_context\`** for instant mission landscape + architectural context. Ensure the \`outcomeContract\` is binary and verifiable. Parent initiatives auto-cascade on child completion \u2014 no manual closing needed._
|
|
1228
1171
|
|
|
@@ -1240,7 +1183,7 @@ Capture the "Why" and "How" during the planning phase to ensure the final ADR ha
|
|
|
1240
1183
|
- **Discovery Logs**: Record insights found during initial reconnaissance.
|
|
1241
1184
|
|
|
1242
1185
|
**Hand-off**: Once the mission is planned and logged, the setup phase is over. Execute via \`/continue\`.
|
|
1243
|
-
`,
|
|
1186
|
+
`,shadow_onboard:'---\nname: onboard\ndescription: Initialize and analyze a new repository for deep intelligence by building semantic index, syncing state, activating git hooks, and establishing missions. Use when onboarding to a new repository, initializing Shadow Engine, setting up git hooks, or when the user asks about repository setup, initialization, or first-time configuration.\n---\n\n# Repository Onboarding\n\nInitialize and analyze a new repository for deep intelligence.\n\n## Workflow\n\n1. **Semantic Init**: `shadow_recon_onboard` (repoPath) \u2014 **Only run once** per repo to build the baseline. Auto-populates the hologram.\n2. **Read Hologram**: `shadow_recon_hologram` (repoPath) \u2014 Get instant architectural context (~1300 tokens: topography + gravity zones).\n3. **Unified Sync**: `shadow_sync_trace` (repoPath) \u2014 **The One-Stop Shop**. Performs indexing + ghost analysis + mission re-hydration.\n4. **Active Briefing**: `shadow_ops_briefing` (scope: "project", altitude: "atmosphere", repoPath) \u2014 Resumes the shared backlog with relevance-ranked candidates.\n - Use `altitude: "orbit"` for a lean overview (~200 tokens), or `altitude: "ground"` for full detail.\n5. **Architectural Deep Dive** (optional):\n - `shadow_recon_topography` (repoPath) \u2014 View layers (Entry/Logic/Data/Utility/Test).\n - `shadow_ops_chronicle` (limit: 5, repoPath) \u2014 Narrative feed.\n - `shadow_analyze_mesh` (repoPath) \u2014 If repo is event-driven: map HTTP routes, socket events, pubsub topics immediately.\n - `shadow_env_diagnose` (repoPath) \u2014 Verify environment health: hooks installed, index state, ember daemon status.\n6. **Hooks Activation**: `shadow_env_hooks` (action: "install", repoPath) \u2014 installs post-commit and **post-checkout** hooks. Post-checkout fires incremental reindex in background on every branch switch.\n7. **Establish Mission**: `shadow_ops_plan` (name, goal, repoPath).\n\n## Precise Tooling\n\n| Action | Atomic Tool |\n| :---------------- | :----------------------------------------------------------------------------------- |\n| **Index** | `shadow_recon_onboard` |\n| **Hologram** | `shadow_recon_hologram` (repoPath) |\n| **Layers** | `shadow_recon_topography` |\n| **History** | `shadow_ops_chronicle` (limit: 10) |\n| **Resume (lean)** | `shadow_ops_briefing` (scope: "project", altitude: "orbit") |\n| **Resume (full)** | `shadow_ops_briefing` (scope: "project", altitude: "atmosphere") |\n| **Hooks** | `shadow_env_hooks` (action: "install") |\n| **Env Health** | `shadow_env_diagnose` (repoPath) \u2014 hooks status, index state, ember warming progress |\n| **Event Mesh** | `shadow_analyze_mesh` (repoPath) \u2014 event-driven repos: routes + topics surface |\n\n_Note: Always use absolute paths for `repoPath`. Call `shadow_recon_hologram` immediately after init for instant architectural context. `shadow_env_hooks` now installs both post-commit and post-checkout hooks \u2014 branch switches will auto-reindex in background via Ember daemon._\n',shadow_research:`---
|
|
1244
1187
|
name: research
|
|
1245
1188
|
description: Conduct high-signal research for external dependencies by combining local context, web search, and Context7 documentation. Use when researching libraries, checking integration examples, verifying versions, or when the user asks about external dependencies, library documentation, or integration patterns.
|
|
1246
1189
|
---
|
|
@@ -1274,9 +1217,9 @@ High-signal research for external dependencies.
|
|
|
1274
1217
|
- **\`shadow_search_config\` with \`showUsage: true\`**: Shows usage counts per config var and identifies orphaned vars (defined but never used in code).
|
|
1275
1218
|
|
|
1276
1219
|
_Note: Always check \`package.json\` for the exact version before querying Context7 to ensure documentation alignment._
|
|
1277
|
-
`,
|
|
1220
|
+
`,shadow_sync:`---
|
|
1278
1221
|
name: sync
|
|
1279
|
-
description: Sync index and mission state after external changes. Day-to-day: index + NanoRepair run automatically when MCP tools (search, inspect, etc.) trigger reindex. Use trace after git pull/checkout/merge (or rely on hooks); use index deep:true for full rebuild.
|
|
1222
|
+
description: 'Sync index and mission state after external changes. Day-to-day: index + NanoRepair run automatically when MCP tools (search, inspect, etc.) trigger reindex. Use trace after git pull/checkout/merge (or rely on hooks); use index deep:true for full rebuild.'
|
|
1280
1223
|
---
|
|
1281
1224
|
|
|
1282
1225
|
# Repository Synchronization
|
|
@@ -1292,7 +1235,7 @@ description: Sync index and mission state after external changes. Day-to-day: in
|
|
|
1292
1235
|
| **Repair only (rare)** | \`shadow_sync_repair\` (repoPath) |
|
|
1293
1236
|
|
|
1294
1237
|
**Note:** \`trace\` does index + ghost analysis + NanoRepair + lifecycle + mission re-hydration. Hooks run it on commit/checkout/merge.
|
|
1295
|
-
`,
|
|
1238
|
+
`,shadow_synthesize:`---
|
|
1296
1239
|
name: synthesize
|
|
1297
1240
|
description: Distill mission logs into Architectural Decision Records (ADRs) and persist them to the Shadow Engine and Git Notes. Use when completing missions, creating ADRs, synthesizing architectural decisions, or when the user asks about decision records, mission completion, or architectural documentation.
|
|
1298
1241
|
---
|
|
@@ -1317,12 +1260,13 @@ Distill mission logs into an Architectural Decision Record (ADR) and persist it
|
|
|
1317
1260
|
|
|
1318
1261
|
## Precise Tooling
|
|
1319
1262
|
|
|
1320
|
-
| Action | Atomic Tool | Usage
|
|
1321
|
-
| :-------------------- | :--------------------------------------- |
|
|
1322
|
-
| **Complete & Seal** | \`shadow_ops_track\` (status: "completed") | **Primary**. Triggers auto-synthesis + cascade.
|
|
1323
|
-
| **Manual Distill** | \`shadow_ops_synthesize\` | Re-run synthesis manually (re-gen only).
|
|
1324
|
-
| **Crystallize First** | \`shadow_ops_crystallize\` | Compress raw logs before synthesis.
|
|
1325
|
-
| **
|
|
1263
|
+
| Action | Atomic Tool | Usage |
|
|
1264
|
+
| :-------------------- | :--------------------------------------- | :---------------------------------------------------------------- |
|
|
1265
|
+
| **Complete & Seal** | \`shadow_ops_track\` (status: "completed") | **Primary**. Triggers auto-synthesis + cascade. |
|
|
1266
|
+
| **Manual Distill** | \`shadow_ops_synthesize\` | Re-run synthesis manually (re-gen only). |
|
|
1267
|
+
| **Crystallize First** | \`shadow_ops_crystallize\` | Compress raw logs before synthesis. |
|
|
1268
|
+
| **Theme Crystallize** | \`shadow_ops_crystallize_theme\` | Cross-mission: cluster semantic themes across ALL missions' logs. |
|
|
1269
|
+
| **View Chronicle** | \`shadow_ops_chronicle\` | View the combined narrative feed. |
|
|
1326
1270
|
|
|
1327
1271
|
_Note: Synthesis consolidation includes all child missions recursively. Cascade parent completion propagates upward through the entire hierarchy._
|
|
1328
1272
|
|
|
@@ -1339,7 +1283,7 @@ When the last child mission under a parent is completed:
|
|
|
1339
1283
|
## Tooling Strategy
|
|
1340
1284
|
|
|
1341
1285
|
Synthesis is the final commit of the mission's logic into the repository's permanent history. Avoid manual markdown files for ADRs; trust the **Git Notes** architecture to preserve the "Story of the Code."
|
|
1342
|
-
`,
|
|
1286
|
+
`,shadow_trace_impact:`---
|
|
1343
1287
|
name: trace-impact
|
|
1344
1288
|
description: Map the blast radius of a change by analyzing impact, flow traces, cross-repo dependencies, and boundary maps. Use when analyzing change impact, assessing risk, tracing dependencies, or when the user asks about change impact, blast radius, or dependency analysis.
|
|
1345
1289
|
---
|
|
@@ -1394,7 +1338,7 @@ _Note: **Start with \`shadow_ops_context\`** for instant gravity zones + archite
|
|
|
1394
1338
|
- **High Risk**: >10 dependents OR crosses layers (e.g., Test -> Logic)
|
|
1395
1339
|
- **Medium Risk**: 5-10 dependents within same layer
|
|
1396
1340
|
- **Low Risk**: <5 dependents, same layer, no circular deps
|
|
1397
|
-
`,
|
|
1341
|
+
`,shadow_understand:'---\nname: understand\ndescription: Find the high-signal path to understanding complex logic through intent retrieval, topological placement, relational analysis, and mechanics inspection. Use when understanding architecture, analyzing complex code, tracing logic flow, or when the user asks about how something works, architectural patterns, or code comprehension.\n---\n\n# Architectural Understanding\n\nFind the high-signal path to understanding complex logic.\n\n## Workflow\n\n1. **Session Context (The Fast Lane)**: `shadow_ops_context` (repoPath) \u2014 **ONE CALL** returns hologram + chronicle(5) + briefing (relevance-ranked candidates).\n - Skip to step 3 if you have what you need from context alone.\n2. **Optional Expanded Context** (only if shadow_ops_context wasn\'t enough):\n - `shadow_recon_topography` (repoPath) \u2014 Detailed layer breakdown beyond hologram summary.\n - `shadow_recon_tree` (subPath: "src/services", maxDepth: 2, repoPath) \u2014 Visual file hierarchy.\n - `shadow_ops_briefing` (scope: "mission", missionId, altitude: "ground") \u2014 Full mission detail with raw logs, working set, collisions.\n3. **Relational Analysis (The Who)**:\n - `shadow_analyze_impact` (symbolName, filePath, depth: 3, repoPath) \u2014 Blast radius.\n - `shadow_analyze_deps` (filePath, direction: "imported_by", repoPath) \u2014 Who depends on this?\n - `shadow_search_concept` (query, repoPath) \u2014 Semantic search.\n - `shadow_analyze_mesh` (repoPath) \u2014 When the system is event-driven: map all HTTP routes, socket events, pubsub topics and their producers/consumers.\n - `shadow_analyze_type_graph` (filePath, repoPath) \u2014 When understanding a type system: interface/class inheritance chains.\n4. **Mechanics (The How)**:\n - **For Logic**: `shadow_analyze_flow` (symbolName, filePath, repoPath) \u2014 Trace execution.\n - **For Objects**: `shadow_inspect_file` (filePath, detailLevel: "signatures", repoPath) \u2014 All exports.\n - **For Symbol Deep Dive**: `shadow_inspect_symbol` (symbolName, filePath, context: "full", repoPath) \u2014 With deps.\n - **For Change History**: `shadow_analyze_explain_diff` (fromCommit, toCommit, repoPath) \u2014 Semantic narrative of what changed and why between commits.\n5. **Synthesis**: `shadow_ops_log` (missionId, type: "discovery", content, symbolName, repoPath).\n\n## Precise Tooling\n\n| Discovery Layer | Atomic Tool |\n| :----------------- | :--------------------------------------------------------------------------------------------------- |\n| **Session Start** | `shadow_ops_context` (repoPath) \u2014 **START HERE** |\n| **Hologram** | `shadow_recon_hologram` (repoPath) \u2014 if you need standalone hologram |\n| **History** | `shadow_ops_chronicle` (limit: 5) \u2014 if you need more than 5 from context |\n| **Layers** | `shadow_recon_topography` \u2014 detailed breakdown |\n| **Mission Detail** | `shadow_ops_briefing` (altitude: "ground") \u2014 full logs + working set |\n| **Blast Radius** | `shadow_analyze_impact` (symbolName, depth: 3) |\n| **Dependents** | `shadow_analyze_deps` (filePath, direction: "imported_by") |\n| **Flow Trace** | `shadow_analyze_flow` (symbolName, filePath) |\n| **Structure** | `shadow_inspect_file` (detailLevel: "signatures") |\n| **Deep Dive** | `shadow_inspect_symbol` (context: "full") |\n| **File Discovery** | `shadow_search_path` (query, **ranked: true**) \u2014 gravity-sorted results with layer classification |\n| **Event Mesh** | `shadow_analyze_mesh` (repoPath) \u2014 HTTP routes, socket events, pubsub topics + producers/consumers |\n| **Type Graph** | `shadow_analyze_type_graph` (filePath) \u2014 interface/class inheritance chains |\n| **Explain Diff** | `shadow_analyze_explain_diff` (fromCommit, toCommit) \u2014 semantic narrative of changes between commits |\n\n_Note: **ALWAYS start with `shadow_ops_context`** for instant architectural context + history + mission state in ONE call. Use `context: "definition"` for token-efficient single symbol inspection._\n\n## Intelligence Options\n\n- **`shadow_search_path` with `ranked: true`**: Results sorted by gravity (high-import files first) with layer classification (Entry/Logic/Data). Use when you need to find the most architecturally important files matching a pattern.\n- **`shadow_search_concept` with `compact: true`**: Omits code snippets for ~60% token savings. Use for broad exploration before deep dives.\n- **Briefing altitude levels**: Use `orbit` for quick status, `atmosphere` for strategy + crystals, `ground` for raw logs + collisions.\n- **`shadow_ops_crystallize`**: If a mission has excessive raw logs, crystallize them first for leaner briefings.\n',shadow_workspace:`---
|
|
1398
1342
|
name: workspace
|
|
1399
1343
|
description: Manage multi-repository workspaces and cross-repo mission links using the Shadow Engine. Use when working with multiple repositories, federated search across repos, linking missions across repos, or when the user asks about workspace management, multi-repo workflows, or cross-repository dependencies.
|
|
1400
1344
|
---
|
|
@@ -1424,7 +1368,15 @@ _Note: Use fused search after \`shadow_workspace_fuse\` to look up concepts acro
|
|
|
1424
1368
|
## \u{1F6E0} Tooling Strategy
|
|
1425
1369
|
|
|
1426
1370
|
Use **\`shadow_workspace_fuse\`** early in multi-repo sessions to unlock "X-Ray" vision across boundaries.
|
|
1427
|
-
`};import*as
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1371
|
+
`};import*as nt from"@clack/prompts";function Wd(s){return[{name:"Claude Code",dir:Je.join(s,".claude","skills"),folderBased:!0,createIfMissing:!1},{name:"Cursor",dir:Je.join(s,".cursor","skills"),folderBased:!0,createIfMissing:!1},{name:"Gemini CLI",dir:Je.join(s,".gemini","skills"),folderBased:!0,createIfMissing:!0},{name:"Codex",dir:Je.join(s,".codex","skills"),folderBased:!0,createIfMissing:!1},{name:"Antigravity",dir:Je.join(s,".gemini","antigravity","global_workflows"),folderBased:!1,createIfMissing:!1}]}function Ys(s=!1){let e=Fd.homedir(),t=Wd(e),n=0;for(let i of t){if(!$e.existsSync(i.dir))if(i.createIfMissing)$e.mkdirSync(i.dir,{recursive:!0});else continue;if(i.folderBased)try{for(let r of $e.readdirSync(i.dir))r.startsWith("shadow_shadow_")&&$e.rmSync(Je.join(i.dir,r),{recursive:!0,force:!0})}catch{}for(let[r,o]of Object.entries(vc))if(i.folderBased){let a=Je.join(i.dir,r);$e.existsSync(a)||$e.mkdirSync(a,{recursive:!0});let c=Je.join(a,"skill.md");$e.existsSync(c)&&$e.unlinkSync(c);let l=Je.join(a,"SKILL.md");(s||!$e.existsSync(l))&&($e.writeFileSync(l,o),n++)}else{let a=Je.join(i.dir,`${r}.md`);(s||!$e.existsSync(a))&&($e.writeFileSync(a,o),n++)}}return n}async function Tc(){nt.intro("\u{1F311} Liquid Shadow: Skills Update");let s=nt.spinner();s.start("Deploying latest skill definitions...");let e=Ys(!0);s.stop("Done."),e>0?nt.note(`Updated ${e} skill files across all detected targets.`,"Manifest"):nt.note("No skill targets found (Claude Code, Cursor, Gemini CLI, Codex, Antigravity).","Manifest"),nt.outro("\u{1F311} Skills are up to date.")}import{pino as zd}from"pino";import*as de from"@clack/prompts";var it=zd({transport:{target:"pino-pretty",options:{colorize:!0}}}),Pt="liquid-shadow",Ks="liquid-shadow-mcp";function Ud(s){let e=(s||Ks).trim();return e.length>0?e:Ks}function jd(s){let e=[],t=/[^\s"']+|"([^"]*)"|'([^']*)'/g,n;for(;(n=t.exec(s))!==null;)e.push(n[1]??n[2]??n[0]??"");return e}function kc(s){if(!s)return[];let e=s.trim();if(!e)return[];if(e.startsWith("[")){let t;try{t=JSON.parse(e)}catch{throw new Error('--mcp-args JSON parsing failed. Use a valid JSON array like ["--flag","value"].')}if(!Array.isArray(t)||t.some(n=>typeof n!="string"))throw new Error("--mcp-args JSON must be an array of strings.");return t}return jd(e)}function Rc(s){return s.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Bd(s,e){let t=`[${e.map(n=>`"${Rc(n)}"`).join(", ")}]`;return`[mcp_servers.${Pt}]
|
|
1372
|
+
command = "${Rc(s)}"
|
|
1373
|
+
args = ${t}`}function Gd(s,e,t){let n=s.split(/\r?\n/),i=n.findIndex(c=>c.trim()===e);if(i===-1)return`${s.length===0||s.endsWith(`
|
|
1374
|
+
`)?s:`${s}
|
|
1375
|
+
`}
|
|
1376
|
+
${t}
|
|
1377
|
+
`;let r=n.length;for(let c=i+1;c<n.length;c++)if(/^\s*\[[^\]]+\]\s*$/.test(n[c]||"")){r=c;break}let o=t.split(`
|
|
1378
|
+
`);return`${[...n.slice(0,i),...o,...n.slice(r)].join(`
|
|
1379
|
+
`).replace(/\n{3,}/g,`
|
|
1380
|
+
|
|
1381
|
+
`).trimEnd()}
|
|
1382
|
+
`}async function Cc(s=!1,e=!1,t=Ks,n=[]){de.intro("\u{1F311} Liquid Shadow: Tactical Onboarding");let i=Hd.homedir(),r=0,o=Ud(t),a=Array.isArray(n)?n:[],c=e||await de.confirm({message:"Deploy Autonomous Reasoning Skills? (Injects /onboard, /understand, etc.)",initialValue:!0});if(de.isCancel(c)){de.outro("Onboarding aborted.");return}let l=e||await de.confirm({message:"Connect to MCP Reasoning Engines? (Claude Code, Claude Desktop, Gemini CLI, Codex)",initialValue:!0});if(de.isCancel(l)){de.outro("Onboarding aborted.");return}if(!c&&!l){de.outro("No actions selected. Operational state unchanged.");return}let p=de.spinner();p.start("Establishing intelligence assets..."),c&&(r=Ys(!0)),l&&(qd(i,o,a,!0),Vd(i,o,a,!0)),p.stop("Intelligence layer established."),r>0?de.note(`Successfully deployed ${r} tactical skills.`,"Manifest"):de.note("No new skills deployed (up to date or scope skipped).","Manifest"),de.outro("\u{1F311} Liquid Shadow is operational.")}function qd(s,e,t,n){let i=[{name:"Claude Code",path:Zt.join(s,".claude.json"),extraFields:{type:"stdio"},createIfMissing:!1},{name:"Claude Desktop",path:Zt.join(s,"Library","Application Support","Claude","claude_desktop_config.json"),createIfMissing:!1},{name:"Gemini CLI",path:Zt.join(s,".gemini","settings.json"),createIfMissing:!0},{name:"Antigravity IDE",path:Zt.join(s,".gemini","antigravity","mcp_config.json"),createIfMissing:!1}];for(let r of i){if(!bt.existsSync(r.path))if(r.createIfMissing)bt.mkdirSync(Zt.dirname(r.path),{recursive:!0}),bt.writeFileSync(r.path,"{}");else{it.debug(`${r.name} config not found at ${r.path}, skipping.`);continue}try{let o=JSON.parse(bt.readFileSync(r.path,"utf8"));if(o.mcpServers||(o.mcpServers={}),o.mcpServers[Pt]){if(!n){it.info(`${r.name}: ${Pt} already configured.`);continue}it.info(`${r.name}: updating existing ${Pt} configuration.`)}o.mcpServers[Pt]={command:e,args:t,env:{},...r.extraFields??{}},bt.writeFileSync(r.path,JSON.stringify(o,null,2)),it.info(`Updated ${r.name} config at ${r.path}`)}catch(o){it.error(`Failed to update ${r.name} config at ${r.path}: ${o}`)}}}function Vd(s,e,t,n){let i=Zt.join(s,".codex","config.toml");if(!bt.existsSync(i)){it.debug(`Codex config not found at ${i}, skipping.`);return}try{let r=bt.readFileSync(i,"utf8"),o=`[mcp_servers.${Pt}]`,a=Bd(e,t);if(r.includes(o)&&!n){it.info(`Codex: ${Pt} already configured.`);return}let c=Gd(r,o,a);bt.writeFileSync(i,c),it.info(`Updated Codex config at ${i}`)}catch(r){it.error(`Failed to update Codex config at ${i}: ${r}`)}}St();import{readFileSync as Jd}from"node:fs";var en={name:"@precisionutilityguild/liquid-shadow",version:"0.0.0",license:"UNLICENSED",description:"Tactical Repository Intelligence Operative - Liquid Shadow Ecosystem"};function Ic(){let s=JSON.parse(Jd(_e("package.json"),"utf8"));return{name:typeof s.name=="string"&&s.name.trim().length>0?s.name:en.name,version:typeof s.version=="string"&&s.version.trim().length>0?s.version:en.version,license:typeof s.license=="string"&&s.license.trim().length>0?s.license:en.license,description:typeof s.description=="string"&&s.description.trim().length>0?s.description:en.description}}function be(s){let e=process.cwd();return Vi(e,s.flags)}process.on("unhandledRejection",s=>{console.error("\x1B[31mUnhandled Rejection:\x1B[0m",s),Q().then(()=>process.exit(1))});process.on("uncaughtException",s=>{console.error("\x1B[31mUncaught Exception:\x1B[0m",s),Q().then(()=>process.exit(1))});var Qs=en;try{Qs=Ic()}catch(s){console.error("Failed to parse package.json, using defaults",s)}var ie=Yd().name("liquid-shadow").version(Qs.version).description(Qs.description).scriptName("liquid-shadow");ie.command("index","Index the repository for AI analysis",{parameters:["[dir]"],flags:{output:{type:String,alias:"o",description:"Export to JSON file instead of indexing"},level:{type:String,alias:"l",description:"Detail level",default:"detailed"},subPath:{type:String,description:"Only process files within this subpath"},force:{type:Boolean,description:"Force re-indexing of all files",default:!1},deep:{type:Boolean,description:"Perform deep semantic indexing (headings + symbol embeddings)",default:!0}}}).on("index",async s=>{let e=be(s),t={...s.flags,dir:s.flags.dir??e.dir,level:s.flags.level??e.level,deep:s.flags.deep??e.deep};t.deep==="false"||t.deep===!1?t.deep=!1:t.deep=!0,await pa(s.parameters.dir||e.dir,t)});ie.command("status","Show current repository intelligence status",{parameters:["[dir]"]}).on("status",async s=>{let e=be(s);await Dr(s.parameters.dir||e.dir)});ie.command("dashboard","Operational intelligence dashboard (TUI)",{parameters:["[dir]"]}).on("dashboard",async s=>{let e=be(s);await cs(s.parameters.dir||e.dir)});ie.command("metrics","Show performance metrics and observability data",{parameters:["[dir]"]}).on("metrics",async s=>{let e=be(s);await Br(s.parameters.dir||e.dir)});ie.command("benchmark","Run performance benchmark on repository indexing",{parameters:["[dir]"]}).on("benchmark",async s=>{let e=be(s);await da(s.parameters.dir||e.dir)});ie.command("tree","Visualize repository structure as a tree",{parameters:["[dir]"],flags:{subPath:{type:String,description:"Subpath to visualize"},depth:{type:String,alias:"d",description:"Max depth",default:"3"}}}).on("tree",async s=>{let e=be(s);await aa(s.parameters.dir||e.dir,{...s.flags,dir:s.flags.dir??e.dir})});ie.command("recon","Repository reconnaissance and architecture analysis",{parameters:["<mode>","[dir]"],flags:{subPath:{type:String,description:"Subpath to focus on"}}}).on("recon",async s=>{let e=be(s);await Ca(s.parameters.mode,s.parameters.dir||e.dir,{...s.flags})});ie.command("trace","Trace execution flow for a given file/symbol",{parameters:["<file>","[symbolName]"],flags:{dir:{type:String,alias:"d",default:"."}}}).on("trace",async s=>{let e=be(s);await Sa(s.parameters.file,{...s.flags,dir:s.flags.dir??e.dir,symbolName:s.parameters.symbolName})});ie.command("sync","Deep synchronize intelligence lifecycle (Trace + Repair + Re-hydrate)",{parameters:["[dir]"],flags:{contextPivot:{type:Boolean,default:!1,description:"Opt in to suspend other-branch missions and resume current-branch missions"},mergeSentinel:{type:Boolean,default:!1,description:"Opt in to auto-complete missions from merged branches"}}}).on("sync",async s=>{let e=be(s);await Ta(s.parameters.dir||e.dir,{contextPivot:!!s.flags.contextPivot,mergeSentinel:!!s.flags.mergeSentinel})});ie.command("search-config","Search for configuration values",{parameters:["[key]"],flags:{dir:{type:String,alias:"d",default:"."},kind:{type:String,description:"Filter by config kind"}}}).on("search-config",async s=>{let e=be(s);await Ha(s.parameters.key,{...s.flags,dir:s.flags.dir??e.dir})});ie.command("search-concept","Search for files by concept/intent (Semantic)",{parameters:["<query>"],flags:{dir:{type:String,alias:"d",default:"."},interactive:{type:Boolean,alias:"i",description:"Interactive TUI: pick a result to inspect",default:!1}}}).on("search-concept",async s=>{let e=be(s);await Oa(s.parameters.query,{...s.flags,dir:s.flags.dir??e.dir})});ie.command("search-symbol","Search for specific code symbols",{parameters:["<query>"],flags:{dir:{type:String,alias:"d",default:"."},interactive:{type:Boolean,alias:"i",description:"Interactive TUI: pick a result to inspect",default:!1}}}).on("search-symbol",async s=>{let e=be(s);await Fa(s.parameters.query,{...s.flags,dir:s.flags.dir??e.dir})});ie.command("search-fuzzy",'Fuzzy search for symbols (e.g., "usc" finds "UserServiceClient")',{parameters:["<query>"],flags:{dir:{type:String,alias:"d",default:"."},interactive:{type:Boolean,alias:"i",description:"Interactive TUI: pick a result to inspect",default:!1}}}).on("search-fuzzy",async s=>{let e=be(s);await Wa(s.parameters.query,{...s.flags,dir:s.flags.dir??e.dir})});ie.command("hooks","Manage git hooks for automatic intelligence updates",{parameters:["<action>","[path]"]}).on("hooks",async s=>{await za([s.parameters.action,s.parameters.path])});ie.command("workspace","Workspace-level mission orchestration",{parameters:["<action>","[args...]"]}).on("workspace",async s=>{await Xa([s.parameters.action,...s.parameters.args])});ie.command("mission","Mission management (start, plan, briefing, distill)",{parameters:["<action>","[args...]"]}).on("mission",async s=>{await bc([s.parameters.action,...s.parameters.args])});ie.command("inspect","Deep inspection of specific files or symbols",{parameters:["<mode>","[args...]"]}).on("inspect",async s=>{await _c([s.parameters.mode,...s.parameters.args])});ie.command("watch","Watch repo and reindex on file changes",{parameters:["[dir]"]}).on("watch",async s=>{let e=be(s);await wc(s.parameters.dir||e.dir)});ie.command("chronicle","Generate a repository-wide narrative feed (ADRs/Epics)",{parameters:["[dir]"],flags:{format:{type:String,alias:"f",description:"Output format (markdown|json)",default:"markdown"},limit:{type:Number,alias:"l",description:"Limit number of entries",default:10},offset:{type:Number,description:"Pagination offset",default:0},since:{type:String,description:"Show entries since date (YYYY-MM-DD)"},until:{type:String,description:"Show entries until date (YYYY-MM-DD)"}}}).on("chronicle",async s=>{let e=be(s);await xc(s.parameters.dir||e.dir,{...s.flags,format:s.flags.format,limit:s.flags.limit?parseInt(String(s.flags.limit),10):void 0,offset:s.flags.offset?parseInt(String(s.flags.offset),10):void 0,since:s.flags.since?Math.floor(new Date(String(s.flags.since)).getTime()/1e3):void 0,until:s.flags.until?Math.floor(new Date(String(s.flags.until)).getTime()/1e3):void 0})});ie.command("init","Initialize Liquid Shadow skills and configuration",{flags:{force:{type:Boolean,alias:"f",description:"Force overwrite existing skills and MCP server entries",default:!1},yes:{type:Boolean,alias:"y",description:"Skip interactive confirmation (unsafe)",default:!1},mcpCommand:{type:String,description:"Override MCP command used in generated client configs",default:"liquid-shadow-mcp"},mcpArgs:{type:String,description:'Optional MCP args (JSON array recommended, e.g. ["--flag","value"] or quoted string)'}}}).on("init",async s=>{let e;try{e=kc(s.flags.mcpArgs)}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`Invalid --mcp-args: ${n}`),process.exit(1);return}await Cc(s.flags.force,s.flags.yes,s.flags.mcpCommand,e)});ie.command("skills","Manage Liquid Shadow reasoning skills",{parameters:["<action>"]}).on("skills",async s=>{let e=s.parameters.action;e==="update"?await Tc():(console.error(`Unknown skills action: ${e}. Available: update`),process.exit(1))});ie.command("completion","Generate shell completion script (bash or zsh)",{parameters:["<shell>"]}).on("completion",async s=>{await Sc(s.parameters.shell||"")});if(process.argv.length<=2){let s=Vi(process.cwd(),{});cs(s.dir)}else ie.parse();
|