@unbrained/pm-cli 2026.11.25 → 2026.11.26

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.
Files changed (164) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli/commander-usage.js +9 -9
  3. package/dist/cli/error-guidance.js +5 -5
  4. package/dist/cli/help-content.js +4 -4
  5. package/dist/cli/register-setup.js +1 -1
  6. package/dist/cli/runtime/selection.js +1 -1
  7. package/dist/cli-bundle/bundle-manifest.json +1 -1
  8. package/dist/cli-bundle/chunks/{chunk-LPW7S5KA.js → chunk-5AAIRHNE.js} +2 -2
  9. package/dist/cli-bundle/chunks/chunk-5BPDT7G2.js +2 -0
  10. package/dist/cli-bundle/chunks/{chunk-7EPYCU7U.js → chunk-5FY2VHRF.js} +5 -5
  11. package/dist/cli-bundle/chunks/{chunk-YIGBEY7K.js → chunk-7F3UFYZA.js} +2 -2
  12. package/dist/cli-bundle/chunks/chunk-B2GM6KOM.js +2 -0
  13. package/dist/cli-bundle/chunks/chunk-BITDGTAX.js +2 -0
  14. package/dist/cli-bundle/chunks/{chunk-L6VS7F3R.js → chunk-CBBKXTJG.js} +2 -2
  15. package/dist/cli-bundle/chunks/chunk-DUJSME77.js +3 -0
  16. package/dist/cli-bundle/chunks/{chunk-OWK2JL4I.js → chunk-DYL2N3OC.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-GBVF2ZB3.js → chunk-FWBR3OW7.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-OS5W4ZG2.js → chunk-GQXK4KKH.js} +31 -31
  19. package/dist/cli-bundle/chunks/{chunk-FHLOGAGA.js → chunk-HOLQZ56F.js} +2 -2
  20. package/dist/cli-bundle/chunks/chunk-HTGN24XM.js +3 -0
  21. package/dist/cli-bundle/chunks/{chunk-K34FR5CO.js → chunk-IGW3RVJC.js} +2 -2
  22. package/dist/cli-bundle/chunks/{chunk-FVY7U3SU.js → chunk-KCRRTJ4X.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-DF6A7C32.js → chunk-KES4VHU4.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-CZEMEPPQ.js → chunk-LNZKNVMT.js} +2 -2
  25. package/dist/cli-bundle/chunks/chunk-MNFCJNQA.js +35 -0
  26. package/dist/cli-bundle/chunks/{chunk-CONBVY2O.js → chunk-NDS4MXZX.js} +2 -2
  27. package/dist/cli-bundle/chunks/{chunk-BVJMVU4Z.js → chunk-PQSEEVOA.js} +6 -6
  28. package/dist/cli-bundle/chunks/chunk-QMM46SJM.js +4 -0
  29. package/dist/cli-bundle/chunks/chunk-RFK3ERYX.js +2 -0
  30. package/dist/cli-bundle/chunks/chunk-T3GJPXIZ.js +69 -0
  31. package/dist/cli-bundle/chunks/{chunk-CNUFU454.js → chunk-WZOJSHJT.js} +3 -3
  32. package/dist/cli-bundle/chunks/{chunk-C4KIZQHW.js → chunk-XRCE4QNL.js} +2 -2
  33. package/dist/cli-bundle/chunks/{chunk-SCIPT7WF.js → chunk-ZDL45VTB.js} +2 -2
  34. package/dist/cli-bundle/chunks/{field-option-collisions-QE65APSD.js → field-option-collisions-CGRJEAPQ.js} +2 -2
  35. package/dist/cli-bundle/chunks/{item-revision-INDHJV6X.js → item-revision-FGDR5NSF.js} +2 -2
  36. package/dist/cli-bundle/chunks/item-transaction-C3KAMEYO.js +2 -0
  37. package/dist/cli-bundle/chunks/{mutation-actor-KU7BMLUN.js → mutation-actor-HGG47KXV.js} +2 -2
  38. package/dist/cli-bundle/chunks/{mutation-admission-3OMCTQD4.js → mutation-admission-LLHIRY6O.js} +2 -2
  39. package/dist/cli-bundle/chunks/{register-list-query-3GV3LBOT.js → register-list-query-EKSCZWEZ.js} +2 -2
  40. package/dist/cli-bundle/chunks/{register-mutation-GZLF47SX.js → register-mutation-ZIAOKKUJ.js} +2 -2
  41. package/dist/cli-bundle/chunks/{register-operations-PBJZGCAL.js → register-operations-ECVBZ5FM.js} +2 -2
  42. package/dist/cli-bundle/chunks/register-setup-3QYD5H4H.js +2 -0
  43. package/dist/cli-bundle/chunks/{stage-3WIZBD4N.js → stage-RSCSUYEJ.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/{chunk-VU2PH4PF.js → chunk-3BR5NWQI.js} +2 -2
  45. package/dist/cli-bundle/focused-chunks/{chunk-BOIMP2AR.js → chunk-3GQRWIT5.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-X4EWD6TL.js → chunk-AAB3ZR7Z.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-C3FEDTSD.js → chunk-AVLB4L7M.js} +26 -26
  48. package/dist/cli-bundle/focused-chunks/{chunk-5RBC4WSE.js → chunk-FQWKESMI.js} +58 -59
  49. package/dist/cli-bundle/focused-chunks/{chunk-BYQK5DGH.js → chunk-FW5Q26HA.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/chunk-GQBWI4KA.js +2 -0
  51. package/dist/cli-bundle/focused-chunks/{chunk-TQIKDFOD.js → chunk-IWEGGRRD.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/{chunk-ZLRRII55.js → chunk-JUG3BAZZ.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/chunk-KEZ4VXYD.js +2 -0
  54. package/dist/cli-bundle/focused-chunks/{chunk-XKLBTDJ7.js → chunk-NSFS3VWP.js} +3 -3
  55. package/dist/cli-bundle/focused-chunks/{chunk-TRL4JDWX.js → chunk-NXUFVQ33.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/{chunk-YYEWIKNI.js → chunk-QNWNUQSJ.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/chunk-QSRXF6XS.js +15 -0
  58. package/dist/cli-bundle/focused-chunks/{chunk-WVA5KOXF.js → chunk-R6QFPHWW.js} +3 -3
  59. package/dist/cli-bundle/focused-chunks/{chunk-PKX2EHE3.js → chunk-RDELKGLS.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{chunk-3Y5PTQ2F.js → chunk-RFJ3MEFP.js} +2 -2
  61. package/dist/cli-bundle/focused-chunks/{chunk-SXC2EO3E.js → chunk-RMJKVQYE.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/{chunk-UWWAVXG4.js → chunk-TNVLDU7Z.js} +3 -3
  63. package/dist/cli-bundle/focused-chunks/chunk-UA2JNKMY.js +4 -0
  64. package/dist/cli-bundle/focused-chunks/{chunk-7SSGTGZO.js → chunk-VV2QF5IE.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/{chunk-MB56Y4M6.js → chunk-WHHFPATO.js} +2 -2
  66. package/dist/cli-bundle/focused-chunks/{chunk-JOKRDFMQ.js → chunk-YNRW2FWB.js} +2 -2
  67. package/dist/cli-bundle/focused-chunks/{chunk-4LQL4EO6.js → chunk-YSZZSV6M.js} +2 -2
  68. package/dist/cli-bundle/focused-chunks/{field-option-collisions-5ROXGUME.js → field-option-collisions-WV6GPYYP.js} +2 -2
  69. package/dist/cli-bundle/focused-chunks/{item-revision-KYMSQVZE.js → item-revision-RPTXN7WW.js} +2 -2
  70. package/dist/cli-bundle/focused-chunks/{item-transaction-I4HLVHEJ.js → item-transaction-A6MVNPT7.js} +2 -2
  71. package/dist/cli-bundle/focused-chunks/{mutation-actor-GGOQKAE6.js → mutation-actor-6ZVW6OME.js} +2 -2
  72. package/dist/cli-bundle/focused-chunks/{mutation-admission-OS36ZCMH.js → mutation-admission-2DA4CINP.js} +2 -2
  73. package/dist/cli-bundle/focused-chunks/{stage-4ZFWJUKO.js → stage-RG3PKST7.js} +2 -2
  74. package/dist/cli-bundle/main.js +26 -26
  75. package/dist/cli-bundle/sdk-authoring.js +1 -1
  76. package/dist/cli-bundle/sdk-contracts.js +4 -4
  77. package/dist/cli-bundle/sdk-core.js +1 -1
  78. package/dist/cli-bundle/sdk-governance.js +1 -1
  79. package/dist/cli-bundle/sdk-graph.js +1 -1
  80. package/dist/cli-bundle/sdk-merge.js +63 -63
  81. package/dist/cli-bundle/sdk-query.js +1 -1
  82. package/dist/cli-bundle/sdk-runtime.js +1 -1
  83. package/dist/cli-bundle/sdk-testing.js +1 -1
  84. package/dist/cli-bundle/sdk.js +11 -11
  85. package/dist/core/reproducibility/context.d.ts +2 -0
  86. package/dist/core/reproducibility/context.js +1 -1
  87. package/dist/sdk/cli-bootstrap.d.ts +17 -0
  88. package/dist/sdk/cli-bootstrap.js +1 -1
  89. package/dist/sdk/cli-contracts/command-aliases.js +1 -1
  90. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  91. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  92. package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
  93. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  94. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  95. package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
  96. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  97. package/dist/sdk/cli-contracts.d.ts +1 -1
  98. package/dist/sdk/cli-contracts.js +1 -1
  99. package/dist/sdk/completion/shared.d.ts +1 -1
  100. package/dist/sdk/completion/shared.js +1 -1
  101. package/dist/sdk/extension/bundled-catalog.js +1 -1
  102. package/dist/sdk/extension/install-sources.js +5 -5
  103. package/dist/sdk/extension/listing-fields.d.ts +15 -0
  104. package/dist/sdk/extension/listing-fields.js +2 -0
  105. package/dist/sdk/extension/managed-update-status.js +1 -1
  106. package/dist/sdk/extension/npm-spec.d.ts +18 -0
  107. package/dist/sdk/extension/npm-spec.js +2 -0
  108. package/dist/sdk/extension/static-inventory.d.ts +53 -1
  109. package/dist/sdk/extension/static-inventory.js +1 -1
  110. package/dist/sdk/extension/update-check.js +1 -1
  111. package/dist/sdk/extension/update-observations.js +3 -0
  112. package/dist/sdk/extension/upgrade-hints.js +2 -0
  113. package/dist/sdk/extension.d.ts +2 -0
  114. package/dist/sdk/extension.js +1 -1
  115. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  116. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  117. package/dist/sdk/governance/upgrade.d.ts +7 -2
  118. package/dist/sdk/governance/upgrade.js +2 -2
  119. package/dist/sdk/index.d.ts +1 -1
  120. package/dist/sdk/public-surface.json +1 -1
  121. package/dist/sdk/query/context.d.ts +20 -7
  122. package/dist/sdk/query/context.js +4 -2
  123. package/dist/sdk/runtime-input.js +1 -1
  124. package/dist/sdk/testing.d.ts +20 -2
  125. package/docs/COMMANDS.md +19 -1
  126. package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +6 -0
  127. package/docs/EXTENSION_LIFECYCLE.md +72 -2
  128. package/docs/SDK.md +21 -2
  129. package/marketplace.json +1 -1
  130. package/package.json +1 -1
  131. package/packages/pm-beads/package.json +1 -1
  132. package/packages/pm-calendar/package.json +1 -1
  133. package/packages/pm-command-kit/package.json +1 -1
  134. package/packages/pm-digital-twin/package.json +1 -1
  135. package/packages/pm-governance-audit/package.json +1 -1
  136. package/packages/pm-guide-shell/package.json +1 -1
  137. package/packages/pm-kanban/package.json +1 -1
  138. package/packages/pm-lifecycle-hooks/package.json +1 -1
  139. package/packages/pm-linked-test-adapters/package.json +1 -1
  140. package/packages/pm-search-advanced/package.json +1 -1
  141. package/packages/pm-templates/package.json +1 -1
  142. package/packages/pm-todos/package.json +1 -1
  143. package/packages/pm-vcs/package.json +1 -1
  144. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  145. package/plugins/pm-claude/package.json +1 -1
  146. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  147. package/plugins/pm-codex/package.json +1 -1
  148. package/plugins/pm-codex/plugin.json +1 -1
  149. package/runtime-dependencies.json +1 -1
  150. package/dist/cli-bundle/chunks/chunk-4FZH5BTV.js +0 -2
  151. package/dist/cli-bundle/chunks/chunk-GZI7ZAB7.js +0 -2
  152. package/dist/cli-bundle/chunks/chunk-LOX3VY4T.js +0 -2
  153. package/dist/cli-bundle/chunks/chunk-VA4T37Q4.js +0 -70
  154. package/dist/cli-bundle/chunks/chunk-WQOEVGLQ.js +0 -2
  155. package/dist/cli-bundle/chunks/chunk-XHCIOLJP.js +0 -3
  156. package/dist/cli-bundle/chunks/chunk-XKWJONAO.js +0 -2
  157. package/dist/cli-bundle/chunks/chunk-ZBOQEZ2H.js +0 -33
  158. package/dist/cli-bundle/chunks/chunk-ZLICQPRG.js +0 -3
  159. package/dist/cli-bundle/chunks/item-transaction-LCKK4XXB.js +0 -2
  160. package/dist/cli-bundle/chunks/register-setup-ZLJEF6NZ.js +0 -2
  161. package/dist/cli-bundle/focused-chunks/chunk-A4R57E4K.js +0 -2
  162. package/dist/cli-bundle/focused-chunks/chunk-IAOKVKWW.js +0 -2
  163. package/dist/cli-bundle/focused-chunks/chunk-VMYVN36N.js +0 -13
  164. package/dist/cli-bundle/focused-chunks/chunk-WL2R7T5G.js +0 -2
@@ -0,0 +1,4 @@
1
+ import{b as ne}from"./chunk-NDS4MXZX.js";import{Va as K,Xa as Q,Za as Z,_a as ee}from"./chunk-KCRRTJ4X.js";import{I as te,v as Y}from"./chunk-XRCE4QNL.js";import{Ag as X,Dc as G,Dh as J,Hc as H,Nb as z,Ng as W,Pf as j,Rf as V,Sf as B,V as $,ab as F,ba as D,hh as q,sc as P,ta as U}from"./chunk-WZOJSHJT.js";import{O as L,Q as y}from"./chunk-DUJSME77.js";import{A as c,C as u,E as k,G as E,K as C}from"./chunk-6OIHST4I.js";function ft(t,e){let n=H(t),r=t.length>0?t[t.length-1].after_hash:B(),i=e===void 0||n.item_hash_version===void 0?void 0:V(e,n.item_hash_version,F(t.at(-1)?.hash_algorithm)),a=e===void 0?void 0:i===void 0?j(e):i[Math.max(0,i.indexOf(r))],o=a===void 0?void 0:a===r,s=[...n.errors];return o===!1&&s.push("verify_failed:current_item_hash_mismatch"),{ok:s.length===0,entries:t.length,errors:s,latest_after_hash:t.length>0?t[t.length-1].after_hash:void 0,current_item_hash:a,current_matches_latest:o}}async function _t(t,e,n={}){let r=D(n.cwd??process.cwd(),n.pmRoot);await te(r);let i=await Y(r),a=$(i,J()),o=await ne(r,t,i,a.type_to_folder),s=await P(o.historyPath,o.id);if(s.length===0)throw new u(`No history exists for ${o.id}; point-in-time reads are unavailable.`,c.NOT_FOUND);let p=Q(e,s),x=ee(Z(s,p.historyIndex),p),f=G(x,{schema:i.schema});if(f.metadata.id!==o.id)throw new u(`History target resolved to item ${f.metadata.id}, expected ${o.id}.`,c.GENERIC_FAILURE);let _=s[p.historyIndex],m=K(s,!0);return{document:f,reconstructed:!0,as_of_version:m===null?null:m+p.historyIndex+1,as_of_timestamp:_.ts,target:p,history_length:s.length}}import re from"node:fs/promises";import S from"node:path";function ie(t){return[...new Set(t.map(e=>e.trim()).filter(e=>e.length>0))].sort((e,n)=>e.localeCompare(n))}function l(t){return t.trim().toLowerCase()}function Dt(t){let e=t.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-"),n=0;for(;e[n]==="-";)n+=1;let r=e.length;for(;r>n&&e[r-1]==="-";)r-=1;let i=e.slice(n,r);if(i.length===0)throw new u("Extension manifest name must resolve to a non-empty directory name.",c.USAGE);if(i==="."||i==="..")throw new u('Extension manifest name must not resolve to "." or "..".',c.USAGE);return i}function ye(t){return W(t)}async function ge(t){try{let e=JSON.parse(await re.readFile(S.join(t,"package.json"),"utf8")),n=typeof e.name=="string"&&/^(?:@[a-z0-9._~-]+\/)?[a-z0-9._~-]+$/iu.test(e.name)?e.name:void 0;return{...n?{package_name:n}:{},has_build_script:["build","prepare","prepack"].some(r=>typeof e.scripts?.[r]=="string")}}catch{return{has_build_script:!1}}}async function Ee(t,e,n){if(n.source_kind!=="github"||typeof n.source_root!="string")return new u(`Extension entry file is missing at "${e}".`,c.USAGE);let r=await ge(n.source_root),i=r.package_name?`pm package install npm:${r.package_name}`:void 0,a=n.source_input??n.source_root;return new u(`Extension entry "${t.entry}" is absent from GitHub source "${a}". pm package install copies GitHub repositories without running package scripts${r.has_build_script?", and this package declares a build or publish script":""}. ${i?`Try "${i}" if the package is published, or install a locally built directory.`:"Build the source locally and install that directory, or use its published npm: package."}`,c.USAGE,{code:"github_source_entry_unbuilt",required:"Use a GitHub tree with committed runtime output, a published npm artifact, or a locally built source directory.",why:"GitHub installation is a source copy and never executes untrusted package build scripts.",examples:i?[i,`pm package install ${n.source_root}`]:[`pm package install ${n.source_root}`],nextSteps:i?[`Retry with ${i}.`,"Or build the repository locally, then install its directory."]:["Build the repository locally, then install its directory.","If it is published, retry with pm package install npm:<package-name>."],recovery:{attempted_command:`pm install ${a}`,normalized_args:["install",a],...i?{next_best_command:i}:{}}})}async function Ut(t,e={}){let n=S.join(t,"manifest.json");if(!await k(n))throw new u(`Extension manifest is missing at "${n}".`,c.USAGE);let r;try{r=JSON.parse(await re.readFile(n,"utf8"))}catch(o){throw new u(`Failed to parse extension manifest at "${n}": ${ve(o)}`,c.USAGE)}let i=ye(r);if(!i)throw new u(`Extension manifest at "${n}" is invalid.`,c.USAGE);let a=S.resolve(t,i.entry);if(!U(t,a))throw new u(`Extension entry "${i.entry}" resolves outside extension directory "${t}".`,c.USAGE);if(!await k(a))throw await Ee(i,a,e);if(!await q(t,a))throw new u(`Extension entry "${i.entry}" resolves outside extension directory after symlink resolution.`,c.USAGE);return{directory:t,manifest_path:n,entry_path:a,manifest:i}}function ve(t){return t instanceof Error?t.message:String(t)}import A from"node:fs/promises";import be from"node:path";var we=".managed-extensions.json",v=1;function b(t){return be.join(t,we)}function xe(){return{version:v,updated_at:y(),entries:[]}}function M(t){return[...t].sort((e,n)=>{let r=e.scope.localeCompare(n.scope);if(r!==0)return r;let i=e.name.localeCompare(n.name);return i!==0?i:e.directory.localeCompare(n.directory)})}function Xt(t,e){return t.kind!==e.kind||t.input!==e.input||t.location!==e.location?!1:t.kind==="npm"&&e.kind==="npm"?t.package===e.package&&t.version===e.version:t.kind==="github"&&e.kind==="github"?t.repository===e.repository&&t.ref===e.ref&&t.subpath===e.subpath&&t.commit===e.commit:t.kind==="builtin"&&e.kind==="builtin"?t.name===e.name:!0}function d(t){return typeof t=="string"?t:void 0}var ke=/^(?:npm_registry|github_remote)_lookup_timed_out$/u;function Se(t,e){let n=d(e);return n===void 0||t.kind!=="github"||n.trim().length===0||/^[a-z0-9_]+$/u.test(n.trim())?n:"github_remote_lookup_failed"}function ae(t){return typeof t=="string"&&ke.test(t.trim())}function Ae(t,e){return ae(t)&&typeof e=="number"&&Number.isSafeInteger(e)&&e>0?{update_check_timeout_ms:e}:{}}function Me(t){return typeof t.name=="string"&&t.name.trim().length>0&&typeof t.directory=="string"&&t.directory.trim().length>0&&(t.scope==="project"||t.scope==="global")&&typeof t.manifest_version=="string"&&typeof t.manifest_entry=="string"&&Array.isArray(t.capabilities)&&t.capabilities.every(e=>typeof e=="string")&&typeof t.installed_at=="string"&&typeof t.updated_at=="string"}function Ie(t){if(typeof t!="object"||t===null)return null;let e=t;return e.kind!=="local"&&e.kind!=="github"&&e.kind!=="npm"&&e.kind!=="builtin"||typeof e.input!="string"||typeof e.location!="string"?null:{kind:e.kind,input:e.input,location:e.location,name:d(e.name),package:d(e.package),version:d(e.version),repository:d(e.repository),owner:d(e.owner),repo:d(e.repo),ref:d(e.ref),subpath:d(e.subpath),commit:d(e.commit)}}function Ne(t){if(typeof t!="object"||t===null)return null;let e=t;if(!Me(e))return null;let n=Ie(e.source);if(!n)return null;let r=X(e.contributions);return r===null?null:{name:e.name.trim(),directory:e.directory.trim(),scope:e.scope,manifest_version:e.manifest_version,manifest_entry:e.manifest_entry,capabilities:ie(e.capabilities),contributions:r,installed_at:e.installed_at,updated_at:e.updated_at,source:n,last_update_check_at:d(e.last_update_check_at),last_update_remote_commit:d(e.last_update_remote_commit),last_update_remote_version:d(e.last_update_remote_version),update_available:ae(e.update_error)?null:typeof e.update_available=="boolean"||e.update_available===null?e.update_available:void 0,update_error:Se(n,e.update_error),...Ae(e.update_error,e.update_check_timeout_ms)}}function I(t){if(typeof t!="object"||t===null)return null;let e=t;if(e.version!==v||!Array.isArray(e.entries))return null;let n=[];for(let r of e.entries){let i=Ne(r);i&&n.push(i)}return{version:v,updated_at:d(e.updated_at)??y(),entries:M(n)}}async function Wt(t){let e=b(t),n=xe();try{let r=await A.readFile(e,"utf8"),i=JSON.parse(r),a=I(i);if(!a)throw new u(`Managed extension state file "${e}" has an invalid schema. Repair or remove it before mutating extension state.`,c.GENERIC_FAILURE);return{path:e,state:a,warnings:[]}}catch(r){if(r instanceof u)throw r;if(typeof r=="object"&&r!==null&&"code"in r&&E(r))return{path:e,state:n,warnings:[]};throw new u(`Managed extension state file "${e}" could not be read. Repair or remove it before mutating extension state.`,c.GENERIC_FAILURE)}}async function Oe(t,e){let n=b(t),r={version:v,updated_at:y(),entries:M(e.entries)};await A.mkdir(t,{recursive:!0}),await A.writeFile(n,`${JSON.stringify(r,null,2)}
2
+ `,"utf8")}function Te(t,e){let n=t.entries.filter(r=>l(r.name)!==l(e.name)&&l(r.directory)!==l(e.directory));return n.push(e),{...t,updated_at:y(),entries:M(n)}}async function qt(t,e,n,r){let i=e.entries.find(o=>l(o.name)===l(n));if(!i)return e;let a=Te(e,{...i,contributions:r});return await Oe(t,a),a}import oe from"npm-package-arg";import N from"semver";var Re=new Set(["tag","version","range"]);function Ce(t){try{let e=oe(t),n=e.subSpec;return e.type==="alias"?n?.type:e.type}catch{return}}function O(t){if(t.kind!=="npm")return!1;let e=t.input.startsWith("npm:")?t.input.slice(4).trim():t.input.trim(),n=Ce(e);return n!==void 0&&Re.has(n)}function T(t){try{return oe.resolve("pm-version-probe",t).type==="version"}catch{return!1}}function se(t,e){let n=N.parse(t,{loose:!0}),r=N.parse(e,{loose:!0});return n===null||r===null?t!==e:N.gt(n,r)}import{constants as ce}from"node:fs";import w from"node:fs/promises";import h from"node:path";var $e="extension-update-observations.json",de=1,De=64*1024,Ue=16*1024*1024,le=1024*1024,Le=300*1e3,ue=2e3;function pe(t){return h.join(t,"runtime",$e)}var me=256;function g(t,e){let n=t[e];return typeof n=="string"&&n.length>0&&n.length<=me?n:void 0}function Fe(t){let e=Date.parse(t);return Number.isFinite(e)&&e<=Date.now()+Le}function ze(t){return t.remote_version===void 0||t.remote_version===null?null:g(t,"remote_version")}function Pe(t){if(typeof t!="object"||t===null||Array.isArray(t))return;let e=t,n=g(e,"name"),r=g(e,"installed_version"),i=g(e,"installed_updated_at"),a=g(e,"checked_at"),o=ze(e);if(!(n===void 0||r===void 0||i===void 0||o===void 0)&&!(a===void 0||!Fe(a)||typeof e.update_available!="boolean"))return{name:n,installed_version:r,installed_updated_at:i,remote_version:o,update_available:e.update_available,checked_at:a}}var Ge=".stale-cleanup",He=64*1024;async function je(t){try{let e=await w.lstat(t);return!e.isFile()||e.size>He}catch{return!1}}async function fe(t){try{return!(await w.lstat(t)).isDirectory()}catch{return!1}}async function Ve(t){let e=pe(t);try{if(await fe(h.dirname(e)))return[];let n=await _e(e,le);if(n===void 0)return[];let r=JSON.parse(n),i=typeof r=="object"&&r!==null?r:{};return(i.version===de&&Array.isArray(i.observations)?i.observations:[]).flatMap(o=>Pe(o)??[])}catch{return[]}}function Be(t=ce,e=!1){return t.O_RDONLY|(e?0:t.O_NOFOLLOW??0)|(t.O_NONBLOCK??0)}async function _e(t,e,n={}){if(n.followLinks!==!0&&!(await w.lstat(t)).isFile())return;let r=await w.open(t,Be(ce,n.followLinks===!0));try{if(!(await r.stat()).isFile())return;let i=Buffer.alloc(Math.min(De,e+1)),a=[],o=0;for(;o<=e;){let{bytesRead:s}=await r.read(i,0,Math.min(i.length,e+1-o),o);if(s===0)break;a.push(Buffer.from(i.subarray(0,s))),o+=s}return o>e?void 0:Buffer.concat(a,o).toString("utf8")}finally{await r.close()}}function Xe(t){return t.flatMap(e=>typeof e.last_update_check_at=="string"&&e.update_error===void 0&&typeof e.update_available=="boolean"&&(e.source.kind==="github"||O(e.source))&&[e.name,e.manifest_version,e.updated_at,e.last_update_remote_version??""].every(n=>n.length<=me)?[{name:e.name,installed_version:e.manifest_version,installed_updated_at:e.updated_at,remote_version:e.last_update_remote_version??e.last_update_remote_commit?.slice(0,12)??null,update_available:e.update_available,checked_at:e.last_update_check_at}]:[]).sort((e,n)=>e.name.localeCompare(n.name))}async function We(t){let e;try{e=await _e(b(t),Ue,{followLinks:!0})}catch(n){return E(n)?[]:void 0}if(e!==void 0)try{let n=JSON.parse(e),r=I(n),i=n.entries;return r!==null&&Array.isArray(i)&&i.length===r.entries.length?r.entries:void 0}catch{return}}function R(t){let e=new Map;for(let n of t){let r=`${l(n.name)}\0${n.installed_version}\0${n.installed_updated_at}`,i=e.get(r);(i===void 0||Date.parse(i.checked_at)<=Date.parse(n.checked_at))&&e.set(r,n)}return[...e.values()]}function qe(t,e){return l(t.name)===l(e.name)&&t.installed_version===e.manifest_version&&t.installed_updated_at===e.updated_at}async function Je(t,e,n){if(n.length===0)return;let r=pe(t),i=async()=>{if(await fe(h.dirname(r)))throw new Error(`${h.dirname(r)} is not a directory`)};await i();let a=h.join(t,"locks","extension-update-observations.lock");for(let s of[a,h.join(`${a}${Ge}`,"owner.json")])if(await je(s))throw new Error("update observation lock metadata is not a small regular file");let o=await z(t,"extension-update-observations",30,"pm package manage",!1,!1,ue,{maxWaitMs:ue});try{await i();let s=[...await Ve(t),...n],p=await We(e),x=(p===void 0?R(s):p.flatMap(_=>R(s.filter(m=>qe(m,_)&&he(m,_.source))))).sort((_,m)=>_.name.localeCompare(m.name)),f=`${JSON.stringify({version:de,observations:x},null,2)}
3
+ `;if(Buffer.byteLength(f,"utf8")>le)throw new Error("update observation record exceeds its size limit");await o.fence(()=>C(r,f))}finally{await o.release()}}async function dn(t,e,n,r){if(!(r||L()))try{await Je(t,e,Xe(n));return}catch(i){let a=i?.context?.code;return typeof a=="string"&&a.length>0?`extension_update_observation_write_failed:${a}`:"extension_update_observation_write_failed"}}function ln(t,e){if(typeof e.version!="string"||e.updated_at===void 0)return;let n=l(e.name);return R(t.filter(r=>l(r.name)===n&&r.installed_version===e.version&&r.installed_updated_at===e.updated_at&&he(r,e.source)))[0]}function Ye(t,e){let n=e?.trim().toLowerCase(),r=t.remote_version?.toLowerCase();return!n||r===void 0||!/^[0-9a-f]{7,40}$/u.test(r)?!1:n.startsWith(r)!==t.update_available}function he(t,e){return e===void 0?!0:e.kind==="github"?Ye(t,e.commit):O(e)?typeof e.version=="string"&&T(e.version)&&t.remote_version!==null&&T(t.remote_version)&&se(t.remote_version,e.version)===t.update_available:t.update_available===!1}function pn(t){return t?.update_available===!0?t.remote_version??"available":null}export{ft as a,_t as b,ie as c,l as d,Dt as e,ye as f,Ut as g,b as h,M as i,Xt as j,I as k,Wt as l,Oe as m,Te as n,qt as o,O as p,se as q,Ve as r,_e as s,We as t,dn as u,ln as v,pn as w};
4
+ //# sourceMappingURL=chunk-QMM46SJM.js.map
@@ -0,0 +1,2 @@
1
+ import{ad as r}from"./chunk-GQXK4KKH.js";import{sa as t}from"./chunk-KCRRTJ4X.js";function i(o,n,p){return r(o,t(n),p)}export{i as a};
2
+ //# sourceMappingURL=chunk-RFK3ERYX.js.map