@aventurevc/aventure-cli 0.7.301 → 0.7.328
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.
- package/README.md +6 -4
- package/dist/aventure-cli/command-catalog.compact.txt +121 -106
- package/dist/aventure-cli/index.js +1 -1
- package/dist/aventure-cli/unified-operations.json +914 -1420
- package/dist/chunks/auth-B_0cUOPk.js +114 -0
- package/dist/chunks/aventure-cli-DaJTB05k.js +74 -0
- package/dist/chunks/detail-D4XYLrLh.js +1 -0
- package/dist/chunks/index.node-Dqukns1W.js +1 -0
- package/dist/chunks/oauth-bearer-credential-C-EZmWvX.js +4 -0
- package/dist/chunks/oauth-login-C3Cr4IJb.js +1 -0
- package/dist/chunks/oauth-login-qlqzOJeW.js +6 -0
- package/dist/chunks/openapi-commands-C70h-zCn.js +1 -0
- package/dist/chunks/{person-owner-ChqQWHII.js → person-owner-BqBLyw4S.js} +5 -4
- package/dist/chunks/text-field-_7ZvrzAF.js +1 -0
- package/dist/chunks/text-response-DDwkjRpA.js +5 -0
- package/package.json +3 -3
- package/scripts/install-zsh-completion-loader.mjs +37 -4
- package/dist/chunks/auth-DIikL8AE.js +0 -114
- package/dist/chunks/aventure-cli-dQwsB1r3.js +0 -73
- package/dist/chunks/detail-DeMsv_6C.js +0 -1
- package/dist/chunks/index.node-LwG3axmM.js +0 -1
- package/dist/chunks/mcp-generation-contract-BdBNx3qx.js +0 -4
- package/dist/chunks/oauth-credential-BwiTQED3.js +0 -2
- package/dist/chunks/oauth-login-CDzQlEcb.js +0 -1
- package/dist/chunks/oauth-login-DlCQkNvx.js +0 -5
- package/dist/chunks/openapi-commands-BtFm7m9T.js +0 -3
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{D as e,at as t,j as n,k as r}from"./auth-B_0cUOPk.js";import{C as i,a,c as o,v as s}from"./person-owner-BqBLyw4S.js";import{a as c,i as l,n as u,t as d}from"./text-field-_7ZvrzAF.js";function f(e,t,n=t.inputName){if(t.in===`body`)return n;let r=re.find(t=>n===t.name&&e.path.includes(t.path));return r===void 0?y(v(n!==`id`&&n!==`slug`?n:`${h(e.path)}${_(n)}`),t):r.inputName}function p(e,t,n=ee(e)){return m(g(e,t),new Set(n))}function m(e,t){if(!t.has(e))return e;let n=`body${_(e)}`,r=n;for(let e=2;t.has(r);e+=1)r=`${n}${e}`;return r}function h(e){return ie.find(([,t])=>t.test(e))?.[0]??`record`}function g(e,t){if(t.name===`id`&&e.path===`/v1/app/url-slug-redirects`)return`recordId`;let n=te(t);return y(e.intent===`search`&&(t.name.startsWith(`filter.`)||t.name.startsWith(`search.`))?v(n.replace(/^(?:filter|search)/u,``).replace(/^./u,e=>e.toLowerCase())):n,t)}function ee(e){return new Set(e.parameter.filter(e=>e.in===`path`||e.in===`query`||e.in===`header`).map(t=>f(e,t)))}function _(e){return e.replace(/^./u,e=>e.toUpperCase())}function v(e){return e.replace(/^addressAddress/u,`address`).replace(/^arrayFilterAmountInvestedRange/u,`fundraiseAmountInvestedRange`).replace(/^arrayFilterAmountRaisedRange/u,`fundraiseAmountRaisedRange`).replace(/^arrayFilterEntityName$/u,`entityName`).replace(/^arrayFilterInvestedCompany$/u,`fundraiseInvestedCompanyName`).replace(/^arrayFilterPersonTitle$/u,`personTitle`).replace(/^arrayFilterRound$/u,`fundraiseRound`).replace(/^arrayFilterTotalInvestmentCount/u,`totalInvestmentCount`).replace(/^arrayFilterTypeRecord$/u,`typeRecord`).replace(/^createEntity/u,`entity`).replace(/^createUrlLink/u,`urlLink`).replace(/^fundraiseActivity/u,`fundraise`).replace(/FundraiseActivity/gu,`Fundraise`).replace(/^logoOption/u,`logo`).replace(/LogoOption/gu,`Logo`).replace(/^researchDetailTypeResearchDetail$/u,`researchDetailType`).replace(/^researchDetailValueResearchDetail$/u,`researchDetailValue`).replace(/^textText$/u,`text`).replace(/^textTextName$/u,`textName`).replace(/^textTextType$/u,`textType`)}function te(e){let t=v(e.inputName);return/(?:^|\.)nameAlias\[\]\./u.test(e.name)?t.replace(/^entityNameAlias/u,`alias`):/(?:^|\.)urlLink\[\]\./u.test(e.name)?ne(t):/(?:^|\.)manualLogo\./u.test(e.name)?t.replace(/^manualLogo/u,`logo`):t}function ne(e){return e===`urlLinkUrl`?`url`:e===`urlLinkUrlType`?`urlType`:e.replace(/^urlLink/u,`url`)}function y(e,t){return e===`text`?/(?:^|\.)text(?:\[\])?\.text$/u.test(t.name)?`textBody`:`inputText`:e}var re=[{name:`detailId`,path:`/research-details/{detailId}`,inputName:`researchDetailId`},{name:`version`,path:`/instructions/`,inputName:`instructionVersion`},{name:`detailId`,path:`/financial/valuation/{detailId}`,inputName:`valuationDetailId`},{name:`joinId`,path:`/fundraise-investor-joins`,inputName:`fundraiseInvestorJoinId`}],ie=[[`entity`,/^\/v1\/entities(?:$|\/detail|\/lookup|\/summary|\/duplicate-check)/u],[`person`,/^\/v1\/people(?:\/detail|\/lookup|\/duplicate-check|\/\{slug\})/u],[`news`,/^\/v1\/(?:news\/|jobs\/news\/)/u],[`screenshot`,/^\/v1\/media\/screenshots\//u],[`media`,/^\/v1\/media/u],[`article`,/^\/v1\/app\/blog\/articles/u],[`page`,/^\/v1\/app\/pages/u],[`contact`,/^\/v1\/contacts\//u],[`provenance`,/^\/v1\/provenance\//u],[`location`,/^\/v1\/addresses\/locations\//u]];function ae(e){let t=e.requestBody?.[0],n=e.parameter.map(t=>b(t,f(e,t))),r=(t?.parameter??[]).map(t=>b(t,p(e,t)));return{selector:n.filter(e=>e.location===`path`||x(e)),pagination:n.filter(S),filter:[...n.filter(C),...r.filter(C)],body:r.filter(e=>!C(e))}}function b(e,t){return{name:e.in===`body`?t:e.name,flag:r(t),required:e.required,location:e.in,description:e.description||`${e.name} ${e.in} parameter`}}function x(e){return/(^|[A-Z])(id|slug)$/u.test(e.name)}function S(e){return[`page`,`size`,`sort`,`cursor`,`mode`,`projection`].includes(e.name)}function C(e){return e.location!==`path`&&!x(e)&&!S(e)}var w=`aventure`,oe={high:60,medium:30},se={high:20,medium:10};function ce(e){let{contract:t,guidance:r,enumQueryFlag:i}=e,a=t.requestBody?.[0],o=i?.inputName??null,s=D(t.parameter,o),c=D(a?.parameter??[],null),l=s.map(e=>fe(t,e)),u=c.map(e=>pe(t,e)),d=a?.requiredPath??[],f=new Set((a?.parameter??[]).map(({name:e})=>e)),m=d.filter(e=>!f.has(e)&&!c.some(({name:t})=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`))),h=a?.required===!0&&a.kind===`json`&&(u.length===0||m.length>0),g=[w,...t.projection.cliPath,...i===null?[]:[i.flag],...l,...u,...h?[`--from-file "<path>"`]:[]];return{intent:t.intent,operationId:t.operationId,recommendedCommand:g.join(` `),useFor:r.useFor,notFor:r.notFor,apiRoute:`${t.method} ${t.path}`,mcpTool:n(t.intent),missingInputs:[...s.map(e=>e.name),...c.map(e=>p(t,e)),...m,...h?[`fromFile`]:[]],pathInput:E(t.parameter,`path`),queryInput:E(t.parameter,`query`),bodyInput:(a?.parameter??[]).map(e=>e.name),operationDescription:t.description,bodySchemaName:a?.schemaName??null,bodyKind:a?.kind??null,bodyRequired:a?.required??!1,requiredBodyPath:d,confidence:e.confidence,alternatives:e.alternatives}}function le(e){let t=T(e.description);return{useFor:t.useFor||e.summary||e.description||`${e.method} ${e.path}`,notFor:t.notFor||`See operation description`}}function T(e){let t=e.match(/USE FOR:\s*([\s\S]*?)(?:NOT FOR:|$)/iu),n=e.match(/NOT FOR:\s*([\s\S]*?)$/iu);return{useFor:t?.[1]?.trim()??``,notFor:n?.[1]?.trim()??``}}function ue(e,t){if(e===0)return`low`;let n=e-t;return e>=oe.high&&n>=se.high?`high`:e>=oe.medium&&n>=se.medium?`medium`:`low`}function de(e,t,n=[]){return{intent:`unknown`,operationId:``,recommendedCommand:``,useFor:e,notFor:t,apiRoute:``,mcpTool:``,missingInputs:n,pathInput:[],queryInput:[],bodyInput:[],operationDescription:``,bodySchemaName:null,bodyKind:null,bodyRequired:!1,requiredBodyPath:[],confidence:`low`,alternatives:[]}}function E(e,t){return e.flatMap(e=>e.in===t?(e.itemProperty??[e]).map(e=>e.name):[])}function D(e,t){return e.filter(e=>e.required&&e.schemaDefault===void 0&&(t===null||e.inputName!==t))}function fe(t,n){let i=f(t,n),a=`${i}${n.schemaType===`array`?`...`:``}`;return`${r(i)} ${e(`<${a}>`)}`}function pe(t,n){let i=p(t,n),a=`${i}${n.schemaType===`array`?`...`:``}`;return`${r(i)} ${e(`<${a}>`)}`}var O=2,me=new Set(`a.an.the.and.or.for.to.of.in.on.at.by.with.from.into.is.are.be.do.does.how.what.which.that.this.these.those.i.me.my.we.our.you.your.it.its.please.want.need.can.could.should.would`.split(`.`)),he=new Set([`delete`,`remove`,`destroy`,`purge`,`erase`,`drop`,`detach`,`unlink`]),ge=new Set([`create`,`add`,`update`,`edit`,`set`,`change`,`modify`,`upload`,`attach`,`merge`,`link`,`join`,`write`,`import`,`publish`,`verify`]),_e=new Set([`list`,`get`,`show`,`view`,`browse`,`fetch`,`read`,`lookup`,`find`,`count`,`inspect`]);function ve(e){let t=t=>[...e].some(e=>t.has(e));return t(he)?`delete`:t(ge)?`write`:t(_e)?`read`:`neutral`}function k(e,t){let n=N(t);n.length!==0&&(e.add(n),(n===`individual`||n===`individuals`)&&k(e,`person`),A(e,ye(n),n),A(e,be(n),n))}function ye(e){if(e===`people`)return`person`;let t=e.endsWith(`ies`)?e.slice(0,-3):``;if(t.length>=O&&!t.endsWith(`v`)&&/[^aeiou]$/u.test(t))return`${e.slice(0,-3)}y`;if(e.length>O&&e.endsWith(`s`)&&!e.endsWith(`ss`)&&!e.endsWith(`us`)&&e!==`news`)return e.slice(0,-1)}function be(e){return e===`person`?`people`:e.length>=O&&e.endsWith(`y`)&&/[^aeiou]y$/u.test(e)?`${e.slice(0,-1)}ies`:e.endsWith(`s`)?void 0:`${e}s`}function A(e,t,n){t!==void 0&&t!==n&&t.length>=O&&/^[a-z]+$/u.test(t)&&e.add(t)}function j(e){let t=new Set(M(e)),n=Array.from(t);for(let e of n)k(t,e);return t}function xe(e){return M(e).map(j)}function Se(e,t){if(e.length===0)return!1;let n=j(t.join(` `));return e.every(e=>[...e].some(e=>n.has(e)))}function M(e){return N(e).split(/[^a-z0-9]+/u).filter(e=>e.length>0&&!me.has(e))}function N(e){return e.trim().replace(/([a-z0-9])([A-Z])/gu,`$1 $2`).replace(/[_-]/gu,` `).replace(/\s+/gu,` `).toLowerCase()}var Ce=20,we=15,Te=30,Ee=2;function P(e,t,n){let r=N(e.trim());if(r.length===0)return t.map(e=>({item:e,score:1}));let i=j(r),a=xe(r);return t.map(e=>{let t=n(e);return{item:e,fields:t,score:je(r,i,a,t)}}).filter(({score:e})=>e>0).toSorted((e,t)=>Number(e.fields.deprecated===!0)-Number(t.fields.deprecated===!0)||t.score-e.score||e.fields.cliPath.length-t.fields.cliPath.length||e.fields.cliPath.join(` `).localeCompare(t.fields.cliPath.join(` `))||e.fields.operationId.localeCompare(t.fields.operationId)).map(({item:e,score:t})=>({item:e,score:t}))}function De(e){return{...e,cliPath:e.projection.cliPath,enumParameter:e.parameter.map(e=>({values:e.itemSchemaEnum??e.schemaEnum??[],direct:e.name===e.inputName})),parameterName:e.parameter.flatMap(e=>[e.name,e.inputName]),parameterDescription:[...e.parameter,...e.requestBody??[],...(e.requestBody??[]).flatMap(e=>e.parameter)].map(({description:e})=>e)}}function Oe(e,t){let n=e.q?.trim()??``,r=P(n,t.filter(t=>ke(e,t)),De).map(({item:e,score:t})=>({contract:e,score:t})),i=r.map(({contract:e})=>e),a=e.limit===void 0||!Number.isFinite(e.limit)?Ce:e.limit,o=Math.min(i.length,Math.max(0,Math.trunc(a)));if(e.resolve!==!0){let e=r.slice(0,o).map(({contract:e})=>Ae(e));return{summary:`Operation catalog matches`,data:e,counts:{totalOperations:t.length,matched:i.length,returned:e.length}}}if(n.length===0)return F(t.length,i.length,`Provide q to get a generated command recommendation`,`Catalog listing; omit resolve to browse operations`,[`q`]);let s=j(N(n)),c=ve(s),l=r.filter(({contract:e})=>c===`delete`?!0:e.intent===`delete`||e.projection.destructive?!1:c!==`read`||e.projection.scope!==`write`).toSorted((e,t)=>t.score-e.score||Number(e.contract.projection.scope===`write`)-Number(t.contract.projection.scope===`write`)||e.contract.path.length-t.contract.path.length||e.contract.operationId.localeCompare(t.contract.operationId)),u=l[0];if(u===void 0)return F(t.length,i.length,`No generated operation matched this query`,`See generated operation descriptions`);let d=l.slice(1).map(({contract:e})=>`${w} ${e.projection.cliPath.join(` `)}`).filter((e,t,n)=>n.indexOf(e)===t).slice(0,2),f=u.contract;return{summary:`How-to command recommendation`,data:ce({contract:f,guidance:le(f),confidence:ue(u.score,l[1]?.score??0),alternatives:d,enumQueryFlag:Ie(s,f)}),counts:{totalOperations:t.length,matched:i.length,returned:1}}}function F(e,t,n,r,i=[]){return{summary:`How-to command recommendation`,data:de(n,r,i),counts:{totalOperations:e,matched:t,returned:0}}}function ke(e,t){let n=e.root?.trim().toLowerCase();return!(e.method!==void 0&&t.method!==e.method||e.scope!==void 0&&t.projection.scope!==e.scope||n&&t.resource!==n&&t.projection.cliPath[0]!==n)}function Ae(e){let t=e.requestBody?.[0];return{operationId:e.operationId,method:e.method,path:e.path,cli:e.projection.cliPath.join(` `),resource:e.resource,intent:e.intent,scope:e.projection.scope,bodySchemaName:t?.schemaName??null,bodyKind:t?.kind??null,bodyRequired:t?.required??!1,requiredBodyPath:t?.requiredPath??[],argument:ae(e)}}function je(e,t,n,r){let i=Pe(r),a=Me(r),o=0;i.some(t=>t===e)&&(o+=100),i.some(t=>t.includes(e))&&(o+=40),o+=Ne(e,i);let s=new Set(i.flatMap(M));for(let e of t)i.some(t=>t===e)?o+=20:s.has(e)&&(o+=8);for(let e of r.cliPath){let n=new Set;k(n,e),[...n].some(e=>t.has(e))&&(o+=we)}Se(n,a)&&(o+=200),r.parameterName.some(t=>N(t)===e)&&(o+=Te);let c=new Set(r.parameterDescription.flatMap(M));for(let e of t)c.has(e)&&(o+=Ee);return o+=Re(t,r.enumParameter),[`list`,`search`,`find`,`browse`].some(e=>t.has(e))&&/^(?:list|search)[A-Z]/u.test(r.operationId)&&(o+=30),o-=Fe(e,t,r.description),o}function Me(e){return[e.operationId,e.cliPath.join(` `),e.summary].map(N).filter(e=>e.length>0)}function Ne(e,t){let n=M(e),r=0;for(let e=0;e<n.length-1;e+=1){let i=n.slice(e,e+2).join(` `);t.some(e=>e.includes(i))&&(r+=24)}return r}function Pe(e){return[...new Set([e.operationId,e.method,e.path,e.resource,e.intent,e.cliPath.join(` `),e.summary,T(e.description).useFor||e.description].map(N).filter(e=>e.length>0))]}function Fe(e,t,n){let r=N(T(n).notFor);if(r.length===0)return 0;let i=r.includes(e)?40:0,a=new Set(M(r));for(let e of t)r===e?i+=20:a.has(e)&&(i+=8);return i}function Ie(t,n){for(let i of n.parameter){if(i.in!==`query`)continue;let a=Le(t,i);if(a!==null){let t=f(n,i);return{inputName:i.inputName,flag:`${r(t)} ${e(a,i.schemaType,i.itemSchemaType)}`}}}return null}function Le(e,t){return(t.itemSchemaEnum??t.schemaEnum??[]).find(t=>ze(e,t))??null}function Re(e,t){let n=0;for(let{values:r,direct:i}of t)r.some(t=>ze(e,t))&&(n+=i?40:10);return n}function ze(e,t){let n=M(t);return n.length>0&&n.every(t=>e.has(t))}var Be=a([`HIGH`,`MEDIUM`,`LOW`]),Ve=a([`OPERATION`,`SKILL`,`PROMPT`,`COMPLETION_GATE`,`RESEARCH_DETAIL_TYPE`]),He=s({excerpt:i(),sourceId:i(),sourceType:Ve,sourceVersion:i().nullish()}),Ue=s({answer:i(),citation:o(He),confidence:Be}),We=a([`auto`,`exact`,`keyword`,`semantic`,`natural`]),Ge=s({modeRequested:We,modeUsed:We}),I=120,L=30,R=8,z=10,Ke=2,qe=[`id`,`association.associationId`,`slug`,`name`,`nameBrand`,`nameFull`,`core.nameBrand`,`core.nameFull`,`core.slug`,`core.typeRecord`,`entity.core.nameBrand`,`entity.core.slug`,`title`,`sourceName`,`publishedAt`,`round`,`dateAnnounced`,`amountRaised`,`investorAttribution.amountInvested`,`stage`,`updatedAt`,`createdAt`],Je=new Set([`page`,`size`,`sort`,`cursor`,`mode`,`projection`]),B=[`interpretation`,`confidence`,`unsupported`,`execution`,`fallbackUsed`],Ye=new Map(c.map(({operationId:e,projection:t})=>[e,`${w} ${t.cliPath.join(` `)}`]));function Xe(e,t){if(typeof e==`string`)return e;let n=U(e);if(n===null)return null;let{response:r,hiddenNote:i}=l(n.operationId,n.response),a={...n,response:r},o=at(a.response);if(o!==null)return`${ft(o).join(`
|
|
2
|
+
`)}\n`;let s=a.summary??t??a.operationId??`OpenAPI call succeeded`,c=$e(a);return`${[...ft([s,`${a.method} ${a.endpoint}`,...c].filter(e=>e.length>0)),...i].join(`
|
|
3
|
+
`)}\n`}function Ze(e){let t=U(e)?.response,n=t!==void 0&&X(t)?t.interpretation:void 0;if(n===void 0||!X(n))return null;let r=Ge.safeParse(n.execution);if(!r.success)return null;let{modeRequested:i,modeUsed:a}=r.data,o=K(n.filter??null),{unsupported:s,fallbackUsed:c}=n;return`${[`strategy: requested=${i} used=${a}`,...o!==void 0&&X(o)?[`constraints:`,...Object.entries(o).map(([e,t])=>` ${e}: ${Qe(t)}`)]:[],typeof s==`string`&&s.trim().length>0?`unsupported: ${s}`:``,c===!0?`fallback: semantic search over the original query`:``].filter(Boolean).join(`
|
|
4
|
+
`)}\n`}var Qe=e=>Z(e)?u(e):Array.isArray(e)&&e.every(Z)?e.map(e=>u(e)).join(`, `):JSON.stringify(e);function $e(e){let{response:t,method:n,endpoint:r,nextCursor:i,httpStatus:a}=e;if(t===void 0)return a===void 0?[]:[`status=${a} no response body`];let o=a===void 0||n===`GET`?``:`status=${a}`,s=X(t)&&!J(t)?ot(t):null,c=s===null?void 0:it(s.context)?K(s.context):s.context;return[o,...J(t)?V(t,r,i):s===null?ct(t)?H(t.filter,t.meta):lt(t)?H([...t.arrayFilterEntry,...t.rangeFilterEntry],t.filtersMeta):ut(t)?nt(t):W(t,``):[...V(s.page,r,i),...c===void 0?[]:W(c,``)]].filter(Boolean)}function V(e,t,n){let r=rt(t),i=e.numberOfElements??e.content.length;return[`rows=${i} page=${e.number??0} size=${e.size??i} total=${e.totalElements??i}${e.totalPages===void 0?``:` totalPages=${e.totalPages}`}`,r.length>0?`filters: ${r.join(` `)}`:``,n===void 0?``:`next: --cursor ${$(n)}`,...et(e.content)].filter(Boolean)}function et(e){let t=e.filter(X);if(t.length===0)return e.length===0?[`(empty)`]:G(e,``);let n=tt(t);if(n.length===0)return G(e.slice(0,L),``);let r=t.slice(0,L).map(e=>{let t=q(e);return n.map(e=>t[e]??``)}),i=n.map(e=>e.split(`.`).at(-1)??e),a=i.map((e,t)=>{let n=r.map(e=>e[t]??``),i=Math.max(e.length,...n.map(e=>e.length));return e===`id`||e.endsWith(`Id`)?i:Math.min(32,i)}),o=e=>e.map((e,t)=>dt(e,a[t]??12).padEnd(a[t]??12)).join(` `),s=[o(i),o(a.map(e=>`-`.repeat(e)))];return r.forEach(e=>s.push(o(e))),t.length>L&&s.push(`... ${t.length-L} more rows`),s}function tt(e){let t=new Set(e.flatMap(e=>Object.keys(q(e)))),n=qe.filter(e=>t.has(e)),r=[...t].filter(e=>!n.includes(e)).filter(e=>!e.toLowerCase().includes(`logo`)).slice(0,R-n.length);return[...n,...r].slice(0,R)}function H(e,t){let n=t!==void 0&&X(t)?t:{},r=[`total`,`limit`].flatMap(e=>typeof n[e]==`number`?[` ${e}=${n[e]}`]:[]).join(``),i=[`filters=${e.length}${r}`];for(let t of e){let e=t.choiceOption.length,n=t.choiceOptionTotal===null?`unknown (degraded)`:t.choiceOptionTotal??e,r=t.choiceOptionTruncated===!0?` truncated`:``;i.push(`- ${t.filterKey} (${t.label}): choices ${e}/${n}${r}`),t.choiceOption.slice(0,z).forEach(e=>{i.push(` ${Q(t.filterKey)} ${$(e.value)}`)}),e>z&&i.push(` ... ${e-z} more shown`)}return i}function nt(e){let t=Q(e.filterKey);return[`${e.filterKey}: ${e.result.length} matches`,...e.result.slice(0,z).map(e=>`${t} ${$(e)}`),e.result.length>z?`... ${e.result.length-z} more matches`:``].filter(Boolean)}function rt(e){let t=e.indexOf(`?`);return t<0?[]:[...new URLSearchParams(e.slice(t+1)).entries()].filter(([e,t])=>!Je.has(e)&&t.length>0).map(([e,t])=>`${Q(e)} ${$(t)}`)}function U(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let n=Reflect.get(e,`method`),r=Reflect.get(e,`endpoint`);if(typeof n!=`string`||typeof r!=`string`)return null;let i=Reflect.get(e,`operationId`),a=Reflect.get(e,`summary`),o=Reflect.get(e,`httpStatus`),s=Reflect.get(e,`nextCursor`),c=Reflect.get(e,`response`),l=c===void 0?void 0:t.safeParse(c);return l!==void 0&&!l.success?null:{method:n,endpoint:r,httpStatus:typeof o==`number`?o:void 0,operationId:typeof i==`string`?i:void 0,summary:typeof a==`string`?a:void 0,nextCursor:typeof s==`string`&&s.length>0?s:void 0,response:l?.data}}function W(e,t,n){if(e===void 0)return[];if(Z(e))return[`${t}${d(e,n)}`];if(Array.isArray(e))return G(e,t,n);let r=[];for(let[n,i]of Object.entries(e)){if(Z(i)){r.push(`${t}${n}: ${d(i,n)}`);continue}r.push(`${t}${n}:`);for(let e of W(i,`${t} `,n))r.push(e)}return r.length===0?[`${t}(empty)`]:r}function G(e,t,n){if(e.length===0)return[`${t}(empty)`];let r=[];for(let i of e){if(Z(i)){r.push(`${t}- ${d(i,n)}`);continue}r.push(`${t}-`);for(let e of W(i,`${t} `))r.push(e)}return r}function it(e){let t=e.interpretation;return t!==void 0&&X(t)}function K(e){if(Z(e))return e===null||typeof e==`string`&&e.trim().length===0?void 0:e;if(Array.isArray(e)){let t=e.flatMap(e=>{let t=K(e);return t===void 0?[]:[t]});return t.length===0?void 0:t}let t=Object.entries(e).flatMap(([e,t])=>{let n=K(t);return n===void 0?[]:[[e,n]]});if(t.length!==0)return Object.fromEntries([...B.flatMap(e=>t.filter(([t])=>t===e)),...t.filter(([e])=>!B.includes(e))])}function at(e){let t=Ue.safeParse(e);if(!t.success)return null;let{answer:n,citation:r,confidence:i}=t.data,a=n.trimEnd().split(`
|
|
5
|
+
`),o=new Set(r.flatMap(({sourceType:e,sourceId:t})=>{if(e!==Ve.enum.OPERATION)return[];let n=Ye.get(t);return n===void 0?[]:[n]}));return o.size>0&&a.push(``,`Commands:`,...[...o].map(e=>` ${e}`)),a.push(``,`Confidence: ${i}`),r.length===0?a:(a.push(`Sources (${r.length}):`),a.push(...r.map(({excerpt:e,sourceId:t})=>{let n=e.trim();return n.length>0?` - ${t}: ${n}`:` - ${t}`})),a)}function q(e,t=``,n=0){return Z(e)?t.length===0?{}:{[t]:u(e,t)}:n>Ke?{}:Array.isArray(e)?e.length===0?{}:q(e[0],t,n+1):Object.fromEntries(Object.entries(e).flatMap(([e,r])=>{let i=t.length===0?e:`${t}.${e}`;return Z(r)?[[i,u(r,i)]]:Object.entries(q(r,i,n+1))}))}var J=e=>X(e)&&Array.isArray(e.content);function ot(e){let[t,...n]=Object.entries(e).filter(e=>J(e[1])&&typeof e[1].totalElements==`number`);if(t===void 0||n.length>0)return null;let[r,i]=t;return{page:i,context:Object.fromEntries(Object.entries(e).filter(([e])=>e!==r))}}function st(e){return X(e)&&typeof e.label==`string`&&typeof e.filterKey==`string`&&Array.isArray(e.choiceOption)}var ct=e=>X(e)&&Y(e.filter),lt=e=>X(e)&&Y(e.arrayFilterEntry)&&Y(e.rangeFilterEntry),Y=e=>Array.isArray(e)&&e.every(st),ut=e=>X(e)&&typeof e.filterKey==`string`&&Array.isArray(e.result)&&e.result.every(e=>typeof e==`string`),X=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Z=e=>typeof e!=`object`||!e,Q=e=>`--${e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}`,$=e=>/^[A-Za-z0-9._:/@-]+$/.test(e)?e:`'${e.replaceAll(`'`,`'\\''`)}'`,dt=(e,t)=>e.length<=t?e:`${e.slice(0,Math.max(0,t-3))}...`,ft=e=>e.length<=I?e:[...e.slice(0,I),`... ${e.length-I} more lines`];export{k as a,Oe as i,Ze as n,N as o,P as r,Xe as t};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aventurevc/aventure-cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.328",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Public aVenture CLI.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
},
|
|
33
33
|
"aventurePublicApi": {
|
|
34
34
|
"repository": "aventurevc/aventure-docs",
|
|
35
|
-
"commit": "
|
|
35
|
+
"commit": "6f6b3be1bc8aec078690459c51201879a15e12ac",
|
|
36
36
|
"openapiPath": "openapi/openapi.json",
|
|
37
|
-
"openapiSha256": "
|
|
37
|
+
"openapiSha256": "345479b3070ce92fe26597ac37efc25c0a5c8231e6ab9a2ae602c602f0829dde"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {}
|
|
40
40
|
}
|
|
@@ -15,12 +15,18 @@ import { delimiter, dirname, isAbsolute, join } from "node:path";
|
|
|
15
15
|
import process from "node:process";
|
|
16
16
|
import { fileURLToPath } from "node:url";
|
|
17
17
|
|
|
18
|
+
// Keeps the pre-`avctl` name: it identifies managed loaders that earlier releases already wrote.
|
|
18
19
|
const MARKER_PREFIX = "# aventure-cli completion loader";
|
|
19
20
|
const BACKUP_SUFFIX = ".aventure-cli-completion.bak";
|
|
20
21
|
const CLI_BIN_TARGET = "dist/aventure-cli/index.js";
|
|
21
22
|
const PACKAGE_ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
22
23
|
const PACKAGE_CLI_BIN = join(PACKAGE_ROOT, CLI_BIN_TARGET);
|
|
23
24
|
const PACKAGE_JSON = join(PACKAGE_ROOT, "package.json");
|
|
25
|
+
const GITHUB_PACKAGES_REGISTRY = "https://npm.pkg.github.com/";
|
|
26
|
+
// The private package renamed its command from `aventure-cli` to `avctl`, and loaders are named
|
|
27
|
+
// after commands, so the old private package's managed loaders would outlive it. Only the private
|
|
28
|
+
// package retires them: the public package never shipped `aventure-cli`.
|
|
29
|
+
const RETIRED_PRIVATE_CLI_BINS = ["aventure-cli"];
|
|
24
30
|
|
|
25
31
|
/** @param {string | undefined} value */
|
|
26
32
|
function isTruthy(value) {
|
|
@@ -41,18 +47,40 @@ function resolveConfigHome(env) {
|
|
|
41
47
|
return home ? join(home, ".config") : null;
|
|
42
48
|
}
|
|
43
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {{
|
|
52
|
+
* bin?: Record<string, string>;
|
|
53
|
+
* aventurePublish?: { variants?: { cli?: { bin?: Record<string, string> } } };
|
|
54
|
+
* publishConfig?: { registry?: string };
|
|
55
|
+
* }} InstallerPackageJson
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/** @returns {InstallerPackageJson} */
|
|
44
59
|
function readPackageJson() {
|
|
45
60
|
return JSON.parse(readFileSync(PACKAGE_JSON, "utf8"));
|
|
46
61
|
}
|
|
47
62
|
|
|
48
|
-
|
|
49
|
-
|
|
63
|
+
/** @param {InstallerPackageJson} packageJson */
|
|
64
|
+
function cliBins(packageJson) {
|
|
50
65
|
const cliBinMap = packageJson.aventurePublish?.variants?.cli?.bin ?? packageJson.bin ?? {};
|
|
51
66
|
return Object.entries(cliBinMap).flatMap(([bin, target]) =>
|
|
52
67
|
target === CLI_BIN_TARGET ? [bin] : [],
|
|
53
68
|
);
|
|
54
69
|
}
|
|
55
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Retired bins this package no longer ships. A working tree has no publishConfig and builds the
|
|
73
|
+
* private package.
|
|
74
|
+
*
|
|
75
|
+
* @param {InstallerPackageJson} packageJson
|
|
76
|
+
* @param {readonly string[]} bins
|
|
77
|
+
*/
|
|
78
|
+
function retiredBins(packageJson, bins) {
|
|
79
|
+
const registry = packageJson.publishConfig?.registry ?? GITHUB_PACKAGES_REGISTRY;
|
|
80
|
+
if (registry !== GITHUB_PACKAGES_REGISTRY) return [];
|
|
81
|
+
return RETIRED_PRIVATE_CLI_BINS.filter((bin) => !bins.includes(bin));
|
|
82
|
+
}
|
|
83
|
+
|
|
56
84
|
/** @param {string} value */
|
|
57
85
|
function shellSingleQuote(value) {
|
|
58
86
|
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
@@ -243,8 +271,10 @@ function installTargets(bins, env, platformName) {
|
|
|
243
271
|
*/
|
|
244
272
|
export function main(args = process.argv.slice(2), env = process.env, platformName = osPlatform()) {
|
|
245
273
|
if (isTruthy(env.AVENTURE_CLI_SKIP_COMPLETION_INSTALL) || platformName === "win32") return;
|
|
246
|
-
const
|
|
274
|
+
const packageJson = readPackageJson();
|
|
275
|
+
const bins = cliBins(packageJson);
|
|
247
276
|
if (bins.length === 0) return;
|
|
277
|
+
const retired = allTargets(retiredBins(packageJson, bins), env);
|
|
248
278
|
if (args.includes("--status")) {
|
|
249
279
|
for (const target of allTargets(bins, env)) {
|
|
250
280
|
const state = !existsSync(target.file)
|
|
@@ -257,7 +287,9 @@ export function main(args = process.argv.slice(2), env = process.env, platformNa
|
|
|
257
287
|
return;
|
|
258
288
|
}
|
|
259
289
|
if (args.includes("--uninstall")) {
|
|
260
|
-
const removed = allTargets(bins, env).filter((target) =>
|
|
290
|
+
const removed = [...allTargets(bins, env), ...retired].filter((target) =>
|
|
291
|
+
removeLoader(target.file),
|
|
292
|
+
);
|
|
261
293
|
console.log(
|
|
262
294
|
`removed completions: ${[...new Set(removed.map((target) => target.shell))].join(", ") || "none"}`,
|
|
263
295
|
);
|
|
@@ -268,6 +300,7 @@ export function main(args = process.argv.slice(2), env = process.env, platformNa
|
|
|
268
300
|
writeLoader(target.file, target.contents);
|
|
269
301
|
shells.add(target.shell);
|
|
270
302
|
}
|
|
303
|
+
for (const target of retired) removeLoader(target.file);
|
|
271
304
|
console.log(
|
|
272
305
|
`installed completions: ${[...shells].join(", ")} - remove with: ${bins[0]} completion uninstall`,
|
|
273
306
|
);
|