@unbrained/pm-cli 2026.11.24 → 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.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli/commander-usage.js +9 -9
- package/dist/cli/error-guidance.js +5 -5
- package/dist/cli/help-content.js +4 -4
- package/dist/cli/register-setup.js +1 -1
- package/dist/cli/runtime/selection.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-WWTPNIC2.js → chunk-5AAIRHNE.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-5BPDT7G2.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ZYCOM4MS.js → chunk-5FY2VHRF.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-YYT3MIRF.js → chunk-6OIHST4I.js} +1 -1
- package/dist/cli-bundle/chunks/chunk-7F3UFYZA.js +2 -0
- package/dist/cli-bundle/chunks/chunk-B2GM6KOM.js +2 -0
- package/dist/cli-bundle/chunks/chunk-BITDGTAX.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-DQDRA3SW.js → chunk-CBBKXTJG.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-DUJSME77.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-37UDIJ2K.js → chunk-DYL2N3OC.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VJSGUXGU.js → chunk-FWBR3OW7.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-GQXK4KKH.js +31 -0
- package/dist/cli-bundle/chunks/{chunk-ZOX4SWRL.js → chunk-HOLQZ56F.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-HTGN24XM.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-PW7U7WCE.js → chunk-IGW3RVJC.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-KCRRTJ4X.js +125 -0
- package/dist/cli-bundle/chunks/{chunk-Z7MFVRDV.js → chunk-KES4VHU4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-D6PDUKUG.js → chunk-KHFUHGL3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HNKK2UG6.js → chunk-LNZKNVMT.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-5DUP4AZA.js → chunk-MGJMQSN4.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-MNFCJNQA.js +35 -0
- package/dist/cli-bundle/chunks/{chunk-PQUBVRV5.js → chunk-NDS4MXZX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TVIJ2VCU.js → chunk-PQSEEVOA.js} +6 -6
- package/dist/cli-bundle/chunks/chunk-QMM46SJM.js +4 -0
- package/dist/cli-bundle/chunks/chunk-RFK3ERYX.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-7X253M6Z.js → chunk-SX76UGEY.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-T3GJPXIZ.js +69 -0
- package/dist/cli-bundle/chunks/{chunk-FXJYZBWV.js → chunk-WZOJSHJT.js} +40 -40
- package/dist/cli-bundle/chunks/{chunk-23K6DQQY.js → chunk-XRCE4QNL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-SSALO4DB.js → chunk-ZDL45VTB.js} +2 -2
- package/dist/cli-bundle/chunks/{field-option-collisions-W66HSWMK.js → field-option-collisions-CGRJEAPQ.js} +2 -2
- package/dist/cli-bundle/chunks/{indexed-receipt-blobs-BPYKN5Q7.js → indexed-receipt-blobs-H3MMNXXG.js} +2 -2
- package/dist/cli-bundle/chunks/{item-revision-D3LSBNIR.js → item-revision-FGDR5NSF.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-C3KAMEYO.js +2 -0
- package/dist/cli-bundle/chunks/{mutation-actor-OKL3CQVX.js → mutation-actor-HGG47KXV.js} +2 -2
- package/dist/cli-bundle/chunks/mutation-admission-LLHIRY6O.js +2 -0
- package/dist/cli-bundle/chunks/{register-list-query-3LBV6CS2.js → register-list-query-EKSCZWEZ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-72AGTMNE.js → register-mutation-ZIAOKKUJ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-XERFG2SH.js → register-operations-ECVBZ5FM.js} +2 -2
- package/dist/cli-bundle/chunks/register-setup-3QYD5H4H.js +2 -0
- package/dist/cli-bundle/chunks/{runtime-schema-JP2KBHBY.js → runtime-schema-Y4SHTEXL.js} +2 -2
- package/dist/cli-bundle/chunks/{settlement-hook-6MR32OOC.js → settlement-hook-ESAAEBRM.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-T2LKWN7C.js → stage-RSCSUYEJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LMU7DDOA.js → chunk-3BR5NWQI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-46MP7IZN.js → chunk-3GQRWIT5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RIE3SJSE.js → chunk-4SX2BN4V.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RLO2HCZT.js → chunk-AAB3ZR7Z.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-AVLB4L7M.js +44 -0
- package/dist/cli-bundle/focused-chunks/{chunk-B6BNHKUW.js → chunk-FQWKESMI.js} +58 -59
- package/dist/cli-bundle/focused-chunks/{chunk-GXP7Q4XM.js → chunk-FW5Q26HA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-GQBWI4KA.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-3ELVASVA.js → chunk-IWEGGRRD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-Z7W2RQIB.js → chunk-JUG3BAZZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-KEZ4VXYD.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-A6VEMCRR.js → chunk-NGFDPEP7.js} +1 -1
- package/dist/cli-bundle/focused-chunks/{chunk-SMMOZ3H3.js → chunk-NSFS3VWP.js} +37 -37
- package/dist/cli-bundle/focused-chunks/{chunk-OZOCEB2Q.js → chunk-NXUFVQ33.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RIQUIHYU.js → chunk-OCKKIECS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UVTUX54T.js → chunk-QNWNUQSJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-QSRXF6XS.js +15 -0
- package/dist/cli-bundle/focused-chunks/chunk-R6QFPHWW.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-24VRBNKE.js → chunk-RDELKGLS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-RFJ3MEFP.js +27 -0
- package/dist/cli-bundle/focused-chunks/{chunk-C7WHWI7K.js → chunk-RMJKVQYE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-3OCDKITJ.js → chunk-TNVLDU7Z.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-UA2JNKMY.js +4 -0
- package/dist/cli-bundle/focused-chunks/chunk-VV2QF5IE.js +91 -0
- package/dist/cli-bundle/focused-chunks/{chunk-HL47UQZJ.js → chunk-WHHFPATO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YD66IRSL.js → chunk-YNRW2FWB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-XDBHD4CY.js → chunk-YSZZSV6M.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{field-option-collisions-UODPSV6W.js → field-option-collisions-WV6GPYYP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-EGEJMG3G.js → indexed-receipt-blobs-PG2VJ3MB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-revision-QH7RNBX4.js → item-revision-RPTXN7WW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-transaction-ZO72OINF.js → item-transaction-A6MVNPT7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-actor-PHVLKG4I.js → mutation-actor-6ZVW6OME.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-ZSG5OECH.js → mutation-admission-2DA4CINP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{runtime-schema-6RQMIDTN.js → runtime-schema-YXPYDD2C.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{settlement-hook-FMLGKG7J.js → settlement-hook-4MGRERCT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-AQMKRVX4.js → stage-RG3PKST7.js} +2 -2
- package/dist/cli-bundle/main.js +26 -26
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +4 -4
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +63 -63
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +12 -12
- package/dist/core/reproducibility/context.d.ts +2 -0
- package/dist/core/reproducibility/context.js +1 -1
- package/dist/core/shared/command-line.d.ts +54 -4
- package/dist/core/shared/command-line.js +1 -1
- package/dist/core/shared/errors.d.ts +9 -0
- package/dist/core/shared/secret-rules.js +5 -5
- package/dist/core/shared/url-credentials.d.ts +16 -3
- package/dist/core/shared/url-credentials.js +1 -1
- package/dist/core/store/item-store.d.ts +26 -4
- package/dist/core/store/item-store.js +1 -1
- package/dist/sdk/cli-bootstrap.d.ts +17 -0
- package/dist/sdk/cli-bootstrap.js +1 -1
- package/dist/sdk/cli-contracts/command-aliases.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +1 -1
- package/dist/sdk/command-line.d.ts +1 -1
- package/dist/sdk/command-line.js +1 -1
- package/dist/sdk/completion/shared.d.ts +1 -1
- package/dist/sdk/completion/shared.js +1 -1
- package/dist/sdk/context-intent-contracts.js +1 -1
- package/dist/sdk/extension/bundled-catalog.js +1 -1
- package/dist/sdk/extension/install-sources.js +5 -5
- package/dist/sdk/extension/listing-fields.d.ts +15 -0
- package/dist/sdk/extension/listing-fields.js +2 -0
- package/dist/sdk/extension/managed-update-status.js +1 -1
- package/dist/sdk/extension/npm-spec.d.ts +18 -0
- package/dist/sdk/extension/npm-spec.js +2 -0
- package/dist/sdk/extension/static-inventory.d.ts +53 -1
- package/dist/sdk/extension/static-inventory.js +1 -1
- package/dist/sdk/extension/update-check.js +1 -1
- package/dist/sdk/extension/update-observations.js +3 -0
- package/dist/sdk/extension/upgrade-hints.js +2 -0
- package/dist/sdk/extension.d.ts +2 -0
- package/dist/sdk/extension.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/governance/tracked-runtime-cache.js +1 -1
- package/dist/sdk/governance/upgrade.d.ts +7 -2
- package/dist/sdk/governance/upgrade.js +2 -2
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/lifecycle/claim.d.ts +21 -1
- package/dist/sdk/lifecycle/claim.js +1 -1
- package/dist/sdk/lifecycle/task-composition.js +1 -1
- package/dist/sdk/ownership-source.d.ts +15 -1
- package/dist/sdk/ownership-source.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/context.d.ts +20 -7
- package/dist/sdk/query/context.js +4 -2
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/testing.d.ts +20 -2
- package/docs/AGENT_GUIDE.md +2 -2
- package/docs/COMMANDS.md +19 -1
- package/docs/CONFIGURATION.md +1 -0
- package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +6 -0
- package/docs/EXTENSION_LIFECYCLE.md +72 -2
- package/docs/MUTATION_INTEGRITY.md +97 -8
- package/docs/SDK.md +61 -5
- package/docs/WORKSPACE_POSITION_AND_LIFECYCLE.md +17 -4
- package/marketplace.json +1 -1
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-7IROAPWI.js +0 -3
- package/dist/cli-bundle/chunks/chunk-7VRFEURZ.js +0 -33
- package/dist/cli-bundle/chunks/chunk-AWB5KBJS.js +0 -2
- package/dist/cli-bundle/chunks/chunk-I2OJ5B4A.js +0 -2
- package/dist/cli-bundle/chunks/chunk-I3BFCKZR.js +0 -2
- package/dist/cli-bundle/chunks/chunk-MXUSC5RS.js +0 -31
- package/dist/cli-bundle/chunks/chunk-PLIUU37C.js +0 -3
- package/dist/cli-bundle/chunks/chunk-STOOTHZZ.js +0 -2
- package/dist/cli-bundle/chunks/chunk-TKRY22SO.js +0 -2
- package/dist/cli-bundle/chunks/chunk-XFADNMGD.js +0 -2
- package/dist/cli-bundle/chunks/chunk-YOPTAIBD.js +0 -125
- package/dist/cli-bundle/chunks/chunk-YW2HBHRO.js +0 -70
- package/dist/cli-bundle/chunks/item-transaction-M6NTBYH3.js +0 -2
- package/dist/cli-bundle/chunks/mutation-admission-EKPEOZMF.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-W22L34Z4.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3GT4A3ZN.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-3Z7MCUJM.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-5LDBS6MS.js +0 -91
- package/dist/cli-bundle/focused-chunks/chunk-EUQGZPGO.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-FDZPRJXJ.js +0 -27
- package/dist/cli-bundle/focused-chunks/chunk-LMFIAQ2V.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-Q2HY44LV.js +0 -13
- package/dist/cli-bundle/focused-chunks/chunk-REFMQY47.js +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{execFile as J}from"node:child_process";import l from"node:fs/promises";import k from"node:os";import c from"node:path";import{fileURLToPath as
|
|
2
|
-
${r}`,p.GENERIC_FAILURE)}}function ne(e=process.platform){return e==="win32"?"npm.cmd":"npm"}function ae(e=process.platform){return e==="win32"}async function
|
|
3
|
-
${f}`,p.GENERIC_FAILURE)}}function
|
|
4
|
-
`,"utf8");try{await Promise.all([l.rm(c.join(e,"package-lock.json"),{force:!0}),l.rm(c.join(e,"npm-shrinkwrap.json"),{force:!0})]),r.length>0&&await n(["install","--ignore-scripts","--no-audit","--fund=false","--package-lock=false","--no-save","--omit=peer","--"],e),o&&await
|
|
5
|
-
`,"utf8")}}function
|
|
1
|
+
import{execFile as J}from"node:child_process";import l from"node:fs/promises";import k from"node:os";import c from"node:path";import{fileURLToPath as q}from"node:url";import{promisify as T}from"node:util";import v from"npm-package-arg";import{extract as H,list as K}from"tar";import{collectPackageExtensionDirectories as V}from"../../core/packages/manifest.js";import{resolvePmPackageRootFromModule as Z}from"../../core/packages/root.js";import{pathExists as m}from"../../core/fs/fs-utils.js";import{isPathWithinDirectory as Q}from"../../core/fs/path-utils.js";import{EXIT_CODE as p}from"../../core/shared/constants.js";import{PmCliError as d}from"../../core/shared/errors.js";import{listBundledPackageAliases as X}from"./bundled-catalog.js";const j=T(J),y="@unbrained/pm-cli",Y={maxArchiveBytes:64*1024*1024,maxEntries:4096,maxExpandedBytes:256*1024*1024,maxEntryBytes:64*1024*1024};let b;async function ee(e,n=process.cwd()){const t=e.trim();if(!/^(@[^/\\\s]+\/[^/\\\s]+|[^@/\\\s][^/\\\s]*)$/u.test(t))return null;let a=c.resolve(n);for(;;){const i=c.join(a,"node_modules",...t.split("/")),r=c.join(i,"package.json");if(await m(r))try{const s=JSON.parse(await l.readFile(r,"utf8"));if(s.name===t)return{package:t,...typeof s.version=="string"?{version:s.version}:{},directory:i}}catch{return null}const o=c.dirname(a);if(o===a)return null;a=o}}function x(e,n,t){const a=e.split("/").map(f=>f.trim()).filter(f=>f.length>0);if(a.length<2)return null;const i=a[0],r=a[1].replace(/\.git$/i,"");if(i.length===0||r.length===0)return null;const o=a.slice(2);let s,u;return o[0]==="tree"&&o.length>=2?(s=o[1],u=o.slice(2).join("/")):o.length>0&&(u=o.join("/")),typeof t=="string"&&t.trim().length>0&&(s=t.trim()),{kind:"github",input:n,owner:i,repo:r,repository:`https://github.com/${i}/${r}.git`,ref:s,subpath:u&&u.length>0?u:void 0}}function te(e,n,t){const a=e.slice(4).trim();if(a.length===0)throw new d('npm package source must include a package spec after "npm:".',p.USAGE);if(n)throw new d('Options "--gh/--github" cannot be combined with npm: package sources.',p.USAGE);if(t)throw new d('Option "--ref" cannot be combined with npm: package sources.',p.USAGE);return{kind:"npm",input:e,spec:a}}function Re(e,n={}){const t=e.trim();if(t.length===0)throw new d("Extension source is required for --install.",p.USAGE);const a=typeof n.ref=="string"&&n.ref.trim().length>0?n.ref.trim():void 0;if(t.startsWith("npm:"))return te(t,n.forceGithub===!0,a);const i=(()=>{try{const o=new URL(t);if(o.hostname!=="github.com")return null;const s=o.pathname.replace(/^\/+/,"");return x(s,t,a)}catch{return null}})();if(i)return i;const r=t.startsWith("github.com/")?t.slice(11):null;if(r){const o=x(r,t,a);if(!o)throw new d(`Invalid GitHub source "${t}".`,p.USAGE);return o}if(n.forceGithub){const o=x(t,t,a);if(!o)throw new d(`Invalid GitHub shorthand "${t}".`,p.USAGE);return o}if(/^https?:\/\//i.test(t))throw new d(`Unsupported extension source URL "${t}". Supported remote source host: github.com.`,p.USAGE);return{kind:"local",input:t,absolute_path:c.resolve(process.cwd(),t)}}async function P(e,n=j,t){try{return((await n("git",e,{encoding:"utf8",timeout:t})).stdout??"").trim()}catch(a){const i=typeof a=="object"&&a!==null&&"stderr"in a?String(a.stderr):"",r=i.trim().length>0?i.trim():a instanceof Error?a.message:String(a);throw new d(`Git command failed: git ${e.join(" ")}
|
|
2
|
+
${r}`,p.GENERIC_FAILURE)}}function ne(e=process.platform){return e==="win32"?"npm.cmd":"npm"}function ae(e=process.platform){return e==="win32"}async function _(e,n,t=j,a=process.platform,i=process.env){const r=ne(a),o=Object.fromEntries(Object.entries(i).filter(([s])=>s.toLowerCase()!=="npm_config_allow_scripts"));o.NPM_CONFIG_ALLOW_SCRIPTS="";try{return((await t(r,e,{cwd:n,encoding:"utf8",env:o,shell:ae(a)})).stdout??"").trim()}catch(s){const u=typeof s=="object"&&s!==null&&"stderr"in s?String(s.stderr):"",f=u.trim().length>0?u.trim():s instanceof Error?s.message:String(s);throw new d(`npm command failed: ${r} ${e.join(" ")}
|
|
3
|
+
${f}`,p.GENERIC_FAILURE)}}function E(e){const n=e.trim(),t=n.includes("@file:")?n.slice(0,n.lastIndexOf("@file:")):n;return t.startsWith("@")?t.match(/^(@[^/@\s]+\/[^/@\s]+)/)?.[1]??t:t.match(/^([^/@\s]+)/)?.[1]??t}const re=/^(?:(?:github|gitlab|bitbucket|gist):|git(?:\+[a-z]+)?:|[a-z][a-z0-9+.-]*:\/\/|[\w.-]+@[\w.-]+:)/iu;function ie(e){if(!S(e)){try{const n=v(e.trim());if((n.type==="git"||n.type==="remote")&&!n.name)return}catch{}return E(e)}}function oe(e){const n=e.trim();let t;try{t=v(n)}catch{return}if(!(t.type!=="git"||t.name||re.test(n)))throw new d(`npm:${n} names no local directory here, and npm would read it as a git repository.`,p.USAGE,{code:"npm_source_shorthand_ambiguous",required:"Spell the source explicitly: npm:./<path> for a local directory, or npm:github:<owner>/<repo> for a repository.",why:"A bare owner/repo npm spec means a local directory when one exists and a git host otherwise, so pm refuses to guess which code to install."})}function S(e){const n="@file:",t=e.lastIndexOf(n);return t>0&&e.slice(0,t).trim().length>0&&e.slice(t+n.length).trim().length>0}function se(e){const t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes("npm err! code e404")||t.includes("404 not found")||t.includes("is not in this registry")}function ce(e){const t=(e instanceof Error?e.message:String(e)).toLowerCase();return se(e)||t.includes("not found")}function le(e){const n=e.trim().toLowerCase();return n.startsWith("@unbrained/pm-")||n.startsWith("pm-")}function pe(e){const n=E(e),t=le(n),a=n.replace(/^.*\//,""),i=t?`github.com/unbraind/${a}`:void 0,r=i?`pm package install --project ${i}`:void 0;return{message:t?`npm package "${e}" was not found in the registry. If this is an unpublished first-party pm package, install its GitHub repository instead.`:`npm package "${e}" was not found in the registry.`,context:{code:"npm_package_not_found",required:"Use an install source that exists, or publish the npm package before installing it with npm:<name>.",why:"Classifying npm 404s avoids repeated registry retries and gives agents a deterministic fallback path.",examples:r?[r,"pm package catalog --project --json"]:[`npm view ${n}`,"pm package catalog --project --json"],nextSteps:r?[`Try ${r} if the repository exists.`,"Use pm package catalog --project --json to inspect bundled package aliases before installing."]:[`Verify ${n} exists in the npm registry and that you have access to it.`,"Use pm package catalog --project --json to inspect bundled package aliases before installing."],recovery:{attempted_command:`pm install --project npm:${e}`,normalized_args:["install","--project",`npm:${e}`],...i&&r?{fallback_candidates:[{source:i,command:r,reason:"canonical first-party GitHub repository fallback for unpublished pm packages"}],next_best_command:r}:{}}}}}function de(e,n){if(!ce(n))return null;const t=pe(e);return new d(t.message,p.NOT_FOUND,t.context)}async function A(e){if(c.isAbsolute(e)||e.startsWith(".")||e.startsWith("..")){const n=c.resolve(process.cwd(),e);return await m(n)?n:null}try{const n=new URL(e);if(n.protocol==="file:"){const t=q(n);return await m(t)?t:null}}catch{}if(!/^[a-z][a-z0-9+.-]*:/i.test(e)){const n=c.resolve(process.cwd(),e);if(await m(n))return n}return null}async function $(e){const n=await A(e);if(n)return n;const t=ue(e);return t!==e?t:(/^[a-z][a-z0-9+.-]*:/i.test(e),e)}function ue(e,n=process.cwd()){const t="@file:",a=e.lastIndexOf(t);if(!S(e))return e;const i=e.slice(0,a),r=e.slice(a+t.length);if(r.startsWith("//")&&!r.startsWith("///"))return e;if(!r.startsWith("/"))return`${i}@${c.resolve(n,r)}`;let o;try{o=decodeURIComponent(new URL(`file:${r}`).pathname)}catch{return e}const s=/^\/[A-Za-z]:/.test(o)?o.slice(1):o;return`${i}@${s}`}function N(e,n){const t=c.resolve(e,n),a=c.relative(e,t);if(a.length===0||a===".."||a.startsWith(`..${c.sep}`)||c.isAbsolute(a))throw new d("npm pack reported a package archive outside its isolated destination.",p.GENERIC_FAILURE,{code:"npm_package_archive_unsafe",required:"Retry with a trusted npm client that writes its archive inside the requested pack destination.",why:"pm will not read a package-manager artifact outside the isolated directory created for this install."});return t}function me(e,n){if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e;if(!(typeof t.filename!="string"||t.filename.trim().length===0))return{...n===void 0?{}:{key:n},filename:t.filename,...typeof t.name=="string"?{name:t.name}:{},...typeof t.version=="string"?{version:t.version}:{}}}function fe(e){return(Array.isArray(e)?e.map(t=>({value:t})):typeof e=="object"&&e!==null?Object.entries(e).map(([t,a])=>({key:t,value:a})):[]).flatMap(({key:t,value:a})=>{const i=me(a,t);return i?[i]:[]})}function he(e,n){const t=n?.trim().toLowerCase(),a=t?e.filter(o=>{const s=o.name?.trim().toLowerCase();return s!==void 0?s===t:o.key?.trim().toLowerCase()===t}):[];if(a.length===1)return a[0];if(e.length!==1)return;const i=e[0],r=i.name??i.key;return t&&r!==void 0&&r.trim().toLowerCase()!==t?void 0:i}function C(e,n,t){let a;try{a=JSON.parse(e)}catch{const o=e.split(/\r?\n/).map(s=>s.trim()).filter(s=>s.length>0).at(-1);if(!o)throw new d("npm pack did not report a tarball filename.",p.GENERIC_FAILURE);return{tarball:N(n,o)}}const i=fe(a),r=he(i,t);if(!r)throw new d("npm pack --json returned an unsupported or ambiguous package receipt.",p.GENERIC_FAILURE,{code:"npm_pack_json_shape_unsupported",required:"Use an npm client that returns an array of package receipts or an object keyed by package name, with exactly one requested package entry containing filename.",why:`Well-formed JSON contained ${i.length} usable package receipt(s), but pm could not select ${t??"one package"} deterministically.`});return{tarball:N(n,r.filename),package:r.name??r.key,version:r.version}}async function L(e){return U(e,_)}async function U(e,n){const t=await A(e.spec);if(t){if((await l.stat(t)).isFile()&&I(t))return w(t);const o=c.join(t,"package.json"),s=await m(o)?JSON.parse(await l.readFile(o,"utf8")):{};return{directory:await g(t,e.input),package:typeof s.name=="string"?s.name:void 0,version:typeof s.version=="string"?s.version:void 0,cleanup:async()=>{}}}oe(e.spec);const a=await l.mkdtemp(c.join(k.tmpdir(),"pm-npm-package-source-")),i=c.join(a,"pack");await l.mkdir(i,{recursive:!0});try{const r=await $(e.spec),o=await n(["pack",r,"--json","--pack-destination",i]),s=C(o,i,ie(e.spec));if(!await m(s.tarball))throw new d("npm pack did not create its reported package archive.",p.GENERIC_FAILURE,{code:"npm_package_archive_missing",required:"Retry the npm package install with a healthy registry and writable temporary directory.",why:"The package manager reported a tarball filename that was absent before validation, so pm cannot safely extract or install it."});const u=await w(s.tarball);return{directory:u.directory,package:s.package??u.package,version:s.version??u.version,cleanup:async()=>{try{await u.cleanup()}finally{await l.rm(a,{recursive:!0,force:!0})}}}}catch(r){await l.rm(a,{recursive:!0,force:!0});const o=de(e.spec,r);throw o||r}}function I(e){const n=e.toLowerCase();return n.endsWith(".tgz")||n.endsWith(".tar.gz")}function h(e){throw new d(e,p.USAGE,{code:"local_package_archive_unsafe",required:"Use a bounded npm .tgz or .tar.gz archive with one package/ root and no links or escaping paths.",why:"Package archives are untrusted input and must be validated before any entry reaches the filesystem."})}function R(e,n,t){if(e.meta)return;t.entries+=1,t.entries>n.maxEntries&&h(`Local package archive exceeds the ${n.maxEntries} entry limit.`);const a=e.path,i=a.split("/");(a.includes("\\")||a.startsWith("/")||/^[A-Za-z]:/u.test(a)||i.some(r=>r===".."))&&h(`Local package archive contains an escaping path: "${a}".`),i[0]!=="package"&&h(`Local package archive entry "${a}" is outside the required package/ root.`),(e.type==="SymbolicLink"||e.type==="Link")&&h(`Local package archive link "${a}" is not supported.`),e.type!=="File"&&e.type!=="OldFile"&&e.type!=="Directory"&&h(`Local package archive entry "${a}" uses unsupported type "${e.type}".`),e.size>n.maxEntryBytes&&h(`Local package archive entry "${a}" exceeds the ${n.maxEntryBytes} byte entry limit.`),t.expandedBytes+=e.size,t.expandedBytes>n.maxExpandedBytes&&h(`Local package archive exceeds the ${n.maxExpandedBytes} expanded byte limit.`),a==="package/package.json"&&(t.packageJsonEntries+=1)}async function w(e,n=Y){(await l.stat(e)).size>n.maxArchiveBytes&&h(`Local package archive exceeds the ${n.maxArchiveBytes} archive byte limit.`);const a=await l.mkdtemp(c.join(k.tmpdir(),"pm-local-package-archive-")),i=c.join(a,"extract");await l.mkdir(i,{recursive:!0});const r={entries:0,expandedBytes:0,packageJsonEntries:0};let o;try{if(await K({file:e,strict:!0,maxDecompressionRatio:100,onReadEntry:M=>{if(o===void 0)try{R(M,n,r)}catch(B){o=B}}}),o!==void 0)throw o;r.packageJsonEntries!==1&&h(`Local package archive must contain exactly one package/package.json entry; found ${r.packageJsonEntries}.`),await H({file:e,cwd:i,strict:!0,preservePaths:!1,preserveOwner:!1,noMtime:!0,unlink:!0,maxDepth:64,maxDecompressionRatio:100});const s=c.join(i,"package"),u=c.join(s,"package.json"),f=JSON.parse(await l.readFile(u,"utf8"));return await O(s),{directory:await g(s,e),package:typeof f.name=="string"?f.name:void 0,version:typeof f.version=="string"?f.version:void 0,cleanup:async()=>{await l.rm(a,{recursive:!0,force:!0})}}}catch(s){throw await l.rm(a,{recursive:!0,force:!0}),s}}async function O(e,n=_){const t=c.join(e,"package.json");if(!await m(t))return;let a;try{a=JSON.parse(await l.readFile(t,"utf8"))}catch{return}if(typeof a!="object"||a===null)return;const i=a,r=W(i),o=G(i);if(r.length===0&&!o)return;const s={...a};delete s.devDependencies;const u={...s};F(u),await l.writeFile(t,`${JSON.stringify(u,null,2)}
|
|
4
|
+
`,"utf8");try{await Promise.all([l.rm(c.join(e,"package-lock.json"),{force:!0}),l.rm(c.join(e,"npm-shrinkwrap.json"),{force:!0})]),r.length>0&&await n(["install","--ignore-scripts","--no-audit","--fund=false","--package-lock=false","--no-save","--omit=peer","--"],e),o&&await D(e)}finally{await l.writeFile(t,`${JSON.stringify(s,null,2)}
|
|
5
|
+
`,"utf8")}}function G(e){for(const n of[e.dependencies,e.optionalDependencies,e.peerDependencies])if(typeof n=="object"&&n!==null&&y in n)return!0;return!1}function F(e){for(const n of["dependencies","optionalDependencies","peerDependencies"]){const t=e[n];if(typeof t!="object"||t===null)continue;const a={...t};delete a[y],Object.keys(a).length===0?delete e[n]:e[n]=a}}async function D(e){const n=Z(import.meta.url,["../../.."]),[t,a]=y.split("/"),i=c.join(e,"node_modules",t),r=c.join(i,a);await l.mkdir(i,{recursive:!0}),await l.rm(r,{recursive:!0,force:!0}),await l.symlink(n,r,z(process.platform))}function z(e){return e==="win32"?"junction":"dir"}function ge(e,n){if(e.startsWith("-"))throw new d(`Extension runtime dependency name "${e}" is unsafe because npm could interpret it as a command-line option.`,p.USAGE,{code:"extension_dependency_name_unsafe",required:"Use a valid npm package name that does not begin with a dash.",why:"Extension manifests are untrusted input and dependency names must never become npm options."});if([...n].some(a=>{const i=a.charCodeAt(0);return i<=31||i===127||"&|;()`\"'".includes(a)}))throw new d(`Extension runtime dependency "${e}" has an unsafe version specifier.`,p.USAGE,{code:"extension_dependency_version_unsafe",required:"Use an npm version, range, dist-tag, URL, or file specifier without shell metacharacters.",why:"npm.cmd requires a command shell on Windows, so untrusted shell metacharacters cannot be forwarded."});try{v.resolve(e,n)}catch{throw new d(`Extension runtime dependency "${e}@${n}" is not a valid npm dependency specifier.`,p.USAGE,{code:"extension_dependency_spec_invalid",required:"Use a valid npm package name and npm-supported version, range, dist-tag, URL, or file specifier.",why:"Only grammar-validated dependency specs may be written to the isolated runtime install manifest."})}return`${e}@${n}`}function W(e){const n=new Map;for(const t of[e.dependencies,e.optionalDependencies,e.peerDependencies])if(!(typeof t!="object"||t===null))for(const[a,i]of Object.entries(t)){if(a===y||typeof i!="string"||i.trim().length===0||n.has(a))continue;const r=i.trim();n.set(a,ge(a,r))}return[...n.values()]}async function g(e,n){const t=await V(e);if(t.length===1)return t[0];if(t.length>1){const a=t.map(i=>c.relative(e,i).replaceAll(c.sep,"/")).sort((i,r)=>i.localeCompare(r));throw new d(`Package source "${n}" contains multiple extension manifests. Provide an explicit extension path. Candidates: ${a.join(", ")}`,p.USAGE)}throw new d(`Unable to locate a pm extension manifest in package source "${n}". Package installs currently activate only extension resources, so add package.json pm.extensions or an extensions/ directory. Metadata-only resources like pm.docs/pm.examples are catalog metadata and do not activate commands.`,p.USAGE)}async function ye(e,n){const t=[];n.subpath&&(t.push(n.subpath),t.push(c.posix.join(".agents/pm/extensions",n.subpath)),t.push(c.posix.join(".custom/pm-extensions",n.subpath)),t.push(c.posix.join(".custom/pm-extension",n.subpath)));for(const i of t){const r=c.resolve(e,i);if(Q(e,r)&&await m(c.join(r,"manifest.json")))return{directory:r,resolved_subpath:i}}if(await m(c.join(e,"manifest.json")))return{directory:e,resolved_subpath:"."};const a=await g(e,n.input);return{directory:a,resolved_subpath:c.relative(e,a).replaceAll(c.sep,"/")}}function we(e){const n=e.trim();return n.length===0||n.startsWith(".")||n.startsWith("~")?!1:n.startsWith("@")?n.split("/").length===2:!n.includes("/")&&!n.includes("\\")}async function ke(e){const n=`Local extension source does not exist: "${e.absolute_path}".`,t=e.input.trim();if(!we(t))return new d(n,p.NOT_FOUND);let a=[];try{const r=process.env.PM_CLI_PACKAGE_ROOT,o=typeof r=="string"&&r.trim().length>0?c.resolve(r.trim()):"";b?.key!==o&&(b={key:o,aliases:await X()}),a=b.aliases}catch{}const i=[`Retry with pm package install npm:${t} if the package is published to npm.`,`Or inspect bundled packages with pm package catalog --project --json before installing by alias. Known aliases (blank means none found): ${a.join(", ")}`];return new d(`${n} "${t}" did not match a local directory, bundled package alias, or bundled package name; if you meant an npm package, install it as "npm:${t}".`,p.NOT_FOUND,{code:"local_source_not_found_bare_name",required:`Use "npm:${t}" for npm registry packages, a bundled catalog alias, or an existing local directory path.`,why:"Bare names resolve as local paths only after bundled aliases, so unmatched names need an explicit npm: source.",examples:[`pm package install npm:${t}`,"pm package catalog --project --json"],nextSteps:i,recovery:{attempted_command:`pm install ${t}`,normalized_args:["install",t],next_best_command:`pm package install npm:${t}`}})}async function Oe(e){if(e.kind==="local"){let a;try{a=await l.stat(e.absolute_path)}catch{throw await ke(e)}if(a.isFile()&&I(e.absolute_path)){const r=await w(e.absolute_path);return{source:e,directory:r.directory,source_root:c.dirname(r.directory),resolved_subpath:c.relative(c.dirname(r.directory),r.directory).replaceAll(c.sep,"/"),npm_package:r.package,npm_version:r.version,cleanup:r.cleanup}}if(!a.isDirectory())throw new d(`Local extension source must be a directory or npm .tgz/.tar.gz archive: "${e.absolute_path}".`,p.USAGE);const i=await g(e.absolute_path,e.input);return{source:e,directory:i,source_root:e.absolute_path}}if(e.kind==="npm"){const a=await L(e);return{source:e,directory:a.directory,source_root:c.dirname(a.directory),cleanup:a.cleanup,resolved_subpath:c.relative(c.dirname(a.directory),a.directory).replaceAll(c.sep,"/"),npm_package:a.package,npm_version:a.version}}const n=await l.mkdtemp(c.join(k.tmpdir(),"pm-extension-source-")),t=["clone","--depth","1"];e.ref&&t.push("--branch",e.ref),t.push(e.repository,n);try{await P(t);const a=await P(["-C",n,"rev-parse","HEAD"]),i=await ye(n,e);return{source:e,directory:i.directory,source_root:n,resolved_subpath:i.resolved_subpath,commit:a,cleanup:async()=>{await l.rm(n,{recursive:!0,force:!0})}}}catch(a){throw await l.rm(n,{recursive:!0,force:!0}),a}}async function Ge(e,n){if(!await m(e)||!await m(n))return!1;const[t,a]=await Promise.all([l.realpath(e),l.realpath(n)]);return t===a}const Fe={extractLocalPackageArchive:w,validateLocalPackageArchiveEntry:R,installNpmPackageRuntimeDependencies:O,npmPackageNameFromSpec:E,parsePackedNpmPackage:C,resolveNpmSourceDirectoryWithRunner:U,resolveNpmSourceDirectory:L,resolveNpmPackSpec:$,findInstalledNpmPackageCandidate:ee,resolvePackageExtensionDirectory:g,runtimeDependencyInstallSpecs:W,hasHostedPmCliDependency:G,removeHostedPmCliDependency:F,linkHostedPmCliDependency:D,resolveDirectorySymlinkType:z,runNpmCommand:_};export{Fe as _testOnlyInstallSources,Ge as areDirectoriesEquivalent,pe as buildNpmNotFoundRecovery,ee as findInstalledNpmPackageCandidate,se as isNpmNotFoundError,ce as isNpmPackNotFoundError,ue as normalizeNpmLocalFileAliasSpec,Re as parseExtensionInstallSource,Oe as resolveInstallSource,ne as resolveNpmCommandName,P as runGitCommand,ae as shouldRunNpmCommandInShell,de as wrapNpmPackResolutionError};
|
|
6
6
|
//# sourceMappingURL=install-sources.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Split `--fields` into distinct keys; undefined when the option is absent. `example` replaces the generated refusal example. */
|
|
2
|
+
export declare function parseListingFields(raw:unknown,allowed:readonly string[],listing:string,example?:string):string[]|undefined;
|
|
3
|
+
/** Keep only the requested keys of each row, in the requested order; a key a row lacks reads as null. */
|
|
4
|
+
export declare function projectListingRows(rows:ReadonlyArray<object>,fields:readonly string[]):Record<string,unknown>[];
|
|
5
|
+
/** Row keys an explore or manage row can carry, in their emitted order. */
|
|
6
|
+
export declare const EXPLORE_MANAGE_ROW_FIELDS:readonly["name","directory","version","entry","scope","active","enabled","runtime_active","activation_status","managed","source","update_available","last_update_check_at","last_update_remote_version","last_update_remote_commit","update_error","update_check_timeout_ms","update_check_status","update_check_reason","command_paths","action_paths","contributions"];
|
|
7
|
+
/** Validate an explore or manage `--fields` selection; called at admission, before any check or adoption runs. */
|
|
8
|
+
export declare function parseExploreManageFields(rawFields:unknown,listing:string):string[]|undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Shape explore and manage rows from an admitted selection: `--fields` selects
|
|
11
|
+
* any subset; without it the embedded `contributions` map stays out, because
|
|
12
|
+
* `pm package describe` maps every registered surface and the map dominated each
|
|
13
|
+
* row (pm-gh1777).
|
|
14
|
+
*/
|
|
15
|
+
export declare function projectExploreManageRows(rows:ReadonlyArray<object>,fields:readonly string[]|undefined):object[];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{EXIT_CODE as s}from"../../core/shared/constants.js";import{PmCliError as c}from"../../core/shared/errors.js";function u(e,t,n,r){if(e==null||e===!1)return;const i=[...new Set(String(e).split(",").map(a=>a.trim()).filter(a=>a.length>0))];if(i.length===0)throw new c(`Package ${n} --fields requires a comma-separated list of field names`,s.USAGE);const o=i.filter(a=>!t.includes(a));if(o.length>0)throw new c(`Package ${n} --fields has unknown field(s): ${o.join(", ")}`,s.USAGE,{code:"invalid_argument_value",examples:[r??`pm package ${n} --fields ${t.slice(0,3).join(",")}`],recovery:{allowed_values:[...t],provided_fields:["--fields"]}});return i}function p(e,t){return e.map(n=>Object.fromEntries(t.map(r=>[r,n[r]??null])))}const d=["name","directory","version","entry","scope","active","enabled","runtime_active","activation_status","managed","source","update_available","last_update_check_at","last_update_remote_version","last_update_remote_commit","update_error","update_check_timeout_ms","update_check_status","update_check_reason","command_paths","action_paths","contributions"];function m(e,t){return u(e,d,t)}function f(e,t){return t!==void 0?p(e,t):e.map(n=>{const{contributions:r,...i}=n;return i})}export{d as EXPLORE_MANAGE_ROW_FIELDS,m as parseExploreManageFields,u as parseListingFields,f as projectExploreManageRows,p as projectListingRows};
|
|
2
|
+
//# sourceMappingURL=listing-fields.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{mapWithFixedConcurrency as c}from"./concurrency.js";import{sortManagedEntries as _}from"./managed-state.js";import{checkGithubUpdate as
|
|
1
|
+
import{mapWithFixedConcurrency as c}from"./concurrency.js";import{isRegistryNpmSource as m}from"./npm-spec.js";import{sortManagedEntries as _}from"./managed-state.js";import{checkGithubUpdate as p,checkNpmUpdate as f,resolveExtensionUpdateCheckTimeoutMs as l,updateCheckTeardown as h}from"./update-check.js";const u=4;function k(n){let i=n;const a=[];return{acquire:()=>i>0?(i-=1,Promise.resolve()):new Promise(e=>a.push(e)),release:()=>{const e=a.shift();e?e():i+=1}}}function s(n,i){const{update_check_timeout_ms:a,...e}=n;return i===void 0?e:{...e,update_check_timeout_ms:i}}async function U(n,i=!1,a=l(),e=!0){const o=k(u),d=await c(n.entries,u,async t=>{if(!["github","npm"].includes(t.source.kind))return t;if(i||t.source.kind==="npm"&&!m(t.source))return s({...t,last_update_check_at:void 0,last_update_remote_commit:void 0,last_update_remote_version:void 0,update_available:null,update_error:void 0},void 0);await o.acquire();const r=t.source.kind==="github"?await p(t.source,void 0,a):await f(t.source,void 0,a);return e?h(r).then(o.release):o.release(),s({...t,last_update_check_at:r.checked_at,last_update_remote_commit:"remote_commit"in r?r.remote_commit:void 0,last_update_remote_version:"remote_version"in r?r.remote_version:void 0,update_available:r.available,update_error:r.error},r.timeout_ms)});return{...n,entries:_(d)}}export{U as refreshManagedExtensionUpdates};
|
|
2
2
|
//# sourceMappingURL=managed-update-status.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type{ManagedExtensionSource}from "./managed-state.js";
|
|
2
|
+
/** Whether a raw npm spec names a local path, tarball or `file:` artifact rather than a registry package. */
|
|
3
|
+
export declare function isLocalNpmSpec(spec:string):boolean;
|
|
4
|
+
/** Whether a managed source installs from the npm registry, so a newer registry release can replace it. */
|
|
5
|
+
export declare function isRegistryNpmSource(source:ManagedExtensionSource):boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Whether a string is an exact npm version, by the rule the live freshness check applies to the registry's
|
|
8
|
+
* answer (npm-package-arg resolves it as a `version` spec), so the offline cache reader accepts exactly what
|
|
9
|
+
* the writer can produce, build metadata included (Codex review round 14).
|
|
10
|
+
*/
|
|
11
|
+
export declare function isExactNpmVersion(value:string):boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Whether a registry `latest` is an update for an installed version: newer under
|
|
14
|
+
* SemVer precedence (a release is newer than its own prerelease; an older
|
|
15
|
+
* `latest` is no update, because installing it would downgrade). Versions that
|
|
16
|
+
* are not valid SemVer count as an update whenever they differ.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isNewerRegistryVersion(latest:string,installed:string):boolean;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import a from"node:path";import s from"npm-package-arg";import n from"semver";const o=new Set(["tag","version","range"]);function p(t){try{const e=s(t),r=e.subSpec;return e.type==="alias"?r?.type:e.type}catch{return}}function l(t){if(a.isAbsolute(t)||t.startsWith(".")||t.startsWith("file:"))return!0;const e=p(t);return e!==void 0&&o.has(e)?!1:e==="file"||e==="directory"||/\.(?:tgz|tar\.gz|tar)$/iu.test(t)}function m(t){if(t.kind!=="npm")return!1;const e=t.input.startsWith("npm:")?t.input.slice(4).trim():t.input.trim(),r=p(e);return r!==void 0&&o.has(r)}function d(t){try{return s.resolve("pm-version-probe",t).type==="version"}catch{return!1}}function y(t,e){const r=n.parse(t,{loose:!0}),i=n.parse(e,{loose:!0});return r===null||i===null?t!==e:n.gt(r,i)}export{d as isExactNpmVersion,l as isLocalNpmSpec,y as isNewerRegistryVersion,m as isRegistryNpmSource};
|
|
2
|
+
//# sourceMappingURL=npm-spec.js.map
|
|
@@ -23,7 +23,57 @@ managed:boolean|null;
|
|
|
23
23
|
/** Runtime state is never inferred from configuration. */
|
|
24
24
|
runtime_active:null;
|
|
25
25
|
/** Manifest version when available. */
|
|
26
|
-
version?:string;
|
|
26
|
+
version?:string;
|
|
27
|
+
/**
|
|
28
|
+
* Newer version the last `pm package manage` check observed for this installed
|
|
29
|
+
* version, or null when none is known (pm-gh1777); absent on a row for a
|
|
30
|
+
* requested package that is not installed.
|
|
31
|
+
*/
|
|
32
|
+
update?:string|null;}
|
|
33
|
+
/** The `--fields` contract every package listing shares (pm-gh1777), published with the listing it serves. */
|
|
34
|
+
export{parseListingFields,projectListingRows}from "./listing-fields.js";
|
|
35
|
+
/**
|
|
36
|
+
* Refuse a lifecycle option another package action owns. Commander accepts these on the parent command, so
|
|
37
|
+
* without this check `pm package list --fix-managed-state` would succeed without adopting anything, and a
|
|
38
|
+
* caller could mistake the listing for the operation it asked for (Codex review round 13).
|
|
39
|
+
*/
|
|
40
|
+
export declare function refuseStaticInventoryForeignOptions(options:Record<string,unknown>):void;
|
|
41
|
+
/** The read-output controls a caller passed, by their global-option keys. */
|
|
42
|
+
export interface StaticInventoryReadOutputControls{
|
|
43
|
+
/** Row cap a read would apply; the inventory cannot page, so any value is refused. */
|
|
44
|
+
outputLimit?:string;
|
|
45
|
+
/** Projection mode a read would apply; the inventory projects with `--fields` instead, so any value is refused. */
|
|
46
|
+
outputInclude?:string;
|
|
47
|
+
/** Read session that would suppress repeated rows across calls; refused because the inventory keeps no session. */
|
|
48
|
+
outputSession?:string;
|
|
49
|
+
/** Continuation token of an earlier page; refused because the inventory returns every row at once. */
|
|
50
|
+
outputCursor?:string;
|
|
51
|
+
/** Request for the per-row identity contract; refused when true because inventory rows carry none. */
|
|
52
|
+
outputRowContract?:boolean;
|
|
53
|
+
/** Byte budget for the rendered result; only `unbounded` is accepted, since the inventory cannot trim rows to fit. */
|
|
54
|
+
outputBudget?:string;
|
|
55
|
+
/** Raw `--output-format` value as typed; only `toon` and `json` are formats, anything else is refused. */
|
|
56
|
+
outputFormat?:unknown;}
|
|
57
|
+
/**
|
|
58
|
+
* The static inventory returns every installed package and applies no read-output
|
|
59
|
+
* row controls, so those controls are refused instead of silently ignored; the
|
|
60
|
+
* output format and an unbounded budget still apply (Codex review round 2).
|
|
61
|
+
*/
|
|
62
|
+
export declare function refuseStaticInventoryReadOutputControls(controls:StaticInventoryReadOutputControls):void;
|
|
63
|
+
/**
|
|
64
|
+
* The tracker's configured default output format (`output.default_format`), so the static
|
|
65
|
+
* listing renders as every other command does (Codex review round 9). Absent, unreadable or
|
|
66
|
+
* unknown values yield undefined.
|
|
67
|
+
*/
|
|
68
|
+
export declare function readStaticDefaultOutputFormat(pmRoot:string):Promise<"json"|"toon"|undefined>;
|
|
69
|
+
/**
|
|
70
|
+
* Whether the tracker shows deprecation hints (`ux.deprecation_hints`, on by default), read
|
|
71
|
+
* statically so the deprecated `pm extension list` spelling keeps its migration hint without
|
|
72
|
+
* leaving the no-activation path (Codex review round 11).
|
|
73
|
+
*/
|
|
74
|
+
export declare function readStaticDeprecationHints(pmRoot:string):Promise<boolean>;
|
|
75
|
+
/** Row keys `pm package list --fields` selects from, in their emitted order. */
|
|
76
|
+
export declare const INVENTORY_ROW_FIELDS:readonly["name","directory","scope","installed","status","configured_enabled","managed","runtime_active","version","update"];
|
|
27
77
|
/** A read-only inventory with explicit completeness and source receipts. */
|
|
28
78
|
export interface StaticExtensionInventoryResult{
|
|
29
79
|
/** Selected storage scope. */
|
|
@@ -34,6 +84,8 @@ complete:boolean;
|
|
|
34
84
|
settings_status:"ok"|"absent"|"invalid"|"unreadable";
|
|
35
85
|
/** Status of the managed install metadata. */
|
|
36
86
|
managed_state_status:"ok"|"absent"|"invalid"|"unreadable";
|
|
87
|
+
/** Installed entries whose last observed check found a newer release; always set by {@link inspectStaticExtensionInventory}. */
|
|
88
|
+
updates_available?:number;
|
|
37
89
|
/** Installed entries, or one absent entry for a missing requested name. */
|
|
38
90
|
extensions:StaticExtensionInventoryEntry[];
|
|
39
91
|
/** Every failure that affected completeness. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import h from"node:fs/promises";import s from"node:path";import{resolveGlobalPmRoot as I}from"../../core/store/paths.js";import{EXIT_CODE as y}from"../../core/shared/constants.js";import{PmCliError as _}from"../../core/shared/errors.js";import{normalizeManagedState as O}from"./managed-state.js";import{normalizeExtensionNameForMatch as d,normalizeStringList as v,parseExtensionManifest as N}from"./shared.js";import{findApplicableUpdateObservation as R,readBoundedRegularFile as m,readExtensionUpdateObservations as M,resolveObservedUpdateVersion as F}from"./update-observations.js";import{parseListingFields as de,projectListingRows as ue}from"./listing-fields.js";const C=[["install","--install"],["uninstall","--uninstall"],["explore","--explore"],["list","--list"],["manage","--manage"],["describe","--describe"],["markdown","--markdown"],["output","--output"],["reload","--reload"],["doctor","--doctor"],["catalog","--catalog"],["adopt","--adopt"],["adoptAll","--adopt-all"],["activate","--activate"],["deactivate","--deactivate"],["migrate","--migrate"],["init","--init"],["scaffold","--scaffold"],["capability","--capability"],["declarative","--declarative"],["gh","--gh"],["github","--github"],["ref","--ref"],["fixManagedState","--fix-managed-state"],["runtimeProbe","--runtime-probe"],["trace","--trace"],["watch","--watch"],["strictExit","--strict-exit"],["failOnWarn","--fail-on-warn"],["isolated","--isolated"],["ignoreGlobal","--ignore-global"],["detail","--detail"],["dryRun","--dry-run"]];function ee(e){const n=C.filter(([t])=>e[t]!==void 0&&e[t]!==!1).map(([,t])=>t);if(n.length!==0)throw new _(`${n.join(", ")} ${n.length===1?"does":"do"} not apply to pm package list, a read that changes nothing.`,y.USAGE,{code:"invalid_argument_value",required:"Drop the option, or run the package action that owns it (pm package manage, pm package doctor, pm package reload).",examples:["pm package manage --fix-managed-state","pm package list --fields name,version,update"]})}function te(e){if(e.outputFormat!==void 0&&e.outputFormat!=="json"&&e.outputFormat!=="toon")throw new _("--output-format must be toon or json.",y.USAGE,{code:"invalid_argument_value"});const n=[["--output-limit",e.outputLimit],["--output-include",e.outputInclude],["--output-session",e.outputSession],["--output-cursor",e.outputCursor],["--output-row-contract",e.outputRowContract===!0?"true":void 0],["--output-budget",e.outputBudget==="unbounded"?void 0:e.outputBudget]].filter(t=>typeof t[1]=="string").map(([t])=>t);if(n.length!==0)throw new _(`pm package list does not apply ${n.join(", ")}: it returns every installed package. Narrow rows with --fields, or use pm package manage or pm package catalog for read-output controls.`,y.USAGE,{code:"read_output_surface_unsupported",flag:n[0],details:{command:"package list",output_option_keys:n},required:"Drop the row-shaping output controls; pm package list keeps --output-format and an unbounded --output-budget.",examples:["pm package list --fields name,version,update"]})}const D=16*1024*1024,L=1024*1024,S=4*1024*1024;async function x(e){try{const n=await m(s.join(e,"settings.json"),S,{followLinks:!0}),t=n===void 0?void 0:JSON.parse(n);return typeof t=="object"&&t!==null?t:void 0}catch{return}}async function ne(e){const n=(await x(e))?.output?.default_format;return n==="json"||n==="toon"?n:void 0}async function ae(e){return(await x(e))?.ux?.deprecation_hints!==!1}const re=["name","directory","scope","installed","status","configured_enabled","managed","runtime_active","version","update"];function c(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function g(e){return e!=="invalid"&&e!=="unreadable"}function G(e){const n=JSON.parse(e);if(typeof n!="object"||n===null||Array.isArray(n))throw new SyntaxError("Invalid settings object");const t=n.extensions;if(t===void 0)return{enabled:[],disabled:[]};if(typeof t!="object"||t===null||Array.isArray(t))throw new SyntaxError("Invalid extensions settings");const a=t;if(a.enabled!==void 0&&(!Array.isArray(a.enabled)||!a.enabled.every(r=>typeof r=="string"))||a.disabled!==void 0&&(!Array.isArray(a.disabled)||!a.disabled.every(r=>typeof r=="string")))throw new SyntaxError("Invalid extension enablement lists");return{enabled:a.enabled??[],disabled:a.disabled??[]}}async function U(e){let n;try{n=await m(e,S,{followLinks:!0})}catch(t){return c(t)?{status:"absent",enabled:[],disabled:[]}:{status:"unreadable",enabled:[],disabled:[],error:{code:"settings_unreadable",path:e}}}if(n===void 0)return{status:"unreadable",enabled:[],disabled:[],error:{code:"settings_unreadable",path:e}};try{return{status:"ok",...G(n)}}catch{return{status:"invalid",enabled:[],disabled:[],error:{code:"settings_invalid",path:e}}}}async function B(e){let n;try{n=await m(e,D,{followLinks:!0})}catch(t){if(c(t))try{if((await h.stat(s.dirname(e))).isDirectory())return{status:"absent",entries:[]}}catch(a){if(c(a))return{status:"absent",entries:[]}}return{status:"unreadable",entries:[],error:{code:"managed_state_unreadable",path:e}}}if(n===void 0)return{status:"unreadable",entries:[],error:{code:"managed_state_unreadable",path:e}};try{const t=JSON.parse(n),a=O(t);if(!a||typeof t!="object"||t===null||!Array.isArray(t.entries)||a.entries.length!==t.entries.length)throw new SyntaxError("Invalid managed extension state");return{status:"ok",entries:a.entries}}catch{return{status:"invalid",entries:[],error:{code:"managed_state_invalid",path:e}}}}async function z(e){try{return{directories:(await h.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,a)=>t.localeCompare(a))}}catch(n){return c(n)?{directories:[]}:{directories:[],error:{code:"extensions_unreadable",path:e}}}}async function Y(e){let n;try{n=await m(e,L,{followLinks:!0})}catch(t){return c(t)?{manifest:null,error:{code:"manifest_invalid",path:e}}:{manifest:null,error:{code:"manifest_unreadable",path:e}}}if(n===void 0)return{manifest:null,error:{code:"manifest_unreadable",path:e}};try{const t=N(JSON.parse(n));return t?{manifest:t}:{manifest:null,error:{code:"manifest_invalid",path:e}}}catch{return{manifest:null,error:{code:"manifest_invalid",path:e}}}}function J(e,n,t){return e.find(a=>d(a.name)===d(n)||d(a.directory)===d(t))}function X(e){const n=e.manifest?.name??e.directory,t=new Set(v(e.settings.enabled)),a=new Set(v(e.settings.disabled)),r=!g(e.settings.status)||!e.manifest?null:!a.has(n)&&(t.size===0||t.has(n)),i=g(e.managed.status)?J(e.managed.entries,n,e.directory)!==void 0:null;return{name:n,directory:e.directory,scope:e.scope,installed:!0,status:e.manifest?r===!1?"inactive":"installed":"malformed_manifest",configured_enabled:r,managed:i,runtime_active:null,...e.manifest?{version:e.manifest.version}:{}}}function q(e,n,t,a){const r=t.find(p=>p.directory===n),i={name:e.name,version:e.version,updated_at:r?.updated_at,source:r?.source};return{...e,update:F(R(a,i))}}async function oe(e){const n=e.scope??"project",t=n==="global"?I(e.cwd??process.cwd()):e.pmRoot,a=s.join(t,"extensions"),r=await U(s.join(t,"settings.json")),i=await B(s.join(a,".managed-extensions.json")),p=await z(a),u=[];for(const o of[r,i,p])o.error&&u.push(o.error);const f=e.name?.trim(),E=await M(t),A=i.entries,l=[];for(const o of p.directories){const k=s.join(a,o,"manifest.json"),b=await Y(k);b.error&&u.push(b.error);const w=X({directory:o,scope:n,manifest:b.manifest,settings:r,managed:i});f&&![w.name,o].some(T=>d(T)===d(f))||l.push(q(w,o,A,E))}f&&l.length===0&&u.every(o=>o.code!=="extensions_unreadable")&&l.push({name:f,directory:null,scope:n,installed:!1,status:"absent",configured_enabled:g(r.status)?!1:null,managed:g(i.status)?!1:null,runtime_active:null});const j=l.filter(o=>typeof o.update=="string").length;return{scope:n,complete:u.length===0,settings_status:r.status,managed_state_status:i.status,updates_available:j,extensions:l,errors:u}}export{re as INVENTORY_ROW_FIELDS,oe as inspectStaticExtensionInventory,de as parseListingFields,ue as projectListingRows,ne as readStaticDefaultOutputFormat,ae as readStaticDeprecationHints,ee as refuseStaticInventoryForeignOptions,te as refuseStaticInventoryReadOutputControls};
|
|
2
2
|
//# sourceMappingURL=static-inventory.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{nowIso as
|
|
1
|
+
import{nowIso as m}from"../../core/shared/time.js";import{spawn as k}from"node:child_process";import{AsyncLocalStorage as C}from"node:async_hooks";import{isMainThread as b}from"node:worker_threads";import A from"npm-package-arg";import{killProcessTree as R}from"../../core/shared/process-tree.js";import{isNewerRegistryVersion as D}from"./npm-spec.js";import{resolveNpmCommandName as K,shouldRunNpmCommandInShell as L}from"./install-sources.js";const B="PM_EXTENSION_UPDATE_CHECK_TIMEOUT_MS",G=1e4,H=1e3,V=25e3,X=2e3,Q="npm_registry_lookup_failed",z="npm_registry_lookup_timed_out",F="github_remote_lookup_failed",W="github_remote_lookup_timed_out";function y(e=process.env){const t=e[B]?.trim(),r=t?Number(t):Number.NaN;return Number.isFinite(r)?Math.min(V,Math.max(H,Math.trunc(r))):G}class l extends Error{timeout_ms;teardown;constructor(t,r,n){super(t),this.name="UpdateQueryError",this.timeout_ms=r,this.teardown=n}}const N=new WeakMap;function ae(e){return N.get(e)??Promise.resolve()}function O(e,t){const r={checked_at:e,available:null,error:t instanceof Error?t.message:String(t)};return t instanceof l&&t.timeout_ms!==void 0&&(r.timeout_ms=t.timeout_ms),t instanceof l&&t.teardown!==void 0&&N.set(r,t.teardown),r}const _=new Set;function I(){for(const e of _)e()}const M=new C;async function de(e){const t=new Set;try{return await M.run(t,e)}finally{b||await Promise.all(t)}}function Y(e){return _.size===0&&process.on("exit",I),_.add(e),()=>{_.delete(e),_.size===0&&process.off("exit",I)}}function Z(e){const t=()=>e.exitCode!==null||e.signalCode!==null,r=()=>{t()||e.kill("SIGKILL")},n=()=>t()||e.pid===void 0?Promise.resolve():new Promise(i=>{const a=setTimeout(()=>{e.unref(),i()},X);e.once("exit",()=>{clearTimeout(a),i()})}),o=()=>(r(),e.stdout?.destroy(),n());return{stop:()=>t()||e.pid===void 0?Promise.resolve().then(o):R(e.pid,{kill:r,alive:()=>!t()}).then(o,o),killNow:r}}function P(e,t,r,n){return new Promise((o,i)=>{let a;try{a=k(e,t,{env:n.env,shell:n.shell,stdio:["ignore","pipe","ignore"]})}catch{i(new l(n.failed));return}const s=a,f=performance.now()+r;let p=!1,T="",w=0;const h=Z(s),x=M.getStore();let g;const E=()=>{const d=Y(h.killNow),c=new Promise(v=>{setTimeout(()=>{h.stop().then(v,v)},0)}).finally(d);return x?.add(c),g=c,c},S=setTimeout(()=>{u(new l(n.timedOut,r,E()))},r);function u(d){p||(p=!0,clearTimeout(S),performance.now()>=f?i(new l(n.timedOut,r,g)):d?i(d):o(T.trim()))}if(s.on("error",()=>u(new l(n.failed))),!s.stdout){u(new l(n.failed,void 0,E()));return}s.stdout.setEncoding("utf8"),s.stdout.on("data",d=>{if(!p){if(w+=Buffer.byteLength(d),w>n.maxBuffer){u(new l(n.failed,void 0,E()));return}T+=d}}),s.on("exit",(d,c)=>{d===0&&c===null||(u(new l(n.failed)),s.stdout.destroy())}),s.on("close",(d,c)=>u(d===0&&c===null?void 0:new l(n.failed)))})}function U(e,t,r){if(typeof t=="string")try{const n=A.resolve(e,t);if(n.type==="version")return n.fetchSpec}catch{}throw new Error(r)}const $=(e,t)=>P(K(),e,t,{env:{...process.env,npm_config_ignore_scripts:"true"},shell:L(),maxBuffer:64*1024,timedOut:z,failed:Q}),J=(e,t)=>P("git",e,t,{env:{...process.env,GIT_TERMINAL_PROMPT:"0",GCM_INTERACTIVE:"never"},maxBuffer:1024*1024,timedOut:W,failed:F});async function le(e,t=$,r=y()){try{if(e.kind!=="npm"||!e.package||!/^(?:@[a-zA-Z0-9._-]+\/)?[a-zA-Z0-9._-]+$/u.test(e.package))throw new Error("missing_or_invalid_npm_package_identity");const n=U(e.package,e.version,"missing_or_invalid_installed_npm_version"),o=await t(["view",e.package,"dist-tags.latest","--json","--ignore-scripts"],r);let i;try{i=JSON.parse(o)}catch{throw new Error("invalid_npm_registry_metadata")}const a=Array.isArray(i)&&i.length===1?i[0]:i,s=U(e.package,a,"invalid_npm_registry_version");return{checked_at:m(),available:D(s,n),remote_version:s}}catch(n){return O(m(),n)}}const q=(e,t,r)=>{const n=e.split(/\r?\n/).map(a=>a.trim()).filter(Boolean).map(a=>{const[s,f=""]=a.split(/\s+/);return{commit:s,ref:f}}),o=n.find(a=>a.ref.endsWith("^{}"))??n[0];if(!o)return{checked_at:r,available:null,error:"no_remote_reference_found"};const i=t?.trim();return i?{checked_at:r,remote_commit:o.commit,available:o.commit!==i}:{checked_at:r,remote_commit:o.commit,available:null,error:"missing_installed_commit"}},ce=async(e,t=J,r=y())=>{if(e.kind!=="github"||!e.repository)return{checked_at:m(),available:null,error:"not_a_github_managed_source"};try{const n=[e.ref?.trim(),"HEAD"].find(Boolean),o=await t(["ls-remote",e.repository,n,`${n}^{}`],r);return q(o,e.commit,m())}catch(n){return O(m(),n)}};export{G as EXTENSION_UPDATE_CHECK_TIMEOUT_DEFAULT_MS,F as GITHUB_REMOTE_LOOKUP_FAILED,W as GITHUB_REMOTE_LOOKUP_TIMED_OUT,Q as NPM_REGISTRY_LOOKUP_FAILED,z as NPM_REGISTRY_LOOKUP_TIMED_OUT,B as PM_EXTENSION_UPDATE_CHECK_TIMEOUT_MS_ENV,ce as checkGithubUpdate,le as checkNpmUpdate,y as resolveExtensionUpdateCheckTimeoutMs,ae as updateCheckTeardown,de as withUpdateCheckTeardownScope};
|
|
2
2
|
//# sourceMappingURL=update-check.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{constants as h}from"node:fs";import _ from"node:fs/promises";import d from"node:path";import{isReproducibleExecutionActive as M}from"../../core/reproducibility/context.js";import{acquireLockLease as T}from"../../core/lock/lock.js";import{writeFileAtomic as L}from"../../core/fs/fs-utils.js";import{normalizeManagedState as R,resolveManagedExtensionStatePath as C}from"./managed-state.js";import{isFileMissingError as U}from"../../core/fs/fs-utils.js";import{isExactNpmVersion as w,isNewerRegistryVersion as B,isRegistryNpmSource as E}from"./npm-spec.js";import{normalizeExtensionNameForMatch as u}from"./shared.js";const F="extension-update-observations.json",b=1,D=64*1024,I=16*1024*1024,O=1024*1024,V=300*1e3,A=2e3;function g(t){return d.join(t,"runtime",F)}const S=256;function l(t,e){const n=t[e];return typeof n=="string"&&n.length>0&&n.length<=S?n:void 0}function $(t){const e=Date.parse(t);return Number.isFinite(e)&&e<=Date.now()+V}function j(t){return t.remote_version===void 0||t.remote_version===null?null:l(t,"remote_version")}function X(t){if(typeof t!="object"||t===null||Array.isArray(t))return;const e=t,n=l(e,"name"),a=l(e,"installed_version"),r=l(e,"installed_updated_at"),i=l(e,"checked_at"),o=j(e);if(!(n===void 0||a===void 0||r===void 0||o===void 0)&&!(i===void 0||!$(i)||typeof e.update_available!="boolean"))return{name:n,installed_version:a,installed_updated_at:r,remote_version:o,update_available:e.update_available,checked_at:i}}const z=".stale-cleanup",K=64*1024;async function P(t){try{const e=await _.lstat(t);return!e.isFile()||e.size>K}catch{return!1}}async function x(t){try{return!(await _.lstat(t)).isDirectory()}catch{return!1}}async function W(t){const e=g(t);try{if(await x(d.dirname(e)))return[];const n=await k(e,O);if(n===void 0)return[];const a=JSON.parse(n),r=typeof a=="object"&&a!==null?a:{};return(r.version===b&&Array.isArray(r.observations)?r.observations:[]).flatMap(o=>X(o)??[])}catch{return[]}}function G(t=h,e=!1){return t.O_RDONLY|(e?0:t.O_NOFOLLOW??0)|(t.O_NONBLOCK??0)}async function k(t,e,n={}){if(n.followLinks!==!0&&!(await _.lstat(t)).isFile())return;const a=await _.open(t,G(h,n.followLinks===!0));try{if(!(await a.stat()).isFile())return;const r=Buffer.alloc(Math.min(D,e+1)),i=[];let o=0;for(;o<=e;){const{bytesRead:s}=await a.read(r,0,Math.min(r.length,e+1-o),o);if(s===0)break;i.push(Buffer.from(r.subarray(0,s))),o+=s}return o>e?void 0:Buffer.concat(i,o).toString("utf8")}finally{await a.close()}}function Y(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"||E(e.source))&&[e.name,e.manifest_version,e.updated_at,e.last_update_remote_version??""].every(n=>n.length<=S)?[{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 H(t){let e;try{e=await k(C(t),I,{followLinks:!0})}catch(n){return U(n)?[]:void 0}if(e!==void 0)try{const n=JSON.parse(e),a=R(n),r=n.entries;return a!==null&&Array.isArray(r)&&r.length===a.entries.length?a.entries:void 0}catch{return}}function p(t){const e=new Map;for(const n of t){const a=`${u(n.name)}\0${n.installed_version}\0${n.installed_updated_at}`,r=e.get(a);(r===void 0||Date.parse(r.checked_at)<=Date.parse(n.checked_at))&&e.set(a,n)}return[...e.values()]}function J(t,e){return u(t.name)===u(e.name)&&t.installed_version===e.manifest_version&&t.installed_updated_at===e.updated_at}async function q(t,e,n){if(n.length===0)return;const a=g(t),r=async()=>{if(await x(d.dirname(a)))throw new Error(`${d.dirname(a)} is not a directory`)};await r();const i=d.join(t,"locks","extension-update-observations.lock");for(const s of[i,d.join(`${i}${z}`,"owner.json")])if(await P(s))throw new Error("update observation lock metadata is not a small regular file");const o=await T(t,"extension-update-observations",30,"pm package manage",!1,!1,A,{maxWaitMs:A});try{await r();const s=[...await W(t),...n],m=await H(e),N=(m===void 0?p(s):m.flatMap(c=>p(s.filter(f=>J(f,c)&&y(f,c.source))))).sort((c,f)=>c.name.localeCompare(f.name)),v=`${JSON.stringify({version:b,observations:N},null,2)}
|
|
2
|
+
`;if(Buffer.byteLength(v,"utf8")>O)throw new Error("update observation record exceeds its size limit");await o.fence(()=>L(a,v))}finally{await o.release()}}async function ue(t,e,n,a){if(!(a||M()))try{await q(t,e,Y(n));return}catch(r){const i=r?.context?.code;return typeof i=="string"&&i.length>0?`extension_update_observation_write_failed:${i}`:"extension_update_observation_write_failed"}}function le(t,e){if(typeof e.version!="string"||e.updated_at===void 0)return;const n=u(e.name);return p(t.filter(a=>u(a.name)===n&&a.installed_version===e.version&&a.installed_updated_at===e.updated_at&&y(a,e.source)))[0]}function Q(t,e){const n=e?.trim().toLowerCase(),a=t.remote_version?.toLowerCase();return!n||a===void 0||!/^[0-9a-f]{7,40}$/u.test(a)?!1:n.startsWith(a)!==t.update_available}function y(t,e){return e===void 0?!0:e.kind==="github"?Q(t,e.commit):E(e)?typeof e.version=="string"&&w(e.version)&&t.remote_version!==null&&w(t.remote_version)&&B(t.remote_version,e.version)===t.update_available:t.update_available===!1}function ce(t){return t?.update_available===!0?t.remote_version??"available":null}export{F as EXTENSION_UPDATE_OBSERVATIONS_FILE,Y as collectExtensionUpdateObservations,le as findApplicableUpdateObservation,k as readBoundedRegularFile,W as readExtensionUpdateObservations,H as readStrictManagedRecords,ue as recordCheckedUpdateObservations,q as recordExtensionUpdateObservations,g as resolveExtensionUpdateObservationsPath,G as resolveGuardedReadFlags,ce as resolveObservedUpdateVersion};
|
|
3
|
+
//# sourceMappingURL=update-observations.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import o from"node:path";import{renderPmCommand as p}from"../command-line.js";function c(r,e,n=!1){return["project","global"].filter(t=>r.some(a=>a.scope===t)).map(t=>p(["--pm-path",s(e),...n?["--no-extensions"]:[],"package","manage",`--${t}`]))}function s(r){const e=o.resolve(r);return/\s$/u.test(e)?`${e}${o.sep}.`:e}export{c as buildExtensionUpgradeHints,s as renderTrimSafeTrackerPath};
|
|
2
|
+
//# sourceMappingURL=upgrade-hints.js.map
|
package/dist/sdk/extension.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export type ExtensionScope="project"|"global";
|
|
|
12
12
|
export type ExtensionActivationStatus="ok"|"failed"|"not_loaded"|"unknown";
|
|
13
13
|
/** Documents the extension command options payload exchanged by command, SDK, and package integrations. */
|
|
14
14
|
export interface ExtensionCommandOptions{
|
|
15
|
+
/** Declared lifecycle scope from MCP and SDK callers; selects the same scope as the `project`/`local`/`global` switches. */
|
|
16
|
+
scope?:"project"|"local"|"global";
|
|
15
17
|
/** Value that configures or reports install for this contract. */
|
|
16
18
|
install?:boolean;
|
|
17
19
|
/** Value that configures or reports uninstall for this contract. */
|