@hlix/cli 0.4.3 → 0.4.5

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.
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ import{a as y,d as _,e as m,f as X,g as A,h as x,i as P,j as ke,k}from"./index-benazc7g.js";import{l as ve,m as Se,n as Ce,o as Ie,p as He}from"./index-rraz48fm.js";import{r as Ct}from"./index-y1n35st0.js";import{relative as It,resolve as Ht}from"node:path";import{parseArgs as Pt}from"node:util";import{createMastraCode as jt}from"mastracode";import{loadMcpConfig as _t}from"@mastra/code-sdk/mcp/config";import{executeSubagent as At}from"@mastra/code-sdk/agents/subagents/execute";import{exploreSubagent as Mt}from"@mastra/code-sdk/agents/subagents/explore";import{planSubagent as Rt}from"@mastra/code-sdk/agents/subagents/plan";import{hasHeadlessFlag as Tt,parseHeadlessArgs as Ot,runMC as $t}from"mastracode/headless";import{MastraTUI as Et}from"mastracode/tui";var Me=[["You are already on the latest version","Update Hlix Code with npm or brew"],["A new version of Mastra Code is available","Hlix Code updates via npm or brew"],["-g mastracode@","-g @hlix/cli@"],["Error: Auth storage not configured","Use hlix models or --sandbox local"],["To use Mastra Code you need at least one API key or OAuth login","Run `hlix auth login`, or add a provider key for your own"],["See https://mastra.ai/models for supported providers and API key env vars.","Your hlix workspace supplies the models; a provider key is optional."],["https://mastra.ai/docs/memory/observational-memory","Observational memory summarizes long threads."],["Manage Mastra Code plugins","Manage Hlix Code plugins"],["Mastra Code","Hlix Code"],["MastraCode","Hlix Code"],["mastracode","hlix"]];function b(e){let t=e;for(let[s,r]of Me)t=t.split(s).join(r);return t}function K(e){let s=e.state?.terminal;if(!s||typeof s.write!=="function")throw Error("Hlix Code cannot rebrand this MastraCode TUI: no `state.terminal.write` to wrap.");let r=s.write.bind(s);s.write=(o)=>r(b(o))}import{mkdirSync as Ne,writeFileSync as Fe}from"node:fs";import{join as G}from"node:path";import{createTool as Re}from"@mastra/core/tools";import{z as u}from"zod";var I=(e)=>`hlix_${e.split(" ").join("_")}`,Te=u.object({args:u.array(u.string()).optional().describe("Positional arguments that follow the command name."),flags:u.record(u.string(),u.union([u.string(),u.boolean()])).optional().describe('Options without the leading dashes, e.g. { "yes": true, "name": "api" }.')}),Oe=u.object({exitCode:u.number(),stdout:u.string(),stderr:u.string()});function $e(e,t,s){let r=e.name.split(" ").concat(t.args??[]);for(let[o,a]of Object.entries(t.flags??{})){if(a===!1)continue;if(r.push(`--${o}`),typeof a==="string")r.push(a)}if(!t.flags?.cwd)r.push("--cwd",s);if(e.supportsJson&&!t.flags?.json)r.push("--json");return r}async function Ee(e,t,s,r=process.env){let o="",a="";return{exitCode:await X([e],$e(e,t,s),{stdout:(c)=>{o+=c},stderr:(c)=>{a+=c},env:r}),stdout:o,stderr:a}}function z(e){let t={};for(let s of e.commands??k){let r=I(s.name);t[r]=Re({id:r,description:`${s.summary}
3
+
4
+ ${s.usage}`,inputSchema:Te,outputSchema:Oe,execute:async(o)=>Ee(s,o,e.cwd,e.env)})}return t}var We=(e)=>`${e.split(" ").join("-")}.md`;function Le(e){return["---",`description: ${e.summary}`,"---","",`Call the tool \`${I(e.name)}\` with the user's arguments: $ARGUMENTS.`,"Show the result.",""].join(`
5
+ `)}var De={"follow.md":["---","description: Watch a cloud task being coded, live","---","","Call the tool `hlix_tasks_follow` with `taskId` set to $ARGUMENTS. It streams the","coder's text and tool calls into this session. Summarise what it did.",""].join(`
6
+ `),"harness.md":["---","description: Show or change the harness — which coder does the work","---","","Call the tool `hlix_harness` with `harness` set to $ARGUMENTS when the user","named one, and with no argument when they did not. Show `message` verbatim.",""].join(`
7
+ `)};function J(e,t=k){let s=G(e,".hlix","commands");Ne(s,{recursive:!0});let r=[],o=[...t.map((a)=>[We(a.name),Le(a)]),...Object.entries(De)];for(let[a,i]of o){let c=G(s,a);try{Fe(c,i,{flag:"wx"}),r.push(c)}catch(n){if(n.code!=="EEXIST")throw n}}return r}import{execFileSync as Ue}from"node:child_process";import{createACPTool as Be}from"@mastra/acp";import{createTool as qe}from"@mastra/core/tools";import{z as h}from"zod";var w={"claude-code":{harness:"claude-code",label:"Claude Code",command:"claude-agent-acp",args:[],authEnvVars:["ANTHROPIC_API_KEY"],install:"npm i -g @agentclientprotocol/claude-agent-acp"},codex:{harness:"codex",label:"Codex",command:"codex-acp",args:[],authEnvVars:["OPENAI_API_KEY"],env:{NO_BROWSER:"1"},install:"npm i -g @agentclientprotocol/codex-acp"},"cursor-agent":{harness:"cursor-agent",label:"Cursor Agent",command:"cursor-agent",args:["acp"],authEnvVars:["CURSOR_API_KEY"],install:"curl https://cursor.com/install -fsS | bash"}};function Z(e){if(e.flag)return{harness:Ye(e.flag,"--harness"),source:"flag"};if(e.configured)return{harness:e.configured,source:e.configSource??"project"};return{harness:P,source:"default"}}function Ye(e,t){if(x.includes(e))return e;throw Error(`${t} must be one of ${x.join(", ")}; got "${e}".`)}var H="hlix_tasks_follow",Ke=(e)=>`hlix_coder_${e.split("-").join("_")}`;function ee(e,t){let s=t.source==="default"?"":` (${t.source==="flag"?"--harness":t.source})`;return`${e} · harness: ${t.harness}${s}`}function te(e,t=3000){try{return Ue("which",[e],{timeout:t,stdio:"ignore"}),!0}catch{return!1}}var j=(e)=>`harness ${e.harness} needs \`${e.command}\` on PATH. Install it with: ${e.install}`;function Xe(e){let t=e.options??[],s=t.find((r)=>r.kind==="allow_once")??t.find((r)=>r.kind==="reject_once");if(!s)return{outcome:{outcome:"cancelled"}};return{outcome:{outcome:"selected",optionId:s.optionId}}}var V=["view","search_content","find_files","file_stat","lsp_inspect"],Q=["ask_user","task_write","task_update","task_complete","task_check"],ze=(e)=>[`harness ${e} runs in the project's Coding Workspace, not on this machine.`,"This session can follow and stream that work, but cannot start it:","which coder the platform uses comes from the project's harness preference,","and this CLI has no command that creates a task."].join(" "),se=(e)=>[e==="unknown"?"This project's harness could not be read from the server. Do NOT guess which coder it runs — say so, and offer to check with the `hlix_harness` tool.":`This project's harness is ${e}: the platform runs ${e} for the coding work it executes, in the project's Coding Workspace.`,"Change it with the `hlix_harness` tool, which writes the project's setting.","","To do coding work here, dispatch it and then watch it:","1. `hlix_cycles_create` with the project id, a title and a description. That"," is what STARTS work — it enters the project's loop, which plans the cycle,"," creates its tasks and starts the coder. It returns no cycle id.","2. `hlix_tasks_list` with that project to find the tasks planning produced.",`3. \`${H}\` with a task id, which streams that coder's own text and`," tool calls into this session live. Report what it did.","","`hlix_tasks_create` only adds a board row; it does not start anything, and","there is no way to start a single task. Never claim otherwise."].join(`
8
+ `),Ge=(e,t)=>[`The user chose the ${e.label} harness. Do not edit files or run commands`,`yourself. Hand the whole task to \`${t}\` as one natural-language brief,`,`then report what it did. ${e.label} reads and writes the same working`,"directory you are in.","",`It authenticates from ${e.authEnvVars.join(" or ")} in this shell's`,"environment. If it reports a credential problem, say so — do not retry."].join(`
9
+ `);function re(e){if(e.sandbox==="cloud"||e.active==="hlix")return[];let t=new Set(e.unavailable??[]),s=e.model?{defaultModelId:e.model}:{},r=[{id:"hlix",name:"Hlix",description:"The hlix agent codes here, with the full toolset.",...s}];for(let o of Object.values(w)){let a=e.active===o.harness,i=Ke(o.harness);r.push({id:o.harness,name:o.label,description:`${o.label} runs on this machine over ACP and edits ${e.cwd}.`,instructions:Ge(o,i),availableTools:t.has(o.harness)?[...V,...Q,H]:[i,...V,...Q,H],...t.has(o.harness)?{}:{additionalTools:{[i]:Be({id:i,description:`Run a coding task with ${o.label}. Give it one natural-language brief; it reads and writes the working directory and returns its final output.`,command:o.command,args:o.args,cwd:e.cwd,...o.env?{env:o.env}:{},...e.workspace?{workspace:e.workspace}:{},onPermissionRequest:async(c)=>Xe(c)})}},...s,...a?{metadata:{default:!0}}:{}})}return r}function Je(e){let t=[...e.available],s=(o,a="none")=>({harness:e.current,available:t,action:a,message:o});if(!e.requested)return s(`harness: ${e.current}. Available here: ${t.join(", ")}.`);if(!x.includes(e.requested))return s(`/harness must name one of ${x.join(", ")}; got "${e.requested}".`);let r=e.requested;if(e.sandbox==="cloud"){let o=`${e.sandboxLine} · harness: ${r} (project preference)`;return{harness:r,available:t,action:"preference",message:r==="hlix"?o:`${o}. ${ze(r)}`}}if(!t.includes(r))return s(j(w[r]));if(!e.modesBuilt)return s(`This session runs the hlix coder, so there is no ${r} mode to switch to. Restart with \`hlix --harness ${r}\`, or make it the default with \`hlix config set harness ${r}\`.`,"restart");return{harness:r,available:t,action:"mode",message:`${e.sandboxLine} · harness: ${r}`}}function oe(e){return qe({id:"hlix_harness",description:"Show or change the harness — which coder does the work. In a local or docker sandbox it switches this session's coder; in a cloud sandbox it writes the project's harness preference, which is what the platform runs. With no argument it reports the current harness.",inputSchema:h.object({harness:h.string().optional().describe(`One of ${x.join(", ")}. Omit to report the current one.`)}),outputSchema:h.object({harness:h.string(),available:h.array(h.string()),message:h.string()}),execute:async(t)=>{let s=e.session(),r=Je({...t.harness?{requested:t.harness}:{},current:s?.mode.get()??P,available:e.available,sandbox:e.sandbox,sandboxLine:e.sandboxLine,modesBuilt:e.modesBuilt}),o={harness:r.harness,available:r.available,message:r.message};if(r.action==="mode"&&s)return await s.mode.switch({modeId:r.harness}),o;if(r.action==="preference"){if(!e.setProjectHarness)return{...o,message:"This folder is not bound to a hlix project, so there is no project preference to write. Run `hlix init` or pass --project <id>."};await e.setProjectHarness(r.harness)}return o}})}import{createTool as Ve}from"@mastra/core/tools";import{writeToolProgress as Qe}from"mastracode/plugin";import{z as p}from"zod";function Ze(e){switch(e.type){case"on_chat_model_stream":return e.delta?{event:"text",text:e.delta}:null;case"reasoning":return e.delta?{event:"text",text:e.delta}:null;case"on_tool_start":return{event:"tool_start",toolName:e.name,args:e.input};case"on_tool_end":return{event:"tool_end",toolName:e.name,result:e.output,isError:et(e.output)};case"error":return{event:"finish",isError:!0,result:e.message};case"done":return{event:"finish",isError:!1};default:return null}}function et(e){return typeof e==="object"&&e!==null&&e.status==="failed"}async function tt(e,t){let s=[],r=[],o="streamed",a="The coder's turn ended.";for await(let i of e){if(i.type==="idle"){o="idle",a="Nothing is being coded right now. The task is not in build or test.";break}if(i.type==="error")o="error",a=i.message;if(i.type==="on_chat_model_stream")s.push(i.delta);if(i.type==="on_tool_start")r.push(i.name);let c=Ze(i);if(c)await t(c)}return{status:o,text:s.join(""),tools:r,message:a}}function ne(e){return Ve({id:"hlix_tasks_follow",description:"Watch a hlix task being coded in the cloud, live. Streams the coder's text and tool calls into this session as they happen, and returns what it did. Use it after a task starts building.",inputSchema:p.object({taskId:p.string().describe("The task to follow.")}),outputSchema:p.object({status:p.enum(["streamed","idle","error","unassigned"]),text:p.string(),tools:p.array(p.string()),message:p.string()}),execute:async(t,s)=>{let r=m(e.env??process.env,{cwd:e.cwd,flags:{}}),o=await r.tasks.get(t.taskId);if(!o.agentId)return{status:"unassigned",text:"",tools:[],message:"No agent has picked this task up yet, so there is no coder to watch. Check `hlix_tasks_get` again once it is building."};return tt(r.projects.observeAgent(o.projectId,o.agentId),(a)=>Qe(s,a))}})}import{buildMode as st}from"@mastra/code-sdk/agents/modes/build";import{fastMode as rt}from"@mastra/code-sdk/agents/modes/explore";import{planMode as ot}from"@mastra/code-sdk/agents/modes/plan";import{setCustomProvidersSource as nt}from"@mastra/code-sdk/agents/model";import{getCustomProviderId as v,loadSettings as at}from"@mastra/code-sdk/onboarding/settings";var S="hlix",ae="default",it=(e)=>`${S}/${e}`;function ct(e){return{name:S,url:`${e.baseUrl.replace(/\/+$/,"")}/v1/api/ai/w/${e.workspaceId}`,apiKey:e.apiKey,models:[...new Set([ae,...e.models??[]])]}}var lt=3000;async function ie(e){let t=_({env:e.env,flags:{},cwd:e.cwd});if(t.conflict||!t.credential||!t.workspaceId)return{};try{return{ids:(await m(e.env,{cwd:e.cwd,flags:{}}).ai.models(t.workspaceId,{signal:AbortSignal.timeout(e.timeoutMs??lt)})).models.map((r)=>r.id)}}catch(s){return{warning:`could not read your workspace's models (${s instanceof Error?s.message:String(s)}). Offering the workspace default only.`}}}function dt(e){let t=e.provider??"",s=v(S);return t===s||t.endsWith(`/${s}`)}function ce(e){let t=e.listAvailableModels.bind(e);return e.listAvailableModels=async()=>(await t()).filter(dt),e}function ut(e){let t=[st,ot,rt];return e?t.map((s)=>({...s,defaultModelId:e})):t}function le(e){let t=_({env:e.env,flags:{},cwd:e.cwd});if(t.conflict||!t.credential||!t.workspaceId)return null;let s=ct({baseUrl:t.baseUrl,workspaceId:t.workspaceId,apiKey:t.credential.apiKey,...e.models?{models:e.models}:{}}),r=v(s.name);return nt(()=>[...at().customProviders.filter((o)=>v(o.name)!==r),s]),{provider:s,modelId:it(ae)}}var de=(e,t)=>e.length>0?[...e]:ut(t),mt=(e)=>new RegExp(`^(?:[^/]+/)?${v(S)}/.+`).test(e);function ue(e){if(e.configured){let t=e.configuredSource??"config";if(!e.cloud||!e.wired||mt(e.configured))return{id:e.configured,source:t};return{id:e.wired.modelId,source:"workspace",notice:`model ${e.configured} from ${t} is not available on the cloud sandbox; using hlix default`}}return e.wired?{id:e.wired.modelId,source:"workspace"}:null}var me=(e,t)=>t?`${e} · model: ${t.id} (${t.source})`:e;import{execFileSync as yt}from"node:child_process";import{DockerSandbox as bt}from"@mastra/docker";import{LocalFilesystem as kt,Workspace as vt}from"@mastra/core/workspace";import{posix as pe}from"node:path";import{MastraFilesystem as pt,MastraSandbox as ht,Workspace as gt}from"@mastra/core/workspace";var ft=600000,xt=["recursive","overwrite","force","maxDepth","extension"];function g(e){let t=e??{},s={};for(let r of xt)if(t[r]!==void 0)s[r]=t[r];return Object.keys(s).length>0?{options:s}:{}}var he=(e)=>e instanceof Date?e:new Date(typeof e==="string"||typeof e==="number"?e:0);class ge extends pt{id;name="RemoteFilesystem";provider="hlix-coding-workspace";basePath;status="ready";client;constructor(e,t){super({name:"RemoteFilesystem"});this.client=e,this.basePath=t.root,this.id=t.id??`hlix-remote-fs:${t.root}`}getInfo(){return{id:this.id,name:this.name,provider:this.provider,status:this.status,metadata:{root:this.basePath}}}resolveAbsolutePath(e){return pe.isAbsolute(e)?e:pe.join(this.basePath,e)}async call(e){let{result:t}=await this.client.fs({...e,encoding:e.encoding??"utf8",path:this.resolveAbsolutePath(e.path)});return t}async readFile(e,t){let r=await this.call({op:"read",path:e,encoding:"base64"}),o=Buffer.from(r.content,r.encoding);return t?.encoding?o.toString(t.encoding):o}async writeFile(e,t,s){await this.call({op:"write",path:e,content:Buffer.from(t).toString("base64"),encoding:"base64",...g(s)})}async appendFile(e,t){await this.call({op:"append",path:e,content:Buffer.from(t).toString("base64"),encoding:"base64"})}async deleteFile(e,t){await this.call({op:"delete",path:e,...g(t)})}async copyFile(e,t,s){await this.call({op:"copy",path:e,dest:this.resolveAbsolutePath(t),...g(s)})}async moveFile(e,t,s){await this.call({op:"move",path:e,dest:this.resolveAbsolutePath(t),...g(s)})}async mkdir(e,t){await this.call({op:"mkdir",path:e,...g(t)})}async rmdir(e,t){await this.call({op:"rmdir",path:e,...g(t)})}async readdir(e,t){return await this.call({op:"readdir",path:e,...g(t)})??[]}async exists(e){return await this.call({op:"exists",path:e})===!0}async stat(e){let t=await this.call({op:"stat",path:e});return{...t,createdAt:he(t.createdAt),modifiedAt:he(t.modifiedAt)}}}var wt=(e)=>`'${e.split("'").join("'\\''")}'`;class fe extends ht{id;name="RemoteSandbox";provider="hlix-coding-workspace";status="ready";client;constructor(e,t){super({name:"RemoteSandbox"});if(this.client=e,this.id=`hlix-remote-sandbox:${t.projectId}`,t.root)this.setWorkingDirectory(t.root)}async start(){}getInfo(){return{id:this.id,name:this.name,provider:this.provider,status:this.status,createdAt:new Date(0)}}async executeCommand(e,t=[],s){let r=[e,...t.map(wt)].join(" "),o=Date.now(),a=s?.cwd??this.workingDirectory,i=await this.client.exec({command:r,...a?{cwd:a}:{},timeoutMs:s?.timeout??ft});return{success:i.exitCode===0,exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr,executionTimeMs:Date.now()-o,command:e,args:t}}}function xe(e,t){let s=t.root??"/workspace";return new gt({id:`hlix-project:${t.projectId}`,name:"Hlix Coding Workspace",filesystem:new ge(e,{root:s}),sandbox:new fe(e,{projectId:t.projectId,root:s})})}function St(e,t){if(A.includes(e))return e;throw new y("invalid_usage",`${t==="flag"?"--sandbox":"sandbox in .hlix/config.json"} must be one of ${A.join(", ")}; got "${e}".`)}function we(e){if(e.flag){let t=e.flagSource??"flag";return{choice:St(e.flag,t),reason:t==="flag"?`--sandbox ${e.flag}`:"config"}}if(e.projectId)return{choice:"cloud",reason:`project ${e.projectId}`};if(e.dockerAvailable())return{choice:"docker",reason:"auto"};return{choice:"local",reason:"auto"}}var ye=(e)=>`sandbox: ${e.choice} (${e.reason})`;function be(e=3000){try{return yt("docker",["info"],{timeout:e,stdio:"ignore"}),!0}catch{return!1}}function M(e,t){if(e.choice==="local")return;if(e.choice==="cloud"){if(!t.remote||!t.projectId)throw new y("invalid_usage","The cloud sandbox needs a hlix project. Run `hlix init`, pass --project <id>, or choose --sandbox docker|local.");return xe(t.remote,{projectId:t.projectId})}let s="/workspace";return new vt({id:"hlix-code-docker",name:"Hlix Code (Docker)",filesystem:new kt({basePath:t.cwd}),...t.skills&&t.skills.length>0?{skills:t.skills}:{},sandbox:new bt({id:"hlix-code",volumes:{[t.cwd]:s},workingDirectory:s})})}var Nt=["Your name is Hlix Code. You are hlix's coding agent.","An earlier line of these instructions calls you Mastra Code — that is the","name of a framework hlix builds on, not your name. Never introduce yourself","as Mastra Code and never offer it as what the user is running. Naming the","underlying framework is fine when the user asks how hlix is implemented."].join(`
10
+ `),Ft=["Hlix Code could not resolve a model.","Run `hlix auth login` to use your workspace's models (no model key of your own needed),","or set your provider's key (ANTHROPIC_API_KEY, OPENAI_API_KEY, OPENROUTER_API_KEY) to use your own subscription."].join(`
11
+ `),Wt=(e)=>e instanceof Error?e.message:String(e),Lt=["You are running inside Hlix Code, the terminal harness for the hlix control plane.","Every `hlix` CLI command is available to you as a tool named `hlix_<command>`,","with spaces replaced by underscores — `hlix_status`, `hlix_tasks_list`, `hlix_push`.","Use those tools instead of running `hlix` through the shell: they resolve the","folder's workspace binding and credential the same way the CLI does, and they","return the CLI's machine-readable output.","Report a non-zero exit code and its stderr to the user verbatim. Never invent a","project, task or workspace id — read one with a tool first.","","This project's secrets live in the hlix secrets store, not in a file in this","folder: `hlix_secrets_list` shows them keyed by (key, source file) with every","value masked, and `hlix_secrets_set` changes one. When the user asks for a",'local env file, call `hlix_secrets_export` with `{ flags: { out: ".env" } }` —',"it writes the rendered file at mode 0600 and refuses a path git tracks. Do not","repeat an exported secret value back into the conversation."].join(`
12
+ `);function Dt(e){if(!e||e.entries.length===0)return"";let t=e.entries.length,s=new Set(e.entries.map((r)=>r.source)).size;return`secrets: ${t} ${t===1?"entry":"entries"} (${s} ${s===1?"source":"sources"})`}async function Ut(e,t){try{return await m(process.env,{cwd:e,flags:{}}).secrets.listEntries(t)}catch{return null}}function Bt(e){let{values:t}=Pt({args:e,allowPositionals:!0,strict:!1,options:{local:{type:"boolean"},sandbox:{type:"string"},harness:{type:"string"},project:{type:"string"},cwd:{type:"string"}}}),s=typeof t.sandbox==="string"?t.sandbox:t.local===!0?"local":void 0;return{...s?{sandbox:s,sandboxSource:"flag"}:{},...typeof t.harness==="string"?{harness:t.harness}:{},...typeof t.project==="string"?{project:t.project}:{},cwd:Ht(typeof t.cwd==="string"?t.cwd:".")}}function qt(e){let t=Object.keys(w),r=e.sandbox==="cloud"?t:t.filter((n)=>e.installed(n)),o=["hlix",...r],a=t.filter((n)=>!r.includes(n)),i=e.requested.harness;if(i==="hlix"||r.includes(i))return{harness:e.requested,available:o,unavailable:a,refusal:null,warning:null};let c=j(w[i]);if(e.requested.source==="flag")return{harness:e.requested,available:o,unavailable:a,refusal:c,warning:null};return{harness:{harness:"hlix",source:"default"},available:o,unavailable:a,refusal:null,warning:`${c} Falling back to harness hlix.`}}async function Yt(e,t){try{let r=await m(process.env,{cwd:e,flags:{}}).modelConfig.resolvedProjectHarness(t);return{harness:r.harness,source:r.source}}catch{return null}}function Kt(e,t){let s=t.skills&&t.skills.length>0?{skills:t.skills}:{};if(e.choice!=="cloud")return M(e,{cwd:t.cwd,...s});if(!t.projectId)throw new y("invalid_usage","The cloud sandbox needs a hlix project. Run `hlix init`, pass --project <id>, or choose --sandbox docker|local.");let o=m(process.env,{cwd:t.cwd,flags:{}}).projects.workspace(t.projectId);return M(e,{cwd:t.cwd,projectId:t.projectId,remote:o})}var R=".hlix";function Xt(e){return e.skills.filter((t)=>!t.harnessReads).map((t)=>t.path)}function zt(e,t){return e.skills.filter((s)=>s.scope==="project").map((s)=>It(t,s.path)).filter((s)=>s!==""&&!s.startsWith(".."))}function Gt(e,t){if(e.length===0)return;let s={explore:"fast",plan:"plan",execute:"build"},r=t.find((n)=>n.metadata?.default===!0)?.id??t.find((n)=>n.id==="build")?.id??t[0]?.id,o=(n)=>t.find((d)=>d.id===s[n])?.defaultModelId??t.find((d)=>d.id===r)?.defaultModelId,a=[Mt,Rt,At].map((n)=>{let d=o(n.id);return{...n,...d?{defaultModelId:d}:{}}}),i=new Set(a.map((n)=>n.id)),c=e.filter((n)=>!i.has(n.name)).map((n)=>{let d=n.model??o("execute");return{id:n.name,name:n.name,description:n.description||`Project subagent from ${n.path}`,instructions:n.instructions,...n.tools?{allowedControllerTools:n.tools}:{},...d?{defaultModelId:d}:{}}});return[...a,...c]}var Jt=new Set(["--sandbox","--harness","--project","--cwd"]),Vt=new Set(["--local"]);function Qt(e){let t=[];for(let s=0;s<e.length;s+=1){let r=e[s];if(Vt.has(r))continue;if(Jt.has(r)){s+=1;continue}t.push(r)}return["node","hlix",...t]}function Zt(e,t,s){return{controller:s.cloud?ce(e.controller):e.controller,session:e.session,...e.hookManager?{hookManager:e.hookManager}:{},...e.mcpManager?{mcpManager:e.mcpManager}:{},...e.pluginManager?{pluginManager:e.pluginManager}:{},...e.knowledgeInspector?{knowledgeInspector:e.knowledgeInspector}:{},...s.cloud?{}:{authStorage:e.authStorage},storageMaintenance:e.storageMaintenance,appName:"Hlix Code",version:t}}async function es(e,t,s,r){let o=Qt(t);if(Tt(o)){let i=Ot(o),n=await $t({controller:e.controller,session:e.session,prompt:i.prompt??"",...i.model?{model:i.model}:{},...i.maxTurns?{maxTurns:i.maxTurns}:{}}).result;if(process.stdout.write(`${n.text}
13
+ `),n.error)process.stderr.write(`${b(n.error.message)}
14
+ `);return n.exitCode}let a=new Et(Zt(e,s,r));return K(a),await a.run(),0}async function cr(e,t={boot:jt,present:es}){let s=Bt(e),r=ke(s.cwd,process.env),o=s.project??r.merged.projectId,a=Se(s.cwd,ve(process.env),{configDir:R}),i,c,n;try{if(c=we({flag:s.sandbox??r.merged.sandbox,flagSource:s.sandbox?"flag":"config",projectId:o,dockerAvailable:()=>be()}),n=qt({requested:Z({...s.harness?{flag:s.harness}:{},...r.merged.harness?{configured:r.merged.harness}:{},...r.sources.harness?{configSource:r.sources.harness}:{}}),sandbox:c.choice,installed:(l)=>te(w[l].command)}),n.refusal)throw new y("invalid_usage",n.refusal);i=Kt(c,{cwd:s.cwd,projectId:o,...c.choice==="docker"?{skills:zt(a,s.cwd)}:{}})}catch(l){return process.stderr.write(`error: ${l instanceof Error?l.message:String(l)}
15
+ `),2}if(n.warning)process.stderr.write(`warning: ${n.warning}
16
+ `);if(c.choice==="cloud"){let l=o?await Yt(s.cwd,o):null;if(l&&s.harness&&s.harness!==l.harness)process.stderr.write(`warning: this project runs ${l.harness}. Run \`/harness ${s.harness}\` to make ${s.harness} the project's setting.
17
+ `);n={...n,harness:l??{harness:"unknown",source:o?"the project's setting could not be read":"no project bound"}}}let d=await ie({cwd:s.cwd,env:process.env});if(d.warning)process.stderr.write(`warning: ${d.warning}
18
+ `);let f=ue({wired:le({cwd:s.cwd,env:process.env,...d.ids?{models:d.ids}:{}}),cloud:c.choice==="cloud",...r.merged.model?{configured:r.merged.model}:{},...r.sources.model?{configuredSource:r.sources.model}:{}});if(f?.notice)process.stderr.write(`warning: ${f.notice}
19
+ `);let T=ye(c);process.stdout.write(`${me(ee(T,n.harness),f)}
20
+ `);let O=He(a);if(O)process.stdout.write(`${O}
21
+ `);let E=o?Dt(await Ut(s.cwd,o)):"";if(E)process.stdout.write(`${E}
22
+ `);J(s.cwd);let N=null,Pe=n.harness.harness==="unknown"?"hlix":n.harness.harness,F=re({sandbox:c.choice,cwd:s.cwd,active:Pe,unavailable:n.unavailable,...i?{workspace:i}:{},...f?{model:f.id}:{}}),je=new Set(Object.keys(_t(s.cwd,R).mcpServers??{})),W=Object.fromEntries(a.mcpServers.filter((l)=>!je.has(l.name)).map((l)=>[l.name,l.config])),L=Ce(a.generatedCommands,s.cwd),D=[...a.commands.map((l)=>l.path),...L?[L]:[]],U=Xt(a),B=de(F,f?.id),q=Gt(a.subagents,B),Y=Ie(a.instructions,s.cwd),{version:_e}=await import("./package-bkxredkn.js"),Ae={configDir:R,cwd:s.cwd,coAuthor:{name:"Hlix Code",email:"noreply@hlix.ai"},hostInstructions:[Nt,Lt,...c.choice==="cloud"?[se(n.harness.harness)]:[],...Y?[Y]:[]].join(`
23
+
24
+ `),...Object.keys(W).length>0?{mcpServers:W}:{},...q?{subagents:q}:{},...D.length>0||U.length>0?{initialState:{pluginCommandPaths:D,pluginSkillPaths:U}}:{},extraTools:{...z({cwd:s.cwd}),hlix_tasks_follow:ne({cwd:s.cwd}),hlix_harness:oe({sandbox:c.choice,sandboxLine:T,available:n.available,modesBuilt:F.length>0,session:()=>N,...o?{setProjectHarness:async(l)=>{await m(process.env,{cwd:s.cwd,flags:{}}).modelConfig.setProjectHarness(o,l)}}:{}})},modes:B,...i?{workspace:i}:{}},C;try{C=await t.boot(Ae)}catch(l){return process.stderr.write(`error: ${b(Wt(l))}
25
+ ${Ft}
26
+ `),2}return N=C.session,t.present(C,e,_e,{cloud:c.choice==="cloud"})}export{Xt as extraSkillPaths,Qt as headlessArgv,Bt as parseHlixCodeArgs,qt as planHarness,cr as runHlixCode,Dt as secretsStatusLine,Gt as standardsSubagents,Zt as tuiOptions,zt as workspaceSkillPaths};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import"./index-syeavftx.js";var s="@hlix/cli",i="0.4.3",n="SEE LICENSE IN LICENSE",a="Hlix Code and the hlix control-plane CLI.",r=["hlix","cli","agents"],d="https://hlix.ai",p="module",c="./dist/index.js",o={hlix:"./dist/index.js"},l=["dist","skills","LICENSE","THIRD_PARTY_NOTICES"],u={node:">=22.19.0"},b={access:"public"},h={build:"rm -rf dist && bun build src/index.ts --outdir dist --target node --format esm --splitting --packages external --minify --banner '#!/usr/bin/env node'",test:'bun test --isolate src --path-ignore-patterns "**/*.integration.test.ts" --timeout 20000',typecheck:"tsc --noEmit",prepublishOnly:"bun run typecheck && bun run build && bun run test","test:integration":"NODE_ENV=test bun run ../../apps/backend/scripts/with-aimock.ts -- bun run ../../apps/backend/scripts/with-test-db.ts -- bun test --isolate --preload ../../apps/backend/test/helpers/pool-lifecycle.ts --timeout 60000 .integration.test.ts"},m={"@mastra/acp":"^0.4.1","@mastra/code-sdk":"1.7.0","@mastra/core":"1.65.0","@mastra/docker":"^0.7.0",ignore:"7.0.8",mastracode:"0.39.0","openapi-fetch":"^0.17.0",zod:"4.5.4"},g={"@hlix/sdk":"^0.2.0","@types/bun":"latest",typescript:"^7.0.2"},k={name:s,version:i,license:n,description:a,keywords:r,homepage:d,type:p,main:c,bin:o,files:l,engines:u,publishConfig:b,scripts:h,dependencies:m,devDependencies:g};export{o as bin,k as default,m as dependencies,a as description,g as devDependencies,u as engines,l as files,d as homepage,r as keywords,n as license,c as main,s as name,b as publishConfig,h as scripts,p as type,i as version};
2
+ import"./index-y1n35st0.js";var s="@hlix/cli",i="0.4.5",n="SEE LICENSE IN LICENSE",a="Hlix Code and the hlix control-plane CLI.",r=["hlix","cli","agents"],d="https://hlix.ai",p="module",c="./dist/index.js",o={hlix:"./dist/index.js"},l=["dist","skills","LICENSE","THIRD_PARTY_NOTICES"],u={node:">=22.19.0"},b={access:"public"},h={build:"rm -rf dist && bun build src/index.ts --outdir dist --target node --format esm --splitting --packages external --minify --banner '#!/usr/bin/env node'",test:'bun test --isolate src --path-ignore-patterns "**/*.integration.test.ts" --timeout 20000',typecheck:"tsc --noEmit",prepublishOnly:"bun run typecheck && bun run build && bun run test","test:integration":"NODE_ENV=test bun run ../../apps/backend/scripts/with-aimock.ts -- bun run ../../apps/backend/scripts/with-test-db.ts -- bun test --isolate --preload ../../apps/backend/test/helpers/pool-lifecycle.ts --timeout 60000 .integration.test.ts"},m={"@mastra/acp":"^0.4.1","@mastra/code-sdk":"1.7.1","@mastra/core":"1.66.0","@mastra/docker":"^0.7.0",ignore:"7.0.8",mastracode:"0.39.1","openapi-fetch":"^0.17.0",zod:"4.5.4"},g={"@hlix/sdk":"^0.2.0","@types/bun":"latest",typescript:"^7.0.2"},k={name:s,version:i,license:n,description:a,keywords:r,homepage:d,type:p,main:c,bin:o,files:l,engines:u,publishConfig:b,scripts:h,dependencies:m,devDependencies:g};export{o as bin,k as default,m as dependencies,a as description,g as devDependencies,u as engines,l as files,d as homepage,r as keywords,n as license,c as main,s as name,b as publishConfig,h as scripts,p as type,i as version};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hlix/cli",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "Hlix Code and the hlix control-plane CLI.",
6
6
  "keywords": [
@@ -35,11 +35,11 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@mastra/acp": "^0.4.1",
38
- "@mastra/code-sdk": "1.7.0",
39
- "@mastra/core": "1.65.0",
38
+ "@mastra/code-sdk": "1.7.1",
39
+ "@mastra/core": "1.66.0",
40
40
  "@mastra/docker": "^0.7.0",
41
41
  "ignore": "7.0.8",
42
- "mastracode": "0.39.0",
42
+ "mastracode": "0.39.1",
43
43
  "openapi-fetch": "^0.17.0",
44
44
  "zod": "4.5.4"
45
45
  },