prjct-cli 1.27.0 → 1.27.1

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.27.1] - 2026-02-11
4
+
5
+ ### Bug Fixes
6
+
7
+ - exclude router files (p.md/p.toml) from subcommand installation
8
+
9
+
3
10
  ## [1.27.0] - 2026-02-11
4
11
 
5
12
  ### Features
@@ -277,7 +277,7 @@ Context: ${s}`:""}`,tags:i,userTriggered:!0})}async getAllMemories(e){return(awa
277
277
  `).forEach(i=>{let[a,...c]=i.split(":");if(a&&c.length>0){let u=c.join(":").trim();u.startsWith("[")&&u.endsWith("]")?o[a.trim()]=u.slice(1,-1).split(",").map(d=>d.trim()):o[a.trim()]=u.replace(/^["']|["']$/g,"")}}),{frontmatter:o,content:s.trim()}}async function Kp(r){if($s.has(r))return ab(r),$s.get(r);let e,t=Dc();if(t){let s=`commands/${r}.md`;e=t[s]}if(!e){let s=ni.join(pe,"templates","commands",`${r}.md`);try{e=await ob.readFile(s,"utf-8")}catch{throw Po.notFound(r)}}let n=si(e);return cb(),$s.set(r,n),Jn.push(r),n}async function lb(r){return(await Kp(r)).frontmatter["allowed-tools"]||[]}function ub(){$s.clear(),Jn.length=0}function ve(r){let e=Dc();if(e?.[r])return e[r];let t=ni.join(pe,"templates",r);try{return jc.readFileSync(t,"utf-8")}catch{return null}}function Ms(r){let e=Dc();if(e)return Object.keys(e).filter(n=>n.startsWith(r));let t=ni.join(pe,"templates",r);try{return jc.readdirSync(t).map(s=>`${r}${s}`)}catch{return[]}}var ib,$s,Jn,Ac,qp,db,Rc,qn=y(()=>{"use strict";cn();dt();ib=50,$s=new Map,Jn=[],Ac=null,qp=!1;l(Dc,"loadBundle");l(ab,"updateLruOrder");l(cb,"evictLru");l(si,"parseFrontmatter");l(Kp,"load");l(lb,"getAllowedTools");l(ub,"clearCache");l(ve,"getTemplateContent");l(Ms,"listTemplates");db={load:Kp,parseFrontmatter:si,getAllowedTools:lb,clearCache:ub,getTemplateContent:ve,listTemplates:Ms},Rc=db});import X from"node:fs/promises";import Mc from"node:os";import Z from"node:path";async function pb(){try{let r=ve("global/modules/module-config.json");if(r)return JSON.parse(r);let e=Z.join(pe,"templates/global/modules/module-config.json"),t=await X.readFile(e,"utf-8");return JSON.parse(t)}catch{return null}}async function mb(r){let e=await pb();if(!e){let i=ve("global/CLAUDE.md");if(i)return i;let a=Z.join(pe,"templates/global/CLAUDE.md");return X.readFile(a,"utf-8")}let t=r||e.default,n=e.profiles[t];if(!n&&!e.profiles[e.default]){let a=ve("global/CLAUDE.md");if(a)return a;let c=Z.join(pe,"templates/global/CLAUDE.md");return X.readFile(c,"utf-8")}let s=(n||e.profiles[e.default]).modules,o=[];o.push("<!-- prjct:start - DO NOT REMOVE THIS MARKER -->");for(let i of s){let a=ve(`global/modules/${i}`);if(a)o.push(""),o.push(a);else try{let c=Z.join(pe,"templates/global/modules",i),u=await X.readFile(c,"utf-8");o.push(""),o.push(u)}catch{console.warn(`Module not found: ${i}`)}}return o.push(""),o.push("<!-- prjct:end - DO NOT REMOVE THIS MARKER -->"),o.push(""),o.join(`
278
278
  `)}async function gb(){try{let r=Z.join(Mc.homedir(),".prjct-cli","docs");await X.mkdir(r,{recursive:!0});let e=Ms("global/docs/");if(e.length>0){for(let s of e)if(s.endsWith(".md")){let o=ve(s);if(o){let i=Z.basename(s);await X.writeFile(Z.join(r,i),o,"utf-8")}}return{success:!0}}let t=Z.join(pe,"templates/global/docs"),n=await X.readdir(t);for(let s of n)if(s.endsWith(".md")){let o=Z.join(t,s),i=Z.join(r,s),a=await X.readFile(o,"utf-8");await X.writeFile(i,a,"utf-8")}return{success:!0}}catch(r){return{success:!1,error:w(r)}}}async function fb(){let r=(Be(),xt(ut)),e=await r.getActiveProvider(),t=e.name;if(!(await r.detectProvider(t)).installed&&!e.configDir)return{success:!1,error:`${e.displayName} not detected`,action:"skipped"};try{await X.mkdir(e.configDir,{recursive:!0});let s=Z.join(e.configDir,e.contextFile),o=Z.join(pe,"templates","global",e.contextFile),i="";try{let u=ve(`global/${e.contextFile}`);u?i=u:i=await X.readFile(o,"utf-8")}catch{if(t==="claude")try{i=await mb()}catch{let d=ve("global/CLAUDE.md");if(d)i=d;else{let m=Z.join(pe,"templates/global/CLAUDE.md");i=await X.readFile(m,"utf-8")}}else{let d=ve("global/CLAUDE.md");if(d)i=d;else{let m=Z.join(pe,"templates/global/CLAUDE.md");i=await X.readFile(m,"utf-8")}t==="gemini"&&(i=i.replace(/Claude/g,"Gemini"))}}let a="",c=!1;try{a=await X.readFile(s,"utf-8"),c=!0}catch(u){if(v(u))c=!1;else throw u}if(c){let u="<!-- prjct:start - DO NOT REMOVE THIS MARKER -->",d="<!-- prjct:end - DO NOT REMOVE THIS MARKER -->";if(a.includes(u)&&a.includes(d)){let p=a.substring(0,a.indexOf(u)),g=a.substring(a.indexOf(d)+d.length),f=i.substring(i.indexOf(u),i.indexOf(d)+d.length),S=p+f+g;return await X.writeFile(s,S,"utf-8"),{success:!0,action:"updated",path:s}}else{let p=`${a}
279
279
 
280
- ${i}`;return await X.writeFile(s,p,"utf-8"),{success:!0,action:"appended",path:s}}}else return await X.writeFile(s,i,"utf-8"),{success:!0,action:"created",path:s}}catch(s){return{success:!1,error:w(s),action:"failed"}}}function Yp(){let r=Mc.homedir();return{claude:{commands:Z.join(r,".claude","commands","p"),config:Z.join(r,".claude"),router:Z.join(r,".claude","commands","p.md")},gemini:{commands:Z.join(r,".gemini","commands"),config:Z.join(r,".gemini"),router:Z.join(r,".gemini","commands","p.toml")}}}var $c,hb,Ee,xn=y(()=>{"use strict";qn();_();dt();l(pb,"loadModuleConfig");l(mb,"composeGlobalTemplate");l(gb,"installDocs");l(fb,"installGlobalConfig");$c=class{static{l(this,"CommandInstaller")}homeDir;claudeCommandsPath="";claudeConfigPath="";templatesDir;_initialized=!1;constructor(){this.homeDir=Mc.homedir(),this.templatesDir=Z.join(pe,"templates","commands")}async ensureInit(){if(this._initialized)return;let t=await(Be(),xt(ut)).getActiveProvider();t.name==="gemini"?this.claudeCommandsPath=Z.join(t.configDir,"commands"):this.claudeCommandsPath=Z.join(t.configDir,"commands","p"),this.claudeConfigPath=t.configDir,this._initialized=!0}async detectActiveProvider(){await this.ensureInit();try{return await X.access(this.claudeConfigPath),!0}catch(e){if(v(e))return!1;throw e}}async detectClaude(){return this.detectActiveProvider()}async getCommandFiles(){let e=Ms("commands/");if(e.length>0)return e.filter(t=>t.endsWith(".md")).map(t=>t.replace("commands/",""));try{return(await X.readdir(this.templatesDir)).filter(n=>n.endsWith(".md"))}catch{return["init.md","now.md","done.md","ship.md","next.md","idea.md","recap.md","progress.md","stuck.md","context.md","analyze.md","sync.md","roadmap.md","task.md","git.md","fix.md","test.md","cleanup.md","design.md"]}}async installCommands(){let e=await this.detectActiveProvider(),n=await(Be(),xt(ut)).getActiveProvider();if(!e)return{success:!1,error:`${n.displayName} not detected. Please install it first.`};try{await this.installRouter(),await X.mkdir(this.claudeCommandsPath,{recursive:!0});let s=await this.getCommandFiles(),o=[],i=[];for(let a of s)try{let c=Z.join(this.claudeCommandsPath,a),u=ve(`commands/${a}`);if(u)await X.writeFile(c,u,"utf-8");else{let d=Z.join(this.templatesDir,a),m=await X.readFile(d,"utf-8");await X.writeFile(c,m,"utf-8")}o.push(a.replace(".md",""))}catch(c){i.push({file:a,error:w(c)})}return{success:!0,installed:o,errors:i,path:this.claudeCommandsPath}}catch(s){return{success:!1,error:w(s)}}}async uninstallCommands(){try{let e=await this.getCommandFiles(),t=[],n=[];for(let s of e)try{let o=Z.join(this.claudeCommandsPath,s);await X.unlink(o),t.push(s.replace(".md",""))}catch(o){o.code!=="ENOENT"&&n.push({file:s,error:w(o)})}try{await X.rmdir(this.claudeCommandsPath)}catch{}return{success:!0,uninstalled:t,errors:n}}catch(e){return{success:!1,error:w(e)}}}async checkInstallation(){if(!await this.detectClaude())return{installed:!1,claudeDetected:!1};try{await X.access(this.claudeCommandsPath);let n=(await X.readdir(this.claudeCommandsPath)).filter(s=>s.endsWith(".md")).map(s=>s.replace(".md",""));return{installed:n.length>0,claudeDetected:!0,commands:n,path:this.claudeCommandsPath}}catch(t){if(v(t))return{installed:!1,claudeDetected:!0,commands:[]};throw t}}async updateCommands(){console.log("Updating commands with latest templates...");let e=await this.installCommands();return e.success&&e.installed&&console.log(`Updated ${e.installed.length} commands`),e}async installToAll(){return await this.installCommands()}async getInstallPath(){return await this.ensureInit(),this.claudeCommandsPath}async verifyTemplate(e){if(ve(`commands/${e}.md`))return!0;try{let n=Z.join(this.templatesDir,`${e}.md`);return await X.access(n),!0}catch(n){if(v(n))return!1;throw n}}async installRouter(){let t=await(Be(),xt(ut)).getActiveProvider(),n=t.name==="gemini"?"p.toml":"p.md";try{let s=Z.join(t.configDir,"commands",n);await X.mkdir(Z.dirname(s),{recursive:!0});let o=ve(`commands/${n}`);if(o)return await X.writeFile(s,o,"utf-8"),!0;let i=Z.join(this.templatesDir,n),a=await X.readFile(i,"utf-8");return await X.writeFile(s,a,"utf-8"),!0}catch(s){if(v(s))return!1;throw s}}async removeLegacyCommands(){let t=await(Be(),xt(ut)).getActiveProvider(),n=Z.join(t.configDir,"commands"),s=0;try{let i=(await X.readdir(n)).filter(a=>a.startsWith("p.")&&a.endsWith(".md"));for(let a of i)try{await X.unlink(Z.join(n,a)),s++}catch{}}catch{}return s}async syncCommands(){if(!await this.detectActiveProvider())return{success:!1,error:"AI agent not detected",added:0,updated:0,removed:0};try{await this.installRouter(),await X.mkdir(this.claudeCommandsPath,{recursive:!0});let t=await this.getCommandFiles(),n=[];try{n=await X.readdir(this.claudeCommandsPath),n=n.filter(o=>o.endsWith(".md"))}catch(o){if(v(o))n=[];else throw o}let s={success:!0,added:0,updated:0,removed:0,errors:[]};for(let o of t)try{let i=Z.join(this.claudeCommandsPath,o),a=n.includes(o),c=ve(`commands/${o}`);if(c)await X.writeFile(i,c,"utf-8");else{let u=Z.join(this.templatesDir,o),d=await X.readFile(u,"utf-8");await X.writeFile(i,d,"utf-8")}a?s.updated++:s.added++}catch(i){s.errors.push({file:o,error:w(i)})}return await this.removeLegacyCommands(),s}catch(t){return{success:!1,error:w(t),added:0,updated:0,removed:0}}}async installGlobalConfig(){return fb()}async installDocs(){return gb()}};l(Yp,"getProviderPaths");hb=new $c,Ee=hb});import{z as Oe}from"zod";function em(r,e="default"){let t=Xp[e]||Xp.default;return r/1e3*t}function ri(r){return r<.01?`$${(r*100).toFixed(2)}\xA2`:`$${r.toFixed(2)}`}var yb,wb,Qp,Zp,Xp,oi=y(()=>{"use strict";yb=Oe.object({date:Oe.string(),tokensSaved:Oe.number(),syncs:Oe.number(),avgCompressionRate:Oe.number(),totalDuration:Oe.number()}),wb=Oe.object({agentName:Oe.string(),usageCount:Oe.number(),tokensSaved:Oe.number()}),Qp=Oe.object({totalTokensSaved:Oe.number(),avgCompressionRate:Oe.number(),syncCount:Oe.number(),watchTriggers:Oe.number(),avgSyncDuration:Oe.number(),totalSyncDuration:Oe.number(),agentUsage:Oe.array(wb),dailyStats:Oe.array(yb),firstSync:Oe.string(),lastUpdated:Oe.string()}),Zp={totalTokensSaved:0,avgCompressionRate:0,syncCount:0,watchTriggers:0,avgSyncDuration:0,totalSyncDuration:0,agentUsage:[],dailyStats:[],firstSync:"",lastUpdated:""},Xp={"claude-opus-4.5":.005,"claude-sonnet-4.5":.003,"claude-haiku-4.5":.001,"claude-opus-4":.015,"claude-sonnet-4":.003,"claude-3-opus":.015,"claude-3-sonnet":.003,"gpt-4o":.0025,"gpt-4":.01,"gemini-pro":.00125,default:.003};l(em,"estimateCostSaved");l(ri,"formatCost")});function Sb(){return/<!-- prjct:preserve(?::([\w-]+))? -->/g}function kb(r){let e=[],t=Sb(),n,s=0;for(;(n=t.exec(r))!==null;){let o=n.index,i=n[0],a=n[1]||`section-${s++}`,c=r.indexOf(Oc,o+i.length);if(c===-1)continue;let u=c+Oc.length,d=r.substring(o,u);e.push({id:a,content:d,startIndex:o,endIndex:u})}return e}function Fc(r,e){let t=kb(e);if(t.length===0)return r;let n=r.trimEnd();n+=`
280
+ ${i}`;return await X.writeFile(s,p,"utf-8"),{success:!0,action:"appended",path:s}}}else return await X.writeFile(s,i,"utf-8"),{success:!0,action:"created",path:s}}catch(s){return{success:!1,error:w(s),action:"failed"}}}function Yp(){let r=Mc.homedir();return{claude:{commands:Z.join(r,".claude","commands","p"),config:Z.join(r,".claude"),router:Z.join(r,".claude","commands","p.md")},gemini:{commands:Z.join(r,".gemini","commands"),config:Z.join(r,".gemini"),router:Z.join(r,".gemini","commands","p.toml")}}}var $c,hb,Ee,xn=y(()=>{"use strict";qn();_();dt();l(pb,"loadModuleConfig");l(mb,"composeGlobalTemplate");l(gb,"installDocs");l(fb,"installGlobalConfig");$c=class{static{l(this,"CommandInstaller")}homeDir;claudeCommandsPath="";claudeConfigPath="";templatesDir;_initialized=!1;constructor(){this.homeDir=Mc.homedir(),this.templatesDir=Z.join(pe,"templates","commands")}async ensureInit(){if(this._initialized)return;let t=await(Be(),xt(ut)).getActiveProvider();t.name==="gemini"?this.claudeCommandsPath=Z.join(t.configDir,"commands"):this.claudeCommandsPath=Z.join(t.configDir,"commands","p"),this.claudeConfigPath=t.configDir,this._initialized=!0}async detectActiveProvider(){await this.ensureInit();try{return await X.access(this.claudeConfigPath),!0}catch(e){if(v(e))return!1;throw e}}async detectClaude(){return this.detectActiveProvider()}async getCommandFiles(){let e=new Set(["p.md","p.toml"]),t=Ms("commands/");if(t.length>0)return t.filter(n=>n.endsWith(".md")).map(n=>n.replace("commands/","")).filter(n=>!e.has(n));try{return(await X.readdir(this.templatesDir)).filter(s=>s.endsWith(".md")&&!e.has(s))}catch{return["init.md","now.md","done.md","ship.md","next.md","idea.md","recap.md","progress.md","stuck.md","context.md","analyze.md","sync.md","roadmap.md","task.md","git.md","fix.md","test.md","cleanup.md","design.md"]}}async installCommands(){let e=await this.detectActiveProvider(),n=await(Be(),xt(ut)).getActiveProvider();if(!e)return{success:!1,error:`${n.displayName} not detected. Please install it first.`};try{await this.installRouter(),await X.mkdir(this.claudeCommandsPath,{recursive:!0});let s=await this.getCommandFiles(),o=[],i=[];for(let a of s)try{let c=Z.join(this.claudeCommandsPath,a),u=ve(`commands/${a}`);if(u)await X.writeFile(c,u,"utf-8");else{let d=Z.join(this.templatesDir,a),m=await X.readFile(d,"utf-8");await X.writeFile(c,m,"utf-8")}o.push(a.replace(".md",""))}catch(c){i.push({file:a,error:w(c)})}return{success:!0,installed:o,errors:i,path:this.claudeCommandsPath}}catch(s){return{success:!1,error:w(s)}}}async uninstallCommands(){try{let e=await this.getCommandFiles(),t=[],n=[];for(let s of e)try{let o=Z.join(this.claudeCommandsPath,s);await X.unlink(o),t.push(s.replace(".md",""))}catch(o){o.code!=="ENOENT"&&n.push({file:s,error:w(o)})}try{await X.rmdir(this.claudeCommandsPath)}catch{}return{success:!0,uninstalled:t,errors:n}}catch(e){return{success:!1,error:w(e)}}}async checkInstallation(){if(!await this.detectClaude())return{installed:!1,claudeDetected:!1};try{await X.access(this.claudeCommandsPath);let n=(await X.readdir(this.claudeCommandsPath)).filter(s=>s.endsWith(".md")).map(s=>s.replace(".md",""));return{installed:n.length>0,claudeDetected:!0,commands:n,path:this.claudeCommandsPath}}catch(t){if(v(t))return{installed:!1,claudeDetected:!0,commands:[]};throw t}}async updateCommands(){console.log("Updating commands with latest templates...");let e=await this.installCommands();return e.success&&e.installed&&console.log(`Updated ${e.installed.length} commands`),e}async installToAll(){return await this.installCommands()}async getInstallPath(){return await this.ensureInit(),this.claudeCommandsPath}async verifyTemplate(e){if(ve(`commands/${e}.md`))return!0;try{let n=Z.join(this.templatesDir,`${e}.md`);return await X.access(n),!0}catch(n){if(v(n))return!1;throw n}}async installRouter(){let t=await(Be(),xt(ut)).getActiveProvider(),n=t.name==="gemini"?"p.toml":"p.md";try{let s=Z.join(t.configDir,"commands",n);await X.mkdir(Z.dirname(s),{recursive:!0});let o=ve(`commands/${n}`);if(o)return await X.writeFile(s,o,"utf-8"),!0;let i=Z.join(this.templatesDir,n),a=await X.readFile(i,"utf-8");return await X.writeFile(s,a,"utf-8"),!0}catch(s){if(v(s))return!1;throw s}}async removeLegacyCommands(){let t=await(Be(),xt(ut)).getActiveProvider(),n=Z.join(t.configDir,"commands"),s=0;try{let i=(await X.readdir(n)).filter(a=>a.startsWith("p.")&&a.endsWith(".md"));for(let a of i)try{await X.unlink(Z.join(n,a)),s++}catch{}}catch{}return s}async syncCommands(){if(!await this.detectActiveProvider())return{success:!1,error:"AI agent not detected",added:0,updated:0,removed:0};try{await this.installRouter(),await X.mkdir(this.claudeCommandsPath,{recursive:!0});let t=await this.getCommandFiles(),n=[];try{n=await X.readdir(this.claudeCommandsPath),n=n.filter(o=>o.endsWith(".md"))}catch(o){if(v(o))n=[];else throw o}let s={success:!0,added:0,updated:0,removed:0,errors:[]};for(let o of t)try{let i=Z.join(this.claudeCommandsPath,o),a=n.includes(o),c=ve(`commands/${o}`);if(c)await X.writeFile(i,c,"utf-8");else{let u=Z.join(this.templatesDir,o),d=await X.readFile(u,"utf-8");await X.writeFile(i,d,"utf-8")}a?s.updated++:s.added++}catch(i){s.errors.push({file:o,error:w(i)})}return await this.removeLegacyCommands(),s}catch(t){return{success:!1,error:w(t),added:0,updated:0,removed:0}}}async installGlobalConfig(){return fb()}async installDocs(){return gb()}};l(Yp,"getProviderPaths");hb=new $c,Ee=hb});import{z as Oe}from"zod";function em(r,e="default"){let t=Xp[e]||Xp.default;return r/1e3*t}function ri(r){return r<.01?`$${(r*100).toFixed(2)}\xA2`:`$${r.toFixed(2)}`}var yb,wb,Qp,Zp,Xp,oi=y(()=>{"use strict";yb=Oe.object({date:Oe.string(),tokensSaved:Oe.number(),syncs:Oe.number(),avgCompressionRate:Oe.number(),totalDuration:Oe.number()}),wb=Oe.object({agentName:Oe.string(),usageCount:Oe.number(),tokensSaved:Oe.number()}),Qp=Oe.object({totalTokensSaved:Oe.number(),avgCompressionRate:Oe.number(),syncCount:Oe.number(),watchTriggers:Oe.number(),avgSyncDuration:Oe.number(),totalSyncDuration:Oe.number(),agentUsage:Oe.array(wb),dailyStats:Oe.array(yb),firstSync:Oe.string(),lastUpdated:Oe.string()}),Zp={totalTokensSaved:0,avgCompressionRate:0,syncCount:0,watchTriggers:0,avgSyncDuration:0,totalSyncDuration:0,agentUsage:[],dailyStats:[],firstSync:"",lastUpdated:""},Xp={"claude-opus-4.5":.005,"claude-sonnet-4.5":.003,"claude-haiku-4.5":.001,"claude-opus-4":.015,"claude-sonnet-4":.003,"claude-3-opus":.015,"claude-3-sonnet":.003,"gpt-4o":.0025,"gpt-4":.01,"gemini-pro":.00125,default:.003};l(em,"estimateCostSaved");l(ri,"formatCost")});function Sb(){return/<!-- prjct:preserve(?::([\w-]+))? -->/g}function kb(r){let e=[],t=Sb(),n,s=0;for(;(n=t.exec(r))!==null;){let o=n.index,i=n[0],a=n[1]||`section-${s++}`,c=r.indexOf(Oc,o+i.length);if(c===-1)continue;let u=c+Oc.length,d=r.substring(o,u);e.push({id:a,content:d,startIndex:o,endIndex:u})}return e}function Fc(r,e){let t=kb(e);if(t.length===0)return r;let n=r.trimEnd();n+=`
281
281
 
282
282
  ---
283
283
 
@@ -1380,7 +1380,7 @@ if [ -f "$CONFIG" ]; then
1380
1380
  fi
1381
1381
  fi
1382
1382
  echo "prjct"
1383
- `;await q.writeFile(s,S,{mode:493})}await my(t,s),await py(e,t)}catch(r){v(r)||H.warn(`Status line warning: ${w(r)}`)}}async function bE(){try{let r=re.join(us.homedir(),".claude"),e=re.join(r,"mcp.json");await P(r)||await q.mkdir(r,{recursive:!0});let t={mcpServers:{context7:{command:"npx",args:["-y","@upstash/context7-mcp@latest"]}}};if(await P(e)){let n=await q.readFile(e,"utf-8"),s=JSON.parse(n);if(s.mcpServers?.context7)return;s.mcpServers=s.mcpServers||{},s.mcpServers.context7=t.mcpServers.context7,await q.writeFile(e,JSON.stringify(s,null,2),"utf-8")}else await q.writeFile(e,JSON.stringify(t,null,2),"utf-8")}catch(r){H.warn(`Context7 MCP setup warning: ${w(r)}`)}}async function Pa(r,e){if(!await P(r))return;let t=await q.readdir(r);for(let n of t)if(n.endsWith(".sh")){let s=re.join(r,n),o=re.join(e,n);await q.copyFile(s,o),await q.chmod(o,493)}}async function my(r,e){try{if(await P(r)){if((await q.lstat(r)).isSymbolicLink()&&await q.readlink(r)===e)return;await q.unlink(r)}await q.symlink(e,r)}catch{try{await P(e)&&(await q.copyFile(e,r),await q.chmod(r,493))}catch(n){v(n)||H.warn(`Symlink fallback warning: ${n.message}`)}}}function CE(r,e){if(console.log(""),r.cliInstalled?console.log(` ${me.green("\u2713")} ${e.displayName} CLI installed`):console.log(` ${me.green("\u2713")} ${e.displayName} CLI found`),r.commandsAdded+r.commandsUpdated>0){let n=[];r.commandsAdded>0&&n.push(`${r.commandsAdded} new`),r.commandsUpdated>0&&n.push(`${r.commandsUpdated} updated`),console.log(` ${me.green("\u2713")} Commands synced (${n.join(", ")})`)}else console.log(` ${me.green("\u2713")} Commands up to date`);r.configAction==="created"?console.log(` ${me.green("\u2713")} Global config created (${e.contextFile})`):r.configAction==="updated"?console.log(` ${me.green("\u2713")} Global config updated (${e.contextFile})`):r.configAction==="appended"&&console.log(` ${me.green("\u2713")} Global config merged (${e.contextFile})`),console.log("")}var vE,yy=y(()=>{"use strict";qn();ki();he();_();ln();xe();Ln();dt();Be();xn();Va();l(fE,"installAICLI");l(gy,"run");l(hE,"installGeminiRouter");l(yE,"installGeminiGlobalConfig");l(fy,"installAntigravitySkill");l(wE,"needsAntigravityInstallation");l(SE,"migrateProjectsCliVersion");l(py,"ensureStatusLineSettings");l(kE,"installStatusLine");l(bE,"installContext7MCP");l(Pa,"installStatusLineModules");l(my,"ensureStatusLineSymlink");l(CE,"showResults");vE=process.argv[1]?.includes("setup.ts")||process.argv[1]?.includes("setup.js");vE&&gy().catch(r=>{console.error("Setup error:",r.message),process.exit(1)})});var wy=Iy((qJ,xE)=>{xE.exports={name:"prjct-cli",version:"1.27.0",description:"Context layer for AI agents. Project context for Claude Code, Gemini CLI, and more.",main:"dist/bin/prjct.mjs",bin:{prjct:"bin/prjct"},publishConfig:{access:"public",registry:"https://registry.npmjs.org"},scripts:{build:"node scripts/build.js","build:node":"node scripts/build.js",release:"node scripts/release.js","release:patch":"node scripts/release.js patch","release:minor":"node scripts/release.js minor","release:major":"node scripts/release.js major",postinstall:"node scripts/postinstall.js",prepare:"lefthook install","update-commands":`bun -e "const installer = require('./core/infrastructure/command-installer'); installer.syncCommands().then(r => console.log('Commands updated:', r)).catch(e => console.error('Error:', e.message))"`,"install-global":"./scripts/install.sh",update:"./scripts/update.sh",test:"bun test","test:watch":"bun test --watch","test:coverage":"bun test --coverage",typecheck:"tsc --noEmit -p core/tsconfig.json","typecheck:watch":"tsc --noEmit -p core/tsconfig.json --watch",validate:"bun scripts/validate-commands.js",lint:"biome lint .","lint:fix":"biome lint --write .","lint:meta":"bun core/cli/lint-meta-commentary.ts",format:"biome format --write .","format:check":"biome format .",check:"biome check .","check:fix":"biome check --write ."},keywords:["claude-code","gemini-cli","ai-agents","context-layer","developer-tools","ai-assistant","productivity","mcp","llm","coding-agents"],author:"prjct.app",license:"MIT",dependencies:{"@hono/node-server":"^1.13.7","@linear/sdk":"^29.0.0","better-sqlite3":"^12.6.2",chalk:"^4.1.2",chokidar:"^5.0.0","date-fns":"^4.1.0",glob:"^13.0.1",hono:"^4.11.3","jsonc-parser":"^3.3.1",prompts:"^2.4.2",zod:"^3.24.1"},devDependencies:{"@biomejs/biome":"^2.3.13","@types/better-sqlite3":"^7.6.13","@types/bun":"latest","@types/chokidar":"^2.1.7","@types/prompts":"^2.4.9",esbuild:"^0.25.0",lefthook:"^2.1.0",typescript:"^5.9.3"},repository:{type:"git",url:"git+https://github.com/jlopezlira/prjct-cli.git"},bugs:{url:"https://github.com/jlopezlira/prjct-cli/issues"},homepage:"https://prjct.app",packageManager:"bun@1.2.23",engines:{node:">=18.0.0",bun:">=1.0.0"},files:["assets/","bin/prjct","dist/","scripts/postinstall.js","scripts/install.sh","LICENSE","README.md","CHANGELOG.md"],prepublishOnly:"node scripts/build.js",trustedDependencies:["chalk","prompts"]}});var RE={};import Sy from"node:os";import Ta from"node:path";import $e from"chalk";async function PE(){let[r,...e]=process.argv.slice(2);if(["-v","--version","version"].includes(r)){let t=await Promise.resolve().then(()=>Ay(wy()));await jE(t.version),process.exit(0)}["-h","--help",void 0].includes(r)&&(DE(),process.exit(0)),h.start();try{let t=G.getByName(r);if(!t){let d=EE(r),m=d?`Did you mean 'prjct ${d}'? Run 'prjct --help' for all commands`:"Run 'prjct --help' to see available commands";h.failWithHint(Gn("UNKNOWN_COMMAND",{message:`Unknown command: ${r}`,hint:m})),h.end(),process.exit(1)}if(t.deprecated){let d=t.replacedBy?`Use 'prjct ${t.replacedBy}' instead`:"Run 'prjct --help' to see available commands";h.failWithHint({message:`Command '${r}' is deprecated`,hint:d}),h.end(),process.exit(1)}t.implemented||(h.failWithHint({message:`Command '${r}' is not yet implemented`,hint:"Run 'prjct --help' to see available commands",docs:"https://github.com/jlopezlira/prjct-cli"}),h.end(),process.exit(1));let{parsedArgs:n,options:s}=AE(t,e),o=TE(t,n);o&&(h.failWithHint(o),h.end(),process.exit(1));let i=null,a=Date.now();try{i=await R.getProjectId(process.cwd()),i&&(await vn.expireIfStale(i),await vn.touch(i))}catch{}let c=new gn,u;if(r==="design"){let d=n.join(" ");u=await c.design(d,s)}else if(r==="analyze")u=await c.analyze(s);else if(r==="cleanup")u=await c.cleanup(s);else if(r==="setup")u=await c.setup(s);else if(r==="update")u=await c.update(s);else{let d=n.join(" ")||null,m=s.md===!0,g={task:l(f=>c.task(f,process.cwd(),{md:m}),"task"),done:l(()=>c.done(process.cwd(),{md:m}),"done"),next:l(()=>c.next(process.cwd(),{md:m}),"next"),pause:l(f=>c.pause(f||"",process.cwd(),{md:m}),"pause"),resume:l(f=>c.resume(f,process.cwd(),{md:m}),"resume"),init:l(f=>c.init(f),"init"),bug:l(f=>c.bug(f||"",process.cwd(),{md:m}),"bug"),idea:l(f=>c.idea(f||"",process.cwd(),{md:m}),"idea"),spec:l(f=>c.spec(f),"spec"),ship:l(f=>c.ship(f,process.cwd(),{md:m}),"ship"),dash:l(f=>c.dash(f||"default",process.cwd(),{md:m}),"dash"),stats:l(()=>c.stats(process.cwd(),{json:s.json===!0,export:s.export===!0}),"stats"),status:l(()=>c.status(process.cwd(),{json:s.json===!0,md:m}),"status"),help:l(f=>c.help(f||""),"help"),perf:l(f=>c.perf(f||"7"),"perf"),velocity:l(f=>c.velocity(f||"0"),"velocity"),recover:l(()=>c.recover(),"recover"),undo:l(()=>c.undo(),"undo"),redo:l(()=>c.redo(),"redo"),history:l(()=>c.history(),"history"),sync:l(()=>c.sync(process.cwd(),{aiTools:s.agents?String(s.agents).split(","):void 0,preview:s.preview===!0||s["dry-run"]===!0,yes:s.yes===!0,json:s.json===!0,md:m,package:s.package?String(s.package):void 0,full:s.full===!0}),"sync"),seal:l(()=>c.seal(process.cwd(),{json:s.json===!0}),"seal"),verify:l(()=>c.verify(process.cwd(),{json:s.json===!0,semantic:s.semantic===!0}),"verify"),start:l(()=>c.start(),"start"),context:l(f=>c.context(f),"context")}[r];if(g)u=await g(d);else throw new Error(`Command '${r}' has no handler`)}if(i){let d=Date.now()-a;try{await vn.trackCommand(i,r,d)}catch{}try{await zn.recordTiming(i,"command_duration",d,{command:r});let m=globalThis.__perfStartNs;if(m){let p=Number(process.hrtime.bigint()-m)/1e6;await zn.recordTiming(i,"startup_time",p)}await zn.recordMemory(i,{command:r})}catch{}}u?.message&&console.log(u.message),h.end(),process.exit(u?.success?0:1)}catch(t){console.error("Error:",w(t)),process.env.DEBUG&&console.error(wo(t)),h.end(),process.exit(1)}}function TE(r,e){if(!r.params)return null;let t=r.params.match(/<[^>]+>/g);if(!t||t.length===0)return null;if(e.length<t.length){let n=t.map(o=>o.slice(1,-1)).join(", "),s=r.usage.terminal||`prjct ${r.name} ${r.params}`;return Gn("MISSING_PARAM",{message:`Missing required parameter: ${n}`,hint:`Usage: ${s}`})}return null}function EE(r){let e=G.getAll().map(s=>s.name),t=null,n=1/0;for(let s of e){let o=IE(r.toLowerCase(),s.toLowerCase());o<n&&(n=o,t=s)}return n<=2?t:null}function IE(r,e){let t=r.length,n=e.length,s=Array.from({length:t+1},()=>Array(n+1).fill(0));for(let o=0;o<=t;o++)s[o][0]=o;for(let o=0;o<=n;o++)s[0][o]=o;for(let o=1;o<=t;o++)for(let i=1;i<=n;i++)s[o][i]=r[o-1]===e[i-1]?s[o-1][i-1]:1+Math.min(s[o-1][i],s[o][i-1],s[o-1][i-1]);return s[t][n]}function AE(r,e){let t=[],n={};for(let s=0;s<e.length;s++){let o=e[s];if(o.startsWith("--")){let i=o.slice(2);s+1<e.length&&!e[s+1].startsWith("--")?n[i]=e[++s]:n[i]=!0}else t.push(o)}return{parsedArgs:t,options:n}}async function jE(r){let e=await an(),t=Ta.join(Sy.homedir(),".claude","commands","p.md"),n=Ta.join(Sy.homedir(),".gemini","commands","p.toml"),[s,o,i,a]=await Promise.all([P(t),P(n),P(Ta.join(process.cwd(),".cursor","commands","sync.md")),P(Ta.join(process.cwd(),".cursor"))]),c=await ws();if(console.log(`
1383
+ `;await q.writeFile(s,S,{mode:493})}await my(t,s),await py(e,t)}catch(r){v(r)||H.warn(`Status line warning: ${w(r)}`)}}async function bE(){try{let r=re.join(us.homedir(),".claude"),e=re.join(r,"mcp.json");await P(r)||await q.mkdir(r,{recursive:!0});let t={mcpServers:{context7:{command:"npx",args:["-y","@upstash/context7-mcp@latest"]}}};if(await P(e)){let n=await q.readFile(e,"utf-8"),s=JSON.parse(n);if(s.mcpServers?.context7)return;s.mcpServers=s.mcpServers||{},s.mcpServers.context7=t.mcpServers.context7,await q.writeFile(e,JSON.stringify(s,null,2),"utf-8")}else await q.writeFile(e,JSON.stringify(t,null,2),"utf-8")}catch(r){H.warn(`Context7 MCP setup warning: ${w(r)}`)}}async function Pa(r,e){if(!await P(r))return;let t=await q.readdir(r);for(let n of t)if(n.endsWith(".sh")){let s=re.join(r,n),o=re.join(e,n);await q.copyFile(s,o),await q.chmod(o,493)}}async function my(r,e){try{if(await P(r)){if((await q.lstat(r)).isSymbolicLink()&&await q.readlink(r)===e)return;await q.unlink(r)}await q.symlink(e,r)}catch{try{await P(e)&&(await q.copyFile(e,r),await q.chmod(r,493))}catch(n){v(n)||H.warn(`Symlink fallback warning: ${n.message}`)}}}function CE(r,e){if(console.log(""),r.cliInstalled?console.log(` ${me.green("\u2713")} ${e.displayName} CLI installed`):console.log(` ${me.green("\u2713")} ${e.displayName} CLI found`),r.commandsAdded+r.commandsUpdated>0){let n=[];r.commandsAdded>0&&n.push(`${r.commandsAdded} new`),r.commandsUpdated>0&&n.push(`${r.commandsUpdated} updated`),console.log(` ${me.green("\u2713")} Commands synced (${n.join(", ")})`)}else console.log(` ${me.green("\u2713")} Commands up to date`);r.configAction==="created"?console.log(` ${me.green("\u2713")} Global config created (${e.contextFile})`):r.configAction==="updated"?console.log(` ${me.green("\u2713")} Global config updated (${e.contextFile})`):r.configAction==="appended"&&console.log(` ${me.green("\u2713")} Global config merged (${e.contextFile})`),console.log("")}var vE,yy=y(()=>{"use strict";qn();ki();he();_();ln();xe();Ln();dt();Be();xn();Va();l(fE,"installAICLI");l(gy,"run");l(hE,"installGeminiRouter");l(yE,"installGeminiGlobalConfig");l(fy,"installAntigravitySkill");l(wE,"needsAntigravityInstallation");l(SE,"migrateProjectsCliVersion");l(py,"ensureStatusLineSettings");l(kE,"installStatusLine");l(bE,"installContext7MCP");l(Pa,"installStatusLineModules");l(my,"ensureStatusLineSymlink");l(CE,"showResults");vE=process.argv[1]?.includes("setup.ts")||process.argv[1]?.includes("setup.js");vE&&gy().catch(r=>{console.error("Setup error:",r.message),process.exit(1)})});var wy=Iy((qJ,xE)=>{xE.exports={name:"prjct-cli",version:"1.27.1",description:"Context layer for AI agents. Project context for Claude Code, Gemini CLI, and more.",main:"dist/bin/prjct.mjs",bin:{prjct:"bin/prjct"},publishConfig:{access:"public",registry:"https://registry.npmjs.org"},scripts:{build:"node scripts/build.js","build:node":"node scripts/build.js",release:"node scripts/release.js","release:patch":"node scripts/release.js patch","release:minor":"node scripts/release.js minor","release:major":"node scripts/release.js major",postinstall:"node scripts/postinstall.js",prepare:"lefthook install","update-commands":`bun -e "const installer = require('./core/infrastructure/command-installer'); installer.syncCommands().then(r => console.log('Commands updated:', r)).catch(e => console.error('Error:', e.message))"`,"install-global":"./scripts/install.sh",update:"./scripts/update.sh",test:"bun test","test:watch":"bun test --watch","test:coverage":"bun test --coverage",typecheck:"tsc --noEmit -p core/tsconfig.json","typecheck:watch":"tsc --noEmit -p core/tsconfig.json --watch",validate:"bun scripts/validate-commands.js",lint:"biome lint .","lint:fix":"biome lint --write .","lint:meta":"bun core/cli/lint-meta-commentary.ts",format:"biome format --write .","format:check":"biome format .",check:"biome check .","check:fix":"biome check --write ."},keywords:["claude-code","gemini-cli","ai-agents","context-layer","developer-tools","ai-assistant","productivity","mcp","llm","coding-agents"],author:"prjct.app",license:"MIT",dependencies:{"@hono/node-server":"^1.13.7","@linear/sdk":"^29.0.0","better-sqlite3":"^12.6.2",chalk:"^4.1.2",chokidar:"^5.0.0","date-fns":"^4.1.0",glob:"^13.0.1",hono:"^4.11.3","jsonc-parser":"^3.3.1",prompts:"^2.4.2",zod:"^3.24.1"},devDependencies:{"@biomejs/biome":"^2.3.13","@types/better-sqlite3":"^7.6.13","@types/bun":"latest","@types/chokidar":"^2.1.7","@types/prompts":"^2.4.9",esbuild:"^0.25.0",lefthook:"^2.1.0",typescript:"^5.9.3"},repository:{type:"git",url:"git+https://github.com/jlopezlira/prjct-cli.git"},bugs:{url:"https://github.com/jlopezlira/prjct-cli/issues"},homepage:"https://prjct.app",packageManager:"bun@1.2.23",engines:{node:">=18.0.0",bun:">=1.0.0"},files:["assets/","bin/prjct","dist/","scripts/postinstall.js","scripts/install.sh","LICENSE","README.md","CHANGELOG.md"],prepublishOnly:"node scripts/build.js",trustedDependencies:["chalk","prompts"]}});var RE={};import Sy from"node:os";import Ta from"node:path";import $e from"chalk";async function PE(){let[r,...e]=process.argv.slice(2);if(["-v","--version","version"].includes(r)){let t=await Promise.resolve().then(()=>Ay(wy()));await jE(t.version),process.exit(0)}["-h","--help",void 0].includes(r)&&(DE(),process.exit(0)),h.start();try{let t=G.getByName(r);if(!t){let d=EE(r),m=d?`Did you mean 'prjct ${d}'? Run 'prjct --help' for all commands`:"Run 'prjct --help' to see available commands";h.failWithHint(Gn("UNKNOWN_COMMAND",{message:`Unknown command: ${r}`,hint:m})),h.end(),process.exit(1)}if(t.deprecated){let d=t.replacedBy?`Use 'prjct ${t.replacedBy}' instead`:"Run 'prjct --help' to see available commands";h.failWithHint({message:`Command '${r}' is deprecated`,hint:d}),h.end(),process.exit(1)}t.implemented||(h.failWithHint({message:`Command '${r}' is not yet implemented`,hint:"Run 'prjct --help' to see available commands",docs:"https://github.com/jlopezlira/prjct-cli"}),h.end(),process.exit(1));let{parsedArgs:n,options:s}=AE(t,e),o=TE(t,n);o&&(h.failWithHint(o),h.end(),process.exit(1));let i=null,a=Date.now();try{i=await R.getProjectId(process.cwd()),i&&(await vn.expireIfStale(i),await vn.touch(i))}catch{}let c=new gn,u;if(r==="design"){let d=n.join(" ");u=await c.design(d,s)}else if(r==="analyze")u=await c.analyze(s);else if(r==="cleanup")u=await c.cleanup(s);else if(r==="setup")u=await c.setup(s);else if(r==="update")u=await c.update(s);else{let d=n.join(" ")||null,m=s.md===!0,g={task:l(f=>c.task(f,process.cwd(),{md:m}),"task"),done:l(()=>c.done(process.cwd(),{md:m}),"done"),next:l(()=>c.next(process.cwd(),{md:m}),"next"),pause:l(f=>c.pause(f||"",process.cwd(),{md:m}),"pause"),resume:l(f=>c.resume(f,process.cwd(),{md:m}),"resume"),init:l(f=>c.init(f),"init"),bug:l(f=>c.bug(f||"",process.cwd(),{md:m}),"bug"),idea:l(f=>c.idea(f||"",process.cwd(),{md:m}),"idea"),spec:l(f=>c.spec(f),"spec"),ship:l(f=>c.ship(f,process.cwd(),{md:m}),"ship"),dash:l(f=>c.dash(f||"default",process.cwd(),{md:m}),"dash"),stats:l(()=>c.stats(process.cwd(),{json:s.json===!0,export:s.export===!0}),"stats"),status:l(()=>c.status(process.cwd(),{json:s.json===!0,md:m}),"status"),help:l(f=>c.help(f||""),"help"),perf:l(f=>c.perf(f||"7"),"perf"),velocity:l(f=>c.velocity(f||"0"),"velocity"),recover:l(()=>c.recover(),"recover"),undo:l(()=>c.undo(),"undo"),redo:l(()=>c.redo(),"redo"),history:l(()=>c.history(),"history"),sync:l(()=>c.sync(process.cwd(),{aiTools:s.agents?String(s.agents).split(","):void 0,preview:s.preview===!0||s["dry-run"]===!0,yes:s.yes===!0,json:s.json===!0,md:m,package:s.package?String(s.package):void 0,full:s.full===!0}),"sync"),seal:l(()=>c.seal(process.cwd(),{json:s.json===!0}),"seal"),verify:l(()=>c.verify(process.cwd(),{json:s.json===!0,semantic:s.semantic===!0}),"verify"),start:l(()=>c.start(),"start"),context:l(f=>c.context(f),"context")}[r];if(g)u=await g(d);else throw new Error(`Command '${r}' has no handler`)}if(i){let d=Date.now()-a;try{await vn.trackCommand(i,r,d)}catch{}try{await zn.recordTiming(i,"command_duration",d,{command:r});let m=globalThis.__perfStartNs;if(m){let p=Number(process.hrtime.bigint()-m)/1e6;await zn.recordTiming(i,"startup_time",p)}await zn.recordMemory(i,{command:r})}catch{}}u?.message&&console.log(u.message),h.end(),process.exit(u?.success?0:1)}catch(t){console.error("Error:",w(t)),process.env.DEBUG&&console.error(wo(t)),h.end(),process.exit(1)}}function TE(r,e){if(!r.params)return null;let t=r.params.match(/<[^>]+>/g);if(!t||t.length===0)return null;if(e.length<t.length){let n=t.map(o=>o.slice(1,-1)).join(", "),s=r.usage.terminal||`prjct ${r.name} ${r.params}`;return Gn("MISSING_PARAM",{message:`Missing required parameter: ${n}`,hint:`Usage: ${s}`})}return null}function EE(r){let e=G.getAll().map(s=>s.name),t=null,n=1/0;for(let s of e){let o=IE(r.toLowerCase(),s.toLowerCase());o<n&&(n=o,t=s)}return n<=2?t:null}function IE(r,e){let t=r.length,n=e.length,s=Array.from({length:t+1},()=>Array(n+1).fill(0));for(let o=0;o<=t;o++)s[o][0]=o;for(let o=0;o<=n;o++)s[0][o]=o;for(let o=1;o<=t;o++)for(let i=1;i<=n;i++)s[o][i]=r[o-1]===e[i-1]?s[o-1][i-1]:1+Math.min(s[o-1][i],s[o][i-1],s[o-1][i-1]);return s[t][n]}function AE(r,e){let t=[],n={};for(let s=0;s<e.length;s++){let o=e[s];if(o.startsWith("--")){let i=o.slice(2);s+1<e.length&&!e[s+1].startsWith("--")?n[i]=e[++s]:n[i]=!0}else t.push(o)}return{parsedArgs:t,options:n}}async function jE(r){let e=await an(),t=Ta.join(Sy.homedir(),".claude","commands","p.md"),n=Ta.join(Sy.homedir(),".gemini","commands","p.toml"),[s,o,i,a]=await Promise.all([P(t),P(n),P(Ta.join(process.cwd(),".cursor","commands","sync.md")),P(Ta.join(process.cwd(),".cursor"))]),c=await ws();if(console.log(`
1384
1384
  ${$e.cyan("p/")} prjct v${r}
1385
1385
  ${$e.dim("Context layer for AI coding agents")}
1386
1386
 
@@ -261,7 +261,7 @@ Context: ${s}`:""}`,tags:i,userTriggered:!0})}async getAllMemories(e){return(awa
261
261
  `).forEach(i=>{let[a,...c]=i.split(":");if(a&&c.length>0){let u=c.join(":").trim();u.startsWith("[")&&u.endsWith("]")?o[a.trim()]=u.slice(1,-1).split(",").map(d=>d.trim()):o[a.trim()]=u.replace(/^["']|["']$/g,"")}}),{frontmatter:o,content:s.trim()}}async function Au(r){if(Bn.has(r))return Cy(r),Bn.get(r);let e,t=Gi();if(t){let s=`commands/${r}.md`;e=t[s]}if(!e){let s=jr.join(ke,"templates","commands",`${r}.md`);try{e=await by.readFile(s,"utf-8")}catch{throw Ir.notFound(r)}}let n=$r(e);return xy(),Bn.set(r,n),pn.push(r),n}async function vy(r){return(await Au(r)).frontmatter["allowed-tools"]||[]}function Ty(){Bn.clear(),pn.length=0}function ve(r){let e=Gi();if(e?.[r])return e[r];let t=jr.join(ke,"templates",r);try{return zi.readFileSync(t,"utf-8")}catch{return null}}function Vn(r){let e=Gi();if(e)return Object.keys(e).filter(n=>n.startsWith(r));let t=jr.join(ke,"templates",r);try{return zi.readdirSync(t).map(s=>`${r}${s}`)}catch{return[]}}var Py,Bn,pn,Hi,Eu,Ey,Wi,Jn=w(()=>{"use strict";Ut();dn();Py=50,Bn=new Map,pn=[],Hi=null,Eu=!1;l(Gi,"loadBundle");l(Cy,"updateLruOrder");l(xy,"evictLru");l($r,"parseFrontmatter");l(Au,"load");l(vy,"getAllowedTools");l(Ty,"clearCache");l(ve,"getTemplateContent");l(Vn,"listTemplates");Ey={load:Au,parseFrontmatter:$r,getAllowedTools:vy,clearCache:Ty,getTemplateContent:ve,listTemplates:Vn},Wi=Ey});import W from"node:fs/promises";import Vi from"node:os";import J from"node:path";async function Ay(){try{let r=ve("global/modules/module-config.json");if(r)return JSON.parse(r);let e=J.join(ke,"templates/global/modules/module-config.json"),t=await W.readFile(e,"utf-8");return JSON.parse(t)}catch{return null}}async function Iy(r){let e=await Ay();if(!e){let i=ve("global/CLAUDE.md");if(i)return i;let a=J.join(ke,"templates/global/CLAUDE.md");return W.readFile(a,"utf-8")}let t=r||e.default,n=e.profiles[t];if(!n&&!e.profiles[e.default]){let a=ve("global/CLAUDE.md");if(a)return a;let c=J.join(ke,"templates/global/CLAUDE.md");return W.readFile(c,"utf-8")}let s=(n||e.profiles[e.default]).modules,o=[];o.push("<!-- prjct:start - DO NOT REMOVE THIS MARKER -->");for(let i of s){let a=ve(`global/modules/${i}`);if(a)o.push(""),o.push(a);else try{let c=J.join(ke,"templates/global/modules",i),u=await W.readFile(c,"utf-8");o.push(""),o.push(u)}catch{console.warn(`Module not found: ${i}`)}}return o.push(""),o.push("<!-- prjct:end - DO NOT REMOVE THIS MARKER -->"),o.push(""),o.join(`
262
262
  `)}async function Dy(){try{let r=J.join(Vi.homedir(),".prjct-cli","docs");await W.mkdir(r,{recursive:!0});let e=Vn("global/docs/");if(e.length>0){for(let s of e)if(s.endsWith(".md")){let o=ve(s);if(o){let i=J.basename(s);await W.writeFile(J.join(r,i),o,"utf-8")}}return{success:!0}}let t=J.join(ke,"templates/global/docs"),n=await W.readdir(t);for(let s of n)if(s.endsWith(".md")){let o=J.join(t,s),i=J.join(r,s),a=await W.readFile(o,"utf-8");await W.writeFile(i,a,"utf-8")}return{success:!0}}catch(r){return{success:!1,error:y(r)}}}async function Ry(){let r=(Ve(),at(et)),e=await r.getActiveProvider(),t=e.name;if(!(await r.detectProvider(t)).installed&&!e.configDir)return{success:!1,error:`${e.displayName} not detected`,action:"skipped"};try{await W.mkdir(e.configDir,{recursive:!0});let s=J.join(e.configDir,e.contextFile),o=J.join(ke,"templates","global",e.contextFile),i="";try{let u=ve(`global/${e.contextFile}`);u?i=u:i=await W.readFile(o,"utf-8")}catch{if(t==="claude")try{i=await Iy()}catch{let d=ve("global/CLAUDE.md");if(d)i=d;else{let m=J.join(ke,"templates/global/CLAUDE.md");i=await W.readFile(m,"utf-8")}}else{let d=ve("global/CLAUDE.md");if(d)i=d;else{let m=J.join(ke,"templates/global/CLAUDE.md");i=await W.readFile(m,"utf-8")}t==="gemini"&&(i=i.replace(/Claude/g,"Gemini"))}}let a="",c=!1;try{a=await W.readFile(s,"utf-8"),c=!0}catch(u){if(C(u))c=!1;else throw u}if(c){let u="<!-- prjct:start - DO NOT REMOVE THIS MARKER -->",d="<!-- prjct:end - DO NOT REMOVE THIS MARKER -->";if(a.includes(u)&&a.includes(d)){let p=a.substring(0,a.indexOf(u)),g=a.substring(a.indexOf(d)+d.length),f=i.substring(i.indexOf(u),i.indexOf(d)+d.length),S=p+f+g;return await W.writeFile(s,S,"utf-8"),{success:!0,action:"updated",path:s}}else{let p=`${a}
263
263
 
264
- ${i}`;return await W.writeFile(s,p,"utf-8"),{success:!0,action:"appended",path:s}}}else return await W.writeFile(s,i,"utf-8"),{success:!0,action:"created",path:s}}catch(s){return{success:!1,error:y(s),action:"failed"}}}function Iu(){let r=Vi.homedir();return{claude:{commands:J.join(r,".claude","commands","p"),config:J.join(r,".claude"),router:J.join(r,".claude","commands","p.md")},gemini:{commands:J.join(r,".gemini","commands"),config:J.join(r,".gemini"),router:J.join(r,".gemini","commands","p.toml")}}}var Bi,jy,Le,mn=w(()=>{"use strict";Jn();O();dn();l(Ay,"loadModuleConfig");l(Iy,"composeGlobalTemplate");l(Dy,"installDocs");l(Ry,"installGlobalConfig");Bi=class{static{l(this,"CommandInstaller")}homeDir;claudeCommandsPath="";claudeConfigPath="";templatesDir;_initialized=!1;constructor(){this.homeDir=Vi.homedir(),this.templatesDir=J.join(ke,"templates","commands")}async ensureInit(){if(this._initialized)return;let t=await(Ve(),at(et)).getActiveProvider();t.name==="gemini"?this.claudeCommandsPath=J.join(t.configDir,"commands"):this.claudeCommandsPath=J.join(t.configDir,"commands","p"),this.claudeConfigPath=t.configDir,this._initialized=!0}async detectActiveProvider(){await this.ensureInit();try{return await W.access(this.claudeConfigPath),!0}catch(e){if(C(e))return!1;throw e}}async detectClaude(){return this.detectActiveProvider()}async getCommandFiles(){let e=Vn("commands/");if(e.length>0)return e.filter(t=>t.endsWith(".md")).map(t=>t.replace("commands/",""));try{return(await W.readdir(this.templatesDir)).filter(n=>n.endsWith(".md"))}catch{return["init.md","now.md","done.md","ship.md","next.md","idea.md","recap.md","progress.md","stuck.md","context.md","analyze.md","sync.md","roadmap.md","task.md","git.md","fix.md","test.md","cleanup.md","design.md"]}}async installCommands(){let e=await this.detectActiveProvider(),n=await(Ve(),at(et)).getActiveProvider();if(!e)return{success:!1,error:`${n.displayName} not detected. Please install it first.`};try{await this.installRouter(),await W.mkdir(this.claudeCommandsPath,{recursive:!0});let s=await this.getCommandFiles(),o=[],i=[];for(let a of s)try{let c=J.join(this.claudeCommandsPath,a),u=ve(`commands/${a}`);if(u)await W.writeFile(c,u,"utf-8");else{let d=J.join(this.templatesDir,a),m=await W.readFile(d,"utf-8");await W.writeFile(c,m,"utf-8")}o.push(a.replace(".md",""))}catch(c){i.push({file:a,error:y(c)})}return{success:!0,installed:o,errors:i,path:this.claudeCommandsPath}}catch(s){return{success:!1,error:y(s)}}}async uninstallCommands(){try{let e=await this.getCommandFiles(),t=[],n=[];for(let s of e)try{let o=J.join(this.claudeCommandsPath,s);await W.unlink(o),t.push(s.replace(".md",""))}catch(o){o.code!=="ENOENT"&&n.push({file:s,error:y(o)})}try{await W.rmdir(this.claudeCommandsPath)}catch{}return{success:!0,uninstalled:t,errors:n}}catch(e){return{success:!1,error:y(e)}}}async checkInstallation(){if(!await this.detectClaude())return{installed:!1,claudeDetected:!1};try{await W.access(this.claudeCommandsPath);let n=(await W.readdir(this.claudeCommandsPath)).filter(s=>s.endsWith(".md")).map(s=>s.replace(".md",""));return{installed:n.length>0,claudeDetected:!0,commands:n,path:this.claudeCommandsPath}}catch(t){if(C(t))return{installed:!1,claudeDetected:!0,commands:[]};throw t}}async updateCommands(){console.log("Updating commands with latest templates...");let e=await this.installCommands();return e.success&&e.installed&&console.log(`Updated ${e.installed.length} commands`),e}async installToAll(){return await this.installCommands()}async getInstallPath(){return await this.ensureInit(),this.claudeCommandsPath}async verifyTemplate(e){if(ve(`commands/${e}.md`))return!0;try{let n=J.join(this.templatesDir,`${e}.md`);return await W.access(n),!0}catch(n){if(C(n))return!1;throw n}}async installRouter(){let t=await(Ve(),at(et)).getActiveProvider(),n=t.name==="gemini"?"p.toml":"p.md";try{let s=J.join(t.configDir,"commands",n);await W.mkdir(J.dirname(s),{recursive:!0});let o=ve(`commands/${n}`);if(o)return await W.writeFile(s,o,"utf-8"),!0;let i=J.join(this.templatesDir,n),a=await W.readFile(i,"utf-8");return await W.writeFile(s,a,"utf-8"),!0}catch(s){if(C(s))return!1;throw s}}async removeLegacyCommands(){let t=await(Ve(),at(et)).getActiveProvider(),n=J.join(t.configDir,"commands"),s=0;try{let i=(await W.readdir(n)).filter(a=>a.startsWith("p.")&&a.endsWith(".md"));for(let a of i)try{await W.unlink(J.join(n,a)),s++}catch{}}catch{}return s}async syncCommands(){if(!await this.detectActiveProvider())return{success:!1,error:"AI agent not detected",added:0,updated:0,removed:0};try{await this.installRouter(),await W.mkdir(this.claudeCommandsPath,{recursive:!0});let t=await this.getCommandFiles(),n=[];try{n=await W.readdir(this.claudeCommandsPath),n=n.filter(o=>o.endsWith(".md"))}catch(o){if(C(o))n=[];else throw o}let s={success:!0,added:0,updated:0,removed:0,errors:[]};for(let o of t)try{let i=J.join(this.claudeCommandsPath,o),a=n.includes(o),c=ve(`commands/${o}`);if(c)await W.writeFile(i,c,"utf-8");else{let u=J.join(this.templatesDir,o),d=await W.readFile(u,"utf-8");await W.writeFile(i,d,"utf-8")}a?s.updated++:s.added++}catch(i){s.errors.push({file:o,error:y(i)})}return await this.removeLegacyCommands(),s}catch(t){return{success:!1,error:y(t),added:0,updated:0,removed:0}}}async installGlobalConfig(){return Ry()}async installDocs(){return Dy()}};l(Iu,"getProviderPaths");jy=new Bi,Le=jy});import{z as we}from"zod";function $u(r,e="default"){let t=Du[e]||Du.default;return r/1e3*t}function Mr(r){return r<.01?`$${(r*100).toFixed(2)}\xA2`:`$${r.toFixed(2)}`}var $y,My,Ru,ju,Du,Or=w(()=>{"use strict";$y=we.object({date:we.string(),tokensSaved:we.number(),syncs:we.number(),avgCompressionRate:we.number(),totalDuration:we.number()}),My=we.object({agentName:we.string(),usageCount:we.number(),tokensSaved:we.number()}),Ru=we.object({totalTokensSaved:we.number(),avgCompressionRate:we.number(),syncCount:we.number(),watchTriggers:we.number(),avgSyncDuration:we.number(),totalSyncDuration:we.number(),agentUsage:we.array(My),dailyStats:we.array($y),firstSync:we.string(),lastUpdated:we.string()}),ju={totalTokensSaved:0,avgCompressionRate:0,syncCount:0,watchTriggers:0,avgSyncDuration:0,totalSyncDuration:0,agentUsage:[],dailyStats:[],firstSync:"",lastUpdated:""},Du={"claude-opus-4.5":.005,"claude-sonnet-4.5":.003,"claude-haiku-4.5":.001,"claude-opus-4":.015,"claude-sonnet-4":.003,"claude-3-opus":.015,"claude-3-sonnet":.003,"gpt-4o":.0025,"gpt-4":.01,"gemini-pro":.00125,default:.003};l($u,"estimateCostSaved");l(Mr,"formatCost")});function Oy(){return/<!-- prjct:preserve(?::([\w-]+))? -->/g}function Fy(r){let e=[],t=Oy(),n,s=0;for(;(n=t.exec(r))!==null;){let o=n.index,i=n[0],a=n[1]||`section-${s++}`,c=r.indexOf(Ji,o+i.length);if(c===-1)continue;let u=c+Ji.length,d=r.substring(o,u);e.push({id:a,content:d,startIndex:o,endIndex:u})}return e}function qi(r,e){let t=Fy(e);if(t.length===0)return r;let n=r.trimEnd();n+=`
264
+ ${i}`;return await W.writeFile(s,p,"utf-8"),{success:!0,action:"appended",path:s}}}else return await W.writeFile(s,i,"utf-8"),{success:!0,action:"created",path:s}}catch(s){return{success:!1,error:y(s),action:"failed"}}}function Iu(){let r=Vi.homedir();return{claude:{commands:J.join(r,".claude","commands","p"),config:J.join(r,".claude"),router:J.join(r,".claude","commands","p.md")},gemini:{commands:J.join(r,".gemini","commands"),config:J.join(r,".gemini"),router:J.join(r,".gemini","commands","p.toml")}}}var Bi,jy,Le,mn=w(()=>{"use strict";Jn();O();dn();l(Ay,"loadModuleConfig");l(Iy,"composeGlobalTemplate");l(Dy,"installDocs");l(Ry,"installGlobalConfig");Bi=class{static{l(this,"CommandInstaller")}homeDir;claudeCommandsPath="";claudeConfigPath="";templatesDir;_initialized=!1;constructor(){this.homeDir=Vi.homedir(),this.templatesDir=J.join(ke,"templates","commands")}async ensureInit(){if(this._initialized)return;let t=await(Ve(),at(et)).getActiveProvider();t.name==="gemini"?this.claudeCommandsPath=J.join(t.configDir,"commands"):this.claudeCommandsPath=J.join(t.configDir,"commands","p"),this.claudeConfigPath=t.configDir,this._initialized=!0}async detectActiveProvider(){await this.ensureInit();try{return await W.access(this.claudeConfigPath),!0}catch(e){if(C(e))return!1;throw e}}async detectClaude(){return this.detectActiveProvider()}async getCommandFiles(){let e=new Set(["p.md","p.toml"]),t=Vn("commands/");if(t.length>0)return t.filter(n=>n.endsWith(".md")).map(n=>n.replace("commands/","")).filter(n=>!e.has(n));try{return(await W.readdir(this.templatesDir)).filter(s=>s.endsWith(".md")&&!e.has(s))}catch{return["init.md","now.md","done.md","ship.md","next.md","idea.md","recap.md","progress.md","stuck.md","context.md","analyze.md","sync.md","roadmap.md","task.md","git.md","fix.md","test.md","cleanup.md","design.md"]}}async installCommands(){let e=await this.detectActiveProvider(),n=await(Ve(),at(et)).getActiveProvider();if(!e)return{success:!1,error:`${n.displayName} not detected. Please install it first.`};try{await this.installRouter(),await W.mkdir(this.claudeCommandsPath,{recursive:!0});let s=await this.getCommandFiles(),o=[],i=[];for(let a of s)try{let c=J.join(this.claudeCommandsPath,a),u=ve(`commands/${a}`);if(u)await W.writeFile(c,u,"utf-8");else{let d=J.join(this.templatesDir,a),m=await W.readFile(d,"utf-8");await W.writeFile(c,m,"utf-8")}o.push(a.replace(".md",""))}catch(c){i.push({file:a,error:y(c)})}return{success:!0,installed:o,errors:i,path:this.claudeCommandsPath}}catch(s){return{success:!1,error:y(s)}}}async uninstallCommands(){try{let e=await this.getCommandFiles(),t=[],n=[];for(let s of e)try{let o=J.join(this.claudeCommandsPath,s);await W.unlink(o),t.push(s.replace(".md",""))}catch(o){o.code!=="ENOENT"&&n.push({file:s,error:y(o)})}try{await W.rmdir(this.claudeCommandsPath)}catch{}return{success:!0,uninstalled:t,errors:n}}catch(e){return{success:!1,error:y(e)}}}async checkInstallation(){if(!await this.detectClaude())return{installed:!1,claudeDetected:!1};try{await W.access(this.claudeCommandsPath);let n=(await W.readdir(this.claudeCommandsPath)).filter(s=>s.endsWith(".md")).map(s=>s.replace(".md",""));return{installed:n.length>0,claudeDetected:!0,commands:n,path:this.claudeCommandsPath}}catch(t){if(C(t))return{installed:!1,claudeDetected:!0,commands:[]};throw t}}async updateCommands(){console.log("Updating commands with latest templates...");let e=await this.installCommands();return e.success&&e.installed&&console.log(`Updated ${e.installed.length} commands`),e}async installToAll(){return await this.installCommands()}async getInstallPath(){return await this.ensureInit(),this.claudeCommandsPath}async verifyTemplate(e){if(ve(`commands/${e}.md`))return!0;try{let n=J.join(this.templatesDir,`${e}.md`);return await W.access(n),!0}catch(n){if(C(n))return!1;throw n}}async installRouter(){let t=await(Ve(),at(et)).getActiveProvider(),n=t.name==="gemini"?"p.toml":"p.md";try{let s=J.join(t.configDir,"commands",n);await W.mkdir(J.dirname(s),{recursive:!0});let o=ve(`commands/${n}`);if(o)return await W.writeFile(s,o,"utf-8"),!0;let i=J.join(this.templatesDir,n),a=await W.readFile(i,"utf-8");return await W.writeFile(s,a,"utf-8"),!0}catch(s){if(C(s))return!1;throw s}}async removeLegacyCommands(){let t=await(Ve(),at(et)).getActiveProvider(),n=J.join(t.configDir,"commands"),s=0;try{let i=(await W.readdir(n)).filter(a=>a.startsWith("p.")&&a.endsWith(".md"));for(let a of i)try{await W.unlink(J.join(n,a)),s++}catch{}}catch{}return s}async syncCommands(){if(!await this.detectActiveProvider())return{success:!1,error:"AI agent not detected",added:0,updated:0,removed:0};try{await this.installRouter(),await W.mkdir(this.claudeCommandsPath,{recursive:!0});let t=await this.getCommandFiles(),n=[];try{n=await W.readdir(this.claudeCommandsPath),n=n.filter(o=>o.endsWith(".md"))}catch(o){if(C(o))n=[];else throw o}let s={success:!0,added:0,updated:0,removed:0,errors:[]};for(let o of t)try{let i=J.join(this.claudeCommandsPath,o),a=n.includes(o),c=ve(`commands/${o}`);if(c)await W.writeFile(i,c,"utf-8");else{let u=J.join(this.templatesDir,o),d=await W.readFile(u,"utf-8");await W.writeFile(i,d,"utf-8")}a?s.updated++:s.added++}catch(i){s.errors.push({file:o,error:y(i)})}return await this.removeLegacyCommands(),s}catch(t){return{success:!1,error:y(t),added:0,updated:0,removed:0}}}async installGlobalConfig(){return Ry()}async installDocs(){return Dy()}};l(Iu,"getProviderPaths");jy=new Bi,Le=jy});import{z as we}from"zod";function $u(r,e="default"){let t=Du[e]||Du.default;return r/1e3*t}function Mr(r){return r<.01?`$${(r*100).toFixed(2)}\xA2`:`$${r.toFixed(2)}`}var $y,My,Ru,ju,Du,Or=w(()=>{"use strict";$y=we.object({date:we.string(),tokensSaved:we.number(),syncs:we.number(),avgCompressionRate:we.number(),totalDuration:we.number()}),My=we.object({agentName:we.string(),usageCount:we.number(),tokensSaved:we.number()}),Ru=we.object({totalTokensSaved:we.number(),avgCompressionRate:we.number(),syncCount:we.number(),watchTriggers:we.number(),avgSyncDuration:we.number(),totalSyncDuration:we.number(),agentUsage:we.array(My),dailyStats:we.array($y),firstSync:we.string(),lastUpdated:we.string()}),ju={totalTokensSaved:0,avgCompressionRate:0,syncCount:0,watchTriggers:0,avgSyncDuration:0,totalSyncDuration:0,agentUsage:[],dailyStats:[],firstSync:"",lastUpdated:""},Du={"claude-opus-4.5":.005,"claude-sonnet-4.5":.003,"claude-haiku-4.5":.001,"claude-opus-4":.015,"claude-sonnet-4":.003,"claude-3-opus":.015,"claude-3-sonnet":.003,"gpt-4o":.0025,"gpt-4":.01,"gemini-pro":.00125,default:.003};l($u,"estimateCostSaved");l(Mr,"formatCost")});function Oy(){return/<!-- prjct:preserve(?::([\w-]+))? -->/g}function Fy(r){let e=[],t=Oy(),n,s=0;for(;(n=t.exec(r))!==null;){let o=n.index,i=n[0],a=n[1]||`section-${s++}`,c=r.indexOf(Ji,o+i.length);if(c===-1)continue;let u=c+Ji.length,d=r.substring(o,u);e.push({id:a,content:d,startIndex:o,endIndex:u})}return e}function qi(r,e){let t=Fy(e);if(t.length===0)return r;let n=r.trimEnd();n+=`
265
265
 
266
266
  ---
267
267
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prjct-cli",
3
- "version": "1.27.0",
3
+ "version": "1.27.1",
4
4
  "description": "Context layer for AI agents. Project context for Claude Code, Gemini CLI, and more.",
5
5
  "main": "dist/bin/prjct.mjs",
6
6
  "bin": {