@hagicode/cli 0.1.0-dev.17.1.4437f14 → 0.1.0-dev.19.1.7d58d9d
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.
|
@@ -33,7 +33,7 @@ ${M([{header:"Session ID",value:o=>o.sessionId},{header:"Title",value:o=>o.title
|
|
|
33
33
|
`}function z(t,e=[]){return q([["sessionId",t.sessionId],["type",t.type],["title",t.title],["status",t.status],["projectId",t.projectId],["proposalName",t.proposalName],["independentWorkspace",String(t.enableIndependentWorkspace)],["baseBranch",t.baseBranch],["chatExecutorType",t.chatExecutorType],["metadata",t.metadata],...e])}function lt(t,e,o,n=[]){return`${t}
|
|
34
34
|
${q([["sessionId",e],["message",o.message],...n])}`}var m={BASE:"",VERSION:"1",WITH_CREDENTIALS:!1,CREDENTIALS:"include",TOKEN:void 0,USERNAME:void 0,PASSWORD:void 0,HEADERS:void 0,ENCODE_PATH:void 0},ot=class extends Error{url;status;statusText;body;request;constructor(t,e,o){super(o),this.name="ApiError",this.url=e.url,this.status=e.status,this.statusText=e.statusText,this.body=e.body,this.request=t}},D={USAGE:2,HTTP_BAD_REQUEST:20,HTTP_UNAUTHORIZED:21,HTTP_FORBIDDEN:23,HTTP_NOT_FOUND:24,HTTP_CONFLICT:29,HTTP_CLIENT_ERROR:40,HTTP_SERVER_ERROR:50,TRANSPORT:60,UNKNOWN:70},$=class extends Error{constructor(t){super(t),this.name="CliUsageError"}},ut=class extends Error{status;details;constructor(t,e,o){super(e),this.name="CliHttpError",this.status=t,this.details=o}};function re(t){if(!(!t||typeof t!="object"||Array.isArray(t)))return t}function X(t,e){const o=re(t)?.[e];return typeof o=="string"&&o.trim()?o.trim():void 0}function oe(t){return t.includes("fetch failed")||t.includes("ECONNREFUSED")||t.includes("ENOTFOUND")||t.includes("Failed to parse URL")}function Ot(t){switch(t){case 400:return D.HTTP_BAD_REQUEST;case 401:return D.HTTP_UNAUTHORIZED;case 403:return D.HTTP_FORBIDDEN;case 404:return D.HTTP_NOT_FOUND;case 409:return D.HTTP_CONFLICT;default:return t&&t>=400&&t<500?D.HTTP_CLIENT_ERROR:t&&t>=500?D.HTTP_SERVER_ERROR:D.UNKNOWN}}function ne(t,e={}){if(t instanceof $)return{exitCode:D.USAGE,message:t.message};if(t instanceof ut)return{exitCode:Ot(t.status),status:t.status,message:t.message,details:t.details};if(t instanceof ot){const o=X(t.body,"error")??X(t.body,"message")??t.message;return{exitCode:Ot(t.status),status:t.status,message:o,errorCode:X(t.body,"errorCode"),correlationId:X(t.body,"correlationId"),details:t.body}}if(t instanceof Error){if(!oe(t.message))return{exitCode:D.UNKNOWN,message:t.message};const o=e.baseUrl??"the configured backend";return{exitCode:D.TRANSPORT,message:t.message.includes("Failed to parse URL")?`Invalid HagiCode backend base URL: ${o}`:`Cannot reach HagiCode backend at ${o}. Check that the backend is running and the base URL is correct.`}}return{exitCode:D.UNKNOWN,message:String(t)}}function wt(t,e={}){if(e.json)return`${JSON.stringify({error:{message:t.message,status:t.status,exitCode:t.exitCode,errorCode:t.errorCode,correlationId:t.correlationId,details:t.details}},null,2)}
|
|
35
35
|
`;const o=[t.status?`status=${t.status}`:void 0,t.errorCode?`errorCode=${t.errorCode}`:void 0,t.correlationId?`correlationId=${t.correlationId}`:void 0].filter(Boolean),n=o.length>0?` (${o.join(", ")})`:"";return`${t.message}${n}
|
|
36
|
-
`}var ae="--base-url",le="HAGI_API_BASE_URL";function R(t){const e=t?.trim();return e||void 0}function It(t=process.env){return(0,vt.join)(R(t.XDG_CONFIG_HOME)??(0,vt.join)((0,Qt.homedir)(),".config"),"hagi","config.json")}function ue(t=process.env){const e=It(t);let o;try{o=(0,Kt.readFileSync)(e,"utf8")}catch(s){if(s.code==="ENOENT")return;throw new $(`Cannot read CLI config file ${e}: ${s instanceof Error?s.message:String(s)}`)}let n;try{n=JSON.parse(o)}catch{throw new $(`CLI config file ${e} is not valid JSON.`)}const i=n&&typeof n=="object"&&!Array.isArray(n)?n.baseUrl:void 0;return typeof i=="string"?R(i):void 0}function ce(t={},e=process.env){const o=R(t.baseUrl)??R(e.HAGI_API_BASE_URL)??ue(e);if(!o)throw new $(`No backend base URL is configured. Set ${ae} <url>, the ${le} environment variable, or "baseUrl" in ${It(e)}.`);return{baseUrl:o,token:R(t.token)??R(e.HAGI_API_TOKEN),lang:R(t.lang)??R(e.HAGI_API_LANG)}}function de(t={},e=process.env){const o=ce(t,e);return m.BASE=o.baseUrl,m.WITH_CREDENTIALS=!1,m.CREDENTIALS="omit",m.TOKEN=o.token,m.HEADERS=o.lang?{"Accept-Language":o.lang}:void 0,o}function pe(){return R(m.BASE)}var he=class extends Error{constructor(t){super(t),this.name="CancelError"}get isCancelled(){return!0}},me=class{#e;#i;#t;#s;#o;#n;#r;constructor(t){this.#e=!1,this.#i=!1,this.#t=!1,this.#s=[],this.#o=new Promise((e,o)=>{this.#n=e,this.#r=o;const n=l=>{this.#e||this.#i||this.#t||(this.#e=!0,this.#n&&this.#n(l))},i=l=>{this.#e||this.#i||this.#t||(this.#i=!0,this.#r&&this.#r(l))},s=l=>{this.#e||this.#i||this.#t||this.#s.push(l)};return Object.defineProperty(s,"isResolved",{get:()=>this.#e}),Object.defineProperty(s,"isRejected",{get:()=>this.#i}),Object.defineProperty(s,"isCancelled",{get:()=>this.#t}),t(n,i,s)})}get[Symbol.toStringTag](){return"Cancellable Promise"}then(t,e){return this.#o.then(t,e)}catch(t){return this.#o.catch(t)}finally(t){return this.#o.finally(t)}cancel(){if(!(this.#e||this.#i||this.#t)){if(this.#t=!0,this.#s.length)try{for(const t of this.#s)t()}catch(t){console.warn("Cancellation threw an error",t);return}this.#s.length=0,this.#r&&this.#r(new he("Request aborted"))}}get isCancelled(){return this.#t}},ct=t=>t!=null,Q=t=>typeof t=="string",st=t=>Q(t)&&t!=="",dt=t=>typeof t=="object"&&typeof t.type=="string"&&typeof t.stream=="function"&&typeof t.arrayBuffer=="function"&&typeof t.constructor=="function"&&typeof t.constructor.name=="string"&&/^(Blob|File)$/.test(t.constructor.name)&&/^(Blob|File)$/.test(t[Symbol.toStringTag]),xt=t=>t instanceof FormData,fe=t=>{try{return btoa(t)}catch{return Buffer.from(t).toString("base64")}},ge=t=>{const e=[],o=(i,s)=>{e.push(`${encodeURIComponent(i)}=${encodeURIComponent(String(s))}`)},n=(i,s)=>{ct(s)&&(Array.isArray(s)?s.forEach(l=>{n(i,l)}):typeof s=="object"?Object.entries(s).forEach(([l,u])=>{n(`${i}[${l}]`,u)}):o(i,s))};return Object.entries(t).forEach(([i,s])=>{n(i,s)}),e.length>0?`?${e.join("&")}`:""},ve=(t,e)=>{const o=t.ENCODE_PATH||encodeURI,n=e.url.replace("{api-version}",t.VERSION).replace(/{(.*?)}/g,(s,l)=>e.path?.hasOwnProperty(l)?o(String(e.path[l])):s),i=`${t.BASE}${n}`;return e.query?`${i}${ge(e.query)}`:i},ye=t=>{if(t.formData){const e=new FormData,o=(n,i)=>{Q(i)||dt(i)?e.append(n,i):e.append(n,JSON.stringify(i))};return Object.entries(t.formData).filter(([n,i])=>ct(i)).forEach(([n,i])=>{Array.isArray(i)?i.forEach(s=>o(n,s)):o(n,i)}),e}},Y=async(t,e)=>typeof e=="function"?e(t):e,Oe=async(t,e)=>{const[o,n,i,s]=await Promise.all([Y(e,t.TOKEN),Y(e,t.USERNAME),Y(e,t.PASSWORD),Y(e,t.HEADERS)]),l=Object.entries({Accept:"application/json",...s,...e.headers}).filter(([u,h])=>ct(h)).reduce((u,[h,y])=>({...u,[h]:String(y)}),{});return st(o)&&(l.Authorization=`Bearer ${o}`),st(n)&&st(i)&&(l.Authorization=`Basic ${fe(`${n}:${i}`)}`),e.body!==void 0&&(e.mediaType?l["Content-Type"]=e.mediaType:dt(e.body)?l["Content-Type"]=e.body.type||"application/octet-stream":Q(e.body)?l["Content-Type"]="text/plain":xt(e.body)||(l["Content-Type"]="application/json")),new Headers(l)},Ae=t=>{if(t.body!==void 0)return t.mediaType?.includes("/json")?JSON.stringify(t.body):Q(t.body)||dt(t.body)||xt(t.body)?t.body:JSON.stringify(t.body)},Se=async(t,e,o,n,i,s,l)=>{const u=new AbortController,h={headers:s,body:n??i,method:e.method,signal:u.signal};return t.WITH_CREDENTIALS&&(h.credentials=t.CREDENTIALS),l(()=>u.abort()),await fetch(o,h)},Ce=(t,e)=>{if(e){const o=t.headers.get(e);if(Q(o))return o}},_e=async t=>{if(t.status!==204)try{const e=t.headers.get("Content-Type");if(e)return["application/json","application/problem+json"].some(o=>e.toLowerCase().startsWith(o))?await t.json():await t.text()}catch(e){console.error(e)}},be=(t,e)=>{const o={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",...t.errors}[e.status];if(o)throw new ot(t,e,o);if(!e.ok)throw new ot(t,e,`Generic Error: status: ${e.status??"unknown"}; status text: ${e.statusText??"unknown"}; body: ${(()=>{try{return JSON.stringify(e.body,null,2)}catch{return}})()}`)},g=(t,e)=>new me(async(o,n,i)=>{try{const s=ve(t,e),l=ye(e),u=Ae(e),h=await Oe(t,e);if(!i.isCancelled){const y=await Se(t,e,s,u,l,h,i),C=await _e(y),S=Ce(y,e.responseHeader),_={url:s,ok:y.ok,status:y.status,statusText:y.statusText,body:S??C};be(e,_),o(_.body)}}catch(s){n(s)}}),Ee=class{static getApiDataAggregation(){return g(m,{method:"GET",url:"/api/DataAggregation",errors:{400:"Depth parameter is no longer supported"}})}},rt=class{static postApiProject({requestBody:t}){return g(m,{method:"POST",url:"/api/Project",body:t,mediaType:"application/json"})}static postApiProjectDemo(){return g(m,{method:"POST",url:"/api/Project/demo"})}static putApiProject({id:t,requestBody:e}){return g(m,{method:"PUT",url:"/api/Project/{id}",path:{id:t},body:e,mediaType:"application/json"})}static deleteApiProject({id:t}){return g(m,{method:"DELETE",url:"/api/Project/{id}",path:{id:t}})}static postApiProjectOpenInVscode({id:t,subPath:e}){return g(m,{method:"POST",url:"/api/Project/{id}/open-in-vscode",path:{id:t},query:{subPath:e},errors:{400:"Invalid project path or sub-path",403:"Sub-path is outside project directory",404:"Project not found",500:"Failed to launch VS Code"}})}static getApiProjectMonospecsManagement({id:t}){return g(m,{method:"GET",url:"/api/Project/{id}/monospecs/management",path:{id:t},errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static putApiProjectMonospecsManagement({id:t,requestBody:e}){return g(m,{method:"PUT",url:"/api/Project/{id}/monospecs/management",path:{id:t},body:e,mediaType:"application/json",errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static postApiProjectMonospecsInitialize({id:t}){return g(m,{method:"POST",url:"/api/Project/{id}/monospecs/initialize",path:{id:t},errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static getApiProjectDesignMd({id:t,repositoryPath:e}){return g(m,{method:"GET",url:"/api/Project/{id}/design-md",path:{id:t},query:{repositoryPath:e},errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static putApiProjectDesignMd({id:t,requestBody:e}){return g(m,{method:"PUT",url:"/api/Project/{id}/design-md",path:{id:t},body:e,mediaType:"application/json",errors:{400:"Bad Request",404:"Not Found",409:"Conflict",500:"Internal Server Error"}})}static getApiProjectDesignMdSiteIndex({id:t}){return g(m,{method:"GET",url:"/api/Project/{id}/design-md/site-index",path:{id:t},errors:{400:"Bad Request",404:"Not Found",502:"Bad Gateway",504:"Gateway Timeout"}})}static getApiProjectDesignMdSiteIndexPreview({id:t,slug:e,theme:o="light"}){return g(m,{method:"GET",url:"/api/Project/{id}/design-md/site-index/{slug}/preview",path:{id:t,slug:e},query:{theme:o},errors:{400:"Bad Request",404:"Not Found",502:"Bad Gateway",504:"Gateway Timeout"}})}static getApiProjectDesignMdSiteIndex1({id:t,slug:e}){return g(m,{method:"GET",url:"/api/Project/{id}/design-md/site-index/{slug}",path:{id:t,slug:e},errors:{400:"Bad Request",404:"Not Found",502:"Bad Gateway",504:"Gateway Timeout"}})}static getApiProjectBranchesValidate({id:t,branchName:e,repositoryPath:o}){return g(m,{method:"GET",url:"/api/Project/{id}/branches/validate",path:{id:t},query:{branchName:e,repositoryPath:o},errors:{400:"Branch name is required",404:"Project not found"}})}static getApiProjectValidatePath({path:t}){return g(m,{method:"GET",url:"/api/Project/validate-path",query:{path:t},errors:{400:"Path parameter is missing or invalid",500:"Internal server error during validation"}})}static postApiProjectScanGitRepos({requestBody:t}){return g(m,{method:"POST",url:"/api/Project/scan-git-repos",body:t,mediaType:"application/json",errors:{400:"Invalid request parameters",500:"Internal server error during scan"}})}static postApiProjectValidateMonospecs({requestBody:t}){return g(m,{method:"POST",url:"/api/Project/validate-monospecs",body:t,mediaType:"application/json",errors:{400:"Invalid request parameters",500:"Internal server error"}})}},V=class{static postApiSessionsAutoTask({requestBody:t}){return g(m,{method:"POST",url:"/api/Sessions/auto-task",body:t,mediaType:"application/json",errors:{400:"Missing required fields or invalid prompt ID",404:"Project not found",500:"Internal server error"}})}static postApiSessionsArchiveChat({sessionId:t}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/archive-chat",path:{sessionId:t},errors:{400:"Session is not a chat session",404:"Session not found",500:"Failed to archive chat session"}})}static postApiSessionsChat({requestBody:t}){return g(m,{method:"POST",url:"/api/Sessions/chat",body:t,mediaType:"application/json",errors:{400:"Bad Request"}})}static postApiSessions({requestBody:t}){return g(m,{method:"POST",url:"/api/Sessions",body:t,mediaType:"application/json",errors:{400:"Bad Request"}})}static getApiSessions({type:t,activeOnly:e,includeArchived:o,projectId:n,projectIds:i}){return g(m,{method:"GET",url:"/api/Sessions",query:{type:t,activeOnly:e,includeArchived:o,projectId:n,projectIds:i}})}static getApiSessions1({sessionId:t}){return g(m,{method:"GET",url:"/api/Sessions/{sessionId}",path:{sessionId:t},errors:{400:"Invalid session ID format",404:"Session not found",500:"Internal server error occurred"}})}static putApiSessions({sessionId:t,requestBody:e}){return g(m,{method:"PUT",url:"/api/Sessions/{sessionId}",path:{sessionId:t},body:e,mediaType:"application/json"})}static deleteApiSessions({sessionId:t,deleteFiles:e=!1}){return g(m,{method:"DELETE",url:"/api/Sessions/{sessionId}",path:{sessionId:t},query:{deleteFiles:e},errors:{404:"Session not found",500:"Failed to delete session"}})}static getApiSessionsMessages({sessionId:t,page:e=1,pageSize:o=50,historyScope:n,order:i="desc"}){return g(m,{method:"GET",url:"/api/Sessions/{sessionId}/messages",path:{sessionId:t},query:{page:e,pageSize:o,historyScope:n,order:i},errors:{404:"Not Found",500:"Internal Server Error"}})}static postApiSessionsMessages({sessionId:t,requestBody:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/messages",path:{sessionId:t},body:e,mediaType:"application/json"})}static postApiSessionsCancel({sessionId:t}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/cancel",path:{sessionId:t},errors:{404:"Session not found",500:"Failed to cancel session"}})}static getApiSessionsProcessingStatus({sessionId:t}){return g(m,{method:"GET",url:"/api/Sessions/{sessionId}/processing-status",path:{sessionId:t},errors:{404:"Session not found",500:"Failed to get processing status"}})}static deleteApiSessionsQueue({sessionId:t,queueIndex:e}){return g(m,{method:"DELETE",url:"/api/Sessions/{sessionId}/queue/{queueIndex}",path:{sessionId:t,queueIndex:e},errors:{400:"Invalid queue index",404:"Session not found",500:"Failed to cancel message"}})}static postApiSessionsAnnotations({sessionId:t,requestBody:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/annotations",path:{sessionId:t},body:e,mediaType:"application/json",errors:{400:"Invalid request or session is not a proposal session",404:"Session not found",500:"Failed to process annotations"}})}static postApiSessionsOptimizeProposal({sessionId:t,requestBody:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/optimize-proposal",path:{sessionId:t},body:e,mediaType:"application/json",errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static postApiSessionsGenerateProposal({sessionId:t,requestBody:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/generate-proposal",path:{sessionId:t},body:e,mediaType:"application/json",errors:{400:"Session is not a proposal session or proposal name not generated",404:"Session not found",500:"Failed to generate proposal"}})}static postApiSessionsArchive({sessionId:t,requestBody:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/archive",path:{sessionId:t},body:e,mediaType:"application/json",errors:{400:"Session is not a proposal session or proposal name missing",404:"Session not found",500:"Failed to archive session"}})}static postApiSessionsExecuteProposal({sessionId:t,requestBody:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/execute-proposal",path:{sessionId:t},body:e,mediaType:"application/json",errors:{400:"Session is not a proposal session, not in valid status, or proposal name missing",404:"Session not found",500:"Failed to execute proposal"}})}static postApiSessionsComplete({sessionId:t}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/complete",path:{sessionId:t},errors:{400:"Session is not in ExecutionCompleted status",404:"Session not found",500:"Failed to complete session"}})}static postApiSessionsValidateExecute({sessionId:t}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/validate-execute",path:{sessionId:t},errors:{404:"Session not found",500:"Failed to validate session"}})}static postApiSessionsValidateStart({sessionId:t}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/validate-start",path:{sessionId:t},errors:{404:"Session not found",500:"Failed to validate session"}})}static postApiSessionsValidateArchive({sessionId:t}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/validate-archive",path:{sessionId:t},errors:{404:"Session not found",500:"Failed to validate session"}})}static getApiSessionsOpenspecFile({sessionId:t,relativePath:e}){return g(m,{method:"GET",url:"/api/Sessions/{sessionId}/openspec-file",path:{sessionId:t},query:{relativePath:e},errors:{404:"Session not found or file not found",500:"Failed to read file"}})}static postApiSessionsUpdateCessionId({sessionId:t}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/update-cession-id",path:{sessionId:t},errors:{404:"Session not found",500:"Failed to update CessionId"}})}static postApiSessionsOpenInVscode({sessionId:t,subPath:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/open-in-vscode",path:{sessionId:t},query:{subPath:e},errors:{400:"Invalid project path or sub-path",403:"Sub-path is outside project directory",404:"Session not found",500:"Failed to launch VS Code"}})}static postApiSessionsCorrectProposalName({sessionId:t,requestBody:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/correct-proposal-name",path:{sessionId:t},body:e,mediaType:"application/json",errors:{400:"Invalid name format or validation failed",404:"Session not found",409:"Name already in use by another session",500:"Internal server error"}})}static deleteApiSessionsWorkspace({sessionId:t}){return g(m,{method:"DELETE",url:"/api/Sessions/{sessionId}/workspace",path:{sessionId:t},errors:{400:"Session does not have an independent workspace",404:"Session not found",500:"Failed to delete workspace"}})}},F=class{static getApiSkillsLocal(){return g(m,{method:"GET",url:"/api/skills/local"})}static postApiSkillsLocalUninstall({requestBody:t}){return g(m,{method:"POST",url:"/api/skills/local/uninstall",body:t,mediaType:"application/json"})}static getApiSkillsGallery({query:t}){return g(m,{method:"GET",url:"/api/skills/gallery",query:{query:t}})}static getApiSkillsGalleryDetail({id:t,source:e}){return g(m,{method:"GET",url:"/api/skills/gallery/detail",query:{id:t,source:e}})}static getApiSkillsGalleryInstallContext({id:t,source:e}){return g(m,{method:"GET",url:"/api/skills/gallery/install-context",query:{id:t,source:e}})}static getApiSkillsProvidersTrusted(){return g(m,{method:"GET",url:"/api/skills/providers/trusted"})}static postApiSkillsProvidersTrusted({requestBody:t}){return g(m,{method:"POST",url:"/api/skills/providers/trusted",body:t,mediaType:"application/json"})}static deleteApiSkillsProvidersTrusted({requestBody:t}){return g(m,{method:"DELETE",url:"/api/skills/providers/trusted",body:t,mediaType:"application/json"})}static postApiSkillsProvidersTrustedReset(){return g(m,{method:"POST",url:"/api/skills/providers/trusted/reset"})}static postApiSkillsGalleryInstall({requestBody:t}){return g(m,{method:"POST",url:"/api/skills/gallery/install",body:t,mediaType:"application/json"})}static getApiSkillsRecommendationsConfig({locale:t}){return g(m,{method:"GET",url:"/api/skills/recommendations/config",query:{locale:t}})}static postApiSkillsRecommendationsGenerate({requestBody:t}){return g(m,{method:"POST",url:"/api/skills/recommendations/generate",body:t,mediaType:"application/json"})}static postApiSkillsRecommendationsInstall({requestBody:t}){return g(m,{method:"POST",url:"/api/skills/recommendations/install",body:t,mediaType:"application/json"})}static getApiSkillsGalleryInstallStream({id:t,source:e,skillSlug:o,version:n}){return g(m,{method:"GET",url:"/api/skills/gallery/install/stream",query:{id:t,source:e,skillSlug:o,version:n}})}},J=class{static getApiVaults(){return g(m,{method:"GET",url:"/api/vaults"})}static postApiVaults({requestBody:t}){return g(m,{method:"POST",url:"/api/vaults",body:t,mediaType:"application/json",errors:{400:"Bad Request",500:"Internal Server Error"}})}static putApiVaults({id:t,requestBody:e}){return g(m,{method:"PUT",url:"/api/vaults/{id}",path:{id:t},body:e,mediaType:"application/json",errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static deleteApiVaults({id:t,deleteLocalFiles:e=!1}){return g(m,{method:"DELETE",url:"/api/vaults/{id}",path:{id:t},query:{deleteLocalFiles:e},errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static getApiVaultsFiles({id:t,path:e}){return g(m,{method:"GET",url:"/api/vaults/{id}/files",path:{id:t},query:{path:e},errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static getApiVaultsFilesContent({id:t,path:e}){return g(m,{method:"GET",url:"/api/vaults/{id}/files/content",path:{id:t},query:{path:e},errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}};function Pe(){return{listSessions:t=>V.getApiSessions(t),getSession:t=>V.getApiSessions1({sessionId:t}),createProposalSession:t=>V.postApiSessions({requestBody:t}),createChatSession:t=>V.postApiSessionsChat({requestBody:t}),createAutoTaskSession:t=>V.postApiSessionsAutoTask({requestBody:t}),updateSession:(t,e)=>V.putApiSessions({sessionId:t,requestBody:e}),deleteSession:(t,e)=>V.deleteApiSessions({sessionId:t,deleteFiles:e}),sendMessage:(t,e)=>V.postApiSessionsMessages({sessionId:t,requestBody:e}),optimizeProposal:(t,e)=>V.postApiSessionsOptimizeProposal({sessionId:t,requestBody:e}),generateProposal:(t,e)=>V.postApiSessionsGenerateProposal({sessionId:t,requestBody:e}),executeProposal:(t,e)=>V.postApiSessionsExecuteProposal({sessionId:t,requestBody:e}),archiveProposal:(t,e)=>V.postApiSessionsArchive({sessionId:t,requestBody:e}),completeProposal:t=>V.postApiSessionsComplete({sessionId:t}),submitAnnotations:(t,e)=>V.postApiSessionsAnnotations({sessionId:t,requestBody:e}),listProjects:()=>Ee.getApiDataAggregation(),createProject:t=>rt.postApiProject({requestBody:t}),updateProject:(t,e)=>rt.putApiProject({id:t,requestBody:e}),deleteProject:t=>rt.deleteApiProject({id:t}),listVaults:()=>J.getApiVaults(),createVault:t=>J.postApiVaults({requestBody:t}),updateVault:(t,e)=>J.putApiVaults({id:t,requestBody:e}),deleteVault:(t,e)=>J.deleteApiVaults({id:t,deleteLocalFiles:e}),listVaultFiles:(t,e)=>J.getApiVaultsFiles({id:t,path:e}),previewVaultFile:(t,e)=>J.getApiVaultsFilesContent({id:t,path:e}),archiveChat:t=>V.postApiSessionsArchiveChat({sessionId:t}),listLocalSkills:()=>F.getApiSkillsLocal(),uninstallLocalSkill:t=>F.postApiSkillsLocalUninstall({requestBody:t}),searchSkillGallery:t=>F.getApiSkillsGallery({query:t}),getSkillGalleryDetail:(t,e)=>F.getApiSkillsGalleryDetail({id:t,source:e}),installGallerySkill:t=>F.postApiSkillsGalleryInstall({requestBody:t}),listTrustedSkillProviders:()=>F.getApiSkillsProvidersTrusted(),upsertTrustedSkillProvider:t=>F.postApiSkillsProvidersTrusted({requestBody:t}),deleteTrustedSkillProvider:t=>F.deleteApiSkillsProvidersTrusted({requestBody:t}),resetTrustedSkillProviders:()=>F.postApiSkillsProvidersTrustedReset()}}function A(t){const e=t?.trim();return e||void 0}function x(t,e){const o=A(t);if(!o)throw new $(`${e} is required.`);return o}function kt(t){const e=t?.map(o=>A(o)).filter(Boolean);return e&&e.length>0?e:void 0}function jt(t=process.env,e={stdout:o=>{process.stdout.write(o)},stderr:o=>{process.stderr.write(o)}}){return{api:Pe(),env:t,io:e}}function Te(t){return t.option("--base-url <url>",'Backend API base URL. Overrides HAGI_API_BASE_URL and the "baseUrl" config file entry.').option("--token <token>","Bearer token for backend API calls. Overrides HAGI_API_TOKEN.").option("--lang <lang>","Accept-Language value for backend API calls. Overrides HAGI_API_LANG.")}function P(t){return t.option("--json","Emit deterministic JSON instead of human-readable text.")}function T(t,e){const o=t.optsWithGlobals();return{api:e.api,env:e.env,io:e.io,outputJson:o.json===!0,runtime:de({baseUrl:o.baseUrl,token:o.token,lang:o.lang},e.env)}}function we(t,e){P(t.command("create").description("Create an AutoTask session through the dedicated generated endpoint.")).requiredOption("--title <title>","AutoTask session title.").requiredOption("--project-id <id>","Owning project id.").requiredOption("--prompt-id <id>","Prompt template id.").option("--message <text>","Optional custom message override.").option("--preset-id <id>","Optional preset id.").option("--repository-path <path>","Optional MonoSpecs repository path.").option("--project-ids <ids...>","Optional extra project ids for multi-project flows.").option("--need-push","Request push after commit creation when supported.").option("--target-branch-mode <mode>","Optional target branch mode.").option("--target-branch-name <name>","Optional custom target branch name.").option("--script-key <key>","Optional stable dungeon script key.").option("--hero-id <id>","Optional preferred hero id.").option("--target-type <type>","Optional target type for the AutoTask session.").option("--vault-id <id>","Optional vault id for the AutoTask session.").action(async function(n){if(n.targetBranchName&&n.targetBranchMode!=="new-custom")throw new $("--target-branch-name requires --target-branch-mode new-custom.");if(n.targetBranchMode==="new-custom"&&!A(n.targetBranchName))throw new $("--target-branch-name is required when --target-branch-mode is new-custom.");const i=T(this,e),s={title:x(n.title,"--title"),projectId:x(n.projectId,"--project-id"),promptId:x(n.promptId,"--prompt-id"),message:A(n.message),presetId:A(n.presetId),repositoryPath:A(n.repositoryPath),projectIds:kt(n.projectIds),needPush:n.needPush?!0:void 0,targetBranchMode:A(n.targetBranchMode),targetBranchName:A(n.targetBranchName),scriptKey:A(n.scriptKey),heroId:A(n.heroId),targetType:A(n.targetType),vaultId:A(n.vaultId)},l=W(await i.api.createAutoTaskSession(s));if(i.outputJson){i.io.stdout(E({session:l,promptId:s.promptId,requested:s}));return}i.io.stdout(`AutoTask session created
|
|
36
|
+
`}var ae="--base-url",le="HAGI_API_BASE_URL";function R(t){const e=t?.trim();return e||void 0}function It(t=process.env){return(0,vt.join)(R(t.XDG_CONFIG_HOME)??(0,vt.join)((0,Qt.homedir)(),".config"),"hagi","config.json")}function ue(t=process.env){const e=It(t);let o;try{o=(0,Kt.readFileSync)(e,"utf8")}catch(s){if(s.code==="ENOENT")return;throw new $(`Cannot read CLI config file ${e}: ${s instanceof Error?s.message:String(s)}`)}let n;try{n=JSON.parse(o)}catch{throw new $(`CLI config file ${e} is not valid JSON.`)}const i=n&&typeof n=="object"&&!Array.isArray(n)?n.baseUrl:void 0;return typeof i=="string"?R(i):void 0}function ce(t={},e=process.env){const o=R(t.baseUrl)??R(e.HAGI_API_BASE_URL)??ue(e);if(!o)throw new $(`No backend base URL is configured. Set ${ae} <url>, the ${le} environment variable, or "baseUrl" in ${It(e)}.`);return{baseUrl:o,token:R(t.token)??R(e.HAGI_API_TOKEN),lang:R(t.lang)??R(e.HAGI_API_LANG)}}function de(t={},e=process.env){const o=ce(t,e);return m.BASE=o.baseUrl,m.WITH_CREDENTIALS=!1,m.CREDENTIALS="omit",m.TOKEN=o.token,m.HEADERS=o.lang?{"Accept-Language":o.lang}:void 0,o}function pe(){return R(m.BASE)}var he=class extends Error{constructor(t){super(t),this.name="CancelError"}get isCancelled(){return!0}},me=class{#e;#i;#t;#s;#o;#n;#r;constructor(t){this.#e=!1,this.#i=!1,this.#t=!1,this.#s=[],this.#o=new Promise((e,o)=>{this.#n=e,this.#r=o;const n=l=>{this.#e||this.#i||this.#t||(this.#e=!0,this.#n&&this.#n(l))},i=l=>{this.#e||this.#i||this.#t||(this.#i=!0,this.#r&&this.#r(l))},s=l=>{this.#e||this.#i||this.#t||this.#s.push(l)};return Object.defineProperty(s,"isResolved",{get:()=>this.#e}),Object.defineProperty(s,"isRejected",{get:()=>this.#i}),Object.defineProperty(s,"isCancelled",{get:()=>this.#t}),t(n,i,s)})}get[Symbol.toStringTag](){return"Cancellable Promise"}then(t,e){return this.#o.then(t,e)}catch(t){return this.#o.catch(t)}finally(t){return this.#o.finally(t)}cancel(){if(!(this.#e||this.#i||this.#t)){if(this.#t=!0,this.#s.length)try{for(const t of this.#s)t()}catch(t){console.warn("Cancellation threw an error",t);return}this.#s.length=0,this.#r&&this.#r(new he("Request aborted"))}}get isCancelled(){return this.#t}},ct=t=>t!=null,Q=t=>typeof t=="string",st=t=>Q(t)&&t!=="",dt=t=>typeof t=="object"&&typeof t.type=="string"&&typeof t.stream=="function"&&typeof t.arrayBuffer=="function"&&typeof t.constructor=="function"&&typeof t.constructor.name=="string"&&/^(Blob|File)$/.test(t.constructor.name)&&/^(Blob|File)$/.test(t[Symbol.toStringTag]),xt=t=>t instanceof FormData,fe=t=>{try{return btoa(t)}catch{return Buffer.from(t).toString("base64")}},ge=t=>{const e=[],o=(i,s)=>{e.push(`${encodeURIComponent(i)}=${encodeURIComponent(String(s))}`)},n=(i,s)=>{ct(s)&&(Array.isArray(s)?s.forEach(l=>{n(i,l)}):typeof s=="object"?Object.entries(s).forEach(([l,u])=>{n(`${i}[${l}]`,u)}):o(i,s))};return Object.entries(t).forEach(([i,s])=>{n(i,s)}),e.length>0?`?${e.join("&")}`:""},ve=(t,e)=>{const o=t.ENCODE_PATH||encodeURI,n=e.url.replace("{api-version}",t.VERSION).replace(/{(.*?)}/g,(s,l)=>e.path?.hasOwnProperty(l)?o(String(e.path[l])):s),i=`${t.BASE}${n}`;return e.query?`${i}${ge(e.query)}`:i},ye=t=>{if(t.formData){const e=new FormData,o=(n,i)=>{Q(i)||dt(i)?e.append(n,i):e.append(n,JSON.stringify(i))};return Object.entries(t.formData).filter(([n,i])=>ct(i)).forEach(([n,i])=>{Array.isArray(i)?i.forEach(s=>o(n,s)):o(n,i)}),e}},Y=async(t,e)=>typeof e=="function"?e(t):e,Oe=async(t,e)=>{const[o,n,i,s]=await Promise.all([Y(e,t.TOKEN),Y(e,t.USERNAME),Y(e,t.PASSWORD),Y(e,t.HEADERS)]),l=Object.entries({Accept:"application/json",...s,...e.headers}).filter(([u,h])=>ct(h)).reduce((u,[h,y])=>({...u,[h]:String(y)}),{});return st(o)&&(l.Authorization=`Bearer ${o}`),st(n)&&st(i)&&(l.Authorization=`Basic ${fe(`${n}:${i}`)}`),e.body!==void 0&&(e.mediaType?l["Content-Type"]=e.mediaType:dt(e.body)?l["Content-Type"]=e.body.type||"application/octet-stream":Q(e.body)?l["Content-Type"]="text/plain":xt(e.body)||(l["Content-Type"]="application/json")),new Headers(l)},Ae=t=>{if(t.body!==void 0)return t.mediaType?.includes("/json")?JSON.stringify(t.body):Q(t.body)||dt(t.body)||xt(t.body)?t.body:JSON.stringify(t.body)},Se=async(t,e,o,n,i,s,l)=>{const u=new AbortController,h={headers:s,body:n??i,method:e.method,signal:u.signal};return t.WITH_CREDENTIALS&&(h.credentials=t.CREDENTIALS),l(()=>u.abort()),await fetch(o,h)},Ce=(t,e)=>{if(e){const o=t.headers.get(e);if(Q(o))return o}},_e=async t=>{if(t.status!==204)try{const e=t.headers.get("Content-Type");if(e)return["application/json","application/problem+json"].some(o=>e.toLowerCase().startsWith(o))?await t.json():await t.text()}catch(e){console.error(e)}},be=(t,e)=>{const o={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",...t.errors}[e.status];if(o)throw new ot(t,e,o);if(!e.ok)throw new ot(t,e,`Generic Error: status: ${e.status??"unknown"}; status text: ${e.statusText??"unknown"}; body: ${(()=>{try{return JSON.stringify(e.body,null,2)}catch{return}})()}`)},g=(t,e)=>new me(async(o,n,i)=>{try{const s=ve(t,e),l=ye(e),u=Ae(e),h=await Oe(t,e);if(!i.isCancelled){const y=await Se(t,e,s,u,l,h,i),C=await _e(y),S=Ce(y,e.responseHeader),_={url:s,ok:y.ok,status:y.status,statusText:y.statusText,body:S??C};be(e,_),o(_.body)}}catch(s){n(s)}}),Ee=class{static getApiDataAggregation(){return g(m,{method:"GET",url:"/api/DataAggregation",errors:{400:"Depth parameter is no longer supported"}})}},rt=class{static postApiProject({requestBody:t}){return g(m,{method:"POST",url:"/api/Project",body:t,mediaType:"application/json"})}static postApiProjectDemo(){return g(m,{method:"POST",url:"/api/Project/demo"})}static putApiProject({id:t,requestBody:e}){return g(m,{method:"PUT",url:"/api/Project/{id}",path:{id:t},body:e,mediaType:"application/json"})}static deleteApiProject({id:t}){return g(m,{method:"DELETE",url:"/api/Project/{id}",path:{id:t}})}static postApiProjectOpenInVscode({id:t,subPath:e}){return g(m,{method:"POST",url:"/api/Project/{id}/open-in-vscode",path:{id:t},query:{subPath:e},errors:{400:"Invalid project path or sub-path",403:"Sub-path is outside project directory",404:"Project not found",500:"Failed to launch VS Code"}})}static getApiProjectMonospecsManagement({id:t}){return g(m,{method:"GET",url:"/api/Project/{id}/monospecs/management",path:{id:t},errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static putApiProjectMonospecsManagement({id:t,requestBody:e}){return g(m,{method:"PUT",url:"/api/Project/{id}/monospecs/management",path:{id:t},body:e,mediaType:"application/json",errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static postApiProjectMonospecsInitialize({id:t}){return g(m,{method:"POST",url:"/api/Project/{id}/monospecs/initialize",path:{id:t},errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static getApiProjectDesignMd({id:t,repositoryPath:e}){return g(m,{method:"GET",url:"/api/Project/{id}/design-md",path:{id:t},query:{repositoryPath:e},errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static putApiProjectDesignMd({id:t,requestBody:e}){return g(m,{method:"PUT",url:"/api/Project/{id}/design-md",path:{id:t},body:e,mediaType:"application/json",errors:{400:"Bad Request",404:"Not Found",409:"Conflict",500:"Internal Server Error"}})}static getApiProjectDesignMdSiteIndex({id:t}){return g(m,{method:"GET",url:"/api/Project/{id}/design-md/site-index",path:{id:t},errors:{400:"Bad Request",404:"Not Found",502:"Bad Gateway",504:"Gateway Timeout"}})}static getApiProjectDesignMdSiteIndexPreview({id:t,slug:e,theme:o="light"}){return g(m,{method:"GET",url:"/api/Project/{id}/design-md/site-index/{slug}/preview",path:{id:t,slug:e},query:{theme:o},errors:{400:"Bad Request",404:"Not Found",502:"Bad Gateway",504:"Gateway Timeout"}})}static getApiProjectDesignMdSiteIndex1({id:t,slug:e}){return g(m,{method:"GET",url:"/api/Project/{id}/design-md/site-index/{slug}",path:{id:t,slug:e},errors:{400:"Bad Request",404:"Not Found",502:"Bad Gateway",504:"Gateway Timeout"}})}static getApiProjectBranchesValidate({id:t,branchName:e,repositoryPath:o}){return g(m,{method:"GET",url:"/api/Project/{id}/branches/validate",path:{id:t},query:{branchName:e,repositoryPath:o},errors:{400:"Branch name is required",404:"Project not found"}})}static getApiProjectValidatePath({path:t}){return g(m,{method:"GET",url:"/api/Project/validate-path",query:{path:t},errors:{400:"Path parameter is missing or invalid",500:"Internal server error during validation"}})}static postApiProjectScanGitRepos({requestBody:t}){return g(m,{method:"POST",url:"/api/Project/scan-git-repos",body:t,mediaType:"application/json",errors:{400:"Invalid request parameters",500:"Internal server error during scan"}})}static postApiProjectValidateMonospecs({requestBody:t}){return g(m,{method:"POST",url:"/api/Project/validate-monospecs",body:t,mediaType:"application/json",errors:{400:"Invalid request parameters",500:"Internal server error"}})}},V=class{static postApiSessionsAutoTask({requestBody:t}){return g(m,{method:"POST",url:"/api/Sessions/auto-task",body:t,mediaType:"application/json",errors:{400:"Missing required fields or invalid prompt ID",404:"Project not found",500:"Internal server error"}})}static postApiSessionsArchiveChat({sessionId:t}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/archive-chat",path:{sessionId:t},errors:{400:"Session is not a chat session",404:"Session not found",500:"Failed to archive chat session"}})}static postApiSessionsChat({requestBody:t}){return g(m,{method:"POST",url:"/api/Sessions/chat",body:t,mediaType:"application/json",errors:{400:"Bad Request"}})}static postApiSessions({requestBody:t}){return g(m,{method:"POST",url:"/api/Sessions",body:t,mediaType:"application/json",errors:{400:"Bad Request"}})}static getApiSessions({type:t,activeOnly:e,includeArchived:o,projectId:n,projectIds:i}){return g(m,{method:"GET",url:"/api/Sessions",query:{type:t,activeOnly:e,includeArchived:o,projectId:n,projectIds:i}})}static getApiSessions1({sessionId:t}){return g(m,{method:"GET",url:"/api/Sessions/{sessionId}",path:{sessionId:t},errors:{400:"Invalid session ID format",404:"Session not found",500:"Internal server error occurred"}})}static putApiSessions({sessionId:t,requestBody:e}){return g(m,{method:"PUT",url:"/api/Sessions/{sessionId}",path:{sessionId:t},body:e,mediaType:"application/json"})}static deleteApiSessions({sessionId:t,deleteFiles:e=!1}){return g(m,{method:"DELETE",url:"/api/Sessions/{sessionId}",path:{sessionId:t},query:{deleteFiles:e},errors:{404:"Session not found",500:"Failed to delete session"}})}static getApiSessionsMessages({sessionId:t,page:e=1,pageSize:o=50,historyScope:n,order:i="desc"}){return g(m,{method:"GET",url:"/api/Sessions/{sessionId}/messages",path:{sessionId:t},query:{page:e,pageSize:o,historyScope:n,order:i},errors:{404:"Not Found",500:"Internal Server Error"}})}static postApiSessionsMessages({sessionId:t,requestBody:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/messages",path:{sessionId:t},body:e,mediaType:"application/json"})}static postApiSessionsCancel({sessionId:t}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/cancel",path:{sessionId:t},errors:{404:"Session not found",500:"Failed to cancel session"}})}static getApiSessionsProcessingStatus({sessionId:t}){return g(m,{method:"GET",url:"/api/Sessions/{sessionId}/processing-status",path:{sessionId:t},errors:{404:"Session not found",500:"Failed to get processing status"}})}static deleteApiSessionsQueue({sessionId:t,queueIndex:e}){return g(m,{method:"DELETE",url:"/api/Sessions/{sessionId}/queue/{queueIndex}",path:{sessionId:t,queueIndex:e},errors:{400:"Invalid queue index",404:"Session not found",500:"Failed to cancel message"}})}static postApiSessionsAnnotations({sessionId:t,requestBody:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/annotations",path:{sessionId:t},body:e,mediaType:"application/json",errors:{400:"Invalid request or session is not a proposal session",404:"Session not found",500:"Failed to process annotations"}})}static postApiSessionsOptimizeProposal({sessionId:t,requestBody:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/optimize-proposal",path:{sessionId:t},body:e,mediaType:"application/json",errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static postApiSessionsGenerateProposal({sessionId:t,requestBody:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/generate-proposal",path:{sessionId:t},body:e,mediaType:"application/json",errors:{400:"Session is not a proposal session or proposal name not generated",404:"Session not found",500:"Failed to generate proposal"}})}static postApiSessionsArchive({sessionId:t,requestBody:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/archive",path:{sessionId:t},body:e,mediaType:"application/json",errors:{400:"Session is not a proposal session or proposal name missing",404:"Session not found",500:"Failed to archive session"}})}static postApiSessionsExecuteProposal({sessionId:t,requestBody:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/execute-proposal",path:{sessionId:t},body:e,mediaType:"application/json",errors:{400:"Session is not a proposal session, not in valid status, or proposal name missing",404:"Session not found",500:"Failed to execute proposal"}})}static postApiSessionsComplete({sessionId:t}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/complete",path:{sessionId:t},errors:{400:"Session is not in ExecutionCompleted status",404:"Session not found",500:"Failed to complete session"}})}static postApiSessionsValidateExecute({sessionId:t}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/validate-execute",path:{sessionId:t},errors:{404:"Session not found",500:"Failed to validate session"}})}static postApiSessionsValidateStart({sessionId:t}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/validate-start",path:{sessionId:t},errors:{404:"Session not found",500:"Failed to validate session"}})}static postApiSessionsValidateArchive({sessionId:t}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/validate-archive",path:{sessionId:t},errors:{404:"Session not found",500:"Failed to validate session"}})}static getApiSessionsOpenspecFile({sessionId:t,relativePath:e}){return g(m,{method:"GET",url:"/api/Sessions/{sessionId}/openspec-file",path:{sessionId:t},query:{relativePath:e},errors:{404:"Session not found or file not found",500:"Failed to read file"}})}static postApiSessionsUpdateCessionId({sessionId:t}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/update-cession-id",path:{sessionId:t},errors:{404:"Session not found",500:"Failed to update CessionId"}})}static postApiSessionsOpenInVscode({sessionId:t,subPath:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/open-in-vscode",path:{sessionId:t},query:{subPath:e},errors:{400:"Invalid project path or sub-path",403:"Sub-path is outside project directory",404:"Session not found",500:"Failed to launch VS Code"}})}static postApiSessionsCorrectProposalName({sessionId:t,requestBody:e}){return g(m,{method:"POST",url:"/api/Sessions/{sessionId}/correct-proposal-name",path:{sessionId:t},body:e,mediaType:"application/json",errors:{400:"Invalid name format or validation failed",404:"Session not found",409:"Name already in use by another session",500:"Internal server error"}})}static deleteApiSessionsWorkspace({sessionId:t}){return g(m,{method:"DELETE",url:"/api/Sessions/{sessionId}/workspace",path:{sessionId:t},errors:{400:"Session does not have an independent workspace",404:"Session not found",500:"Failed to delete workspace"}})}},F=class{static getApiSkillsLocal(){return g(m,{method:"GET",url:"/api/skills/local"})}static postApiSkillsLocalUninstall({requestBody:t}){return g(m,{method:"POST",url:"/api/skills/local/uninstall",body:t,mediaType:"application/json"})}static getApiSkillsGallery({query:t}){return g(m,{method:"GET",url:"/api/skills/gallery",query:{query:t}})}static getApiSkillsGalleryDetail({id:t,source:e}){return g(m,{method:"GET",url:"/api/skills/gallery/detail",query:{id:t,source:e}})}static getApiSkillsGalleryInstallContext({id:t,source:e}){return g(m,{method:"GET",url:"/api/skills/gallery/install-context",query:{id:t,source:e}})}static getApiSkillsProvidersTrusted(){return g(m,{method:"GET",url:"/api/skills/providers/trusted"})}static postApiSkillsProvidersTrusted({requestBody:t}){return g(m,{method:"POST",url:"/api/skills/providers/trusted",body:t,mediaType:"application/json"})}static deleteApiSkillsProvidersTrusted({requestBody:t}){return g(m,{method:"DELETE",url:"/api/skills/providers/trusted",body:t,mediaType:"application/json"})}static postApiSkillsProvidersTrustedReset(){return g(m,{method:"POST",url:"/api/skills/providers/trusted/reset"})}static postApiSkillsGalleryInstall({requestBody:t}){return g(m,{method:"POST",url:"/api/skills/gallery/install",body:t,mediaType:"application/json"})}static getApiSkillsRecommendationsConfig({locale:t}){return g(m,{method:"GET",url:"/api/skills/recommendations/config",query:{locale:t}})}static postApiSkillsRecommendationsGenerate({requestBody:t}){return g(m,{method:"POST",url:"/api/skills/recommendations/generate",body:t,mediaType:"application/json"})}static postApiSkillsRecommendationsInstall({requestBody:t}){return g(m,{method:"POST",url:"/api/skills/recommendations/install",body:t,mediaType:"application/json"})}static getApiSkillsGalleryInstallStream({id:t,source:e,skillSlug:o,version:n}){return g(m,{method:"GET",url:"/api/skills/gallery/install/stream",query:{id:t,source:e,skillSlug:o,version:n}})}},J=class{static getApiVaults(){return g(m,{method:"GET",url:"/api/vaults"})}static postApiVaults({requestBody:t}){return g(m,{method:"POST",url:"/api/vaults",body:t,mediaType:"application/json",errors:{400:"Bad Request",500:"Internal Server Error"}})}static putApiVaults({id:t,requestBody:e}){return g(m,{method:"PUT",url:"/api/vaults/{id}",path:{id:t},body:e,mediaType:"application/json",errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static deleteApiVaults({id:t,deleteLocalFiles:e=!1}){return g(m,{method:"DELETE",url:"/api/vaults/{id}",path:{id:t},query:{deleteLocalFiles:e},errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static getApiVaultsFiles({id:t,path:e}){return g(m,{method:"GET",url:"/api/vaults/{id}/files",path:{id:t},query:{path:e},errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}static getApiVaultsFilesContent({id:t,path:e}){return g(m,{method:"GET",url:"/api/vaults/{id}/files/content",path:{id:t},query:{path:e},errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}};function Pe(){return{listSessions:t=>V.getApiSessions(t),getSession:t=>V.getApiSessions1({sessionId:t}),createProposalSession:t=>V.postApiSessions({requestBody:t}),createChatSession:t=>V.postApiSessionsChat({requestBody:t}),createAutoTaskSession:t=>V.postApiSessionsAutoTask({requestBody:t}),updateSession:(t,e)=>V.putApiSessions({sessionId:t,requestBody:e}),deleteSession:(t,e)=>V.deleteApiSessions({sessionId:t,deleteFiles:e}),sendMessage:(t,e)=>V.postApiSessionsMessages({sessionId:t,requestBody:e}),optimizeProposal:(t,e)=>V.postApiSessionsOptimizeProposal({sessionId:t,requestBody:e}),generateProposal:(t,e)=>V.postApiSessionsGenerateProposal({sessionId:t,requestBody:e}),executeProposal:(t,e)=>V.postApiSessionsExecuteProposal({sessionId:t,requestBody:e}),archiveProposal:(t,e)=>V.postApiSessionsArchive({sessionId:t,requestBody:e}),completeProposal:t=>V.postApiSessionsComplete({sessionId:t}),submitAnnotations:(t,e)=>V.postApiSessionsAnnotations({sessionId:t,requestBody:e}),listProjects:()=>Ee.getApiDataAggregation(),createProject:t=>rt.postApiProject({requestBody:t}),updateProject:(t,e)=>rt.putApiProject({id:t,requestBody:e}),deleteProject:t=>rt.deleteApiProject({id:t}),listVaults:()=>J.getApiVaults(),createVault:t=>J.postApiVaults({requestBody:t}),updateVault:(t,e)=>J.putApiVaults({id:t,requestBody:e}),deleteVault:(t,e)=>J.deleteApiVaults({id:t,deleteLocalFiles:e}),listVaultFiles:(t,e)=>J.getApiVaultsFiles({id:t,path:e}),previewVaultFile:(t,e)=>J.getApiVaultsFilesContent({id:t,path:e}),archiveChat:t=>V.postApiSessionsArchiveChat({sessionId:t}),listLocalSkills:()=>F.getApiSkillsLocal(),uninstallLocalSkill:t=>F.postApiSkillsLocalUninstall({requestBody:t}),searchSkillGallery:t=>F.getApiSkillsGallery({query:t}),getSkillGalleryDetail:(t,e)=>F.getApiSkillsGalleryDetail({id:t,source:e}),installGallerySkill:t=>F.postApiSkillsGalleryInstall({requestBody:t}),listTrustedSkillProviders:()=>F.getApiSkillsProvidersTrusted(),upsertTrustedSkillProvider:t=>F.postApiSkillsProvidersTrusted({requestBody:t}),deleteTrustedSkillProvider:t=>F.deleteApiSkillsProvidersTrusted({requestBody:t}),resetTrustedSkillProviders:()=>F.postApiSkillsProvidersTrustedReset()}}function A(t){const e=t?.trim();return e||void 0}function x(t,e){const o=A(t);if(!o)throw new $(`${e} is required.`);return o}function kt(t){const e=t?.map(o=>A(o)).filter(Boolean);return e&&e.length>0?e:void 0}function jt(t=process.env,e={stdout:o=>{process.stdout.write(o)},stderr:o=>{process.stderr.write(o)}}){return{api:Pe(),env:t,io:e}}function Te(t){return t.option("--base-url <url>",'Backend API base URL. Overrides HAGI_API_BASE_URL and the "baseUrl" config file entry.').option("--token <token>","Bearer token for backend API calls. Overrides HAGI_API_TOKEN.").option("--lang <lang>","Accept-Language value for backend API calls. Overrides HAGI_API_LANG.")}function P(t){return t.option("--json","Emit deterministic JSON instead of human-readable text.")}function T(t,e){const o=t.optsWithGlobals();return{api:e.api,env:e.env,io:e.io,outputJson:o.json===!0,runtime:de({baseUrl:o.baseUrl,token:o.token,lang:o.lang},e.env)}}function we(t,e){P(t.command("create").description("Create an AutoTask session through the dedicated generated endpoint.")).requiredOption("--title <title>","AutoTask session title.").requiredOption("--project-id <id>","Owning project id.").requiredOption("--prompt-id <id>","Prompt template id.").option("--message <text>","Optional custom message override.").option("--preset-id <id>","Optional preset id.").option("--repository-path <path>","Optional MonoSpecs repository path.").option("--project-ids <ids...>","Optional extra project ids for multi-project flows.").option("--need-push","Request push after commit creation when supported.").option("--target-branch-mode <mode>","Optional target branch mode.").option("--target-branch-name <name>","Optional custom target branch name.").option("--script-key <key>","Optional stable scenario script key.").option("--hero-id <id>","Optional preferred hero id.").option("--target-type <type>","Optional target type for the AutoTask session.").option("--vault-id <id>","Optional vault id for the AutoTask session.").action(async function(n){if(n.targetBranchName&&n.targetBranchMode!=="new-custom")throw new $("--target-branch-name requires --target-branch-mode new-custom.");if(n.targetBranchMode==="new-custom"&&!A(n.targetBranchName))throw new $("--target-branch-name is required when --target-branch-mode is new-custom.");const i=T(this,e),s={title:x(n.title,"--title"),projectId:x(n.projectId,"--project-id"),promptId:x(n.promptId,"--prompt-id"),message:A(n.message),presetId:A(n.presetId),repositoryPath:A(n.repositoryPath),projectIds:kt(n.projectIds),needPush:n.needPush?!0:void 0,targetBranchMode:A(n.targetBranchMode),targetBranchName:A(n.targetBranchName),scriptKey:A(n.scriptKey),heroId:A(n.heroId),targetType:A(n.targetType),vaultId:A(n.vaultId)},l=W(await i.api.createAutoTaskSession(s));if(i.outputJson){i.io.stdout(E({session:l,promptId:s.promptId,requested:s}));return}i.io.stdout(`AutoTask session created
|
|
37
37
|
${z(l,[["promptId",s.promptId],["repositoryPath",s.repositoryPath],["targetBranchMode",s.targetBranchMode],["targetBranchName",s.targetBranchName],["scriptKey",s.scriptKey],["heroId",s.heroId]])}`)})}var et=(function(t){return t.CLAUDE_CODE_CLI="ClaudeCodeCli",t.CODEX_CLI="CodexCli",t.GIT_HUB_COPILOT="GitHubCopilot",t.CODEBUDDY_CLI="CodebuddyCli",t.OPEN_CODE_CLI="OpenCodeCli",t.IFLOW_CLI="IFlowCli",t.HERMES_CLI="HermesCli",t.QODER_CLI="QoderCli",t.KIRO_CLI="KiroCli",t.KIMI_CLI="KimiCli",t.GEMINI_CLI="GeminiCli",t.DEEP_AGENTS_CLI="DeepAgentsCli",t})({}),pt=(function(t){return t.READONLY="Readonly",t.EDIT="Edit",t})({});function Ie(t,e){P(t.command("send").description("Send a follow-up message to an AutoTask session.")).requiredOption("--session-id <id>","AutoTask session id.").requiredOption("--content <text>","Message content.").addOption(new L("--mode <mode>","Message mode override.").choices(Object.values(pt))).addOption(new L("--executor-type <type>","Executor override for this message.").choices(Object.values(et))).action(async function(n){const i=T(this,e),s=n.sessionId.trim(),l=await i.api.sendMessage(s,{content:x(n.content,"--content"),mode:n.mode,executorType:n.executorType});if(i.outputJson){i.io.stdout(E({sessionId:s,message:l.message,requested:{mode:n.mode,executorType:n.executorType}}));return}i.io.stdout(lt("AutoTask message sent",s,l,[["mode",n.mode],["executorType",n.executorType]]))})}function xe(t,e){const o=t.command("autotask").description("Manage AutoTask sessions.");we(o,e),Ie(o,e)}function ke(t,e){P(t.command("archive").description("Archive a chat session through the dedicated chat archive endpoint.")).requiredOption("--session-id <id>","Chat session id to archive.").action(async function(n){const i=T(this,e),s=n.sessionId.trim(),l=await i.api.archiveChat(s);if(i.outputJson){i.io.stdout(E({sessionId:s,message:l.message}));return}i.io.stdout(`Chat archived
|
|
38
38
|
sessionId ${s}
|
|
39
39
|
message ${l.message}
|
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./chunks/main-
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./chunks/main-C1tXh2Yv.js");s.runCli().then(e=>{e!==0&&(process.exitCode=e)}).catch(e=>{const n=e instanceof Error?e.stack??e.message:String(e);process.stderr.write(`${n}
|
|
3
3
|
`),process.exitCode=s.EXIT_CODES.UNKNOWN});
|
package/dist/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/main-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/main-C1tXh2Yv.js");exports.createCliApp=e.createCliApp;exports.runCli=e.runCli;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hagicode/cli",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.19.1.7d58d9d",
|
|
4
4
|
"description": "HagiCode CLI for project, proposal, vault, chat, and AutoTask management.",
|
|
5
5
|
"homepage": "https://github.com/HagiCode-org/cli#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"openapi-typescript-codegen": "^0.29.0",
|
|
62
62
|
"rimraf": "^6.1.2",
|
|
63
63
|
"tsx": "^4.20.6",
|
|
64
|
-
"typescript": "^
|
|
64
|
+
"typescript": "^6.0.3",
|
|
65
65
|
"vite": "^8.0.3",
|
|
66
66
|
"vitest": "^4.1.1"
|
|
67
67
|
}
|