quirl-cli 0.1.4 → 0.1.6
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/dist/quirl.mjs +33 -32
- package/package.json +1 -1
package/dist/quirl.mjs
CHANGED
|
@@ -167,7 +167,7 @@ if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid
|
|
|
167
167
|
`)}`),e.otherDocs.length&&r.push(`## Other docs (fetch with search_docs or read_doc when relevant)\n\n${e.otherDocs.map(e=>`- ${e.title} (${e.type})${e.summary?`: ${e.summary}`:``}`).join(`
|
|
168
168
|
`)}`);let a=n;for(let e of r){let n=`${a}\n\n${e}`;if(n.length<=t){a=n;continue}let r=t-a.length-71-2;return r>200&&(a=`${a}\n\n${e.slice(0,r)}`),a+`
|
|
169
169
|
|
|
170
|
-
… (cut for length: call the quirl_context tool for the full briefing)`}return a}const Ib=e=>({content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]});function
|
|
170
|
+
… (cut for length: call the quirl_context tool for the full briefing)`}return a}const Ib=e=>({content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]}),Lb=[`database`,`storage`,`service`,`queue`,`auth`,`external_api`],Rb={resource:V().describe(`The resource's name, provider or id (from list_resources)`),inEnvironment:V().optional().describe(`Its current environment, when the same resource exists in several`)};function zb(e){let t=new Ur(e),n=new yb({name:`quirl`,version:e.version},{instructions:`Quirl is this team's single source of truth for the project: what the product does (capabilities), the words the team uses (glossary), docs, tasks, repos and resources.
|
|
171
171
|
- Before answering questions about how the product works or what a term means, check Quirl (lookup, search_docs) rather than guessing. list_features and get_feature show what's being built.
|
|
172
172
|
- Use the glossary's words in code, commits and replies. Refer to items by their ids: capabilities C-12, features F-4, tasks by their number (e.g. Q-1). Don't use deprecated terms.
|
|
173
173
|
- When you start, finish or get blocked on work, update the task (update_task), and attach branches, commits and pull requests as evidence.
|
|
@@ -178,9 +178,10 @@ if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid
|
|
|
178
178
|
- Tag items only from their tag sets (listed under Tags in the briefing): capabilities by who they're for and their kind, features by kind of change, tasks by kind of work. Product areas aren't tags; group capabilities under a parent capability instead.
|
|
179
179
|
- Flags are messages people send about a section (a capability, feature, task, doc or term). Approved ones are listed first in the briefing: act on them, then mark each done with resolve_flag. Only admins approve or remove flags (decide_flag); list_flags shows them.
|
|
180
180
|
- Home shows everyone the product as a map built from Quirl: each top-level capability with its icon, arrows from what it relies on, and its parts listed under it. Give features and capabilities an icon (request_feature's icon, set_feature_icon, set_capability_icon), and propose what each capability relies on and which capability it's part of (propose_capability_details) once it's approved.
|
|
181
|
-
-
|
|
181
|
+
- Correct what's wrong instead of leaving it: update_feature or withdraw_feature for a feature, update_task or archive_task for a task, propose_capability_update (also its name) for a capability. list_capabilities gives them as data.
|
|
182
|
+
- Resources (databases, hosted services, external APIs) come from quirl sync. If the project runs on something sync can't see from the code, add it with add_resource; correct or relabel one with update_resource (e.g. its environment), and drop a wrong one with remove_resource. Never pass secret values.
|
|
182
183
|
- If the project has no capabilities yet, offer to read the codebase and draft them with propose_capability.
|
|
183
|
-
- If the project briefing isn't already in your context, call quirl_context first.`}),r={p_project:e.project},i=()=>({tool:n.server.getClientVersion()?.name??`mcp`,model:process.env.QUIRL_AGENT_MODEL}),a=e=>async t=>{try{return Ib(await e(t))}catch(e){if(e instanceof Hr)return{...Ib(e.message),isError:!0};throw e}};n.registerTool(`quirl_context`,{title:`Project briefing`,description:`The project briefing: always-loaded docs in full, glossary, capabilities, your open tasks and the list of other docs. Usually already loaded at session start.`,inputSchema:{}},a(async()=>Fb(await t.context(e.project)))),n.registerTool(`search_docs`,{title:`Search docs`,description:`Full-text search across the project's docs (README, ADRs, guides, runbooks). Returns matching sections with their content. Use for anything not in the briefing.`,inputSchema:{query:V().describe(`Words to search for, e.g. 'refund approval limits'`),limit:H().int().min(1).max(20).optional()}},a(({query:e,limit:n})=>t.call(`search_docs`,{...r,p_query:e,p_limit:n??6}))),n.registerTool(`read_doc`,{title:`Read a doc`,description:`Read one doc in full, by id, title or source path.`,inputSchema:{doc:V().describe(`Doc id, title or path, e.g. 'docs/adr/004-queues.md'`)}},a(({doc:e})=>t.call(`read_doc`,{...r,p_doc:e}))),n.registerTool(`lookup`,{title:`Look up a term, capability or contract`,description:`Find glossary terms, capabilities, features and API/table contracts matching a name. Use it to check what a word means here, or the request/response shape of an endpoint or table.`,inputSchema:{query:V().describe(`A term, capability, endpoint or table name, e.g. 'Visit' or 'POST /login'`)}},a(({query:e})=>t.call(`lookup`,{...r,p_query:e})));let o=(e,t,r,i)=>{n.registerTool(e,r,i),n.registerTool(t,{...r,description:`Old name for ${e}; use ${e}. ${r.description}`},i)};o(`list_tasks`,`list_cards`,{title:`List tasks`,description:`List tasks on the board. Defaults to your own tasks that aren't done.`,inputSchema:{onlyMine:$p().optional(),includeDone:$p().optional()}},a(({onlyMine:e,includeDone:n})=>t.call(`list_cards`,{...r,p_only_mine:e??!0,p_include_done:n??!1})));let s=`Markdown: short paragraphs, and lists for steps or parts, not one long block.`,c=`Kind of work: e.g. Frontend, Backend, Database, Design, DevOps, Testing, Docs, Research. Only tags from the task set are accepted (see tagSets in quirl_context); propose a new value with propose_term (kind tag, tagSet task_work).`,l=V().describe(`Task number, e.g. 'K-104' or '104'`);return o(`get_task`,`get_card`,{title:`Get a task`,description:`A task with its feature, docs, dependencies and evidence.`,inputSchema:{task:l.optional(),card:l.optional()}},a(({task:e,card:n})=>t.call(`get_card`,{...r,p_card:e??n}))),o(`create_task`,`create_card`,{title:`Create a task`,description:`Add a task to the board (status: todo). Use it for work you discover that should be tracked. Put it under the feature it serves.`,inputSchema:{title:V(),description:V().optional().describe(`What to do and why. ${s}`),type:vm([`feature_work`,`bug`,`chore`,`research`]).optional(),feature:V().optional().describe(`Feature name or id (e.g. F-4) this task belongs to`),tags:U(V()).optional().describe(c)}},a(async({title:e,description:n,type:a,feature:o,tags:s})=>{let c=await t.call(`create_card`,{...r,p_title:e,p_description:n??``,p_type:a??`feature_work`,p_feature:o??null,p_agent:i()});return s?.length&&await t.call(`update_card`,{...r,p_card:c,p_patch:{tags:s},p_agent:i()}),c})),o(`update_task`,`update_card`,{title:`Update a task`,description:`Move a task, mark it blocked (with a reason) or unblocked, put it under a feature, set its tags, rewrite its title or description, and attach evidence: a branch, commit or pull request. Repos are referenced by name.`,inputSchema:{task:l.optional(),card:l.optional(),status:vm([`backlog`,`todo`,`in_progress`,`review`,`done`]).optional(),feature:V().optional().describe(`Feature name or id (e.g. F-4) to put the task under; an empty string takes it off its feature`),title:V().optional(),description:V().optional().describe(`Replaces the description. ${s}`),tags:U(V()).optional().describe(`${c} Replaces the current tags.`),blocked:$p().optional(),blockedReason:V().optional(),addBranch:W({repo:V(),name:V()}).optional(),addCommit:W({repo:V(),sha:V(),message:V().optional()}).optional(),addPullRequest:W({repo:V(),number:H().int(),url:V(),state:vm([`open`,`merged`,`closed`]).optional()}).optional()}},a(({task:e,card:n,...a})=>t.call(`update_card`,{...r,p_card:e??n,p_patch:a,p_agent:i()}))),n.registerTool(`propose_term`,{title:`Propose a glossary term`,description:`Suggest a new glossary term. It shows up for approval; it isn't used until a person approves it.`,inputSchema:{term:V(),plain:V().describe(`What it means, for someone non-technical`),technical:V().describe(`What it means in the code`),kind:vm([`concept`,`tag`,`name`]).optional(),tagSet:V().optional().describe(`Required for kind 'tag': the set the value belongs to, e.g. feature_change, task_work, capability_audience, capability_kind (see tagSets in quirl_context)`),reason:V().optional()}},a(({term:e,plain:n,technical:a,kind:o,tagSet:s,reason:c})=>t.call(`propose_term`,{...r,p_term:e,p_plain:n,p_technical:a,p_kind:o??`concept`,p_tag_set:s??null,p_reason:c??null,p_agent:i()}))),n.registerTool(`propose_term_retire`,{title:`Retire a glossary term`,description:`Propose retiring a glossary term or tag that's no longer used or was a mistake. With replaceWith, the term stays as one not to say (agents are told the replacement); without it, it's removed. Either way it comes off every capability, task and feature that used it. A person approves it. Built-in tag values can't be retired.`,inputSchema:{term:V().describe(`The term or tag to retire`),replaceWith:V().optional().describe(`An approved term to say instead, if there is one`),reason:V().optional()}},a(({term:e,replaceWith:n,reason:a})=>t.call(`propose_term_retire`,{...r,p_term:e,p_replace_with:n??null,p_reason:a??null,p_agent:i()}))),n.registerTool(`list_flags`,{title:`List flags`,description:`Flags are messages people send about a section of the project: a capability, feature, task, doc or glossary term. Lists open (waiting for an admin) and approved (to act on) flags, or only those with the given status.`,inputSchema:{status:vm([`open`,`approved`,`removed`,`done`]).optional()}},a(({status:e})=>t.call(`list_flags`,{...r,p_status:e??null}))),n.registerTool(`decide_flag`,{title:`Approve or remove a flag`,description:`Admins only. Approve a flag so agents act on it at the start of their sessions, or remove it. An approved flag can still be removed. Only do this when the person you work for asks you to.`,inputSchema:{flag:V().describe(`The flag's id, from the briefing or list_flags`),decision:vm([`approve`,`remove`])}},a(({flag:e,decision:n})=>t.call(`decide_flag`,{...r,p_flag:e,p_approve:n===`approve`,p_agent:i()}))),n.registerTool(`resolve_flag`,{title:`Mark a flag done`,description:`Mark an approved flag done once you've handled it, so it leaves the briefing. Say briefly what you did.`,inputSchema:{flag:V().describe(`The flag's id, from the briefing or list_flags`),note:V().optional().describe(`What was done, e.g. 'Updated C-12 to mention SMS'`)}},a(({flag:e,note:n})=>t.call(`resolve_flag`,{...r,p_flag:e,p_note:n??null,p_agent:i()}))),n.registerTool(`set_capability_icon`,{title:`Set a capability's icon`,description:`Give a capability an icon that fits what it does; it's shown on the capability's card. Use the same icon a related feature has when one fits both.`,inputSchema:{capability:V().describe(`Capability name or id (e.g. C-12)`),icon:vm(Nb)}},a(({capability:e,icon:n})=>t.call(`set_capability_icon`,{...r,p_capability:e,p_icon:n,p_agent:i()}))),n.registerTool(`add_resource`,{title:`Add or fill in a resource`,description:"Record a service the project runs on that `quirl sync` can't see from the code: a hosted database another team runs, a SaaS named only in docs or the console, a staging copy. Sync already finds most things from env templates, docker-compose and client packages, so check Stack first (lookup) and don't add what it found. A resource with the same provider and environment is filled in rather than duplicated: the fields you give are set, and repos and capabilities are added to its links. Never pass URLs with credentials, keys or other secret values.",inputSchema:{name:V().describe(`What the team calls it, e.g. "Postgres", "Stripe"`),type:vm([`database`,`storage`,`service`,`queue`,`auth`,`external_api`]),provider:V().optional().describe(`Who runs it, e.g. "Google Cloud SQL", "Stripe". Resources are matched on this. Defaults to the name.`),description:V().optional().describe(`One plain sentence on what the project uses it for`),technical:V().optional().describe(`Technical notes for developers: setup, access, limits`),environment:V().optional().describe(`Defaults to "production"; e.g. "staging"`),repos:U(V()).optional().describe(`Repos that use it, by name`),capabilities:U(V()).optional().describe(`Capabilities that run on it, by name or id (e.g. C-12)`)}},a(e=>t.call(`add_resource`,{...r,p_name:e.name,p_type:e.type,p_provider:e.provider??null,p_description:e.description??null,p_technical:e.technical??null,p_environment:e.environment??null,p_repos:e.repos??null,p_capabilities:e.capabilities??null,p_agent:i()}))),n.registerTool(`list_features`,{title:`List features`,description:`List the project's features with their status, the capability each changes (or createsCapability when it has none), and task counts. Shipped ones are left out unless includeShipped. Check here before requesting a feature.`,inputSchema:{includeShipped:$p().optional()}},a(({includeShipped:e})=>t.call(`list_features`,{...r,p_include_shipped:e??!1}))),n.registerTool(`get_feature`,{title:`Get a feature`,description:`A feature with its description, status, the capability it changes (and what that capability does) and its tasks.`,inputSchema:{feature:V().describe(`Feature name or id (e.g. F-4)`)}},a(({feature:e})=>t.call(`get_feature`,{...r,p_feature:e}))),n.registerTool(`request_feature`,{title:`Request a feature`,description:`Request a feature: a change to the product that stakeholders follow on the Features page, usually made of several tasks. Check list_features first so you don't request one twice. It shows as requested straight away and a person accepts or declines it. Put tasks under it with create_task or update_task.`,inputSchema:{name:V().describe(`Short name, e.g. 'Repeat appointments'`),description:V().describe(`What changes for the user, in plain words. Markdown: short paragraphs, and lists for parts`),capability:V().optional().describe(`Capability name or id (e.g. C-12) it changes. Leave it out when the feature creates a new capability`),tags:U(V()).optional().describe(`Kind of change: e.g. New, Improvement, Visual, Fix, Performance, Security, Removal, Internal (the feature_change set in quirl_context)`),reason:V().optional().describe(`Why it's worth doing`),icon:vm(Nb).optional().describe(`An icon that fits the feature, shown on its card`)}},a(async({name:e,description:n,capability:a,tags:o,reason:s,icon:c})=>{let l=await t.call(`request_feature`,{...r,p_name:e,p_description:n,p_capability:a??null,p_tags:o??null,p_reason:s??null,p_agent:i()});return c&&l===`requested`&&await t.call(`set_feature_icon`,{...r,p_feature:e,p_icon:c,p_agent:i()}),l})),n.registerTool(`set_feature_icon`,{title:`Set a feature's icon`,description:`Give a feature an icon that fits what it does; it's shown on the feature's card. list_features shows which features have none.`,inputSchema:{feature:V().describe(`Feature name or id (e.g. F-4)`),icon:vm(Nb)}},a(({feature:e,icon:n})=>t.call(`set_feature_icon`,{...r,p_feature:e,p_icon:n,p_agent:i()}))),n.registerTool(`tag_feature`,{title:`Tag a feature`,description:`Set a feature's kind-of-change tags (replaces the current ones). Only values from the feature_change tag set are accepted.`,inputSchema:{feature:V().describe(`Feature name or id (e.g. F-4)`),tags:U(V()).describe(`Kind of change: e.g. New, Improvement, Visual, Fix, Performance, Security, Removal, Internal`)}},a(({feature:e,tags:n})=>t.call(`tag_feature`,{...r,p_feature:e,p_tags:n,p_agent:i()}))),n.registerTool(`propose_capability`,{title:`Propose a capability`,description:"Draft a capability: one thing the product does today, described for a non-technical reader. Use it when the project has none yet (for example right after `quirl init`), when you find one that's missing, or when a feature that creates a new capability ships (pass it in features). Never for something not built yet: request a feature instead. A person approves it before it shows up.",inputSchema:{name:V().describe(`Short name, e.g. 'Online booking'`),whatItDoes:V().describe(`One or two plain sentences, no jargon`),technical:V().optional().describe(`Where it lives in the code and how it works. Markdown: short paragraphs, and lists for parts, not one long block`),features:U(V()).optional().describe(`Feature names or ids (e.g. F-4) that create or change this capability; they're linked to it once it's approved`),reason:V().optional()}},a(({name:e,whatItDoes:n,technical:a,features:o,reason:s})=>t.call(`propose_capability`,{...r,p_name:e,p_what_it_does:n,p_technical:a??``,p_features:o??null,p_reason:s??null,p_agent:i()}))),n.registerTool(`propose_capability_archive`,{title:`Propose archiving a capability`,description:`Suggest retiring a capability that no longer describes what the product does, or that was drafted for something not built yet. Unshipped features linked to it will create a new capability when they ship. A person approves it.`,inputSchema:{capability:V().describe(`Capability name or id (e.g. C-12)`),reason:V().describe(`Why it should go`)}},a(({capability:e,reason:n})=>t.call(`propose_capability_archive`,{...r,p_capability:e,p_reason:n,p_agent:i()}))),n.registerTool(`propose_capability_update`,{title:`Propose a capability correction`,description:`Suggest a corrected description for a capability when the code no longer matches it. A person approves it.`,inputSchema:{capability:V().describe(`Capability name or id (e.g. C-12)`),field:vm([`what_it_does`,`technical_description`]),after:V().describe(`The corrected text. Markdown: short paragraphs, and lists for parts, not one long block`),reason:V().optional()}},a(({capability:e,field:n,after:a,reason:o})=>t.call(`propose_capability_update`,{...r,p_capability:e,p_field:n,p_after:a,p_reason:o??null,p_agent:i()}))),n.registerTool(`propose_capability_details`,{title:`Propose how a capability works and its connections`,description:`Suggest a capability's 'How it works' steps, its tags (glossary terms of kind 'tag'), the capability it's part of, and its connections: capabilities it relies on, repos, resources it runs on, glossary terms and docs. Each part you pass replaces that part when a person approves it; parts you leave out are kept. Names are matched to existing, approved items. What it relies on draws the arrows on the Home map, so link the steps a user goes through (e.g. invoicing relies on booking).`,inputSchema:{capability:V().describe(`Capability name or id (e.g. C-12)`),howItWorks:U(V()).optional().describe(`3 to 5 plain-language steps, as the user experiences it`),reliesOn:U(W({capability:V().describe(`Capability name or id (e.g. C-12)`),label:V().describe(`How it relies on it, read before the name, e.g. 'extends'`)})).optional(),parent:V().optional().describe(`The capability this one is part of (name or id, e.g. C-2), or 'none' to make it top-level. Parts are listed under their parent instead of on their own`),repos:U(V()).optional().describe(`Repo names`),resources:U(V()).optional().describe(`Resource names it runs on`),terms:U(V()).optional().describe(`Glossary terms`),docs:U(V()).optional().describe(`Doc titles, or <repo>/<path> (e.g. quirl/AGENTS.md) when titles repeat`),tags:U(V()).optional().describe(`Who it's for (Customer, Admin, Developer, Agent) and its kind (Interface, Integration, Data, Automation, Infrastructure, Access and security, AI): the capability tag sets in quirl_context`),reason:V().optional()}},a(({capability:e,howItWorks:n,reliesOn:a,parent:o,repos:s,resources:c,terms:l,docs:u,tags:d,reason:f})=>t.call(`propose_capability_details`,{...r,p_capability:e,p_how_it_works:n??null,p_relies_on:a??null,p_parent:o??null,p_repos:s??null,p_resources:c??null,p_terms:l??null,p_docs:u??null,p_tags:d??null,p_reason:f??null,p_agent:i()}))),n}async function Rb(e){await Lb(e).connect(new Mb)}const zb=`0.1.4`,Bb=process.env.QUIRL_SERVER===`local`?{apiUrl:`http://127.0.0.1:54321`,publishableKey:`sb_publishable_ACJWlzQHlZjBrEguHvfOxg_3BJgxAaH`,appUrl:`http://localhost:5173`}:{apiUrl:`https://dugevhzlzrdtasuibdzr.supabase.co`,publishableKey:`sb_publishable_45P7GyyZoJsN0AO3wfmqNA_CXbx1iCW`,appUrl:`https://app.quirl.io`};function Vb(){return{apiUrl:process.env.QUIRL_API_URL??Bb.apiUrl,publishableKey:process.env.QUIRL_PUBLISHABLE_KEY??Bb.publishableKey,appUrl:process.env.QUIRL_APP_URL??Bb.appUrl}}const Hb=()=>x(process.env.XDG_CONFIG_HOME??x(h(),`.config`),`quirl`),Ub=()=>x(Hb(),`credentials.json`);async function Wb(){try{return JSON.parse(await u(Ub(),`utf8`))}catch{return{}}}async function Gb(){return process.env.QUIRL_KEY?{apiUrl:Vb().apiUrl,key:process.env.QUIRL_KEY,email:``}:(await Wb())[Vb().apiUrl]??null}async function Kb(e){let t=await Wb();t[e.apiUrl]=e,await l(Hb(),{recursive:!0,mode:448}),await m(Ub(),`${JSON.stringify(t,null,` `)}\n`,{mode:384}),await s(Ub(),384)}async function qb(){let e=await Wb();delete e[Vb().apiUrl],Object.keys(e).length?await m(Ub(),`${JSON.stringify(e,null,` `)}\n`,{mode:384}):await f(Ub(),{force:!0})}async function Jb(){let e=Vb();return{apiUrl:e.apiUrl,publishableKey:e.publishableKey,key:(await Gb())?.key??``}}function Yb(e=process.cwd()){try{return a(`git`,[`rev-parse`,`--show-toplevel`],{cwd:e,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim()}catch{return e}}const Xb=e=>x(e,`.quirl`,`project.json`);async function Zb(e=process.cwd()){let t=e;for(;;)try{return{root:t,link:JSON.parse(await u(Xb(t),`utf8`))}}catch{let e=y(t);if(e===t)return null;t=e}}async function Qb(e,t){await l(x(e,`.quirl`),{recursive:!0}),await m(Xb(e),`${JSON.stringify(t,null,` `)}\n`)}function $b(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];r===`*`?e[n+1]===`*`?(t+=e[n+2]===`/`?`(?:.*/)?`:`.*`,n+=e[n+2]===`/`?2:1):t+=`[^/]*`:t+=r===`?`?`[^/]`:r.replace(/[.+^${}()|[\]\\]/g,`\\$&`)}return RegExp(`^${t}$`)}function ex(e){let t=[];for(let n of e.split(/\r?\n/)){let e=n.replace(/\s+$/,``);if(!e||e.startsWith(`#`))continue;let r=e.startsWith(`!`);r&&(e=e.slice(1));let i=e.endsWith(`/`);i&&(e=e.slice(0,-1));let a=e.includes(`/`);e=e.replace(/^\//,``);let o=$b(e).source.slice(1,-1);t.push({regex:RegExp(a?`^${o}$`:`^(?:.*/)?${o}$`),negate:r,dirOnly:i})}return t}function tx(e,t){if(!e.length)return!1;let n=t.split(`/`);for(let t=1;t<=n.length;t++){let r=n.slice(0,t).join(`/`),i=t<n.length,a=!1;for(let t of e)(!t.dirOnly||i)&&t.regex.test(r)&&(a=!t.negate);if(a)return!0}return!1}async function nx(e){try{return ex(await u(_.join(e,`.quirlignore`),`utf8`))}catch{return[]}}function rx(e,t){return new Promise(n=>{if(!t.length)return n(/* @__PURE__ */ new Set);i(`git`,[`check-ignore`,`--stdin`,`-z`],{cwd:e,maxBuffer:268435456,timeout:6e4},(e,t)=>n(new Set(String(t??``).split(`\0`).filter(Boolean)))).stdin?.end(`${t.join(`\0`)}\0`)})}const ix=n(i),ax=/* @__PURE__ */ new Set([`.git`,`node_modules`,`dist`,`build`,`.next`,`vendor`,`.venv`,`venv`,`__pycache__`,`coverage`,`.turbo`,`.svelte-kit`,`.nuxt`,`.output`,`.cache`,`.vercel`,`.pnpm-store`,`fixtures`,`test-fixtures`,`__fixtures__`,`testdata`]),ox=1048576,sx=2e5;async function cx(e){let t=[],n=await nx(e),r=(await ux(e,t)).filter(e=>!tx(n,e.path)),i=await rx(e,r.map(e=>e.path)),a=r.filter(e=>!i.has(e.path)),o=new Map(a.map(e=>[e.path,e]));return{root:e,files:a,warnings:t,file:e=>o.get(e),async readText(e,n=ox){if(e.size>n)return t.push(`${e.path}: skipped, ${_x(e.size)} is over the ${_x(n)} limit`),null;try{return await u(e.absolutePath,`utf8`)}catch(n){return t.push(`${e.path}: could not be read (${hx(n)})`),null}}}}async function lx(e,t){let n=[],r=await nx(e),{stdout:i}=await ix(`git`,[`ls-tree`,`-r`,`-l`,`-z`,`--full-tree`,t],{cwd:e,maxBuffer:268435456,timeout:6e4}),a=[];for(let e of i.split(`\0`)){let t=e.indexOf(` `);if(t===-1)continue;let[i,o,s,c]=e.slice(0,t).trim().split(/\s+/),l=e.slice(t+1);if(o===`blob`&&i!==`120000`&&s&&!l.split(`/`).some(e=>ax.has(e))&&!tx(r,l)){if(a.length>=sx){n.push(`Stopped after ${sx} files; the rest of the tree was not scanned`);break}a.push({path:l,absolutePath:s,size:Number(c)||0})}}dx(a);let o=new Map(a.map(e=>[e.path,e]));return{root:e,files:a,warnings:n,file:e=>o.get(e),async readText(t,r=ox){if(t.size>r)return n.push(`${t.path}: skipped, ${_x(t.size)} is over the ${_x(r)} limit`),null;try{let{stdout:n}=await ix(`git`,[`cat-file`,`blob`,t.absolutePath],{cwd:e,maxBuffer:r+1024,timeout:3e4});return n}catch(e){return n.push(`${t.path}: could not be read (${hx(e)})`),null}}}}async function ux(e,t){let n=[],r=[``];for(;r.length>0;){let i=r.pop(),a;try{a=await d(_.join(e,i),{withFileTypes:!0})}catch(e){t.push(`${i||`.`}: folder could not be read (${hx(e)})`);continue}for(let o of a){let a=i?`${i}/${o.name}`:o.name;if(o.isSymbolicLink())continue;if(o.isDirectory()){!ax.has(o.name)&&!C(_.join(e,a,`.git`))&&r.push(a);continue}if(!o.isFile())continue;if(n.length>=sx)return t.push(`Stopped after ${sx} files; the rest of the tree was not scanned`),dx(n);let s=_.join(e,a);try{let e=await c(s);n.push({path:a,absolutePath:s,size:e.size})}catch(e){t.push(`${a}: could not be read (${hx(e)})`)}}}return dx(n)}function dx(e){return e.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path))}function fx(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function px(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function mx(e,t){return e?`${e}/${t}`:t}function hx(e){return Gr(e instanceof Error?e.message:String(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function gx(e){return typeof e==`string`?e:void 0}function _x(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:`${Math.ceil(e/1024)} KB`}async function vx({hook:e=!1}={}){let t=await Zb();if(!t){if(e)return;throw Error("This folder isn't linked to a Quirl project. Run `quirl init`.")}try{let n=await new Ur(await Jb()).context(t.link.projectId);process.stdout.write(`${Fb(n,e?9500:void 0)}\n`)}catch(n){if(!e)throw n;process.stdout.write(`Quirl project "${t.link.name}": couldn't load the briefing (${hx(n)}). The quirl MCP tools may still work.\n`)}}async function yx(e,t=3){let n=[],r=async(e,i)=>{if(C(_.join(e,`.git`))&&n.push(e),i>=t)return;let a;try{a=await d(e,{withFileTypes:!0})}catch{return}for(let t of a)!t.isDirectory()||t.name.startsWith(`.`)||ax.has(t.name)||await r(_.join(e,t.name),i+1)};return await r(_.resolve(e),0),n.sort((e,t)=>e.localeCompare(t))}const bx=process.stdout.isTTY&&!process.env.NO_COLOR,xx=e=>t=>bx?`\x1b[${e}m${t}\x1b[0m`:t,Sx=xx(1),Q=xx(2),Cx=xx(32),wx=xx(31),Tx=xx(36),Ex=e=>console.log(`${Cx(`✓`)} ${e}`),Dx=e=>console.log(` ${e}`),Ox=(e,t)=>console.log(`\n${e} ${t}`),kx=e=>console.log(` ${e}`);function Ax(e){if(!bx)return kx(Q(e)),{stop:()=>{}};let t=0,n=setInterval(()=>{process.stdout.write(`\r ${Tx(`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`[t++%10]??``)} ${Q(e)}`)},80);return{stop:()=>{clearInterval(n),process.stdout.write(`\r\x1B[2K`)}}}var jx=class extends Error{};async function Mx(e,t=``){if(!process.stdin.isTTY)return t;let n=E({input:process.stdin,output:process.stdout});try{return(await n.question(e)).trim()||t}finally{n.close()}}async function Nx(e,t){let n=await Mx(`${e} ${Q(t?`[Y/n]`:`[y/N]`)} `,t?`y`:`n`);return/^y/i.test(n)}function Px(e){if(process.env.QUIRL_NO_BROWSER)return;let t=process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,n=process.platform===`win32`?[`/c`,`start`,``,e]:[e];try{o(t,n,{stdio:`ignore`,detached:!0}).on(`error`,()=>{}).unref()}catch{}}const Fx=`<!-- quirl:start -->`,Ix=`<!-- quirl:end -->`,Lx=`# quirl: keep the project in sync`;function Rx(){try{let e=a(process.platform===`win32`?`where`:`which`,[`quirl`],{stdio:[`ignore`,`pipe`,`ignore`]}).toString();if(!/[\\/]_npx[\\/]/.test(e))return{command:`quirl`,args:[],shell:`quirl`,portable:!0}}catch{}return{command:`npx`,args:[`-y`,`quirl-cli`],shell:`npx -y quirl-cli`,portable:!0}}const zx=[`QUIRL_SERVER`,`QUIRL_API_URL`,`QUIRL_PUBLISHABLE_KEY`,`QUIRL_APP_URL`];function Bx(){return Object.fromEntries(zx.flatMap(e=>process.env[e]?[[e,process.env[e]]]:[]))}function Vx(){return`${Object.entries(Bx()).map(([e,t])=>`${e}="${t}" `).join(``)}${Rx().shell}`}async function Hx(e){try{return JSON.parse(await u(e,`utf8`))}catch(t){if(t.code===`ENOENT`)return{};throw Error(`${e} isn't valid JSON; fix it and run \`quirl init\` again.`)}}const Ux=async(e,t)=>{await l(y(e),{recursive:!0}),await m(e,`${JSON.stringify(t,null,2)}\n`)};async function Wx(e){let t=x(e,`.mcp.json`),n=await Hx(t),r=Rx();n.mcpServers={...n.mcpServers,quirl:{command:r.command,args:[...r.args,`mcp`],...Object.keys(Bx()).length?{env:Bx()}:{}}},await Ux(t,n)}async function Gx(e){let t=x(e,`.claude`,`settings.json`),n=await Hx(t),r=n.hooks??{},i=`${Vx()} context --hook`;r.SessionStart=[...(r.SessionStart??[]).map(e=>({...e,hooks:e.hooks.filter(e=>!/\bcontext --hook$/.test(e.command))})).filter(e=>e.hooks.length),{hooks:[{type:`command`,command:i,timeout:15}]}],n.hooks=r,await Ux(t,n)}async function Kx(e,t,n=[]){let r=x(e,`CLAUDE.md`),i=``;try{i=await u(r,`utf8`)}catch{}let a=`${Fx}
|
|
184
|
+
- If the project briefing isn't already in your context, call quirl_context first.`}),r={p_project:e.project},i=()=>({tool:n.server.getClientVersion()?.name??`mcp`,model:process.env.QUIRL_AGENT_MODEL}),a=e=>async t=>{try{return Ib(await e(t))}catch(e){if(e instanceof Hr)return{...Ib(e.message),isError:!0};throw e}};n.registerTool(`quirl_context`,{title:`Project briefing`,description:`The project briefing: always-loaded docs in full, glossary, capabilities, your open tasks and the list of other docs. Usually already loaded at session start.`,inputSchema:{}},a(async()=>Fb(await t.context(e.project)))),n.registerTool(`search_docs`,{title:`Search docs`,description:`Full-text search across the project's docs (README, ADRs, guides, runbooks). Returns matching sections with their content. Use for anything not in the briefing.`,inputSchema:{query:V().describe(`Words to search for, e.g. 'refund approval limits'`),limit:H().int().min(1).max(20).optional()}},a(({query:e,limit:n})=>t.call(`search_docs`,{...r,p_query:e,p_limit:n??6}))),n.registerTool(`read_doc`,{title:`Read a doc`,description:`Read one doc in full, by id, title or source path.`,inputSchema:{doc:V().describe(`Doc id, title or path, e.g. 'docs/adr/004-queues.md'`)}},a(({doc:e})=>t.call(`read_doc`,{...r,p_doc:e}))),n.registerTool(`lookup`,{title:`Look up a term, capability or contract`,description:`Find glossary terms, capabilities, features and API/table contracts matching a name. Use it to check what a word means here, or the request/response shape of an endpoint or table.`,inputSchema:{query:V().describe(`A term, capability, endpoint or table name, e.g. 'Visit' or 'POST /login'`)}},a(({query:e})=>t.call(`lookup`,{...r,p_query:e})));let o=(e,t,r,i)=>{n.registerTool(e,r,i),n.registerTool(t,{...r,description:`Old name for ${e}; use ${e}. ${r.description}`},i)};o(`list_tasks`,`list_cards`,{title:`List tasks`,description:`List tasks on the board. Defaults to your own tasks that aren't done.`,inputSchema:{onlyMine:$p().optional(),includeDone:$p().optional()}},a(({onlyMine:e,includeDone:n})=>t.call(`list_cards`,{...r,p_only_mine:e??!0,p_include_done:n??!1})));let s=`Markdown: short paragraphs, and lists for steps or parts, not one long block.`,c=`Kind of work: e.g. Frontend, Backend, Database, Design, DevOps, Testing, Docs, Research. Only tags from the task set are accepted (see tagSets in quirl_context); propose a new value with propose_term (kind tag, tagSet task_work).`,l=V().describe(`Task number, e.g. 'K-104' or '104'`),u=V().optional().describe(`Who does it: "me", a member's email or name (only people on the project), or "none"`);return o(`get_task`,`get_card`,{title:`Get a task`,description:`A task with its feature, docs, dependencies and evidence.`,inputSchema:{task:l.optional(),card:l.optional()}},a(({task:e,card:n})=>t.call(`get_card`,{...r,p_card:e??n}))),o(`create_task`,`create_card`,{title:`Create a task`,description:`Add a task to the board (status: todo). Use it for work you discover that should be tracked. Put it under the feature it serves.`,inputSchema:{title:V(),description:V().optional().describe(`What to do and why. ${s}`),type:vm([`feature_work`,`bug`,`chore`,`research`]).optional(),feature:V().optional().describe(`Feature name or id (e.g. F-4) this task belongs to`),tags:U(V()).optional().describe(c),assignee:u.describe(`Who does it: "me" (the default), a member's email or name, or "none"`)}},a(async({title:e,description:n,type:a,feature:o,tags:s,assignee:c})=>{let l=await t.call(`create_card`,{...r,p_title:e,p_description:n??``,p_type:a??`feature_work`,p_feature:o??null,p_agent:i()});return(s?.length||c)&&await t.call(`update_card`,{...r,p_card:l,p_patch:{...s?.length?{tags:s}:{},...c?{assignee:c}:{}},p_agent:i()}),l})),o(`update_task`,`update_card`,{title:`Update a task`,description:`Move a task, mark it blocked (with a reason) or unblocked, assign it, put it under a feature, set its tags, rewrite its title or description, and attach evidence: a branch, commit or pull request. Repos are referenced by name.`,inputSchema:{task:l.optional(),card:l.optional(),assignee:u,status:vm([`backlog`,`todo`,`in_progress`,`review`,`done`]).optional(),feature:V().optional().describe(`Feature name or id (e.g. F-4) to put the task under; an empty string takes it off its feature`),title:V().optional(),description:V().optional().describe(`Replaces the description. ${s}`),tags:U(V()).optional().describe(`${c} Replaces the current tags.`),blocked:$p().optional(),blockedReason:V().optional(),addBranch:W({repo:V(),name:V()}).optional(),addCommit:W({repo:V(),sha:V(),message:V().optional()}).optional(),addPullRequest:W({repo:V(),number:H().int(),url:V(),state:vm([`open`,`merged`,`closed`]).optional()}).optional()}},a(({task:e,card:n,...a})=>t.call(`update_card`,{...r,p_card:e??n,p_patch:a,p_agent:i()}))),n.registerTool(`archive_task`,{title:`Archive a task`,description:`Remove a task that shouldn't be there: a duplicate or a mistake. It's archived and stays in history, and its feature's status is worked out without it. For work that's finished, move it to done instead.`,inputSchema:{task:l,reason:V().optional().describe(`Why, for history`)}},a(({task:e,reason:n})=>t.call(`archive_card`,{...r,p_card:e,p_reason:n??null,p_agent:i()}))),n.registerTool(`propose_term`,{title:`Propose a glossary term`,description:`Suggest a new glossary term. It shows up for approval; it isn't used until a person approves it.`,inputSchema:{term:V(),plain:V().describe(`What it means, for someone non-technical`),technical:V().describe(`What it means in the code`),kind:vm([`concept`,`tag`,`name`]).optional(),tagSet:V().optional().describe(`Required for kind 'tag': the set the value belongs to, e.g. feature_change, task_work, capability_audience, capability_kind (see tagSets in quirl_context)`),reason:V().optional()}},a(({term:e,plain:n,technical:a,kind:o,tagSet:s,reason:c})=>t.call(`propose_term`,{...r,p_term:e,p_plain:n,p_technical:a,p_kind:o??`concept`,p_tag_set:s??null,p_reason:c??null,p_agent:i()}))),n.registerTool(`propose_term_retire`,{title:`Retire a glossary term`,description:`Propose retiring a glossary term or tag that's no longer used or was a mistake. With replaceWith, the term stays as one not to say (agents are told the replacement); without it, it's removed. Either way it comes off every capability, task and feature that used it. A person approves it. Built-in tag values can't be retired.`,inputSchema:{term:V().describe(`The term or tag to retire`),replaceWith:V().optional().describe(`An approved term to say instead, if there is one`),reason:V().optional()}},a(({term:e,replaceWith:n,reason:a})=>t.call(`propose_term_retire`,{...r,p_term:e,p_replace_with:n??null,p_reason:a??null,p_agent:i()}))),n.registerTool(`list_flags`,{title:`List flags`,description:`Flags are messages people send about a section of the project: a capability, feature, task, doc or glossary term. Lists open (waiting for an admin) and approved (to act on) flags, or only those with the given status.`,inputSchema:{status:vm([`open`,`approved`,`removed`,`done`]).optional()}},a(({status:e})=>t.call(`list_flags`,{...r,p_status:e??null}))),n.registerTool(`decide_flag`,{title:`Approve or remove a flag`,description:`Admins only. Approve a flag so agents act on it at the start of their sessions, or remove it. An approved flag can still be removed. Only do this when the person you work for asks you to.`,inputSchema:{flag:V().describe(`The flag's id, from the briefing or list_flags`),decision:vm([`approve`,`remove`])}},a(({flag:e,decision:n})=>t.call(`decide_flag`,{...r,p_flag:e,p_approve:n===`approve`,p_agent:i()}))),n.registerTool(`resolve_flag`,{title:`Mark a flag done`,description:`Mark an approved flag done once you've handled it, so it leaves the briefing. Say briefly what you did.`,inputSchema:{flag:V().describe(`The flag's id, from the briefing or list_flags`),note:V().optional().describe(`What was done, e.g. 'Updated C-12 to mention SMS'`)}},a(({flag:e,note:n})=>t.call(`resolve_flag`,{...r,p_flag:e,p_note:n??null,p_agent:i()}))),n.registerTool(`set_capability_icon`,{title:`Set a capability's icon`,description:`Give a capability an icon that fits what it does; it's shown on the capability's card. Use the same icon a related feature has when one fits both.`,inputSchema:{capability:V().describe(`Capability name or id (e.g. C-12)`),icon:vm(Nb)}},a(({capability:e,icon:n})=>t.call(`set_capability_icon`,{...r,p_capability:e,p_icon:n,p_agent:i()}))),n.registerTool(`add_resource`,{title:`Add or fill in a resource`,description:"Record a service the project runs on that `quirl sync` can't see from the code: a hosted database another team runs, a SaaS named only in docs or the console, a staging copy. Sync already finds most things from env templates, docker-compose and client packages, so check Stack first (lookup) and don't add what it found. A resource with the same provider and environment is filled in rather than duplicated: the fields you give are set, and repos and capabilities are added to its links. Never pass URLs with credentials, keys or other secret values.",inputSchema:{name:V().describe(`What the team calls it, e.g. "Postgres", "Stripe"`),type:vm(Lb),provider:V().optional().describe(`Who runs it, e.g. "Google Cloud SQL", "Stripe". Resources are matched on this. Defaults to the name.`),description:V().optional().describe(`One plain sentence on what the project uses it for`),technical:V().optional().describe(`Technical notes for developers: setup, access, limits`),environment:V().optional().describe(`Defaults to "production"; e.g. "staging"`),repos:U(V()).optional().describe(`Repos that use it, by name`),capabilities:U(V()).optional().describe(`Capabilities that run on it, by name or id (e.g. C-12)`)}},a(e=>t.call(`add_resource`,{...r,p_name:e.name,p_type:e.type,p_provider:e.provider??null,p_description:e.description??null,p_technical:e.technical??null,p_environment:e.environment??null,p_repos:e.repos??null,p_capabilities:e.capabilities??null,p_agent:i()}))),n.registerTool(`list_resources`,{title:`List the project's resources`,description:`Every resource on Stack: name, type, provider, environment, whether sync found it or someone added it, the repos that use it and the capabilities that run on it.`,inputSchema:{}},a(()=>t.call(`list_resources`,r))),n.registerTool(`update_resource`,{title:`Change a resource`,description:`Correct a resource: rename it, relabel its environment (a scanned one that's really the local docker database becomes 'local'), or change its type, provider, descriptions or links. Only the fields you pass change. repos and capabilities replace its links; use add_resource to add to them. Sync keeps updating a relabelled resource instead of adding it again. Never pass secret values.`,inputSchema:{...Rb,name:V().optional(),type:vm(Lb).optional(),provider:V().optional(),environment:V().optional().describe(`e.g. "production", "staging", "dev", "local"`),description:V().optional().describe(`One plain sentence on what the project uses it for`),technical:V().optional().describe(`Notes for developers`),repos:U(V()).optional().describe(`Replaces the repos that use it`),capabilities:U(V()).optional().describe(`Replaces the capabilities that run on it (names or C-12)`)}},a(e=>t.call(`update_resource`,{...r,p_resource:e.resource,p_in_environment:e.inEnvironment??null,p_name:e.name??null,p_type:e.type??null,p_provider:e.provider??null,p_environment:e.environment??null,p_description:e.description??null,p_technical:e.technical??null,p_repos:e.repos??null,p_capabilities:e.capabilities??null,p_agent:i()}))),n.registerTool(`remove_resource`,{title:`Remove a wrong resource`,description:`Remove a resource that isn't one: a false match from sync, a duplicate, something no longer used. It's archived, stays in history, and sync won't add it again. A resource holding endpoints or tables from sync can't be removed; relabel it instead.`,inputSchema:{...Rb,reason:V().optional().describe(`Why it's wrong, for history`)}},a(e=>t.call(`remove_resource`,{...r,p_resource:e.resource,p_in_environment:e.inEnvironment??null,p_reason:e.reason??null,p_agent:i()}))),n.registerTool(`list_features`,{title:`List features`,description:`List the project's features with their status, the capability each changes (or createsCapability when it has none), and task counts. Shipped ones are left out unless includeShipped. Check here before requesting a feature.`,inputSchema:{includeShipped:$p().optional()}},a(({includeShipped:e})=>t.call(`list_features`,{...r,p_include_shipped:e??!1}))),n.registerTool(`get_feature`,{title:`Get a feature`,description:`A feature with its description, status, the capability it changes (and what that capability does) and its tasks.`,inputSchema:{feature:V().describe(`Feature name or id (e.g. F-4)`)}},a(({feature:e})=>t.call(`get_feature`,{...r,p_feature:e}))),n.registerTool(`request_feature`,{title:`Request a feature`,description:`Request a feature: a change to the product that stakeholders follow on the Features page, usually made of several tasks. Check list_features first so you don't request one twice. It shows as requested straight away and a person accepts or declines it. Put tasks under it with create_task or update_task.`,inputSchema:{name:V().describe(`Short name, e.g. 'Repeat appointments'`),description:V().describe(`What changes for the user, in plain words. Markdown: short paragraphs, and lists for parts`),capability:V().optional().describe(`Capability name or id (e.g. C-12) it changes. Leave it out when the feature creates a new capability`),tags:U(V()).optional().describe(`Kind of change: e.g. New, Improvement, Visual, Fix, Performance, Security, Removal, Internal (the feature_change set in quirl_context)`),reason:V().optional().describe(`Why it's worth doing`),icon:vm(Nb).optional().describe(`An icon that fits the feature, shown on its card`)}},a(async({name:e,description:n,capability:a,tags:o,reason:s,icon:c})=>{let l=await t.call(`request_feature`,{...r,p_name:e,p_description:n,p_capability:a??null,p_tags:o??null,p_reason:s??null,p_agent:i()});return c&&l===`requested`&&await t.call(`set_feature_icon`,{...r,p_feature:e,p_icon:c,p_agent:i()}),l})),n.registerTool(`set_feature_icon`,{title:`Set a feature's icon`,description:`Give a feature an icon that fits what it does; it's shown on the feature's card. list_features shows which features have none.`,inputSchema:{feature:V().describe(`Feature name or id (e.g. F-4)`),icon:vm(Nb)}},a(({feature:e,icon:n})=>t.call(`set_feature_icon`,{...r,p_feature:e,p_icon:n,p_agent:i()}))),n.registerTool(`update_feature`,{title:`Correct a feature`,description:`Fix a feature's name, description or the capability it changes, e.g. after requesting it with the wrong one. Only the fields you pass change; it shows in the feature's history. Tags: tag_feature; icon: set_feature_icon.`,inputSchema:{feature:V().describe(`Feature name or id (e.g. F-4)`),name:V().optional(),description:V().optional().describe(`What changes for the user, in plain words. Markdown: short paragraphs, and lists for parts`),capability:V().optional().describe(`The capability it changes (name or C-12), or "none" when it creates a new one`)}},a(({feature:e,name:n,description:a,capability:o})=>t.call(`update_feature`,{...r,p_feature:e,p_name:n??null,p_description:a??null,p_capability:o??null,p_agent:i()}))),n.registerTool(`withdraw_feature`,{title:`Withdraw a feature`,description:`Remove a feature that shouldn't be there: a duplicate, a mistake, or an idea dropped before any work. It's archived and stays in history. One that shipped can't be withdrawn; move or archive its tasks first (update_task, archive_task).`,inputSchema:{feature:V().describe(`Feature name or id (e.g. F-4)`),reason:V().optional().describe(`Why, for history`)}},a(({feature:e,reason:n})=>t.call(`withdraw_feature`,{...r,p_feature:e,p_reason:n??null,p_agent:i()}))),n.registerTool(`tag_feature`,{title:`Tag a feature`,description:`Set a feature's kind-of-change tags (replaces the current ones). Only values from the feature_change tag set are accepted.`,inputSchema:{feature:V().describe(`Feature name or id (e.g. F-4)`),tags:U(V()).describe(`Kind of change: e.g. New, Improvement, Visual, Fix, Performance, Security, Removal, Internal`)}},a(({feature:e,tags:n})=>t.call(`tag_feature`,{...r,p_feature:e,p_tags:n,p_agent:i()}))),n.registerTool(`list_capabilities`,{title:`List the capabilities`,description:`Every capability as data: id (C-12), name, status, icon, the capability it's part of, what it does, what it relies on, its tags and the features changing it. Retired ones only with includeRetired.`,inputSchema:{includeRetired:$p().optional()}},a(({includeRetired:e})=>t.call(`list_capabilities`,{...r,p_include_retired:e??!1}))),n.registerTool(`propose_capability`,{title:`Propose a capability`,description:"Draft a capability: one thing the product does today, described for a non-technical reader. Use it when the project has none yet (for example right after `quirl init`), when you find one that's missing, or when a feature that creates a new capability ships (pass it in features). Never for something not built yet: request a feature instead. A person approves it before it shows up.",inputSchema:{name:V().describe(`Short name, e.g. 'Online booking'`),whatItDoes:V().describe(`One or two plain sentences, no jargon`),technical:V().optional().describe(`Where it lives in the code and how it works. Markdown: short paragraphs, and lists for parts, not one long block`),features:U(V()).optional().describe(`Feature names or ids (e.g. F-4) that create or change this capability; they're linked to it once it's approved`),reason:V().optional()}},a(({name:e,whatItDoes:n,technical:a,features:o,reason:s})=>t.call(`propose_capability`,{...r,p_name:e,p_what_it_does:n,p_technical:a??``,p_features:o??null,p_reason:s??null,p_agent:i()}))),n.registerTool(`propose_capability_archive`,{title:`Propose archiving a capability`,description:`Suggest retiring a capability that no longer describes what the product does, or that was drafted for something not built yet. Unshipped features linked to it will create a new capability when they ship. A person approves it.`,inputSchema:{capability:V().describe(`Capability name or id (e.g. C-12)`),reason:V().describe(`Why it should go`)}},a(({capability:e,reason:n})=>t.call(`propose_capability_archive`,{...r,p_capability:e,p_reason:n,p_agent:i()}))),n.registerTool(`propose_capability_update`,{title:`Propose a capability correction`,description:`Suggest a corrected name or description for a capability when the code no longer matches it. A person approves it.`,inputSchema:{capability:V().describe(`Capability name or id (e.g. C-12)`),field:vm([`name`,`what_it_does`,`technical_description`]),after:V().describe(`The new name, or the corrected text. Markdown: short paragraphs, and lists for parts, not one long block`),reason:V().optional()}},a(({capability:e,field:n,after:a,reason:o})=>t.call(`propose_capability_update`,{...r,p_capability:e,p_field:n,p_after:a,p_reason:o??null,p_agent:i()}))),n.registerTool(`propose_capability_details`,{title:`Propose how a capability works and its connections`,description:`Suggest a capability's 'How it works' steps, its tags (glossary terms of kind 'tag'), the capability it's part of, and its connections: capabilities it relies on, repos, resources it runs on, glossary terms and docs. Each part you pass replaces that part when a person approves it; parts you leave out are kept. Names are matched to existing, approved items. What it relies on draws the arrows on the Home map, so link the steps a user goes through (e.g. invoicing relies on booking).`,inputSchema:{capability:V().describe(`Capability name or id (e.g. C-12)`),howItWorks:U(V()).optional().describe(`3 to 5 plain-language steps, as the user experiences it`),reliesOn:U(W({capability:V().describe(`Capability name or id (e.g. C-12)`),label:V().describe(`How it relies on it, read before the name, e.g. 'extends'`)})).optional(),parent:V().optional().describe(`The capability this one is part of (name or id, e.g. C-2), or 'none' to make it top-level. Parts are listed under their parent instead of on their own`),repos:U(V()).optional().describe(`Repo names`),resources:U(V()).optional().describe(`Resource names it runs on`),terms:U(V()).optional().describe(`Glossary terms`),docs:U(V()).optional().describe(`Doc titles, or <repo>/<path> (e.g. quirl/AGENTS.md) when titles repeat`),tags:U(V()).optional().describe(`Who it's for (Customer, Admin, Developer, Agent) and its kind (Interface, Integration, Data, Automation, Infrastructure, Access and security, AI): the capability tag sets in quirl_context`),reason:V().optional()}},a(({capability:e,howItWorks:n,reliesOn:a,parent:o,repos:s,resources:c,terms:l,docs:u,tags:d,reason:f})=>t.call(`propose_capability_details`,{...r,p_capability:e,p_how_it_works:n??null,p_relies_on:a??null,p_parent:o??null,p_repos:s??null,p_resources:c??null,p_terms:l??null,p_docs:u??null,p_tags:d??null,p_reason:f??null,p_agent:i()}))),n}async function Bb(e){await zb(e).connect(new Mb)}const Vb=`0.1.6`,Hb=process.env.QUIRL_SERVER===`local`?{apiUrl:`http://127.0.0.1:54321`,publishableKey:`sb_publishable_ACJWlzQHlZjBrEguHvfOxg_3BJgxAaH`,appUrl:`http://localhost:5173`}:{apiUrl:`https://dugevhzlzrdtasuibdzr.supabase.co`,publishableKey:`sb_publishable_45P7GyyZoJsN0AO3wfmqNA_CXbx1iCW`,appUrl:`https://app.quirl.io`};function Ub(){return{apiUrl:process.env.QUIRL_API_URL??Hb.apiUrl,publishableKey:process.env.QUIRL_PUBLISHABLE_KEY??Hb.publishableKey,appUrl:process.env.QUIRL_APP_URL??Hb.appUrl}}const Wb=()=>x(process.env.XDG_CONFIG_HOME??x(h(),`.config`),`quirl`),Gb=()=>x(Wb(),`credentials.json`);async function Kb(){try{return JSON.parse(await u(Gb(),`utf8`))}catch{return{}}}async function qb(){return process.env.QUIRL_KEY?{apiUrl:Ub().apiUrl,key:process.env.QUIRL_KEY,email:``}:(await Kb())[Ub().apiUrl]??null}async function Jb(e){let t=await Kb();t[e.apiUrl]=e,await l(Wb(),{recursive:!0,mode:448}),await m(Gb(),`${JSON.stringify(t,null,` `)}\n`,{mode:384}),await s(Gb(),384)}async function Yb(){let e=await Kb();delete e[Ub().apiUrl],Object.keys(e).length?await m(Gb(),`${JSON.stringify(e,null,` `)}\n`,{mode:384}):await f(Gb(),{force:!0})}async function Xb(){let e=Ub();return{apiUrl:e.apiUrl,publishableKey:e.publishableKey,key:(await qb())?.key??``}}function Zb(e=process.cwd()){try{return a(`git`,[`rev-parse`,`--show-toplevel`],{cwd:e,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim()}catch{return e}}const Qb=e=>x(e,`.quirl`,`project.json`);async function $b(e=process.cwd()){let t=e;for(;;)try{return{root:t,link:JSON.parse(await u(Qb(t),`utf8`))}}catch{let e=y(t);if(e===t)return null;t=e}}async function ex(e,t){await l(x(e,`.quirl`),{recursive:!0}),await m(Qb(e),`${JSON.stringify(t,null,` `)}\n`)}function tx(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];r===`*`?e[n+1]===`*`?(t+=e[n+2]===`/`?`(?:.*/)?`:`.*`,n+=e[n+2]===`/`?2:1):t+=`[^/]*`:t+=r===`?`?`[^/]`:r.replace(/[.+^${}()|[\]\\]/g,`\\$&`)}return RegExp(`^${t}$`)}function nx(e){let t=[];for(let n of e.split(/\r?\n/)){let e=n.replace(/\s+$/,``);if(!e||e.startsWith(`#`))continue;let r=e.startsWith(`!`);r&&(e=e.slice(1));let i=e.endsWith(`/`);i&&(e=e.slice(0,-1));let a=e.includes(`/`);e=e.replace(/^\//,``);let o=tx(e).source.slice(1,-1);t.push({regex:RegExp(a?`^${o}$`:`^(?:.*/)?${o}$`),negate:r,dirOnly:i})}return t}function rx(e,t){if(!e.length)return!1;let n=t.split(`/`);for(let t=1;t<=n.length;t++){let r=n.slice(0,t).join(`/`),i=t<n.length,a=!1;for(let t of e)(!t.dirOnly||i)&&t.regex.test(r)&&(a=!t.negate);if(a)return!0}return!1}async function ix(e){try{return nx(await u(_.join(e,`.quirlignore`),`utf8`))}catch{return[]}}function ax(e,t){return new Promise(n=>{if(!t.length)return n(/* @__PURE__ */ new Set);i(`git`,[`check-ignore`,`--stdin`,`-z`],{cwd:e,maxBuffer:268435456,timeout:6e4},(e,t)=>n(new Set(String(t??``).split(`\0`).filter(Boolean)))).stdin?.end(`${t.join(`\0`)}\0`)})}const ox=n(i),sx=/* @__PURE__ */ new Set([`.git`,`node_modules`,`dist`,`build`,`.next`,`vendor`,`.venv`,`venv`,`__pycache__`,`coverage`,`.turbo`,`.svelte-kit`,`.nuxt`,`.output`,`.cache`,`.vercel`,`.pnpm-store`,`fixtures`,`test-fixtures`,`__fixtures__`,`testdata`]),cx=1048576,lx=2e5;async function ux(e){let t=[],n=await ix(e),r=(await fx(e,t)).filter(e=>!rx(n,e.path)),i=await ax(e,r.map(e=>e.path)),a=r.filter(e=>!i.has(e.path)),o=new Map(a.map(e=>[e.path,e]));return{root:e,files:a,warnings:t,file:e=>o.get(e),async readText(e,n=cx){if(e.size>n)return t.push(`${e.path}: skipped, ${yx(e.size)} is over the ${yx(n)} limit`),null;try{return await u(e.absolutePath,`utf8`)}catch(n){return t.push(`${e.path}: could not be read (${_x(n)})`),null}}}}async function dx(e,t){let n=[],r=await ix(e),{stdout:i}=await ox(`git`,[`ls-tree`,`-r`,`-l`,`-z`,`--full-tree`,t],{cwd:e,maxBuffer:268435456,timeout:6e4}),a=[];for(let e of i.split(`\0`)){let t=e.indexOf(` `);if(t===-1)continue;let[i,o,s,c]=e.slice(0,t).trim().split(/\s+/),l=e.slice(t+1);if(o===`blob`&&i!==`120000`&&s&&!l.split(`/`).some(e=>sx.has(e))&&!rx(r,l)){if(a.length>=lx){n.push(`Stopped after ${lx} files; the rest of the tree was not scanned`);break}a.push({path:l,absolutePath:s,size:Number(c)||0})}}px(a);let o=new Map(a.map(e=>[e.path,e]));return{root:e,files:a,warnings:n,file:e=>o.get(e),async readText(t,r=cx){if(t.size>r)return n.push(`${t.path}: skipped, ${yx(t.size)} is over the ${yx(r)} limit`),null;try{let{stdout:n}=await ox(`git`,[`cat-file`,`blob`,t.absolutePath],{cwd:e,maxBuffer:r+1024,timeout:3e4});return n}catch(e){return n.push(`${t.path}: could not be read (${_x(e)})`),null}}}}async function fx(e,t){let n=[],r=[``];for(;r.length>0;){let i=r.pop(),a;try{a=await d(_.join(e,i),{withFileTypes:!0})}catch(e){t.push(`${i||`.`}: folder could not be read (${_x(e)})`);continue}for(let o of a){let a=i?`${i}/${o.name}`:o.name;if(o.isSymbolicLink())continue;if(o.isDirectory()){!sx.has(o.name)&&!C(_.join(e,a,`.git`))&&r.push(a);continue}if(!o.isFile())continue;if(n.length>=lx)return t.push(`Stopped after ${lx} files; the rest of the tree was not scanned`),px(n);let s=_.join(e,a);try{let e=await c(s);n.push({path:a,absolutePath:s,size:e.size})}catch(e){t.push(`${a}: could not be read (${_x(e)})`)}}}return px(n)}function px(e){return e.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path))}function mx(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function hx(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function gx(e,t){return e?`${e}/${t}`:t}function _x(e){return Gr(e instanceof Error?e.message:String(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vx(e){return typeof e==`string`?e:void 0}function yx(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:`${Math.ceil(e/1024)} KB`}async function bx({hook:e=!1}={}){let t=await $b();if(!t){if(e)return;throw Error("This folder isn't linked to a Quirl project. Run `quirl init`.")}try{let n=await new Ur(await Xb()).context(t.link.projectId);process.stdout.write(`${Fb(n,e?9500:void 0)}\n`)}catch(n){if(!e)throw n;process.stdout.write(`Quirl project "${t.link.name}": couldn't load the briefing (${_x(n)}). The quirl MCP tools may still work.\n`)}}async function xx(e,t=3){let n=[],r=async(e,i)=>{if(C(_.join(e,`.git`))&&n.push(e),i>=t)return;let a;try{a=await d(e,{withFileTypes:!0})}catch{return}for(let t of a)!t.isDirectory()||t.name.startsWith(`.`)||sx.has(t.name)||await r(_.join(e,t.name),i+1)};return await r(_.resolve(e),0),n.sort((e,t)=>e.localeCompare(t))}const Sx=process.stdout.isTTY&&!process.env.NO_COLOR,Cx=e=>t=>Sx?`\x1b[${e}m${t}\x1b[0m`:t,wx=Cx(1),Q=Cx(2),Tx=Cx(32),Ex=Cx(31),Dx=Cx(36),Ox=e=>console.log(`${Tx(`✓`)} ${e}`),kx=e=>console.log(` ${e}`),Ax=(e,t)=>console.log(`\n${e} ${t}`),jx=e=>console.log(` ${e}`);function Mx(e){if(!Sx)return jx(Q(e)),{stop:()=>{}};let t=0,n=setInterval(()=>{process.stdout.write(`\r ${Dx(`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`[t++%10]??``)} ${Q(e)}`)},80);return{stop:()=>{clearInterval(n),process.stdout.write(`\r\x1B[2K`)}}}var Nx=class extends Error{};async function Px(e,t=``){if(!process.stdin.isTTY)return t;let n=E({input:process.stdin,output:process.stdout});try{return(await n.question(e)).trim()||t}finally{n.close()}}async function Fx(e,t){let n=await Px(`${e} ${Q(t?`[Y/n]`:`[y/N]`)} `,t?`y`:`n`);return/^y/i.test(n)}function Ix(e){if(process.env.QUIRL_NO_BROWSER)return;let t=process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,n=process.platform===`win32`?[`/c`,`start`,``,e]:[e];try{o(t,n,{stdio:`ignore`,detached:!0}).on(`error`,()=>{}).unref()}catch{}}const Lx=`<!-- quirl:start -->`,Rx=`<!-- quirl:end -->`,zx=`# quirl: keep the project in sync`;function Bx(){try{let e=a(process.platform===`win32`?`where`:`which`,[`quirl`],{stdio:[`ignore`,`pipe`,`ignore`]}).toString();if(!/[\\/]_npx[\\/]/.test(e))return{command:`quirl`,args:[],shell:`quirl`,portable:!0}}catch{}return{command:`npx`,args:[`-y`,`quirl-cli`],shell:`npx -y quirl-cli`,portable:!0}}const Vx=[`QUIRL_SERVER`,`QUIRL_API_URL`,`QUIRL_PUBLISHABLE_KEY`,`QUIRL_APP_URL`];function Hx(){return Object.fromEntries(Vx.flatMap(e=>process.env[e]?[[e,process.env[e]]]:[]))}function Ux(){return`${Object.entries(Hx()).map(([e,t])=>`${e}="${t}" `).join(``)}${Bx().shell}`}async function Wx(e){try{return JSON.parse(await u(e,`utf8`))}catch(t){if(t.code===`ENOENT`)return{};throw Error(`${e} isn't valid JSON; fix it and run \`quirl init\` again.`)}}const Gx=async(e,t)=>{await l(y(e),{recursive:!0}),await m(e,`${JSON.stringify(t,null,2)}\n`)};async function Kx(e){let t=x(e,`.mcp.json`),n=await Wx(t),r=Bx();n.mcpServers={...n.mcpServers,quirl:{command:r.command,args:[...r.args,`mcp`],...Object.keys(Hx()).length?{env:Hx()}:{}}},await Gx(t,n)}async function qx(e){let t=x(e,`.claude`,`settings.json`),n=await Wx(t),r=n.hooks??{},i=`${Ux()} context --hook`;r.SessionStart=[...(r.SessionStart??[]).map(e=>({...e,hooks:e.hooks.filter(e=>!/\bcontext --hook$/.test(e.command))})).filter(e=>e.hooks.length),{hooks:[{type:`command`,command:i,timeout:15}]}],n.hooks=r,await Gx(t,n)}async function Jx(e,t,n=[]){let r=x(e,`CLAUDE.md`),i=``;try{i=await u(r,`utf8`)}catch{}let a=`${Lx}
|
|
184
185
|
## Quirl
|
|
185
186
|
|
|
186
187
|
${n.length?`This folder holds the repos of the Quirl project **${t}** (${n.join(`, `)}). Quirl is`:`This repo is part of the Quirl project **${t}**,`} the team's source of truth for what the product does. The project briefing (always-loaded docs, glossary, capabilities, your tasks) is loaded at the start of each session. Use the \`quirl\` MCP tools:
|
|
@@ -193,24 +194,24 @@ ${n.length?`This folder holds the repos of the Quirl project **${t}** (${n.join(
|
|
|
193
194
|
- Capabilities describe only what exists; anything not built yet is a feature. When a feature ships, propose the capability change (\`propose_capability_update\`, or \`propose_capability\` with \`features\` for a new one).
|
|
194
195
|
- If a capability description or term is wrong or missing, propose a fix (\`propose_capability_update\`, \`propose_term\`) instead of working around it. Retire a term that's no longer used with \`propose_term_retire\`.
|
|
195
196
|
- After changing docs, dependencies or schemas, run \`quirl sync\` (the pre-push hook does it on push).
|
|
196
|
-
${
|
|
197
|
+
${Rx}`,o=RegExp(`${Lx}[\\s\\S]*?${Rx}`);i=o.test(i)?i.replace(o,a):`${i.trimEnd()}${i.trim()?`
|
|
197
198
|
|
|
198
|
-
`:``}${a}\n`,await m(r,i)}async function
|
|
199
|
+
`:``}${a}\n`,await m(r,i)}async function Yx(e){let t;try{t=a(`git`,[`rev-parse`,`--git-path`,`hooks`],{cwd:e}).toString().trim()}catch{return null}b(t)||(t=x(e,t));let n=x(t,`pre-push`),r=``;try{r=await u(n,`utf8`)}catch{}let i=`${zx}\n${Ux()} sync --quiet --source=git_hook || echo "quirl: sync skipped"\n`,o=r.indexOf(zx);if(o>=0){let e=r.indexOf(`
|
|
199
200
|
`,r.indexOf(`
|
|
200
|
-
`,o)+1);r=`${r.slice(0,o)}${i}${e>=0?r.slice(e+1):``}`}else r=r?`${r.trimEnd()}\n\n${i}`:`#!/bin/sh\n${i}`;return await l(t,{recursive:!0}),await m(n,r),await s(n,493),n}async function
|
|
201
|
-
`)),r=!t.docs&&
|
|
202
|
-
`)):null,a=e=>{let t=
|
|
203
|
-
`),n=/^---\n([\s\S]*?)\n---\n/.exec(t),r=n?.[1]?/^title:\s*["']?(.+?)["']?\s*$/m.exec(n[1]):null;if(r?.[1])return r[1];let i=t.replace(/^(```|~~~)[\s\S]*?^\1.*$/gm,``),a=/^#\s+(.+?)\s*#*\s*$/m.exec(i),o=/^(?!\s*$)([^\n#>].*)\n=+\s*$/m.exec(i),s=a&&o?a.index<o.index?a[1]:o[1]:a?.[1]??o?.[1];return s?sS(s):null}function sS(e){return e.replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[`*_]/g,``).trim()}function cS(e,t){let n=`${e} ${t}`.toLowerCase();return/(^|\/)adrs?\//.test(n)||/\bdecision|\badr[-_ ]?\d/.test(n)?`decision`:/guideline|convention|contributing|style ?guide|styleguide|code[-_ ]?style|coding[-_ ]standard/.test(n)?`guideline`:/guide|how[-_ ]?to|setup|set[-_ ]up|getting[-_ ]started|install|tutorial|runbook|playbook/.test(n)?`how_to`:/architecture|design|overview/.test(n)?`architecture`:`reference`}function lS(e,t){if(t===`guideline`)return!0;let n=fx(e).toLowerCase();return/architecture|conventions?|guidelines?|contributing|style-?guide/.test(n)||t===`architecture`&&/overview/.test(n)}const uS=/* @__PURE__ */ new Set([`claude.md`,`agents.md`,`.cursorrules`]);async function dS(e){let t=[];for(let n of e.files){if(!(uS.has(fx(n.path).toLowerCase())||n.path===`.github/copilot-instructions.md`))continue;let r=(await e.readText(n))?.replace(/<!-- quirl:start -->[\s\S]*?<!-- quirl:end -->\n?/,``).trim();r&&t.push({path:n.path,body:r})}return t}const fS=/\.(md|mdx|markdown|txt)$/i,pS=/\.(pdf|docx?|odt|rtf|pages|pptx?|key|xlsx?|numbers)$/i;async function mS(e){let t=[],n=[];for(let r of e.files){if(r.path.split(`/`).some(e=>e.startsWith(`.`)))continue;let i=fx(r.path);if(pS.test(i)){n.push(r.path);continue}if(!fS.test(i)||/^(claude|agents)\.md$/i.test(i))continue;let a=await e.readText(r);if(!a?.trim())continue;let o=i.replace(fS,``),s=($x.test(i)?oS(a):null)??o,c=cS(r.path,s);t.push({path:r.path,title:s,type:c,body:a,alwaysLoadCandidate:!1,contentHash:w(`sha256`).update(a).digest(`hex`)})}return{docs:t,unsupported:n}}const hS=n(i);async function gS(e,t){try{let{stdout:n}=await hS(`git`,t,{cwd:e,timeout:1e4}),r=n.trim();return r===``?null:r}catch{return null}}async function _S(e){let t=await gS(e,[`symbolic-ref`,`--quiet`,`refs/remotes/origin/HEAD`]),n=[...t?[t.replace(/^refs\/remotes\//,``)]:[],`origin/main`,`origin/master`,`main`,`master`];for(let t of n)if(await gS(e,[`rev-parse`,`--verify`,`--quiet`,`${t}^{commit}`]))return{ref:t,branch:t.replace(/^origin\//,``)};return null}async function vS(e){try{return await hS(`git`,[`fetch`,`--quiet`,`--no-tags`,`origin`],{cwd:e,timeout:6e4}),await hS(`git`,[`remote`,`set-head`,`origin`,`--auto`],{cwd:e,timeout:3e4}).catch(()=>{}),!0}catch{return!1}}async function yS(e,t,n){let r=_.basename(e);if(await gS(e,[`rev-parse`,`--is-inside-work-tree`])!==`true`)return t.push(`Not a git repository (or git is not installed): repo details are empty`),{name:r,provider:null,url:null,defaultBranch:null,headSha:null,lastCommitAt:null,scannedRef:null};let i=n??`HEAD`,[a,o,s,c,l]=await Promise.all([gS(e,[`remote`,`get-url`,`origin`]),gS(e,[`rev-parse`,`--verify`,`--quiet`,`${i}^{commit}`]),gS(e,[`log`,`-1`,`--format=%cI`,i]),gS(e,[`symbolic-ref`,`--quiet`,`refs/remotes/origin/HEAD`]),gS(e,[`symbolic-ref`,`--quiet`,`--short`,`HEAD`])]);o===null&&t.push(`Git repository has no commits yet`),a===null&&t.push(`Git repository has no 'origin' remote`);let u=a?bS(a):null;return a&&!u&&t.push(`Could not read the 'origin' remote URL`),{name:u?.name??r,provider:u?.provider??null,url:u?.url??null,defaultBranch:n?.replace(/^origin\//,``)??c?.replace(/^refs\/remotes\/origin\//,``)??l,headSha:o,scannedRef:n,lastCommitAt:s?new Date(s).toISOString():null}}function bS(e){let t,n,r=/^(?:[^@/]+@)?([^:/]+):(?!\/)(.+)$/.exec(e);if(/^[a-z+]+:\/\//i.test(e)){let r;try{r=new URL(e)}catch{return null}if(r.protocol===`file:`)return null;t=r.hostname,n=r.pathname}else if(r?.[1]&&r[2])t=r[1],n=r[2];else return null;if(n=n.replace(/^\/+/,``).replace(/\/+$/,``).replace(/\.git$/,``),!t||!n)return null;let i=t.toLowerCase(),a=i.includes(`github`)?`github`:i.includes(`gitlab`)?`gitlab`:null;return{name:n.slice(n.lastIndexOf(`/`)+1),provider:a,url:`https://${i}/${n}`}}var xS=class{#e=/* @__PURE__ */ new Map;#t;#n;constructor(e,t){this.#t=e,this.#n=t}add(e,t,n){if(!e||!t)return;let r=this.#e.get(e);r&&(r.direct&&!n||r.direct===n&&SS(r.version,t)>=0)||this.#e.set(e,{ecosystem:this.#t,package:e,version:t,direct:n,sourceLockfile:this.#n})}has(e){return this.#e.has(e)}rows(){return[...this.#e.values()].sort((e,t)=>e.package.localeCompare(t.package))}};function SS(e,t){let n=e=>e.replace(/^v/,``).split(/[.+-]/),r=n(e),i=n(t);for(let e=0;e<Math.max(r.length,i.length);e++){let t=r[e]??``,n=i[e]??``,a=Number(t),o=Number(n),s=t!==``&&n!==``&&!Number.isNaN(a)&&!Number.isNaN(o)?a-o:t.localeCompare(n);if(s!==0)return s}return 0}function CS(e){let t=/* @__PURE__ */ new Set;if(!Z(e))return t;for(let n of[`dependencies`,`devDependencies`,`optionalDependencies`,`peerDependencies`]){let r=e[n];if(Z(r))for(let e of Object.keys(r))t.add(e)}return t}function wS(e){return JSON.parse(e)}function TS(e,t,n){let r=wS(e);if(!Z(r))throw Error(`not a JSON object`);let i=/* @__PURE__ */ new Set;if(n!==null){let e=wS(n);if(Z(e))for(let t of[`require`,`require-dev`]){let n=e[t];if(Z(n))for(let e of Object.keys(n))i.add(e.toLowerCase())}}let a=new xS(`composer`,t);for(let e of[`packages`,`packages-dev`]){let t=r[e];if(Array.isArray(t))for(let e of t){if(!Z(e))continue;let{name:t,version:n}=e;typeof t==`string`&&typeof n==`string`&&a.add(t,n,i.has(t.toLowerCase()))}}return a.rows()}function ES(e,t,n){let r=new xS(`other`,n),i=/* @__PURE__ */ new Set;if(e!==null){let t=!1;for(let n of e.split(/\r?\n/)){let e=n.trim();if(t){if(e.startsWith(`)`)){t=!1;continue}a(e);continue}if(/^require\s*\($/.test(e)){t=!0;continue}let r=/^require\s+(.+)$/.exec(e);r?.[1]&&a(r[1])}}function a(e){let t=/^(\S+)\s+(\S+)(.*)$/.exec(e);if(!t?.[1]||!t[2]||t[1].startsWith(`//`))return;let n=/\/\/\s*indirect\b/.test(t[3]??``);r.add(t[1],t[2],!n),i.add(t[1])}if(t!==null)for(let e of t.split(/\r?\n/)){let[t,n]=e.trim().split(/\s+/);if(!t||!n)continue;let a=n.replace(/\/go\.mod$/,``);i.has(t)||r.add(t,a,!1)}return r.rows()}var $=/* @__PURE__ */ D((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),DS=/* @__PURE__ */ D((e=>{var t=$();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),OS=/* @__PURE__ */ D((e=>{var t=$(),n=DS();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)t===`!!`&&n===`tag:yaml.org,2002:`||e&&!a.some(e=>e.startsWith(n))||r.push(`%TAG ${t} ${n}`);return r.join(`
|
|
204
|
-
`)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),
|
|
201
|
+
`,o)+1);r=`${r.slice(0,o)}${i}${e>=0?r.slice(e+1):``}`}else r=r?`${r.trimEnd()}\n\n${i}`:`#!/bin/sh\n${i}`;return await l(t,{recursive:!0}),await m(n,r),await s(n,493),n}async function Xx({quiet:e=!1}={}){let t=Ub(),n=await qb();Ax(`🔑`,wx(`Sign in to Quirl`)),n&&!e&&jx(Q(`Already signed in as ${n.email}. Signing in again replaces this machine's key.`));let r=Wr(t.apiUrl,t.publishableKey),i=await r.start(`quirl CLI on ${g()}`),a=`${t.appUrl}/cli/authorize?code=${i.user_code}`;jx(`Approve this computer in your browser:`),jx(Dx(a)),jx(`Check the code matches ${wx(Zx(i.user_code))}`),Ix(a);let o=Mx(`Waiting for you to approve…`),s=Date.now()+6e5;for(;Date.now()<s;){await new Promise(e=>setTimeout(e,2e3));let e=await r.poll(i.request_id,i.poll_secret);if(e.status===`approved`&&e.key){let n=await new Ur({...t,key:e.key}).whoami();return o.stop(),await Jb({apiUrl:t.apiUrl,key:e.key,email:n.email}),jx(`${Tx(`✓`)} Signed in as ${wx(n.email)}`),n}if(e.status!==`pending`)throw o.stop(),new Nx(`Sign-in ${e.status}. Run \`quirl login\` again.`)}throw o.stop(),new Nx("Sign-in timed out. Run `quirl login` again.")}const Zx=e=>`${e.slice(0,4)}-${e.slice(4)}`,Qx=/* @__PURE__ */ new Set([`docs`,`doc`,`adr`,`adrs`,`architecture`]),$x=/* @__PURE__ */ new Set([`readme.md`,`contributing.md`,`architecture.md`]),eS=/^(changelog|changes|history|license|licence|copying|notice|code_of_conduct|claude|agents)(\.|$)/i,tS=/\.(md|mdx|markdown)$/i,nS=/* @__PURE__ */ new Set([`tasks`,`todo`,`todos`,`issues`,`tickets`,`inbox`,`archive`,`archived`]),rS=/^(package\.json|pyproject\.toml|requirements\.txt|go\.mod|cargo\.toml|composer\.json|gemfile|pom\.xml|build\.gradle(\.kts)?|mix\.exs|pubspec\.yaml)$/i;async function iS(e){let t=e.file(`.quirl/config.json`);if(!t)return{};let n=await e.readText(t);try{let e=JSON.parse(n??`{}`),t=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):void 0;return{docs:t(e.docs),alwaysLoad:t(e.alwaysLoad)}}catch{return e.warnings.push(`.quirl/config.json: not valid JSON, ignored`),{}}}function aS(e){if(e.files.some(e=>rS.test(mx(e.path))))return!1;let t=e.files.filter(e=>tS.test(e.path)).length;return t>0&&t*2>=e.files.length}async function oS(e,t={}){let n=nx((t.docs??[]).join(`
|
|
202
|
+
`)),r=!t.docs&&aS(e),i=t.alwaysLoad?nx(t.alwaysLoad.join(`
|
|
203
|
+
`)):null,a=e=>{let t=mx(e);if(!tS.test(t)||eS.test(t))return!1;let i=e.toLowerCase().split(`/`);return e.toLowerCase()===`.github/contributing.md`?!0:i.some(e=>e.startsWith(`.`))?!1:sS(e)||rx(n,e)?!0:r&&!i.slice(0,-1).some(e=>nS.has(e))},o=[];for(let t of e.files){if(!a(t.path))continue;let n=await e.readText(t);if(n===null)continue;let r=cS(n)??mx(t.path).replace(tS,``),s=uS(t.path,r),c;i?(c=rx(i,t.path),c&&n.length>2e4&&e.warnings.push(`${t.path}: listed in alwaysLoad but ${Math.round(n.length/1e3)}k characters; every agent session loads all of it`)):c=dS(t.path,s)&&n.length<=2e4,o.push({path:t.path,title:r,type:s,body:n,alwaysLoadCandidate:c,contentHash:w(`sha256`).update(n).digest(`hex`)})}return o}function sS(e){let t=mx(e);if(!tS.test(t)||eS.test(t))return!1;let n=e.toLowerCase().split(`/`);return n.length===1?$x.has(n[0]??``):e.toLowerCase()===`.github/contributing.md`||n.slice(0,-1).some(e=>Qx.has(e))}function cS(e){let t=e.replace(/\r\n/g,`
|
|
204
|
+
`),n=/^---\n([\s\S]*?)\n---\n/.exec(t),r=n?.[1]?/^title:\s*["']?(.+?)["']?\s*$/m.exec(n[1]):null;if(r?.[1])return r[1];let i=t.replace(/^(```|~~~)[\s\S]*?^\1.*$/gm,``),a=/^#\s+(.+?)\s*#*\s*$/m.exec(i),o=/^(?!\s*$)([^\n#>].*)\n=+\s*$/m.exec(i),s=a&&o?a.index<o.index?a[1]:o[1]:a?.[1]??o?.[1];return s?lS(s):null}function lS(e){return e.replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[`*_]/g,``).trim()}function uS(e,t){let n=`${e} ${t}`.toLowerCase();return/(^|\/)adrs?\//.test(n)||/\bdecision|\badr[-_ ]?\d/.test(n)?`decision`:/guideline|convention|contributing|style ?guide|styleguide|code[-_ ]?style|coding[-_ ]standard/.test(n)?`guideline`:/guide|how[-_ ]?to|setup|set[-_ ]up|getting[-_ ]started|install|tutorial|runbook|playbook/.test(n)?`how_to`:/architecture|design|overview/.test(n)?`architecture`:`reference`}function dS(e,t){if(t===`guideline`)return!0;let n=mx(e).toLowerCase();return/architecture|conventions?|guidelines?|contributing|style-?guide/.test(n)||t===`architecture`&&/overview/.test(n)}const fS=/* @__PURE__ */ new Set([`claude.md`,`agents.md`,`.cursorrules`]);async function pS(e){let t=[];for(let n of e.files){if(!(fS.has(mx(n.path).toLowerCase())||n.path===`.github/copilot-instructions.md`))continue;let r=(await e.readText(n))?.replace(/<!-- quirl:start -->[\s\S]*?<!-- quirl:end -->\n?/,``).trim();r&&t.push({path:n.path,body:r})}return t}const mS=/\.(md|mdx|markdown|txt)$/i,hS=/\.(pdf|docx?|odt|rtf|pages|pptx?|key|xlsx?|numbers)$/i;async function gS(e){let t=[],n=[];for(let r of e.files){if(r.path.split(`/`).some(e=>e.startsWith(`.`)))continue;let i=mx(r.path);if(hS.test(i)){n.push(r.path);continue}if(!mS.test(i)||/^(claude|agents)\.md$/i.test(i))continue;let a=await e.readText(r);if(!a?.trim())continue;let o=i.replace(mS,``),s=(tS.test(i)?cS(a):null)??o,c=uS(r.path,s);t.push({path:r.path,title:s,type:c,body:a,alwaysLoadCandidate:!1,contentHash:w(`sha256`).update(a).digest(`hex`)})}return{docs:t,unsupported:n}}const _S=n(i);async function vS(e,t){try{let{stdout:n}=await _S(`git`,t,{cwd:e,timeout:1e4}),r=n.trim();return r===``?null:r}catch{return null}}async function yS(e){let t=await vS(e,[`symbolic-ref`,`--quiet`,`refs/remotes/origin/HEAD`]),n=[...t?[t.replace(/^refs\/remotes\//,``)]:[],`origin/main`,`origin/master`,`main`,`master`];for(let t of n)if(await vS(e,[`rev-parse`,`--verify`,`--quiet`,`${t}^{commit}`]))return{ref:t,branch:t.replace(/^origin\//,``)};return null}async function bS(e){try{return await _S(`git`,[`fetch`,`--quiet`,`--no-tags`,`origin`],{cwd:e,timeout:6e4}),await _S(`git`,[`remote`,`set-head`,`origin`,`--auto`],{cwd:e,timeout:3e4}).catch(()=>{}),!0}catch{return!1}}async function xS(e,t,n){let r=_.basename(e);if(await vS(e,[`rev-parse`,`--is-inside-work-tree`])!==`true`)return t.push(`Not a git repository (or git is not installed): repo details are empty`),{name:r,provider:null,url:null,defaultBranch:null,headSha:null,lastCommitAt:null,scannedRef:null};let i=n??`HEAD`,[a,o,s,c,l]=await Promise.all([vS(e,[`remote`,`get-url`,`origin`]),vS(e,[`rev-parse`,`--verify`,`--quiet`,`${i}^{commit}`]),vS(e,[`log`,`-1`,`--format=%cI`,i]),vS(e,[`symbolic-ref`,`--quiet`,`refs/remotes/origin/HEAD`]),vS(e,[`symbolic-ref`,`--quiet`,`--short`,`HEAD`])]);o===null&&t.push(`Git repository has no commits yet`),a===null&&t.push(`Git repository has no 'origin' remote`);let u=a?SS(a):null;return a&&!u&&t.push(`Could not read the 'origin' remote URL`),{name:u?.name??r,provider:u?.provider??null,url:u?.url??null,defaultBranch:n?.replace(/^origin\//,``)??c?.replace(/^refs\/remotes\/origin\//,``)??l,headSha:o,scannedRef:n,lastCommitAt:s?new Date(s).toISOString():null}}function SS(e){let t,n,r=/^(?:[^@/]+@)?([^:/]+):(?!\/)(.+)$/.exec(e);if(/^[a-z+]+:\/\//i.test(e)){let r;try{r=new URL(e)}catch{return null}if(r.protocol===`file:`)return null;t=r.hostname,n=r.pathname}else if(r?.[1]&&r[2])t=r[1],n=r[2];else return null;if(n=n.replace(/^\/+/,``).replace(/\/+$/,``).replace(/\.git$/,``),!t||!n)return null;let i=t.toLowerCase(),a=i.includes(`github`)?`github`:i.includes(`gitlab`)?`gitlab`:null;return{name:n.slice(n.lastIndexOf(`/`)+1),provider:a,url:`https://${i}/${n}`}}var CS=class{#e=/* @__PURE__ */ new Map;#t;#n;constructor(e,t){this.#t=e,this.#n=t}add(e,t,n){if(!e||!t)return;let r=this.#e.get(e);r&&(r.direct&&!n||r.direct===n&&wS(r.version,t)>=0)||this.#e.set(e,{ecosystem:this.#t,package:e,version:t,direct:n,sourceLockfile:this.#n})}has(e){return this.#e.has(e)}rows(){return[...this.#e.values()].sort((e,t)=>e.package.localeCompare(t.package))}};function wS(e,t){let n=e=>e.replace(/^v/,``).split(/[.+-]/),r=n(e),i=n(t);for(let e=0;e<Math.max(r.length,i.length);e++){let t=r[e]??``,n=i[e]??``,a=Number(t),o=Number(n),s=t!==``&&n!==``&&!Number.isNaN(a)&&!Number.isNaN(o)?a-o:t.localeCompare(n);if(s!==0)return s}return 0}function TS(e){let t=/* @__PURE__ */ new Set;if(!Z(e))return t;for(let n of[`dependencies`,`devDependencies`,`optionalDependencies`,`peerDependencies`]){let r=e[n];if(Z(r))for(let e of Object.keys(r))t.add(e)}return t}function ES(e){return JSON.parse(e)}function DS(e,t,n){let r=ES(e);if(!Z(r))throw Error(`not a JSON object`);let i=/* @__PURE__ */ new Set;if(n!==null){let e=ES(n);if(Z(e))for(let t of[`require`,`require-dev`]){let n=e[t];if(Z(n))for(let e of Object.keys(n))i.add(e.toLowerCase())}}let a=new CS(`composer`,t);for(let e of[`packages`,`packages-dev`]){let t=r[e];if(Array.isArray(t))for(let e of t){if(!Z(e))continue;let{name:t,version:n}=e;typeof t==`string`&&typeof n==`string`&&a.add(t,n,i.has(t.toLowerCase()))}}return a.rows()}function OS(e,t,n){let r=new CS(`other`,n),i=/* @__PURE__ */ new Set;if(e!==null){let t=!1;for(let n of e.split(/\r?\n/)){let e=n.trim();if(t){if(e.startsWith(`)`)){t=!1;continue}a(e);continue}if(/^require\s*\($/.test(e)){t=!0;continue}let r=/^require\s+(.+)$/.exec(e);r?.[1]&&a(r[1])}}function a(e){let t=/^(\S+)\s+(\S+)(.*)$/.exec(e);if(!t?.[1]||!t[2]||t[1].startsWith(`//`))return;let n=/\/\/\s*indirect\b/.test(t[3]??``);r.add(t[1],t[2],!n),i.add(t[1])}if(t!==null)for(let e of t.split(/\r?\n/)){let[t,n]=e.trim().split(/\s+/);if(!t||!n)continue;let a=n.replace(/\/go\.mod$/,``);i.has(t)||r.add(t,a,!1)}return r.rows()}var $=/* @__PURE__ */ D((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),kS=/* @__PURE__ */ D((e=>{var t=$();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),AS=/* @__PURE__ */ D((e=>{var t=$(),n=kS();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)t===`!!`&&n===`tag:yaml.org,2002:`||e&&!a.some(e=>e.startsWith(n))||r.push(`%TAG ${t} ${n}`);return r.join(`
|
|
205
|
+
`)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),jS=/* @__PURE__ */ D((e=>{var t=$(),n=kS();function r(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function i(e){let t=/* @__PURE__ */ new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function a(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function o(e,n){let r=[],o=/* @__PURE__ */ new Map,s=null;return{onAnchor:t=>{r.push(t),s??=i(e);let o=a(n,s);return s.add(o),o},setAnchors:()=>{for(let e of r){let n=o.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=/* @__PURE__ */ Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:o}}e.anchorIsValid=r,e.anchorNames=i,e.createNodeAnchors=o,e.findNewAnchor=a})),MS=/* @__PURE__ */ D((e=>{function t(e,n,r,i){if(i&&typeof i==`object`){if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let r=i[n],a=t(e,i,String(n),r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),a=t(e,i,n,r);a===void 0?i.delete(n):a!==r&&i.set(n,a)}else if(i instanceof Set)for(let n of Array.from(i)){let r=t(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let a=t(e,i,n,r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}}return e.call(n,r,i)}e.applyReviver=t})),NS=/* @__PURE__ */ D((e=>{var t=$();function n(e,r,i){if(Array.isArray(e))return e.map((e,t)=>n(e,String(t),i));if(e&&typeof e.toJSON==`function`){if(!i||!t.hasAnchor(e))return e.toJSON(r,i);let n={aliasCount:0,count:1,res:void 0};i.anchors.set(e,n),i.onCreate=e=>{n.res=e,delete i.onCreate};let a=e.toJSON(r,i);return i.onCreate&&i.onCreate(a),a}return typeof e==`bigint`&&!i?.keep?Number(e):e}e.toJS=n})),PS=/* @__PURE__ */ D((e=>{var t=MS(),n=$(),r=NS();e.NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:/* @__PURE__ */ new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}}})),FS=/* @__PURE__ */ D((e=>{var t=jS(),n=kS(),r=$(),i=PS(),a=NS(),o=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let o;for(let e of i){if(e===this)break;e.anchor===this.source&&(o=e)}if(o&&t){let{anchors:e,doc:n,maxAliasCount:r}=t,i=e.get(o);
|
|
205
206
|
/* istanbul ignore if */
|
|
206
|
-
if(i||=(a.toJS(o,null,t),e.get(o)),i?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(r>=0&&(i.count+=1,i.aliasCount===0&&(i.aliasCount=s(n,o,e)),i.count*i.aliasCount>r))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return o}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function s(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(r.isCollection(t)){let r=0;for(let i of t.items){let t=s(e,i,n);t>r&&(r=t)}return r}if(r.isPair(t)){let r=s(e,t.key,n),i=s(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=o})),
|
|
207
|
+
if(i||=(a.toJS(o,null,t),e.get(o)),i?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(r>=0&&(i.count+=1,i.aliasCount===0&&(i.aliasCount=s(n,o,e)),i.count*i.aliasCount>r))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return o}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function s(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(r.isCollection(t)){let r=0;for(let i of t.items){let t=s(e,i,n);t>r&&(r=t)}return r}if(r.isPair(t)){let r=s(e,t.key,n),i=s(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=o})),IS=/* @__PURE__ */ D((e=>{var t=$(),n=PS(),r=NS();let i=e=>!e||typeof e!=`function`&&typeof e!=`object`;var a=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};a.BLOCK_FOLDED=`BLOCK_FOLDED`,a.BLOCK_LITERAL=`BLOCK_LITERAL`,a.PLAIN=`PLAIN`,a.QUOTE_DOUBLE=`QUOTE_DOUBLE`,a.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=a,e.isScalarValue=i})),LS=/* @__PURE__ */ D((e=>{var t=FS(),n=$(),r=IS();function i(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function a(e,a,o){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=o.schema[n.MAP].createNode?.(o.schema,null,o);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:s,onAnchor:c,onTagObj:l,schema:u,sourceObjects:d}=o,f;if(s&&e&&typeof e==`object`){if(f=d.get(e),f)return f.anchor??(f.anchor=c(e)),new t.Alias(f.anchor);f={anchor:null,node:null},d.set(e,f)}a?.startsWith(`!!`)&&(a=`tag:yaml.org,2002:`+a.slice(2));let p=i(e,a,u.tags);if(!p){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return f&&(f.node=t),t}p=e instanceof Map?u[n.MAP]:Symbol.iterator in Object(e)?u[n.SEQ]:u[n.MAP]}l&&(l(p),delete o.onTagObj);let m=p?.createNode?p.createNode(o.schema,e,o):typeof p?.nodeClass?.from==`function`?p.nodeClass.from(o.schema,e,o):new r.Scalar(e);return a?m.tag=a:p.default||(m.tag=p.tag),f&&(f.node=m),m}e.createNode=a})),RS=/* @__PURE__ */ D((e=>{var t=LS(),n=$(),r=PS();function i(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=/* @__PURE__ */ new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:/* @__PURE__ */ new Map})}let a=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;e.Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(a(e))this.add(t);else{let[r,...a]=e,o=this.get(r,!0);if(n.isCollection(o))o.addIn(a,t);else if(o===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...a]=e;if(a.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(a,t);else if(e===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}},e.collectionFromPath=i,e.isEmptyPath=a})),zS=/* @__PURE__ */ D((e=>{let t=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function n(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}e.indentComment=n,e.lineComment=(e,t,r)=>e.endsWith(`
|
|
207
208
|
`)?n(r,t):r.includes(`
|
|
208
209
|
`)?`
|
|
209
|
-
`+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),
|
|
210
|
+
`+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),BS=/* @__PURE__ */ D((e=>{let t=`block`,n=`quoted`;function r(e,r,a=`flow`,{indentAtStart:o,lineWidth:s=80,minContentWidth:c=20,onFold:l,onOverflow:u}={}){if(!s||s<0)return e;s<c&&(c=0);let d=Math.max(1+c,1+s-r.length);if(e.length<=d)return e;let f=[],p={},m=s-r.length;typeof o==`number`&&(o>s-Math.max(2,c)?f.push(0):m=s-o);let h,g,_=!1,v=-1,y=-1,b=-1;a===t&&(v=i(e,v,r.length),v!==-1&&(m=v+d));for(let o;o=e[v+=1];){if(a===n&&o===`\\`){switch(y=v,e[v+1]){case`x`:v+=3;break;case`u`:v+=5;break;case`U`:v+=9;break;default:v+=1}b=v}if(o===`
|
|
210
211
|
`)a===t&&(v=i(e,v,r.length)),m=v+r.length+d,h=void 0;else{if(o===` `&&g&&g!==` `&&g!==`
|
|
211
212
|
`&&g!==` `){let t=e[v+1];t&&t!==` `&&t!==`
|
|
212
213
|
`&&t!==` `&&(h=v)}if(v>=m){if(h)f.push(h),m=h+d,h=void 0;else if(a===n){for(;g===` `||g===` `;)g=o,o=e[v+=1],_=!0;let t=v>b+1?v-2:y-1;if(p[t])return e;f.push(t),p[t]=!0,m=t+d,h=void 0}else _=!0}}g=o}if(_&&u&&u(),f.length===0)return e;l&&l();let x=e.slice(0,f[0]);for(let t=0;t<f.length;++t){let i=f[t],o=f[t+1]||e.length;i===0?x=`\n${r}${e.slice(0,o)}`:(a===n&&p[i]&&(x+=`${e[i]}\\`),x+=`\n${r}${e.slice(i+1,o)}`)}return x}function i(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
|
|
213
|
-
`);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=r})),
|
|
214
|
+
`);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=r})),VS=/* @__PURE__ */ D((e=>{var t=IS(),n=BS();let r=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),i=e=>/^(%|---|\.\.\.)/m.test(e);function a(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
|
|
214
215
|
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function o(e,t){let a=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return a;let{implicitKey:o}=t,s=t.options.doubleQuotedMinMultiLineLength,c=t.indent||(i(e)?` `:``),l=``,u=0;for(let e=0,t=a[e];t;t=a[++e])if(t===` `&&a[e+1]===`\\`&&a[e+2]===`n`&&(l+=a.slice(u,e)+`\\ `,e+=1,u=e,t=`\\`),t===`\\`)switch(a[e+1]){case`u`:{l+=a.slice(u,e);let t=a.substr(e+2,4);switch(t){case`0000`:l+=`\\0`;break;case`0007`:l+=`\\a`;break;case`000b`:l+=`\\v`;break;case`001b`:l+=`\\e`;break;case`0085`:l+=`\\N`;break;case`00a0`:l+=`\\_`;break;case`2028`:l+=`\\L`;break;case`2029`:l+=`\\P`;break;default:t.substr(0,2)===`00`?l+=`\\x`+t.substr(2):l+=a.substr(e,6)}e+=5,u=e+1}break;case`n`:if(o||a[e+2]===`"`||a.length<s)e+=1;else{for(l+=a.slice(u,e)+`
|
|
215
216
|
|
|
216
217
|
`;a[e+2]===`\\`&&a[e+3]===`n`&&a[e+4]!==`"`;)l+=`
|
|
@@ -228,29 +229,29 @@ if(i||=(a.toJS(o,null,t),e.get(o)),i?.res===void 0)throw ReferenceError(`This sh
|
|
|
228
229
|
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${g}`),i=!1,a=r(u,!0);p!==`folded`&&o!==t.Scalar.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let c=n.foldFlowLines(`${T}${e}${b}`,g,n.FOLD_BLOCK,a);if(!i)return`>${E}\n${g}${c}`}return s=s.replace(/\n+/g,`$&${g}`),`|${E}\n${g}${T}${s}${b}`}function d(e,a,o,s){let{type:l,value:d}=e,{actualString:f,implicitKey:p,indent:m,indentStep:h,inFlow:g}=a;if(p&&d.includes(`
|
|
229
230
|
`)||g&&/[[\]{},]/.test(d))return c(d,a);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(d))return p||g||!d.includes(`
|
|
230
231
|
`)?c(d,a):u(e,a,o,s);if(!p&&!g&&l!==t.Scalar.PLAIN&&d.includes(`
|
|
231
|
-
`))return u(e,a,o,s);if(i(d)){if(m===``)return a.forceBlockIndent=!0,u(e,a,o,s);if(p&&m===h)return c(d,a)}let _=d.replace(/\n+/g,`$&\n${m}`);if(f){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(_),{compat:t,tags:n}=a.doc.schema;if(n.some(e)||t?.some(e))return c(d,a)}return p?_:n.foldFlowLines(_,m,n.FOLD_FLOW,r(a,!1))}function f(e,n,r,i){let{implicitKey:a,inFlow:l}=n,f=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:p}=e;p!==t.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(f.value)&&(p=t.Scalar.QUOTE_DOUBLE);let m=e=>{switch(e){case t.Scalar.BLOCK_FOLDED:case t.Scalar.BLOCK_LITERAL:return a||l?c(f.value,n):u(f,n,r,i);case t.Scalar.QUOTE_DOUBLE:return o(f.value,n);case t.Scalar.QUOTE_SINGLE:return s(f.value,n);case t.Scalar.PLAIN:return d(f,n,r,i);default:return null}},h=m(p);if(h===null){let{defaultKeyType:e,defaultStringType:t}=n.options,r=a&&e||t;if(h=m(r),h===null)throw Error(`Unsupported default string type ${r}`)}return h}e.stringifyString=f})),
|
|
232
|
+
`))return u(e,a,o,s);if(i(d)){if(m===``)return a.forceBlockIndent=!0,u(e,a,o,s);if(p&&m===h)return c(d,a)}let _=d.replace(/\n+/g,`$&\n${m}`);if(f){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(_),{compat:t,tags:n}=a.doc.schema;if(n.some(e)||t?.some(e))return c(d,a)}return p?_:n.foldFlowLines(_,m,n.FOLD_FLOW,r(a,!1))}function f(e,n,r,i){let{implicitKey:a,inFlow:l}=n,f=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:p}=e;p!==t.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(f.value)&&(p=t.Scalar.QUOTE_DOUBLE);let m=e=>{switch(e){case t.Scalar.BLOCK_FOLDED:case t.Scalar.BLOCK_LITERAL:return a||l?c(f.value,n):u(f,n,r,i);case t.Scalar.QUOTE_DOUBLE:return o(f.value,n);case t.Scalar.QUOTE_SINGLE:return s(f.value,n);case t.Scalar.PLAIN:return d(f,n,r,i);default:return null}},h=m(p);if(h===null){let{defaultKeyType:e,defaultStringType:t}=n.options,r=a&&e||t;if(h=m(r),h===null)throw Error(`Unsupported default string type ${r}`)}return h}e.stringifyString=f})),HS=/* @__PURE__ */ D((e=>{var t=jS(),n=$(),r=zS(),i=VS();function a(e,t){let n=Object.assign({blockQuote:!0,commentString:r.stringifyComment,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(n.collectionStyle){case`block`:i=!1;break;case`flow`:i=!0;break;default:i=null}return{anchors:/* @__PURE__ */ new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:i,options:n}}function o(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let r,i;if(n.isScalar(t)){i=t.value;let n=e.filter(e=>e.identify?.(i));if(n.length>1){let e=n.filter(e=>e.test);e.length>0&&(n=e)}r=n.find(e=>e.format===t.format)??n.find(e=>!e.format)}else i=t,r=e.find(e=>e.nodeClass&&i instanceof e.nodeClass);if(!r){let e=i?.constructor?.name??(i===null?`null`:typeof i);throw Error(`Tag not resolved for ${e} value`)}return r}function s(e,r,{anchors:i,doc:a}){if(!a.directives)return``;let o=[],s=(n.isScalar(e)||n.isCollection(e))&&e.anchor;s&&t.anchorIsValid(s)&&(i.add(s),o.push(`&${s}`));let c=e.tag??(r.default?null:r.tag);return c&&o.push(a.directives.tagString(c)),o.join(` `)}function c(e,t,r,a){if(n.isPair(e))return e.toString(t,r,a);if(n.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=/* @__PURE__ */ new Set([e]),e=e.resolve(t.doc)}let c,l=n.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>c=e});c??=o(t.doc.schema.tags,l);let u=s(l,c,t);u.length>0&&(t.indentAtStart=(t.indentAtStart??0)+u.length+1);let d=typeof c.stringify==`function`?c.stringify(l,t,r,a):n.isScalar(l)?i.stringifyString(l,t,r,a):l.toString(t,r,a);return u?n.isScalar(l)||d[0]===`{`||d[0]===`[`?`${u} ${d}`:`${u}\n${t.indent}${d}`:d}e.createStringifyContext=a,e.stringify=c})),US=/* @__PURE__ */ D((e=>{var t=$(),n=IS(),r=HS(),i=zS();function a({key:e,value:a},o,s,c){let{allNullValues:l,doc:u,indent:d,indentStep:f,options:{commentString:p,indentSeq:m,simpleKeys:h}}=o,g=t.isNode(e)&&e.comment||null;if(h){if(g)throw Error(`With simple keys, key nodes cannot have comments`);if(t.isCollection(e)||!t.isNode(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let _=!h&&(!e||g&&a==null&&!o.inFlow||t.isCollection(e)||(t.isScalar(e)?e.type===n.Scalar.BLOCK_FOLDED||e.type===n.Scalar.BLOCK_LITERAL:typeof e==`object`));o=Object.assign({},o,{allNullValues:!1,implicitKey:!_&&(h||!l),indent:d+f});let v=!1,y=!1,b=r.stringify(e,o,()=>v=!0,()=>y=!0);if(!_&&!o.inFlow&&b.length>1024){if(h)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);_=!0}if(o.inFlow){if(l||a==null)return v&&s&&s(),b===``?`?`:_?`? ${b}`:b}else if(l&&!h||a==null&&_)return b=`? ${b}`,g&&!v?b+=i.lineComment(b,o.indent,p(g)):y&&c&&c(),b;v&&(g=null),_?(g&&(b+=i.lineComment(b,o.indent,p(g))),b=`? ${b}\n${d}:`):(b=`${b}:`,g&&(b+=i.lineComment(b,o.indent,p(g))));let x,S,C;t.isNode(a)?(x=!!a.spaceBefore,S=a.commentBefore,C=a.comment):(x=!1,S=null,C=null,a&&typeof a==`object`&&(a=u.createNode(a))),o.implicitKey=!1,!_&&!g&&t.isScalar(a)&&(o.indentAtStart=b.length+1),y=!1,!m&&f.length>=2&&!o.inFlow&&!_&&t.isSeq(a)&&!a.flow&&!a.tag&&!a.anchor&&(o.indent=o.indent.substring(2));let w=!1,T=r.stringify(a,o,()=>w=!0,()=>y=!0),E=` `;if(g||x||S){if(E=x?`
|
|
232
233
|
`:``,S){let e=p(S);E+=`\n${i.indentComment(e,o.indent)}`}T===``&&!o.inFlow?E===`
|
|
233
234
|
`&&C&&(E=`
|
|
234
235
|
|
|
235
236
|
`):E+=`\n${o.indent}`}else if(!_&&t.isCollection(a)){let e=T[0],t=T.indexOf(`
|
|
236
237
|
`),n=t!==-1,r=o.inFlow??a.flow??a.items.length===0;if(n||!r){let r=!1;if(n&&(e===`&`||e===`!`)){let n=T.indexOf(` `);e===`&`&&n!==-1&&n<t&&T[n+1]===`!`&&(n=T.indexOf(` `,n+1)),(n===-1||t<n)&&(r=!0)}r||(E=`\n${o.indent}`)}}else(T===``||T[0]===`
|
|
237
|
-
`)&&(E=``);return b+=E+T,o.inFlow?w&&s&&s():C&&!w?b+=i.lineComment(b,o.indent,p(C)):y&&c&&c(),b}e.stringifyPair=a})),
|
|
238
|
+
`)&&(E=``);return b+=E+T,o.inFlow?w&&s&&s():C&&!w?b+=i.lineComment(b,o.indent,p(C)):y&&c&&c(),b}e.stringifyPair=a})),WS=/* @__PURE__ */ D((e=>{var t=de(`process`);function n(e,...t){e===`debug`&&console.log(...t)}function r(e,n){(e===`debug`||e===`warn`)&&(typeof t.emitWarning==`function`?t.emitWarning(n):console.warn(n))}e.debug=n,e.warn=r})),GS=/* @__PURE__ */ D((e=>{var t=$(),n=IS();let r={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new n.Scalar(Symbol(`<<`)),{addToJSMap:a}),stringify:()=>`<<`},i=(e,i)=>(r.identify(i)||t.isScalar(i)&&(!i.type||i.type===n.Scalar.PLAIN)&&r.identify(i.value))&&e?.doc.schema.tags.some(e=>e.tag===r.tag&&e.default);function a(e,n,r){let i=s(e,r);if(t.isSeq(i))for(let t of i.items)o(e,n,t);else if(Array.isArray(i))for(let t of i)o(e,n,t);else o(e,n,i)}function o(e,n,r){let i=s(e,r);if(!t.isMap(i))throw Error(`Merge sources must be maps or map aliases`);let a=i.toJSON(null,e,Map);for(let[e,t]of a)n instanceof Map?n.has(e)||n.set(e,t):n instanceof Set?n.add(e):Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0});return n}function s(e,n){return e&&t.isAlias(n)?n.resolve(e.doc,e):n}e.addMergeToJSMap=a,e.isMergeKey=i,e.merge=r})),KS=/* @__PURE__ */ D((e=>{var t=WS(),n=GS(),r=HS(),i=$(),a=NS();function o(e,t,{key:r,value:o}){if(i.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(n.isMergeKey(e,r))n.addMergeToJSMap(e,t,o);else{let n=a.toJS(r,``,e);if(t instanceof Map)t.set(n,a.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=s(r,n,e),c=a.toJS(o,i,e);i in t?Object.defineProperty(t,i,{value:c,writable:!0,enumerable:!0,configurable:!0}):t[i]=c}}return t}function s(e,n,a){if(n===null)return``;if(typeof n!=`object`)return String(n);if(i.isNode(e)&&a?.doc){let n=r.createStringifyContext(a.doc,{});n.anchors=/* @__PURE__ */ new Set;for(let e of a.anchors.keys())n.anchors.add(e.anchor);n.inFlow=!0,n.inStringifyKey=!0;let i=e.toString(n);if(!a.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+`..."`),t.warn(a.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),a.mapKeyWarned=!0}return i}return JSON.stringify(n)}e.addPairToJSMap=o})),qS=/* @__PURE__ */ D((e=>{var t=LS(),n=US(),r=KS(),i=$();function a(e,n,r){return new o(t.createNode(e,void 0,r),t.createNode(n,void 0,r))}var o=class e{constructor(e,t=null){Object.defineProperty(this,i.NODE_TYPE,{value:i.PAIR}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return i.isNode(n)&&(n=n.clone(t)),i.isNode(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){let n=t?.mapAsMap?/* @__PURE__ */ new Map:{};return r.addPairToJSMap(t,n,this)}toString(e,t,r){return e?.doc?n.stringifyPair(this,e,t,r):JSON.stringify(this)}};e.Pair=o,e.createPair=a})),JS=/* @__PURE__ */ D((e=>{var t=$(),n=HS(),r=zS();function i(e,t,n){return(t.inFlow??e.flow?o:a)(e,t,n)}function a({comment:e,items:i},a,{blockItemPrefix:o,flowChars:c,itemIndent:l,onChompKeep:u,onComment:d}){let{indent:f,options:{commentString:p}}=a,m=Object.assign({},a,{indent:l,type:null}),h=!1,g=[];for(let e=0;e<i.length;++e){let c=i[e],u=null;if(t.isNode(c))!h&&c.spaceBefore&&g.push(``),s(a,g,c.commentBefore,h),c.comment&&(u=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(!h&&e.spaceBefore&&g.push(``),s(a,g,e.commentBefore,h))}h=!1;let d=n.stringify(c,m,()=>u=null,()=>h=!0);u&&(d+=r.lineComment(d,l,p(u))),h&&u&&(h=!1),g.push(o+d)}let _;if(g.length===0)_=c.start+c.end;else{_=g[0];for(let e=1;e<g.length;++e){let t=g[e];_+=t?`\n${f}${t}`:`
|
|
238
239
|
`}}return e?(_+=`
|
|
239
240
|
`+r.indentComment(p(e),f),d&&d()):h&&u&&u(),_}function o({items:e},i,{flowChars:a,itemIndent:o}){let{indent:c,indentStep:l,flowCollectionPadding:u,options:{commentString:d}}=i;o+=l;let f=Object.assign({},i,{indent:o,inFlow:!0,type:null}),p=!1,m=0,h=[];for(let a=0;a<e.length;++a){let c=e[a],l=null;if(t.isNode(c))c.spaceBefore&&h.push(``),s(i,h,c.commentBefore,!1),c.comment&&(l=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(e.spaceBefore&&h.push(``),s(i,h,e.commentBefore,!1),e.comment&&(p=!0));let n=t.isNode(c.value)?c.value:null;n?(n.comment&&(l=n.comment),n.commentBefore&&(p=!0)):c.value==null&&e?.comment&&(l=e.comment)}l&&(p=!0);let u=n.stringify(c,f,()=>l=null);p||=h.length>m||u.includes(`
|
|
240
241
|
`),a<e.length-1?u+=`,`:i.options.trailingComma&&(i.options.lineWidth>0&&(p||=h.reduce((e,t)=>e+t.length+2,2)+(u.length+2)>i.options.lineWidth),p&&(u+=`,`)),l&&(u+=r.lineComment(u,o,d(l))),h.push(u),m=h.length}let{start:g,end:_}=a;if(h.length===0)return g+_;if(!p){let e=h.reduce((e,t)=>e+t.length+2,2);p=i.options.lineWidth>0&&e>i.options.lineWidth}if(p){let e=g;for(let t of h)e+=t?`\n${l}${c}${t}`:`
|
|
241
|
-
`;return`${e}\n${c}${_}`}return`${g}${u}${h.join(` `)}${u}${_}`}function s({indent:e,options:{commentString:t}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,``)),i){let a=r.indentComment(t(i),e);n.push(a.trimStart())}}e.stringifyCollection=i})),
|
|
242
|
-
`:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),oC=/* @__PURE__ */ D((e=>{var t=$(),n=GS(),r=PS(),i=YS();function a(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function o(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e)){if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let s={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:a,createNode:o};e.createPairs=o,e.pairs=s,e.resolvePairs=a})),sC=/* @__PURE__ */ D((e=>{var t=$(),n=jS(),r=qS(),i=YS(),a=oC(),o=class e extends i.YAMLSeq{constructor(){super(),this.add=r.YAMLMap.prototype.add.bind(this),this.delete=r.YAMLMap.prototype.delete.bind(this),this.get=r.YAMLMap.prototype.get.bind(this),this.has=r.YAMLMap.prototype.has.bind(this),this.set=r.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=/* @__PURE__ */ new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),cC=/* @__PURE__ */ D((e=>{var t=PS();function n({value:e,source:t},n){return t&&(e?r:i).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}let r={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:n},i={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:n};e.falseTag=i,e.trueTag=r})),lC=/* @__PURE__ */ D((e=>{var t=PS(),n=eC();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),uC=/* @__PURE__ */ D((e=>{var t=eC();let n=e=>typeof e==`bigint`||Number.isInteger(e);function r(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function i(e,r,i){let{value:a}=e;if(n(a)){let e=a.toString(r);return a<0?`-`+i+e.substr(1):i+e}return t.stringifyNumber(e)}let a={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>r(e,2,2,n),stringify:e=>i(e,2,`0b`)},o={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>r(e,1,8,n),stringify:e=>i(e,8,`0`)},s={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},c={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)};e.int=s,e.intBin=a,e.intHex=c,e.intOct=o})),dC=/* @__PURE__ */ D((e=>{var t=$(),n=GS(),r=qS(),i=class e extends r.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),fC=/* @__PURE__ */ D((e=>{var t=eC();function n(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function r(e){let{value:n}=e,r=e=>e;if(typeof n==`bigint`)r=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let i=``;n<0&&(i=`-`,n*=r(-1));let a=r(60),o=[n%a];return n<60?o.unshift(0):(n=(n-o[0])/a,o.unshift(n%a),n>=60&&(n=(n-o[0])/a,o.unshift(n))),i+o.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let i={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>n(e,r),stringify:r},a={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>n(e,!1),stringify:r},o={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(o.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,r,i,a,s,c,l]=t.map(Number),u=t[7]?Number((t[7]+`00`).substr(1,3)):0,d=Date.UTC(r,i-1,a,s||0,c||0,l||0,u),f=t[8];if(f&&f!==`Z`){let e=n(f,!1);Math.abs(e)<30&&(e*=60),d-=6e4*e}return new Date(d)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=a,e.intTime=i,e.timestamp=o})),pC=/* @__PURE__ */ D((e=>{var t=JS(),n=QS(),r=XS(),i=ZS(),a=aC(),o=cC(),s=lC(),c=uC(),l=US(),u=sC(),d=oC(),f=dC(),p=fC();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,f.set,p.intTime,p.floatTime,p.timestamp]})),mC=/* @__PURE__ */ D((e=>{var t=JS(),n=QS(),r=XS(),i=ZS(),a=$S(),o=tC(),s=nC(),c=rC(),l=iC(),u=aC(),d=US(),f=sC(),p=oC(),m=pC(),h=dC(),g=fC();let _=/* @__PURE__ */ new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,m.schema],[`yaml-1.1`,m.schema]]),v={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:g.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:g.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:f.omap,pairs:p.pairs,seq:r.seq,set:h.set,timestamp:g.timestamp},y={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":f.omap,"tag:yaml.org,2002:pairs":p.pairs,"tag:yaml.org,2002:set":h.set,"tag:yaml.org,2002:timestamp":g.timestamp};function b(e,t,n){let r=_.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(_.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?v[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(v).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=y,e.getTags=b})),hC=/* @__PURE__ */ D((e=>{var t=$(),n=JS(),r=XS(),i=ZS(),a=mC();let o=(e,t)=>e.key<t.key?-1:+(e.key>t.key);e.Schema=class e{constructor({compat:e,customTags:s,merge:c,resolveKnownTags:l,schema:u,sortMapEntries:d,toStringDefaults:f}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof u==`string`&&u||`core`,this.knownTags=l?a.coreKnownTags:{},this.tags=a.getTags(s,this.name,c),this.toStringOptions=f??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof d==`function`?d:d===!0?o:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}}})),gC=/* @__PURE__ */ D((e=>{var t=$(),n=BS(),r=LS();function i(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd){if(e.comment){let t=c(e.comment);t.includes(`
|
|
242
|
+
`;return`${e}\n${c}${_}`}return`${g}${u}${h.join(` `)}${u}${_}`}function s({indent:e,options:{commentString:t}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,``)),i){let a=r.indentComment(t(i),e);n.push(a.trimStart())}}e.stringifyCollection=i})),YS=/* @__PURE__ */ D((e=>{var t=JS(),n=KS(),r=RS(),i=$(),a=qS(),o=IS();function s(e,t){let n=i.isScalar(t)?t.value:t;for(let r of e)if(i.isPair(r)&&(r.key===t||r.key===n||i.isScalar(r.key)&&r.key.value===n))return r}e.YAMLMap=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(i.MAP,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,o=new this(e),s=(e,s)=>{if(typeof i==`function`)s=i.call(t,e,s);else if(Array.isArray(i)&&!i.includes(e))return;(s!==void 0||r)&&o.items.push(a.createPair(e,s,n))};if(t instanceof Map)for(let[e,n]of t)s(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))s(e,t[e]);return typeof e.sortMapEntries==`function`&&o.items.sort(e.sortMapEntries),o}add(e,t){let n;n=i.isPair(e)?e:!e||typeof e!=`object`||!(`key`in e)?new a.Pair(e,e?.value):new a.Pair(e.key,e.value);let r=s(this.items,n.key),c=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);i.isScalar(r.value)&&o.isScalarValue(n.value)?r.value.value=n.value:r.value=n.value}else if(c){let e=this.items.findIndex(e=>c(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=s(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=s(this.items,e)?.value;return(!t&&i.isScalar(n)?n.value:n)??void 0}has(e){return!!s(this.items,e)}set(e,t){this.add(new a.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?/* @__PURE__ */ new Map:{};t?.onCreate&&t.onCreate(i);for(let e of this.items)n.addPairToJSMap(t,i,e);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!i.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),t.stringifyCollection(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:r,onComment:n})}},e.findPair=s})),XS=/* @__PURE__ */ D((e=>{var t=$(),n=YS();e.map={collection:`map`,default:!0,nodeClass:n.YAMLMap,tag:`tag:yaml.org,2002:map`,resolve(e,n){return t.isMap(e)||n(`Expected a mapping for this tag`),e},createNode:(e,t,r)=>n.YAMLMap.from(e,t,r)}})),ZS=/* @__PURE__ */ D((e=>{var t=LS(),n=JS(),r=RS(),i=$(),a=IS(),o=NS(),s=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(i.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=c(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=c(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&i.isScalar(r)?r.value:r}has(e){let t=c(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=c(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];i.isScalar(r)&&a.isScalarValue(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(o.toJS(e,String(r++),t));return n}toString(e,t,r){return e?n.stringifyCollection(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,n,r){let{replacer:i}=r,a=new this(e);if(n&&Symbol.iterator in Object(n)){let e=0;for(let o of n){if(typeof i==`function`){let t=n instanceof Set?o:String(e++);o=i.call(n,t,o)}a.items.push(t.createNode(o,void 0,r))}}return a}};function c(e){let t=i.isScalar(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}e.YAMLSeq=s})),QS=/* @__PURE__ */ D((e=>{var t=$(),n=ZS();e.seq={collection:`seq`,default:!0,nodeClass:n.YAMLSeq,tag:`tag:yaml.org,2002:seq`,resolve(e,n){return t.isSeq(e)||n(`Expected a sequence for this tag`),e},createNode:(e,t,r)=>n.YAMLSeq.from(e,t,r)}})),$S=/* @__PURE__ */ D((e=>{var t=VS();e.string={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,n,r,i){return n=Object.assign({actualString:!0},n),t.stringifyString(e,n,r,i)}}})),eC=/* @__PURE__ */ D((e=>{var t=IS();let n={identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new t.Scalar(null),stringify:({source:e},t)=>typeof e==`string`&&n.test.test(e)?e:t.options.nullStr};e.nullTag=n})),tC=/* @__PURE__ */ D((e=>{var t=IS();let n={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new t.Scalar(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},r){return e&&n.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?r.options.trueStr:r.options.falseStr}};e.boolTag=n})),nC=/* @__PURE__ */ D((e=>{function t({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}e.stringifyNumber=t})),rC=/* @__PURE__ */ D((e=>{var t=IS(),n=nC();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let n=new t.Scalar(parseFloat(e)),r=e.indexOf(`.`);return r!==-1&&e[e.length-1]===`0`&&(n.minFractionDigits=e.length-r-1),n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),iC=/* @__PURE__ */ D((e=>{var t=nC();let n=e=>typeof e==`bigint`||Number.isInteger(e),r=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function i(e,r,i){let{value:a}=e;return n(a)&&a>=0?i+a.toString(r):t.stringifyNumber(e)}e.int={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},e.intHex={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)},e.intOct={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>r(e,2,8,n),stringify:e=>i(e,8,`0o`)}})),aC=/* @__PURE__ */ D((e=>{var t=XS(),n=eC(),r=QS(),i=$S(),a=tC(),o=rC(),s=iC();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),oC=/* @__PURE__ */ D((e=>{var t=IS(),n=XS(),r=QS();function i(e){return typeof e==`bigint`||Number.isInteger(e)}let a=({value:e})=>JSON.stringify(e),o=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:a},{identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:a},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:a},{identify:i,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>i(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:a}];e.schema=[n.map,r.seq].concat(o,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}})})),sC=/* @__PURE__ */ D((e=>{var t=de(`buffer`),n=IS(),r=VS();e.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,n){if(typeof t.Buffer==`function`)return t.Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return n(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:i,value:a},o,s,c){if(!a)return``;let l=a,u;if(typeof t.Buffer==`function`)u=l instanceof t.Buffer?l.toString(`base64`):t.Buffer.from(l.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<l.length;++t)e+=String.fromCharCode(l[t]);u=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(i??=n.Scalar.BLOCK_LITERAL,i!==n.Scalar.QUOTE_DOUBLE){let e=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),t=Math.ceil(u.length/e),r=Array(t);for(let n=0,i=0;n<t;++n,i+=e)r[n]=u.substr(i,e);u=r.join(i===n.Scalar.BLOCK_LITERAL?`
|
|
243
|
+
`:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),cC=/* @__PURE__ */ D((e=>{var t=$(),n=qS(),r=IS(),i=ZS();function a(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function o(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e)){if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let s={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:a,createNode:o};e.createPairs=o,e.pairs=s,e.resolvePairs=a})),lC=/* @__PURE__ */ D((e=>{var t=$(),n=NS(),r=YS(),i=ZS(),a=cC(),o=class e extends i.YAMLSeq{constructor(){super(),this.add=r.YAMLMap.prototype.add.bind(this),this.delete=r.YAMLMap.prototype.delete.bind(this),this.get=r.YAMLMap.prototype.get.bind(this),this.has=r.YAMLMap.prototype.has.bind(this),this.set=r.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=/* @__PURE__ */ new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),uC=/* @__PURE__ */ D((e=>{var t=IS();function n({value:e,source:t},n){return t&&(e?r:i).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}let r={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:n},i={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:n};e.falseTag=i,e.trueTag=r})),dC=/* @__PURE__ */ D((e=>{var t=IS(),n=nC();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),fC=/* @__PURE__ */ D((e=>{var t=nC();let n=e=>typeof e==`bigint`||Number.isInteger(e);function r(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function i(e,r,i){let{value:a}=e;if(n(a)){let e=a.toString(r);return a<0?`-`+i+e.substr(1):i+e}return t.stringifyNumber(e)}let a={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>r(e,2,2,n),stringify:e=>i(e,2,`0b`)},o={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>r(e,1,8,n),stringify:e=>i(e,8,`0`)},s={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},c={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)};e.int=s,e.intBin=a,e.intHex=c,e.intOct=o})),pC=/* @__PURE__ */ D((e=>{var t=$(),n=qS(),r=YS(),i=class e extends r.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),mC=/* @__PURE__ */ D((e=>{var t=nC();function n(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function r(e){let{value:n}=e,r=e=>e;if(typeof n==`bigint`)r=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let i=``;n<0&&(i=`-`,n*=r(-1));let a=r(60),o=[n%a];return n<60?o.unshift(0):(n=(n-o[0])/a,o.unshift(n%a),n>=60&&(n=(n-o[0])/a,o.unshift(n))),i+o.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let i={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>n(e,r),stringify:r},a={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>n(e,!1),stringify:r},o={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(o.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,r,i,a,s,c,l]=t.map(Number),u=t[7]?Number((t[7]+`00`).substr(1,3)):0,d=Date.UTC(r,i-1,a,s||0,c||0,l||0,u),f=t[8];if(f&&f!==`Z`){let e=n(f,!1);Math.abs(e)<30&&(e*=60),d-=6e4*e}return new Date(d)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=a,e.intTime=i,e.timestamp=o})),hC=/* @__PURE__ */ D((e=>{var t=XS(),n=eC(),r=QS(),i=$S(),a=sC(),o=uC(),s=dC(),c=fC(),l=GS(),u=lC(),d=cC(),f=pC(),p=mC();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,f.set,p.intTime,p.floatTime,p.timestamp]})),gC=/* @__PURE__ */ D((e=>{var t=XS(),n=eC(),r=QS(),i=$S(),a=tC(),o=rC(),s=iC(),c=aC(),l=oC(),u=sC(),d=GS(),f=lC(),p=cC(),m=hC(),h=pC(),g=mC();let _=/* @__PURE__ */ new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,m.schema],[`yaml-1.1`,m.schema]]),v={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:g.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:g.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:f.omap,pairs:p.pairs,seq:r.seq,set:h.set,timestamp:g.timestamp},y={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":f.omap,"tag:yaml.org,2002:pairs":p.pairs,"tag:yaml.org,2002:set":h.set,"tag:yaml.org,2002:timestamp":g.timestamp};function b(e,t,n){let r=_.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(_.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?v[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(v).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=y,e.getTags=b})),_C=/* @__PURE__ */ D((e=>{var t=$(),n=XS(),r=QS(),i=$S(),a=gC();let o=(e,t)=>e.key<t.key?-1:+(e.key>t.key);e.Schema=class e{constructor({compat:e,customTags:s,merge:c,resolveKnownTags:l,schema:u,sortMapEntries:d,toStringDefaults:f}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof u==`string`&&u||`core`,this.knownTags=l?a.coreKnownTags:{},this.tags=a.getTags(s,this.name,c),this.toStringOptions=f??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof d==`function`?d:d===!0?o:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}}})),vC=/* @__PURE__ */ D((e=>{var t=$(),n=HS(),r=zS();function i(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd){if(e.comment){let t=c(e.comment);t.includes(`
|
|
243
244
|
`)?(a.push(`...`),a.push(r.indentComment(t,``))):a.push(`... ${t}`)}else a.push(`...`)}else{let t=e.comment;t&&l&&(t=t.replace(/^\n+/,``)),t&&((!l||u)&&a[a.length-1]!==``&&a.push(``),a.push(r.indentComment(c(t),``)))}return a.join(`
|
|
244
245
|
`)+`
|
|
245
|
-
`}e.stringifyDocument=i})),
|
|
246
|
-
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}}})),
|
|
247
|
-
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let n of e.items){for(let e of n.start)if(e.type===`newline`)return!0;if(n.sep){for(let e of n.sep)if(e.type===`newline`)return!0}if(t(n.key)||t(n.value))return!0}return!1;default:return!0}}e.containsNewline=t})),
|
|
246
|
+
`}e.stringifyDocument=i})),yC=/* @__PURE__ */ D((e=>{var t=FS(),n=RS(),r=$(),i=qS(),a=NS(),o=_C(),s=vC(),c=jS(),l=MS(),u=LS(),d=AS(),f=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,r.NODE_TYPE,{value:r.DOC});let i=null;typeof t==`function`||Array.isArray(t)?i=t:n===void 0&&t&&(n=t,t=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=a;let{version:o}=a;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new d.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let t=Object.create(e.prototype,{[r.NODE_TYPE]:{value:r.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=r.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){p(this.contents)&&this.contents.add(e)}addIn(e,t){p(this.contents)&&this.contents.addIn(e,t)}createAlias(e,n){if(!e.anchor){let t=c.anchorNames(this);e.anchor=!n||t.has(n)?c.findNewAnchor(n||`a`,t):n}return new t.Alias(e.anchor)}createNode(e,t,n){let i;if(typeof t==`function`)e=t.call({"":e},``,e),i=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),i=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:d,tag:f}=n??{},{onAnchor:p,setAnchors:m,sourceObjects:h}=c.createNodeAnchors(this,o||`a`),g={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:p,onTagObj:d,replacer:i,schema:this.schema,sourceObjects:h},_=u.createNode(e,f,g);return s&&r.isCollection(_)&&(_.flow=!0),m(),_}createPair(e,t,n={}){let r=this.createNode(e,null,n),a=this.createNode(t,null,n);return new i.Pair(r,a)}delete(e){return p(this.contents)?this.contents.delete(e):!1}deleteIn(e){return n.isEmptyPath(e)?this.contents!=null&&(this.contents=null,!0):p(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return r.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return n.isEmptyPath(e)?!t&&r.isScalar(this.contents)?this.contents.value:this.contents:r.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return r.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return n.isEmptyPath(e)?this.contents!==void 0:r.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=n.collectionFromPath(this.schema,[e],t):p(this.contents)&&this.contents.set(e,t)}setIn(e,t){n.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=n.collectionFromPath(this.schema,Array.from(e),t):p(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new d.Directives({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new d.Directives({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new o.Schema(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){let s={anchors:/* @__PURE__ */ new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},c=a.toJS(this.contents,t??``,s);if(typeof i==`function`)for(let{count:e,res:t}of s.anchors.values())i(t,e);return typeof o==`function`?l.applyReviver(o,{"":c},``,c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return s.stringifyDocument(this,e)}};function p(e){if(r.isCollection(e))return!0;throw Error(`Expected a YAML collection as document contents`)}e.Document=f})),bC=/* @__PURE__ */ D((e=>{var t=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},n=class extends t{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},r=class extends t{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}};e.YAMLError=t,e.YAMLParseError=n,e.YAMLWarning=r,e.prettifyError=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
|
|
247
|
+
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}}})),xC=/* @__PURE__ */ D((e=>{function t(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:b&&n===`seq-item-ind`||(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}e.resolveProps=t})),SC=/* @__PURE__ */ D((e=>{function t(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
|
|
248
|
+
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let n of e.items){for(let e of n.start)if(e.type===`newline`)return!0;if(n.sep){for(let e of n.sep)if(e.type===`newline`)return!0}if(t(n.key)||t(n.value))return!0}return!1;default:return!0}}e.containsNewline=t})),CC=/* @__PURE__ */ D((e=>{var t=SC();function n(e,n,r){if(n?.type===`flow-collection`){let i=n.end[0];i.indent===e&&(i.source===`]`||i.source===`}`)&&t.containsNewline(n)&&r(i,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}e.flowIndentCheck=n})),wC=/* @__PURE__ */ D((e=>{var t=$();function n(e,n,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let a=typeof i==`function`?i:(e,n)=>e===n||t.isScalar(e)&&t.isScalar(n)&&e.value===n.value;return n.some(e=>a(e.key,r))}e.mapIncludes=n})),TC=/* @__PURE__ */ D((e=>{var t=qS(),n=YS(),r=xC(),i=SC(),a=CC(),o=wC();let s=`All mapping items must start at the same column`;function c({composeNode:e,composeEmptyNode:c},l,u,d,f){let p=new((f?.nodeClass)??n.YAMLMap)(l.schema);l.atRoot&&=!1;let m=u.offset,h=null;for(let n of u.items){let{start:f,key:g,sep:_,value:v}=n,y=r.resolveProps(f,{indicator:`explicit-key-ind`,next:g??_?.[0],offset:m,onError:d,parentIndent:u.indent,startOnNewline:!0}),b=!y.found;if(b){if(g&&(g.type===`block-seq`?d(m,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in g&&g.indent!==u.indent&&d(m,`BAD_INDENT`,s)),!y.anchor&&!y.tag&&!_){h=y.end,y.comment&&(p.comment?p.comment+=`
|
|
248
249
|
`+y.comment:p.comment=y.comment);continue}(y.newlineAfterProp||i.containsNewline(g))&&d(g??f[f.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else y.found?.indent!==u.indent&&d(m,`BAD_INDENT`,s);l.atKey=!0;let x=y.end,S=g?e(l,g,y,d):c(l,x,f,null,y,d);l.schema.compat&&a.flowIndentCheck(u.indent,g,d),l.atKey=!1,o.mapIncludes(l,p.items,S)&&d(x,`DUPLICATE_KEY`,`Map keys must be unique`);let C=r.resolveProps(_??[],{indicator:`map-value-ind`,next:v,offset:S.range[2],onError:d,parentIndent:u.indent,startOnNewline:!g||g.type===`block-scalar`});if(m=C.end,C.found){b&&(v?.type===`block-map`&&!C.hasNewline&&d(m,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),l.options.strict&&y.start<C.found.offset-1024&&d(S.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let r=v?e(l,v,C,d):c(l,m,_,null,C,d);l.schema.compat&&a.flowIndentCheck(u.indent,v,d),m=r.range[2];let i=new t.Pair(S,r);l.options.keepSourceTokens&&(i.srcToken=n),p.items.push(i)}else{b&&d(S.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),C.comment&&(S.comment?S.comment+=`
|
|
249
|
-
`+C.comment:S.comment=C.comment);let e=new t.Pair(S);l.options.keepSourceTokens&&(e.srcToken=n),p.items.push(e)}}return h&&h<m&&d(h,`IMPOSSIBLE`,`Map comment with trailing content`),p.range=[u.offset,m,h??m],p}e.resolveBlockMap=c})),
|
|
250
|
+
`+C.comment:S.comment=C.comment);let e=new t.Pair(S);l.options.keepSourceTokens&&(e.srcToken=n),p.items.push(e)}}return h&&h<m&&d(h,`IMPOSSIBLE`,`Map comment with trailing content`),p.range=[u.offset,m,h??m],p}e.resolveBlockMap=c})),EC=/* @__PURE__ */ D((e=>{var t=ZS(),n=xC(),r=CC();function i({composeNode:e,composeEmptyNode:i},a,o,s,c){let l=new((c?.nodeClass)??t.YAMLSeq)(a.schema);a.atRoot&&=!1,a.atKey&&=!1;let u=o.offset,d=null;for(let{start:t,value:c}of o.items){let f=n.resolveProps(t,{indicator:`seq-item-ind`,next:c,offset:u,onError:s,parentIndent:o.indent,startOnNewline:!0});if(!f.found){if(f.anchor||f.tag||c)c?.type===`block-seq`?s(f.end,`BAD_INDENT`,`All sequence items must start at the same column`):s(u,`MISSING_CHAR`,`Sequence item without - indicator`);else{d=f.end,f.comment&&(l.comment=f.comment);continue}}let p=c?e(a,c,f,s):i(a,f.end,t,null,f,s);a.schema.compat&&r.flowIndentCheck(o.indent,c,s),u=p.range[2],l.items.push(p)}return l.range=[o.offset,u,d??u],l}e.resolveBlockSeq=i})),DC=/* @__PURE__ */ D((e=>{function t(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}e.resolveEnd=t})),OC=/* @__PURE__ */ D((e=>{var t=$(),n=qS(),r=YS(),i=ZS(),a=DC(),o=xC(),s=SC(),c=wC();let l=`Block collections are not allowed within flow collections`,u=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function d({composeNode:e,composeEmptyNode:d},f,p,m,h){let g=p.start.source===`{`,_=g?`flow map`:`flow sequence`,v=new((h?.nodeClass)??(g?r.YAMLMap:i.YAMLSeq))(f.schema);v.flow=!0;let y=f.atRoot;y&&(f.atRoot=!1),f.atKey&&=!1;let b=p.offset+p.start.source.length;for(let i=0;i<p.items.length;++i){let a=p.items[i],{start:h,key:y,sep:x,value:S}=a,C=o.resolveProps(h,{flow:_,indicator:`explicit-key-ind`,next:y??x?.[0],offset:b,onError:m,parentIndent:p.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!x&&!S){i===0&&C.comma?m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`):i<p.items.length-1&&m(C.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${_}`),C.comment&&(v.comment?v.comment+=`
|
|
250
251
|
`+C.comment:v.comment=C.comment),b=C.end;continue}!g&&f.options.strict&&s.containsNewline(y)&&m(y,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(i===0)C.comma&&m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`);else if(C.comma||m(C.start,`MISSING_CHAR`,`Missing , between ${_} items`),C.comment){let e=``;loop:for(let t of h)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let n=v.items[v.items.length-1];t.isPair(n)&&(n=n.value??n.key),n.comment?n.comment+=`
|
|
251
252
|
`+e:n.comment=e,C.comment=C.comment.substring(e.length+1)}}if(!g&&!x&&!C.found){let t=S?e(f,S,C,m):d(f,C.end,x,null,C,m);v.items.push(t),b=t.range[2],u(S)&&m(t.range,`BLOCK_IN_FLOW`,l)}else{f.atKey=!0;let t=C.end,i=y?e(f,y,C,m):d(f,t,h,null,C,m);u(y)&&m(i.range,`BLOCK_IN_FLOW`,l),f.atKey=!1;let s=o.resolveProps(x??[],{flow:_,indicator:`map-value-ind`,next:S,offset:i.range[2],onError:m,parentIndent:p.indent,startOnNewline:!1});if(s.found){if(!g&&!C.found&&f.options.strict){if(x)for(let e of x){if(e===s.found)break;if(e.type===`newline`){m(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}C.start<s.found.offset-1024&&m(s.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else S&&(`source`in S&&S.source?.[0]===`:`?m(S,`MISSING_CHAR`,`Missing space after : in ${_}`):m(s.start,`MISSING_CHAR`,`Missing , or : between ${_} items`));let w=S?e(f,S,s,m):s.found?d(f,s.end,x,null,s,m):null;w?u(S)&&m(w.range,`BLOCK_IN_FLOW`,l):s.comment&&(i.comment?i.comment+=`
|
|
252
253
|
`+s.comment:i.comment=s.comment);let T=new n.Pair(i,w);if(f.options.keepSourceTokens&&(T.srcToken=a),g){let e=v;c.mapIncludes(f,e.items,i)&&m(t,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(T)}else{let e=new r.YAMLMap(f.schema);e.flow=!0,e.items.push(T);let t=(w??i).range;e.range=[i.range[0],t[1],t[2]],v.items.push(e)}b=w?w.range[2]:s.end}}let x=g?`}`:`]`,[S,...C]=p.end,w=b;if(S?.source===x)w=S.offset+S.source.length;else{let e=_[0].toUpperCase()+_.substring(1),t=y?`${e} must end with a ${x}`:`${e} in block collection must be sufficiently indented and end with a ${x}`;m(b,y?`MISSING_CHAR`:`BAD_INDENT`,t),S&&S.source.length!==1&&C.unshift(S)}if(C.length>0){let e=a.resolveEnd(C,w,f.options.strict,m);e.comment&&(v.comment?v.comment+=`
|
|
253
|
-
`+e.comment:v.comment=e.comment),v.range=[p.offset,w,e.offset]}else v.range=[p.offset,w,w];return v}e.resolveFlowCollection=d})),
|
|
254
|
+
`+e.comment:v.comment=e.comment),v.range=[p.offset,w,e.offset]}else v.range=[p.offset,w,w];return v}e.resolveFlowCollection=d})),kC=/* @__PURE__ */ D((e=>{var t=$(),n=IS(),r=YS(),i=ZS(),a=TC(),o=EC(),s=OC();function c(e,t,n,r,i,c){let l=n.type===`block-map`?a.resolveBlockMap(e,t,n,r,c):n.type===`block-seq`?o.resolveBlockSeq(e,t,n,r,c):s.resolveFlowCollection(e,t,n,r,c),u=l.constructor;return i===`!`||i===u.tagName?(l.tag=u.tagName,l):(i&&(l.tag=i),l)}function l(e,a,o,s,l){let u=s.tag,d=u?a.directives.tagName(u.source,e=>l(u,`TAG_RESOLVE_FAILED`,e)):null;if(o.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=s,n=e&&u?e.offset>u.offset?e:u:e??u;n&&(!t||t.offset<n.offset)&&l(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let f=o.type===`block-map`?`map`:o.type===`block-seq`?`seq`:o.start.source===`{`?`map`:`seq`;if(!u||!d||d===`!`||d===r.YAMLMap.tagName&&f===`map`||d===i.YAMLSeq.tagName&&f===`seq`)return c(e,a,o,l,d);let p=a.schema.tags.find(e=>e.tag===d&&e.collection===f);if(!p){let t=a.schema.knownTags[d];if(t?.collection===f)a.schema.tags.push(Object.assign({},t,{default:!1})),p=t;else return t?l(u,`BAD_COLLECTION_TYPE`,`${t.tag} used for ${f} collection, but expects ${t.collection??`scalar`}`,!0):l(u,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${d}`,!0),c(e,a,o,l,d)}let m=c(e,a,o,l,d,p),h=p.resolve?.(m,e=>l(u,`TAG_RESOLVE_FAILED`,e),a.options)??m,g=t.isNode(h)?h:new n.Scalar(h);return g.range=m.range,g.tag=d,p?.format&&(g.format=p.format),g}e.composeCollection=l})),AC=/* @__PURE__ */ D((e=>{var t=IS();function n(e,n,a){let o=n.offset,s=r(n,e.options.strict,a);if(!s)return{value:``,type:null,comment:``,range:[o,o,o]};let c=s.mode===`>`?t.Scalar.BLOCK_FOLDED:t.Scalar.BLOCK_LITERAL,l=n.source?i(n.source):[],u=l.length;for(let e=l.length-1;e>=0;--e){let t=l[e][1];if(t===``||t===`\r`)u=e;else break}if(u===0){let e=s.chomp===`+`&&l.length>0?`
|
|
254
255
|
`.repeat(Math.max(1,l.length-1)):``,t=o+s.length;return n.source&&(t+=n.source.length),{value:e,type:c,comment:s.comment,range:[o,t,t]}}let d=n.indent+s.indent,f=n.offset+s.length,p=0;for(let t=0;t<u;++t){let[n,r]=l[t];if(r===``||r===`\r`)s.indent===0&&n.length>d&&(d=n.length);else{n.length<d&&a(f+n.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),s.indent===0&&(d=n.length),p=t,d===0&&!e.atRoot&&a(f,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}f+=n.length+r.length+1}for(let e=l.length-1;e>=u;--e)l[e][0].length>d&&(u=e+1);let m=``,h=``,g=!1;for(let e=0;e<p;++e)m+=l[e][0].slice(d)+`
|
|
255
256
|
`;for(let e=p;e<u;++e){let[n,r]=l[e];f+=n.length+r.length+1;let i=r[r.length-1]===`\r`;
|
|
256
257
|
/* istanbul ignore if already caught in lexer */
|
|
@@ -271,7 +272,7 @@ if(i&&(r=r.slice(0,-1)),r&&n.length<d){let e=`Block scalar lines must not be les
|
|
|
271
272
|
/* istanbul ignore if should not happen */
|
|
272
273
|
if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;
|
|
273
274
|
/* istanbul ignore next should not happen */
|
|
274
|
-
default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function i(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}e.resolveBlockScalar=n})),
|
|
275
|
+
default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function i(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}e.resolveBlockScalar=n})),jC=/* @__PURE__ */ D((e=>{var t=IS(),n=DC();function r(e,r,o){let{offset:c,type:l,source:u,end:d}=e,f,p,m=(e,t,n)=>o(c+e,t,n);switch(l){case`scalar`:f=t.Scalar.PLAIN,p=i(u,m);break;case`single-quoted-scalar`:f=t.Scalar.QUOTE_SINGLE,p=a(u,m);break;case`double-quoted-scalar`:f=t.Scalar.QUOTE_DOUBLE,p=s(u,m);break;
|
|
275
276
|
/* istanbul ignore next should not happen */
|
|
276
277
|
default:return o(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${l}`),{value:``,type:null,comment:``,range:[c,c+u.length,c+u.length]}}let h=c+u.length,g=n.resolveEnd(d,h,r,o);return{value:p,type:f,comment:g.comment,range:[c,h,g.offset]}}function i(e,t){let n=``;switch(e[0]){
|
|
277
278
|
/* istanbul ignore next should not happen */
|
|
@@ -288,10 +289,10 @@ case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;c
|
|
|
288
289
|
`);)r===`
|
|
289
290
|
`&&(n+=`
|
|
290
291
|
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}let l={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
|
|
291
|
-
`,r:`\r`,t:` `,v:`\v`,N:`
`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function u(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}e.resolveFlowScalar=r})),
|
|
292
|
+
`,r:`\r`,t:` `,v:`\v`,N:`
`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function u(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}e.resolveFlowScalar=r})),MC=/* @__PURE__ */ D((e=>{var t=$(),n=IS(),r=AC(),i=jC();function a(e,a,c,l){let{value:u,type:d,comment:f,range:p}=a.type===`block-scalar`?r.resolveBlockScalar(e,a,l):i.resolveFlowScalar(a,e.options.strict,l),m=c?e.directives.tagName(c.source,e=>l(c,`TAG_RESOLVE_FAILED`,e)):null,h;h=e.options.stringKeys&&e.atKey?e.schema[t.SCALAR]:m?o(e.schema,u,m,c,l):a.type===`scalar`?s(e,u,a,l):e.schema[t.SCALAR];let g;try{let r=h.resolve(u,e=>l(c??a,`TAG_RESOLVE_FAILED`,e),e.options);g=t.isScalar(r)?r:new n.Scalar(r)}catch(e){let t=e instanceof Error?e.message:String(e);l(c??a,`TAG_RESOLVE_FAILED`,t),g=new n.Scalar(u)}return g.range=p,g.source=u,d&&(g.type=d),m&&(g.tag=m),h.format&&(g.format=h.format),f&&(g.comment=f),g}function o(e,n,r,i,a){if(r===`!`)return e[t.SCALAR];let o=[];for(let t of e.tags)if(!t.collection&&t.tag===r){if(t.default&&t.test)o.push(t);else return t}for(let e of o)if(e.test?.test(n))return e;let s=e.knownTags[r];return s&&!s.collection?(e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(a(i,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${r}`,r!==`tag:yaml.org,2002:str`),e[t.SCALAR])}function s({atKey:e,directives:n,schema:r},i,a,o){let s=r.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(i))||r[t.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[t.SCALAR];s.tag!==e.tag&&o(a,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${n.tagString(s.tag)} or ${n.tagString(e.tag)}`,!0)}return s}e.composeScalar=a})),NC=/* @__PURE__ */ D((e=>{function t(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}e.emptyScalarPosition=t})),PC=/* @__PURE__ */ D((e=>{var t=FS(),n=$(),r=kC(),i=MC(),a=DC(),o=NC();let s={composeNode:c,composeEmptyNode:l};function c(e,t,a,o){let c=e.atKey,{spaceBefore:d,comment:f,anchor:p,tag:m}=a,h,g=!0;switch(t.type){case`alias`:h=u(e,t,o),(p||m)&&o(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:h=i.composeScalar(e,t,m,o),p&&(h.anchor=p.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{h=r.composeCollection(s,e,t,a,o),p&&(h.anchor=p.source.substring(1))}catch(e){o(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:o(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),g=!1}return h??=l(e,t.offset,void 0,null,a,o),p&&h.anchor===``&&o(p,`BAD_ALIAS`,`Anchor cannot be an empty string`),c&&e.options.stringKeys&&(!n.isScalar(h)||typeof h.value!=`string`||h.tag&&h.tag!==`tag:yaml.org,2002:str`)&&o(m??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),d&&(h.spaceBefore=!0),f&&(t.type===`scalar`&&t.source===``?h.comment=f:h.commentBefore=f),e.options.keepSourceTokens&&g&&(h.srcToken=t),h}function l(e,t,n,r,{spaceBefore:a,comment:s,anchor:c,tag:l,end:u},d){let f={type:`scalar`,offset:o.emptyScalarPosition(t,n,r),indent:-1,source:``},p=i.composeScalar(e,f,l,d);return c&&(p.anchor=c.source.substring(1),p.anchor===``&&d(c,`BAD_ALIAS`,`Anchor cannot be an empty string`)),a&&(p.spaceBefore=!0),s&&(p.comment=s,p.range[2]=u),p}function u({options:e},{offset:n,source:r,end:i},o){let s=new t.Alias(r.substring(1));s.source===``&&o(n,`BAD_ALIAS`,`Alias cannot be an empty string`),s.source.endsWith(`:`)&&o(n+r.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let c=n+r.length,l=a.resolveEnd(i,c,e.strict,o);return s.range=[n,c,l.offset],l.comment&&(s.comment=l.comment),s}e.composeEmptyNode=l,e.composeNode=c})),FC=/* @__PURE__ */ D((e=>{var t=yC(),n=PC(),r=DC(),i=xC();function a(e,a,{offset:o,start:s,value:c,end:l},u){let d=Object.assign({_directives:a},e),f=new t.Document(void 0,d),p={atKey:!1,atRoot:!0,directives:f.directives,options:f.options,schema:f.schema},m=i.resolveProps(s,{indicator:`doc-start`,next:c??l?.[0],offset:o,onError:u,parentIndent:0,startOnNewline:!0});m.found&&(f.directives.docStart=!0,c&&(c.type===`block-map`||c.type===`block-seq`)&&!m.hasNewline&&u(m.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),f.contents=c?n.composeNode(p,c,m,u):n.composeEmptyNode(p,m.end,s,null,m,u);let h=f.contents.range[2],g=r.resolveEnd(l,h,!1,u);return g.comment&&(f.comment=g.comment),f.range=[o,h,g.offset],f}e.composeDoc=a})),IC=/* @__PURE__ */ D((e=>{var t=de(`process`),n=AS(),r=yC(),i=bC(),a=$(),o=FC(),s=DC();function c(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function l(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
|
|
292
293
|
|
|
293
294
|
`:`
|
|
294
|
-
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}e.Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=c(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=l(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:l(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=c(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}}})),
|
|
295
|
+
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}e.Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=c(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=l(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:l(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=c(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}}})),LC=/* @__PURE__ */ D((e=>{var t=AC(),n=jC(),r=bC(),i=VS();function a(e,i=!0,a){if(e){let o=(e,t,n)=>{let i=typeof e==`number`?e:Array.isArray(e)?e[0]:e.offset;if(a)a(i,t,n);else throw new r.YAMLParseError([i,i+1],t,n)};switch(e.type){case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return n.resolveFlowScalar(e,i,o);case`block-scalar`:return t.resolveBlockScalar({options:{strict:i}},e,o)}}return null}function o(e,t){let{implicitKey:n=!1,indent:r,inFlow:a=!1,offset:o=-1,type:s=`PLAIN`}=t,c=i.stringifyString({type:s,value:e},{implicitKey:n,indent:r>0?` `.repeat(r):``,inFlow:a,options:{blockQuote:!0,lineWidth:-1}}),u=t.end??[{type:`newline`,offset:-1,indent:r,source:`
|
|
295
296
|
`}];switch(c[0]){case`|`:case`>`:{let e=c.indexOf(`
|
|
296
297
|
`),t=c.substring(0,e),n=c.substring(e+1)+`
|
|
297
298
|
`,i=[{type:`block-scalar-header`,offset:o,indent:r,source:t}];return l(i,u)||i.push({type:`newline`,offset:-1,indent:r,source:`
|
|
@@ -299,11 +300,11 @@ case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;c
|
|
|
299
300
|
`),r=t.substring(0,n),i=t.substring(n+1)+`
|
|
300
301
|
`;if(e.type===`block-scalar`){let t=e.props[0];if(t.type!==`block-scalar-header`)throw Error(`Invalid block scalar header`);t.source=r,e.source=i}else{let{offset:t}=e,n=`indent`in e?e.indent:-1,a=[{type:`block-scalar-header`,offset:t,indent:n,source:r}];l(a,`end`in e?e.end:void 0)||a.push({type:`newline`,offset:-1,indent:n,source:`
|
|
301
302
|
`});for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:`block-scalar`,indent:n,props:a,source:i})}}function l(e,t){if(t)for(let n of t)switch(n.type){case`space`:case`comment`:e.push(n);break;case`newline`:return e.push(n),!0}return!1}function u(e,t,n){switch(e.type){case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:e.type=n,e.source=t;break;case`block-scalar`:{let r=e.props.slice(1),i=t.length;e.props[0].type===`block-scalar-header`&&(i-=e.props[0].source.length);for(let e of r)e.offset+=i;delete e.props,Object.assign(e,{type:n,source:t,end:r});break}case`block-map`:case`block-seq`:{let r={type:`newline`,offset:e.offset+t.length,indent:e.indent,source:`
|
|
302
|
-
`};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=o,e.resolveAsScalar=a,e.setScalarValue=s})),
|
|
303
|
+
`};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=o,e.resolveAsScalar=a,e.setScalarValue=s})),RC=/* @__PURE__ */ D((e=>{let t=e=>`type`in e?n(e):r(e);function n(e){switch(e.type){case`block-scalar`:{let t=``;for(let r of e.props)t+=n(r);return t+e.source}case`block-map`:case`block-seq`:{let t=``;for(let n of e.items)t+=r(n);return t}case`flow-collection`:{let t=e.start.source;for(let n of e.items)t+=r(n);for(let n of e.end)t+=n.source;return t}case`document`:{let t=r(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if(`end`in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function r({start:e,key:t,sep:r,value:i}){let a=``;for(let t of e)a+=t.source;if(t&&(a+=n(t)),r)for(let e of r)a+=e.source;return i&&(a+=n(i)),a}e.stringify=t})),zC=/* @__PURE__ */ D((e=>{let t=Symbol(`break visit`),n=Symbol(`skip children`),r=Symbol(`remove item`);function i(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),a(Object.freeze([]),e,t)}i.BREAK=t,i.SKIP=n,i.REMOVE=r,i.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},i.parentCollection=(e,t)=>{let n=i.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],a=n?.[r];if(a&&`items`in a)return a;throw Error(`Parent collection not found`)};function a(e,n,i){let o=i(n,e);if(typeof o==`symbol`)return o;for(let s of[`key`,`value`]){let c=n[s];if(c&&`items`in c){for(let n=0;n<c.items.length;++n){let o=a(Object.freeze(e.concat([[s,n]])),c.items[n],i);if(typeof o==`number`)n=o-1;else if(o===t)return t;else o===r&&(c.items.splice(n,1),--n)}typeof o==`function`&&s===`key`&&(o=o(n,e))}}return typeof o==`function`?o(n,e):o}e.visit=i})),BC=/* @__PURE__ */ D((e=>{var t=LC(),n=RC(),r=zC();let i=e=>!!e&&`items`in e,a=e=>!!e&&(e.type===`scalar`||e.type===`single-quoted-scalar`||e.type===`double-quoted-scalar`||e.type===`block-scalar`);
|
|
303
304
|
/* istanbul ignore next */
|
|
304
305
|
function o(e){switch(e){case``:return`<BOM>`;case``:return`<DOC>`;case``:return`<FLOW_END>`;case``:return`<SCALAR>`;default:return JSON.stringify(e)}}function s(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
|
|
305
306
|
`:case`\r
|
|
306
|
-
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=``,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=i,e.isScalar=a,e.prettyToken=o,e.tokenType=s})),
|
|
307
|
+
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=``,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=i,e.isScalar=a,e.prettyToken=o,e.tokenType=s})),VC=/* @__PURE__ */ D((e=>{var t=BC();function n(e){switch(e){case void 0:case` `:case`
|
|
307
308
|
`:case`\r`:case` `:return!0;default:return!1}}let r=/* @__PURE__ */ new Set(`0123456789ABCDEFabcdef`),i=/* @__PURE__ */ new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),a=/* @__PURE__ */ new Set(`,[]{}`),o=/* @__PURE__ */ new Set(` ,[]{}
|
|
308
309
|
\r `),s=e=>!e||o.has(e);e.Lexer=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
|
|
309
310
|
`||t===`\r`&&this.buffer[e+1]===`
|
|
@@ -322,7 +323,7 @@ function o(e){switch(e){case``:return`<BOM>`;case``:return`<DOC>`;case``:re
|
|
|
322
323
|
`,t=this.buffer[i+1]):r=i),t===`#`||e&&a.has(t))break;if(o===`
|
|
323
324
|
`){let e=this.continueScalar(i+1);if(e===-1)break;i=Math.max(i,e-2)}}else{if(e&&a.has(o))break;r=i}return!o&&!this.atEnd?this.setNext(`plain-scalar`):(yield t.SCALAR,yield*this.pushToIndex(r+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(s),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,r=this.charAt(1);if(n(r)||t&&a.has(r)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!n(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(i.has(t))t=this.buffer[++e];else if(t===`%`&&r.has(this.buffer[e+1])&&r.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
324
325
|
`?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
|
|
325
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}})),
|
|
326
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}})),HC=/* @__PURE__ */ D((e=>{e.LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}}})),UC=/* @__PURE__ */ D((e=>{var t=de(`process`),n=BC(),r=VC();function i(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function a(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function o(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function s(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;
|
|
326
327
|
/* istanbul ignore next should not happen */
|
|
327
328
|
default:return[]}}function c(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function l(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function u(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!i(t.start,`explicit-key-ind`)&&!i(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,o(t.value)?t.value.end?l(t.value.end,t.sep):t.value.end=t.sep:l(t.start,t.sep),delete t.sep)}e.Parser=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new r.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,t.env.LOG_TOKENS&&console.log(`|`,n.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=n.tokenType(e);if(!r){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(r===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=r,yield*this.step(),r){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source})}else{if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}
|
|
328
329
|
/* istanbul ignore next should not happen */
|
|
@@ -338,10 +339,10 @@ default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.l
|
|
|
338
339
|
/* istanbul ignore else should not happen */
|
|
339
340
|
n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=c(s(t));u(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
|
|
340
341
|
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
341
|
-
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),HC=/* @__PURE__ */ D((e=>{var t=PC(),n=_C(),r=vC(),i=HS(),a=$(),o=BC(),s=VC();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),UC=(/* @__PURE__ */ D((e=>{var t=PC(),n=_C(),r=hC(),i=vC(),a=NS(),o=$(),s=GS(),c=PS(),l=qS(),u=YS();RC();var d=zC(),f=BC(),p=VC(),m=HC(),h=DS();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync})))();function WC(e,t){let n=(0,UC.parse)(e,{uniqueKeys:!1});if(!Z(n))throw Error(`not a YAML mapping`);let r=new xS(`npm`,t),i=Z(n.importers)?n.importers:{".":n};for(let e of Object.values(i))if(Z(e))for(let t of[`dependencies`,`devDependencies`,`optionalDependencies`]){let n=e[t];if(Z(n))for(let[e,t]of Object.entries(n)){let n=Z(t)?t.version:t;if(typeof n!=`string`||GC(n))continue;let i=qC(n);i?r.add(i.name,i.version,!0):r.add(e,KC(n),!0)}}for(let e of[`packages`,`snapshots`]){let t=n[e];if(Z(t))for(let e of Object.keys(t)){let t=qC(e);t&&!GC(t.version)&&r.add(t.name,t.version,!1)}}return r.rows()}function GC(e){return/^(link|file|workspace):/.test(e)}function KC(e){return e.replace(/\(.*$/,``).replace(/_(?=[^/]*@).*$/,``)}function qC(e){let t=e.replace(/^\//,``).replace(/\(.*$/,``),n=t.indexOf(`@`,1);if(n>0)return{name:t.slice(0,n),version:KC(t.slice(n+1))};if(!e.startsWith(`/`))return null;let r=t.lastIndexOf(`/`);return r<=0?null:{name:t.slice(0,r),version:KC(t.slice(r+1))}}function JC(e,t){let n=wS(e);if(!Z(n))throw Error(`not a JSON object`);let r=new xS(`npm`,t);if(Z(n.packages)){let e=/* @__PURE__ */ new Set;for(let[t,r]of Object.entries(n.packages))if(!t.includes(`node_modules/`))for(let t of CS(r))e.add(t);for(let[t,i]of Object.entries(n.packages)){let n=t.lastIndexOf(`node_modules/`);if(n===-1||!Z(i)||i.link===!0)continue;let a=t.slice(n+13),o=typeof i.name==`string`?i.name:a;if(typeof i.version!=`string`)continue;let s=t===`node_modules/${a}`;r.add(o,i.version,s&&e.has(a))}return r.rows()}if(Z(n.dependencies)){let e=(t,n)=>{for(let[i,a]of Object.entries(t)){if(!Z(a))continue;let t=a.version;typeof t==`string`&&!GC(t)&&r.add(i,t,n===0&&a.dev!==!0),Z(a.dependencies)&&e(a.dependencies,n+1)}};e(n.dependencies,0)}return r.rows()}function YC(e,t,n){let r=new xS(`npm`,t),i=[],a=!1;for(let t of e.split(/\r?\n/)){if(t===``||t.startsWith(`#`))continue;if(!/^\s/.test(t)&&t.endsWith(`:`)){let e=t.slice(0,-1).split(`,`).map(e=>e.trim().replace(/^"|"$/g,``));a=e.some(e=>/@(workspace|link|file|portal):/.test(e)),i=[...new Set(e.map(XC).filter(e=>e!==null))];continue}let e=/^\s+version:?\s+"?([^"\s]+)"?/.exec(t)?.[1];if(e&&!a){for(let t of i)r.add(t,e,n.has(t));i=[]}}return r.rows()}function XC(e){if(e===`__metadata`)return null;let t=e.indexOf(`@`,1);return t>0?e.slice(0,t):null}async function ZC(e,t){let n=px(t),r=/* @__PURE__ */ new Set,i=await QC(e,mx(n,`package.json`));for(let e of CS(i))r.add(e);if(!Z(i))return r;let a=i.workspaces,o=(Array.isArray(a)?a:Z(a)&&Array.isArray(a.packages)?a.packages:[]).filter(e=>typeof e==`string`).map(e=>$C(mx(n,e.replace(/^\.\//,``).replace(/\/$/,``))));if(o.length===0)return r;for(let t of e.files){if(!t.path.endsWith(`package.json`))continue;let n=px(t.path);if(o.some(e=>e.test(n)))for(let n of CS(await QC(e,t.path)))r.add(n)}return r}async function QC(e,t){let n=e.file(t);if(!n)return null;let r=await e.readText(n);if(r===null)return null;try{return wS(r)}catch{return e.warnings.push(`${t}: not valid JSON, skipped`),null}}function $C(e){let t=e.split(`/`).map(e=>e===`**`?`.*`:e.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`[^/]*`)).join(`/`);return RegExp(`^${t}$`)}function ew(e){return e.toLowerCase().replace(/[-_.]+/g,`-`)}function tw(e,t,n){let r=new xS(`pip`,t),i=!1,a=null,o=null,s=!1,c=()=>{a&&o&&!s&&r.add(a,o,n.has(ew(a))),a=null,o=null,s=!1};for(let t of e.split(/\r?\n/)){if(/^\s*\[{1,2}([^\]]+)\]{1,2}\s*$/.exec(t)){t.trim()===`[[package]]`?(c(),i=!0):i=!1;continue}if(!i)continue;let e=/^\s*(name|version|source)\s*=\s*(.+)$/.exec(t);if(!e)continue;let n=e[2]?.trim()??``;if(e[1]===`source`)s=/\b(editable|virtual)\s*=/.test(n);else{let t=/^"([^"]*)"/.exec(n)?.[1];e[1]===`name`&&t&&(a=t),e[1]===`version`&&t&&(o=t)}}return c(),r.rows()}function nw(e){let t=/* @__PURE__ */ new Set,n=``,r=null,i=``,a=e=>{let n=/^\s*([A-Za-z0-9][A-Za-z0-9._-]*)/.exec(e)?.[1];n&&t.add(ew(n))},o=()=>{for(let e of i.matchAll(/"([^"]*)"|'([^']*)'/g))a(e[1]??e[2]??``);r=null,i=``},s=e=>e.replace(/"[^"]*"|'[^']*'/g,``).includes(`]`);for(let a of e.split(/\r?\n/)){let e=a.replace(/\s+#.*$/,``);if(r!==null){i+=` ${e}`,s(e)&&o();continue}let c=/^\s*\[([^\]]+)\]\s*$/.exec(e);if(c){n=(c[1]??``).trim();continue}let l=/^\s*"?([A-Za-z0-9_.-]+)"?\s*=\s*(.*)$/.exec(e);if(!l)continue;let u=l[1]??``,d=l[2]??``;n===`tool.poetry.dependencies`||n===`tool.poetry.dev-dependencies`||/^tool\.poetry\.group\.[^.]+\.dependencies$/.test(n)?ew(u)!==`python`&&t.add(ew(u)):(n===`project`&&u===`dependencies`||n===`project.optional-dependencies`||n===`dependency-groups`)&&d.trimStart().startsWith(`[`)&&(r=u,i=d,s(d.trimStart().slice(1))&&o())}return t}function rw(e,t){let n=new xS(`pip`,t),r=0;for(let t of e.split(/\r?\n/)){let e=t.replace(/(^|\s)#.*$/,``).trim();if(e===``||e.startsWith(`-`))continue;let i=/^([A-Za-z0-9][A-Za-z0-9._-]*)\s*(?:\[[^\]]*\])?\s*===?\s*([^\s;,\\]+)/.exec(e);i?.[1]&&i[2]?n.add(i[1],i[2],!0):r++}return{rows:n.rows(),unpinned:r}}async function iw(e){let t=[];for(let n of e.files)try{let r=await aw(e,n);r&&t.push(...r)}catch(t){e.warnings.push(`${n.path}: could not be parsed (${hx(t)})`)}return t}async function aw(e,t){let n=fx(t.path),r=px(t.path),i=t=>t?e.readText(t,52428800):Promise.resolve(null),a=t=>e.file(mx(r,t));switch(n){case`pnpm-lock.yaml`:{let e=await i(t);return e===null?null:WC(e,t.path)}case`package-lock.json`:case`npm-shrinkwrap.json`:{let e=await i(t);return e===null?null:JC(e,t.path)}case`yarn.lock`:{let n=await i(t);return n===null?null:YC(n,t.path,await ZC(e,t.path))}case`composer.lock`:{let e=await i(t);return e===null?null:TS(e,t.path,await i(a(`composer.json`)))}case`poetry.lock`:case`uv.lock`:{let e=await i(t);if(e===null)return null;let n=await i(a(`pyproject.toml`)),r=n?nw(n):/* @__PURE__ */ new Set;return tw(e,t.path,r)}case`go.sum`:case`go.mod`:return n===`go.mod`&&a(`go.sum`)?null:ES(await i(a(`go.mod`)),n===`go.sum`?await i(t):null,t.path)}if(/^requirements[\w.-]*\.txt$/i.test(n)||/(^|\/)requirements\/[^/]+\.txt$/.test(t.path)){let n=await i(t);if(n===null)return null;let{rows:r,unpinned:a}=rw(n,t.path);return a>0&&e.warnings.push(`${t.path}: ${a} requirement${a===1?``:`s`} without an exact == pin skipped`),r}return null}const ow={ts:`TypeScript`,tsx:`TypeScript`,mts:`TypeScript`,cts:`TypeScript`,js:`JavaScript`,jsx:`JavaScript`,mjs:`JavaScript`,cjs:`JavaScript`,py:`Python`,go:`Go`,rb:`Ruby`,php:`PHP`,java:`Java`,kt:`Kotlin`,kts:`Kotlin`,swift:`Swift`,rs:`Rust`,cs:`C#`,fs:`F#`,c:`C`,h:`C`,cc:`C++`,cpp:`C++`,cxx:`C++`,hpp:`C++`,m:`Objective-C`,mm:`Objective-C++`,scala:`Scala`,dart:`Dart`,ex:`Elixir`,exs:`Elixir`,erl:`Erlang`,clj:`Clojure`,hs:`Haskell`,ml:`OCaml`,lua:`Lua`,r:`R`,pl:`Perl`,groovy:`Groovy`,zig:`Zig`,sol:`Solidity`,sql:`SQL`,sh:`Shell`,bash:`Shell`,zsh:`Shell`,ps1:`PowerShell`,tf:`HCL`,vue:`Vue`,svelte:`Svelte`,astro:`Astro`,html:`HTML`,css:`CSS`,scss:`SCSS`,sass:`SCSS`,less:`Less`};function sw(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=n.path.lastIndexOf(`.`);if(e===-1||e<n.path.lastIndexOf(`/`))continue;let r=ow[n.path.slice(e+1).toLowerCase()];r&&t.set(r,(t.get(r)??0)+1)}return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,5).map(([e])=>e)}const cw=/* @__PURE__ */ new Set([`auth`,`storage`,`realtime`,`_realtime`,`extensions`,`graphql`,`graphql_public`,`supabase_functions`,`supabase_migrations`,`pgsodium`,`pgsodium_masks`,`vault`,`net`,`cron`,`pgbouncer`,`pg_catalog`,`information_schema`]),lw=/^(not|null|default|primary|unique|references|check|constraint|generated|collate|deferrable|initially|identity)$/i;function uw(e){if(!/\.sql$/i.test(e))return!1;let t=e.toLowerCase();return/(^|\/)migrations\//.test(t)||/(^|\/)db\/migrate\//.test(t)}const dw=e=>e.slice(0,e.lastIndexOf(`/`)+1);function fw(e,t){let n=e.toLowerCase();if(!n.endsWith(`.sql`)||uw(e))return!1;let r=n.slice(n.lastIndexOf(`/`)+1);return/seed|fixture|sample|test|demo/.test(r)?!1:/schema|structure/.test(r)||t.has(dw(n))||/(^|\/)docker-entrypoint-initdb\.d\//.test(n)}async function pw(e){let t=/* @__PURE__ */ new Map,n=e.files.filter(e=>uw(e.path)),r=new Set(n.flatMap(e=>{let t=/^(.*\/)?(migrations|db\/migrate)\//.exec(e.path.toLowerCase());return t?[t[1]??``]:[]})),i=e.files.filter(e=>fw(e.path,r)).sort((e,t)=>e.path<t.path?-1:1);n.sort((e,t)=>{let n=e.path.slice(e.path.lastIndexOf(`/`)+1),r=t.path.slice(t.path.lastIndexOf(`/`)+1);return n<r?-1:n>r?1:e.path<t.path?-1:1});for(let r of[...i,...n]){let n=await e.readText(r);if(n!==null)for(let i of mw(n))try{Sw(i,r.path,t,e.warnings)}catch(t){e.warnings.push(`${r.path}: could not read statement "${Mw(i)}" (${hx(t)})`)}}return[...t.values()].filter(e=>!cw.has(e.schema)).map(e=>{let t=e.schema===`public`?e.table:`${e.schema}.${e.table}`;return{kind:`table`,name:t,sourcePath:e.sourcePath,table:t,columns:e.columns}})}function mw(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r],a=e[r+1];if(i===`-`&&a===`-`){let t=e.indexOf(`
|
|
342
|
-
`,r);r=t===-1?e.length:t,n+=` `}else if(i===`/`&&a===`*`){let t=1;for(r+=2;r<e.length&&t>0;)e.startsWith(`/*`,r)?(t++,r+=2):e.startsWith(`*/`,r)?(t--,r+=2):r++;n+=` `}else if(i===`'`||i===`"`){let t=r+1;for(;t<e.length;)if(e[t]===i){if(e[t+1]===i)t+=2;else break}else t++;n+=e.slice(r,t+1),r=t+1}else{if(i===`$`){let t=/^\$[A-Za-z_]?[A-Za-z0-9_]*\$/.exec(e.slice(r,r+64))?.[0];if(t){let i=e.indexOf(t,r+t.length),a=i===-1?e.length:i+t.length;n+=e.slice(r,a),r=a;continue}}i===`;`?(n.trim()&&t.push(n.trim()),n=``,r++):(n+=i,r++)}}return n.trim()&&t.push(n.trim()),t.map(e=>e.replace(/\s+/g,` `))}function hw(e){let t=[],n=0,r=null,i=0;for(let a=0;a<e.length;a++){let o=e[a];r?o===r&&(r=null):o===`'`||o===`"`?r=o:o===`(`?n++:o===`)`?n--:o===`,`&&n===0&&(t.push(e.slice(i,a).trim()),i=a+1)}return t.push(e.slice(i).trim()),t.filter(Boolean)}function gw(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(/\s/.test(r)){n++;continue}if(r===`(`){let r=0,i=n,a=null;for(;i<e.length;i++){let t=e[i];if(a)t===a&&(a=null);else if(t===`'`||t===`"`)a=t;else if(t===`(`)r++;else if(t===`)`&&--r===0)break}t.push(e.slice(n,i+1)),n=i+1;continue}let i=n,a=null;for(;i<e.length;i++){let t=e[i];if(a)t===a&&(a=null);else if(t===`'`||t===`"`)a=t;else if(/\s/.test(t)||t===`(`)break}t.push(e.slice(n,i)),n=i}return t}const _w=String.raw`(?:"(?:[^"]|"")+"|[A-Za-z_][\w$]*)`,vw=String.raw`(${_w}(?:\s*\.\s*${_w})?)`;function yw(e){let t=e.trim();return t.startsWith(`"`)?t.slice(1,-1).replace(/""/g,`"`):t.toLowerCase()}function bw(e){let t=e.match(new RegExp(_w,`g`))??[e];return t.length>=2?{schema:yw(t[0]??``),table:yw(t[1]??``)}:{schema:`public`,table:yw(t[0]??e)}}function xw(e,t){return`${e}.${t}`}function Sw(e,t,n,r){if(/^create\s+(?:(?:global|local)\s+)?(?:temp(?:orary)?\s+|unlogged\s+)?table\b/i.test(e)){Cw(e,t,n,r);return}let i=new RegExp(String.raw`^alter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?${vw}\s+(.+)$`,`i`).exec(e);if(i?.[1]&&i[2]){Aw(bw(i[1]),i[2],t,n,r);return}let a=/^drop\s+table\s+(?:if\s+exists\s+)?(.+?)(?:\s+(?:cascade|restrict))?$/i.exec(e);if(a?.[1])for(let e of hw(a[1])){let{schema:t,table:r}=bw(e);n.delete(xw(t,r))}}function Cw(e,t,n,r){let i=new RegExp(String.raw`^create\s+(?:(?:global|local)\s+)?(?:temp(?:orary)?\s+|unlogged\s+)?table\s+(?:if\s+not\s+exists\s+)?${vw}\s*\(`,`i`).exec(e);if(!i?.[1]){r.push(`${t}: skipped a create table statement it couldn't read: "${Mw(e)}"`);return}let{schema:a,table:o}=bw(i[1]),s=i[0].length-1,c=ww(e,s);if(c===-1){r.push(`${t}: unbalanced parentheses in create table ${o}`);return}let l=xw(a,o);if(n.has(l)&&/\bif\s+not\s+exists\b/i.test(e.slice(0,s)))return;let u={schema:a,table:o,sourcePath:t,columns:[]};for(let i of hw(e.slice(s+1,c))){if(/^(constraint|primary\s+key|unique|foreign\s+key|check|exclude|like)\b/i.test(i)){kw(u,i,n);continue}let e=Tw(i,n);e?u.columns.push(e):r.push(`${t}: skipped column definition "${Mw(i)}" in ${o}`)}n.set(l,u)}function ww(e,t){let n=0,r=null;for(let i=t;i<e.length;i++){let t=e[i];if(r)t===r&&(r=null);else if(t===`'`||t===`"`)r=t;else if(t===`(`)n++;else if(t===`)`&&--n===0)return i}return-1}function Tw(e,t){let n=gw(e),r=n[0];if(!r||n.length<2)return null;let i=1,a=[];for(;i<n.length&&!lw.test(n[i]??``);)a.push(n[i]),i++;if(a.length===0)return null;let o={name:yw(r),type:a.join(` `).replace(/\s+\(/g,`(`).toLowerCase(),required:!1};return Ew(o,n.slice(i),t),o}function Ew(e,t,n){for(let r=0;r<t.length;r++){let i=t[r]?.toLowerCase(),a=t[r+1]?.toLowerCase();if(i===`not`&&a===`null`)e.required=!0,r++;else if(i===`primary`&&a===`key`)e.primaryKey=!0,e.required=!0,r++;else if(i===`unique`)e.unique=!0;else if(i==="default"){let n=[];for(;r+1<t.length&&!lw.test(t[r+1]??``);)n.push(t[r+1]),r++;n.length>0&&(e.default=Dw(n))}else if(i===`references`){let i=t[r+1];if(!i)continue;let a=t[r+2]?.startsWith(`(`)?t[r+2]:void 0;e.references=Ow(i,a,n),r+=a?2:1}}}function Dw(e){return e.join(` `).replace(/\s+\(/g,`(`)}function Ow(e,t,n){let{schema:r,table:i}=bw(e),a=r===`public`?i:`${r}.${i}`,o=t?yw(t.slice(1,-1).split(`,`)[0]??``):null;return o||=n.get(xw(r,i))?.columns.find(e=>e.primaryKey)?.name??`id`,`${a}.${o}`}function kw(e,t,n){let r=t.replace(new RegExp(String.raw`^constraint\s+${_w}\s+`,`i`),``),i=e=>(e??``).split(`,`).map(e=>yw(e)).filter(Boolean),a=/^primary\s+key\s*\(([^)]*)\)/i.exec(r);if(a){for(let t of i(a[1])){let n=e.columns.find(e=>e.name===t);n&&(n.primaryKey=!0,n.required=!0)}return}let o=/^unique\s*(?:nulls\s+(?:not\s+)?distinct\s*)?\(([^)]*)\)/i.exec(r);if(o){let t=i(o[1]),n=t.length===1?e.columns.find(e=>e.name===t[0]):void 0;n&&(n.unique=!0);return}let s=new RegExp(String.raw`^foreign\s+key\s*\(([^)]*)\)\s*references\s+${vw}\s*(\([^)]*\))?`,`i`).exec(r);if(s?.[2]){let t=i(s[1]),r=s[3]?i(s[3].slice(1,-1)):[];t.forEach((t,i)=>{let a=e.columns.find(e=>e.name===t);if(!a)return;let o=r[i];a.references=Ow(s[2],o?`(${o})`:void 0,n)})}}function Aw(e,t,n,r,i){let a=r.get(xw(e.schema,e.table));if(!a){!cw.has(e.schema)&&/\b(add|drop|alter|rename)\s+column\b/i.test(t)&&i.push(`${n}: alter table ${e.table} before any create table for it, skipped`);return}let o=new RegExp(String.raw`^rename\s+to\s+(${_w})$`,`i`).exec(t);if(o?.[1]){r.delete(xw(a.schema,a.table)),a.table=yw(o[1]),r.set(xw(a.schema,a.table),a);return}let s=new RegExp(String.raw`^rename\s+(?:column\s+)?(${_w})\s+to\s+(${_w})$`,`i`).exec(t);if(s?.[1]&&s[2]){let e=a.columns.find(e=>e.name===yw(s[1]));e&&(e.name=yw(s[2]))}else for(let e of hw(t)){let t=/^add\s+(?:column\s+)?(?:if\s+not\s+exists\s+)?(.+)$/i.exec(e);if(t?.[1]&&!/^add\s+(constraint|primary|unique|foreign|check|exclude)\b/i.test(e)){let o=Tw(t[1],r);if(!o){i.push(`${n}: skipped "${Mw(e)}" on ${a.table}`);continue}a.columns.some(e=>e.name===o.name)||a.columns.push(o);continue}let o=/^add\s+(.+)$/i.exec(e);if(o?.[1]){kw(a,o[1],r);continue}let s=new RegExp(String.raw`^drop\s+(?:column\s+)?(?:if\s+exists\s+)?(${_w})`,`i`).exec(e);if(s?.[1]&&!/^drop\s+constraint\b/i.test(e)){let e=yw(s[1]);a.columns=a.columns.filter(t=>t.name!==e);continue}let c=new RegExp(String.raw`^alter\s+(?:column\s+)?(${_w})\s+(.+)$`,`i`).exec(e);if(c?.[1]&&c[2]){let e=a.columns.find(e=>e.name===yw(c[1]));e&&jw(e,c[2])}}}function jw(e,t){if(/^set\s+not\s+null$/i.test(t))e.required=!0;else if(/^drop\s+not\s+null$/i.test(t))e.required=!!e.primaryKey;else if(/^drop\s+default$/i.test(t))delete e.default;else{let n=/^set\s+default\s+(.+)$/i.exec(t);if(n?.[1]){e.default=Dw(gw(n[1]));return}let r=/^(?:set\s+data\s+)?type\s+(.+?)(?:\s+(?:using|collate)\s+.*)?$/i.exec(t);r?.[1]&&(e.type=r[1].replace(/\s+\(/g,`(`).toLowerCase())}}function Mw(e){return e.length>60?`${e.slice(0,57)}...`:e}const Nw=[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`],Pw=/^(openapi|swagger)([.-][\w.-]*)?\.(json|ya?ml)$/i,Fw=/\.(json|ya?ml)$/i;async function Iw(e){let t=[];for(let n of e.files){let r=Pw.test(fx(n.path));if(!r&&!Fw.test(n.path)||!r&&(n.size>1048576||/(^|\/)[^/]*lock[^/]*$/i.test(n.path)))continue;let i=await e.readText(n,r?10485760:void 0);if(i===null||!r&&!/^\s*["']?(openapi|swagger)["']?\s*:/m.test(i))continue;let a;try{a=/\.json$/i.test(n.path)?JSON.parse(i):(0,UC.parse)(i)}catch(t){e.warnings.push(`${n.path}: OpenAPI file could not be parsed (${hx(t)})`);continue}!Z(a)||typeof a.openapi!=`string`&&typeof a.swagger!=`string`?r&&e.warnings.push(`${n.path}: no top-level openapi or swagger version, skipped`):t.push(...Lw(a,n.path,e.warnings))}return t}function Lw(e,t,n){let r=typeof e.swagger==`string`,i=new Rw(e,t,n),a=r?e.securityDefinitions:Bw(e.components)?.securitySchemes,o=Z(a)?a:{},s=Z(e.paths)?e.paths:{},c=[];for(let[n,a]of Object.entries(s)){let s=i.resolve(a);if(s)for(let a of Nw){let l=Bw(s[a.toLowerCase()]);if(!l)continue;let u=[...Array.isArray(s.parameters)?s.parameters:[],...Array.isArray(l.parameters)?l.parameters:[]],d=l.security??e.security;c.push({kind:`endpoint`,name:gx(l.summary)?.trim()||gx(l.operationId)||`${a} ${n}`,sourcePath:t,method:a,path:n,auth:eT(d,o,i),request:r?Gw(u,l,e,i):Hw(l.requestBody,i),responses:Kw(l,e,r,i)})}}return c}var Rw=class{#e;#t;#n;#r=/* @__PURE__ */ new Set;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}resolve(e){let t=e;for(let e=0;e<8;e++){if(!Z(t))return null;let e=t.$ref;if(typeof e!=`string`)return t;t=this.#i(e)}return null}refName(e){if(!Z(e)||typeof e.$ref!=`string`)return null;let t=e.$ref.slice(e.$ref.lastIndexOf(`/`)+1);return t?zw(t):null}#i(e){if(!e.startsWith(`#/`))return this.#r.has(e)||(this.#r.add(e),this.#n.push(`${this.#t}: external $ref "${e}" not followed`)),null;let t=this.#e;for(let n of e.slice(2).split(`/`)){if(!Z(t))break;t=t[zw(n)]}return t===void 0&&!this.#r.has(e)&&(this.#r.add(e),this.#n.push(`${this.#t}: $ref "${e}" points at nothing`)),t}};function zw(e){return decodeURIComponent(e).replace(/~1/g,`/`).replace(/~0/g,`~`)}function Bw(e){return Z(e)?e:null}function Vw(e){if(!Z(e))return null;let t=Object.entries(e).filter(e=>Z(e[1]));return t.find(([e])=>e===`application/json`)??t.find(([e])=>/json/.test(e))??t[0]??null}function Hw(e,t){let n=t.resolve(e),r=n?Vw(n.content):null;return r?Uw(r[0],r[1],t):null}function Uw(e,t,n){let r=t.schema;return{contentType:e,fields:Xw(r,n),example:Ww(t,n)??$w(r,n,0)}}function Ww(e,t){if(e.example!==void 0)return e.example;if(Z(e.examples)){let n=t.resolve(Object.values(e.examples)[0]);if(n&&n.value!==void 0)return n.value}}function Gw(e,t,n,r){let i=e.map(e=>r.resolve(e)).filter(e=>e!==null),a=Jw(t.consumes)??Jw(n.consumes),o=i.find(e=>e.in===`body`);if(o)return{contentType:a??`application/json`,fields:Xw(o.schema,r),example:$w(o.schema,r,0)};let s=i.filter(e=>e.in===`formData`);if(s.length===0)return null;let c=s.map(e=>({name:gx(e.name)??``,type:Qw(e,r),required:e.required===!0,...Zw(e)}));return{contentType:a??`application/x-www-form-urlencoded`,fields:c,example:Object.fromEntries(s.map(e=>[gx(e.name)??``,$w(e,r,1)]))}}function Kw(e,t,n,r){if(!Z(e.responses))return[];let i=Jw(e.produces)??Jw(t.produces)??`application/json`,a=[];for(let[t,o]of Object.entries(e.responses)){let e=r.resolve(o);if(!e)continue;let s=null;if(n){if(e.schema!==void 0){let t=Bw(e.examples);s={contentType:i,fields:Xw(e.schema,r),example:t?.[i]??$w(e.schema,r,0)}}}else{let t=Vw(e.content);t&&(s=Uw(t[0],t[1],r))}a.push({status:qw(t),description:gx(e.description)??``,body:s})}return a}function qw(e){let t=e.replace(/x/gi,`0`),n=Number.parseInt(t,10);return Number.isNaN(n)?0:n}function Jw(e){return Array.isArray(e)&&typeof e[0]==`string`?e[0]:void 0}function Yw(e,t,n=0){let r=t.resolve(e);if(!r||n>8)return r;if(Array.isArray(r.allOf)){let e={},i=[];for(let a of r.allOf){let r=Yw(a,t,n+1);r&&(Z(r.properties)&&Object.assign(e,r.properties),Array.isArray(r.required)&&i.push(...r.required.filter(e=>typeof e==`string`)))}return Z(r.properties)&&Object.assign(e,r.properties),Array.isArray(r.required)&&i.push(...r.required.filter(e=>typeof e==`string`)),{...r,type:`object`,properties:e,required:i}}let i=Array.isArray(r.oneOf)?r.oneOf:Array.isArray(r.anyOf)?r.anyOf:null;return i&&i.length>0&&!r.properties?Yw(i[0],t,n+1):r}function Xw(e,t){let n=Yw(e,t);if(n?.type===`array`&&(n=Yw(n.items,t)),!n||!Z(n.properties))return[];let r=new Set(Array.isArray(n.required)?n.required:[]);return Object.entries(n.properties).map(([e,n])=>{let i=Yw(n,t)??{};return{name:e,type:Qw(n,t),required:r.has(e),...Zw(i)}})}function Zw(e){let t={},n=gx(e.description)?.trim();return n&&(t.description=n),Array.isArray(e.enum)&&(t.values=e.enum.map(e=>String(e))),t}function Qw(e,t,n=0){let r=t.refName(e),i=Yw(e,t);if(!i)return r??`unknown`;let a=Array.isArray(i.type)?i.type.filter(e=>e!==`null`).join(` | `):gx(i.type);return a===`array`?n>8?`array`:`${Qw(i.items,t,n+1)}[]`:r&&(a===`object`||a===void 0)?r:gx(i.format)??a??(i.properties?`object`:`unknown`)}function $w(e,t,n){let r=Yw(e,t);if(!r||n>8)return null;if(r.example!==void 0)return r.example;if(Array.isArray(r.enum)&&r.enum.length>0)return r.enum[0];let i=Array.isArray(r.type)?r.type.find(e=>e!==`null`):r.type;if(i===`object`||i===void 0&&Z(r.properties)){let e=Z(r.properties)?r.properties:{};return Object.fromEntries(Object.entries(e).map(([e,r])=>[e,$w(r,t,n+1)]))}switch(i){case`array`:return[$w(r.items,t,n+1)];case`string`:return`string`;case`integer`:case`number`:return 0;case`boolean`:return!1;default:return null}}function eT(e,t,n){if(!Array.isArray(e)||e.length===0)return null;let r=[];for(let i of e){if(!Z(i))continue;let e=Object.keys(i);e.length===0?r.push(`none`):r.push(e.map(e=>tT(e,n.resolve(t[e]))).join(` + `))}let i=[...new Set(r)];return i.length===0||i.length===1&&i[0]===`none`?null:i.map(e=>e===`none`?`no auth`:e).join(` or `)}function tT(e,t){if(!t)return e;switch(gx(t.type)?.toLowerCase()){case`http`:{let e=gx(t.scheme)?.toLowerCase();if(e===`bearer`){let e=gx(t.bearerFormat);return e?`Bearer token (${e})`:`Bearer token`}return e===`basic`?`Basic auth`:`HTTP ${e??`auth`}`}case`basic`:return`Basic auth`;case`apikey`:return`apikey ${gx(t.in)??`header`} ${gx(t.name)??e}`;case`oauth2`:return`OAuth2`;case`openidconnect`:return`OpenID Connect`;case`mutualtls`:return`Mutual TLS`;default:return e}}const nT=[`readme.md`,`readme.mdx`,`readme.markdown`,`readme.txt`,`readme`];async function rT(e){let t=e.files.find(e=>!e.path.includes(`/`)&&nT.includes(e.path.toLowerCase()));if(!t)return null;let n=await e.readText(t);return{path:t.path,oneLiner:n===null?null:iT(n)}}function iT(e){let t=e.replace(/\r\n/g,`
|
|
342
|
+
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),WC=/* @__PURE__ */ D((e=>{var t=IC(),n=yC(),r=bC(),i=WS(),a=$(),o=HC(),s=UC();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),GC=(/* @__PURE__ */ D((e=>{var t=IC(),n=yC(),r=_C(),i=bC(),a=FS(),o=$(),s=qS(),c=IS(),l=YS(),u=ZS();BC();var d=VC(),f=HC(),p=UC(),m=WC(),h=kS();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync})))();function KC(e,t){let n=(0,GC.parse)(e,{uniqueKeys:!1});if(!Z(n))throw Error(`not a YAML mapping`);let r=new CS(`npm`,t),i=Z(n.importers)?n.importers:{".":n};for(let e of Object.values(i))if(Z(e))for(let t of[`dependencies`,`devDependencies`,`optionalDependencies`]){let n=e[t];if(Z(n))for(let[e,t]of Object.entries(n)){let n=Z(t)?t.version:t;if(typeof n!=`string`||qC(n))continue;let i=YC(n);i?r.add(i.name,i.version,!0):r.add(e,JC(n),!0)}}for(let e of[`packages`,`snapshots`]){let t=n[e];if(Z(t))for(let e of Object.keys(t)){let t=YC(e);t&&!qC(t.version)&&r.add(t.name,t.version,!1)}}return r.rows()}function qC(e){return/^(link|file|workspace):/.test(e)}function JC(e){return e.replace(/\(.*$/,``).replace(/_(?=[^/]*@).*$/,``)}function YC(e){let t=e.replace(/^\//,``).replace(/\(.*$/,``),n=t.indexOf(`@`,1);if(n>0)return{name:t.slice(0,n),version:JC(t.slice(n+1))};if(!e.startsWith(`/`))return null;let r=t.lastIndexOf(`/`);return r<=0?null:{name:t.slice(0,r),version:JC(t.slice(r+1))}}function XC(e,t){let n=ES(e);if(!Z(n))throw Error(`not a JSON object`);let r=new CS(`npm`,t);if(Z(n.packages)){let e=/* @__PURE__ */ new Set;for(let[t,r]of Object.entries(n.packages))if(!t.includes(`node_modules/`))for(let t of TS(r))e.add(t);for(let[t,i]of Object.entries(n.packages)){let n=t.lastIndexOf(`node_modules/`);if(n===-1||!Z(i)||i.link===!0)continue;let a=t.slice(n+13),o=typeof i.name==`string`?i.name:a;if(typeof i.version!=`string`)continue;let s=t===`node_modules/${a}`;r.add(o,i.version,s&&e.has(a))}return r.rows()}if(Z(n.dependencies)){let e=(t,n)=>{for(let[i,a]of Object.entries(t)){if(!Z(a))continue;let t=a.version;typeof t==`string`&&!qC(t)&&r.add(i,t,n===0&&a.dev!==!0),Z(a.dependencies)&&e(a.dependencies,n+1)}};e(n.dependencies,0)}return r.rows()}function ZC(e,t,n){let r=new CS(`npm`,t),i=[],a=!1;for(let t of e.split(/\r?\n/)){if(t===``||t.startsWith(`#`))continue;if(!/^\s/.test(t)&&t.endsWith(`:`)){let e=t.slice(0,-1).split(`,`).map(e=>e.trim().replace(/^"|"$/g,``));a=e.some(e=>/@(workspace|link|file|portal):/.test(e)),i=[...new Set(e.map(QC).filter(e=>e!==null))];continue}let e=/^\s+version:?\s+"?([^"\s]+)"?/.exec(t)?.[1];if(e&&!a){for(let t of i)r.add(t,e,n.has(t));i=[]}}return r.rows()}function QC(e){if(e===`__metadata`)return null;let t=e.indexOf(`@`,1);return t>0?e.slice(0,t):null}async function $C(e,t){let n=hx(t),r=/* @__PURE__ */ new Set,i=await ew(e,gx(n,`package.json`));for(let e of TS(i))r.add(e);if(!Z(i))return r;let a=i.workspaces,o=(Array.isArray(a)?a:Z(a)&&Array.isArray(a.packages)?a.packages:[]).filter(e=>typeof e==`string`).map(e=>tw(gx(n,e.replace(/^\.\//,``).replace(/\/$/,``))));if(o.length===0)return r;for(let t of e.files){if(!t.path.endsWith(`package.json`))continue;let n=hx(t.path);if(o.some(e=>e.test(n)))for(let n of TS(await ew(e,t.path)))r.add(n)}return r}async function ew(e,t){let n=e.file(t);if(!n)return null;let r=await e.readText(n);if(r===null)return null;try{return ES(r)}catch{return e.warnings.push(`${t}: not valid JSON, skipped`),null}}function tw(e){let t=e.split(`/`).map(e=>e===`**`?`.*`:e.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`[^/]*`)).join(`/`);return RegExp(`^${t}$`)}function nw(e){return e.toLowerCase().replace(/[-_.]+/g,`-`)}function rw(e,t,n){let r=new CS(`pip`,t),i=!1,a=null,o=null,s=!1,c=()=>{a&&o&&!s&&r.add(a,o,n.has(nw(a))),a=null,o=null,s=!1};for(let t of e.split(/\r?\n/)){if(/^\s*\[{1,2}([^\]]+)\]{1,2}\s*$/.exec(t)){t.trim()===`[[package]]`?(c(),i=!0):i=!1;continue}if(!i)continue;let e=/^\s*(name|version|source)\s*=\s*(.+)$/.exec(t);if(!e)continue;let n=e[2]?.trim()??``;if(e[1]===`source`)s=/\b(editable|virtual)\s*=/.test(n);else{let t=/^"([^"]*)"/.exec(n)?.[1];e[1]===`name`&&t&&(a=t),e[1]===`version`&&t&&(o=t)}}return c(),r.rows()}function iw(e){let t=/* @__PURE__ */ new Set,n=``,r=null,i=``,a=e=>{let n=/^\s*([A-Za-z0-9][A-Za-z0-9._-]*)/.exec(e)?.[1];n&&t.add(nw(n))},o=()=>{for(let e of i.matchAll(/"([^"]*)"|'([^']*)'/g))a(e[1]??e[2]??``);r=null,i=``},s=e=>e.replace(/"[^"]*"|'[^']*'/g,``).includes(`]`);for(let a of e.split(/\r?\n/)){let e=a.replace(/\s+#.*$/,``);if(r!==null){i+=` ${e}`,s(e)&&o();continue}let c=/^\s*\[([^\]]+)\]\s*$/.exec(e);if(c){n=(c[1]??``).trim();continue}let l=/^\s*"?([A-Za-z0-9_.-]+)"?\s*=\s*(.*)$/.exec(e);if(!l)continue;let u=l[1]??``,d=l[2]??``;n===`tool.poetry.dependencies`||n===`tool.poetry.dev-dependencies`||/^tool\.poetry\.group\.[^.]+\.dependencies$/.test(n)?nw(u)!==`python`&&t.add(nw(u)):(n===`project`&&u===`dependencies`||n===`project.optional-dependencies`||n===`dependency-groups`)&&d.trimStart().startsWith(`[`)&&(r=u,i=d,s(d.trimStart().slice(1))&&o())}return t}function aw(e,t){let n=new CS(`pip`,t),r=0;for(let t of e.split(/\r?\n/)){let e=t.replace(/(^|\s)#.*$/,``).trim();if(e===``||e.startsWith(`-`))continue;let i=/^([A-Za-z0-9][A-Za-z0-9._-]*)\s*(?:\[[^\]]*\])?\s*===?\s*([^\s;,\\]+)/.exec(e);i?.[1]&&i[2]?n.add(i[1],i[2],!0):r++}return{rows:n.rows(),unpinned:r}}async function ow(e){let t=[];for(let n of e.files)try{let r=await sw(e,n);r&&t.push(...r)}catch(t){e.warnings.push(`${n.path}: could not be parsed (${_x(t)})`)}return t}async function sw(e,t){let n=mx(t.path),r=hx(t.path),i=t=>t?e.readText(t,52428800):Promise.resolve(null),a=t=>e.file(gx(r,t));switch(n){case`pnpm-lock.yaml`:{let e=await i(t);return e===null?null:KC(e,t.path)}case`package-lock.json`:case`npm-shrinkwrap.json`:{let e=await i(t);return e===null?null:XC(e,t.path)}case`yarn.lock`:{let n=await i(t);return n===null?null:ZC(n,t.path,await $C(e,t.path))}case`composer.lock`:{let e=await i(t);return e===null?null:DS(e,t.path,await i(a(`composer.json`)))}case`poetry.lock`:case`uv.lock`:{let e=await i(t);if(e===null)return null;let n=await i(a(`pyproject.toml`)),r=n?iw(n):/* @__PURE__ */ new Set;return rw(e,t.path,r)}case`go.sum`:case`go.mod`:return n===`go.mod`&&a(`go.sum`)?null:OS(await i(a(`go.mod`)),n===`go.sum`?await i(t):null,t.path)}if(/^requirements[\w.-]*\.txt$/i.test(n)||/(^|\/)requirements\/[^/]+\.txt$/.test(t.path)){let n=await i(t);if(n===null)return null;let{rows:r,unpinned:a}=aw(n,t.path);return a>0&&e.warnings.push(`${t.path}: ${a} requirement${a===1?``:`s`} without an exact == pin skipped`),r}return null}const cw={ts:`TypeScript`,tsx:`TypeScript`,mts:`TypeScript`,cts:`TypeScript`,js:`JavaScript`,jsx:`JavaScript`,mjs:`JavaScript`,cjs:`JavaScript`,py:`Python`,go:`Go`,rb:`Ruby`,php:`PHP`,java:`Java`,kt:`Kotlin`,kts:`Kotlin`,swift:`Swift`,rs:`Rust`,cs:`C#`,fs:`F#`,c:`C`,h:`C`,cc:`C++`,cpp:`C++`,cxx:`C++`,hpp:`C++`,m:`Objective-C`,mm:`Objective-C++`,scala:`Scala`,dart:`Dart`,ex:`Elixir`,exs:`Elixir`,erl:`Erlang`,clj:`Clojure`,hs:`Haskell`,ml:`OCaml`,lua:`Lua`,r:`R`,pl:`Perl`,groovy:`Groovy`,zig:`Zig`,sol:`Solidity`,sql:`SQL`,sh:`Shell`,bash:`Shell`,zsh:`Shell`,ps1:`PowerShell`,tf:`HCL`,vue:`Vue`,svelte:`Svelte`,astro:`Astro`,html:`HTML`,css:`CSS`,scss:`SCSS`,sass:`SCSS`,less:`Less`};function lw(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=n.path.lastIndexOf(`.`);if(e===-1||e<n.path.lastIndexOf(`/`))continue;let r=cw[n.path.slice(e+1).toLowerCase()];r&&t.set(r,(t.get(r)??0)+1)}return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,5).map(([e])=>e)}const uw=/* @__PURE__ */ new Set([`auth`,`storage`,`realtime`,`_realtime`,`extensions`,`graphql`,`graphql_public`,`supabase_functions`,`supabase_migrations`,`pgsodium`,`pgsodium_masks`,`vault`,`net`,`cron`,`pgbouncer`,`pg_catalog`,`information_schema`]),dw=/^(not|null|default|primary|unique|references|check|constraint|generated|collate|deferrable|initially|identity)$/i;function fw(e){if(!/\.sql$/i.test(e))return!1;let t=e.toLowerCase();return/(^|\/)migrations\//.test(t)||/(^|\/)db\/migrate\//.test(t)}const pw=e=>e.slice(0,e.lastIndexOf(`/`)+1);function mw(e,t){let n=e.toLowerCase();if(!n.endsWith(`.sql`)||fw(e))return!1;let r=n.slice(n.lastIndexOf(`/`)+1);return/seed|fixture|sample|test|demo/.test(r)?!1:/schema|structure/.test(r)||t.has(pw(n))||/(^|\/)docker-entrypoint-initdb\.d\//.test(n)}async function hw(e){let t=/* @__PURE__ */ new Map,n=e.files.filter(e=>fw(e.path)),r=new Set(n.flatMap(e=>{let t=/^(.*\/)?(migrations|db\/migrate)\//.exec(e.path.toLowerCase());return t?[t[1]??``]:[]})),i=e.files.filter(e=>mw(e.path,r)).sort((e,t)=>e.path<t.path?-1:1);n.sort((e,t)=>{let n=e.path.slice(e.path.lastIndexOf(`/`)+1),r=t.path.slice(t.path.lastIndexOf(`/`)+1);return n<r?-1:n>r?1:e.path<t.path?-1:1});for(let r of[...i,...n]){let n=await e.readText(r);if(n!==null)for(let i of gw(n))try{ww(i,r.path,t,e.warnings)}catch(t){e.warnings.push(`${r.path}: could not read statement "${Pw(i)}" (${_x(t)})`)}}return[...t.values()].filter(e=>!uw.has(e.schema)).map(e=>{let t=e.schema===`public`?e.table:`${e.schema}.${e.table}`;return{kind:`table`,name:t,sourcePath:e.sourcePath,table:t,columns:e.columns}})}function gw(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r],a=e[r+1];if(i===`-`&&a===`-`){let t=e.indexOf(`
|
|
343
|
+
`,r);r=t===-1?e.length:t,n+=` `}else if(i===`/`&&a===`*`){let t=1;for(r+=2;r<e.length&&t>0;)e.startsWith(`/*`,r)?(t++,r+=2):e.startsWith(`*/`,r)?(t--,r+=2):r++;n+=` `}else if(i===`'`||i===`"`){let t=r+1;for(;t<e.length;)if(e[t]===i){if(e[t+1]===i)t+=2;else break}else t++;n+=e.slice(r,t+1),r=t+1}else{if(i===`$`){let t=/^\$[A-Za-z_]?[A-Za-z0-9_]*\$/.exec(e.slice(r,r+64))?.[0];if(t){let i=e.indexOf(t,r+t.length),a=i===-1?e.length:i+t.length;n+=e.slice(r,a),r=a;continue}}i===`;`?(n.trim()&&t.push(n.trim()),n=``,r++):(n+=i,r++)}}return n.trim()&&t.push(n.trim()),t.map(e=>e.replace(/\s+/g,` `))}function _w(e){let t=[],n=0,r=null,i=0;for(let a=0;a<e.length;a++){let o=e[a];r?o===r&&(r=null):o===`'`||o===`"`?r=o:o===`(`?n++:o===`)`?n--:o===`,`&&n===0&&(t.push(e.slice(i,a).trim()),i=a+1)}return t.push(e.slice(i).trim()),t.filter(Boolean)}function vw(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(/\s/.test(r)){n++;continue}if(r===`(`){let r=0,i=n,a=null;for(;i<e.length;i++){let t=e[i];if(a)t===a&&(a=null);else if(t===`'`||t===`"`)a=t;else if(t===`(`)r++;else if(t===`)`&&--r===0)break}t.push(e.slice(n,i+1)),n=i+1;continue}let i=n,a=null;for(;i<e.length;i++){let t=e[i];if(a)t===a&&(a=null);else if(t===`'`||t===`"`)a=t;else if(/\s/.test(t)||t===`(`)break}t.push(e.slice(n,i)),n=i}return t}const yw=String.raw`(?:"(?:[^"]|"")+"|[A-Za-z_][\w$]*)`,bw=String.raw`(${yw}(?:\s*\.\s*${yw})?)`;function xw(e){let t=e.trim();return t.startsWith(`"`)?t.slice(1,-1).replace(/""/g,`"`):t.toLowerCase()}function Sw(e){let t=e.match(new RegExp(yw,`g`))??[e];return t.length>=2?{schema:xw(t[0]??``),table:xw(t[1]??``)}:{schema:`public`,table:xw(t[0]??e)}}function Cw(e,t){return`${e}.${t}`}function ww(e,t,n,r){if(/^create\s+(?:(?:global|local)\s+)?(?:temp(?:orary)?\s+|unlogged\s+)?table\b/i.test(e)){Tw(e,t,n,r);return}let i=new RegExp(String.raw`^alter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?${bw}\s+(.+)$`,`i`).exec(e);if(i?.[1]&&i[2]){Mw(Sw(i[1]),i[2],t,n,r);return}let a=/^drop\s+table\s+(?:if\s+exists\s+)?(.+?)(?:\s+(?:cascade|restrict))?$/i.exec(e);if(a?.[1])for(let e of _w(a[1])){let{schema:t,table:r}=Sw(e);n.delete(Cw(t,r))}}function Tw(e,t,n,r){let i=new RegExp(String.raw`^create\s+(?:(?:global|local)\s+)?(?:temp(?:orary)?\s+|unlogged\s+)?table\s+(?:if\s+not\s+exists\s+)?${bw}\s*\(`,`i`).exec(e);if(!i?.[1]){r.push(`${t}: skipped a create table statement it couldn't read: "${Pw(e)}"`);return}let{schema:a,table:o}=Sw(i[1]),s=i[0].length-1,c=Ew(e,s);if(c===-1){r.push(`${t}: unbalanced parentheses in create table ${o}`);return}let l=Cw(a,o);if(n.has(l)&&/\bif\s+not\s+exists\b/i.test(e.slice(0,s)))return;let u={schema:a,table:o,sourcePath:t,columns:[]};for(let i of _w(e.slice(s+1,c))){if(/^(constraint|primary\s+key|unique|foreign\s+key|check|exclude|like)\b/i.test(i)){jw(u,i,n);continue}let e=Dw(i,n);e?u.columns.push(e):r.push(`${t}: skipped column definition "${Pw(i)}" in ${o}`)}n.set(l,u)}function Ew(e,t){let n=0,r=null;for(let i=t;i<e.length;i++){let t=e[i];if(r)t===r&&(r=null);else if(t===`'`||t===`"`)r=t;else if(t===`(`)n++;else if(t===`)`&&--n===0)return i}return-1}function Dw(e,t){let n=vw(e),r=n[0];if(!r||n.length<2)return null;let i=1,a=[];for(;i<n.length&&!dw.test(n[i]??``);)a.push(n[i]),i++;if(a.length===0)return null;let o={name:xw(r),type:a.join(` `).replace(/\s+\(/g,`(`).toLowerCase(),required:!1};return Ow(o,n.slice(i),t),o}function Ow(e,t,n){for(let r=0;r<t.length;r++){let i=t[r]?.toLowerCase(),a=t[r+1]?.toLowerCase();if(i===`not`&&a===`null`)e.required=!0,r++;else if(i===`primary`&&a===`key`)e.primaryKey=!0,e.required=!0,r++;else if(i===`unique`)e.unique=!0;else if(i==="default"){let n=[];for(;r+1<t.length&&!dw.test(t[r+1]??``);)n.push(t[r+1]),r++;n.length>0&&(e.default=kw(n))}else if(i===`references`){let i=t[r+1];if(!i)continue;let a=t[r+2]?.startsWith(`(`)?t[r+2]:void 0;e.references=Aw(i,a,n),r+=a?2:1}}}function kw(e){return e.join(` `).replace(/\s+\(/g,`(`)}function Aw(e,t,n){let{schema:r,table:i}=Sw(e),a=r===`public`?i:`${r}.${i}`,o=t?xw(t.slice(1,-1).split(`,`)[0]??``):null;return o||=n.get(Cw(r,i))?.columns.find(e=>e.primaryKey)?.name??`id`,`${a}.${o}`}function jw(e,t,n){let r=t.replace(new RegExp(String.raw`^constraint\s+${yw}\s+`,`i`),``),i=e=>(e??``).split(`,`).map(e=>xw(e)).filter(Boolean),a=/^primary\s+key\s*\(([^)]*)\)/i.exec(r);if(a){for(let t of i(a[1])){let n=e.columns.find(e=>e.name===t);n&&(n.primaryKey=!0,n.required=!0)}return}let o=/^unique\s*(?:nulls\s+(?:not\s+)?distinct\s*)?\(([^)]*)\)/i.exec(r);if(o){let t=i(o[1]),n=t.length===1?e.columns.find(e=>e.name===t[0]):void 0;n&&(n.unique=!0);return}let s=new RegExp(String.raw`^foreign\s+key\s*\(([^)]*)\)\s*references\s+${bw}\s*(\([^)]*\))?`,`i`).exec(r);if(s?.[2]){let t=i(s[1]),r=s[3]?i(s[3].slice(1,-1)):[];t.forEach((t,i)=>{let a=e.columns.find(e=>e.name===t);if(!a)return;let o=r[i];a.references=Aw(s[2],o?`(${o})`:void 0,n)})}}function Mw(e,t,n,r,i){let a=r.get(Cw(e.schema,e.table));if(!a){!uw.has(e.schema)&&/\b(add|drop|alter|rename)\s+column\b/i.test(t)&&i.push(`${n}: alter table ${e.table} before any create table for it, skipped`);return}let o=new RegExp(String.raw`^rename\s+to\s+(${yw})$`,`i`).exec(t);if(o?.[1]){r.delete(Cw(a.schema,a.table)),a.table=xw(o[1]),r.set(Cw(a.schema,a.table),a);return}let s=new RegExp(String.raw`^rename\s+(?:column\s+)?(${yw})\s+to\s+(${yw})$`,`i`).exec(t);if(s?.[1]&&s[2]){let e=a.columns.find(e=>e.name===xw(s[1]));e&&(e.name=xw(s[2]))}else for(let e of _w(t)){let t=/^add\s+(?:column\s+)?(?:if\s+not\s+exists\s+)?(.+)$/i.exec(e);if(t?.[1]&&!/^add\s+(constraint|primary|unique|foreign|check|exclude)\b/i.test(e)){let o=Dw(t[1],r);if(!o){i.push(`${n}: skipped "${Pw(e)}" on ${a.table}`);continue}a.columns.some(e=>e.name===o.name)||a.columns.push(o);continue}let o=/^add\s+(.+)$/i.exec(e);if(o?.[1]){jw(a,o[1],r);continue}let s=new RegExp(String.raw`^drop\s+(?:column\s+)?(?:if\s+exists\s+)?(${yw})`,`i`).exec(e);if(s?.[1]&&!/^drop\s+constraint\b/i.test(e)){let e=xw(s[1]);a.columns=a.columns.filter(t=>t.name!==e);continue}let c=new RegExp(String.raw`^alter\s+(?:column\s+)?(${yw})\s+(.+)$`,`i`).exec(e);if(c?.[1]&&c[2]){let e=a.columns.find(e=>e.name===xw(c[1]));e&&Nw(e,c[2])}}}function Nw(e,t){if(/^set\s+not\s+null$/i.test(t))e.required=!0;else if(/^drop\s+not\s+null$/i.test(t))e.required=!!e.primaryKey;else if(/^drop\s+default$/i.test(t))delete e.default;else{let n=/^set\s+default\s+(.+)$/i.exec(t);if(n?.[1]){e.default=kw(vw(n[1]));return}let r=/^(?:set\s+data\s+)?type\s+(.+?)(?:\s+(?:using|collate)\s+.*)?$/i.exec(t);r?.[1]&&(e.type=r[1].replace(/\s+\(/g,`(`).toLowerCase())}}function Pw(e){return e.length>60?`${e.slice(0,57)}...`:e}const Fw=[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`],Iw=/^(openapi|swagger)([.-][\w.-]*)?\.(json|ya?ml)$/i,Lw=/\.(json|ya?ml)$/i;async function Rw(e){let t=[];for(let n of e.files){let r=Iw.test(mx(n.path));if(!r&&!Lw.test(n.path)||!r&&(n.size>1048576||/(^|\/)[^/]*lock[^/]*$/i.test(n.path)))continue;let i=await e.readText(n,r?10485760:void 0);if(i===null||!r&&!/^\s*["']?(openapi|swagger)["']?\s*:/m.test(i))continue;let a;try{a=/\.json$/i.test(n.path)?JSON.parse(i):(0,GC.parse)(i)}catch(t){e.warnings.push(`${n.path}: OpenAPI file could not be parsed (${_x(t)})`);continue}!Z(a)||typeof a.openapi!=`string`&&typeof a.swagger!=`string`?r&&e.warnings.push(`${n.path}: no top-level openapi or swagger version, skipped`):t.push(...zw(a,n.path,e.warnings))}return t}function zw(e,t,n){let r=typeof e.swagger==`string`,i=new Bw(e,t,n),a=r?e.securityDefinitions:Hw(e.components)?.securitySchemes,o=Z(a)?a:{},s=Z(e.paths)?e.paths:{},c=[];for(let[n,a]of Object.entries(s)){let s=i.resolve(a);if(s)for(let a of Fw){let l=Hw(s[a.toLowerCase()]);if(!l)continue;let u=[...Array.isArray(s.parameters)?s.parameters:[],...Array.isArray(l.parameters)?l.parameters:[]],d=l.security??e.security;c.push({kind:`endpoint`,name:vx(l.summary)?.trim()||vx(l.operationId)||`${a} ${n}`,sourcePath:t,method:a,path:n,auth:nT(d,o,i),request:r?qw(u,l,e,i):Ww(l.requestBody,i),responses:Jw(l,e,r,i)})}}return c}var Bw=class{#e;#t;#n;#r=/* @__PURE__ */ new Set;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}resolve(e){let t=e;for(let e=0;e<8;e++){if(!Z(t))return null;let e=t.$ref;if(typeof e!=`string`)return t;t=this.#i(e)}return null}refName(e){if(!Z(e)||typeof e.$ref!=`string`)return null;let t=e.$ref.slice(e.$ref.lastIndexOf(`/`)+1);return t?Vw(t):null}#i(e){if(!e.startsWith(`#/`))return this.#r.has(e)||(this.#r.add(e),this.#n.push(`${this.#t}: external $ref "${e}" not followed`)),null;let t=this.#e;for(let n of e.slice(2).split(`/`)){if(!Z(t))break;t=t[Vw(n)]}return t===void 0&&!this.#r.has(e)&&(this.#r.add(e),this.#n.push(`${this.#t}: $ref "${e}" points at nothing`)),t}};function Vw(e){return decodeURIComponent(e).replace(/~1/g,`/`).replace(/~0/g,`~`)}function Hw(e){return Z(e)?e:null}function Uw(e){if(!Z(e))return null;let t=Object.entries(e).filter(e=>Z(e[1]));return t.find(([e])=>e===`application/json`)??t.find(([e])=>/json/.test(e))??t[0]??null}function Ww(e,t){let n=t.resolve(e),r=n?Uw(n.content):null;return r?Gw(r[0],r[1],t):null}function Gw(e,t,n){let r=t.schema;return{contentType:e,fields:Qw(r,n),example:Kw(t,n)??tT(r,n,0)}}function Kw(e,t){if(e.example!==void 0)return e.example;if(Z(e.examples)){let n=t.resolve(Object.values(e.examples)[0]);if(n&&n.value!==void 0)return n.value}}function qw(e,t,n,r){let i=e.map(e=>r.resolve(e)).filter(e=>e!==null),a=Xw(t.consumes)??Xw(n.consumes),o=i.find(e=>e.in===`body`);if(o)return{contentType:a??`application/json`,fields:Qw(o.schema,r),example:tT(o.schema,r,0)};let s=i.filter(e=>e.in===`formData`);if(s.length===0)return null;let c=s.map(e=>({name:vx(e.name)??``,type:eT(e,r),required:e.required===!0,...$w(e)}));return{contentType:a??`application/x-www-form-urlencoded`,fields:c,example:Object.fromEntries(s.map(e=>[vx(e.name)??``,tT(e,r,1)]))}}function Jw(e,t,n,r){if(!Z(e.responses))return[];let i=Xw(e.produces)??Xw(t.produces)??`application/json`,a=[];for(let[t,o]of Object.entries(e.responses)){let e=r.resolve(o);if(!e)continue;let s=null;if(n){if(e.schema!==void 0){let t=Hw(e.examples);s={contentType:i,fields:Qw(e.schema,r),example:t?.[i]??tT(e.schema,r,0)}}}else{let t=Uw(e.content);t&&(s=Gw(t[0],t[1],r))}a.push({status:Yw(t),description:vx(e.description)??``,body:s})}return a}function Yw(e){let t=e.replace(/x/gi,`0`),n=Number.parseInt(t,10);return Number.isNaN(n)?0:n}function Xw(e){return Array.isArray(e)&&typeof e[0]==`string`?e[0]:void 0}function Zw(e,t,n=0){let r=t.resolve(e);if(!r||n>8)return r;if(Array.isArray(r.allOf)){let e={},i=[];for(let a of r.allOf){let r=Zw(a,t,n+1);r&&(Z(r.properties)&&Object.assign(e,r.properties),Array.isArray(r.required)&&i.push(...r.required.filter(e=>typeof e==`string`)))}return Z(r.properties)&&Object.assign(e,r.properties),Array.isArray(r.required)&&i.push(...r.required.filter(e=>typeof e==`string`)),{...r,type:`object`,properties:e,required:i}}let i=Array.isArray(r.oneOf)?r.oneOf:Array.isArray(r.anyOf)?r.anyOf:null;return i&&i.length>0&&!r.properties?Zw(i[0],t,n+1):r}function Qw(e,t){let n=Zw(e,t);if(n?.type===`array`&&(n=Zw(n.items,t)),!n||!Z(n.properties))return[];let r=new Set(Array.isArray(n.required)?n.required:[]);return Object.entries(n.properties).map(([e,n])=>{let i=Zw(n,t)??{};return{name:e,type:eT(n,t),required:r.has(e),...$w(i)}})}function $w(e){let t={},n=vx(e.description)?.trim();return n&&(t.description=n),Array.isArray(e.enum)&&(t.values=e.enum.map(e=>String(e))),t}function eT(e,t,n=0){let r=t.refName(e),i=Zw(e,t);if(!i)return r??`unknown`;let a=Array.isArray(i.type)?i.type.filter(e=>e!==`null`).join(` | `):vx(i.type);return a===`array`?n>8?`array`:`${eT(i.items,t,n+1)}[]`:r&&(a===`object`||a===void 0)?r:vx(i.format)??a??(i.properties?`object`:`unknown`)}function tT(e,t,n){let r=Zw(e,t);if(!r||n>8)return null;if(r.example!==void 0)return r.example;if(Array.isArray(r.enum)&&r.enum.length>0)return r.enum[0];let i=Array.isArray(r.type)?r.type.find(e=>e!==`null`):r.type;if(i===`object`||i===void 0&&Z(r.properties)){let e=Z(r.properties)?r.properties:{};return Object.fromEntries(Object.entries(e).map(([e,r])=>[e,tT(r,t,n+1)]))}switch(i){case`array`:return[tT(r.items,t,n+1)];case`string`:return`string`;case`integer`:case`number`:return 0;case`boolean`:return!1;default:return null}}function nT(e,t,n){if(!Array.isArray(e)||e.length===0)return null;let r=[];for(let i of e){if(!Z(i))continue;let e=Object.keys(i);e.length===0?r.push(`none`):r.push(e.map(e=>rT(e,n.resolve(t[e]))).join(` + `))}let i=[...new Set(r)];return i.length===0||i.length===1&&i[0]===`none`?null:i.map(e=>e===`none`?`no auth`:e).join(` or `)}function rT(e,t){if(!t)return e;switch(vx(t.type)?.toLowerCase()){case`http`:{let e=vx(t.scheme)?.toLowerCase();if(e===`bearer`){let e=vx(t.bearerFormat);return e?`Bearer token (${e})`:`Bearer token`}return e===`basic`?`Basic auth`:`HTTP ${e??`auth`}`}case`basic`:return`Basic auth`;case`apikey`:return`apikey ${vx(t.in)??`header`} ${vx(t.name)??e}`;case`oauth2`:return`OAuth2`;case`openidconnect`:return`OpenID Connect`;case`mutualtls`:return`Mutual TLS`;default:return e}}const iT=[`readme.md`,`readme.mdx`,`readme.markdown`,`readme.txt`,`readme`];async function aT(e){let t=e.files.find(e=>!e.path.includes(`/`)&&iT.includes(e.path.toLowerCase()));if(!t)return null;let n=await e.readText(t);return{path:t.path,oneLiner:n===null?null:oT(n)}}function oT(e){let t=e.replace(/\r\n/g,`
|
|
343
344
|
`).replace(/^---\n[\s\S]*?\n---\n/,``).replace(/<!--[\s\S]*?-->/g,``).replace(/^(```|~~~)[\s\S]*?^\1.*$/gm,``);for(let e of t.split(/\n\s*\n/)){let t=e.split(`
|
|
344
|
-
`).map(e=>e.trim()).filter(Boolean),n=t[0];if(!n||/^(#|=+$|-+$|\||[-*+] |\d+\. |>|<|\[!\[|!\[)/.test(n)||/^ {4}|^\t/.test(e))continue;let r=aT(t.join(` `));if(!(r.length<15||!/[a-z]/i.test(r)))return oT(/^.+?[.!?](?=\s+["'([]?[A-Z]|\s*$)/.exec(r)?.[0]??r,200)}return null}function aT(e){return e.replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]*)\]\[[^\]]*\]/g,`$1`).replace(/<[^>]+>/g,``).replace(/`([^`]*)`/g,`$1`).replace(/(\*\*|__)(.*?)\1/g,`$2`).replace(/(^|\W)[*_](\S(?:.*?\S)?)[*_](?=\W|$)/g,`$1$2`).replace(/\s+/g,` `).trim()}function oT(e,t){if(e.length<=t)return e;let n=e.slice(0,t-1),r=n.lastIndexOf(` `);return`${(r>t/2?n.slice(0,r):n).trimEnd()}…`}const sT={name:`Supabase`,type:`database`,provider:`Supabase Postgres`},cT={name:`Postgres`,type:`database`,provider:`Postgres`},lT={name:`MySQL`,type:`database`,provider:`MySQL`},uT={name:`MongoDB`,type:`database`,provider:`MongoDB`},dT={name:`Redis`,type:`database`,provider:`Redis`},fT={name:`Elasticsearch`,type:`database`,provider:`Elasticsearch`},pT={name:`AWS S3`,type:`storage`,provider:`AWS S3`},mT={name:`AWS SQS`,type:`queue`,provider:`AWS SQS`},hT={name:`AWS`,type:`service`,provider:`AWS`},gT={name:`MinIO`,type:`storage`,provider:`MinIO`},_T={name:`Cloudinary`,type:`storage`,provider:`Cloudinary`},vT={name:`RabbitMQ`,type:`queue`,provider:`RabbitMQ`},yT={name:`Kafka`,type:`queue`,provider:`Kafka`},bT={name:`Stripe`,type:`external_api`,provider:`Stripe`},xT={name:`Twilio`,type:`external_api`,provider:`Twilio`},ST={name:`SendGrid`,type:`service`,provider:`SendGrid`},CT={name:`Postmark`,type:`service`,provider:`Postmark`},wT={name:`Resend`,type:`service`,provider:`Resend`},TT={name:`Mailgun`,type:`service`,provider:`Mailgun`},ET={name:`Email (SMTP)`,type:`service`,provider:`SMTP`},DT={name:`Firebase`,type:`service`,provider:`Firebase`},OT={name:`OpenAI`,type:`external_api`,provider:`OpenAI`},kT={name:`Anthropic`,type:`external_api`,provider:`Anthropic`},AT={name:`Sentry`,type:`service`,provider:`Sentry`},jT={name:`Auth0`,type:`auth`,provider:`Auth0`},MT={name:`Clerk`,type:`auth`,provider:`Clerk`},NT={name:`Auth.js`,type:`auth`,provider:`Auth.js`},PT={name:`Algolia`,type:`external_api`,provider:`Algolia`},FT={name:`Google Cloud`,type:`service`,provider:`Google Cloud`},IT={name:`Cloud Storage`,type:`storage`,provider:`Google Cloud Storage`},LT={name:`Pub/Sub`,type:`queue`,provider:`Google Cloud Pub/Sub`},RT={name:`BigQuery`,type:`database`,provider:`Google BigQuery`},zT={name:`Firestore`,type:`database`,provider:`Google Firestore`},BT={name:`Secret Manager`,type:`service`,provider:`Google Secret Manager`},VT={name:`Gemini`,type:`external_api`,provider:`Google Gemini`},HT={name:`Vertex AI`,type:`external_api`,provider:`Google Vertex AI`},UT={name:`SerpApi`,type:`external_api`,provider:`SerpApi`},WT={name:`Zyte`,type:`external_api`,provider:`Zyte`},GT={name:`Open Exchange Rates`,type:`external_api`,provider:`Open Exchange Rates`},KT={name:`reCAPTCHA`,type:`external_api`,provider:`Google reCAPTCHA`},qT={name:`DuckDB`,type:`database`,provider:`DuckDB`},JT=[[/^SUPABASE_/,sT],[/^(DATABASE_URL|POSTGRES_|PG(HOST|USER|PASSWORD|DATABASE|PORT)$)/,cT],[/^MYSQL_/,lT],[/^MONGO(DB)?_/,uT],[/^(REDIS_|UPSTASH_REDIS_)/,dT],[/^(ELASTIC(SEARCH)?_)/,fT],[/^(AWS_)?S3_|_S3_BUCKET$|^AWS_BUCKET/,pT],[/^(AWS_)?SQS_/,mT],[/^AWS_(ACCESS_KEY_ID|SECRET_ACCESS_KEY|REGION|DEFAULT_REGION)$/,hT],[/^MINIO_/,gT],[/^CLOUDINARY_/,_T],[/^(RABBITMQ_|AMQP_URL)/,vT],[/^KAFKA_/,yT],[/^STRIPE_/,bT],[/^TWILIO_/,xT],[/^SENDGRID_/,ST],[/^POSTMARK_/,CT],[/^RESEND_/,wT],[/^MAILGUN_/,TT],[/^SMTP_/,ET],[/^FIREBASE_/,DT],[/^OPENAI_/,OT],[/^ANTHROPIC_/,kT],[/^SENTRY_/,AT],[/^AUTH0_/,jT],[/^CLERK_/,MT],[/^(NEXTAUTH_|AUTH_SECRET$)/,NT],[/^ALGOLIA_/,PT],[/^(GCS_BUCKET|GOOGLE_CLOUD_STORAGE_|GCS_)/,IT],[/^(PUBSUB_|GOOGLE_PUBSUB_)/,LT],[/^BIGQUERY_/,RT],[/^FIRESTORE_/,zT],[/^(GEMINI_|GOOGLE_GENAI_)/,VT],[/^VERTEX(_AI)?_/,HT],[/^(SERPAPI_|SERP_API_)/,UT],[/^ZYTE_/,WT],[/^(OPEN_EXCHANGE_RATES_|OPENEXCHANGERATES_|OXR_)/,GT],[/^RECAPTCHA_/,KT],[/^(GOOGLE_CLOUD_PROJECT|GCP_PROJECT(_ID)?|GCLOUD_PROJECT|GOOGLE_APPLICATION_CREDENTIALS)$/,FT]],YT=[[[`@supabase/supabase-js`,`@supabase/ssr`,`supabase`,`github.com/supabase-community/*`,`supabase/supabase-php`],sT],[[`pg`,`postgres`,`pg-promise`,`@neondatabase/serverless`,`@vercel/postgres`,`psycopg2`,`psycopg2-binary`,`psycopg`,`asyncpg`,`github.com/jackc/pgx*`,`github.com/lib/pq`],cT],[[`mysql`,`mysql2`,`pymysql`,`mysqlclient`,`github.com/go-sql-driver/mysql`],lT],[[`mongodb`,`mongoose`,`pymongo`,`motor`,`go.mongodb.org/mongo-driver*`,`mongodb/mongodb`],uT],[[`redis`,`ioredis`,`@upstash/redis`,`predis/predis`,`github.com/redis/go-redis*`,`github.com/go-redis/redis*`],dT],[[`@elastic/elasticsearch`,`elasticsearch`,`elasticsearch/elasticsearch`],fT],[[`@aws-sdk/client-s3`,`github.com/aws/aws-sdk-go-v2/service/s3`,`league/flysystem-aws-s3-v3`],pT],[[`@aws-sdk/client-sqs`,`github.com/aws/aws-sdk-go-v2/service/sqs`],mT],[[`aws-sdk`,`boto3`,`aws/aws-sdk-php`,`github.com/aws/aws-sdk-go`],hT],[[`minio`],gT],[[`cloudinary`,`cloudinary/cloudinary_php`],_T],[[`amqplib`,`pika`,`php-amqplib/php-amqplib`,`github.com/rabbitmq/amqp091-go`],vT],[[`kafkajs`,`kafka-python`,`confluent-kafka`,`github.com/segmentio/kafka-go`],yT],[[`stripe`,`@stripe/stripe-js`,`@stripe/react-stripe-js`,`stripe/stripe-php`,`github.com/stripe/stripe-go*`],bT],[[`twilio`,`twilio/sdk`,`github.com/twilio/twilio-go`],xT],[[`@sendgrid/`,`sendgrid`,`sendgrid/sendgrid`],ST],[[`postmark`,`wildbit/postmark-php`],CT],[[`resend`,`resend/resend-php`],wT],[[`mailgun.js`,`mailgun/mailgun-php`],TT],[[`nodemailer`],ET],[[`firebase`,`firebase-admin`,`firebase-functions`,`kreait/firebase-php`,`firebase.google.com/go*`],DT],[[`openai`,`openai-php/client`,`github.com/sashabaranov/go-openai`],OT],[[`@anthropic-ai/sdk`,`anthropic`,`github.com/anthropics/anthropic-sdk-go`],kT],[[`@sentry/`,`sentry-sdk`,`sentry/sentry`,`sentry/sentry-laravel`,`github.com/getsentry/sentry-go`],AT],[[`@auth0/`,`auth0`,`auth0/auth0-php`],jT],[[`@clerk/`],MT],[[`next-auth`,`@auth/`],NT],[[`algoliasearch`,`algolia/algoliasearch-client-php`],PT],[[`@google-cloud/storage`,`google-cloud-storage`,`cloud.google.com/go/storage`],IT],[[`@google-cloud/pubsub`,`google-cloud-pubsub`,`cloud.google.com/go/pubsub*`],LT],[[`@google-cloud/bigquery`,`google-cloud-bigquery`,`cloud.google.com/go/bigquery`],RT],[[`@google-cloud/firestore`,`google-cloud-firestore`,`cloud.google.com/go/firestore`],zT],[[`@google-cloud/secret-manager`,`google-cloud-secret-manager`,`cloud.google.com/go/secretmanager`],BT],[[`@google/genai`,`@google/generative-ai`,`google-genai`,`google-generativeai`],VT],[[`@google-cloud/vertexai`,`google-cloud-aiplatform`,`vertexai`],HT],[[`serpapi`,`google-search-results`],UT],[[`zyte-api`,`scrapy-zyte-api`],WT],[[`open-exchange-rates`],GT],[[`react-google-recaptcha`,`react-google-recaptcha-v3`,`vue-recaptcha`,`vue-recaptcha-v3`,`@google-cloud/recaptcha-enterprise`,`google-cloud-recaptcha-enterprise`,`django-recaptcha`],KT],[[`@google-cloud/`,`google-cloud-*`,`google-auth-library`,`google-auth`,`cloud.google.com/go*`],FT],[[`duckdb`,`@duckdb/`],qT]],XT=[[/^supabase\//,sT],[/(^|\/)(postgres|postgis|timescaledb)$/,cT],[/(^|\/)(mysql|mariadb)$/,lT],[/(^|\/)mongo(db)?$/,uT],[/(^|\/)(redis|redis-stack|valkey)$/,dT],[/(^|\/)(elasticsearch|opensearch)$/,fT],[/(^|\/)minio$/,gT],[/(^|\/)rabbitmq$/,vT],[/(^|\/)(kafka|cp-kafka)$/,yT],[/(^|\/)localstack$/,hT],[/(^|\/)(cloud-sdk|google-cloud-cli)$/,FT],[/(^|\/)(gcloud-pubsub-emulator|pubsub-emulator)$/,LT],[/(^|\/)fake-gcs-server$/,IT]];function ZT(e){return/^\.env(\.[\w-]+)*\.(example|sample|template|dist)$/i.test(e)||/^(example|sample)\.env$/i.test(e)}function QT(e){let t=fx(e);return/^\.gitlab-ci\.ya?ml$/.test(t)||/^cloudbuild\.ya?ml$/.test(t)||t===`bitbucket-pipelines.yml`||/(^|\/)\.github\/workflows\/[^/]+\.ya?ml$/.test(e)}function $T(e){return[...new Set(e.match(/\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+\b/g)??[])]}function eE(e){return/^(docker-)?compose([.-][\w.-]+)?\.ya?ml$/i.test(e)}var tE=class{#e=/* @__PURE__ */ new Map;add(e,t){let n=this.#e.get(e.provider);n?n.evidence.includes(t)||n.evidence.push(t):this.#e.set(e.provider,{...e,evidence:[t]})}list(){return[...this.#e.values()].sort((e,t)=>e.name.localeCompare(t.name))}};async function nE(e,t){let n=new tE,r=(e,t)=>{let r=e.replace(/^(NEXT_PUBLIC_|VITE_|PUBLIC_|REACT_APP_|EXPO_PUBLIC_|NUXT_PUBLIC_|NUXT_)/,``),i=JT.find(([e])=>e.test(r));i&&n.add(i[1],t)};for(let t of e.files){let i=fx(t.path);if(ZT(i)){let n=await e.readText(t);if(n===null)continue;for(let e of rE(n))r(e,`env: ${e} (${t.path})`)}else if(QT(t.path)){let n=await e.readText(t);if(n===null)continue;for(let e of $T(n))r(e,`pipeline: ${e} (${t.path})`)}else if(eE(i)){let i=await e.readText(t);if(i===null)continue;let a;try{a=(0,UC.parse)(i)}catch(n){e.warnings.push(`${t.path}: could not be parsed (${hx(n)})`);continue}let o=Z(a)&&Z(a.services)?a.services:{};for(let[e,i]of Object.entries(o)){if(!Z(i))continue;let a=i.environment,o=Array.isArray(a)?a.map(e=>String(e).split(`=`,1)[0]??``):Z(a)?Object.keys(a):[];for(let n of o)r(n,`docker-compose: ${e} env ${n} in ${t.path}`);if(typeof i.image!=`string`)continue;let s=iE(i.image),c=XT.find(([e])=>e.test(s));c&&n.add(c[1],`docker-compose: service ${e} (${i.image}) in ${t.path}`)}}else t.path===`supabase/config.toml`||t.path.endsWith(`/supabase/config.toml`)?n.add(sT,`file: ${t.path}`):i===`firebase.json`?n.add(DT,`file: ${t.path}`):/^cloudbuild\.ya?ml$/.test(i)&&n.add(FT,`file: ${t.path}`)}for(let e of t){if(!e.direct)continue;let t=YT.find(([t])=>t.some(t=>aE(t,e.package)));t&&n.add(t[1],`dependency: ${e.package} (${e.sourceLockfile})`)}return n.list()}function rE(e){let t=[];for(let n of e.split(/\r?\n/)){let e=/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(n);e?.[1]&&t.push(e[1])}return t}function iE(e){let t=e.toLowerCase().replace(/@.*$/,``),n=t.lastIndexOf(`/`),r=t.indexOf(`:`,n+1);r!==-1&&(t=t.slice(0,r));let i=t.split(`/`);return i.length>1&&/[.:]|^localhost$/.test(i[0]??``)&&i.shift(),i[0]===`library`&&i.shift(),i.join(`/`)}function aE(e,t){return e.endsWith(`*`)?t.startsWith(e.slice(0,-1)):e.endsWith(`/`)?t.startsWith(e):t===e}async function oE(e,{fromDisk:t=!1}={}){let n=_.resolve(e);if(!(await p(n)).isDirectory())throw Error(`${n} is not a folder`);let r=(/* @__PURE__ */ new Date()).toISOString(),i=[],a=t?null:await _S(n);!t&&!a&&C(_.join(n,`.git`))&&i.push(`No main or master branch found: read the files on disk instead`);let o=a?await lx(n,a.ref):await cx(n),s=await nS(o),[c,l,u,d,f,m,h]=await Promise.all([yS(n,i,a?.ref??null),rT(o),iw(o),iS(o,s),dS(o),Iw(o),pw(o)]),g=await nE(o,u);return{scannedAt:r,root:n,repo:{...c,languages:sw(o.files),readme:l},dependencies:u,docs:d,agentInstructions:f,contracts:[...m,...h],resources:g,docsConfig:{alwaysLoad:!!s.alwaysLoad},warnings:[...i,...o.warnings]}}function sE(e){let t=(e,t,n=`${t}s`)=>e?`${e} ${e===1?t:n}`:``;return[t(e.docs,`doc`)+(e.docsChanged&&e.docsChanged<e.docs?` (${e.docsChanged} changed)`:``),t(e.dependencies,`dependency`,`dependencies`),t(e.contracts,`contract`),t(e.resources,`service`)].filter(Boolean).join(` · `)||`nothing to import yet`}function cE(e){let{scannedRef:t,headSha:n}=e.repo;if(!t)return`files on disk`;let r=t.replace(/^origin\//,``);return n?`${r} @ ${n.slice(0,7)}`:r}async function lE(e,t,{quiet:n=!1,source:r=`connector`}={}){await vS(e);let i=await oE(e),a=await new Ur(await Jb()).call(`sync_repo`,{p_project:t.projectId,p_snapshot:i,p_source:r});if(!n){Ex(`Synced ${Sx(i.repo.name)} to ${Sx(t.name)} ${Q(`from ${cE(i)}`)}`),Dx(Q(sE(a)));for(let e of i.warnings)Dx(Q(`! ${e}`))}return{snapshot:i,result:a}}async function uE(e){return mS(await cx(e))}const dE=26214400,fE=e=>`${(e/1024/1024).toFixed(1)} MB`;async function pE(e,t,{quiet:n=!1}={}){if(!t.folder)return;let{docs:r,unsupported:i}=await uE(e),a=e=>Buffer.byteLength(e.body),o=r.reduce((e,t)=>e+a(t),0);if(o>dE){let t=/* @__PURE__ */ new Map;for(let e of r){let n=e.path.includes(`/`)?`${e.path.split(`/`)[0]}/`:e.path;t.set(n,(t.get(n)??0)+a(e))}let n=[...t].sort((e,t)=>t[1]-e[1]).slice(0,3).map(([e,t])=>`${e} (${fE(t)})`).join(`, `);throw new jx(`The documents outside the repos add up to ${fE(o)}, over the ${fE(dE)} a sync takes. The biggest: ${n}. List what Quirl should skip in ${x(v(e),`.quirlignore`)}, like .gitignore.`)}let s=new Ur(await Jb()),c={p_project:t.projectId,p_folder:t.folder},l=await s.call(`folder_doc_hashes`,c),u=r.filter(e=>l[e.path]!==e.contentHash),d=0;for(let t=0;t<u.length;){let n=[],r=0;for(;t<u.length;){let e=u[t];if(n.length&&r+a(e)>2097152)break;n.push(e),r+=a(e),t++}let i=await s.call(`sync_folder_docs`,{...c,p_folder_name:v(e),p_docs:n});d+=i.docsChanged}let f={...await s.call(`sync_folder_finish`,{...c,p_paths:r.map(e=>e.path)}),docsChanged:d};return n||(Ex(`Synced the documents in ${Sx(`${v(e)}/`)} outside the repos`),Dx(Q(`${f.docs} docs (${f.docsChanged} changed${f.archived?`, ${f.archived} removed`:``})`)),i.length&&Dx(Q(`! ${i.length} PDF/Office files skipped: only markdown and text are read for now`))),f}async function mE(e={}){let t=await Zb();if(!t)throw new jx("This folder isn't linked to a Quirl project. Run `quirl init`.");let n=t.link.repos?.length?t.link.repos.map(e=>x(t.root,e)):[t.root],r=n.length+ +!!t.link.folder,i=0;for(let a of n)try{await lE(a,t.link,e)}catch(e){if(i++,r===1)throw e;let n=S(t.root,a)||`.`;console.error(`${wx(`✗`)} ${n}: ${hx(e)}`)}if(t.link.folder)try{await pE(t.root,t.link,e)}catch(e){i++,console.error(`${wx(`✗`)} documents in ${v(t.root)}/: ${hx(e)}`)}if(i)throw new jx(`${i} of ${r} parts didn't sync.`)}async function hE(e){let t=Yb(),n=await yx(t),r=n.length?n:[t],i=r.length>1||r[0]!==t,a=e=>S(t,e)||v(t),o=h(),s=t.startsWith(o)?`~${t.slice(o.length)}`:t;if(console.log(`\n🌀 ${Sx(`Quirl`)} ${Q(`·`)} connecting ${Sx(s)}`),i&&(Ox(`📁`,`Found ${r.length} ${r.length===1?`repo`:`repos`}`),kx(Q(r.map(a).join(` · `))),!await Nx(` Import all of them into one project?`,!0)))throw new jx("Nothing imported. Run `quirl init` inside the repo you want instead.");let c=!1;if(i&&!n.includes(t)){let{docs:e,unsupported:n}=await uE(t);if(e.length){Ox(`📄`,`Also found ${e.length} ${e.length===1?`document`:`documents`} outside the repos`);for(let t of e.slice(0,8))kx(Q(t.path));e.length>8&&kx(Q(`…and ${e.length-8} more`)),n.length&&kx(Q(`(${n.length} PDF/Office files can't be read yet and are skipped)`)),c=await Nx(` Import them too? Everyone on the project will be able to read them.`,!0)}}await Gb()||await Jx({quiet:!0});let l=await _E((await new Ur(await Jb()).whoami()).projects,e.project??(await Zb(t))?.link.project);if(l.role===`stakeholder`)throw new jx(`You're a stakeholder on ${l.name}; ask an admin or dev to run \`quirl init\`.`);let u={project:l.slug,projectId:l.id,name:l.name};Ox(`🔗`,`Linked to ${Sx(l.name)} ${Q(`· ${l.organization}`)}`);let d=e.claude!==!1,f=e.hooks??await Nx(` Sync with Quirl on every git push?`,!0);Ox(`📦`,`Importing docs, dependencies and schemas`);let p=[];for(let e of r){let t=Ax(`Reading ${a(e)}…`);try{await Qb(e,u);let{snapshot:n,result:r}=await lE(e,u,{quiet:!0});d&&await gE(e,l.name),f&&await qx(e),t.stop(),kx(`${Cx(`✓`)} ${Sx(a(e))} ${Q(`(${cE(n)})`)} ${Q(sE(r))}`);for(let e of n.warnings)kx(Q(` ! ${e}`));p.push(e)}catch(n){t.stop(),kx(`${wx(`✗`)} ${Sx(a(e))} ${hx(n)}`)}}if(!p.length)throw new jx(`No repo was imported.`);if(i){let e=p.map(a),n=await Zb(t),r={...u,repos:e,folder:c?n?.root===t&&n.link.folder||T():void 0};if(await Qb(t,r),c)try{let e=await pE(t,r,{quiet:!0});kx(`${Cx(`✓`)} ${Sx(`documents outside the repos`)} ${Q(`${e?.docs??0} docs`)}`)}catch(e){kx(`${wx(`✗`)} ${Sx(`documents outside the repos`)} ${hx(e)}`)}d&&!p.includes(t)&&await gE(t,l.name,e)}let m=Rx().portable;d&&(Ox(`🤖`,`Connected Claude Code`),kx(Q(`.mcp.json the quirl tools`)),kx(Q(`.claude/settings.json the briefing, loaded as each session starts`)),kx(Q(`CLAUDE.md when to use Quirl`))),f&&Ox(`🪝`,`Quirl syncs on every ${Sx(`git push`)}`);let g=r.length-p.length,_=`.quirl .mcp.json .claude/settings.json CLAUDE.md`;Ox(g?`⚠️ `:`🎉`,g?`Done, but ${g} of ${r.length} repos failed. Fix them and run ${Sx(`quirl init`)} again.`:Sx(`All set!`)),kx(d&&!m?Q(`Don't commit ${_} yet: they point at this checkout until the CLI is installed.`):`${Q(`1.`)} Commit what was added${i?` in each repo`:``}: ${Tx(`git add ${_}`)}`),kx(`${Q(d&&!m?`→`:`2.`)} Start Claude Code here and approve the ${Sx(`quirl`)} server when it asks.`),i&&!p.includes(t)&&kx(Q("Run `quirl sync` here to sync every repo at once.")),console.log(``)}async function gE(e,t,n=[]){await Wx(e),await Gx(e),await Kx(e,t,n)}async function _E(e,t){if(!e.length)throw new jx(`You aren't on any Quirl project yet. Ask an admin to invite you.`);if(t){let n=e.find(e=>e.slug===t||e.id===t);if(!n)throw new jx(`No project "${t}" among yours: ${e.map(e=>e.slug).join(`, `)}.`);return n}if(e.length===1)return e[0];Ox(`🗂️ `,`Which project is this part of?`);for(let[t,n]of e.entries())kx(`${Tx(String(t+1))} ${n.name} ${Q(`· ${n.organization} · ${n.role}`)}`);let n=e[Number(await Mx(` Project [1-${e.length}]: `))-1];if(!n)throw new jx("No project picked. Run `quirl init --project <slug>`.");return n}const vE=`${Sx(`quirl`)} ${Q(zb)}: connect a repo to Quirl
|
|
345
|
+
`).map(e=>e.trim()).filter(Boolean),n=t[0];if(!n||/^(#|=+$|-+$|\||[-*+] |\d+\. |>|<|\[!\[|!\[)/.test(n)||/^ {4}|^\t/.test(e))continue;let r=sT(t.join(` `));if(!(r.length<15||!/[a-z]/i.test(r)))return cT(/^.+?[.!?](?=\s+["'([]?[A-Z]|\s*$)/.exec(r)?.[0]??r,200)}return null}function sT(e){return e.replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]*)\]\[[^\]]*\]/g,`$1`).replace(/<[^>]+>/g,``).replace(/`([^`]*)`/g,`$1`).replace(/(\*\*|__)(.*?)\1/g,`$2`).replace(/(^|\W)[*_](\S(?:.*?\S)?)[*_](?=\W|$)/g,`$1$2`).replace(/\s+/g,` `).trim()}function cT(e,t){if(e.length<=t)return e;let n=e.slice(0,t-1),r=n.lastIndexOf(` `);return`${(r>t/2?n.slice(0,r):n).trimEnd()}…`}const lT={name:`Supabase`,type:`database`,provider:`Supabase Postgres`},uT={name:`Postgres`,type:`database`,provider:`Postgres`},dT={name:`MySQL`,type:`database`,provider:`MySQL`},fT={name:`MongoDB`,type:`database`,provider:`MongoDB`},pT={name:`Redis`,type:`database`,provider:`Redis`},mT={name:`Elasticsearch`,type:`database`,provider:`Elasticsearch`},hT={name:`AWS S3`,type:`storage`,provider:`AWS S3`},gT={name:`AWS SQS`,type:`queue`,provider:`AWS SQS`},_T={name:`AWS`,type:`service`,provider:`AWS`},vT={name:`MinIO`,type:`storage`,provider:`MinIO`},yT={name:`Cloudinary`,type:`storage`,provider:`Cloudinary`},bT={name:`RabbitMQ`,type:`queue`,provider:`RabbitMQ`},xT={name:`Kafka`,type:`queue`,provider:`Kafka`},ST={name:`Stripe`,type:`external_api`,provider:`Stripe`},CT={name:`Twilio`,type:`external_api`,provider:`Twilio`},wT={name:`SendGrid`,type:`service`,provider:`SendGrid`},TT={name:`Postmark`,type:`service`,provider:`Postmark`},ET={name:`Resend`,type:`service`,provider:`Resend`},DT={name:`Mailgun`,type:`service`,provider:`Mailgun`},OT={name:`Email (SMTP)`,type:`service`,provider:`SMTP`},kT={name:`Firebase`,type:`service`,provider:`Firebase`},AT={name:`OpenAI`,type:`external_api`,provider:`OpenAI`},jT={name:`Anthropic`,type:`external_api`,provider:`Anthropic`},MT={name:`Sentry`,type:`service`,provider:`Sentry`},NT={name:`Auth0`,type:`auth`,provider:`Auth0`},PT={name:`Clerk`,type:`auth`,provider:`Clerk`},FT={name:`Auth.js`,type:`auth`,provider:`Auth.js`},IT={name:`Algolia`,type:`external_api`,provider:`Algolia`},LT={name:`Google Cloud`,type:`service`,provider:`Google Cloud`},RT={name:`Cloud Storage`,type:`storage`,provider:`Google Cloud Storage`},zT={name:`Pub/Sub`,type:`queue`,provider:`Google Cloud Pub/Sub`},BT={name:`BigQuery`,type:`database`,provider:`Google BigQuery`},VT={name:`Firestore`,type:`database`,provider:`Google Firestore`},HT={name:`Secret Manager`,type:`service`,provider:`Google Secret Manager`},UT={name:`Gemini`,type:`external_api`,provider:`Google Gemini`},WT={name:`Vertex AI`,type:`external_api`,provider:`Google Vertex AI`},GT={name:`SerpApi`,type:`external_api`,provider:`SerpApi`},KT={name:`Zyte`,type:`external_api`,provider:`Zyte`},qT={name:`Open Exchange Rates`,type:`external_api`,provider:`Open Exchange Rates`},JT={name:`reCAPTCHA`,type:`external_api`,provider:`Google reCAPTCHA`},YT={name:`DuckDB`,type:`database`,provider:`DuckDB`},XT=[[/^SUPABASE_/,lT],[/^(DATABASE_URL|POSTGRES_|PG(HOST|USER|PASSWORD|DATABASE|PORT)$)/,uT],[/^MYSQL_/,dT],[/^MONGO(DB)?_/,fT],[/^(REDIS_|UPSTASH_REDIS_)/,pT],[/^(ELASTIC(SEARCH)?_)/,mT],[/^(AWS_)?S3_|_S3_BUCKET$|^AWS_BUCKET/,hT],[/^(AWS_)?SQS_/,gT],[/^AWS_(ACCESS_KEY_ID|SECRET_ACCESS_KEY|REGION|DEFAULT_REGION)$/,_T],[/^MINIO_/,vT],[/^CLOUDINARY_/,yT],[/^(RABBITMQ_|AMQP_URL)/,bT],[/^KAFKA_/,xT],[/^STRIPE_/,ST],[/^TWILIO_/,CT],[/^SENDGRID_/,wT],[/^POSTMARK_/,TT],[/^RESEND_/,ET],[/^MAILGUN_/,DT],[/^SMTP_/,OT],[/^FIREBASE_/,kT],[/^OPENAI_/,AT],[/^ANTHROPIC_/,jT],[/^SENTRY_/,MT],[/^AUTH0_/,NT],[/^CLERK_/,PT],[/^(NEXTAUTH_|AUTH_SECRET$)/,FT],[/^ALGOLIA_/,IT],[/^(GCS_BUCKET|GOOGLE_CLOUD_STORAGE_|GCS_)/,RT],[/^(PUBSUB_|GOOGLE_PUBSUB_)/,zT],[/^BIGQUERY_/,BT],[/^FIRESTORE_/,VT],[/^(GEMINI_|GOOGLE_GENAI_)/,UT],[/^VERTEX(_AI)?_/,WT],[/^(SERPAPI_|SERP_API_)/,GT],[/^ZYTE_/,KT],[/^(OPEN_EXCHANGE_RATES_|OPENEXCHANGERATES_|OXR_)/,qT],[/^RECAPTCHA_/,JT],[/^(GOOGLE_CLOUD_PROJECT|GCP_PROJECT(_ID)?|GCLOUD_PROJECT|GOOGLE_APPLICATION_CREDENTIALS)$/,LT]],ZT=[[[`@supabase/supabase-js`,`@supabase/ssr`,`supabase`,`github.com/supabase-community/*`,`supabase/supabase-php`],lT],[[`pg`,`postgres`,`pg-promise`,`@neondatabase/serverless`,`@vercel/postgres`,`psycopg2`,`psycopg2-binary`,`psycopg`,`asyncpg`,`github.com/jackc/pgx*`,`github.com/lib/pq`],uT],[[`mysql`,`mysql2`,`pymysql`,`mysqlclient`,`github.com/go-sql-driver/mysql`],dT],[[`mongodb`,`mongoose`,`pymongo`,`motor`,`go.mongodb.org/mongo-driver*`,`mongodb/mongodb`],fT],[[`redis`,`ioredis`,`@upstash/redis`,`predis/predis`,`github.com/redis/go-redis*`,`github.com/go-redis/redis*`],pT],[[`@elastic/elasticsearch`,`elasticsearch`,`elasticsearch/elasticsearch`],mT],[[`@aws-sdk/client-s3`,`github.com/aws/aws-sdk-go-v2/service/s3`,`league/flysystem-aws-s3-v3`],hT],[[`@aws-sdk/client-sqs`,`github.com/aws/aws-sdk-go-v2/service/sqs`],gT],[[`aws-sdk`,`boto3`,`aws/aws-sdk-php`,`github.com/aws/aws-sdk-go`],_T],[[`minio`],vT],[[`cloudinary`,`cloudinary/cloudinary_php`],yT],[[`amqplib`,`pika`,`php-amqplib/php-amqplib`,`github.com/rabbitmq/amqp091-go`],bT],[[`kafkajs`,`kafka-python`,`confluent-kafka`,`github.com/segmentio/kafka-go`],xT],[[`stripe`,`@stripe/stripe-js`,`@stripe/react-stripe-js`,`stripe/stripe-php`,`github.com/stripe/stripe-go*`],ST],[[`twilio`,`twilio/sdk`,`github.com/twilio/twilio-go`],CT],[[`@sendgrid/`,`sendgrid`,`sendgrid/sendgrid`],wT],[[`postmark`,`wildbit/postmark-php`],TT],[[`resend`,`resend/resend-php`],ET],[[`mailgun.js`,`mailgun/mailgun-php`],DT],[[`nodemailer`],OT],[[`firebase`,`firebase-admin`,`firebase-functions`,`kreait/firebase-php`,`firebase.google.com/go*`],kT],[[`openai`,`openai-php/client`,`github.com/sashabaranov/go-openai`],AT],[[`@anthropic-ai/sdk`,`anthropic`,`github.com/anthropics/anthropic-sdk-go`],jT],[[`@sentry/`,`sentry-sdk`,`sentry/sentry`,`sentry/sentry-laravel`,`github.com/getsentry/sentry-go`],MT],[[`@auth0/`,`auth0`,`auth0/auth0-php`],NT],[[`@clerk/`],PT],[[`next-auth`,`@auth/`],FT],[[`algoliasearch`,`algolia/algoliasearch-client-php`],IT],[[`@google-cloud/storage`,`google-cloud-storage`,`cloud.google.com/go/storage`],RT],[[`@google-cloud/pubsub`,`google-cloud-pubsub`,`cloud.google.com/go/pubsub*`],zT],[[`@google-cloud/bigquery`,`google-cloud-bigquery`,`cloud.google.com/go/bigquery`],BT],[[`@google-cloud/firestore`,`google-cloud-firestore`,`cloud.google.com/go/firestore`],VT],[[`@google-cloud/secret-manager`,`google-cloud-secret-manager`,`cloud.google.com/go/secretmanager`],HT],[[`@google/genai`,`@google/generative-ai`,`google-genai`,`google-generativeai`],UT],[[`@google-cloud/vertexai`,`google-cloud-aiplatform`,`vertexai`],WT],[[`serpapi`,`google-search-results`],GT],[[`zyte-api`,`scrapy-zyte-api`],KT],[[`open-exchange-rates`],qT],[[`react-google-recaptcha`,`react-google-recaptcha-v3`,`vue-recaptcha`,`vue-recaptcha-v3`,`@google-cloud/recaptcha-enterprise`,`google-cloud-recaptcha-enterprise`,`django-recaptcha`],JT],[[`@google-cloud/`,`google-cloud-*`,`google-auth-library`,`google-auth`,`cloud.google.com/go*`],LT],[[`duckdb`,`@duckdb/`],YT]],QT=[[/^supabase\//,lT],[/(^|\/)(postgres|postgis|timescaledb)$/,uT],[/(^|\/)(mysql|mariadb)$/,dT],[/(^|\/)mongo(db)?$/,fT],[/(^|\/)(redis|redis-stack|valkey)$/,pT],[/(^|\/)(elasticsearch|opensearch)$/,mT],[/(^|\/)minio$/,vT],[/(^|\/)rabbitmq$/,bT],[/(^|\/)(kafka|cp-kafka)$/,xT],[/(^|\/)localstack$/,_T],[/(^|\/)(cloud-sdk|google-cloud-cli)$/,LT],[/(^|\/)(gcloud-pubsub-emulator|pubsub-emulator)$/,zT],[/(^|\/)fake-gcs-server$/,RT]];function $T(e){return/^\.env(\.[\w-]+)*\.(example|sample|template|dist)$/i.test(e)||/^(example|sample)\.env$/i.test(e)}function eE(e){let t=mx(e);return/^\.gitlab-ci\.ya?ml$/.test(t)||/^cloudbuild\.ya?ml$/.test(t)||t===`bitbucket-pipelines.yml`||/(^|\/)\.github\/workflows\/[^/]+\.ya?ml$/.test(e)}function tE(e){return[...new Set(e.match(/\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+\b/g)??[])]}function nE(e){return/^(docker-)?compose([.-][\w.-]+)?\.ya?ml$/i.test(e)}var rE=class{#e=/* @__PURE__ */ new Map;add(e,t){let n=this.#e.get(e.provider);n?n.evidence.includes(t)||n.evidence.push(t):this.#e.set(e.provider,{...e,evidence:[t]})}list(){return[...this.#e.values()].sort((e,t)=>e.name.localeCompare(t.name))}};async function iE(e,t){let n=new rE,r=(e,t)=>{let r=e.replace(/^(NEXT_PUBLIC_|VITE_|PUBLIC_|REACT_APP_|EXPO_PUBLIC_|NUXT_PUBLIC_|NUXT_)/,``),i=XT.find(([e])=>e.test(r));i&&n.add(i[1],t)};for(let t of e.files){let i=mx(t.path);if($T(i)){let n=await e.readText(t);if(n===null)continue;for(let e of aE(n))r(e,`env: ${e} (${t.path})`)}else if(eE(t.path)){let n=await e.readText(t);if(n===null)continue;for(let e of tE(n))r(e,`pipeline: ${e} (${t.path})`)}else if(nE(i)){let i=await e.readText(t);if(i===null)continue;let a;try{a=(0,GC.parse)(i)}catch(n){e.warnings.push(`${t.path}: could not be parsed (${_x(n)})`);continue}let o=Z(a)&&Z(a.services)?a.services:{};for(let[e,i]of Object.entries(o)){if(!Z(i))continue;let a=i.environment,o=Array.isArray(a)?a.map(e=>String(e).split(`=`,1)[0]??``):Z(a)?Object.keys(a):[];for(let n of o)r(n,`docker-compose: ${e} env ${n} in ${t.path}`);if(typeof i.image!=`string`)continue;let s=oE(i.image),c=QT.find(([e])=>e.test(s));c&&n.add(c[1],`docker-compose: service ${e} (${i.image}) in ${t.path}`)}}else t.path===`supabase/config.toml`||t.path.endsWith(`/supabase/config.toml`)?n.add(lT,`file: ${t.path}`):i===`firebase.json`?n.add(kT,`file: ${t.path}`):/^cloudbuild\.ya?ml$/.test(i)&&n.add(LT,`file: ${t.path}`)}for(let e of t){if(!e.direct)continue;let t=ZT.find(([t])=>t.some(t=>sE(t,e.package)));t&&n.add(t[1],`dependency: ${e.package} (${e.sourceLockfile})`)}return n.list()}function aE(e){let t=[];for(let n of e.split(/\r?\n/)){let e=/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(n);e?.[1]&&t.push(e[1])}return t}function oE(e){let t=e.toLowerCase().replace(/@.*$/,``),n=t.lastIndexOf(`/`),r=t.indexOf(`:`,n+1);r!==-1&&(t=t.slice(0,r));let i=t.split(`/`);return i.length>1&&/[.:]|^localhost$/.test(i[0]??``)&&i.shift(),i[0]===`library`&&i.shift(),i.join(`/`)}function sE(e,t){return e.endsWith(`*`)?t.startsWith(e.slice(0,-1)):e.endsWith(`/`)?t.startsWith(e):t===e}async function cE(e,{fromDisk:t=!1}={}){let n=_.resolve(e);if(!(await p(n)).isDirectory())throw Error(`${n} is not a folder`);let r=(/* @__PURE__ */ new Date()).toISOString(),i=[],a=t?null:await yS(n);!t&&!a&&C(_.join(n,`.git`))&&i.push(`No main or master branch found: read the files on disk instead`);let o=a?await dx(n,a.ref):await ux(n),s=await iS(o),[c,l,u,d,f,m,h]=await Promise.all([xS(n,i,a?.ref??null),aT(o),ow(o),oS(o,s),pS(o),Rw(o),hw(o)]),g=await iE(o,u);return{scannedAt:r,root:n,repo:{...c,languages:lw(o.files),readme:l},dependencies:u,docs:d,agentInstructions:f,contracts:[...m,...h],resources:g,docsConfig:{alwaysLoad:!!s.alwaysLoad},warnings:[...i,...o.warnings]}}function lE(e){let t=(e,t,n=`${t}s`)=>e?`${e} ${e===1?t:n}`:``;return[t(e.docs,`doc`)+(e.docsChanged&&e.docsChanged<e.docs?` (${e.docsChanged} changed)`:``),t(e.dependencies,`dependency`,`dependencies`),t(e.contracts,`contract`),t(e.resources,`service`)].filter(Boolean).join(` · `)||`nothing to import yet`}function uE(e){let{scannedRef:t,headSha:n}=e.repo;if(!t)return`files on disk`;let r=t.replace(/^origin\//,``);return n?`${r} @ ${n.slice(0,7)}`:r}async function dE(e,t,{quiet:n=!1,source:r=`connector`}={}){await bS(e);let i=await cE(e),a=await new Ur(await Xb()).call(`sync_repo`,{p_project:t.projectId,p_snapshot:i,p_source:r});if(!n){Ox(`Synced ${wx(i.repo.name)} to ${wx(t.name)} ${Q(`from ${uE(i)}`)}`),kx(Q(lE(a)));for(let e of i.warnings)kx(Q(`! ${e}`))}return{snapshot:i,result:a}}async function fE(e){return gS(await ux(e))}const pE=26214400,mE=e=>`${(e/1024/1024).toFixed(1)} MB`;async function hE(e,t,{quiet:n=!1}={}){if(!t.folder)return;let{docs:r,unsupported:i}=await fE(e),a=e=>Buffer.byteLength(e.body),o=r.reduce((e,t)=>e+a(t),0);if(o>pE){let t=/* @__PURE__ */ new Map;for(let e of r){let n=e.path.includes(`/`)?`${e.path.split(`/`)[0]}/`:e.path;t.set(n,(t.get(n)??0)+a(e))}let n=[...t].sort((e,t)=>t[1]-e[1]).slice(0,3).map(([e,t])=>`${e} (${mE(t)})`).join(`, `);throw new Nx(`The documents outside the repos add up to ${mE(o)}, over the ${mE(pE)} a sync takes. The biggest: ${n}. List what Quirl should skip in ${x(v(e),`.quirlignore`)}, like .gitignore.`)}let s=new Ur(await Xb()),c={p_project:t.projectId,p_folder:t.folder},l=await s.call(`folder_doc_hashes`,c),u=r.filter(e=>l[e.path]!==e.contentHash),d=0;for(let t=0;t<u.length;){let n=[],r=0;for(;t<u.length;){let e=u[t];if(n.length&&r+a(e)>2097152)break;n.push(e),r+=a(e),t++}let i=await s.call(`sync_folder_docs`,{...c,p_folder_name:v(e),p_docs:n});d+=i.docsChanged}let f={...await s.call(`sync_folder_finish`,{...c,p_paths:r.map(e=>e.path)}),docsChanged:d};return n||(Ox(`Synced the documents in ${wx(`${v(e)}/`)} outside the repos`),kx(Q(`${f.docs} docs (${f.docsChanged} changed${f.archived?`, ${f.archived} removed`:``})`)),i.length&&kx(Q(`! ${i.length} PDF/Office files skipped: only markdown and text are read for now`))),f}async function gE(e={}){let t=await $b();if(!t)throw new Nx("This folder isn't linked to a Quirl project. Run `quirl init`.");let n=t.link.repos?.length?t.link.repos.map(e=>x(t.root,e)):[t.root],r=n.length+ +!!t.link.folder,i=0;for(let a of n)try{await dE(a,t.link,e)}catch(e){if(i++,r===1)throw e;let n=S(t.root,a)||`.`;console.error(`${Ex(`✗`)} ${n}: ${_x(e)}`)}if(t.link.folder)try{await hE(t.root,t.link,e)}catch(e){i++,console.error(`${Ex(`✗`)} documents in ${v(t.root)}/: ${_x(e)}`)}if(i)throw new Nx(`${i} of ${r} parts didn't sync.`)}async function _E(e){let t=Zb(),n=await xx(t),r=n.length?n:[t],i=r.length>1||r[0]!==t,a=e=>S(t,e)||v(t),o=h(),s=t.startsWith(o)?`~${t.slice(o.length)}`:t;if(console.log(`\n🌀 ${wx(`Quirl`)} ${Q(`·`)} connecting ${wx(s)}`),i&&(Ax(`📁`,`Found ${r.length} ${r.length===1?`repo`:`repos`}`),jx(Q(r.map(a).join(` · `))),!await Fx(` Import all of them into one project?`,!0)))throw new Nx("Nothing imported. Run `quirl init` inside the repo you want instead.");let c=!1;if(i&&!n.includes(t)){let{docs:e,unsupported:n}=await fE(t);if(e.length){Ax(`📄`,`Also found ${e.length} ${e.length===1?`document`:`documents`} outside the repos`);for(let t of e.slice(0,8))jx(Q(t.path));e.length>8&&jx(Q(`…and ${e.length-8} more`)),n.length&&jx(Q(`(${n.length} PDF/Office files can't be read yet and are skipped)`)),c=await Fx(` Import them too? Everyone on the project will be able to read them.`,!0)}}await qb()||await Xx({quiet:!0});let l=await yE((await new Ur(await Xb()).whoami()).projects,e.project??(await $b(t))?.link.project);if(l.role===`stakeholder`)throw new Nx(`You're a stakeholder on ${l.name}; ask an admin or dev to run \`quirl init\`.`);let u={project:l.slug,projectId:l.id,name:l.name};Ax(`🔗`,`Linked to ${wx(l.name)} ${Q(`· ${l.organization}`)}`);let d=e.claude!==!1,f=e.hooks??await Fx(` Sync with Quirl on every git push?`,!0);Ax(`📦`,`Importing docs, dependencies and schemas`);let p=[];for(let e of r){let t=Mx(`Reading ${a(e)}…`);try{await ex(e,u);let{snapshot:n,result:r}=await dE(e,u,{quiet:!0});d&&await vE(e,l.name),f&&await Yx(e),t.stop(),jx(`${Tx(`✓`)} ${wx(a(e))} ${Q(`(${uE(n)})`)} ${Q(lE(r))}`);for(let e of n.warnings)jx(Q(` ! ${e}`));p.push(e)}catch(n){t.stop(),jx(`${Ex(`✗`)} ${wx(a(e))} ${_x(n)}`)}}if(!p.length)throw new Nx(`No repo was imported.`);if(i){let e=p.map(a),n=await $b(t),r={...u,repos:e,folder:c?n?.root===t&&n.link.folder||T():void 0};if(await ex(t,r),c)try{let e=await hE(t,r,{quiet:!0});jx(`${Tx(`✓`)} ${wx(`documents outside the repos`)} ${Q(`${e?.docs??0} docs`)}`)}catch(e){jx(`${Ex(`✗`)} ${wx(`documents outside the repos`)} ${_x(e)}`)}d&&!p.includes(t)&&await vE(t,l.name,e)}let m=Bx().portable;d&&(Ax(`🤖`,`Connected Claude Code`),jx(Q(`.mcp.json the quirl tools`)),jx(Q(`.claude/settings.json the briefing, loaded as each session starts`)),jx(Q(`CLAUDE.md when to use Quirl`))),f&&Ax(`🪝`,`Quirl syncs on every ${wx(`git push`)}`);let g=r.length-p.length,_=`.quirl .mcp.json .claude/settings.json CLAUDE.md`;Ax(g?`⚠️ `:`🎉`,g?`Done, but ${g} of ${r.length} repos failed. Fix them and run ${wx(`quirl init`)} again.`:wx(`All set!`)),jx(d&&!m?Q(`Don't commit ${_} yet: they point at this checkout until the CLI is installed.`):`${Q(`1.`)} Commit what was added${i?` in each repo`:``}: ${Dx(`git add ${_}`)}`),jx(`${Q(d&&!m?`→`:`2.`)} Start Claude Code here and approve the ${wx(`quirl`)} server when it asks.`),i&&!p.includes(t)&&jx(Q("Run `quirl sync` here to sync every repo at once.")),console.log(``)}async function vE(e,t,n=[]){await Kx(e),await qx(e),await Jx(e,t,n)}async function yE(e,t){if(!e.length)throw new Nx(`You aren't on any Quirl project yet. Ask an admin to invite you.`);if(t){let n=e.find(e=>e.slug===t||e.id===t);if(!n)throw new Nx(`No project "${t}" among yours: ${e.map(e=>e.slug).join(`, `)}.`);return n}if(e.length===1)return e[0];Ax(`🗂️ `,`Which project is this part of?`);for(let[t,n]of e.entries())jx(`${Dx(String(t+1))} ${n.name} ${Q(`· ${n.organization} · ${n.role}`)}`);let n=e[Number(await Px(` Project [1-${e.length}]: `))-1];if(!n)throw new Nx("No project picked. Run `quirl init --project <slug>`.");return n}const bE=`${wx(`quirl`)} ${Q(Vb)}: connect a repo to Quirl
|
|
345
346
|
|
|
346
347
|
quirl init [--project <slug>] [--hooks|--no-hooks] [--no-claude]
|
|
347
348
|
Link this repo, import it, and connect Claude Code
|
|
@@ -351,4 +352,4 @@ n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2
|
|
|
351
352
|
quirl logout Forget this machine's key
|
|
352
353
|
quirl whoami Show who you're signed in as
|
|
353
354
|
quirl mcp Run the MCP server (used by Claude Code)
|
|
354
|
-
`;async function
|
|
355
|
+
`;async function xE(){let[e,...n]=process.argv.slice(2),{values:r}=t({args:n,allowNegative:!0,options:{project:{type:`string`},hooks:{type:`boolean`},claude:{type:`boolean`},quiet:{type:`boolean`},hook:{type:`boolean`},source:{type:`string`}}});switch(e){case`init`:return _E({project:r.project,hooks:r.hooks,claude:r.claude});case`sync`:return gE({quiet:r.quiet,source:r.source});case`context`:return bx({hook:r.hook});case`login`:await Xx();return;case`logout`:return await Yb(),Ox(`Signed out on this machine.`),kx(Q(`The key still exists until you revoke it under Organization > Access keys in Quirl (${Ub().appUrl}).`));case`whoami`:{if(!await qb())throw new Nx("Not signed in. Run `quirl login`.");let e=await new Ur(await Xb()).whoami();console.log(wx(e.email));for(let t of e.projects)kx(`${t.name} ${Q(`${t.slug} · ${t.organization} · ${t.role}`)}`);let t=await $b();t&&kx(Q(`This folder: ${t.link.name}`));return}case`mcp`:{let e=await $b();if(!e)throw new Nx("This folder isn't linked to a Quirl project. Run `quirl init`.");return Bb({...await Xb(),project:e.link.projectId,version:Vb})}case void 0:case`help`:case`--help`:case`-h`:process.stdout.write(bE);return;case`--version`:case`-v`:return console.log(Vb);default:throw new Nx(`Unknown command "${e}".\n\n${bE}`)}}xE().catch(e=>{let t=e instanceof Nx?e.message:_x(e);console.error(`${Ex(`✗`)} ${t}`),process.exit(1)});export{};
|