@hiperplano/aluy-cli 1.0.0-rc.1 → 1.0.0-rc.2

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.
@@ -1,4 +1,4 @@
1
- var XP=Object.defineProperty;var S=(t,e,o)=>()=>{if(o)throw o[0];try{return t&&(e=t(t=0)),e}catch(n){throw o=[n],n}};var Ff=(t,e)=>{for(var o in e)XP(t,o,{get:e[o],enumerable:!0})};var sa,ax=S(()=>{"use strict";sa="1.0.0-rc.1"});function Mn(t,e){return t.decide(e)}var Ur=S(()=>{"use strict"});var en,Ln,Pn=S(()=>{"use strict";en="remember",Ln="recall"});var Bf,JP,Hs,Uf=S(()=>{"use strict";Bf=class{id;horizon;label;parentId;children;dependencies;pinned;closed;createdAt;lastAccessedAt;accessCount;context;constructor(e,o,n,r,s){this.id=e,this.horizon=o,this.label=n,this.parentId=r,this.children=new Set,this.dependencies=new Set,this.pinned=!1,this.closed=!1,this.createdAt=s,this.lastAccessedAt=s,this.accessCount=0,this.context=[]}touch(e){this.lastAccessedAt=e,this.accessCount+=1}snapshot(){return{id:this.id,horizon:this.horizon,label:this.label,parentId:this.parentId,children:[...this.children],dependencies:[...this.dependencies],pinned:this.pinned,closed:this.closed,createdAt:this.createdAt,lastAccessedAt:this.lastAccessedAt,accessCount:this.accessCount,contextSize:this.context.length}}},JP=200,Hs=class{nodes=new Map;maxBoxes;now;constructor(e){this.maxBoxes=e?.maxBoxes??JP,this.now=e?.clock??Date.now}static boxId(e,o){return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,60)}-${o.toString(36)}`}openBox(e,o,n,r){let s=this.nodes.get(e);if(s)return s.touch(this.now()),{box:s.snapshot(),created:!1};if(this.nodes.size>=this.maxBoxes&&(this.evictOne(),this.nodes.size>=this.maxBoxes))return null;let i=this.now(),a=new Bf(e,o,n,r??null,i);if(r){let l=this.nodes.get(r);l&&l.children.add(e)}return this.nodes.set(e,a),{box:a.snapshot(),created:!0}}closeBox(e){let o=this.nodes.get(e);return o?(o.closed=!0,o.touch(this.now()),o.snapshot()):null}isClosed(e){let o=this.nodes.get(e);return o?o.closed:!1}reopenBox(e){let o=this.nodes.get(e);return o?(o.closed=!1,o.touch(this.now()),o.snapshot()):null}setHorizon(e,o){let n=this.nodes.get(e);return n?(n.horizon=o,n.touch(this.now()),n.snapshot()):null}setParent(e,o){let n=this.nodes.get(e);return n?n.parentId===o?n.snapshot():o!==null&&this.wouldCreateCycle(e,o)?null:(n.parentId&&this.nodes.get(n.parentId)?.children.delete(e),n.parentId=o,o&&this.nodes.get(o)?.children.add(e),n.touch(this.now()),n.snapshot()):null}wouldCreateCycle(e,o){let n=new Set,r=o;for(;r!==null;){if(r===e||n.has(r))return!0;n.add(r),r=this.nodes.get(r)?.parentId??null}return!1}getBox(e){let o=this.nodes.get(e);return o?(o.touch(this.now()),o.snapshot()):null}listBoxes(e="lastAccessedAt"){let o=[...this.nodes.values()].map(n=>n.snapshot());switch(e){case"createdAt":return o.sort((n,r)=>n.createdAt-r.createdAt);case"accessCount":return o.sort((n,r)=>r.accessCount-n.accessCount);default:return o.sort((n,r)=>r.lastAccessedAt-n.lastAccessedAt)}}get size(){return this.nodes.size}addContext(e,o){let n=this.nodes.get(e);return n?(n.context.push({ts:this.now(),text:o}),n.touch(this.now()),n.snapshot()):null}getContext(e){let o=this.nodes.get(e);return o?(o.touch(this.now()),[...o.context]):[]}getContextChain(e){let o=[],n=new Set,r=e;for(;r&&!n.has(r);){n.add(r);let s=this.nodes.get(r);if(!s)break;s.touch(this.now()),o.push({boxId:s.id,entries:[...s.context]}),r=s.parentId}return o}addDependency(e,o){let n=this.nodes.get(e);return!n||!this.nodes.has(o)||n.id===o?!1:(n.dependencies.add(o),n.touch(this.now()),!0)}getDependencies(e){let o=this.nodes.get(e);return o?[...o.dependencies]:[]}pinBox(e){let o=this.nodes.get(e);return o?(o.pinned=!0,o.touch(this.now()),o.snapshot()):null}unpinBox(e){let o=this.nodes.get(e);return o?(o.pinned=!1,o.touch(this.now()),o.snapshot()):null}evictOne(){let e=[];for(let n of this.nodes.values())n.horizon==="longo"||n.pinned||e.push(n);if(e.length===0)return null;e.sort((n,r)=>{let s=n.horizon==="curto"?0:1,i=r.horizon==="curto"?0:1;if(s!==i)return s-i;let a=n.closed?0:1,l=r.closed?0:1;return a!==l?a-l:n.lastAccessedAt!==r.lastAccessedAt?n.lastAccessedAt-r.lastAccessedAt:n.accessCount-r.accessCount});let o=e[0];return this.removeNode(o)}forceEvict(e){let o=this.nodes.get(e);return!o||o.horizon==="longo"||o.pinned?null:this.removeNode(o)}removeBox(e){let o=this.nodes.get(e);return o?this.removeNode(o):null}removeNode(e){if(e.parentId){let o=this.nodes.get(e.parentId);o&&o.children.delete(e.id)}return this.nodes.delete(e.id),e.snapshot()}}});function nd(t){let e=[];for(let o of t){e.push({step:o,depth:0});for(let n of o.substeps??[])e.push({step:n,depth:1})}return e}function dx(t,e){let o,n="pending",r;if(typeof t=="string")o=t;else if(t!==null&&typeof t=="object"){let i=t,a=i.title??i.step??i.text??i.name??i.content;if(typeof a=="string"&&(o=a),typeof i.status=="string"&&QP.has(i.status)&&(n=i.status),e){let l=i.substeps??i.subtasks??i.subpassos??i.children;if(Array.isArray(l)&&l.length>0){let c=[];for(let d of l){let f=dx(d,!1);if(typeof f=="string")return f;c.push(f)}r=c}}}if(o===void 0||o.trim()==="")return eN;let s=o.trim().slice(0,ZP);return r?{title:s,status:n,substeps:r}:{title:s,status:n}}function tN(t){let e=t.steps??t.plan??t.todos??t.items;if(!Array.isArray(e))return{error:'update_plan: passe "steps" como uma LISTA de passos (string ou {title,status}).'};if(e.length===0)return{error:"update_plan: a lista de passos est\xE1 vazia."};let o=[];for(let i of e){let a=dx(i,!0);if(typeof a=="string")return{error:a};o.push(a)}let n=new Set,r=i=>{if(!n.has(i))return n.add(i),i;for(let a=2;;a++){let l=`${i} #${a}`;if(!n.has(l))return n.add(l),l}};for(let i=0;i<o.length;i++){let a=o[i],l=r(a.title),c=a.substeps?.map(d=>({...d,title:r(d.title)}));o[i]=c!==void 0?{...a,title:l,substeps:c}:{...a,title:l}}let s=nd(o).length;return s>lx?{error:`update_plan: no m\xE1ximo ${lx} passos (recebidos ${s}).`}:{steps:o}}function oN(t){let e=nd(t),o=e.filter(r=>r.step.status==="completed").length,n=e.map(r=>`${" ".repeat(r.depth)}${ux[r.step.status]} ${r.step.title}`).join(`
1
+ var XP=Object.defineProperty;var S=(t,e,o)=>()=>{if(o)throw o[0];try{return t&&(e=t(t=0)),e}catch(n){throw o=[n],n}};var Ff=(t,e)=>{for(var o in e)XP(t,o,{get:e[o],enumerable:!0})};var sa,ax=S(()=>{"use strict";sa="1.0.0-rc.2"});function Mn(t,e){return t.decide(e)}var Ur=S(()=>{"use strict"});var en,Ln,Pn=S(()=>{"use strict";en="remember",Ln="recall"});var Bf,JP,Hs,Uf=S(()=>{"use strict";Bf=class{id;horizon;label;parentId;children;dependencies;pinned;closed;createdAt;lastAccessedAt;accessCount;context;constructor(e,o,n,r,s){this.id=e,this.horizon=o,this.label=n,this.parentId=r,this.children=new Set,this.dependencies=new Set,this.pinned=!1,this.closed=!1,this.createdAt=s,this.lastAccessedAt=s,this.accessCount=0,this.context=[]}touch(e){this.lastAccessedAt=e,this.accessCount+=1}snapshot(){return{id:this.id,horizon:this.horizon,label:this.label,parentId:this.parentId,children:[...this.children],dependencies:[...this.dependencies],pinned:this.pinned,closed:this.closed,createdAt:this.createdAt,lastAccessedAt:this.lastAccessedAt,accessCount:this.accessCount,contextSize:this.context.length}}},JP=200,Hs=class{nodes=new Map;maxBoxes;now;constructor(e){this.maxBoxes=e?.maxBoxes??JP,this.now=e?.clock??Date.now}static boxId(e,o){return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,60)}-${o.toString(36)}`}openBox(e,o,n,r){let s=this.nodes.get(e);if(s)return s.touch(this.now()),{box:s.snapshot(),created:!1};if(this.nodes.size>=this.maxBoxes&&(this.evictOne(),this.nodes.size>=this.maxBoxes))return null;let i=this.now(),a=new Bf(e,o,n,r??null,i);if(r){let l=this.nodes.get(r);l&&l.children.add(e)}return this.nodes.set(e,a),{box:a.snapshot(),created:!0}}closeBox(e){let o=this.nodes.get(e);return o?(o.closed=!0,o.touch(this.now()),o.snapshot()):null}isClosed(e){let o=this.nodes.get(e);return o?o.closed:!1}reopenBox(e){let o=this.nodes.get(e);return o?(o.closed=!1,o.touch(this.now()),o.snapshot()):null}setHorizon(e,o){let n=this.nodes.get(e);return n?(n.horizon=o,n.touch(this.now()),n.snapshot()):null}setParent(e,o){let n=this.nodes.get(e);return n?n.parentId===o?n.snapshot():o!==null&&this.wouldCreateCycle(e,o)?null:(n.parentId&&this.nodes.get(n.parentId)?.children.delete(e),n.parentId=o,o&&this.nodes.get(o)?.children.add(e),n.touch(this.now()),n.snapshot()):null}wouldCreateCycle(e,o){let n=new Set,r=o;for(;r!==null;){if(r===e||n.has(r))return!0;n.add(r),r=this.nodes.get(r)?.parentId??null}return!1}getBox(e){let o=this.nodes.get(e);return o?(o.touch(this.now()),o.snapshot()):null}listBoxes(e="lastAccessedAt"){let o=[...this.nodes.values()].map(n=>n.snapshot());switch(e){case"createdAt":return o.sort((n,r)=>n.createdAt-r.createdAt);case"accessCount":return o.sort((n,r)=>r.accessCount-n.accessCount);default:return o.sort((n,r)=>r.lastAccessedAt-n.lastAccessedAt)}}get size(){return this.nodes.size}addContext(e,o){let n=this.nodes.get(e);return n?(n.context.push({ts:this.now(),text:o}),n.touch(this.now()),n.snapshot()):null}getContext(e){let o=this.nodes.get(e);return o?(o.touch(this.now()),[...o.context]):[]}getContextChain(e){let o=[],n=new Set,r=e;for(;r&&!n.has(r);){n.add(r);let s=this.nodes.get(r);if(!s)break;s.touch(this.now()),o.push({boxId:s.id,entries:[...s.context]}),r=s.parentId}return o}addDependency(e,o){let n=this.nodes.get(e);return!n||!this.nodes.has(o)||n.id===o?!1:(n.dependencies.add(o),n.touch(this.now()),!0)}getDependencies(e){let o=this.nodes.get(e);return o?[...o.dependencies]:[]}pinBox(e){let o=this.nodes.get(e);return o?(o.pinned=!0,o.touch(this.now()),o.snapshot()):null}unpinBox(e){let o=this.nodes.get(e);return o?(o.pinned=!1,o.touch(this.now()),o.snapshot()):null}evictOne(){let e=[];for(let n of this.nodes.values())n.horizon==="longo"||n.pinned||e.push(n);if(e.length===0)return null;e.sort((n,r)=>{let s=n.horizon==="curto"?0:1,i=r.horizon==="curto"?0:1;if(s!==i)return s-i;let a=n.closed?0:1,l=r.closed?0:1;return a!==l?a-l:n.lastAccessedAt!==r.lastAccessedAt?n.lastAccessedAt-r.lastAccessedAt:n.accessCount-r.accessCount});let o=e[0];return this.removeNode(o)}forceEvict(e){let o=this.nodes.get(e);return!o||o.horizon==="longo"||o.pinned?null:this.removeNode(o)}removeBox(e){let o=this.nodes.get(e);return o?this.removeNode(o):null}removeNode(e){if(e.parentId){let o=this.nodes.get(e.parentId);o&&o.children.delete(e.id)}return this.nodes.delete(e.id),e.snapshot()}}});function nd(t){let e=[];for(let o of t){e.push({step:o,depth:0});for(let n of o.substeps??[])e.push({step:n,depth:1})}return e}function dx(t,e){let o,n="pending",r;if(typeof t=="string")o=t;else if(t!==null&&typeof t=="object"){let i=t,a=i.title??i.step??i.text??i.name??i.content;if(typeof a=="string"&&(o=a),typeof i.status=="string"&&QP.has(i.status)&&(n=i.status),e){let l=i.substeps??i.subtasks??i.subpassos??i.children;if(Array.isArray(l)&&l.length>0){let c=[];for(let d of l){let f=dx(d,!1);if(typeof f=="string")return f;c.push(f)}r=c}}}if(o===void 0||o.trim()==="")return eN;let s=o.trim().slice(0,ZP);return r?{title:s,status:n,substeps:r}:{title:s,status:n}}function tN(t){let e=t.steps??t.plan??t.todos??t.items;if(!Array.isArray(e))return{error:'update_plan: passe "steps" como uma LISTA de passos (string ou {title,status}).'};if(e.length===0)return{error:"update_plan: a lista de passos est\xE1 vazia."};let o=[];for(let i of e){let a=dx(i,!0);if(typeof a=="string")return{error:a};o.push(a)}let n=new Set,r=i=>{if(!n.has(i))return n.add(i),i;for(let a=2;;a++){let l=`${i} #${a}`;if(!n.has(l))return n.add(l),l}};for(let i=0;i<o.length;i++){let a=o[i],l=r(a.title),c=a.substeps?.map(d=>({...d,title:r(d.title)}));o[i]=c!==void 0?{...a,title:l,substeps:c}:{...a,title:l}}let s=nd(o).length;return s>lx?{error:`update_plan: no m\xE1ximo ${lx} passos (recebidos ${s}).`}:{steps:o}}function oN(t){let e=nd(t),o=e.filter(r=>r.step.status==="completed").length,n=e.map(r=>`${" ".repeat(r.depth)}${ux[r.step.status]} ${r.step.title}`).join(`
2
2
  `);return`plano (${o}/${e.length}):
3
3
  ${n}`}function rN(t,e){return e<0?"m\xE9dio":t===e?"curto":t>e?"longo":"m\xE9dio"}function sN(t,e){let o=new Map;for(let i of e.listBoxes())o.set(i.label,i.id);let n=t.findIndex(i=>i.status==="in_progress"||(i.substeps??[]).some(a=>a.status==="in_progress")),r=(i,a,l)=>{let c=i.status==="in_progress"?"curto":l,d=o.get(i.title),f=d??Hs.boxId(i.title,0);return d?(i.status!=="completed"&&e.isClosed(d)&&e.reopenBox(d),e.setHorizon(d,c),e.setParent(d,a)):e.openBox(f,c,i.title,a),i.status==="completed"&&!e.isClosed(f)&&e.closeBox(f),o.set(i.title,f),f};t.forEach((i,a)=>{let l=rN(a,n),c=r(i,null,l);for(let d of i.substeps??[])r(d,c,l)});let s=new Set;for(let i of t){s.add(i.title);for(let a of i.substeps??[])s.add(a.title)}for(let i of e.listBoxes())s.has(i.label)||e.removeBox(i.id)}function iN(t,e){if(!e)return oN(t);let o=new Map;for(let c of e.listBoxes())o.set(c.label,c);let n=new Map;for(let c of e.listBoxes())n.set(c.id,c);let r=new Map,s=(c,d=new Set)=>{let f=r.get(c);if(f!==void 0)return f;let u=n.get(c);if(!u||!u.parentId||d.has(c))return r.set(c,0),0;let p=s(u.parentId,new Set(d).add(c))+1;return r.set(c,p),p},i=nd(t),l=[`plano (${i.filter(c=>c.step.status==="completed").length}/${i.length}):`];for(let{step:c,depth:d}of i){let f=o.get(c.title),u=f?nN[f.horizon]:"",p=f?s(f.id):d,h=" ".repeat(p),y=ux[c.status];l.push(`${h}${u} ${y} ${c.title}`)}return l.join(`
4
4
  `)}var ia,QP,lx,ZP,eN,ux,nN,cx,aN,mx,rd=S(()=>{"use strict";Uf();ia="update_plan";QP=new Set(["pending","in_progress","completed"]),lx=30,ZP=120,eN="update_plan: cada passo precisa de um t\xEDtulo (texto) n\xE3o-vazio.";ux={pending:"\u2610",in_progress:"\u25B6",completed:"\u2611"};nN={longo:"[\u{1F4D0}]",m\u00E9dio:"[\u{1F4CB}]",curto:"[\u{1F4CC}]"};cx=Object.freeze({type:"string",enum:["pending","in_progress","completed"],description:"pending (a fazer) \xB7 in_progress (em curso) \xB7 completed (feito)."}),aN=Object.freeze({type:"object",properties:{steps:{type:"array",description:"A lista COMPLETA de passos do plano (re-emita TODOS a cada atualiza\xE7\xE3o \u2014 substitui o anterior).",items:{type:"object",properties:{title:{type:"string",description:"O passo, curto e no imperativo."},status:cx,substeps:{type:"array",description:"OPCIONAL: sub-passos que detalham este passo (1 n\xEDvel). Aparecem indentados sob o passo e seguem o foco dele. Use quando um passo tem a\xE7\xF5es menores distintas.",items:{type:"object",properties:{title:{type:"string",description:"O sub-passo, curto e no imperativo."},status:cx},required:["title"],additionalProperties:!1}}},required:["title"],additionalProperties:!1}}},required:["steps"],additionalProperties:!1}),mx={name:ia,effect:"read",description:"Declara/atualiza um PLANO vis\xEDvel (checklist de passos). Use ao iniciar uma tarefa com V\xC1RIOS passos e a cada progresso: re-emita a lista TODA marcando o status de cada passo (pending/in_progress/completed). Mantenha 1 passo in_progress por vez. N\xE3o tem efeito no sistema \u2014 \xE9 s\xF3 o seu plano, para voc\xEA e para o usu\xE1rio acompanharem.",parameters:aN,async run(t,e){let o=tN(t);return"error"in o?{ok:!1,observation:o.error}:(e.graph&&sN(o.steps,e.graph),e.plan&&e.plan.set(nd(o.steps).map(r=>({title:r.step.title,status:r.step.status}))),{ok:!0,observation:iN(o.steps,e.graph)})}}});function fx(t){let e=t.question??t.prompt??t.text??t.message;if(typeof e!="string"||e.trim()==="")return{error:'perguntar: passe "question" (a pergunta em texto). Para escolha, passe tamb\xE9m "options".'};let o=e.trim().slice(0,2e3),n=t.header??t.title,r=typeof n=="string"&&n.trim()!==""?n.trim().slice(0,200):void 0,s=t.options??t.choices,i=Array.isArray(s)?cN(s):void 0;if(typeof i=="string")return{error:i};let a,l=t.kind??t.type;if(typeof l=="string"&&lN.has(l))a=l;else{if(typeof l=="string"&&l.trim()!=="")return{error:`perguntar: "kind" inv\xE1lido "${l}". Use "single", "multi" ou "text".`};a=i!==void 0&&i.length>0?"single":"text"}if((a==="single"||a==="multi")&&(i===void 0||i.length===0))return{error:`perguntar: kind "${a}" requer "options" (uma lista de ao menos 1 op\xE7\xE3o).`};let c=t.allowOther!==!1;return{spec:{kind:a,question:o,...r!==void 0?{header:r}:{},...a!=="text"&&i!==void 0?{options:i}:{},...a!=="text"?{allowOther:c}:{}}}}function cN(t){if(t.length===0)return'perguntar: a lista de "options" est\xE1 vazia.';if(t.length>12)return`perguntar: no m\xE1ximo 12 op\xE7\xF5es (recebidas ${t.length}).`;let e=[];for(let o of t){let n,r;if(typeof o=="string")n=o;else if(o!==null&&typeof o=="object"){let s=o,i=s.label??s.text??s.value??s.name??s.title;typeof i=="string"&&(n=i),typeof s.description=="string"&&s.description.trim()!==""&&(r=s.description.trim().slice(0,300))}if(n===void 0||n.trim()==="")return'perguntar: cada op\xE7\xE3o precisa de um "label" (texto) n\xE3o-vazio.';e.push({label:n.trim().slice(0,200),...r!==void 0?{description:r}:{}})}return e}function dN(t){switch(t.kind){case"choice":return t.label;case"choices":return t.labels.length===0?"(nenhuma)":t.labels.join(", ");case"text":{let e=t.text.split(`
@@ -135,7 +135,7 @@ ${t.trim()}`}}function dT(t,e,o=ml){let{older:n,recent:r}=Eu(t,o);if(n.length===
135
135
  \u2026[truncado: ${t.length-Ty} chars omitidos]`}function JF(t){return t.length<=Ry?t:`${t.slice(0,Ry)}\u2026`}function XT(t){let e=VT(t.server,t.descriptor.name),o=JF(t.descriptor.description.trim()),n=`[tool de um SERVER MCP de terceiro "${t.server}" \u2014 efeito n\xE3o-confi\xE1vel, passa pela catraca] ${o||"(sem descri\xE7\xE3o)"}`,r=t.descriptor.inputSchema,s=r!==null&&typeof r=="object"&&!Array.isArray(r)?r:void 0;return{name:e,effect:"mcp",description:n,...s?{parameters:s}:{},async run(i,a,l){try{let c=await t.transport.callTool(t.descriptor.name,i,l?.signal),d=Ue(c.content);return c.ok?{ok:!0,observation:YT(d),display:`${e}(${QF(i)})`}:{ok:!1,observation:YT(`MCP "${e}" erro: ${d}`)}}catch(c){return{ok:!1,observation:`MCP "${e}" falhou: ${c instanceof Error?c.message:String(c)}`}}}}}function Cy(t,e){let o=[],n=new Set,r=new Map,s=new Map,i=new Set;for(let a of t){let l=XT(a);if(n.has(l.name))continue;n.add(l.name);let c=a.server;s.set(c,(s.get(c)??0)+1);let d=r.get(c)??0;if(d>=_y){i.add(c);continue}r.set(c,d+1),o.push(l)}if(e)for(let a of i){let l=s.get(a)??0;e(`server MCP "${a}" exp\xF4s ${l} tools; usando as primeiras ${_y} (teto por server, anti-estouro de contexto). As demais foram ignoradas \u2014 revise o server ou reduza as tools que ele exp\xF5e.`)}return o}function QF(t){if(Object.keys(t).length===0)return"";let o=JSON.stringify(t);return o.length<=200?o:`${o.slice(0,200)}\u2026`}var Ty,_y,Ry,JT=S(()=>{"use strict";ad();Bn();Ty=2e4;_y=128,Ry=1024});function e_(t,e){let o=new URL(ZT);return t.trim().length>0&&o.searchParams.set("search",t.trim()),o.searchParams.set("limit",String(eB)),e!==void 0&&e.length>0&&o.searchParams.set("cursor",e),o.toString()}async function My(t,e,o){let n=t.trim(),r=[],s;for(let i=0;i<ZF;i++){let a=e_(n,s),l;try{l=await e(a,o)}catch(f){return{ok:!1,query:n,reason:Pu(iB(f))}}if(!l.ok)return{ok:!1,query:n,reason:Pu(l.reason)};if(l.status<200||l.status>=300)return{ok:!1,query:n,reason:Pu(`HTTP ${l.status}`)};let c;try{c=JSON.parse(l.body)}catch{return{ok:!1,query:n,reason:Pu("resposta n\xE3o \xE9 JSON v\xE1lido")}}let d=o_(c);for(let f of d.servers)if(t_(f,n)&&r.push(f),r.length>=Oy)break;if(r.length>=Oy||(s=d.nextCursor,s===void 0||s.length===0))break}return{ok:!0,query:n,results:r}}function Pu(t){return`registro MCP indispon\xEDvel (${gi}): ${t}`}function t_(t,e){if(e.length===0)return!0;let o=e.toLowerCase();return[t.name,t.title??"",t.description,t.run.command??"",t.run.args.join(" ")].join(" ").toLowerCase().includes(o)}function o_(t){if(!qn(t))return{servers:[]};let e=Array.isArray(t.servers)?t.servers:[],o=[];for(let s of e){let i=tB(s);i!==void 0&&o.push(i)}let n=qn(t.metadata)?t.metadata:void 0,r=n!==void 0&&typeof n.nextCursor=="string"?n.nextCursor:void 0;return{servers:o,...r!==void 0?{nextCursor:r}:{}}}function tB(t){if(!qn(t))return;let e=qn(t.server)?t.server:t,o=typeof e.name=="string"?e.name.trim():"";if(o.length===0)return;let n=typeof e.description=="string"?e.description.trim():"",r=typeof e.title=="string"&&e.title.trim().length>0?e.title.trim():void 0,s=typeof e.version=="string"?e.version.trim():void 0,i=oB(e);return{name:o,description:n,run:i,...r!==void 0?{title:r}:{},...s!==void 0?{version:s}:{}}}function oB(t){let e=[],o=Array.isArray(t.remotes)?t.remotes:[];for(let r of o)qn(r)&&typeof r.url=="string"&&e.push(r.url);let n=Array.isArray(t.packages)?t.packages:[];for(let r of n){if(!qn(r))continue;let s=nB(r);if(s!==void 0)return{...s,remoteUrls:e}}return{args:[],env:[],remoteUrls:e}}function nB(t){let e=is(t.registryType)??is(t.registry_name),o=is(t.identifier)??is(t.name);if(o===void 0)return;let n=is(t.version),r=is(t.runtimeHint),s=qn(t.transport)?is(t.transport.type):void 0,i=sB(t.environmentVariables),a=QT(t.runtimeArguments),l=QT(t.packageArguments),c=n!==void 0?`${o}@${n}`:o;return e==="npm"||r==="npx"?{command:"npx",args:rB(["-y",...a,c,...l]),env:i,...s!==void 0?{transport:s}:{}}:e==="pypi"||r==="uvx"||r==="uv"?{command:"uvx",args:[...a,o,...l],env:i,...s!==void 0?{transport:s}:{}}:e==="oci"||r==="docker"?{command:"docker",args:["run","-i","--rm",...a,c,...l],env:i,...s!==void 0?{transport:s}:{}}:{args:[c],env:i,...s!==void 0?{transport:s}:{}}}function rB(t){let e=[],o=!1;for(let n of t){if(n==="-y"||n==="--yes"){if(o)continue;o=!0}e.push(n)}return e}function QT(t){if(!Array.isArray(t))return[];let e=[];for(let o of t)qn(o)&&typeof o.value=="string"&&e.push(o.value);return e}function sB(t){if(!Array.isArray(t))return[];let e=[];for(let o of t)qn(o)&&typeof o.name=="string"&&o.name.length>0&&e.push({name:o.name,required:o.isRequired===!0});return e}function is(t){return typeof t=="string"&&t.trim().length>0?t.trim():void 0}function qn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function iB(t){return t instanceof Error?t.message:String(t)}var gi,ZT,ZF,eB,Oy,n_=S(()=>{"use strict";gi="registry.modelcontextprotocol.io",ZT=`https://${gi}/v0/servers`,ZF=5,eB=100,Oy=25});function s_(t){let{command:e,args:o}=t.run;if(e===void 0)return;let n=i_(t.name);return["aluy","mcp","add",r_(n),"--",e,...o.map(r_)].join(" ")}function i_(t){let o=(t.split("/").pop()??t).replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");return o.length>0?o:"server"}function r_(t){return/^[A-Za-z0-9_./@:+=-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}function Ly(t){if(!t.ok)return`\u26A0 ${t.reason}
136
136
  Tente de novo em instantes; a busca no registro n\xE3o bloqueia o resto do aluy.`;if(t.results.length===0)return`nenhum server encontrado para "${t.query}" no registro oficial MCP.`;let e=[],o=t.results.length;e.push(`${o} server${o===1?"":"s"} para "${t.query}" (registro oficial MCP):`),e.push("");for(let n of t.results)e.push(aB(n)),e.push("");return e.push('Para instalar, copie a linha "\u2192 aluy mcp add \u2026" do server desejado.'),e.push("A sa\xEDda do registro \xE9 apenas informativa \u2014 nada \xE9 executado pela busca."),e.join(`
137
137
  `)}function aB(t){let o=[`\u2022 ${t.version!==void 0?`${t.name} (v${t.version})`:t.name}`],n=t.title!==void 0&&t.title!==t.name?t.title:void 0;n!==void 0&&o.push(` ${n}`),t.description.length>0&&o.push(` ${lB(t.description,200)}`);let r=s_(t);if(r!==void 0){o.push(` \u2192 ${r}`),t.run.transport!==void 0&&t.run.transport!=="stdio"&&o.push(` (transporte "${t.run.transport}" \u2014 v1 do aluy s\xF3 pluga servers stdio LOCAIS)`);let s=t.run.env.filter(i=>i.required).map(i=>i.name);s.length>0&&o.push(` requer env: ${s.join(", ")} (defina por-server no mcp.json)`)}else t.run.remoteUrls.length>0?o.push(` (server REMOTO: ${t.run.remoteUrls.join(", ")} \u2014 fora do v1 de \`aluy mcp add\`)`):o.push(" (sem pacote local conhecido \u2014 nada a instalar pelo aluy)");return o.join(`
138
- `)}function lB(t,e){return t.length<=e?t:t.slice(0,e-1).trimEnd()+"\u2026"}var a_=S(()=>{"use strict"});var l_=S(()=>{"use strict";Lu();HT();qT();WT();GT();KT();JT();ad();n_();a_()});var j=S(()=>{"use strict";ax();Lx();Gx();dw();MT();BT();l_();fy();uu()});import{posix as CU}from"node:path";function OU(t){return CU.normalize(t)}function Xt(t){let e=OU(t);for(let o of MU)if(o.re.test(e))return o.deny?{kind:"deny",why:o.why}:{kind:"ask",why:o.why};return{kind:"allow"}}function Jy(t){return Xt(t).kind==="allow"}var MU,vr=S(()=>{"use strict";MU=[{re:/(?:^|\/|~\/)\.ssh(?:\/|$)/,why:"chaves SSH (~/.ssh)",deny:!0},{re:/(?:^|\/|~\/)\.aws(?:\/|$)/,why:"credenciais AWS (~/.aws)",deny:!0},{re:/(?:^|\/|~\/)\.gnupg(?:\/|$)/,why:"chaves GPG (~/.gnupg)",deny:!0},{re:/(?:~\/|\$\{?HOME\}?\/|\/(?:home|Users)\/[^/]+\/)\.aluy\/rooms(?:\/|$)/,why:"arquivos de sala do Aluy (~/.aluy/rooms)",deny:!0},{re:/~\/\.aluy(?:\/|$)/,why:"estado/credencial do Aluy (~/.aluy)",deny:!0},{re:/(?:^|\/)\.aluy(?:\/(?!agents\/|workflows\/|commands\/)|$)/,why:"estado/credencial do Aluy (.aluy/)",deny:!0},{re:/(?:^|\/|~\/)\.config\/gh\/hosts\.yml$/,why:"token do gh CLI",deny:!0},{re:/(?:^|\/|~\/)\.docker\/config\.json$/,why:"credenciais Docker",deny:!0},{re:/(?:^|\/|~\/)\.kube\/config$/,why:"kubeconfig",deny:!0},{re:/(?:^|\/)id_(?:rsa|ed25519|ecdsa|dsa)\b/,why:"chave privada",deny:!0},{re:/\.pem$|\.p12$|\.pfx$|\.key$/i,why:"material de chave privada",deny:!0},{re:/(?:^|[/\w.-])\.env(?:\.(?!example$|sample$|template$|dist$)[\w.-]+)?$/,why:"arquivo .env (segredos)",deny:!1},{re:/(?:^|\/)[^/]*(?:secret|credential|token|apikey|api_key|password|passwd)[^/]*$/i,why:"arquivo com nome sens\xEDvel (token/secret)",deny:!1}]});var vb={};Ff(vb,{UserWorkflowsLoader:()=>Ei,WORKFLOWS_DIRNAME:()=>bb});import{homedir as lH}from"node:os";import{join as yb}from"node:path";import{readdirSync as cH,readFileSync as dH,mkdirSync as uH,statSync as mH}from"node:fs";var fH,bb,pH,hH,Ei,em=S(()=>{"use strict";j();fH=448,bb="workflows",pH=64*1024,hH=256,Ei=class{dir;constructor(e={}){let o=e.baseDir??yb(lH(),".aluy");this.dir=yb(o,bb)}get workflowsDir(){return this.dir}ensureDir(){try{uH(this.dir,{mode:fH,recursive:!0})}catch{}}load(){let e;try{e=cH(this.dir,{withFileTypes:!0})}catch{return{workflows:[],errors:[]}}let o=e.filter(i=>i.isFile()&&i.name.toLowerCase().endsWith(".md")).map(i=>i.name).sort((i,a)=>i.localeCompare(a)),n=new Set,r=[],s=[];for(let i of o){if(r.length>=hH)break;let a=this.readOne(i);if(a!==null){if(tl(a)){s.push(a);continue}n.has(a.name)||(n.add(a.name),r.push(a))}}return{workflows:r,errors:s}}readOne(e){let o=yb(this.dir,e);try{let n=mH(o);if(!n.isFile()||n.size>pH)return null;let r=dH(o,"utf8");return ol(e,r,"global")}catch{return null}}}});var xb={};Ff(xb,{PROJECT_WORKFLOWS_DIRNAMES:()=>kb,ProjectWorkflowsLoader:()=>Ti});import{join as gH}from"node:path";import{readdirSync as yH,readFileSync as bH,statSync as vH}from"node:fs";var kb,kH,xH,Ti,tm=S(()=>{"use strict";j();vr();kb=[".claude/workflows",".aluy/workflows"],kH=64*1024,xH=256,Ti=class{workspace;constructor(e){this.workspace=e.workspace}load(){let e=new Set,o=[],n=[];for(let r of kb){let s;try{s=this.workspace.resolveInside(r)}catch{continue}let i;try{i=yH(s,{withFileTypes:!0})}catch{continue}let a=i.filter(l=>l.isFile()&&l.name.toLowerCase().endsWith(".md")).map(l=>l.name).sort((l,c)=>l.localeCompare(c));for(let l of a){if(o.length>=xH)break;let c=this.readOne(r,s,l);if(c!==null){if(tl(c)){n.push(c);continue}e.has(c.name)||(e.add(c.name),o.push(c))}}}return{workflows:o,errors:n}}readOne(e,o,n){let r=`${e}/${n}`;if(Xt(r).kind!=="allow")return null;let s=gH(o,n);try{this.workspace.resolveInside(r);let i=vH(s);if(!i.isFile()||i.size>kH)return null;let a=bH(s,"utf8");return ol(n,a,"project")}catch{return null}}}});var Br="1.0.0-rc.1";j();var c_=`aluy \u2014 agente de terminal que roda na sua m\xE1quina, com o seu provider de LLM
138
+ `)}function lB(t,e){return t.length<=e?t:t.slice(0,e-1).trimEnd()+"\u2026"}var a_=S(()=>{"use strict"});var l_=S(()=>{"use strict";Lu();HT();qT();WT();GT();KT();JT();ad();n_();a_()});var j=S(()=>{"use strict";ax();Lx();Gx();dw();MT();BT();l_();fy();uu()});import{posix as CU}from"node:path";function OU(t){return CU.normalize(t)}function Xt(t){let e=OU(t);for(let o of MU)if(o.re.test(e))return o.deny?{kind:"deny",why:o.why}:{kind:"ask",why:o.why};return{kind:"allow"}}function Jy(t){return Xt(t).kind==="allow"}var MU,vr=S(()=>{"use strict";MU=[{re:/(?:^|\/|~\/)\.ssh(?:\/|$)/,why:"chaves SSH (~/.ssh)",deny:!0},{re:/(?:^|\/|~\/)\.aws(?:\/|$)/,why:"credenciais AWS (~/.aws)",deny:!0},{re:/(?:^|\/|~\/)\.gnupg(?:\/|$)/,why:"chaves GPG (~/.gnupg)",deny:!0},{re:/(?:~\/|\$\{?HOME\}?\/|\/(?:home|Users)\/[^/]+\/)\.aluy\/rooms(?:\/|$)/,why:"arquivos de sala do Aluy (~/.aluy/rooms)",deny:!0},{re:/~\/\.aluy(?:\/|$)/,why:"estado/credencial do Aluy (~/.aluy)",deny:!0},{re:/(?:^|\/)\.aluy(?:\/(?!agents\/|workflows\/|commands\/)|$)/,why:"estado/credencial do Aluy (.aluy/)",deny:!0},{re:/(?:^|\/|~\/)\.config\/gh\/hosts\.yml$/,why:"token do gh CLI",deny:!0},{re:/(?:^|\/|~\/)\.docker\/config\.json$/,why:"credenciais Docker",deny:!0},{re:/(?:^|\/|~\/)\.kube\/config$/,why:"kubeconfig",deny:!0},{re:/(?:^|\/)id_(?:rsa|ed25519|ecdsa|dsa)\b/,why:"chave privada",deny:!0},{re:/\.pem$|\.p12$|\.pfx$|\.key$/i,why:"material de chave privada",deny:!0},{re:/(?:^|[/\w.-])\.env(?:\.(?!example$|sample$|template$|dist$)[\w.-]+)?$/,why:"arquivo .env (segredos)",deny:!1},{re:/(?:^|\/)[^/]*(?:secret|credential|token|apikey|api_key|password|passwd)[^/]*$/i,why:"arquivo com nome sens\xEDvel (token/secret)",deny:!1}]});var vb={};Ff(vb,{UserWorkflowsLoader:()=>Ei,WORKFLOWS_DIRNAME:()=>bb});import{homedir as lH}from"node:os";import{join as yb}from"node:path";import{readdirSync as cH,readFileSync as dH,mkdirSync as uH,statSync as mH}from"node:fs";var fH,bb,pH,hH,Ei,em=S(()=>{"use strict";j();fH=448,bb="workflows",pH=64*1024,hH=256,Ei=class{dir;constructor(e={}){let o=e.baseDir??yb(lH(),".aluy");this.dir=yb(o,bb)}get workflowsDir(){return this.dir}ensureDir(){try{uH(this.dir,{mode:fH,recursive:!0})}catch{}}load(){let e;try{e=cH(this.dir,{withFileTypes:!0})}catch{return{workflows:[],errors:[]}}let o=e.filter(i=>i.isFile()&&i.name.toLowerCase().endsWith(".md")).map(i=>i.name).sort((i,a)=>i.localeCompare(a)),n=new Set,r=[],s=[];for(let i of o){if(r.length>=hH)break;let a=this.readOne(i);if(a!==null){if(tl(a)){s.push(a);continue}n.has(a.name)||(n.add(a.name),r.push(a))}}return{workflows:r,errors:s}}readOne(e){let o=yb(this.dir,e);try{let n=mH(o);if(!n.isFile()||n.size>pH)return null;let r=dH(o,"utf8");return ol(e,r,"global")}catch{return null}}}});var xb={};Ff(xb,{PROJECT_WORKFLOWS_DIRNAMES:()=>kb,ProjectWorkflowsLoader:()=>Ti});import{join as gH}from"node:path";import{readdirSync as yH,readFileSync as bH,statSync as vH}from"node:fs";var kb,kH,xH,Ti,tm=S(()=>{"use strict";j();vr();kb=[".claude/workflows",".aluy/workflows"],kH=64*1024,xH=256,Ti=class{workspace;constructor(e){this.workspace=e.workspace}load(){let e=new Set,o=[],n=[];for(let r of kb){let s;try{s=this.workspace.resolveInside(r)}catch{continue}let i;try{i=yH(s,{withFileTypes:!0})}catch{continue}let a=i.filter(l=>l.isFile()&&l.name.toLowerCase().endsWith(".md")).map(l=>l.name).sort((l,c)=>l.localeCompare(c));for(let l of a){if(o.length>=xH)break;let c=this.readOne(r,s,l);if(c!==null){if(tl(c)){n.push(c);continue}e.has(c.name)||(e.add(c.name),o.push(c))}}}return{workflows:o,errors:n}}readOne(e,o,n){let r=`${e}/${n}`;if(Xt(r).kind!=="allow")return null;let s=gH(o,n);try{this.workspace.resolveInside(r);let i=vH(s);if(!i.isFile()||i.size>kH)return null;let a=bH(s,"utf8");return ol(n,a,"project")}catch{return null}}}});var Br="1.0.0-rc.2";j();var c_=`aluy \u2014 agente de terminal que roda na sua m\xE1quina, com o seu provider de LLM
139
139
 
140
140
  Uso:
141
141
  aluy ["objetivo"] [--plan | --yolo] [--dense] [--tier <tier>] [--lang <pt-BR|en>]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiperplano/aluy-cli",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0-rc.2",
4
4
  "description": "Aluy CLI — TUI (Ink) + binário `aluy` + wiring. Consome @hiperplano/aluy-cli-core (engine portável). Credenciais só no keychain do SO.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",