UNPKG

eve

Version:

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

1 lines 1.32 kB
import{hasInteractiveTerminal}from"./preconditions.js";import{createPrompter}from"#setup/prompter.js";import{parseProjectName,validateProjectName}from"#setup/project-name.js";const defaultDependencies={createPrompter,hasInteractiveTerminal};function formatEntries(e){return`${e.slice(0,5).join(`, `)}${e.length>5?`, and ${e.length-5} more`:``}`}async function confirmInitInNonEmptyDirectory(e,t=defaultDependencies){let n=formatEntries(e);if(!t.hasInteractiveTerminal())throw Error(`Cannot choose where to initialize the non-empty current directory without an interactive terminal. Found: ${n}. Pass a new directory name, for example: eve init my-agent.`);let r=t.createPrompter();if(await r.select({message:`Where should eve initialize the project?`,description:`The current directory isn't empty. Found: ${n}.`,options:[{value:`subdirectory`,label:`Create a new subdirectory`,hint:`Keep the current directory unchanged`},{value:`current-directory`,label:`Use the current directory`,hint:`Overwrite files at generated paths`,accent:`warning`}],initialValue:`subdirectory`})===`current-directory`)return{kind:`current-directory`};let i=await r.text({message:`Subdirectory name`,defaultValue:`my-agent`,validate:validateProjectName});return{kind:`subdirectory`,name:parseProjectName(i)}}export{confirmInitInNonEmptyDirectory};