prjct-cli 2.23.12 → 2.23.16
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/CHANGELOG.md +23 -1810
- package/README.md +22 -60
- package/dist/bin/prjct-core.mjs +329 -329
- package/dist/daemon/entry.mjs +204 -204
- package/dist/mcp/server.mjs +1 -1
- package/package.json +1 -1
package/dist/mcp/server.mjs
CHANGED
|
@@ -543,7 +543,7 @@ CREATE TABLE velocity_sprints (
|
|
|
543
543
|
AND entity_id = ?
|
|
544
544
|
AND content_hash = ?`,t,e.entityType,e.entityId,e.contentHash),y.run(t,`INSERT INTO sync_pending
|
|
545
545
|
(project_id, entity_type, entity_id, event_type, content_hash, payload, enqueued_at)
|
|
546
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)`,t,e.entityType??null,e.entityId??null,e.eventType??null,e.contentHash??null,n,s),{id:y.get(t,"SELECT last_insert_rowid() AS id")?.id??0,event:e,enqueuedAt:s}}list(t,e){let s=e?"SELECT * FROM sync_pending WHERE project_id = ? ORDER BY id ASC LIMIT ?":"SELECT * FROM sync_pending WHERE project_id = ? ORDER BY id ASC";return(e?y.query(t,s,t,e):y.query(t,s,t)).map(i=>this.rowToEntry(i))}count(t){return y.get(t,"SELECT COUNT(*) AS n FROM sync_pending WHERE project_id = ?",t)?.n??0}clearUpTo(t,e){if(e<=0)return 0;let s=this.count(t);return y.run(t,"DELETE FROM sync_pending WHERE project_id = ? AND id <= ?",t,e),s-this.count(t)}clearAll(t){y.run(t,"DELETE FROM sync_pending WHERE project_id = ?",t)}clearByIds(t,e){if(e.length===0)return;let s=e.map(()=>"?").join(",");y.run(t,`DELETE FROM sync_pending WHERE project_id = ? AND id IN (${s})`,t,...e)}rowToEntry(t){let e;try{e=JSON.parse(t.payload)}catch{e={type:"unknown.corrupt",path:[],data:null,timestamp:t.enqueued_at,projectId:t.project_id}}return{id:t.id,event:e,enqueuedAt:t.enqueued_at}}},et=new Le});var Oe,Bt,Me=k(()=>{"use strict";ot();Pr();C();U();Oe=class{static{c(this,"SyncEventBus")}async publish(t){et.append(t.projectId,t)}async getPending(t){return et.list(t).map(e=>e.event)}async clearPending(t){et.clearAll(t)}async getPendingEntries(t){return et.list(t)}async clearPendingUpTo(t,e){return et.clearUpTo(t,e)}async clearPendingByIds(t,e){et.clearByIds(t,e)}async updateLastSync(t){let e=v.getLastSyncPath(t),s={timestamp:g(),success:!0};await F(e,s)}async getLastSync(t){let e=v.getLastSyncPath(t);return await At(e,null)}},Bt=new Oe});var Fe={};Q(Fe,{default:()=>so});import Zi from"node:crypto";import Rr from"node:fs/promises";import Ar from"node:os";import to from"node:path";function Nr(){return Zi.randomUUID()}var Ir,Cr,je,eo,so,Ue=k(()=>{"use strict";ot();U();Ir="https://api.prjct.app",Cr={apiKey:null,apiUrl:Ir,userId:null,email:null,lastAuth:null};c(Nr,"freshDeviceId");je=class{static{c(this,"AuthConfigManager")}configPath;cachedConfig=null;constructor(){this.configPath=v.getAuthConfigPath()}getConfigPath(){return this.configPath}async read(){if(this.cachedConfig)return this.cachedConfig;let t=await At(this.configPath),e=t??{...Cr},s=!1;if(e.deviceId||(e.deviceId=Nr(),s=!0),e.hostname||(e.hostname=Ar.hostname(),s=!0),this.cachedConfig=e,s&&t)try{await F(this.configPath,this.cachedConfig),await Rr.chmod(this.configPath,384)}catch{}return this.cachedConfig}async getDeviceId(){return(await this.read()).deviceId??Nr()}async getHostname(){return(await this.read()).hostname??Ar.hostname()}async write(t){let s={...await this.read(),...t,lastAuth:new Date().toISOString()};await G(to.dirname(this.configPath)),await F(this.configPath,s),await Rr.chmod(this.configPath,384),this.cachedConfig=s}async hasAuth(){let t=await this.read();return t.apiKey!==null&&t.apiKey.length>0}async getApiKey(){return(await this.read()).apiKey}async getApiUrl(){return(await this.read()).apiUrl||Ir}async saveAuth(t,e,s){await this.write({apiKey:t,userId:e,email:s})}async clearAuth(){this.cachedConfig={...Cr},await F(this.configPath,this.cachedConfig)}async getStatus(){let t=await this.read();return{authenticated:t.apiKey!==null,email:t.email,apiKeyPrefix:t.apiKey?`${t.apiKey.substring(0,12)}...`:null,lastAuth:t.lastAuth}}clearCache(){this.cachedConfig=null}},eo=new je,so=eo});var Lr={};Q(Lr,{_resetPublishHelperCache:()=>co,publishCRUD:()=>Dr,publishCRUDSync:()=>q});import ro from"node:crypto";function io(r){let t=r&&typeof r=="object"&&!Array.isArray(r)?JSON.stringify(oo(r)):JSON.stringify(r);return ro.createHash("sha256").update(t).digest("hex")}function oo(r){let t={};for(let e of Object.keys(r).sort())t[e]=r[e];return t}async function ao(){if(Ht)return Ht;try{let{default:r}=await Promise.resolve().then(()=>(Ue(),Fe)),t=r;if(typeof t.getDeviceId=="function"){let e=await t.getDeviceId();return Ht=e,e}return"unknown-device"}catch{return"unknown-device"}}function co(){Ht=null}async function Dr(r){try{let t=await ao(),e=io(r.data),s={type:`${r.entityType}.${no[r.eventType]}`,path:[r.entityType,r.entityId],data:r.data,timestamp:new Date().toISOString(),projectId:r.projectId,entityType:r.entityType,entityId:r.entityId,eventType:r.eventType,contentHash:e,deviceId:t,originDeviceId:r.originDeviceId??t,revisionCount:r.revisionCount??1};await Bt.publish(s)}catch{}}function q(r){Dr(r)}var no,Ht,wt=k(()=>{"use strict";Me();no={upsert:"updated",delete:"deleted"};c(io,"hashPayload");c(oo,"sortKeys");Ht=null;c(ao,"resolveDeviceId");c(co,"_resetPublishHelperCache");c(Dr,"publishCRUD");c(q,"publishCRUDSync")});var bt,$e,ut,qt=k(()=>{"use strict";St();wt();C();j();bt={SHIPPED_RETENTION_DAYS:90,IDEA_DORMANT_DAYS:180,QUEUE_COMPLETED_DAYS:7,PAUSED_TASK_DAYS:30,MEMORY_MAX_ENTRIES:500},$e=class{static{c(this,"ArchiveStorage")}archive(t,e){let s=H(),n=g();return E.run(t,"INSERT INTO archives (id, entity_type, entity_id, entity_data, summary, archived_at, reason) VALUES (?, ?, ?, ?, ?, ?, ?)",s,e.entityType,e.entityId,JSON.stringify(e.entityData),e.summary??null,n,e.reason),q({projectId:t,entityType:"archives",entityId:s,eventType:"upsert",data:{id:s,entity_type:e.entityType,entity_id:e.entityId,summary:e.summary??null,reason:e.reason,archived_at:n}}),s}archiveMany(t,e){if(e.length===0)return 0;let s=g();return E.transaction(t,n=>{let i=n.prepare("INSERT INTO archives (id, entity_type, entity_id, entity_data, summary, archived_at, reason) VALUES (?, ?, ?, ?, ?, ?, ?)");for(let o of e)i.run(H(),o.entityType,o.entityId,JSON.stringify(o.entityData),o.summary??null,s,o.reason)}),e.length}getArchived(t,e,s=50){return e?E.query(t,"SELECT * FROM archives WHERE entity_type = ? ORDER BY archived_at DESC LIMIT ?",e,s):E.query(t,"SELECT * FROM archives ORDER BY archived_at DESC LIMIT ?",s)}getStats(t){let e=E.query(t,"SELECT entity_type, COUNT(*) as count FROM archives GROUP BY entity_type"),s={shipped:0,idea:0,queue_task:0,paused_task:0,memory_entry:0,total:0};for(let n of e){let i=n.entity_type;i in s&&(s[i]=n.count),s.total+=n.count}return s}restore(t,e){let s=E.get(t,"SELECT * FROM archives WHERE id = ?",e);return s?(E.run(t,"DELETE FROM archives WHERE id = ?",e),JSON.parse(s.entity_data)):null}pruneOldArchives(t,e){let s=new Date(Date.now()-e*24*60*60*1e3).toISOString(),n=this.getTotalCount(t);E.run(t,"DELETE FROM archives WHERE archived_at < ?",s);let i=this.getTotalCount(t);return n-i}getTotalCount(t){return E.get(t,"SELECT COUNT(*) as count FROM archives")?.count??0}},ut=new $e});import go from"node:crypto";function fo(r){let[t,e]=r.split(".");return t?{entityType:t.endsWith("s")?t:`${t}s`,eventType:e==="deleted"||e==="archived"||e==="removed"?"delete":"upsert"}:{}}function ho(r){if(!r||typeof r!="object")return;let t=r;for(let e of["taskId","task_id","id","feature_id","featureId","specId","spec_id"]){let s=t[e];if(typeof s=="string"&&s.length>0)return s}}function yo(r){let t=r&&typeof r=="object"&&!Array.isArray(r)?JSON.stringify(To(r)):JSON.stringify(r);return go.createHash("sha256").update(t).digest("hex")}function To(r){let t={};for(let e of Object.keys(r).sort())t[e]=r[e];return t}async function ko(){if(Gt)return Gt;try{let{default:r}=await Promise.resolve().then(()=>(Ue(),Fe)),t=r;return typeof t.getDeviceId=="function"?(Gt=await t.getDeviceId(),Gt):"unknown-device"}catch{return"unknown-device"}}var Gt,lt,Be=k(()=>{"use strict";Me();me();C();j();c(fo,"deriveEntityShape");c(ho,"entityIdOf");c(yo,"hashPayload");c(To,"sortKeys");Gt=null;c(ko,"_resolveDeviceId");lt=class{static{c(this,"StorageManager")}filename;cache;constructor(t,e){this.filename=t,this.cache=new Nt({ttl:5e3,maxSize:50})}getStoreKey(){return this.filename.replace(".json","")}async read(t){if(!(process.env.PRJCT_IN_DAEMON==="1"||process.env.PRJCT_DAEMON==="1")){let s=this.cache.get(t);if(s!==null)return s}try{let s=E.getDoc(t,this.getStoreKey());if(s!==null)return this.cache.set(t,s),s}catch{}return this.getDefault()}async write(t,e){E.setDoc(t,this.getStoreKey(),e),this.cache.set(t,e)}async update(t,e){let s=this.getStoreKey(),n=8;for(let i=1;i<=n;i++){let o=E.getDocWithStamp(t,s),a=o?o.data:this.getDefault(),u=e(a);if(E.casSetDoc(t,s,u,o?.updatedAt??null))return this.cache.set(t,u),u}throw new Error(`StorageManager.update: unresolved write contention after ${n} attempts (key=${s})`)}async publishEvent(t,e,s){let n=fo(e),i={type:e,path:[this.filename.replace(".json","")],data:s,timestamp:g(),projectId:t,entityType:n.entityType,entityId:ho(s),eventType:n.eventType,contentHash:yo(s),deviceId:await ko(),revisionCount:1};await Bt.publish(i)}async publishEntityEvent(t,e,s,n){let i=`${e}.${s}`,o={...n,timestamp:g()};await this.publishEvent(t,i,o)}async exists(t){try{return E.hasDoc(t,this.getStoreKey())}catch{return!1}}clearCache(t){t?this.cache.delete(t):this.cache.clear()}getCacheStats(){return this.cache.stats()}}});var dn,mn,gn,fn,hn=k(()=>{"use strict";dn={frontend:["component","page","view","ui","layout","style","css","scss","sass","hook","context","store","redux","zustand","react","vue","svelte","angular","next","nuxt","app","client"],backend:["api","route","controller","service","middleware","handler","resolver","schema","model","entity","repository","server","socket","graphql","rest","trpc"],database:["migration","seed","schema","model","entity","repository","prisma","drizzle","sequelize","typeorm","mongoose","knex","sql","db"],auth:["auth","login","logout","session","token","jwt","oauth","passport","credential","permission","role","user","account"],testing:["test","spec","e2e","integration","unit","mock","fixture","stub","jest","vitest","cypress","playwright"],config:["config","env","setting","constant","option","tsconfig","eslint","prettier","vite","webpack","rollup"],infra:["docker","compose","kubernetes","k8s","ci","cd","github","gitlab","jenkins","terraform","ansible","deploy"],util:["util","helper","lib","common","shared","core","base","abstract"]},mn=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".py",".go",".rs",".java",".kt",".swift",".rb",".php",".c",".cpp",".h",".hpp",".cs",".vue",".svelte"]),gn=new Set(["node_modules",".git","dist","build",".next",".nuxt",".output","coverage",".cache","__pycache__",".pytest_cache","vendor","target",".turbo",".vercel"]),fn=new Set(["a","an","the","and","or","but","is","are","was","were","be","been","being","have","has","had","do","does","did","will","would","could","should","may","might","must","shall","can","need","to","of","in","for","on","with","at","by","from","as","into","through","during","before","after","above","below","between","under","again","further","then","once","here","there","when","where","why","how","all","each","few","more","most","other","some","such","no","nor","not","only","own","same","so","than","too","very","just","add","create","make","implement","fix","update","change","modify","remove","delete","new"])});import Eo from"node:fs/promises";import Yt from"node:path";async function Jt(r,t,e={}){let s=Date.now(),n=e.maxFiles??30,i=e.minScore??.1,o=e.includeTests??!1,a=So(r),u=await wo(t),p=await bo(t),m=[];for(let f of u){if(!o&&vo(f))continue;let T=_o(f,a,p,e.historicalBoosts);T.score>=i&&m.push(T)}m.sort((f,T)=>T.score-f.score);let d=m.slice(0,n);return{files:d,metrics:{filesScanned:u.length,filesReturned:d.length,scanDuration:Date.now()-s}}}function So(r){return r.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).filter(e=>!fn.has(e)&&e.length>2)}async function wo(r){let t=[];async function e(s,n=""){try{let i=await Eo.readdir(s,{withFileTypes:!0});for(let o of i){let a=Yt.join(s,o.name),u=Yt.join(n,o.name);if(o.isDirectory()){if(gn.has(o.name)||o.name.startsWith("."))continue;await e(a,u)}else if(o.isFile()){let p=Yt.extname(o.name).toLowerCase();mn.has(p)&&t.push(u)}}}catch(i){L(i)}}return c(e,"walk"),await e(r),t}async function bo(r){let t=new Map;try{let{stdout:e}=await _(`git log -30 --pretty=format:"%H %ct" --name-only | awk '
|
|
546
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)`,t,e.entityType??null,e.entityId??null,e.eventType??null,e.contentHash??null,n,s),{id:y.get(t,"SELECT last_insert_rowid() AS id")?.id??0,event:e,enqueuedAt:s}}list(t,e){let s=e?"SELECT * FROM sync_pending WHERE project_id = ? ORDER BY id ASC LIMIT ?":"SELECT * FROM sync_pending WHERE project_id = ? ORDER BY id ASC";return(e?y.query(t,s,t,e):y.query(t,s,t)).map(i=>this.rowToEntry(i))}count(t){return y.get(t,"SELECT COUNT(*) AS n FROM sync_pending WHERE project_id = ?",t)?.n??0}clearUpTo(t,e){if(e<=0)return 0;let s=this.count(t);return y.run(t,"DELETE FROM sync_pending WHERE project_id = ? AND id <= ?",t,e),s-this.count(t)}clearAll(t){y.run(t,"DELETE FROM sync_pending WHERE project_id = ?",t)}clearByIds(t,e){if(e.length===0)return;let s=e.map(()=>"?").join(",");y.run(t,`DELETE FROM sync_pending WHERE project_id = ? AND id IN (${s})`,t,...e)}rowToEntry(t){let e;try{e=JSON.parse(t.payload)}catch{e={type:"unknown.corrupt",path:[],data:null,timestamp:t.enqueued_at,projectId:t.project_id}}return{id:t.id,event:e,enqueuedAt:t.enqueued_at}}},et=new Le});var Oe,Bt,Me=k(()=>{"use strict";ot();Pr();C();U();Oe=class{static{c(this,"SyncEventBus")}async publish(t){et.append(t.projectId,t)}async getPending(t){return et.list(t).map(e=>e.event)}async clearPending(t){et.clearAll(t)}async getPendingEntries(t){return et.list(t)}async clearPendingUpTo(t,e){return et.clearUpTo(t,e)}async clearPendingByIds(t,e){et.clearByIds(t,e)}async updateLastSync(t){let e=v.getLastSyncPath(t),s={timestamp:g(),success:!0};await F(e,s)}async getLastSync(t){let e=v.getLastSyncPath(t);return await At(e,null)}},Bt=new Oe});var Fe={};Q(Fe,{default:()=>so});import Zi from"node:crypto";import Rr from"node:fs/promises";import Ar from"node:os";import to from"node:path";function Nr(){return Zi.randomUUID()}var Ir,Cr,je,eo,so,Ue=k(()=>{"use strict";ot();U();Ir="https://api.prjct.app",Cr={apiKey:null,apiUrl:Ir,userId:null,email:null,lastAuth:null};c(Nr,"freshDeviceId");je=class{static{c(this,"AuthConfigManager")}configPath;cachedConfig=null;constructor(){this.configPath=v.getAuthConfigPath()}getConfigPath(){return this.configPath}async read(){if(this.cachedConfig)return this.cachedConfig;let t=await At(this.configPath),e=t??{...Cr},s=!1;if(e.deviceId||(e.deviceId=Nr(),s=!0),e.hostname||(e.hostname=Ar.hostname(),s=!0),this.cachedConfig=e,s&&t)try{await F(this.configPath,this.cachedConfig),await Rr.chmod(this.configPath,384)}catch{}return this.cachedConfig}async getDeviceId(){return(await this.read()).deviceId??Nr()}async getHostname(){return(await this.read()).hostname??Ar.hostname()}async write(t){let s={...await this.read(),...t,lastAuth:new Date().toISOString()};await G(to.dirname(this.configPath)),await F(this.configPath,s),await Rr.chmod(this.configPath,384),this.cachedConfig=s}async hasAuth(){let t=await this.read();return t.apiKey!==null&&t.apiKey.length>0}async getApiKey(){return(await this.read()).apiKey}async getApiUrl(){return(await this.read()).apiUrl||Ir}async saveAuth(t,e,s){await this.write({apiKey:t,userId:e,email:s})}async clearAuth(){this.cachedConfig={...Cr},await F(this.configPath,this.cachedConfig)}async getStatus(){let t=await this.read();return{authenticated:t.apiKey!==null,email:t.email,apiKeyPrefix:t.apiKey?`${t.apiKey.substring(0,12)}...`:null,lastAuth:t.lastAuth}}clearCache(){this.cachedConfig=null}},eo=new je,so=eo});var Lr={};Q(Lr,{_resetPublishHelperCache:()=>co,publishCRUD:()=>Dr,publishCRUDSync:()=>q});import ro from"node:crypto";function io(r){let t=r&&typeof r=="object"&&!Array.isArray(r)?JSON.stringify(oo(r)):JSON.stringify(r);return ro.createHash("sha256").update(t).digest("hex")}function oo(r){let t={};for(let e of Object.keys(r).sort())t[e]=r[e];return t}async function ao(){if(Ht)return Ht;try{let{default:r}=await Promise.resolve().then(()=>(Ue(),Fe)),t=r;if(typeof t.getDeviceId=="function"){let e=await t.getDeviceId();return Ht=e,e}return"unknown-device"}catch{return"unknown-device"}}function co(){Ht=null}async function Dr(r){try{let t=await ao(),e=io(r.data),s={type:`${r.entityType}.${no[r.eventType]}`,path:[r.entityType,r.entityId],data:r.data,timestamp:new Date().toISOString(),projectId:r.projectId,entityType:r.entityType,entityId:r.entityId,eventType:r.eventType,contentHash:e,deviceId:t,originDeviceId:r.originDeviceId??t,revisionCount:r.revisionCount??1};await Bt.publish(s)}catch{}}function q(r){Dr(r)}var no,Ht,wt=k(()=>{"use strict";Me();no={upsert:"updated",delete:"deleted"};c(io,"hashPayload");c(oo,"sortKeys");Ht=null;c(ao,"resolveDeviceId");c(co,"_resetPublishHelperCache");c(Dr,"publishCRUD");c(q,"publishCRUDSync")});var bt,$e,ut,qt=k(()=>{"use strict";St();wt();C();j();bt={SHIPPED_RETENTION_DAYS:90,IDEA_DORMANT_DAYS:180,QUEUE_COMPLETED_DAYS:7,PAUSED_TASK_DAYS:30,MEMORY_MAX_ENTRIES:500},$e=class{static{c(this,"ArchiveStorage")}archive(t,e){let s=H(),n=g();return E.run(t,"INSERT INTO archives (id, entity_type, entity_id, entity_data, summary, archived_at, reason) VALUES (?, ?, ?, ?, ?, ?, ?)",s,e.entityType,e.entityId,JSON.stringify(e.entityData),e.summary??null,n,e.reason),q({projectId:t,entityType:"archives",entityId:s,eventType:"upsert",data:{id:s,entity_type:e.entityType,entity_id:e.entityId,summary:e.summary??null,reason:e.reason,archived_at:n}}),s}archiveMany(t,e){if(e.length===0)return 0;let s=g();return E.transaction(t,n=>{let i=n.prepare("INSERT INTO archives (id, entity_type, entity_id, entity_data, summary, archived_at, reason) VALUES (?, ?, ?, ?, ?, ?, ?)");for(let o of e)i.run(H(),o.entityType,o.entityId,JSON.stringify(o.entityData),o.summary??null,s,o.reason)}),e.length}getArchived(t,e,s=50){return e?E.query(t,"SELECT * FROM archives WHERE entity_type = ? ORDER BY archived_at DESC LIMIT ?",e,s):E.query(t,"SELECT * FROM archives ORDER BY archived_at DESC LIMIT ?",s)}getStats(t){let e=E.query(t,"SELECT entity_type, COUNT(*) as count FROM archives GROUP BY entity_type"),s={shipped:0,idea:0,queue_task:0,paused_task:0,memory_entry:0,total:0};for(let n of e){let i=n.entity_type;i in s&&(s[i]=n.count),s.total+=n.count}return s}restore(t,e){let s=E.get(t,"SELECT * FROM archives WHERE id = ?",e);return s?(E.run(t,"DELETE FROM archives WHERE id = ?",e),JSON.parse(s.entity_data)):null}pruneOldArchives(t,e){let s=new Date(Date.now()-e*24*60*60*1e3).toISOString(),n=this.getTotalCount(t);E.run(t,"DELETE FROM archives WHERE archived_at < ?",s);let i=this.getTotalCount(t);return n-i}getTotalCount(t){return E.get(t,"SELECT COUNT(*) as count FROM archives")?.count??0}},ut=new $e});import go from"node:crypto";function fo(r){let[t,e]=r.split(".");return t?{entityType:t.endsWith("s")?t:`${t}s`,eventType:e==="deleted"||e==="archived"||e==="removed"?"delete":"upsert"}:{}}function ho(r){if(!r||typeof r!="object")return;let t=r;for(let e of["taskId","task_id","id","feature_id","featureId","specId","spec_id"]){let s=t[e];if(typeof s=="string"&&s.length>0)return s}}function yo(r){let t=r&&typeof r=="object"&&!Array.isArray(r)?JSON.stringify(To(r)):JSON.stringify(r);return go.createHash("sha256").update(t).digest("hex")}function To(r){let t={};for(let e of Object.keys(r).sort())t[e]=r[e];return t}async function ko(){if(Gt)return Gt;try{let{default:r}=await Promise.resolve().then(()=>(Ue(),Fe)),t=r;return typeof t.getDeviceId=="function"?(Gt=await t.getDeviceId(),Gt):"unknown-device"}catch{return"unknown-device"}}var Gt,lt,Be=k(()=>{"use strict";Me();me();C();j();c(fo,"deriveEntityShape");c(ho,"entityIdOf");c(yo,"hashPayload");c(To,"sortKeys");Gt=null;c(ko,"_resolveDeviceId");lt=class{static{c(this,"StorageManager")}filename;cache;constructor(t,e){this.filename=t,this.cache=new Nt({ttl:5e3,maxSize:50})}getStoreKey(){return this.filename.replace(".json","")}async read(t){if(!(process.env.PRJCT_IN_DAEMON==="1")){let s=this.cache.get(t);if(s!==null)return s}try{let s=E.getDoc(t,this.getStoreKey());if(s!==null)return this.cache.set(t,s),s}catch{}return this.getDefault()}async write(t,e){E.setDoc(t,this.getStoreKey(),e),this.cache.set(t,e)}async update(t,e){let s=this.getStoreKey(),n=8;for(let i=1;i<=n;i++){let o=E.getDocWithStamp(t,s),a=o?o.data:this.getDefault(),u=e(a);if(E.casSetDoc(t,s,u,o?.updatedAt??null))return this.cache.set(t,u),u}throw new Error(`StorageManager.update: unresolved write contention after ${n} attempts (key=${s})`)}async publishEvent(t,e,s){let n=fo(e),i={type:e,path:[this.filename.replace(".json","")],data:s,timestamp:g(),projectId:t,entityType:n.entityType,entityId:ho(s),eventType:n.eventType,contentHash:yo(s),deviceId:await ko(),revisionCount:1};await Bt.publish(i)}async publishEntityEvent(t,e,s,n){let i=`${e}.${s}`,o={...n,timestamp:g()};await this.publishEvent(t,i,o)}async exists(t){try{return E.hasDoc(t,this.getStoreKey())}catch{return!1}}clearCache(t){t?this.cache.delete(t):this.cache.clear()}getCacheStats(){return this.cache.stats()}}});var dn,mn,gn,fn,hn=k(()=>{"use strict";dn={frontend:["component","page","view","ui","layout","style","css","scss","sass","hook","context","store","redux","zustand","react","vue","svelte","angular","next","nuxt","app","client"],backend:["api","route","controller","service","middleware","handler","resolver","schema","model","entity","repository","server","socket","graphql","rest","trpc"],database:["migration","seed","schema","model","entity","repository","prisma","drizzle","sequelize","typeorm","mongoose","knex","sql","db"],auth:["auth","login","logout","session","token","jwt","oauth","passport","credential","permission","role","user","account"],testing:["test","spec","e2e","integration","unit","mock","fixture","stub","jest","vitest","cypress","playwright"],config:["config","env","setting","constant","option","tsconfig","eslint","prettier","vite","webpack","rollup"],infra:["docker","compose","kubernetes","k8s","ci","cd","github","gitlab","jenkins","terraform","ansible","deploy"],util:["util","helper","lib","common","shared","core","base","abstract"]},mn=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".py",".go",".rs",".java",".kt",".swift",".rb",".php",".c",".cpp",".h",".hpp",".cs",".vue",".svelte"]),gn=new Set(["node_modules",".git","dist","build",".next",".nuxt",".output","coverage",".cache","__pycache__",".pytest_cache","vendor","target",".turbo",".vercel"]),fn=new Set(["a","an","the","and","or","but","is","are","was","were","be","been","being","have","has","had","do","does","did","will","would","could","should","may","might","must","shall","can","need","to","of","in","for","on","with","at","by","from","as","into","through","during","before","after","above","below","between","under","again","further","then","once","here","there","when","where","why","how","all","each","few","more","most","other","some","such","no","nor","not","only","own","same","so","than","too","very","just","add","create","make","implement","fix","update","change","modify","remove","delete","new"])});import Eo from"node:fs/promises";import Yt from"node:path";async function Jt(r,t,e={}){let s=Date.now(),n=e.maxFiles??30,i=e.minScore??.1,o=e.includeTests??!1,a=So(r),u=await wo(t),p=await bo(t),m=[];for(let f of u){if(!o&&vo(f))continue;let T=_o(f,a,p,e.historicalBoosts);T.score>=i&&m.push(T)}m.sort((f,T)=>T.score-f.score);let d=m.slice(0,n);return{files:d,metrics:{filesScanned:u.length,filesReturned:d.length,scanDuration:Date.now()-s}}}function So(r){return r.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).filter(e=>!fn.has(e)&&e.length>2)}async function wo(r){let t=[];async function e(s,n=""){try{let i=await Eo.readdir(s,{withFileTypes:!0});for(let o of i){let a=Yt.join(s,o.name),u=Yt.join(n,o.name);if(o.isDirectory()){if(gn.has(o.name)||o.name.startsWith("."))continue;await e(a,u)}else if(o.isFile()){let p=Yt.extname(o.name).toLowerCase();mn.has(p)&&t.push(u)}}}catch(i){L(i)}}return c(e,"walk"),await e(r),t}async function bo(r){let t=new Map;try{let{stdout:e}=await _(`git log -30 --pretty=format:"%H %ct" --name-only | awk '
|
|
547
547
|
/^[a-f0-9]{40}/ { commit=$1; timestamp=$2; next }
|
|
548
548
|
NF { files[$0]++; if (!lastmod[$0]) lastmod[$0]=timestamp }
|
|
549
549
|
END { for (f in files) print files[f], lastmod[f], f }
|