quirl-cli 0.1.7 → 0.1.8
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
|
@@ -196,10 +196,11 @@ if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid
|
|
|
196
196
|
- Docs written in Quirl (source 'quirl' in read_doc), such as PRDs and specs, are created and changed here: create_doc, edit_doc (one section at a time), archive_doc; doc_history shows who changed what. Docs synced from a repo are changed in the repo.
|
|
197
197
|
- 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.
|
|
198
198
|
- 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.
|
|
199
|
+
- A repo is named after its git remote. To give it another name, set "repoName" in its .quirl/project.json (in a folder of repos, { "path", "name" } in "repos") and run quirl sync; everything linked to it stays. remove_repo takes a repo out of the project, only when the person asks.
|
|
199
200
|
- If the project has no capabilities yet, offer to read the codebase and draft them with propose_capability.
|
|
200
|
-
- 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 Kb(await e(t))}catch(e){if(e instanceof Ur)return{...Kb(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()=>zb(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:B().describe(`Words to search for, e.g. 'refund approval limits'`),limit:V().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. source says where it lives: 'quirl' for docs written in Quirl (editable with edit_doc), otherwise the repo or folder it's synced from.`,inputSchema:{doc:B().describe(`Doc id, title or path, e.g. 'docs/adr/004-queues.md'`)}},a(({doc:e})=>t.call(`read_doc`,{...r,p_doc:e})));let o=[`product`,`guideline`,`architecture`,`decision`,`how_to`,`reference`];n.registerTool(`create_doc`,{title:`Write a new doc`,description:`Write a doc in Quirl itself: a PRD, spec or product note with no file behind it. Docs about code that tests or builds rely on belong in their repo, where sync picks them up. Use product for PRDs and specs. Never include secret values.`,inputSchema:{title:B(),body:B().describe(`Markdown. Headings (##, ###) split it into sections edit_doc can change one at a time.`),type:ym(o).optional().describe(`Defaults to reference`)}},a(({title:e,body:n,type:a})=>t.call(`create_doc`,{...r,p_title:e,p_body:n,p_type:a??`reference`,p_agent:i()}))),n.registerTool(`edit_doc`,{title:`Edit a doc written in Quirl`,description:`Change one section of a doc written in Quirl, or the whole doc, without rewriting the rest. A section is named by its heading, or by its path when a heading repeats ('Billing > Refunds'). replace swaps the section's text (keeping its heading, unless the new text starts with one); append adds to the end of it. Without a section, replace rewrites the doc and append adds to its end. Docs synced from a repo or folder are changed there instead. The edit fails if the doc changed since it was read, rather than overwriting that change.`,inputSchema:{doc:B().describe(`Doc id or title`),section:B().optional().describe(`Heading text or path, e.g. 'Scope' or 'Billing > Refunds'`),content:B().describe(`Markdown`),mode:ym([`replace`,`append`]).optional().describe(`Defaults to replace`),title:B().optional().describe(`A new title for the doc`),type:ym(o).optional()}},a(async({doc:e,section:n,content:a,mode:o,title:s,type:c})=>{let l=await t.call(`read_doc`,{...r,p_doc:e});if(!l.editable)throw new Ur(`"${l.title}" comes from ${l.source}. Change it there; sync brings it into Quirl.`);let u;try{u=Gb(l.body,n,a,o??`replace`)}catch(e){throw new Ur(e.message)}return{...await t.call(`update_doc`,{...r,p_doc:l.id,p_title:s??null,p_body:u,p_type:c??null,p_expected_hash:l.contentHash,p_agent:i()}),edited:n??`the whole doc`,sections:Hb(u)}})),n.registerTool(`doc_history`,{title:`A doc's history`,description:`Who changed a doc and when, newest first, with lines added and removed. Pass a version to see what it changed (a diff against the version before), or full to get that version's whole text, e.g. to bring back wording with edit_doc.`,inputSchema:{doc:B().describe(`Doc id or title`),version:V().int().optional(),full:em().optional().describe(`With version: its whole text instead of the diff`)}},a(async({doc:e,version:n,full:i})=>{let a=await t.call(`doc_history`,{...r,p_doc:e,p_limit:n?200:21}),o=a.versions,s=e=>o.find(t=>t.version===e-1);if(n){let e=o.find(e=>e.version===n);if(!e)throw new Ur(`"${a.title}" has no version ${n}; the latest is ${o[0]?.version??0}.`);if(i)return{version:n,title:e.title,body:e.body};let t=s(n);return{version:n,author:e.author??`unknown`,at:e.createdAt,...t&&t.title!==e.title?{renamed:`${t.title} → ${e.title}`}:{},diff:t?Ib(t.body,e.body)||`(no text changes)`:`(first version)`}}return{title:a.title,source:a.source,versions:o.slice(0,20).map(e=>{let t=s(e.version);return{version:e.version,author:e.author??`unknown`,at:e.createdAt,change:t?Pb(Nb(t.body,e.body)):`first version`}})}})),n.registerTool(`archive_doc`,{title:`Archive a doc written in Quirl`,description:`Remove a doc written in Quirl that's no longer true or was a mistake. It's archived and stays in history. Docs synced from a repo or folder are deleted there instead.`,inputSchema:{doc:B().describe(`Doc id or title`),reason:B().optional().describe(`Why, for history`)}},a(({doc:e,reason:n})=>t.call(`archive_doc`,{...r,p_doc:e,p_reason:n??null,p_agent:i()}))),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:B().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 s=(e,t,r,i)=>{n.registerTool(e,r,i),n.registerTool(t,{...r,description:`Old name for ${e}; use ${e}. ${r.description}`},i)};s(`list_tasks`,`list_cards`,{title:`List tasks`,description:`List tasks on the board. Defaults to your own tasks that aren't done.`,inputSchema:{onlyMine:em().optional(),includeDone:em().optional()}},a(({onlyMine:e,includeDone:n})=>t.call(`list_cards`,{...r,p_only_mine:e??!0,p_include_done:n??!1})));let c=`Markdown: short paragraphs, and lists for steps or parts, not one long block.`,l=`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).`,u=B().describe(`Task number, e.g. 'K-104' or '104'`),d=B().optional().describe(`Who does it: "me", a member's email or name (only people on the project), or "none"`);return s(`get_task`,`get_card`,{title:`Get a task`,description:`A task with its feature, docs, dependencies and evidence.`,inputSchema:{task:u.optional(),card:u.optional()}},a(({task:e,card:n})=>t.call(`get_card`,{...r,p_card:e??n}))),s(`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:B(),description:B().optional().describe(`What to do and why. ${c}`),type:ym([`feature_work`,`bug`,`chore`,`research`]).optional(),feature:B().optional().describe(`Feature name or id (e.g. F-4) this task belongs to`),tags:H(B()).optional().describe(l),assignee:d.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})),s(`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:u.optional(),card:u.optional(),assignee:d,status:ym([`backlog`,`todo`,`in_progress`,`review`,`done`]).optional(),feature:B().optional().describe(`Feature name or id (e.g. F-4) to put the task under; an empty string takes it off its feature`),title:B().optional(),description:B().optional().describe(`Replaces the description. ${c}`),tags:H(B()).optional().describe(`${l} Replaces the current tags.`),blocked:em().optional(),blockedReason:B().optional(),addBranch:U({repo:B(),name:B()}).optional(),addCommit:U({repo:B(),sha:B(),message:B().optional()}).optional(),addPullRequest:U({repo:B(),number:V().int(),url:B(),state:ym([`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:u,reason:B().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:B(),plain:B().describe(`What it means, for someone non-technical`),technical:B().describe(`What it means in the code`),kind:ym([`concept`,`tag`,`name`]).optional(),tagSet:B().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:B().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:B().describe(`The term or tag to retire`),replaceWith:B().optional().describe(`An approved term to say instead, if there is one`),reason:B().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:ym([`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:B().describe(`The flag's id, from the briefing or list_flags`),decision:ym([`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:B().describe(`The flag's id, from the briefing or list_flags`),note:B().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:B().describe(`Capability name or id (e.g. C-12)`),icon:ym(Lb)}},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:B().describe(`What the team calls it, e.g. "Postgres", "Stripe"`),type:ym(qb),provider:B().optional().describe(`Who runs it, e.g. "Google Cloud SQL", "Stripe". Resources are matched on this. Defaults to the name.`),description:B().optional().describe(`One plain sentence on what the project uses it for`),technical:B().optional().describe(`Technical notes for developers: setup, access, limits`),environment:B().optional().describe(`Defaults to "production"; e.g. "staging"`),repos:H(B()).optional().describe(`Repos that use it, by name`),capabilities:H(B()).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:{...Jb,name:B().optional(),type:ym(qb).optional(),provider:B().optional(),environment:B().optional().describe(`e.g. "production", "staging", "dev", "local"`),description:B().optional().describe(`One plain sentence on what the project uses it for`),technical:B().optional().describe(`Notes for developers`),repos:H(B()).optional().describe(`Replaces the repos that use it`),capabilities:H(B()).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:{...Jb,reason:B().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:em().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:B().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:B().describe(`Short name, e.g. 'Repeat appointments'`),description:B().describe(`What changes for the user, in plain words. Markdown: short paragraphs, and lists for parts`),capability:B().optional().describe(`Capability name or id (e.g. C-12) it changes. Leave it out when the feature creates a new capability`),tags:H(B()).optional().describe(`Kind of change: e.g. New, Improvement, Visual, Fix, Performance, Security, Removal, Internal (the feature_change set in quirl_context)`),reason:B().optional().describe(`Why it's worth doing`),icon:ym(Lb).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:B().describe(`Feature name or id (e.g. F-4)`),icon:ym(Lb)}},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:B().describe(`Feature name or id (e.g. F-4)`),name:B().optional(),description:B().optional().describe(`What changes for the user, in plain words. Markdown: short paragraphs, and lists for parts`),capability:B().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:B().describe(`Feature name or id (e.g. F-4)`),reason:B().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:B().describe(`Feature name or id (e.g. F-4)`),tags:H(B()).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:em().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:B().describe(`Short name, e.g. 'Online booking'`),whatItDoes:B().describe(`One or two plain sentences, no jargon`),technical:B().optional().describe(`Where it lives in the code and how it works. Markdown: short paragraphs, and lists for parts, not one long block`),features:H(B()).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:B().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:B().describe(`Capability name or id (e.g. C-12)`),reason:B().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:B().describe(`Capability name or id (e.g. C-12)`),field:ym([`name`,`what_it_does`,`technical_description`]),after:B().describe(`The new name, or the corrected text. Markdown: short paragraphs, and lists for parts, not one long block`),reason:B().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:B().describe(`Capability name or id (e.g. C-12)`),howItWorks:H(B()).optional().describe(`3 to 5 plain-language steps, as the user experiences it`),reliesOn:H(U({capability:B().describe(`Capability name or id (e.g. C-12)`),label:B().describe(`How it relies on it, read before the name, e.g. 'extends'`)})).optional(),parent:B().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:H(B()).optional().describe(`Repo names`),resources:H(B()).optional().describe(`Resource names it runs on`),terms:H(B()).optional().describe(`Glossary terms`),docs:H(B()).optional().describe(`Doc titles, or <repo>/<path> (e.g. quirl/AGENTS.md) when titles repeat`),tags:H(B()).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:B().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 Xb(e){await Yb(e).connect(new Mb)}const Zb=`0.1.7`,Qb=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 $b(){return{apiUrl:process.env.QUIRL_API_URL??Qb.apiUrl,publishableKey:process.env.QUIRL_PUBLISHABLE_KEY??Qb.publishableKey,appUrl:process.env.QUIRL_APP_URL??Qb.appUrl}}const ex=()=>x(process.env.XDG_CONFIG_HOME??x(h(),`.config`),`quirl`),tx=()=>x(ex(),`credentials.json`);async function nx(){try{return JSON.parse(await u(tx(),`utf8`))}catch{return{}}}async function rx(){return process.env.QUIRL_KEY?{apiUrl:$b().apiUrl,key:process.env.QUIRL_KEY,email:``}:(await nx())[$b().apiUrl]??null}async function ix(e){let t=await nx();t[e.apiUrl]=e,await l(ex(),{recursive:!0,mode:448}),await m(tx(),`${JSON.stringify(t,null,` `)}\n`,{mode:384}),await s(tx(),384)}async function ax(){let e=await nx();delete e[$b().apiUrl],Object.keys(e).length?await m(tx(),`${JSON.stringify(e,null,` `)}\n`,{mode:384}):await f(tx(),{force:!0})}async function ox(){let e=$b();return{apiUrl:e.apiUrl,publishableKey:e.publishableKey,key:(await rx())?.key??``}}function sx(e=process.cwd()){try{return a(`git`,[`rev-parse`,`--show-toplevel`],{cwd:e,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim()}catch{return e}}const cx=e=>x(e,`.quirl`,`project.json`);async function lx(e=process.cwd()){let t=e;for(;;)try{return{root:t,link:JSON.parse(await u(cx(t),`utf8`))}}catch{let e=y(t);if(e===t)return null;t=e}}async function ux(e,t){await l(x(e,`.quirl`),{recursive:!0}),await m(cx(e),`${JSON.stringify(t,null,` `)}\n`)}function dx(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 fx(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=dx(e).source.slice(1,-1);t.push({regex:RegExp(a?`^${o}$`:`^(?:.*/)?${o}$`),negate:r,dirOnly:i})}return t}function px(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 mx(e){try{return fx(await u(_.join(e,`.quirlignore`),`utf8`))}catch{return[]}}function hx(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 gx=n(i),_x=/* @__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`]),vx=1048576,yx=2e5;async function bx(e){let t=[],n=await mx(e),r=(await Sx(e,t)).filter(e=>!px(n,e.path)),i=await hx(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=vx){if(e.size>n)return t.push(`${e.path}: skipped, ${kx(e.size)} is over the ${kx(n)} limit`),null;try{return await u(e.absolutePath,`utf8`)}catch(n){return t.push(`${e.path}: could not be read (${Dx(n)})`),null}}}}async function xx(e,t){let n=[],r=await mx(e),{stdout:i}=await gx(`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=>_x.has(e))&&!px(r,l)){if(a.length>=yx){n.push(`Stopped after ${yx} files; the rest of the tree was not scanned`);break}a.push({path:l,absolutePath:s,size:Number(c)||0})}}Cx(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=vx){if(t.size>r)return n.push(`${t.path}: skipped, ${kx(t.size)} is over the ${kx(r)} limit`),null;try{let{stdout:n}=await gx(`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 (${Dx(e)})`),null}}}}async function Sx(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 (${Dx(e)})`);continue}for(let o of a){let a=i?`${i}/${o.name}`:o.name;if(o.isSymbolicLink())continue;if(o.isDirectory()){!_x.has(o.name)&&!C(_.join(e,a,`.git`))&&r.push(a);continue}if(!o.isFile())continue;if(n.length>=yx)return t.push(`Stopped after ${yx} files; the rest of the tree was not scanned`),Cx(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 (${Dx(e)})`)}}}return Cx(n)}function Cx(e){return e.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path))}function wx(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function Tx(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function Ex(e,t){return e?`${e}/${t}`:t}function Dx(e){return Kr(e instanceof Error?e.message:String(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ox(e){return typeof e==`string`?e:void 0}function kx(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:`${Math.ceil(e/1024)} KB`}async function Ax({hook:e=!1}={}){let t=await lx();if(!t){if(e)return;throw Error("This folder isn't linked to a Quirl project. Run `quirl init`.")}try{let n=await new Wr(await ox()).context(t.link.projectId);process.stdout.write(`${zb(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 (${Dx(n)}). The quirl MCP tools may still work.\n`)}}const jx=process.stdout.isTTY&&!process.env.NO_COLOR,Mx=e=>t=>jx?`\x1b[${e}m${t}\x1b[0m`:t,Nx=Mx(1),Q=Mx(2),Px=Mx(32),Fx=Mx(31),Ix=Mx(36),Lx=e=>console.log(`${Px(`✓`)} ${e}`),Rx=e=>console.log(` ${e}`),zx=(e,t)=>console.log(`\n${e} ${t}`),Bx=e=>console.log(` ${e}`);function Vx(e){if(!jx)return Bx(Q(e)),{stop:()=>{}};let t=0,n=setInterval(()=>{process.stdout.write(`\r ${Ix(`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`[t++%10]??``)} ${Q(e)}`)},80);return{stop:()=>{clearInterval(n),process.stdout.write(`\r\x1B[2K`)}}}var Hx=class extends Error{};async function Ux(e,t=``){if(!process.stdin.isTTY)return t;let n=w({input:process.stdin,output:process.stdout});try{return(await n.question(e)).trim()||t}finally{n.close()}}async function Wx(e,t){let n=await Ux(`${e} ${Q(t?`[Y/n]`:`[y/N]`)} `,t?`y`:`n`);return/^y/i.test(n)}function Gx(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 Kx=`.quirl-export.json`,qx=e=>e.toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,80)||`untitled`;function Jx(e){return`---\n${[[`title`,e.title],[`type`,e.type],[`status`,e.status],[`source`,e.source],[`alwaysLoad`,e.alwaysLoad],[`id`,e.id],[`created`,e.createdAt],[`updated`,e.updatedAt]].map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(`
|
|
201
|
-
`)}\n---\n\n`}async function
|
|
202
|
-
`)),o.push(t)}let c=0;try{let e=JSON.parse(await u(_.join(i,
|
|
201
|
+
- 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 Kb(await e(t))}catch(e){if(e instanceof Ur)return{...Kb(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()=>zb(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:B().describe(`Words to search for, e.g. 'refund approval limits'`),limit:V().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. source says where it lives: 'quirl' for docs written in Quirl (editable with edit_doc), otherwise the repo or folder it's synced from.`,inputSchema:{doc:B().describe(`Doc id, title or path, e.g. 'docs/adr/004-queues.md'`)}},a(({doc:e})=>t.call(`read_doc`,{...r,p_doc:e})));let o=[`product`,`guideline`,`architecture`,`decision`,`how_to`,`reference`];n.registerTool(`create_doc`,{title:`Write a new doc`,description:`Write a doc in Quirl itself: a PRD, spec or product note with no file behind it. Docs about code that tests or builds rely on belong in their repo, where sync picks them up. Use product for PRDs and specs. Never include secret values.`,inputSchema:{title:B(),body:B().describe(`Markdown. Headings (##, ###) split it into sections edit_doc can change one at a time.`),type:ym(o).optional().describe(`Defaults to reference`)}},a(({title:e,body:n,type:a})=>t.call(`create_doc`,{...r,p_title:e,p_body:n,p_type:a??`reference`,p_agent:i()}))),n.registerTool(`edit_doc`,{title:`Edit a doc written in Quirl`,description:`Change one section of a doc written in Quirl, or the whole doc, without rewriting the rest. A section is named by its heading, or by its path when a heading repeats ('Billing > Refunds'). replace swaps the section's text (keeping its heading, unless the new text starts with one); append adds to the end of it. Without a section, replace rewrites the doc and append adds to its end. Docs synced from a repo or folder are changed there instead. The edit fails if the doc changed since it was read, rather than overwriting that change.`,inputSchema:{doc:B().describe(`Doc id or title`),section:B().optional().describe(`Heading text or path, e.g. 'Scope' or 'Billing > Refunds'`),content:B().describe(`Markdown`),mode:ym([`replace`,`append`]).optional().describe(`Defaults to replace`),title:B().optional().describe(`A new title for the doc`),type:ym(o).optional()}},a(async({doc:e,section:n,content:a,mode:o,title:s,type:c})=>{let l=await t.call(`read_doc`,{...r,p_doc:e});if(!l.editable)throw new Ur(`"${l.title}" comes from ${l.source}. Change it there; sync brings it into Quirl.`);let u;try{u=Gb(l.body,n,a,o??`replace`)}catch(e){throw new Ur(e.message)}return{...await t.call(`update_doc`,{...r,p_doc:l.id,p_title:s??null,p_body:u,p_type:c??null,p_expected_hash:l.contentHash,p_agent:i()}),edited:n??`the whole doc`,sections:Hb(u)}})),n.registerTool(`doc_history`,{title:`A doc's history`,description:`Who changed a doc and when, newest first, with lines added and removed. Pass a version to see what it changed (a diff against the version before), or full to get that version's whole text, e.g. to bring back wording with edit_doc.`,inputSchema:{doc:B().describe(`Doc id or title`),version:V().int().optional(),full:em().optional().describe(`With version: its whole text instead of the diff`)}},a(async({doc:e,version:n,full:i})=>{let a=await t.call(`doc_history`,{...r,p_doc:e,p_limit:n?200:21}),o=a.versions,s=e=>o.find(t=>t.version===e-1);if(n){let e=o.find(e=>e.version===n);if(!e)throw new Ur(`"${a.title}" has no version ${n}; the latest is ${o[0]?.version??0}.`);if(i)return{version:n,title:e.title,body:e.body};let t=s(n);return{version:n,author:e.author??`unknown`,at:e.createdAt,...t&&t.title!==e.title?{renamed:`${t.title} → ${e.title}`}:{},diff:t?Ib(t.body,e.body)||`(no text changes)`:`(first version)`}}return{title:a.title,source:a.source,versions:o.slice(0,20).map(e=>{let t=s(e.version);return{version:e.version,author:e.author??`unknown`,at:e.createdAt,change:t?Pb(Nb(t.body,e.body)):`first version`}})}})),n.registerTool(`archive_doc`,{title:`Archive a doc written in Quirl`,description:`Remove a doc written in Quirl that's no longer true or was a mistake. It's archived and stays in history. Docs synced from a repo or folder are deleted there instead.`,inputSchema:{doc:B().describe(`Doc id or title`),reason:B().optional().describe(`Why, for history`)}},a(({doc:e,reason:n})=>t.call(`archive_doc`,{...r,p_doc:e,p_reason:n??null,p_agent:i()}))),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:B().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 s=(e,t,r,i)=>{n.registerTool(e,r,i),n.registerTool(t,{...r,description:`Old name for ${e}; use ${e}. ${r.description}`},i)};s(`list_tasks`,`list_cards`,{title:`List tasks`,description:`List tasks on the board. Defaults to your own tasks that aren't done.`,inputSchema:{onlyMine:em().optional(),includeDone:em().optional()}},a(({onlyMine:e,includeDone:n})=>t.call(`list_cards`,{...r,p_only_mine:e??!0,p_include_done:n??!1})));let c=`Markdown: short paragraphs, and lists for steps or parts, not one long block.`,l=`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).`,u=B().describe(`Task number, e.g. 'K-104' or '104'`),d=B().optional().describe(`Who does it: "me", a member's email or name (only people on the project), or "none"`);return s(`get_task`,`get_card`,{title:`Get a task`,description:`A task with its feature, docs, dependencies and evidence.`,inputSchema:{task:u.optional(),card:u.optional()}},a(({task:e,card:n})=>t.call(`get_card`,{...r,p_card:e??n}))),s(`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:B(),description:B().optional().describe(`What to do and why. ${c}`),type:ym([`feature_work`,`bug`,`chore`,`research`]).optional(),feature:B().optional().describe(`Feature name or id (e.g. F-4) this task belongs to`),tags:H(B()).optional().describe(l),assignee:d.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})),s(`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:u.optional(),card:u.optional(),assignee:d,status:ym([`backlog`,`todo`,`in_progress`,`review`,`done`]).optional(),feature:B().optional().describe(`Feature name or id (e.g. F-4) to put the task under; an empty string takes it off its feature`),title:B().optional(),description:B().optional().describe(`Replaces the description. ${c}`),tags:H(B()).optional().describe(`${l} Replaces the current tags.`),blocked:em().optional(),blockedReason:B().optional(),addBranch:U({repo:B(),name:B()}).optional(),addCommit:U({repo:B(),sha:B(),message:B().optional()}).optional(),addPullRequest:U({repo:B(),number:V().int(),url:B(),state:ym([`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:u,reason:B().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:B(),plain:B().describe(`What it means, for someone non-technical`),technical:B().describe(`What it means in the code`),kind:ym([`concept`,`tag`,`name`]).optional(),tagSet:B().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:B().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:B().describe(`The term or tag to retire`),replaceWith:B().optional().describe(`An approved term to say instead, if there is one`),reason:B().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:ym([`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:B().describe(`The flag's id, from the briefing or list_flags`),decision:ym([`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:B().describe(`The flag's id, from the briefing or list_flags`),note:B().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:B().describe(`Capability name or id (e.g. C-12)`),icon:ym(Lb)}},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:B().describe(`What the team calls it, e.g. "Postgres", "Stripe"`),type:ym(qb),provider:B().optional().describe(`Who runs it, e.g. "Google Cloud SQL", "Stripe". Resources are matched on this. Defaults to the name.`),description:B().optional().describe(`One plain sentence on what the project uses it for`),technical:B().optional().describe(`Technical notes for developers: setup, access, limits`),environment:B().optional().describe(`Defaults to "production"; e.g. "staging"`),repos:H(B()).optional().describe(`Repos that use it, by name`),capabilities:H(B()).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:{...Jb,name:B().optional(),type:ym(qb).optional(),provider:B().optional(),environment:B().optional().describe(`e.g. "production", "staging", "dev", "local"`),description:B().optional().describe(`One plain sentence on what the project uses it for`),technical:B().optional().describe(`Notes for developers`),repos:H(B()).optional().describe(`Replaces the repos that use it`),capabilities:H(B()).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:{...Jb,reason:B().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(`remove_repo`,{title:`Remove a repo`,description:"Remove a repo from the project, for admins: one that's retired, or was imported by mistake. Its dependencies, endpoints, tables and synced docs are archived with it, and it's unlinked from capabilities, tasks and resources. Sync skips it from then on; running `quirl init` in it adds it back. Only on the person's request: confirm with them first. To rename a repo instead, set its name in .quirl/project.json and sync.",inputSchema:{repo:B().describe(`The repo's name, URL or id`),reason:B().optional().describe(`Why it's removed, for history`)}},a(e=>t.call(`remove_repo`,{...r,p_repo:e.repo,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:em().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:B().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:B().describe(`Short name, e.g. 'Repeat appointments'`),description:B().describe(`What changes for the user, in plain words. Markdown: short paragraphs, and lists for parts`),capability:B().optional().describe(`Capability name or id (e.g. C-12) it changes. Leave it out when the feature creates a new capability`),tags:H(B()).optional().describe(`Kind of change: e.g. New, Improvement, Visual, Fix, Performance, Security, Removal, Internal (the feature_change set in quirl_context)`),reason:B().optional().describe(`Why it's worth doing`),icon:ym(Lb).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:B().describe(`Feature name or id (e.g. F-4)`),icon:ym(Lb)}},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:B().describe(`Feature name or id (e.g. F-4)`),name:B().optional(),description:B().optional().describe(`What changes for the user, in plain words. Markdown: short paragraphs, and lists for parts`),capability:B().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:B().describe(`Feature name or id (e.g. F-4)`),reason:B().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:B().describe(`Feature name or id (e.g. F-4)`),tags:H(B()).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:em().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:B().describe(`Short name, e.g. 'Online booking'`),whatItDoes:B().describe(`One or two plain sentences, no jargon`),technical:B().optional().describe(`Where it lives in the code and how it works. Markdown: short paragraphs, and lists for parts, not one long block`),features:H(B()).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:B().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:B().describe(`Capability name or id (e.g. C-12)`),reason:B().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:B().describe(`Capability name or id (e.g. C-12)`),field:ym([`name`,`what_it_does`,`technical_description`]),after:B().describe(`The new name, or the corrected text. Markdown: short paragraphs, and lists for parts, not one long block`),reason:B().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:B().describe(`Capability name or id (e.g. C-12)`),howItWorks:H(B()).optional().describe(`3 to 5 plain-language steps, as the user experiences it`),reliesOn:H(U({capability:B().describe(`Capability name or id (e.g. C-12)`),label:B().describe(`How it relies on it, read before the name, e.g. 'extends'`)})).optional(),parent:B().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:H(B()).optional().describe(`Repo names`),resources:H(B()).optional().describe(`Resource names it runs on`),terms:H(B()).optional().describe(`Glossary terms`),docs:H(B()).optional().describe(`Doc titles, or <repo>/<path> (e.g. quirl/AGENTS.md) when titles repeat`),tags:H(B()).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:B().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 Xb(e){await Yb(e).connect(new Mb)}const Zb=`0.1.8`,Qb=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 $b(){return{apiUrl:process.env.QUIRL_API_URL??Qb.apiUrl,publishableKey:process.env.QUIRL_PUBLISHABLE_KEY??Qb.publishableKey,appUrl:process.env.QUIRL_APP_URL??Qb.appUrl}}const ex=()=>x(process.env.XDG_CONFIG_HOME??x(h(),`.config`),`quirl`),tx=()=>x(ex(),`credentials.json`);async function nx(){try{return JSON.parse(await u(tx(),`utf8`))}catch{return{}}}async function rx(){return process.env.QUIRL_KEY?{apiUrl:$b().apiUrl,key:process.env.QUIRL_KEY,email:``}:(await nx())[$b().apiUrl]??null}async function ix(e){let t=await nx();t[e.apiUrl]=e,await l(ex(),{recursive:!0,mode:448}),await m(tx(),`${JSON.stringify(t,null,` `)}\n`,{mode:384}),await s(tx(),384)}async function ax(){let e=await nx();delete e[$b().apiUrl],Object.keys(e).length?await m(tx(),`${JSON.stringify(e,null,` `)}\n`,{mode:384}):await f(tx(),{force:!0})}async function ox(){let e=$b();return{apiUrl:e.apiUrl,publishableKey:e.publishableKey,key:(await rx())?.key??``}}function sx(e){return(e.repos??[]).map(e=>typeof e==`string`?{path:e}:e)}function cx(e=process.cwd()){try{return a(`git`,[`rev-parse`,`--show-toplevel`],{cwd:e,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim()}catch{return e}}const lx=e=>x(e,`.quirl`,`project.json`);async function ux(e=process.cwd()){let t=e;for(;;)try{return{root:t,link:JSON.parse(await u(lx(t),`utf8`))}}catch{let e=y(t);if(e===t)return null;t=e}}async function dx(e,t){await l(x(e,`.quirl`),{recursive:!0}),await m(lx(e),`${JSON.stringify(t,null,` `)}\n`)}function fx(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 px(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=fx(e).source.slice(1,-1);t.push({regex:RegExp(a?`^${o}$`:`^(?:.*/)?${o}$`),negate:r,dirOnly:i})}return t}function mx(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 hx(e){try{return px(await u(_.join(e,`.quirlignore`),`utf8`))}catch{return[]}}function gx(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 _x=n(i),vx=/* @__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`]),yx=1048576,bx=2e5;async function xx(e){let t=[],n=await hx(e),r=(await Cx(e,t)).filter(e=>!mx(n,e.path)),i=await gx(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=yx){if(e.size>n)return t.push(`${e.path}: skipped, ${Ax(e.size)} is over the ${Ax(n)} limit`),null;try{return await u(e.absolutePath,`utf8`)}catch(n){return t.push(`${e.path}: could not be read (${Ox(n)})`),null}}}}async function Sx(e,t){let n=[],r=await hx(e),{stdout:i}=await _x(`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=>vx.has(e))&&!mx(r,l)){if(a.length>=bx){n.push(`Stopped after ${bx} files; the rest of the tree was not scanned`);break}a.push({path:l,absolutePath:s,size:Number(c)||0})}}wx(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=yx){if(t.size>r)return n.push(`${t.path}: skipped, ${Ax(t.size)} is over the ${Ax(r)} limit`),null;try{let{stdout:n}=await _x(`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 (${Ox(e)})`),null}}}}async function Cx(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 (${Ox(e)})`);continue}for(let o of a){let a=i?`${i}/${o.name}`:o.name;if(o.isSymbolicLink())continue;if(o.isDirectory()){!vx.has(o.name)&&!C(_.join(e,a,`.git`))&&r.push(a);continue}if(!o.isFile())continue;if(n.length>=bx)return t.push(`Stopped after ${bx} files; the rest of the tree was not scanned`),wx(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 (${Ox(e)})`)}}}return wx(n)}function wx(e){return e.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path))}function Tx(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function Ex(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function Dx(e,t){return e?`${e}/${t}`:t}function Ox(e){return Kr(e instanceof Error?e.message:String(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kx(e){return typeof e==`string`?e:void 0}function Ax(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:`${Math.ceil(e/1024)} KB`}async function jx({hook:e=!1}={}){let t=await ux();if(!t){if(e)return;throw Error("This folder isn't linked to a Quirl project. Run `quirl init`.")}try{let n=await new Wr(await ox()).context(t.link.projectId);process.stdout.write(`${zb(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 (${Ox(n)}). The quirl MCP tools may still work.\n`)}}const Mx=process.stdout.isTTY&&!process.env.NO_COLOR,Nx=e=>t=>Mx?`\x1b[${e}m${t}\x1b[0m`:t,Px=Nx(1),Q=Nx(2),Fx=Nx(32),Ix=Nx(31),Lx=Nx(36),Rx=e=>console.log(`${Fx(`✓`)} ${e}`),zx=e=>console.log(` ${e}`),Bx=(e,t)=>console.log(`\n${e} ${t}`),Vx=e=>console.log(` ${e}`);function Hx(e){if(!Mx)return Vx(Q(e)),{stop:()=>{}};let t=0,n=setInterval(()=>{process.stdout.write(`\r ${Lx(`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`[t++%10]??``)} ${Q(e)}`)},80);return{stop:()=>{clearInterval(n),process.stdout.write(`\r\x1B[2K`)}}}var Ux=class extends Error{};async function Wx(e,t=``){if(!process.stdin.isTTY)return t;let n=w({input:process.stdin,output:process.stdout});try{return(await n.question(e)).trim()||t}finally{n.close()}}async function Gx(e,t){let n=await Wx(`${e} ${Q(t?`[Y/n]`:`[y/N]`)} `,t?`y`:`n`);return/^y/i.test(n)}function Kx(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 qx=`.quirl-export.json`,Jx=e=>e.toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,80)||`untitled`;function Yx(e){return`---\n${[[`title`,e.title],[`type`,e.type],[`status`,e.status],[`source`,e.source],[`alwaysLoad`,e.alwaysLoad],[`id`,e.id],[`created`,e.createdAt],[`updated`,e.updatedAt]].map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(`
|
|
202
|
+
`)}\n---\n\n`}async function Xx({dir:e=`quirl-docs`,all:t=!1}){let n=await ux();if(!n)throw new Ux("This folder isn't linked to a Quirl project. Run `quirl init`.");let r=new Wr(await ox()),i=_.resolve(e);Bx(`📤`,`Exporting ${t?`all`:`Quirl-written`} docs from ${Px(n.link.name)}`);let a=[];for(let e=0;;e+=100){let i=await r.call(`export_docs`,{p_project:n.link.projectId,p_only_quirl:!t,p_offset:e,p_limit:100});if(a.push(...i),i.length<100)break}let o=[],s=/* @__PURE__ */ new Set;await l(i,{recursive:!0});for(let e of a){let t=`${e.type}/${Jx(e.title)}.md`;for(let n=2;s.has(t);n++)t=`${e.type}/${Jx(e.title)}-${n}.md`;s.add(t),await l(_.join(i,e.type),{recursive:!0}),await m(_.join(i,t),Yx(e)+e.body.replace(/\n*$/,`
|
|
203
|
+
`)),o.push(t)}let c=0;try{let e=JSON.parse(await u(_.join(i,qx),`utf8`));for(let t of e.files??[])s.has(t)||t.includes(`..`)||(await f(_.join(i,t),{force:!0}),c++)}catch{}await m(_.join(i,qx),`${JSON.stringify({project:n.link.project,exportedAt:(/* @__PURE__ */ new Date()).toISOString(),all:t,files:o},null,` `)}\n`),Vx(`${Fx(`✓`)} ${a.length} ${a.length===1?`doc`:`docs`} written to ${Lx(_.relative(process.cwd(),i)||`.`)}${c?Q(` · ${c} removed`):``}`),t||Vx(Q(`Docs synced from repos are left out; add --all to include them.`)),console.log(``)}async function Zx(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(`.`)||vx.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 Qx=`<!-- quirl:start -->`,$x=`<!-- quirl:end -->`,eS=`# quirl: keep the project in sync`;function tS(){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 nS=[`QUIRL_SERVER`,`QUIRL_API_URL`,`QUIRL_PUBLISHABLE_KEY`,`QUIRL_APP_URL`];function rS(){return Object.fromEntries(nS.flatMap(e=>process.env[e]?[[e,process.env[e]]]:[]))}function iS(){return`${Object.entries(rS()).map(([e,t])=>`${e}="${t}" `).join(``)}${tS().shell}`}async function aS(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 oS=async(e,t)=>{await l(y(e),{recursive:!0}),await m(e,`${JSON.stringify(t,null,2)}\n`)};async function sS(e){let t=x(e,`.mcp.json`),n=await aS(t),r=tS();n.mcpServers={...n.mcpServers,quirl:{command:r.command,args:[...r.args,`mcp`],...Object.keys(rS()).length?{env:rS()}:{}}},await oS(t,n)}async function cS(e){let t=x(e,`.claude`,`settings.json`),n=await aS(t),r=n.hooks??{},i=`${iS()} 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 oS(t,n)}async function lS(e,t,n=[]){let r=x(e,`CLAUDE.md`),i=``;try{i=await u(r,`utf8`)}catch{}let a=`${Qx}
|
|
203
204
|
## Quirl
|
|
204
205
|
|
|
205
206
|
${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:
|
|
@@ -212,24 +213,24 @@ ${n.length?`This folder holds the repos of the Quirl project **${t}** (${n.join(
|
|
|
212
213
|
- 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).
|
|
213
214
|
- 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\`.
|
|
214
215
|
- After changing docs, dependencies or schemas, run \`quirl sync\` (the pre-push hook does it on push).
|
|
215
|
-
${
|
|
216
|
+
${$x}`,o=RegExp(`${Qx}[\\s\\S]*?${$x}`);i=o.test(i)?i.replace(o,a):`${i.trimEnd()}${i.trim()?`
|
|
216
217
|
|
|
217
|
-
`:``}${a}\n`,await m(r,i)}async function
|
|
218
|
+
`:``}${a}\n`,await m(r,i)}async function uS(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=`${eS}\n${iS()} sync --quiet --source=git_hook || echo "quirl: sync skipped"\n`,o=r.indexOf(eS);if(o>=0){let e=r.indexOf(`
|
|
218
219
|
`,r.indexOf(`
|
|
219
|
-
`,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
|
|
220
|
-
`)),r=!t.docs&&
|
|
221
|
-
`)):null,a=e=>{let t=
|
|
222
|
-
`),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?CS(s):null}function CS(e){return e.replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[`*_]/g,``).trim()}function wS(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 TS(e,t){if(t===`guideline`)return!0;let n=wx(e).toLowerCase();return/architecture|conventions?|guidelines?|contributing|style-?guide/.test(n)||t===`architecture`&&/overview/.test(n)}const ES=/* @__PURE__ */ new Set([`claude.md`,`agents.md`,`.cursorrules`]);async function DS(e){let t=[];for(let n of e.files){if(!(ES.has(wx(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 OS=/\.(md|mdx|markdown|txt)$/i,kS=/\.(pdf|docx?|odt|rtf|pages|pptx?|key|xlsx?|numbers)$/i;async function AS(e){let t=[],n=[];for(let r of e.files){if(r.path.split(`/`).some(e=>e.startsWith(`.`)))continue;let i=wx(r.path);if(kS.test(i)){n.push(r.path);continue}if(!OS.test(i)||/^(claude|agents)\.md$/i.test(i))continue;let a=await e.readText(r);if(!a?.trim())continue;let o=i.replace(OS,``),s=(hS.test(i)?SS(a):null)??o,c=wS(r.path,s);t.push({path:r.path,title:s,type:c,body:a,alwaysLoadCandidate:!1,contentHash:T(`sha256`).update(a).digest(`hex`)})}return{docs:t,unsupported:n}}const jS=n(i);async function MS(e,t){try{let{stdout:n}=await jS(`git`,t,{cwd:e,timeout:1e4}),r=n.trim();return r===``?null:r}catch{return null}}async function NS(e){let t=await MS(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 MS(e,[`rev-parse`,`--verify`,`--quiet`,`${t}^{commit}`]))return{ref:t,branch:t.replace(/^origin\//,``)};return null}async function PS(e){try{return await jS(`git`,[`fetch`,`--quiet`,`--no-tags`,`origin`],{cwd:e,timeout:6e4}),await jS(`git`,[`remote`,`set-head`,`origin`,`--auto`],{cwd:e,timeout:3e4}).catch(()=>{}),!0}catch{return!1}}async function FS(e,t,n){let r=_.basename(e);if(await MS(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([MS(e,[`remote`,`get-url`,`origin`]),MS(e,[`rev-parse`,`--verify`,`--quiet`,`${i}^{commit}`]),MS(e,[`log`,`-1`,`--format=%cI`,i]),MS(e,[`symbolic-ref`,`--quiet`,`refs/remotes/origin/HEAD`]),MS(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?IS(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 IS(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 LS=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&&RS(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 RS(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 zS(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 BS(e){return JSON.parse(e)}function VS(e,t,n){let r=BS(e);if(!Z(r))throw Error(`not a JSON object`);let i=/* @__PURE__ */ new Set;if(n!==null){let e=BS(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 LS(`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 HS(e,t,n){let r=new LS(`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__ */ E((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})),US=/* @__PURE__ */ E((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})),WS=/* @__PURE__ */ E((e=>{var t=$(),n=US();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(`
|
|
223
|
-
`)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),
|
|
220
|
+
`,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 dS({quiet:e=!1}={}){let t=$b(),n=await rx();Bx(`🔑`,Px(`Sign in to Quirl`)),n&&!e&&Vx(Q(`Already signed in as ${n.email}. Signing in again replaces this machine's key.`));let r=Gr(t.apiUrl,t.publishableKey),i=await r.start(`quirl CLI on ${g()}`),a=`${t.appUrl}/cli/authorize?code=${i.user_code}`;Vx(`Approve this computer in your browser:`),Vx(Lx(a)),Vx(`Check the code matches ${Px(fS(i.user_code))}`),Kx(a);let o=Hx(`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 Wr({...t,key:e.key}).whoami();return o.stop(),await ix({apiUrl:t.apiUrl,key:e.key,email:n.email}),Vx(`${Fx(`✓`)} Signed in as ${Px(n.email)}`),n}if(e.status!==`pending`)throw o.stop(),new Ux(`Sign-in ${e.status}. Run \`quirl login\` again.`)}throw o.stop(),new Ux("Sign-in timed out. Run `quirl login` again.")}const fS=e=>`${e.slice(0,4)}-${e.slice(4)}`,pS=/* @__PURE__ */ new Set([`docs`,`doc`,`adr`,`adrs`,`architecture`]),mS=/* @__PURE__ */ new Set([`readme.md`,`contributing.md`,`architecture.md`]),hS=/^(changelog|changes|history|license|licence|copying|notice|code_of_conduct|claude|agents)(\.|$)/i,gS=/\.(md|mdx|markdown)$/i,_S=/* @__PURE__ */ new Set([`tasks`,`todo`,`todos`,`issues`,`tickets`,`inbox`,`archive`,`archived`]),vS=/^(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 yS(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 bS(e){if(e.files.some(e=>vS.test(Tx(e.path))))return!1;let t=e.files.filter(e=>gS.test(e.path)).length;return t>0&&t*2>=e.files.length}async function xS(e,t={}){let n=px((t.docs??[]).join(`
|
|
221
|
+
`)),r=!t.docs&&bS(e),i=t.alwaysLoad?px(t.alwaysLoad.join(`
|
|
222
|
+
`)):null,a=e=>{let t=Tx(e);if(!gS.test(t)||hS.test(t))return!1;let i=e.toLowerCase().split(`/`);return e.toLowerCase()===`.github/contributing.md`?!0:i.some(e=>e.startsWith(`.`))?!1:SS(e)||mx(n,e)?!0:r&&!i.slice(0,-1).some(e=>_S.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)??Tx(t.path).replace(gS,``),s=TS(t.path,r),c;i?(c=mx(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=ES(t.path,s)&&n.length<=2e4,o.push({path:t.path,title:r,type:s,body:n,alwaysLoadCandidate:c,contentHash:T(`sha256`).update(n).digest(`hex`)})}return o}function SS(e){let t=Tx(e);if(!gS.test(t)||hS.test(t))return!1;let n=e.toLowerCase().split(`/`);return n.length===1?mS.has(n[0]??``):e.toLowerCase()===`.github/contributing.md`||n.slice(0,-1).some(e=>pS.has(e))}function CS(e){let t=e.replace(/\r\n/g,`
|
|
223
|
+
`),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?wS(s):null}function wS(e){return e.replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[`*_]/g,``).trim()}function TS(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 ES(e,t){if(t===`guideline`)return!0;let n=Tx(e).toLowerCase();return/architecture|conventions?|guidelines?|contributing|style-?guide/.test(n)||t===`architecture`&&/overview/.test(n)}const DS=/* @__PURE__ */ new Set([`claude.md`,`agents.md`,`.cursorrules`]);async function OS(e){let t=[];for(let n of e.files){if(!(DS.has(Tx(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 kS=/\.(md|mdx|markdown|txt)$/i,AS=/\.(pdf|docx?|odt|rtf|pages|pptx?|key|xlsx?|numbers)$/i;async function jS(e){let t=[],n=[];for(let r of e.files){if(r.path.split(`/`).some(e=>e.startsWith(`.`)))continue;let i=Tx(r.path);if(AS.test(i)){n.push(r.path);continue}if(!kS.test(i)||/^(claude|agents)\.md$/i.test(i))continue;let a=await e.readText(r);if(!a?.trim())continue;let o=i.replace(kS,``),s=(gS.test(i)?CS(a):null)??o,c=TS(r.path,s);t.push({path:r.path,title:s,type:c,body:a,alwaysLoadCandidate:!1,contentHash:T(`sha256`).update(a).digest(`hex`)})}return{docs:t,unsupported:n}}const MS=n(i);async function NS(e,t){try{let{stdout:n}=await MS(`git`,t,{cwd:e,timeout:1e4}),r=n.trim();return r===``?null:r}catch{return null}}async function PS(e){let t=await NS(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 NS(e,[`rev-parse`,`--verify`,`--quiet`,`${t}^{commit}`]))return{ref:t,branch:t.replace(/^origin\//,``)};return null}async function FS(e){try{return await MS(`git`,[`fetch`,`--quiet`,`--no-tags`,`origin`],{cwd:e,timeout:6e4}),await MS(`git`,[`remote`,`set-head`,`origin`,`--auto`],{cwd:e,timeout:3e4}).catch(()=>{}),!0}catch{return!1}}async function IS(e,t,n){let r=_.basename(e);if(await NS(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([NS(e,[`remote`,`get-url`,`origin`]),NS(e,[`rev-parse`,`--verify`,`--quiet`,`${i}^{commit}`]),NS(e,[`log`,`-1`,`--format=%cI`,i]),NS(e,[`symbolic-ref`,`--quiet`,`refs/remotes/origin/HEAD`]),NS(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?LS(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 LS(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 RS=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&&zS(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 zS(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 BS(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 VS(e){return JSON.parse(e)}function HS(e,t,n){let r=VS(e);if(!Z(r))throw Error(`not a JSON object`);let i=/* @__PURE__ */ new Set;if(n!==null){let e=VS(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 RS(`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 US(e,t,n){let r=new RS(`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__ */ E((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})),WS=/* @__PURE__ */ E((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})),GS=/* @__PURE__ */ E((e=>{var t=$(),n=WS();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(`
|
|
224
|
+
`)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),KS=/* @__PURE__ */ E((e=>{var t=$(),n=WS();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})),qS=/* @__PURE__ */ E((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})),JS=/* @__PURE__ */ E((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})),YS=/* @__PURE__ */ E((e=>{var t=qS(),n=$(),r=JS();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}}})),XS=/* @__PURE__ */ E((e=>{var t=KS(),n=WS(),r=$(),i=YS(),a=JS(),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);
|
|
224
225
|
/* istanbul ignore if */
|
|
225
|
-
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})),
|
|
226
|
+
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})),ZS=/* @__PURE__ */ E((e=>{var t=$(),n=YS(),r=JS();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})),QS=/* @__PURE__ */ E((e=>{var t=XS(),n=$(),r=ZS();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})),$S=/* @__PURE__ */ E((e=>{var t=QS(),n=$(),r=YS();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})),eC=/* @__PURE__ */ E((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(`
|
|
226
227
|
`)?n(r,t):r.includes(`
|
|
227
228
|
`)?`
|
|
228
|
-
`+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),
|
|
229
|
+
`+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),tC=/* @__PURE__ */ E((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===`
|
|
229
230
|
`)a===t&&(v=i(e,v,r.length)),m=v+r.length+d,h=void 0;else{if(o===` `&&g&&g!==` `&&g!==`
|
|
230
231
|
`&&g!==` `){let t=e[v+1];t&&t!==` `&&t!==`
|
|
231
232
|
`&&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!==`
|
|
232
|
-
`);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})),
|
|
233
|
+
`);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})),nC=/* @__PURE__ */ E((e=>{var t=ZS(),n=tC();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]===`
|
|
233
234
|
`){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)+`
|
|
234
235
|
|
|
235
236
|
`;a[e+2]===`\\`&&a[e+3]===`n`&&a[e+4]!==`"`;)l+=`
|
|
@@ -247,29 +248,29 @@ if(i||=(a.toJS(o,null,t),e.get(o)),i?.res===void 0)throw ReferenceError(`This sh
|
|
|
247
248
|
$&`).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`>${ee}\n${g}${c}`}return s=s.replace(/\n+/g,`$&${g}`),`|${ee}\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(`
|
|
248
249
|
`)||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(`
|
|
249
250
|
`)?c(d,a):u(e,a,o,s);if(!p&&!g&&l!==t.Scalar.PLAIN&&d.includes(`
|
|
250
|
-
`))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})),
|
|
251
|
+
`))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})),rC=/* @__PURE__ */ E((e=>{var t=KS(),n=$(),r=eC(),i=nC();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})),iC=/* @__PURE__ */ E((e=>{var t=$(),n=ZS(),r=rC(),i=eC();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),ee=` `;if(g||x||S){if(ee=x?`
|
|
251
252
|
`:``,S){let e=p(S);ee+=`\n${i.indentComment(e,o.indent)}`}T===``&&!o.inFlow?ee===`
|
|
252
253
|
`&&C&&(ee=`
|
|
253
254
|
|
|
254
255
|
`):ee+=`\n${o.indent}`}else if(!_&&t.isCollection(a)){let e=T[0],t=T.indexOf(`
|
|
255
256
|
`),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||(ee=`\n${o.indent}`)}}else(T===``||T[0]===`
|
|
256
|
-
`)&&(ee=``);return b+=ee+T,o.inFlow?w&&s&&s():C&&!w?b+=i.lineComment(b,o.indent,p(C)):y&&c&&c(),b}e.stringifyPair=a})),
|
|
257
|
+
`)&&(ee=``);return b+=ee+T,o.inFlow?w&&s&&s():C&&!w?b+=i.lineComment(b,o.indent,p(C)):y&&c&&c(),b}e.stringifyPair=a})),aC=/* @__PURE__ */ E((e=>{var t=fe(`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})),oC=/* @__PURE__ */ E((e=>{var t=$(),n=ZS();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})),sC=/* @__PURE__ */ E((e=>{var t=aC(),n=oC(),r=rC(),i=$(),a=JS();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})),cC=/* @__PURE__ */ E((e=>{var t=QS(),n=iC(),r=sC(),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})),lC=/* @__PURE__ */ E((e=>{var t=$(),n=rC(),r=eC();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}`:`
|
|
257
258
|
`}}return e?(_+=`
|
|
258
259
|
`+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(`
|
|
259
260
|
`),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}`:`
|
|
260
|
-
`;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})),
|
|
261
|
-
`:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),SC=/* @__PURE__ */ E((e=>{var t=$(),n=sC(),r=XS(),i=dC();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})),CC=/* @__PURE__ */ E((e=>{var t=$(),n=qS(),r=lC(),i=dC(),a=SC(),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})),wC=/* @__PURE__ */ E((e=>{var t=XS();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})),TC=/* @__PURE__ */ E((e=>{var t=XS(),n=gC();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})),EC=/* @__PURE__ */ E((e=>{var t=gC();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__ */ E((e=>{var t=$(),n=sC(),r=lC(),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})),OC=/* @__PURE__ */ E((e=>{var t=gC();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})),kC=/* @__PURE__ */ E((e=>{var t=uC(),n=mC(),r=fC(),i=pC(),a=xC(),o=wC(),s=TC(),c=EC(),l=aC(),u=CC(),d=SC(),f=DC(),p=OC();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]})),AC=/* @__PURE__ */ E((e=>{var t=uC(),n=mC(),r=fC(),i=pC(),a=hC(),o=_C(),s=vC(),c=yC(),l=bC(),u=xC(),d=aC(),f=CC(),p=SC(),m=kC(),h=DC(),g=OC();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})),jC=/* @__PURE__ */ E((e=>{var t=$(),n=uC(),r=fC(),i=pC(),a=AC();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}}})),MC=/* @__PURE__ */ E((e=>{var t=$(),n=nC(),r=$S();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(`
|
|
261
|
+
`;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})),uC=/* @__PURE__ */ E((e=>{var t=lC(),n=sC(),r=$S(),i=$(),a=cC(),o=ZS();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})),dC=/* @__PURE__ */ E((e=>{var t=$(),n=uC();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)}})),fC=/* @__PURE__ */ E((e=>{var t=QS(),n=lC(),r=$S(),i=$(),a=ZS(),o=JS(),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})),pC=/* @__PURE__ */ E((e=>{var t=$(),n=fC();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)}})),mC=/* @__PURE__ */ E((e=>{var t=nC();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)}}})),hC=/* @__PURE__ */ E((e=>{var t=ZS();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})),gC=/* @__PURE__ */ E((e=>{var t=ZS();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})),_C=/* @__PURE__ */ E((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})),vC=/* @__PURE__ */ E((e=>{var t=ZS(),n=_C();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})),yC=/* @__PURE__ */ E((e=>{var t=_C();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`)}})),bC=/* @__PURE__ */ E((e=>{var t=dC(),n=hC(),r=pC(),i=mC(),a=gC(),o=vC(),s=yC();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),xC=/* @__PURE__ */ E((e=>{var t=ZS(),n=dC(),r=pC();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__ */ E((e=>{var t=fe(`buffer`),n=ZS(),r=nC();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?`
|
|
262
|
+
`:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),CC=/* @__PURE__ */ E((e=>{var t=$(),n=cC(),r=ZS(),i=fC();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})),wC=/* @__PURE__ */ E((e=>{var t=$(),n=JS(),r=uC(),i=fC(),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})),TC=/* @__PURE__ */ E((e=>{var t=ZS();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})),EC=/* @__PURE__ */ E((e=>{var t=ZS(),n=_C();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})),DC=/* @__PURE__ */ E((e=>{var t=_C();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})),OC=/* @__PURE__ */ E((e=>{var t=$(),n=cC(),r=uC(),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})),kC=/* @__PURE__ */ E((e=>{var t=_C();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})),AC=/* @__PURE__ */ E((e=>{var t=dC(),n=hC(),r=pC(),i=mC(),a=SC(),o=TC(),s=EC(),c=DC(),l=oC(),u=wC(),d=CC(),f=OC(),p=kC();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]})),jC=/* @__PURE__ */ E((e=>{var t=dC(),n=hC(),r=pC(),i=mC(),a=gC(),o=vC(),s=yC(),c=bC(),l=xC(),u=SC(),d=oC(),f=wC(),p=CC(),m=AC(),h=OC(),g=kC();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})),MC=/* @__PURE__ */ E((e=>{var t=$(),n=dC(),r=pC(),i=mC(),a=jC();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}}})),NC=/* @__PURE__ */ E((e=>{var t=$(),n=rC(),r=eC();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(`
|
|
262
263
|
`)?(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(`
|
|
263
264
|
`)+`
|
|
264
|
-
`}e.stringifyDocument=i})),
|
|
265
|
-
`),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`}}})),
|
|
266
|
-
`))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})),
|
|
265
|
+
`}e.stringifyDocument=i})),PC=/* @__PURE__ */ E((e=>{var t=XS(),n=$S(),r=$(),i=cC(),a=JS(),o=MC(),s=NC(),c=KS(),l=qS(),u=QS(),d=GS(),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})),FC=/* @__PURE__ */ E((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)+`…
|
|
266
|
+
`),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`}}})),IC=/* @__PURE__ */ E((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})),LC=/* @__PURE__ */ E((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(`
|
|
267
|
+
`))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})),RC=/* @__PURE__ */ E((e=>{var t=LC();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})),zC=/* @__PURE__ */ E((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})),BC=/* @__PURE__ */ E((e=>{var t=cC(),n=uC(),r=IC(),i=LC(),a=RC(),o=zC();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+=`
|
|
267
268
|
`+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+=`
|
|
268
|
-
`+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})),
|
|
269
|
+
`+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})),VC=/* @__PURE__ */ E((e=>{var t=fC(),n=IC(),r=RC();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})),HC=/* @__PURE__ */ E((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})),UC=/* @__PURE__ */ E((e=>{var t=$(),n=cC(),r=uC(),i=fC(),a=HC(),o=IC(),s=LC(),c=zC();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+=`
|
|
269
270
|
`+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+=`
|
|
270
271
|
`+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+=`
|
|
271
272
|
`+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+=`
|
|
272
|
-
`+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})),
|
|
273
|
+
`+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})),WC=/* @__PURE__ */ E((e=>{var t=$(),n=ZS(),r=uC(),i=fC(),a=BC(),o=VC(),s=UC();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})),GC=/* @__PURE__ */ E((e=>{var t=ZS();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?`
|
|
273
274
|
`.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)+`
|
|
274
275
|
`;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`;
|
|
275
276
|
/* istanbul ignore if already caught in lexer */
|
|
@@ -290,7 +291,7 @@ if(i&&(r=r.slice(0,-1)),r&&n.length<d){let e=`Block scalar lines must not be les
|
|
|
290
291
|
/* istanbul ignore if should not happen */
|
|
291
292
|
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;
|
|
292
293
|
/* istanbul ignore next should not happen */
|
|
293
|
-
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})),
|
|
294
|
+
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})),KC=/* @__PURE__ */ E((e=>{var t=ZS(),n=HC();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;
|
|
294
295
|
/* istanbul ignore next should not happen */
|
|
295
296
|
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]){
|
|
296
297
|
/* istanbul ignore next should not happen */
|
|
@@ -307,10 +308,10 @@ case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;c
|
|
|
307
308
|
`);)r===`
|
|
308
309
|
`&&(n+=`
|
|
309
310
|
`),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:`
|
|
310
|
-
`,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})),
|
|
311
|
+
`,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})),qC=/* @__PURE__ */ E((e=>{var t=$(),n=ZS(),r=GC(),i=KC();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})),JC=/* @__PURE__ */ E((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})),YC=/* @__PURE__ */ E((e=>{var t=XS(),n=$(),r=WC(),i=qC(),a=HC(),o=JC();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})),XC=/* @__PURE__ */ E((e=>{var t=PC(),n=YC(),r=HC(),i=IC();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})),ZC=/* @__PURE__ */ E((e=>{var t=fe(`process`),n=GS(),r=PC(),i=FC(),a=$(),o=XC(),s=HC();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?`
|
|
311
312
|
|
|
312
313
|
`:`
|
|
313
|
-
`)+(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}}}})),
|
|
314
|
+
`)+(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}}}})),QC=/* @__PURE__ */ E((e=>{var t=GC(),n=KC(),r=FC(),i=nC();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:`
|
|
314
315
|
`}];switch(c[0]){case`|`:case`>`:{let e=c.indexOf(`
|
|
315
316
|
`),t=c.substring(0,e),n=c.substring(e+1)+`
|
|
316
317
|
`,i=[{type:`block-scalar-header`,offset:o,indent:r,source:t}];return l(i,u)||i.push({type:`newline`,offset:-1,indent:r,source:`
|
|
@@ -318,11 +319,11 @@ case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;c
|
|
|
318
319
|
`),r=t.substring(0,n),i=t.substring(n+1)+`
|
|
319
320
|
`;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:`
|
|
320
321
|
`});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:`
|
|
321
|
-
`};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}))
|
|
322
|
+
`};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})),$C=/* @__PURE__ */ E((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})),ew=/* @__PURE__ */ E((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})),tw=/* @__PURE__ */ E((e=>{var t=QC(),n=$C(),r=ew();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`);
|
|
322
323
|
/* istanbul ignore next */
|
|
323
324
|
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`
|
|
324
325
|
`:case`\r
|
|
325
|
-
`: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})),
|
|
326
|
+
`: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})),nw=/* @__PURE__ */ E((e=>{var t=tw();function n(e){switch(e){case void 0:case` `:case`
|
|
326
327
|
`: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(` ,[]{}
|
|
327
328
|
\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===`
|
|
328
329
|
`||t===`\r`&&this.buffer[e+1]===`
|
|
@@ -341,7 +342,7 @@ function o(e){switch(e){case``:return`<BOM>`;case``:return`<DOC>`;case``:re
|
|
|
341
342
|
`,t=this.buffer[i+1]):r=i),t===`#`||e&&a.has(t))break;if(o===`
|
|
342
343
|
`){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===`
|
|
343
344
|
`?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
|
|
344
|
-
`?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)}}})),
|
|
345
|
+
`?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)}}})),rw=/* @__PURE__ */ E((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}}}}})),iw=/* @__PURE__ */ E((e=>{var t=fe(`process`),n=tw(),r=nw();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;
|
|
345
346
|
/* istanbul ignore next should not happen */
|
|
346
347
|
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)}
|
|
347
348
|
/* istanbul ignore next should not happen */
|
|
@@ -357,10 +358,10 @@ default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.l
|
|
|
357
358
|
/* istanbul ignore else should not happen */
|
|
358
359
|
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(`
|
|
359
360
|
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
360
|
-
`,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())}}}})),iw=/* @__PURE__ */ E((e=>{var t=XC(),n=NC(),r=PC(),i=iC(),a=$(),o=nw(),s=rw();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})),aw=(/* @__PURE__ */ E((e=>{var t=XC(),n=NC(),r=jC(),i=PC(),a=YS(),o=$(),s=sC(),c=XS(),l=lC(),u=dC();ew();var d=tw(),f=nw(),p=rw(),m=iw(),h=US();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 ow(e,t){let n=(0,aw.parse)(e,{uniqueKeys:!1});if(!Z(n))throw Error(`not a YAML mapping`);let r=new LS(`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`||sw(n))continue;let i=lw(n);i?r.add(i.name,i.version,!0):r.add(e,cw(n),!0)}}for(let e of[`packages`,`snapshots`]){let t=n[e];if(Z(t))for(let e of Object.keys(t)){let t=lw(e);t&&!sw(t.version)&&r.add(t.name,t.version,!1)}}return r.rows()}function sw(e){return/^(link|file|workspace):/.test(e)}function cw(e){return e.replace(/\(.*$/,``).replace(/_(?=[^/]*@).*$/,``)}function lw(e){let t=e.replace(/^\//,``).replace(/\(.*$/,``),n=t.indexOf(`@`,1);if(n>0)return{name:t.slice(0,n),version:cw(t.slice(n+1))};if(!e.startsWith(`/`))return null;let r=t.lastIndexOf(`/`);return r<=0?null:{name:t.slice(0,r),version:cw(t.slice(r+1))}}function uw(e,t){let n=BS(e);if(!Z(n))throw Error(`not a JSON object`);let r=new LS(`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 zS(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`&&!sw(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 dw(e,t,n){let r=new LS(`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(fw).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 fw(e){if(e===`__metadata`)return null;let t=e.indexOf(`@`,1);return t>0?e.slice(0,t):null}async function pw(e,t){let n=Tx(t),r=/* @__PURE__ */ new Set,i=await mw(e,Ex(n,`package.json`));for(let e of zS(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=>hw(Ex(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=Tx(t.path);if(o.some(e=>e.test(n)))for(let n of zS(await mw(e,t.path)))r.add(n)}return r}async function mw(e,t){let n=e.file(t);if(!n)return null;let r=await e.readText(n);if(r===null)return null;try{return BS(r)}catch{return e.warnings.push(`${t}: not valid JSON, skipped`),null}}function hw(e){let t=e.split(`/`).map(e=>e===`**`?`.*`:e.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`[^/]*`)).join(`/`);return RegExp(`^${t}$`)}function gw(e){return e.toLowerCase().replace(/[-_.]+/g,`-`)}function _w(e,t,n){let r=new LS(`pip`,t),i=!1,a=null,o=null,s=!1,c=()=>{a&&o&&!s&&r.add(a,o,n.has(gw(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 vw(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(gw(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)?gw(u)!==`python`&&t.add(gw(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 yw(e,t){let n=new LS(`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 bw(e){let t=[];for(let n of e.files)try{let r=await xw(e,n);r&&t.push(...r)}catch(t){e.warnings.push(`${n.path}: could not be parsed (${Dx(t)})`)}return t}async function xw(e,t){let n=wx(t.path),r=Tx(t.path),i=t=>t?e.readText(t,52428800):Promise.resolve(null),a=t=>e.file(Ex(r,t));switch(n){case`pnpm-lock.yaml`:{let e=await i(t);return e===null?null:ow(e,t.path)}case`package-lock.json`:case`npm-shrinkwrap.json`:{let e=await i(t);return e===null?null:uw(e,t.path)}case`yarn.lock`:{let n=await i(t);return n===null?null:dw(n,t.path,await pw(e,t.path))}case`composer.lock`:{let e=await i(t);return e===null?null:VS(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?vw(n):/* @__PURE__ */ new Set;return _w(e,t.path,r)}case`go.sum`:case`go.mod`:return n===`go.mod`&&a(`go.sum`)?null:HS(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}=yw(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 Sw={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 Cw(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=Sw[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 ww=/* @__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`]),Tw=/^(not|null|default|primary|unique|references|check|constraint|generated|collate|deferrable|initially|identity)$/i;function Ew(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 Ow(e,t){let n=e.toLowerCase();if(!n.endsWith(`.sql`)||Ew(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 kw(e){let t=/* @__PURE__ */ new Map,n=e.files.filter(e=>Ew(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=>Ow(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 Aw(n))try{Rw(i,r.path,t,e.warnings)}catch(t){e.warnings.push(`${r.path}: could not read statement "${Jw(i)}" (${Dx(t)})`)}}return[...t.values()].filter(e=>!ww.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 Aw(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(`
|
|
361
|
-
`,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 jw(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 Mw(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 Nw=String.raw`(?:"(?:[^"]|"")+"|[A-Za-z_][\w$]*)`,Pw=String.raw`(${Nw}(?:\s*\.\s*${Nw})?)`;function Fw(e){let t=e.trim();return t.startsWith(`"`)?t.slice(1,-1).replace(/""/g,`"`):t.toLowerCase()}function Iw(e){let t=e.match(new RegExp(Nw,`g`))??[e];return t.length>=2?{schema:Fw(t[0]??``),table:Fw(t[1]??``)}:{schema:`public`,table:Fw(t[0]??e)}}function Lw(e,t){return`${e}.${t}`}function Rw(e,t,n,r){if(/^create\s+(?:(?:global|local)\s+)?(?:temp(?:orary)?\s+|unlogged\s+)?table\b/i.test(e)){zw(e,t,n,r);return}let i=new RegExp(String.raw`^alter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?${Pw}\s+(.+)$`,`i`).exec(e);if(i?.[1]&&i[2]){Kw(Iw(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 jw(a[1])){let{schema:t,table:r}=Iw(e);n.delete(Lw(t,r))}}function zw(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+)?${Pw}\s*\(`,`i`).exec(e);if(!i?.[1]){r.push(`${t}: skipped a create table statement it couldn't read: "${Jw(e)}"`);return}let{schema:a,table:o}=Iw(i[1]),s=i[0].length-1,c=Bw(e,s);if(c===-1){r.push(`${t}: unbalanced parentheses in create table ${o}`);return}let l=Lw(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 jw(e.slice(s+1,c))){if(/^(constraint|primary\s+key|unique|foreign\s+key|check|exclude|like)\b/i.test(i)){Gw(u,i,n);continue}let e=Vw(i,n);e?u.columns.push(e):r.push(`${t}: skipped column definition "${Jw(i)}" in ${o}`)}n.set(l,u)}function Bw(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 Vw(e,t){let n=Mw(e),r=n[0];if(!r||n.length<2)return null;let i=1,a=[];for(;i<n.length&&!Tw.test(n[i]??``);)a.push(n[i]),i++;if(a.length===0)return null;let o={name:Fw(r),type:a.join(` `).replace(/\s+\(/g,`(`).toLowerCase(),required:!1};return Hw(o,n.slice(i),t),o}function Hw(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&&!Tw.test(t[r+1]??``);)n.push(t[r+1]),r++;n.length>0&&(e.default=Uw(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=Ww(i,a,n),r+=a?2:1}}}function Uw(e){return e.join(` `).replace(/\s+\(/g,`(`)}function Ww(e,t,n){let{schema:r,table:i}=Iw(e),a=r===`public`?i:`${r}.${i}`,o=t?Fw(t.slice(1,-1).split(`,`)[0]??``):null;return o||=n.get(Lw(r,i))?.columns.find(e=>e.primaryKey)?.name??`id`,`${a}.${o}`}function Gw(e,t,n){let r=t.replace(new RegExp(String.raw`^constraint\s+${Nw}\s+`,`i`),``),i=e=>(e??``).split(`,`).map(e=>Fw(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+${Pw}\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=Ww(s[2],o?`(${o})`:void 0,n)})}}function Kw(e,t,n,r,i){let a=r.get(Lw(e.schema,e.table));if(!a){!ww.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+(${Nw})$`,`i`).exec(t);if(o?.[1]){r.delete(Lw(a.schema,a.table)),a.table=Fw(o[1]),r.set(Lw(a.schema,a.table),a);return}let s=new RegExp(String.raw`^rename\s+(?:column\s+)?(${Nw})\s+to\s+(${Nw})$`,`i`).exec(t);if(s?.[1]&&s[2]){let e=a.columns.find(e=>e.name===Fw(s[1]));e&&(e.name=Fw(s[2]))}else for(let e of jw(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=Vw(t[1],r);if(!o){i.push(`${n}: skipped "${Jw(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]){Gw(a,o[1],r);continue}let s=new RegExp(String.raw`^drop\s+(?:column\s+)?(?:if\s+exists\s+)?(${Nw})`,`i`).exec(e);if(s?.[1]&&!/^drop\s+constraint\b/i.test(e)){let e=Fw(s[1]);a.columns=a.columns.filter(t=>t.name!==e);continue}let c=new RegExp(String.raw`^alter\s+(?:column\s+)?(${Nw})\s+(.+)$`,`i`).exec(e);if(c?.[1]&&c[2]){let e=a.columns.find(e=>e.name===Fw(c[1]));e&&qw(e,c[2])}}}function qw(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=Uw(Mw(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 Jw(e){return e.length>60?`${e.slice(0,57)}...`:e}const Yw=[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`],Xw=/^(openapi|swagger)([.-][\w.-]*)?\.(json|ya?ml)$/i,Zw=/\.(json|ya?ml)$/i;async function Qw(e){let t=[];for(let n of e.files){let r=Xw.test(wx(n.path));if(!r&&!Zw.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,aw.parse)(i)}catch(t){e.warnings.push(`${n.path}: OpenAPI file could not be parsed (${Dx(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(...$w(a,n.path,e.warnings))}return t}function $w(e,t,n){let r=typeof e.swagger==`string`,i=new eT(e,t,n),a=r?e.securityDefinitions:nT(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 Yw){let l=nT(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:Ox(l.summary)?.trim()||Ox(l.operationId)||`${a} ${n}`,sourcePath:t,method:a,path:n,auth:gT(d,o,i),request:r?sT(u,l,e,i):iT(l.requestBody,i),responses:cT(l,e,r,i)})}}return c}var eT=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?tT(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[tT(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 tT(e){return decodeURIComponent(e).replace(/~1/g,`/`).replace(/~0/g,`~`)}function nT(e){return Z(e)?e:null}function rT(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 iT(e,t){let n=t.resolve(e),r=n?rT(n.content):null;return r?aT(r[0],r[1],t):null}function aT(e,t,n){let r=t.schema;return{contentType:e,fields:fT(r,n),example:oT(t,n)??hT(r,n,0)}}function oT(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 sT(e,t,n,r){let i=e.map(e=>r.resolve(e)).filter(e=>e!==null),a=uT(t.consumes)??uT(n.consumes),o=i.find(e=>e.in===`body`);if(o)return{contentType:a??`application/json`,fields:fT(o.schema,r),example:hT(o.schema,r,0)};let s=i.filter(e=>e.in===`formData`);if(s.length===0)return null;let c=s.map(e=>({name:Ox(e.name)??``,type:mT(e,r),required:e.required===!0,...pT(e)}));return{contentType:a??`application/x-www-form-urlencoded`,fields:c,example:Object.fromEntries(s.map(e=>[Ox(e.name)??``,hT(e,r,1)]))}}function cT(e,t,n,r){if(!Z(e.responses))return[];let i=uT(e.produces)??uT(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=nT(e.examples);s={contentType:i,fields:fT(e.schema,r),example:t?.[i]??hT(e.schema,r,0)}}}else{let t=rT(e.content);t&&(s=aT(t[0],t[1],r))}a.push({status:lT(t),description:Ox(e.description)??``,body:s})}return a}function lT(e){let t=e.replace(/x/gi,`0`),n=Number.parseInt(t,10);return Number.isNaN(n)?0:n}function uT(e){return Array.isArray(e)&&typeof e[0]==`string`?e[0]:void 0}function dT(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=dT(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?dT(i[0],t,n+1):r}function fT(e,t){let n=dT(e,t);if(n?.type===`array`&&(n=dT(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=dT(n,t)??{};return{name:e,type:mT(n,t),required:r.has(e),...pT(i)}})}function pT(e){let t={},n=Ox(e.description)?.trim();return n&&(t.description=n),Array.isArray(e.enum)&&(t.values=e.enum.map(e=>String(e))),t}function mT(e,t,n=0){let r=t.refName(e),i=dT(e,t);if(!i)return r??`unknown`;let a=Array.isArray(i.type)?i.type.filter(e=>e!==`null`).join(` | `):Ox(i.type);return a===`array`?n>8?`array`:`${mT(i.items,t,n+1)}[]`:r&&(a===`object`||a===void 0)?r:Ox(i.format)??a??(i.properties?`object`:`unknown`)}function hT(e,t,n){let r=dT(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,hT(r,t,n+1)]))}switch(i){case`array`:return[hT(r.items,t,n+1)];case`string`:return`string`;case`integer`:case`number`:return 0;case`boolean`:return!1;default:return null}}function gT(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=>_T(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 _T(e,t){if(!t)return e;switch(Ox(t.type)?.toLowerCase()){case`http`:{let e=Ox(t.scheme)?.toLowerCase();if(e===`bearer`){let e=Ox(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 ${Ox(t.in)??`header`} ${Ox(t.name)??e}`;case`oauth2`:return`OAuth2`;case`openidconnect`:return`OpenID Connect`;case`mutualtls`:return`Mutual TLS`;default:return e}}const vT=[`readme.md`,`readme.mdx`,`readme.markdown`,`readme.txt`,`readme`];async function yT(e){let t=e.files.find(e=>!e.path.includes(`/`)&&vT.includes(e.path.toLowerCase()));if(!t)return null;let n=await e.readText(t);return{path:t.path,oneLiner:n===null?null:bT(n)}}function bT(e){let t=e.replace(/\r\n/g,`
|
|
361
|
+
`,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())}}}})),aw=/* @__PURE__ */ E((e=>{var t=ZC(),n=PC(),r=FC(),i=aC(),a=$(),o=rw(),s=iw();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})),ow=(/* @__PURE__ */ E((e=>{var t=ZC(),n=PC(),r=MC(),i=FC(),a=XS(),o=$(),s=cC(),c=ZS(),l=uC(),u=fC();tw();var d=nw(),f=rw(),p=iw(),m=aw(),h=WS();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 sw(e,t){let n=(0,ow.parse)(e,{uniqueKeys:!1});if(!Z(n))throw Error(`not a YAML mapping`);let r=new RS(`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`||cw(n))continue;let i=uw(n);i?r.add(i.name,i.version,!0):r.add(e,lw(n),!0)}}for(let e of[`packages`,`snapshots`]){let t=n[e];if(Z(t))for(let e of Object.keys(t)){let t=uw(e);t&&!cw(t.version)&&r.add(t.name,t.version,!1)}}return r.rows()}function cw(e){return/^(link|file|workspace):/.test(e)}function lw(e){return e.replace(/\(.*$/,``).replace(/_(?=[^/]*@).*$/,``)}function uw(e){let t=e.replace(/^\//,``).replace(/\(.*$/,``),n=t.indexOf(`@`,1);if(n>0)return{name:t.slice(0,n),version:lw(t.slice(n+1))};if(!e.startsWith(`/`))return null;let r=t.lastIndexOf(`/`);return r<=0?null:{name:t.slice(0,r),version:lw(t.slice(r+1))}}function dw(e,t){let n=VS(e);if(!Z(n))throw Error(`not a JSON object`);let r=new RS(`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 BS(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`&&!cw(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 fw(e,t,n){let r=new RS(`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(pw).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 pw(e){if(e===`__metadata`)return null;let t=e.indexOf(`@`,1);return t>0?e.slice(0,t):null}async function mw(e,t){let n=Ex(t),r=/* @__PURE__ */ new Set,i=await hw(e,Dx(n,`package.json`));for(let e of BS(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=>gw(Dx(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=Ex(t.path);if(o.some(e=>e.test(n)))for(let n of BS(await hw(e,t.path)))r.add(n)}return r}async function hw(e,t){let n=e.file(t);if(!n)return null;let r=await e.readText(n);if(r===null)return null;try{return VS(r)}catch{return e.warnings.push(`${t}: not valid JSON, skipped`),null}}function gw(e){let t=e.split(`/`).map(e=>e===`**`?`.*`:e.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`[^/]*`)).join(`/`);return RegExp(`^${t}$`)}function _w(e){return e.toLowerCase().replace(/[-_.]+/g,`-`)}function vw(e,t,n){let r=new RS(`pip`,t),i=!1,a=null,o=null,s=!1,c=()=>{a&&o&&!s&&r.add(a,o,n.has(_w(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 yw(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(_w(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)?_w(u)!==`python`&&t.add(_w(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 bw(e,t){let n=new RS(`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 xw(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 (${Ox(t)})`)}return t}async function Sw(e,t){let n=Tx(t.path),r=Ex(t.path),i=t=>t?e.readText(t,52428800):Promise.resolve(null),a=t=>e.file(Dx(r,t));switch(n){case`pnpm-lock.yaml`:{let e=await i(t);return e===null?null:sw(e,t.path)}case`package-lock.json`:case`npm-shrinkwrap.json`:{let e=await i(t);return e===null?null:dw(e,t.path)}case`yarn.lock`:{let n=await i(t);return n===null?null:fw(n,t.path,await mw(e,t.path))}case`composer.lock`:{let e=await i(t);return e===null?null:HS(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?yw(n):/* @__PURE__ */ new Set;return vw(e,t.path,r)}case`go.sum`:case`go.mod`:return n===`go.mod`&&a(`go.sum`)?null:US(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}=bw(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 ww(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 Tw=/* @__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`]),Ew=/^(not|null|default|primary|unique|references|check|constraint|generated|collate|deferrable|initially|identity)$/i;function Dw(e){if(!/\.sql$/i.test(e))return!1;let t=e.toLowerCase();return/(^|\/)migrations\//.test(t)||/(^|\/)db\/migrate\//.test(t)}const Ow=e=>e.slice(0,e.lastIndexOf(`/`)+1);function kw(e,t){let n=e.toLowerCase();if(!n.endsWith(`.sql`)||Dw(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(Ow(n))||/(^|\/)docker-entrypoint-initdb\.d\//.test(n)}async function Aw(e){let t=/* @__PURE__ */ new Map,n=e.files.filter(e=>Dw(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=>kw(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 jw(n))try{zw(i,r.path,t,e.warnings)}catch(t){e.warnings.push(`${r.path}: could not read statement "${Yw(i)}" (${Ox(t)})`)}}return[...t.values()].filter(e=>!Tw.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 jw(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(`
|
|
362
|
+
`,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 Mw(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 Nw(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 Pw=String.raw`(?:"(?:[^"]|"")+"|[A-Za-z_][\w$]*)`,Fw=String.raw`(${Pw}(?:\s*\.\s*${Pw})?)`;function Iw(e){let t=e.trim();return t.startsWith(`"`)?t.slice(1,-1).replace(/""/g,`"`):t.toLowerCase()}function Lw(e){let t=e.match(new RegExp(Pw,`g`))??[e];return t.length>=2?{schema:Iw(t[0]??``),table:Iw(t[1]??``)}:{schema:`public`,table:Iw(t[0]??e)}}function Rw(e,t){return`${e}.${t}`}function zw(e,t,n,r){if(/^create\s+(?:(?:global|local)\s+)?(?:temp(?:orary)?\s+|unlogged\s+)?table\b/i.test(e)){Bw(e,t,n,r);return}let i=new RegExp(String.raw`^alter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?${Fw}\s+(.+)$`,`i`).exec(e);if(i?.[1]&&i[2]){qw(Lw(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 Mw(a[1])){let{schema:t,table:r}=Lw(e);n.delete(Rw(t,r))}}function Bw(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+)?${Fw}\s*\(`,`i`).exec(e);if(!i?.[1]){r.push(`${t}: skipped a create table statement it couldn't read: "${Yw(e)}"`);return}let{schema:a,table:o}=Lw(i[1]),s=i[0].length-1,c=Vw(e,s);if(c===-1){r.push(`${t}: unbalanced parentheses in create table ${o}`);return}let l=Rw(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 Mw(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=Hw(i,n);e?u.columns.push(e):r.push(`${t}: skipped column definition "${Yw(i)}" in ${o}`)}n.set(l,u)}function Vw(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 Hw(e,t){let n=Nw(e),r=n[0];if(!r||n.length<2)return null;let i=1,a=[];for(;i<n.length&&!Ew.test(n[i]??``);)a.push(n[i]),i++;if(a.length===0)return null;let o={name:Iw(r),type:a.join(` `).replace(/\s+\(/g,`(`).toLowerCase(),required:!1};return Uw(o,n.slice(i),t),o}function Uw(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&&!Ew.test(t[r+1]??``);)n.push(t[r+1]),r++;n.length>0&&(e.default=Ww(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=Gw(i,a,n),r+=a?2:1}}}function Ww(e){return e.join(` `).replace(/\s+\(/g,`(`)}function Gw(e,t,n){let{schema:r,table:i}=Lw(e),a=r===`public`?i:`${r}.${i}`,o=t?Iw(t.slice(1,-1).split(`,`)[0]??``):null;return o||=n.get(Rw(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+${Pw}\s+`,`i`),``),i=e=>(e??``).split(`,`).map(e=>Iw(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+${Fw}\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=Gw(s[2],o?`(${o})`:void 0,n)})}}function qw(e,t,n,r,i){let a=r.get(Rw(e.schema,e.table));if(!a){!Tw.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+(${Pw})$`,`i`).exec(t);if(o?.[1]){r.delete(Rw(a.schema,a.table)),a.table=Iw(o[1]),r.set(Rw(a.schema,a.table),a);return}let s=new RegExp(String.raw`^rename\s+(?:column\s+)?(${Pw})\s+to\s+(${Pw})$`,`i`).exec(t);if(s?.[1]&&s[2]){let e=a.columns.find(e=>e.name===Iw(s[1]));e&&(e.name=Iw(s[2]))}else for(let e of Mw(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=Hw(t[1],r);if(!o){i.push(`${n}: skipped "${Yw(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+)?(${Pw})`,`i`).exec(e);if(s?.[1]&&!/^drop\s+constraint\b/i.test(e)){let e=Iw(s[1]);a.columns=a.columns.filter(t=>t.name!==e);continue}let c=new RegExp(String.raw`^alter\s+(?:column\s+)?(${Pw})\s+(.+)$`,`i`).exec(e);if(c?.[1]&&c[2]){let e=a.columns.find(e=>e.name===Iw(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=Ww(Nw(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 Yw(e){return e.length>60?`${e.slice(0,57)}...`:e}const Xw=[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`],Zw=/^(openapi|swagger)([.-][\w.-]*)?\.(json|ya?ml)$/i,Qw=/\.(json|ya?ml)$/i;async function $w(e){let t=[];for(let n of e.files){let r=Zw.test(Tx(n.path));if(!r&&!Qw.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,ow.parse)(i)}catch(t){e.warnings.push(`${n.path}: OpenAPI file could not be parsed (${Ox(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(...eT(a,n.path,e.warnings))}return t}function eT(e,t,n){let r=typeof e.swagger==`string`,i=new tT(e,t,n),a=r?e.securityDefinitions:rT(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 Xw){let l=rT(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:kx(l.summary)?.trim()||kx(l.operationId)||`${a} ${n}`,sourcePath:t,method:a,path:n,auth:_T(d,o,i),request:r?cT(u,l,e,i):aT(l.requestBody,i),responses:lT(l,e,r,i)})}}return c}var tT=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?nT(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[nT(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 nT(e){return decodeURIComponent(e).replace(/~1/g,`/`).replace(/~0/g,`~`)}function rT(e){return Z(e)?e:null}function iT(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 aT(e,t){let n=t.resolve(e),r=n?iT(n.content):null;return r?oT(r[0],r[1],t):null}function oT(e,t,n){let r=t.schema;return{contentType:e,fields:pT(r,n),example:sT(t,n)??gT(r,n,0)}}function sT(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 cT(e,t,n,r){let i=e.map(e=>r.resolve(e)).filter(e=>e!==null),a=dT(t.consumes)??dT(n.consumes),o=i.find(e=>e.in===`body`);if(o)return{contentType:a??`application/json`,fields:pT(o.schema,r),example:gT(o.schema,r,0)};let s=i.filter(e=>e.in===`formData`);if(s.length===0)return null;let c=s.map(e=>({name:kx(e.name)??``,type:hT(e,r),required:e.required===!0,...mT(e)}));return{contentType:a??`application/x-www-form-urlencoded`,fields:c,example:Object.fromEntries(s.map(e=>[kx(e.name)??``,gT(e,r,1)]))}}function lT(e,t,n,r){if(!Z(e.responses))return[];let i=dT(e.produces)??dT(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=rT(e.examples);s={contentType:i,fields:pT(e.schema,r),example:t?.[i]??gT(e.schema,r,0)}}}else{let t=iT(e.content);t&&(s=oT(t[0],t[1],r))}a.push({status:uT(t),description:kx(e.description)??``,body:s})}return a}function uT(e){let t=e.replace(/x/gi,`0`),n=Number.parseInt(t,10);return Number.isNaN(n)?0:n}function dT(e){return Array.isArray(e)&&typeof e[0]==`string`?e[0]:void 0}function fT(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=fT(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?fT(i[0],t,n+1):r}function pT(e,t){let n=fT(e,t);if(n?.type===`array`&&(n=fT(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=fT(n,t)??{};return{name:e,type:hT(n,t),required:r.has(e),...mT(i)}})}function mT(e){let t={},n=kx(e.description)?.trim();return n&&(t.description=n),Array.isArray(e.enum)&&(t.values=e.enum.map(e=>String(e))),t}function hT(e,t,n=0){let r=t.refName(e),i=fT(e,t);if(!i)return r??`unknown`;let a=Array.isArray(i.type)?i.type.filter(e=>e!==`null`).join(` | `):kx(i.type);return a===`array`?n>8?`array`:`${hT(i.items,t,n+1)}[]`:r&&(a===`object`||a===void 0)?r:kx(i.format)??a??(i.properties?`object`:`unknown`)}function gT(e,t,n){let r=fT(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,gT(r,t,n+1)]))}switch(i){case`array`:return[gT(r.items,t,n+1)];case`string`:return`string`;case`integer`:case`number`:return 0;case`boolean`:return!1;default:return null}}function _T(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=>vT(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 vT(e,t){if(!t)return e;switch(kx(t.type)?.toLowerCase()){case`http`:{let e=kx(t.scheme)?.toLowerCase();if(e===`bearer`){let e=kx(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 ${kx(t.in)??`header`} ${kx(t.name)??e}`;case`oauth2`:return`OAuth2`;case`openidconnect`:return`OpenID Connect`;case`mutualtls`:return`Mutual TLS`;default:return e}}const yT=[`readme.md`,`readme.mdx`,`readme.markdown`,`readme.txt`,`readme`];async function bT(e){let t=e.files.find(e=>!e.path.includes(`/`)&&yT.includes(e.path.toLowerCase()));if(!t)return null;let n=await e.readText(t);return{path:t.path,oneLiner:n===null?null:xT(n)}}function xT(e){let t=e.replace(/\r\n/g,`
|
|
362
363
|
`).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(`
|
|
363
|
-
`).map(e=>e.trim()).filter(Boolean),n=t[0];if(!n||/^(#|=+$|-+$|\||[-*+] |\d+\. |>|<|\[!\[|!\[)/.test(n)||/^ {4}|^\t/.test(e))continue;let r=xT(t.join(` `));if(!(r.length<15||!/[a-z]/i.test(r)))return ST(/^.+?[.!?](?=\s+["'([]?[A-Z]|\s*$)/.exec(r)?.[0]??r,200)}return null}function xT(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 ST(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 CT={name:`Supabase`,type:`database`,provider:`Supabase Postgres`},wT={name:`Postgres`,type:`database`,provider:`Postgres`},TT={name:`MySQL`,type:`database`,provider:`MySQL`},ET={name:`MongoDB`,type:`database`,provider:`MongoDB`},DT={name:`Redis`,type:`database`,provider:`Redis`},OT={name:`Elasticsearch`,type:`database`,provider:`Elasticsearch`},kT={name:`AWS S3`,type:`storage`,provider:`AWS S3`},AT={name:`AWS SQS`,type:`queue`,provider:`AWS SQS`},jT={name:`AWS`,type:`service`,provider:`AWS`},MT={name:`MinIO`,type:`storage`,provider:`MinIO`},NT={name:`Cloudinary`,type:`storage`,provider:`Cloudinary`},PT={name:`RabbitMQ`,type:`queue`,provider:`RabbitMQ`},FT={name:`Kafka`,type:`queue`,provider:`Kafka`},IT={name:`Stripe`,type:`external_api`,provider:`Stripe`},LT={name:`Twilio`,type:`external_api`,provider:`Twilio`},RT={name:`SendGrid`,type:`service`,provider:`SendGrid`},zT={name:`Postmark`,type:`service`,provider:`Postmark`},BT={name:`Resend`,type:`service`,provider:`Resend`},VT={name:`Mailgun`,type:`service`,provider:`Mailgun`},HT={name:`Email (SMTP)`,type:`service`,provider:`SMTP`},UT={name:`Firebase`,type:`service`,provider:`Firebase`},WT={name:`OpenAI`,type:`external_api`,provider:`OpenAI`},GT={name:`Anthropic`,type:`external_api`,provider:`Anthropic`},KT={name:`Sentry`,type:`service`,provider:`Sentry`},qT={name:`Auth0`,type:`auth`,provider:`Auth0`},JT={name:`Clerk`,type:`auth`,provider:`Clerk`},YT={name:`Auth.js`,type:`auth`,provider:`Auth.js`},XT={name:`Algolia`,type:`external_api`,provider:`Algolia`},ZT={name:`Google Cloud`,type:`service`,provider:`Google Cloud`},QT={name:`Cloud Storage`,type:`storage`,provider:`Google Cloud Storage`},$T={name:`Pub/Sub`,type:`queue`,provider:`Google Cloud Pub/Sub`},eE={name:`BigQuery`,type:`database`,provider:`Google BigQuery`},tE={name:`Firestore`,type:`database`,provider:`Google Firestore`},nE={name:`Secret Manager`,type:`service`,provider:`Google Secret Manager`},rE={name:`Gemini`,type:`external_api`,provider:`Google Gemini`},iE={name:`Vertex AI`,type:`external_api`,provider:`Google Vertex AI`},aE={name:`SerpApi`,type:`external_api`,provider:`SerpApi`},oE={name:`Zyte`,type:`external_api`,provider:`Zyte`},sE={name:`Open Exchange Rates`,type:`external_api`,provider:`Open Exchange Rates`},cE={name:`reCAPTCHA`,type:`external_api`,provider:`Google reCAPTCHA`},lE={name:`DuckDB`,type:`database`,provider:`DuckDB`},uE=[[/^SUPABASE_/,CT],[/^(DATABASE_URL|POSTGRES_|PG(HOST|USER|PASSWORD|DATABASE|PORT)$)/,wT],[/^MYSQL_/,TT],[/^MONGO(DB)?_/,ET],[/^(REDIS_|UPSTASH_REDIS_)/,DT],[/^(ELASTIC(SEARCH)?_)/,OT],[/^(AWS_)?S3_|_S3_BUCKET$|^AWS_BUCKET/,kT],[/^(AWS_)?SQS_/,AT],[/^AWS_(ACCESS_KEY_ID|SECRET_ACCESS_KEY|REGION|DEFAULT_REGION)$/,jT],[/^MINIO_/,MT],[/^CLOUDINARY_/,NT],[/^(RABBITMQ_|AMQP_URL)/,PT],[/^KAFKA_/,FT],[/^STRIPE_/,IT],[/^TWILIO_/,LT],[/^SENDGRID_/,RT],[/^POSTMARK_/,zT],[/^RESEND_/,BT],[/^MAILGUN_/,VT],[/^SMTP_/,HT],[/^FIREBASE_/,UT],[/^OPENAI_/,WT],[/^ANTHROPIC_/,GT],[/^SENTRY_/,KT],[/^AUTH0_/,qT],[/^CLERK_/,JT],[/^(NEXTAUTH_|AUTH_SECRET$)/,YT],[/^ALGOLIA_/,XT],[/^(GCS_BUCKET|GOOGLE_CLOUD_STORAGE_|GCS_)/,QT],[/^(PUBSUB_|GOOGLE_PUBSUB_)/,$T],[/^BIGQUERY_/,eE],[/^FIRESTORE_/,tE],[/^(GEMINI_|GOOGLE_GENAI_)/,rE],[/^VERTEX(_AI)?_/,iE],[/^(SERPAPI_|SERP_API_)/,aE],[/^ZYTE_/,oE],[/^(OPEN_EXCHANGE_RATES_|OPENEXCHANGERATES_|OXR_)/,sE],[/^RECAPTCHA_/,cE],[/^(GOOGLE_CLOUD_PROJECT|GCP_PROJECT(_ID)?|GCLOUD_PROJECT|GOOGLE_APPLICATION_CREDENTIALS)$/,ZT]],dE=[[[`@supabase/supabase-js`,`@supabase/ssr`,`supabase`,`github.com/supabase-community/*`,`supabase/supabase-php`],CT],[[`pg`,`postgres`,`pg-promise`,`@neondatabase/serverless`,`@vercel/postgres`,`psycopg2`,`psycopg2-binary`,`psycopg`,`asyncpg`,`github.com/jackc/pgx*`,`github.com/lib/pq`],wT],[[`mysql`,`mysql2`,`pymysql`,`mysqlclient`,`github.com/go-sql-driver/mysql`],TT],[[`mongodb`,`mongoose`,`pymongo`,`motor`,`go.mongodb.org/mongo-driver*`,`mongodb/mongodb`],ET],[[`redis`,`ioredis`,`@upstash/redis`,`predis/predis`,`github.com/redis/go-redis*`,`github.com/go-redis/redis*`],DT],[[`@elastic/elasticsearch`,`elasticsearch`,`elasticsearch/elasticsearch`],OT],[[`@aws-sdk/client-s3`,`github.com/aws/aws-sdk-go-v2/service/s3`,`league/flysystem-aws-s3-v3`],kT],[[`@aws-sdk/client-sqs`,`github.com/aws/aws-sdk-go-v2/service/sqs`],AT],[[`aws-sdk`,`boto3`,`aws/aws-sdk-php`,`github.com/aws/aws-sdk-go`],jT],[[`minio`],MT],[[`cloudinary`,`cloudinary/cloudinary_php`],NT],[[`amqplib`,`pika`,`php-amqplib/php-amqplib`,`github.com/rabbitmq/amqp091-go`],PT],[[`kafkajs`,`kafka-python`,`confluent-kafka`,`github.com/segmentio/kafka-go`],FT],[[`stripe`,`@stripe/stripe-js`,`@stripe/react-stripe-js`,`stripe/stripe-php`,`github.com/stripe/stripe-go*`],IT],[[`twilio`,`twilio/sdk`,`github.com/twilio/twilio-go`],LT],[[`@sendgrid/`,`sendgrid`,`sendgrid/sendgrid`],RT],[[`postmark`,`wildbit/postmark-php`],zT],[[`resend`,`resend/resend-php`],BT],[[`mailgun.js`,`mailgun/mailgun-php`],VT],[[`nodemailer`],HT],[[`firebase`,`firebase-admin`,`firebase-functions`,`kreait/firebase-php`,`firebase.google.com/go*`],UT],[[`openai`,`openai-php/client`,`github.com/sashabaranov/go-openai`],WT],[[`@anthropic-ai/sdk`,`anthropic`,`github.com/anthropics/anthropic-sdk-go`],GT],[[`@sentry/`,`sentry-sdk`,`sentry/sentry`,`sentry/sentry-laravel`,`github.com/getsentry/sentry-go`],KT],[[`@auth0/`,`auth0`,`auth0/auth0-php`],qT],[[`@clerk/`],JT],[[`next-auth`,`@auth/`],YT],[[`algoliasearch`,`algolia/algoliasearch-client-php`],XT],[[`@google-cloud/storage`,`google-cloud-storage`,`cloud.google.com/go/storage`],QT],[[`@google-cloud/pubsub`,`google-cloud-pubsub`,`cloud.google.com/go/pubsub*`],$T],[[`@google-cloud/bigquery`,`google-cloud-bigquery`,`cloud.google.com/go/bigquery`],eE],[[`@google-cloud/firestore`,`google-cloud-firestore`,`cloud.google.com/go/firestore`],tE],[[`@google-cloud/secret-manager`,`google-cloud-secret-manager`,`cloud.google.com/go/secretmanager`],nE],[[`@google/genai`,`@google/generative-ai`,`google-genai`,`google-generativeai`],rE],[[`@google-cloud/vertexai`,`google-cloud-aiplatform`,`vertexai`],iE],[[`serpapi`,`google-search-results`],aE],[[`zyte-api`,`scrapy-zyte-api`],oE],[[`open-exchange-rates`],sE],[[`react-google-recaptcha`,`react-google-recaptcha-v3`,`vue-recaptcha`,`vue-recaptcha-v3`,`@google-cloud/recaptcha-enterprise`,`google-cloud-recaptcha-enterprise`,`django-recaptcha`],cE],[[`@google-cloud/`,`google-cloud-*`,`google-auth-library`,`google-auth`,`cloud.google.com/go*`],ZT],[[`duckdb`,`@duckdb/`],lE]],fE=[[/^supabase\//,CT],[/(^|\/)(postgres|postgis|timescaledb)$/,wT],[/(^|\/)(mysql|mariadb)$/,TT],[/(^|\/)mongo(db)?$/,ET],[/(^|\/)(redis|redis-stack|valkey)$/,DT],[/(^|\/)(elasticsearch|opensearch)$/,OT],[/(^|\/)minio$/,MT],[/(^|\/)rabbitmq$/,PT],[/(^|\/)(kafka|cp-kafka)$/,FT],[/(^|\/)localstack$/,jT],[/(^|\/)(cloud-sdk|google-cloud-cli)$/,ZT],[/(^|\/)(gcloud-pubsub-emulator|pubsub-emulator)$/,$T],[/(^|\/)fake-gcs-server$/,QT]];function pE(e){return/^\.env(\.[\w-]+)*\.(example|sample|template|dist)$/i.test(e)||/^(example|sample)\.env$/i.test(e)}function mE(e){let t=wx(e);return/^\.gitlab-ci\.ya?ml$/.test(t)||/^cloudbuild\.ya?ml$/.test(t)||t===`bitbucket-pipelines.yml`||/(^|\/)\.github\/workflows\/[^/]+\.ya?ml$/.test(e)}function hE(e){return[...new Set(e.match(/\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+\b/g)??[])]}function gE(e){return/^(docker-)?compose([.-][\w.-]+)?\.ya?ml$/i.test(e)}var _E=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 vE(e,t){let n=new _E,r=(e,t)=>{let r=e.replace(/^(NEXT_PUBLIC_|VITE_|PUBLIC_|REACT_APP_|EXPO_PUBLIC_|NUXT_PUBLIC_|NUXT_)/,``),i=uE.find(([e])=>e.test(r));i&&n.add(i[1],t)};for(let t of e.files){let i=wx(t.path);if(pE(i)){let n=await e.readText(t);if(n===null)continue;for(let e of yE(n))r(e,`env: ${e} (${t.path})`)}else if(mE(t.path)){let n=await e.readText(t);if(n===null)continue;for(let e of hE(n))r(e,`pipeline: ${e} (${t.path})`)}else if(gE(i)){let i=await e.readText(t);if(i===null)continue;let a;try{a=(0,aw.parse)(i)}catch(n){e.warnings.push(`${t.path}: could not be parsed (${Dx(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=bE(i.image),c=fE.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(CT,`file: ${t.path}`):i===`firebase.json`?n.add(UT,`file: ${t.path}`):/^cloudbuild\.ya?ml$/.test(i)&&n.add(ZT,`file: ${t.path}`)}for(let e of t){if(!e.direct)continue;let t=dE.find(([t])=>t.some(t=>xE(t,e.package)));t&&n.add(t[1],`dependency: ${e.package} (${e.sourceLockfile})`)}return n.list()}function yE(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 bE(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 xE(e,t){return e.endsWith(`*`)?t.startsWith(e.slice(0,-1)):e.endsWith(`/`)?t.startsWith(e):t===e}async function SE(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 NS(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 xx(n,a.ref):await bx(n),s=await vS(o),[c,l,u,d,f,m,h]=await Promise.all([FS(n,i,a?.ref??null),yT(o),bw(o),bS(o,s),DS(o),Qw(o),kw(o)]),g=await vE(o,u);return{scannedAt:r,root:n,repo:{...c,languages:Cw(o.files),readme:l},dependencies:u,docs:d,agentInstructions:f,contracts:[...m,...h],resources:g,docsConfig:{alwaysLoad:!!s.alwaysLoad},warnings:[...i,...o.warnings]}}function CE(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 wE(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 TE(e,t,{quiet:n=!1,source:r=`connector`}={}){await PS(e);let i=await SE(e),a=await new Wr(await ox()).call(`sync_repo`,{p_project:t.projectId,p_snapshot:i,p_source:r});if(!n){Lx(`Synced ${Nx(i.repo.name)} to ${Nx(t.name)} ${Q(`from ${wE(i)}`)}`),Rx(Q(CE(a)));for(let e of i.warnings)Rx(Q(`! ${e}`))}return{snapshot:i,result:a}}async function EE(e){return AS(await bx(e))}const DE=26214400,OE=e=>`${(e/1024/1024).toFixed(1)} MB`;async function kE(e,t,{quiet:n=!1}={}){if(!t.folder)return;let{docs:r,unsupported:i}=await EE(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} (${OE(t)})`).join(`, `);throw new Hx(`The documents outside the repos add up to ${OE(o)}, over the ${OE(DE)} a sync takes. The biggest: ${n}. List what Quirl should skip in ${x(v(e),`.quirlignore`)}, like .gitignore.`)}let s=new Wr(await ox()),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||(Lx(`Synced the documents in ${Nx(`${v(e)}/`)} outside the repos`),Rx(Q(`${f.docs} docs (${f.docsChanged} changed${f.archived?`, ${f.archived} removed`:``})`)),i.length&&Rx(Q(`! ${i.length} PDF/Office files skipped: only markdown and text are read for now`))),f}async function AE(e={}){let t=await lx();if(!t)throw new Hx("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 TE(a,t.link,e)}catch(e){if(i++,r===1)throw e;let n=S(t.root,a)||`.`;console.error(`${Fx(`✗`)} ${n}: ${Dx(e)}`)}if(t.link.folder)try{await kE(t.root,t.link,e)}catch(e){i++,console.error(`${Fx(`✗`)} documents in ${v(t.root)}/: ${Dx(e)}`)}if(i)throw new Hx(`${i} of ${r} parts didn't sync.`)}async function jE(e){let t=sx(),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🌀 ${Nx(`Quirl`)} ${Q(`·`)} connecting ${Nx(s)}`),i&&(zx(`📁`,`Found ${r.length} ${r.length===1?`repo`:`repos`}`),Bx(Q(r.map(a).join(` · `))),!await Wx(` Import all of them into one project?`,!0)))throw new Hx("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 EE(t);if(e.length){zx(`📄`,`Also found ${e.length} ${e.length===1?`document`:`documents`} outside the repos`);for(let t of e.slice(0,8))Bx(Q(t.path));e.length>8&&Bx(Q(`…and ${e.length-8} more`)),n.length&&Bx(Q(`(${n.length} PDF/Office files can't be read yet and are skipped)`)),c=await Wx(` Import them too? Everyone on the project will be able to read them.`,!0)}}await rx()||await uS({quiet:!0});let l=await NE((await new Wr(await ox()).whoami()).projects,e.project??(await lx(t))?.link.project);if(l.role===`stakeholder`)throw new Hx(`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};zx(`🔗`,`Linked to ${Nx(l.name)} ${Q(`· ${l.organization}`)}`);let d=e.claude!==!1,f=e.hooks??await Wx(` Sync with Quirl on every git push?`,!0);zx(`📦`,`Importing docs, dependencies and schemas`);let p=[];for(let e of r){let t=Vx(`Reading ${a(e)}…`);try{await ux(e,u);let{snapshot:n,result:r}=await TE(e,u,{quiet:!0});d&&await ME(e,l.name),f&&await lS(e),t.stop(),Bx(`${Px(`✓`)} ${Nx(a(e))} ${Q(`(${wE(n)})`)} ${Q(CE(r))}`);for(let e of n.warnings)Bx(Q(` ! ${e}`));p.push(e)}catch(n){t.stop(),Bx(`${Fx(`✗`)} ${Nx(a(e))} ${Dx(n)}`)}}if(!p.length)throw new Hx(`No repo was imported.`);if(i){let e=p.map(a),n=await lx(t),r={...u,repos:e,folder:c?n?.root===t&&n.link.folder||ee():void 0};if(await ux(t,r),c)try{let e=await kE(t,r,{quiet:!0});Bx(`${Px(`✓`)} ${Nx(`documents outside the repos`)} ${Q(`${e?.docs??0} docs`)}`)}catch(e){Bx(`${Fx(`✗`)} ${Nx(`documents outside the repos`)} ${Dx(e)}`)}d&&!p.includes(t)&&await ME(t,l.name,e)}let m=eS().portable;d&&(zx(`🤖`,`Connected Claude Code`),Bx(Q(`.mcp.json the quirl tools`)),Bx(Q(`.claude/settings.json the briefing, loaded as each session starts`)),Bx(Q(`CLAUDE.md when to use Quirl`))),f&&zx(`🪝`,`Quirl syncs on every ${Nx(`git push`)}`);let g=r.length-p.length,_=`.quirl .mcp.json .claude/settings.json CLAUDE.md`;zx(g?`⚠️ `:`🎉`,g?`Done, but ${g} of ${r.length} repos failed. Fix them and run ${Nx(`quirl init`)} again.`:Nx(`All set!`)),Bx(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`:``}: ${Ix(`git add ${_}`)}`),Bx(`${Q(d&&!m?`→`:`2.`)} Start Claude Code here and approve the ${Nx(`quirl`)} server when it asks.`),i&&!p.includes(t)&&Bx(Q("Run `quirl sync` here to sync every repo at once.")),console.log(``)}async function ME(e,t,n=[]){await oS(e),await sS(e),await cS(e,t,n)}async function NE(e,t){if(!e.length)throw new Hx(`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 Hx(`No project "${t}" among yours: ${e.map(e=>e.slug).join(`, `)}.`);return n}if(e.length===1)return e[0];zx(`🗂️ `,`Which project is this part of?`);for(let[t,n]of e.entries())Bx(`${Ix(String(t+1))} ${n.name} ${Q(`· ${n.organization} · ${n.role}`)}`);let n=e[Number(await Ux(` Project [1-${e.length}]: `))-1];if(!n)throw new Hx("No project picked. Run `quirl init --project <slug>`.");return n}const PE=`${Nx(`quirl`)} ${Q(Zb)}: connect a repo to Quirl
|
|
364
|
+
`).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 wT={name:`Supabase`,type:`database`,provider:`Supabase Postgres`},TT={name:`Postgres`,type:`database`,provider:`Postgres`},ET={name:`MySQL`,type:`database`,provider:`MySQL`},DT={name:`MongoDB`,type:`database`,provider:`MongoDB`},OT={name:`Redis`,type:`database`,provider:`Redis`},kT={name:`Elasticsearch`,type:`database`,provider:`Elasticsearch`},AT={name:`AWS S3`,type:`storage`,provider:`AWS S3`},jT={name:`AWS SQS`,type:`queue`,provider:`AWS SQS`},MT={name:`AWS`,type:`service`,provider:`AWS`},NT={name:`MinIO`,type:`storage`,provider:`MinIO`},PT={name:`Cloudinary`,type:`storage`,provider:`Cloudinary`},FT={name:`RabbitMQ`,type:`queue`,provider:`RabbitMQ`},IT={name:`Kafka`,type:`queue`,provider:`Kafka`},LT={name:`Stripe`,type:`external_api`,provider:`Stripe`},RT={name:`Twilio`,type:`external_api`,provider:`Twilio`},zT={name:`SendGrid`,type:`service`,provider:`SendGrid`},BT={name:`Postmark`,type:`service`,provider:`Postmark`},VT={name:`Resend`,type:`service`,provider:`Resend`},HT={name:`Mailgun`,type:`service`,provider:`Mailgun`},UT={name:`Email (SMTP)`,type:`service`,provider:`SMTP`},WT={name:`Firebase`,type:`service`,provider:`Firebase`},GT={name:`OpenAI`,type:`external_api`,provider:`OpenAI`},KT={name:`Anthropic`,type:`external_api`,provider:`Anthropic`},qT={name:`Sentry`,type:`service`,provider:`Sentry`},JT={name:`Auth0`,type:`auth`,provider:`Auth0`},YT={name:`Clerk`,type:`auth`,provider:`Clerk`},XT={name:`Auth.js`,type:`auth`,provider:`Auth.js`},ZT={name:`Algolia`,type:`external_api`,provider:`Algolia`},QT={name:`Google Cloud`,type:`service`,provider:`Google Cloud`},$T={name:`Cloud Storage`,type:`storage`,provider:`Google Cloud Storage`},eE={name:`Pub/Sub`,type:`queue`,provider:`Google Cloud Pub/Sub`},tE={name:`BigQuery`,type:`database`,provider:`Google BigQuery`},nE={name:`Firestore`,type:`database`,provider:`Google Firestore`},rE={name:`Secret Manager`,type:`service`,provider:`Google Secret Manager`},iE={name:`Gemini`,type:`external_api`,provider:`Google Gemini`},aE={name:`Vertex AI`,type:`external_api`,provider:`Google Vertex AI`},oE={name:`SerpApi`,type:`external_api`,provider:`SerpApi`},sE={name:`Zyte`,type:`external_api`,provider:`Zyte`},cE={name:`Open Exchange Rates`,type:`external_api`,provider:`Open Exchange Rates`},lE={name:`reCAPTCHA`,type:`external_api`,provider:`Google reCAPTCHA`},uE={name:`DuckDB`,type:`database`,provider:`DuckDB`},dE=[[/^SUPABASE_/,wT],[/^(DATABASE_URL|POSTGRES_|PG(HOST|USER|PASSWORD|DATABASE|PORT)$)/,TT],[/^MYSQL_/,ET],[/^MONGO(DB)?_/,DT],[/^(REDIS_|UPSTASH_REDIS_)/,OT],[/^(ELASTIC(SEARCH)?_)/,kT],[/^(AWS_)?S3_|_S3_BUCKET$|^AWS_BUCKET/,AT],[/^(AWS_)?SQS_/,jT],[/^AWS_(ACCESS_KEY_ID|SECRET_ACCESS_KEY|REGION|DEFAULT_REGION)$/,MT],[/^MINIO_/,NT],[/^CLOUDINARY_/,PT],[/^(RABBITMQ_|AMQP_URL)/,FT],[/^KAFKA_/,IT],[/^STRIPE_/,LT],[/^TWILIO_/,RT],[/^SENDGRID_/,zT],[/^POSTMARK_/,BT],[/^RESEND_/,VT],[/^MAILGUN_/,HT],[/^SMTP_/,UT],[/^FIREBASE_/,WT],[/^OPENAI_/,GT],[/^ANTHROPIC_/,KT],[/^SENTRY_/,qT],[/^AUTH0_/,JT],[/^CLERK_/,YT],[/^(NEXTAUTH_|AUTH_SECRET$)/,XT],[/^ALGOLIA_/,ZT],[/^(GCS_BUCKET|GOOGLE_CLOUD_STORAGE_|GCS_)/,$T],[/^(PUBSUB_|GOOGLE_PUBSUB_)/,eE],[/^BIGQUERY_/,tE],[/^FIRESTORE_/,nE],[/^(GEMINI_|GOOGLE_GENAI_)/,iE],[/^VERTEX(_AI)?_/,aE],[/^(SERPAPI_|SERP_API_)/,oE],[/^ZYTE_/,sE],[/^(OPEN_EXCHANGE_RATES_|OPENEXCHANGERATES_|OXR_)/,cE],[/^RECAPTCHA_/,lE],[/^(GOOGLE_CLOUD_PROJECT|GCP_PROJECT(_ID)?|GCLOUD_PROJECT|GOOGLE_APPLICATION_CREDENTIALS)$/,QT]],fE=[[[`@supabase/supabase-js`,`@supabase/ssr`,`supabase`,`github.com/supabase-community/*`,`supabase/supabase-php`],wT],[[`pg`,`postgres`,`pg-promise`,`@neondatabase/serverless`,`@vercel/postgres`,`psycopg2`,`psycopg2-binary`,`psycopg`,`asyncpg`,`github.com/jackc/pgx*`,`github.com/lib/pq`],TT],[[`mysql`,`mysql2`,`pymysql`,`mysqlclient`,`github.com/go-sql-driver/mysql`],ET],[[`mongodb`,`mongoose`,`pymongo`,`motor`,`go.mongodb.org/mongo-driver*`,`mongodb/mongodb`],DT],[[`redis`,`ioredis`,`@upstash/redis`,`predis/predis`,`github.com/redis/go-redis*`,`github.com/go-redis/redis*`],OT],[[`@elastic/elasticsearch`,`elasticsearch`,`elasticsearch/elasticsearch`],kT],[[`@aws-sdk/client-s3`,`github.com/aws/aws-sdk-go-v2/service/s3`,`league/flysystem-aws-s3-v3`],AT],[[`@aws-sdk/client-sqs`,`github.com/aws/aws-sdk-go-v2/service/sqs`],jT],[[`aws-sdk`,`boto3`,`aws/aws-sdk-php`,`github.com/aws/aws-sdk-go`],MT],[[`minio`],NT],[[`cloudinary`,`cloudinary/cloudinary_php`],PT],[[`amqplib`,`pika`,`php-amqplib/php-amqplib`,`github.com/rabbitmq/amqp091-go`],FT],[[`kafkajs`,`kafka-python`,`confluent-kafka`,`github.com/segmentio/kafka-go`],IT],[[`stripe`,`@stripe/stripe-js`,`@stripe/react-stripe-js`,`stripe/stripe-php`,`github.com/stripe/stripe-go*`],LT],[[`twilio`,`twilio/sdk`,`github.com/twilio/twilio-go`],RT],[[`@sendgrid/`,`sendgrid`,`sendgrid/sendgrid`],zT],[[`postmark`,`wildbit/postmark-php`],BT],[[`resend`,`resend/resend-php`],VT],[[`mailgun.js`,`mailgun/mailgun-php`],HT],[[`nodemailer`],UT],[[`firebase`,`firebase-admin`,`firebase-functions`,`kreait/firebase-php`,`firebase.google.com/go*`],WT],[[`openai`,`openai-php/client`,`github.com/sashabaranov/go-openai`],GT],[[`@anthropic-ai/sdk`,`anthropic`,`github.com/anthropics/anthropic-sdk-go`],KT],[[`@sentry/`,`sentry-sdk`,`sentry/sentry`,`sentry/sentry-laravel`,`github.com/getsentry/sentry-go`],qT],[[`@auth0/`,`auth0`,`auth0/auth0-php`],JT],[[`@clerk/`],YT],[[`next-auth`,`@auth/`],XT],[[`algoliasearch`,`algolia/algoliasearch-client-php`],ZT],[[`@google-cloud/storage`,`google-cloud-storage`,`cloud.google.com/go/storage`],$T],[[`@google-cloud/pubsub`,`google-cloud-pubsub`,`cloud.google.com/go/pubsub*`],eE],[[`@google-cloud/bigquery`,`google-cloud-bigquery`,`cloud.google.com/go/bigquery`],tE],[[`@google-cloud/firestore`,`google-cloud-firestore`,`cloud.google.com/go/firestore`],nE],[[`@google-cloud/secret-manager`,`google-cloud-secret-manager`,`cloud.google.com/go/secretmanager`],rE],[[`@google/genai`,`@google/generative-ai`,`google-genai`,`google-generativeai`],iE],[[`@google-cloud/vertexai`,`google-cloud-aiplatform`,`vertexai`],aE],[[`serpapi`,`google-search-results`],oE],[[`zyte-api`,`scrapy-zyte-api`],sE],[[`open-exchange-rates`],cE],[[`react-google-recaptcha`,`react-google-recaptcha-v3`,`vue-recaptcha`,`vue-recaptcha-v3`,`@google-cloud/recaptcha-enterprise`,`google-cloud-recaptcha-enterprise`,`django-recaptcha`],lE],[[`@google-cloud/`,`google-cloud-*`,`google-auth-library`,`google-auth`,`cloud.google.com/go*`],QT],[[`duckdb`,`@duckdb/`],uE]],pE=[[/^supabase\//,wT],[/(^|\/)(postgres|postgis|timescaledb)$/,TT],[/(^|\/)(mysql|mariadb)$/,ET],[/(^|\/)mongo(db)?$/,DT],[/(^|\/)(redis|redis-stack|valkey)$/,OT],[/(^|\/)(elasticsearch|opensearch)$/,kT],[/(^|\/)minio$/,NT],[/(^|\/)rabbitmq$/,FT],[/(^|\/)(kafka|cp-kafka)$/,IT],[/(^|\/)localstack$/,MT],[/(^|\/)(cloud-sdk|google-cloud-cli)$/,QT],[/(^|\/)(gcloud-pubsub-emulator|pubsub-emulator)$/,eE],[/(^|\/)fake-gcs-server$/,$T]];function mE(e){return/^\.env(\.[\w-]+)*\.(example|sample|template|dist)$/i.test(e)||/^(example|sample)\.env$/i.test(e)}function hE(e){let t=Tx(e);return/^\.gitlab-ci\.ya?ml$/.test(t)||/^cloudbuild\.ya?ml$/.test(t)||t===`bitbucket-pipelines.yml`||/(^|\/)\.github\/workflows\/[^/]+\.ya?ml$/.test(e)}function gE(e){return[...new Set(e.match(/\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+\b/g)??[])]}function _E(e){return/^(docker-)?compose([.-][\w.-]+)?\.ya?ml$/i.test(e)}var vE=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 yE(e,t){let n=new vE,r=(e,t)=>{let r=e.replace(/^(NEXT_PUBLIC_|VITE_|PUBLIC_|REACT_APP_|EXPO_PUBLIC_|NUXT_PUBLIC_|NUXT_)/,``),i=dE.find(([e])=>e.test(r));i&&n.add(i[1],t)};for(let t of e.files){let i=Tx(t.path);if(mE(i)){let n=await e.readText(t);if(n===null)continue;for(let e of bE(n))r(e,`env: ${e} (${t.path})`)}else if(hE(t.path)){let n=await e.readText(t);if(n===null)continue;for(let e of gE(n))r(e,`pipeline: ${e} (${t.path})`)}else if(_E(i)){let i=await e.readText(t);if(i===null)continue;let a;try{a=(0,ow.parse)(i)}catch(n){e.warnings.push(`${t.path}: could not be parsed (${Ox(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=xE(i.image),c=pE.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(wT,`file: ${t.path}`):i===`firebase.json`?n.add(WT,`file: ${t.path}`):/^cloudbuild\.ya?ml$/.test(i)&&n.add(QT,`file: ${t.path}`)}for(let e of t){if(!e.direct)continue;let t=fE.find(([t])=>t.some(t=>SE(t,e.package)));t&&n.add(t[1],`dependency: ${e.package} (${e.sourceLockfile})`)}return n.list()}function bE(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 xE(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 PS(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 Sx(n,a.ref):await xx(n),s=await yS(o),[c,l,u,d,f,m,h]=await Promise.all([IS(n,i,a?.ref??null),bT(o),xw(o),xS(o,s),OS(o),$w(o),Aw(o)]),g=await yE(o,u);return{scannedAt:r,root:n,repo:{...c,languages:ww(o.files),readme:l},dependencies:u,docs:d,agentInstructions:f,contracts:[...m,...h],resources:g,docsConfig:{alwaysLoad:!!s.alwaysLoad},warnings:[...i,...o.warnings]}}function wE(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 TE(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 EE(e,t,{quiet:n=!1,source:r=`connector`,name:i,restore:a}={}){await FS(e);let o=await CE(e),s=(i??t.repoName)?.trim();s&&Object.assign(o.repo,{name:s,nameFromConfig:!0}),a&&Object.assign(o.repo,{restore:!0});let c=await new Wr(await ox()).call(`sync_repo`,{p_project:t.projectId,p_snapshot:o,p_source:r});if(!n){Rx(`Synced ${Px(o.repo.name)} to ${Px(t.name)} ${Q(`from ${TE(o)}`)}`),zx(Q(wE(c)));for(let e of o.warnings)zx(Q(`! ${e}`))}return{snapshot:o,result:c}}async function DE(e){return jS(await xx(e))}const OE=26214400,kE=e=>`${(e/1024/1024).toFixed(1)} MB`;async function AE(e,t,{quiet:n=!1}={}){if(!t.folder)return;let{docs:r,unsupported:i}=await DE(e),a=e=>Buffer.byteLength(e.body),o=r.reduce((e,t)=>e+a(t),0);if(o>OE){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} (${kE(t)})`).join(`, `);throw new Ux(`The documents outside the repos add up to ${kE(o)}, over the ${kE(OE)} a sync takes. The biggest: ${n}. List what Quirl should skip in ${x(v(e),`.quirlignore`)}, like .gitignore.`)}let s=new Wr(await ox()),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||(Rx(`Synced the documents in ${Px(`${v(e)}/`)} outside the repos`),zx(Q(`${f.docs} docs (${f.docsChanged} changed${f.archived?`, ${f.archived} removed`:``})`)),i.length&&zx(Q(`! ${i.length} PDF/Office files skipped: only markdown and text are read for now`))),f}async function jE(e={}){let t=await ux();if(!t)throw new Ux("This folder isn't linked to a Quirl project. Run `quirl init`.");let n=sx(t.link),r=n.length?n.map(e=>({root:x(t.root,e.path),name:e.name})):[{root:t.root,name:void 0}],i=r.length+ +!!t.link.folder,a=0;for(let{root:o,name:s}of r)try{let r=n.length?await ux(o):null,i=s??(r?.root===o?r.link.repoName:void 0);await EE(o,t.link,{...e,name:i})}catch(e){if(a++,i===1)throw e;let n=S(t.root,o)||`.`;console.error(`${Ix(`✗`)} ${n}: ${Ox(e)}`)}if(t.link.folder)try{await AE(t.root,t.link,e)}catch(e){a++,console.error(`${Ix(`✗`)} documents in ${v(t.root)}/: ${Ox(e)}`)}if(a)throw new Ux(`${a} of ${i} parts didn't sync.`)}async function ME(e){let t=cx(),n=await Zx(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🌀 ${Px(`Quirl`)} ${Q(`·`)} connecting ${Px(s)}`),i&&(Bx(`📁`,`Found ${r.length} ${r.length===1?`repo`:`repos`}`),Vx(Q(r.map(a).join(` · `))),!await Gx(` Import all of them into one project?`,!0)))throw new Ux("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 DE(t);if(e.length){Bx(`📄`,`Also found ${e.length} ${e.length===1?`document`:`documents`} outside the repos`);for(let t of e.slice(0,8))Vx(Q(t.path));e.length>8&&Vx(Q(`…and ${e.length-8} more`)),n.length&&Vx(Q(`(${n.length} PDF/Office files can't be read yet and are skipped)`)),c=await Gx(` Import them too? Everyone on the project will be able to read them.`,!0)}}await rx()||await dS({quiet:!0});let l=await PE((await new Wr(await ox()).whoami()).projects,e.project??(await ux(t))?.link.project);if(l.role===`stakeholder`)throw new Ux(`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};Bx(`🔗`,`Linked to ${Px(l.name)} ${Q(`· ${l.organization}`)}`);let d=e.claude!==!1,f=e.hooks??await Gx(` Sync with Quirl on every git push?`,!0);Bx(`📦`,`Importing docs, dependencies and schemas`);let p=[],m=i?await ux(t):null,g=new Map((m?.root===t?sx(m.link):[]).filter(e=>e.name).map(e=>[e.path,e.name]));for(let e of r){let t=Hx(`Reading ${a(e)}…`);try{let n=await ux(e),r=(n?.root===e?n.link.repoName:void 0)??g.get(a(e));r&&g.set(a(e),r);let i=r?{...u,repoName:r}:u;await dx(e,i);let{snapshot:o,result:s}=await EE(e,i,{quiet:!0,restore:!0});d&&await NE(e,l.name),f&&await uS(e),t.stop(),Vx(`${Fx(`✓`)} ${Px(a(e))} ${Q(`(${TE(o)})`)} ${Q(wE(s))}`);for(let e of o.warnings)Vx(Q(` ! ${e}`));p.push(e)}catch(n){t.stop(),Vx(`${Ix(`✗`)} ${Px(a(e))} ${Ox(n)}`)}}if(!p.length)throw new Ux(`No repo was imported.`);if(i){let e=p.map(e=>{let t=g.get(a(e));return t?{path:a(e),name:t}:a(e)}),n=m,r={...u,repos:e,folder:c?n?.root===t&&n.link.folder||ee():void 0};if(await dx(t,r),c)try{let e=await AE(t,r,{quiet:!0});Vx(`${Fx(`✓`)} ${Px(`documents outside the repos`)} ${Q(`${e?.docs??0} docs`)}`)}catch(e){Vx(`${Ix(`✗`)} ${Px(`documents outside the repos`)} ${Ox(e)}`)}d&&!p.includes(t)&&await NE(t,l.name,p.map(a))}let _=tS().portable;d&&(Bx(`🤖`,`Connected Claude Code`),Vx(Q(`.mcp.json the quirl tools`)),Vx(Q(`.claude/settings.json the briefing, loaded as each session starts`)),Vx(Q(`CLAUDE.md when to use Quirl`))),f&&Bx(`🪝`,`Quirl syncs on every ${Px(`git push`)}`);let y=r.length-p.length,b=`.quirl .mcp.json .claude/settings.json CLAUDE.md`;Bx(y?`⚠️ `:`🎉`,y?`Done, but ${y} of ${r.length} repos failed. Fix them and run ${Px(`quirl init`)} again.`:Px(`All set!`)),Vx(d&&!_?Q(`Don't commit ${b} yet: they point at this checkout until the CLI is installed.`):`${Q(`1.`)} Commit what was added${i?` in each repo`:``}: ${Lx(`git add ${b}`)}`),Vx(`${Q(d&&!_?`→`:`2.`)} Start Claude Code here and approve the ${Px(`quirl`)} server when it asks.`),i&&!p.includes(t)&&Vx(Q("Run `quirl sync` here to sync every repo at once.")),console.log(``)}async function NE(e,t,n=[]){await sS(e),await cS(e),await lS(e,t,n)}async function PE(e,t){if(!e.length)throw new Ux(`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 Ux(`No project "${t}" among yours: ${e.map(e=>e.slug).join(`, `)}.`);return n}if(e.length===1)return e[0];Bx(`🗂️ `,`Which project is this part of?`);for(let[t,n]of e.entries())Vx(`${Lx(String(t+1))} ${n.name} ${Q(`· ${n.organization} · ${n.role}`)}`);let n=e[Number(await Wx(` Project [1-${e.length}]: `))-1];if(!n)throw new Ux("No project picked. Run `quirl init --project <slug>`.");return n}const FE=`${Px(`quirl`)} ${Q(Zb)}: connect a repo to Quirl
|
|
364
365
|
|
|
365
366
|
quirl init [--project <slug>] [--hooks|--no-hooks] [--no-claude]
|
|
366
367
|
Link this repo, import it, and connect Claude Code
|
|
@@ -373,4 +374,4 @@ n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2
|
|
|
373
374
|
quirl logout Forget this machine's key
|
|
374
375
|
quirl whoami Show who you're signed in as
|
|
375
376
|
quirl mcp Run the MCP server (used by Claude Code)
|
|
376
|
-
`;async function
|
|
377
|
+
`;async function IE(){let[e,...n]=process.argv.slice(2),{values:r,positionals:i}=t({args:n,allowNegative:!0,allowPositionals:!0,options:{all:{type:`boolean`},project:{type:`string`},hooks:{type:`boolean`},claude:{type:`boolean`},quiet:{type:`boolean`},hook:{type:`boolean`},source:{type:`string`}}});switch(e){case`init`:return ME({project:r.project,hooks:r.hooks,claude:r.claude});case`sync`:return jE({quiet:r.quiet,source:r.source});case`export`:return Xx({dir:i[0],all:r.all});case`context`:return jx({hook:r.hook});case`login`:await dS();return;case`logout`:return await ax(),Rx(`Signed out on this machine.`),zx(Q(`The key still exists until you revoke it under Organization > Access keys in Quirl (${$b().appUrl}).`));case`whoami`:{if(!await rx())throw new Ux("Not signed in. Run `quirl login`.");let e=await new Wr(await ox()).whoami();console.log(Px(e.email));for(let t of e.projects)zx(`${t.name} ${Q(`${t.slug} · ${t.organization} · ${t.role}`)}`);let t=await ux();t&&zx(Q(`This folder: ${t.link.name}`));return}case`mcp`:{let e=await ux();if(!e)throw new Ux("This folder isn't linked to a Quirl project. Run `quirl init`.");return Xb({...await ox(),project:e.link.projectId,version:Zb})}case void 0:case`help`:case`--help`:case`-h`:process.stdout.write(FE);return;case`--version`:case`-v`:return console.log(Zb);default:throw new Ux(`Unknown command "${e}".\n\n${FE}`)}}IE().catch(e=>{let t=e instanceof Ux?e.message:Ox(e);console.error(`${Ix(`✗`)} ${t}`),process.exit(1)});export{};
|