UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

1 lines 2.19 kB
import{isPromptControlCommand}from"./prompt-commands.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{clipVisible,visibleLength}from"#cli/ui/terminal-text.js";const AGENT_HEADER_TIPS=[`Use the /add command to install an integration.`,`Use the /deploy command to deploy your agent.`,`Use the /help command to see every command.`];function pickAgentHeaderTip(e=Math.random){let t=Math.min(AGENT_HEADER_TIPS.length-1,Math.floor(e()*AGENT_HEADER_TIPS.length));return AGENT_HEADER_TIPS[t]}function buildAgentHeader(e){let{theme:t,info:n,width:r}=e,i=t.colors,a=resolveInstalledPackageInfo().version,o=Math.min(68,Math.max(0,r-1)),s=`${i.dim(`☰`)}${i.bold(`eve`)} ${i.dim(`(v${a})`)}`;if(o<4)return[clipVisible(s,r)];let c=t.unicode?`─`:`-`,l=t.unicode?`│`:`|`,u=t.unicode?`╭`:`+`,d=t.unicode?`╮`:`+`,f=t.unicode?`╰`:`+`,p=t.unicode?`╯`:`+`,m=o-2,h=c.repeat(m),row=(e=``,t=0)=>{let n=Math.max(0,m-2),r=clipVisible(e,n),a=Math.max(0,n-visibleLength(r)-t);return`${i.dim(l)} ${r}${` `.repeat(a)} ${i.dim(l)}`},g=n?.agent.name??e.name,_=g===void 0?s:spreadRow(s,i.bold(g),m-2,1),v=[i.dim(`${u}${h}${d}`)];if(v.push(row(_,1)),v.push(row()),e.tip!==void 0&&v.push(row(`${i.bold(`Tip:`)} ${renderTip(e.tip,m-7,t)}`)),v.push(i.dim(`${f}${h}${p}`)),n&&(n.diagnostics.discoveryErrors>0||n.diagnostics.discoveryWarnings>0)){let e=[];n.diagnostics.discoveryErrors>0&&e.push(i.red(`${n.diagnostics.discoveryErrors} error${plural(n.diagnostics.discoveryErrors)}`)),n.diagnostics.discoveryWarnings>0&&e.push(i.yellow(`${n.diagnostics.discoveryWarnings} warning${plural(n.diagnostics.discoveryWarnings)}`)),v.push(``,` ${i.dim(t.glyph.warning)} ${e.join(i.dim(` · `))}`)}return v}function spreadRow(e,t,n,r){let i=Math.max(1,n-r),a=clipVisible(e,Math.max(1,i-visibleLength(t)-1)),o=clipVisible(t,Math.max(1,i-visibleLength(a)-1)),s=Math.max(1,i-visibleLength(a)-visibleLength(o));return`${a}${` `.repeat(s)}${o}`}function renderTip(e,t,n){return clipVisible(e.split(/(\/[a-z:-]+)/u).map(e=>isPromptControlCommand(e)?n.colors.blue(e):n.colors.dim(e)).join(``),t)}function plural(e){return e===1?``:`s`}export{AGENT_HEADER_TIPS,buildAgentHeader,pickAgentHeaderTip};