nemar-cli 0.10.21 → 0.10.22-PR1863.caf1deb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -99,7 +99,7 @@ ${t}`,g4e,y4e,b4e=(e,t,r)=>{let n=r===""?"":`with ${r.trim()}() `,i=h4e.bind(nul
|
|
|
99
99
|
`)}var TC=!1;var{spawn:ZQe}=globalThis.Bun;function lu(e,t=[]){let r=e.replace(eZe,'("$1","<redacted>")');for(let n of t)if(n.length>=tZe)r=r.split(n).join("<redacted>");return r}function Gx(e){let t=["AWS_SESSION_TOKEN","AWS_SECRET_ACCESS_KEY","AWS_ACCESS_KEY_ID"],r=new Set;for(let n of[process.env,e??{}])for(let i of t){let o=n[i];if(typeof o==="string"&&o.length>0)r.add(o)}return[...r]}async function Lne(e,t){let r=e.getReader(),n=new TextDecoder,i="";while(!0){let{done:o,value:s}=await r.read();if(o)break;if(s.byteLength===0)continue;t(),i+=n.decode(s,{stream:!0})}return i+n.decode()}async function k(e,t={}){let r={...process.env,GIT_TERMINAL_PROMPT:"0",...t.env};for(let b of t.unsetEnv??[])delete r[b];let n=ZQe({cmd:e,cwd:t.cwd,...t.stdin===void 0?{}:{stdin:new TextEncoder().encode(t.stdin)},stdout:"pipe",stderr:"pipe",env:r}),i=!1,o,s,a=performance.now(),c=()=>{if(s!==void 0)clearTimeout(s),s=void 0},u=()=>{if(!t.onInactivityWarning)return;c(),s=setTimeout(()=>{s=void 0;try{t.onInactivityWarning?.(performance.now()-a)}catch{console.error("Could not display subprocess inactivity warning; the child result is unaffected.")}},t.inactivityWarningAfterMs??rZe)};if(u(),t.timeout)o=setTimeout(()=>{i=!0,c(),n.kill()},t.timeout);let d=Hx()?[...Gx(r),...t.redact??[]]:[];if(Hx()){let b=t.cwd?` (cwd=${t.cwd})`:"";Xc(l.dim(lu(`$ ${e.join(" ")}${b}`,d)))}let f=()=>{a=performance.now(),u()},p,m,g,h=n.exited.then((b)=>(c(),b));try{[p,m,g]=await Promise.all([Lne(n.stdout,f),Lne(n.stderr,f),h])}finally{if(c(),o)clearTimeout(o)}if(Hx()){if(t.sensitiveOutput)Xc(l.dim("[sensitive subprocess output suppressed]"));else{if(p.trim())Xc(l.dim(lu(p.trimEnd(),d)));if(m.trim())Xc(l.yellow(lu(m.trimEnd(),d)))}Xc(l.dim(`(exit ${g})`))}if(i)return{stdout:p,stderr:m||`Command timed out after ${Math.round(t.timeout/1000)}s`,exitCode:g??1,timedOut:!0};return{stdout:p,stderr:m,exitCode:g,timedOut:!1}}var eZe,tZe=8,rZe=120000;var Lt=F(()=>{je();eZe=/\(\s*"((?:x-amz-)[^"]*|authorization|proxy-authorization)"\s*,\s*"[^"]*"\s*\)/gi});function iZe(){if(process.platform==="darwin")return"macos";if(process.platform==="win32")return"windows";return"linux"}function Une(e,t=iZe()){return e.installInstructions[t]}function oZe(e){let t=e.match(/(\d+\.\d+(?:\.\d+)?)/);return t?t[1]:void 0}function aZe(){let e=Number(process.env.TEST_PROBE_TIMEOUT_MS);return Number.isFinite(e)&&e>0?e:sZe}async function zne(e){try{let{exitCode:t,stdout:r,timedOut:n}=await k(e.cmd,{timeout:aZe()});if(n)return{available:!1,timedOut:!0};if(t!==0)return{available:!1};return{available:!0,version:oZe(r)}}catch(t){let r=t instanceof Error?t.message:String(t);if(!r.includes("ENOENT")&&!r.includes("not found"))console.error(` Warning: ${e.name} check failed unexpectedly: ${r}`);return{available:!1}}}async function Gh(){let e=Object.entries(Bne);return Promise.all(e.map(async([t,r])=>{let{available:n,version:i,timedOut:o}=await zne(r);return{key:t,name:r.name,purpose:r.purpose,required:r.required,available:n,version:i,timedOut:o,installInstruction:Une(r)}}))}async function Vne(){let t=(await Gh()).filter((r)=>r.required&&!r.available);if(t.length===0)return[];console.warn(`
|
|
100
100
|
Heads up: some tools NEMAR needs for uploading/validating aren't installed yet:`);for(let r of t)console.warn(` - ${r.name} (${r.purpose})`),console.warn(` Install: ${r.installInstruction}`);return console.warn("Run `nemar doctor` anytime to re-check. You can finish signup without them.\n"),t}async function uu(e){let r=nZe[e].map((s)=>Bne[s]).filter(Boolean),n=await Promise.all(r.map(async(s)=>{let a=await zne(s);return{check:s,available:a.available,timedOut:a.timedOut}}));for(let s of n)if(s.timedOut&&s.check.required)console.warn(`Warning: ${s.check.name} did not respond to a version check in time; continuing anyway.`);let i=n.filter((s)=>!s.available&&!s.timedOut&&s.check.required).map((s)=>({tool:s.check.name,installInstruction:Une(s.check)}));if(i.length===0)return;let o=[`
|
|
101
101
|
Missing required tools:`];for(let s of i)o.push(` ${s.tool} not installed`),o.push(` Install: ${s.installInstruction}`);throw Error(o.join(`
|
|
102
|
-
`))}var Bne,nZe,sZe=4000;var Wh=F(()=>{Lt();Bne={git:{name:"git",purpose:"version control for dataset metadata",cmd:["git","--version"],required:!0,installInstructions:{macos:"brew install git (or install Xcode Command Line Tools)",linux:"sudo apt-get install git OR sudo dnf install git",windows:"winget install Git.Git (or https://git-scm.com/download/win)"}},"git-annex":{name:"git-annex",purpose:"large-file data transfer (upload/download)",cmd:["git-annex","version"],required:!0,installInstructions:{macos:"brew install git-annex",linux:"sudo apt-get install git-annex OR sudo dnf install git-annex",windows:"Download the installer from https://git-annex.branchable.com/install/Windows/"}},gh:{name:"GitHub CLI (gh)",purpose:"GitHub authentication + repository operations",cmd:["gh","--version"],required:!0,installInstructions:{macos:"brew install gh",linux:"See https://cli.github.com/manual/installation",windows:"winget install GitHub.cli (or: scoop install gh)"}},aws:{name:"AWS CLI",purpose:"S3 data upload/download",cmd:["aws","--version"],required:!0,installInstructions:{macos:"brew install awscli",linux:"pip install awscli OR sudo snap install aws-cli --classic",windows:"winget install Amazon.AWSCLI (or the MSI from https://aws.amazon.com/cli/)"}},deno:{name:"Deno",purpose:"BIDS validation",cmd:["deno","--version"],required:!0,installInstructions:{macos:"brew install deno (or: curl -fsSL https://deno.land/install.sh | sh)",linux:"curl -fsSL https://deno.land/install.sh | sh",windows:"winget install DenoLand.Deno (or: irm https://deno.land/install.ps1 | iex)"}}},nZe={upload:["git-annex","gh","aws","deno"],download:["gh"],clone:["git","gh"],push:["git-annex","gh"],publish:["gh","aws"],update:["git","gh"],release:["git","gh"]}});var Gne;var Hne=F(()=>{Gne={name:"nemar-cli",packageManager:"bun@1.4.3",version:"0.10.
|
|
102
|
+
`))}var Bne,nZe,sZe=4000;var Wh=F(()=>{Lt();Bne={git:{name:"git",purpose:"version control for dataset metadata",cmd:["git","--version"],required:!0,installInstructions:{macos:"brew install git (or install Xcode Command Line Tools)",linux:"sudo apt-get install git OR sudo dnf install git",windows:"winget install Git.Git (or https://git-scm.com/download/win)"}},"git-annex":{name:"git-annex",purpose:"large-file data transfer (upload/download)",cmd:["git-annex","version"],required:!0,installInstructions:{macos:"brew install git-annex",linux:"sudo apt-get install git-annex OR sudo dnf install git-annex",windows:"Download the installer from https://git-annex.branchable.com/install/Windows/"}},gh:{name:"GitHub CLI (gh)",purpose:"GitHub authentication + repository operations",cmd:["gh","--version"],required:!0,installInstructions:{macos:"brew install gh",linux:"See https://cli.github.com/manual/installation",windows:"winget install GitHub.cli (or: scoop install gh)"}},aws:{name:"AWS CLI",purpose:"S3 data upload/download",cmd:["aws","--version"],required:!0,installInstructions:{macos:"brew install awscli",linux:"pip install awscli OR sudo snap install aws-cli --classic",windows:"winget install Amazon.AWSCLI (or the MSI from https://aws.amazon.com/cli/)"}},deno:{name:"Deno",purpose:"BIDS validation",cmd:["deno","--version"],required:!0,installInstructions:{macos:"brew install deno (or: curl -fsSL https://deno.land/install.sh | sh)",linux:"curl -fsSL https://deno.land/install.sh | sh",windows:"winget install DenoLand.Deno (or: irm https://deno.land/install.ps1 | iex)"}}},nZe={upload:["git-annex","gh","aws","deno"],download:["gh"],clone:["git","gh"],push:["git-annex","gh"],publish:["gh","aws"],update:["git","gh"],release:["git","gh"]}});var Gne;var Hne=F(()=>{Gne={name:"nemar-cli",packageManager:"bun@1.4.3",version:"0.10.22-PR1863.caf1deb",description:"CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",type:"module",main:"dist/index.js",bin:{nemar:"dist/index.js"},scripts:{dev:"bun run src/index.ts",build:"bun build src/index.ts --outdir dist --target bun --minify && sed '1s|#!/usr/bin/env node|#!/usr/bin/env bun|' dist/index.js > dist/index.js.tmp && mv dist/index.js.tmp dist/index.js",test:"bun test",lint:"biome check src/","lint:scrub":"biome check scripts/scrub shared/identifier-scrub.ts test/scrub","test:scrub":"bun test --preload ./test/scrub/helpers/temp-dirs-preload.ts --path-ignore-patterns='__run_every_scrub_suite__' test/scrub test/identifier-scan.test.ts test/identifier-scrub.test.ts test/identifier-dates.test.ts test/identifier-fleet.test.ts","migrations:d1-check":"bun run scripts/d1-migration-check.ts","zarr:geometry-check":"bun run backend/scripts/zarr-geometry-conformance.ts","lint:fix":"biome check --fix src/",format:"biome format --write src/",typecheck:"tsc --noEmit && tsc --noEmit -p backend","generate-openapi":"bun run scripts/generate-openapi.ts",prepublishOnly:"bun run build",prepare:"husky",postinstall:"bun scripts/postinstall-check.mjs",deploy:"wrangler deploy",preview:"wrangler dev"},keywords:["nemar","bids","neuroimaging","eeg","emg","datalad","cli"],author:"NEMAR Team",license:"CC-BY-NC-ND-4.0",repository:{type:"git",url:"git+https://github.com/nemarOrg/nemar-cli.git"},bugs:{url:"https://github.com/nemarOrg/nemar-cli/issues"},homepage:"https://docs.nemar.org",engines:{bun:">=1.0.0"},files:["dist","scripts/postinstall-check.mjs","scripts/recover-datasets.json","scripts/withdrawn-datasets.json","README.md","LICENSE"],dependencies:{chalk:"^5.3.0",commander:"^12.1.0",conf:"^13.0.1",inquirer:"^9.2.15",ora:"^8.0.1",semver:"^7.8.5",zod:"^3.23.8"},"lint-staged":{"src/**/*.{ts,tsx}":["biome check --fix"],"backend/src/**/*.{ts,tsx}":["biome check --fix"]},devDependencies:{"@anthropic-ai/sdk":"^0.132.1","@asteasolutions/zod-to-openapi":"^7.3.4","@biomejs/biome":"1.9.4","@types/bun":"latest","@types/inquirer":"^9.0.7","@types/semver":"^7.8.0",ajv:"^8.20.0","ajv-formats":"^3.0.1",husky:"^9.1.7","lint-staged":"^16.3.2",typescript:"^5.5.4",wrangler:"^4.70.0",yaml:"^2.8.4"}}});var ao;var ep=F(()=>{Hne();ao=Gne.version});import{mkdirSync as lZe,readdirSync as uZe,unlinkSync as dZe,writeFileSync as fZe}from"fs";import{join as PC}from"path";function Qne(){tp=!0}function du(){return tp}function Zne(e,t=process.env){return e.includes("--debug")||t.NEMAR_DEBUG==="1"}function Yh(e){Xne=e,rr(`Step: ${e}`)}function Qc(){Yne=!0}function eie(){return Yne}function ke(){if(Jne)return;FC=!0}function NC(){FC=!1,Jne=!0}function tie(){return FC}function rr(e){if(tp)process.stderr.write(`[debug] ${e}
|
|
103
103
|
`)}function gZe(e){let t={};for(let[r,n]of Object.entries(e))t[r]=hZe.has(r.toLowerCase())?"[REDACTED]":n;return t}function nie(e){let t=e.indexOf("@");if(t<=0)return"***";return`${e[0]}***${e.slice(t)}`}function IC(e,t,r=0){if(r>bZe)return"[REDACTED: depth]";if(Array.isArray(t))return t.map((n)=>IC(e,n,r+1));if(t&&typeof t==="object"){let n={};for(let[i,o]of Object.entries(t))n[i]=IC(i,o,r+1);return n}if(typeof t==="string"){if(yZe.test(e))return"[REDACTED]";return t.replace(rie,nie)}return t}function jC(e){return e.replace(wZe,"Bearer [REDACTED]").replace(xZe,"[REDACTED_AWS_KEY]").replace(vZe,"$1[REDACTED]").replace(_Ze,"$1$2=[REDACTED]").replace(rie,nie)}function DZe(e){return jC(e)}function Wne(e,t=mZe){if(e===void 0)return;let r=e;try{let n=JSON.parse(e);r=JSON.stringify(IC("",n))}catch{}if(r=jC(r),Buffer.byteLength(r,"utf8")>t)r=`${Buffer.from(r,"utf8").subarray(0,t).toString("utf8")}... [truncated]`;return r}function Yx(e){if(!tp)return;let t=DZe(e.url);try{let r={...e,url:t,requestHeaders:e.requestHeaders?gZe(e.requestHeaders):void 0,requestBody:Wne(e.requestBody),responseBody:Wne(e.responseBody)};Kx.push(r),rr(`${e.method} ${t} -> ${e.status??"ERROR"} (${e.durationMs}ms)`)}catch(r){let n=M(r);Kx.push({method:e.method,url:t,status:e.status,durationMs:e.durationMs,note:`redaction failed: ${n}`}),rr(`redaction failed for ${e.method} ${t}: ${n}`)}}async function EZe(){let e=[];try{let t=process.versions.bun?`Bun ${process.versions.bun}`:`Node ${process.version}`;e.push(`CLI version: ${ao}`),e.push(`OS/Arch: ${process.platform}/${process.arch}`),e.push(`Runtime: ${t}`)}catch(t){e.push(`(could not read CLI/OS/runtime info: ${M(t)})`)}e.push(""),e.push("Active account:");try{let t=jt();if(t.apiKey){if(t.username)e.push(` Username: ${t.username}`);if(e.push(` API URL: ${t.apiUrl}`),t.role)e.push(` Role: ${t.role}`);e.push(` Sandbox completed: ${!!t.sandboxCompleted}`)}else e.push(" (not authenticated)")}catch(t){e.push(` (could not read account config: ${M(t)})`)}e.push(""),e.push("External tools:");try{let t=await Gh();for(let r of t){let n=r.available?r.version??"installed":r.timedOut?"(timed out)":"not installed";e.push(` ${r.name}: ${n}`)}}catch(t){e.push(` (could not probe external tools: ${M(t)})`)}return e}async function MC(){return(await EZe()).join(`
|
|
104
104
|
`)}async function iie(){if(!tp||Wx!==void 0)return;try{Wx=await MC()}catch(e){let t=M(e);Wx=`(could not build environment report: ${t})`,rr(`environment snapshot failed: ${t}`)}}function oie(e){if(Kne.has(e))return{flag:e};for(let t of Kne){if(!e.startsWith(t)||e.length<=t.length)continue;if(t.length===2)return{flag:t,kind:"short-attached"};if(e[t.length]==="=")return{flag:t,kind:"long-eq"}}return null}function SZe(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r],i=oie(n);if(!i){t.push(n);continue}if(i.kind==="long-eq")t.push(`${i.flag}=[REDACTED]`);else if(i.kind==="short-attached")t.push(`${i.flag}[REDACTED]`);else if(t.push(n),r+1<e.length)t.push("[REDACTED]"),r++}return t}function $Ze(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r],i=oie(n);if(!i){t.push(n);continue}if(!i.kind&&r+1<e.length)r++}return t}function kZe(e){let t=[];for(let n of $Ze(e)){if(n.startsWith("-"))continue;if(t.push(n),t.length===2)break}return(t.length>0?t.join("-"):"nemar").replace(/[^a-zA-Z0-9_-]/g,"_")}function RZe(e,t){let r=[];if(r.push("NEMAR CLI Debug Log"),r.push(`Generated: ${new Date().toISOString()}`),r.push(`Command: nemar ${jC(SZe(e).join(" "))}`),r.push(""),r.push(Wx??"(environment snapshot unavailable)"),r.push(""),r.push("HTTP requests:"),Kx.length===0)r.push(" (none)");else Kx.forEach((n,i)=>{if(r.push(` [${i+1}] ${n.method} ${n.url} -> ${n.status??"ERROR"} (${n.durationMs}ms)`),n.error)r.push(` Error: ${n.error}`);if(n.note)r.push(` Note: ${n.note}`);if(n.requestHeaders)r.push(` Request headers: ${JSON.stringify(n.requestHeaders)}`);if(n.requestBody)r.push(` Request body: ${n.requestBody}`);if(n.responseBody)r.push(` Response body: ${n.responseBody}`)});return r.push(""),r.push(`Failing step: ${Xne??"(none recorded)"}`),r.push(`Exit code: ${t}`),`${r.join(`
|
|
105
105
|
`)}
|
|
@@ -237,7 +237,7 @@ Exemplar clone + publish complete: ${o} -> ${i}`)),console.log(l.dim(` GitHub:
|
|
|
237
237
|
${G.replace(/^/gm," ")}`}let I=" ".repeat(Math.max(0,W-A.length)),H=`${A}${I}${P}`,ne=t.wrap(H,r-2,W);return L+ne.slice(A.length)}function u(A){return A.join(`
|
|
238
238
|
`).replace(/^/gm," ".repeat(2))}let d=[];d.push(`Usage: ${t.commandUsage(e)}`,"");let f=t.commandDescription(e);if(f.length>0)d.push(t.wrap(f,r,0),"");let p=t.visibleArguments(e),m=a(p.map((A)=>t.argumentTerm(A))),g=p.map((A)=>{let L=t.argumentTerm(A);return c(L,l.blue(L),t.argumentDescription(A),m)});if(g.length>0)d.push(l.bold("Arguments:"),u(g),"");let h=t.visibleOptions(e),b=a(h.map((A)=>t.optionTerm(A))),w=h.map((A)=>{let L=t.optionTerm(A);return c(L,l.cyan(L),t.optionDescription(A),b)});if(w.length>0)d.push(l.bold("Options:"),u(w),"");let x=(A,L)=>A.name().localeCompare(L.name()),v=(A)=>{let L=a(A.map((P)=>t.subcommandTerm(P)));return A.map((P)=>{let j=t.subcommandTerm(P);return c(j,l.bold.cyan(j),t.subcommandDescription(P),L)})},R=t.visibleCommands(e),E=Pbe(e),T=yE||!Object.hasOwn(gE,E)?void 0:gE[E];if(T){let A=new Map(R.map((W)=>[W.name(),W])),L=T.map((W)=>A.get(W)).filter((W)=>W!==void 0),P=new Set(L.map((W)=>W.name())),j=R.filter((W)=>!P.has(W.name())&&W.name()!=="help").sort(x);if(L.length===0)return d.push(l.bold("Commands:"),u(v([...R].sort(x))),""),d.join(`
|
|
239
239
|
`);if(d.push(l.bold("Commands:"),u(v(L)),""),j.length>0){let W=j.map((I)=>I.name()).join(", ");d.push(l.bold("More commands")+l.dim(" (--help-all for details):"),t.wrap(W,r-2,0).replace(/^/gm," "),"")}}else if(R.length>0)d.push(l.bold("Commands:"),u(v([...R].sort(x))),"");return d.join(`
|
|
240
|
-
`)}};function sI(e){aI(e)}function aI(e){e.configureHelp(Ibe);for(let t of e.commands)aI(t)}function Fr(e,t){if(yE)Wp.call(e,"after",t);else if(!$0.has(e))$0.add(e),Wp.call(e,"after",oI)}je();je();import{existsSync as hD,mkdirSync as ume,mkdtempSync as nT,readFileSync as wft,writeFileSync as s0}from"fs";import{tmpdir as iT}from"os";import{join as Ea}from"path";_i();sn();function Gz(e,t){return Math.min(Math.floor(Math.log(e)/Math.log(1024)),t)}function St(e){if(e===0)return"0 B";let t=["B","KB","MB","GB","TB"],r=Gz(e,t.length-1);return`${(e/1024**r).toFixed(r===0?0:1)} ${t[r]}`}function Wz(e){if(e===0)return"0 B";let t=["B","KB","MB","GB","TB"],r=Gz(e,t.length-1);return`${Number.parseFloat((e/1024**r).toFixed(2))} ${t[r]}`}sh();af();var Bb=50;var XV=["store","node","registration","drift"];function QV(e){let{verification:t,writerMode:r,now:n}=e;if(t===null)return r==="enabled"?{verdict:"unknown",note:"none recorded: the daily verification sweep has not run, which is unknown and not healthy"}:{verdict:"unchecked",note:null};let i=Date.parse(t.at),o=n.getTime()-i;if(Number.isNaN(i)||o>129600000){let s=Number.isNaN(i)?null:Math.floor(o/3600000);return{verdict:"unknown",note:s===null?"the last record has no readable time, so it says nothing about today":`the last record is ${s} hours old, so it says nothing about today`}}return{verdict:t.overall,note:null}}function E1(e){return e==="alarm"?1:e==="unknown"?2:0}var _8e=["store","node","registration","drift"];function D8e(e){return _8e.filter((t)=>e.checkDays[t].unchecked>0)}function S1(e){let t=[];if(e.coverageStatus==="alarm")t.push("coverage is alarming");if(e.coverageStatus==="unknown")t.push("coverage could not be determined");if(e.autoImportEnabled===!1)t.push("auto-import is OFF");if(e.dispatchLost===!0)t.push("dispatches are not landing");if(e.issuesClosed===null)t.push("no daily sweep activity was recorded, so the daily jobs may not be running");let r=e.neurobagel??null,n=[];if(r===null)t.push("no Neurobagel verification run was recorded, so that job may not be running");else{if(n=D8e(r),r.latest.overall==="alarm")t.push("Neurobagel verification is alarming");if(r.latest.overall==="unknown")t.push("Neurobagel verification could not be determined");if(r.days.alarm>0&&r.latest.overall!=="alarm")t.push(`Neurobagel verification alarmed on ${r.days.alarm} day(s) this week`);if(r.days.unknown>0&&r.latest.overall!=="unknown")t.push(`Neurobagel verification could not be determined on ${r.days.unknown} day(s)`);if(r.failedRuns>0)t.push(`the Neurobagel sweep itself failed on ${r.failedRuns} run(s)`);let i=Math.max(0,7-r.runs);if(i>1)t.push(`the daily Neurobagel verification is missing for ${i} of 7 day(s)`)}if(e.neurobagelFindings===null||e.neurobagelFindings===void 0)t.push("Neurobagel findings could not be counted");else if(e.neurobagelFindings>0)t.push(`${e.neurobagelFindings} Neurobagel finding(s) need attention (see the audit log)`);if(e.errors.length>0)t.push(`${e.errors.length} part(s) of this report failed`);return{attention:t.length>0,problems:t,notChecked:n}}je();var cf=2000,cc=10,lc=500,uc=/^(nm|on|xx)\d{6}$/;Tt();co();Ii();Br();function O(e){return typeof e==="string"?e.replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/gu,""):""}function el(e,t){let r=O(e);return r.length>t?`${r.slice(0,t-1)}\u2026`:r}function eg(e,t=Date.now()){let r=Date.parse(e);if(Number.isNaN(r))return"?";let n=Math.max(0,Math.floor((t-r)/1000));if(n<3600)return`${Math.floor(n/60)}m`;if(n<86400)return`${Math.floor(n/3600)}h`;return`${Math.floor(n/86400)}d`}var KC={owner_name_missing:"Run `nemar admin backfill-names --apply` if the owner's ORCID record publishes their name; an ORCID-linked owner must otherwise make it public on ORCID and sign in again, and an owner with no linked ORCID can now type it into Settings on nemar.org (ADR 0042)."};function ri(e){return e?(t)=>console.error(t):(t)=>console.log(t)}function lp(e){if(!(e instanceof q))return!1;if(e.statusCode>=400&&e.statusCode<500)return!0;let t=ap(e);return t!==void 0&&t!=="internal"}function WC(e,t,r,n){if(t)t.fail(e);else r(l.red(e));if(n)r(l.dim(` ${n}`))}function Die(e,t,r,n,i){if(e instanceof q){let s=(e.blockReason?KC[e.blockReason]:void 0)??n?.[e.statusCode]??(e.statusCode===403?"This command requires admin privileges":void 0);WC(O(e.message),t,i,s);return}WC(r,t,i,`Error details: ${O(M(e))}`)}function wt(e,t,r,n){Die(e,t,r,n,ri(!1))}function Or(e,t,r,n,i={}){if(Die(e,t,r,n,ri(i.json)),process.exitCode=1,lp(e))ke();else NC()}function fn(e,t){if(WC(O(e),t.spinner,ri(t.json),t.hint),process.exitCode=1,t.answered)ke();else NC()}function gs(e,t){if(uc.test(e))return e;return fn(`"${e}" is not a dataset id (like nm000108).`,{json:t,answered:!0}),null}function WZe(e){return/^[a-z]{2}\d{0,6}$/.test(e)}function KZe(e){return/^(nm|on|xx)0\d{5}$/.test(e)}function Eie(e,t){if(WZe(e))return e;return fn(`"${e}" is not a dataset id prefix: use two lowercase letters, then up to six digits (like nm or nm0001).`,{json:t,answered:!0}),null}function Sie(e,t){if(KZe(e))return e;return fn(`"${e}" is not a dataset id (like nm000312). --after takes the last id of the previous page.`,{json:t,answered:!0}),null}function ni(e){if(tt())return!0;let t=ri(e);return t(l.red("Error: Not authenticated")),t(l.dim(" Run 'nemar auth login' first")),process.exitCode=1,ke(),!1}je();sh();je();function up(e){return(t)=>{try{return e(t)}catch{return String(t)}}}var pn={id:up(l.cyan),metric:up(l.magenta),label:up(l.bold),warn:up(l.yellow),muted:up(l.dim),match:up(l.green)};var YZe=/[\u001b\u009b][\[\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PR-TZcf-ntqry=><~]/g,JZe=/[\n\r\t]+/g,XZe=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g;function Tr(e){return e.replace(YZe,"").replace(JZe," ").replace(XZe,"").trim()}var QZe=/(<mark>[\s\S]*?<\/mark>)/g,ZZe=/^<mark>([\s\S]*)<\/mark>$/,$ie=400;function kie(e){if(!e||typeof e!=="string")return null;try{let t=e.length>$ie?e.slice(0,$ie):e,r=Tr(t);if(!r)return null;return r.split(QZe).filter((n)=>n.length>0).map((n)=>{let i=n.match(ZZe);return i?pn.match(i[1]):pn.muted(n)}).join("")}catch{return null}}function Rie(e,t){if(!Number.isFinite(t)||t<=0)return e;if(e.length<=t)return e;let r=e.split(","),n=[],i=0;for(let s of r){let a=n.length===0?s.length:i+1+s.length;if(a>t)break;n.push(s),i=a}let o=r.length-n.length;if(n.length===0){let s=r[0],a=Math.max(0,t-1),c=a>0?`${s.slice(0,a)}\u2026`:"\u2026",u=r.length-1;return u>0?`${c} +${u}`:c}return o>0?`${n.join(",")} +${o}`:n.join(",")}function mu(e){return Tr(e??"")}function YC(e){let t=e.match_kind;return typeof t==="string"&&dV.includes(t)?t:void 0}function JC(e){let t=e.filter((r)=>YC(r)==="exact");return t.length===1?t[0]:null}function XC(e){return e.length>0&&e.every((t)=>YC(t)==="fuzzy")}function QC(e){return e.length===0||e.some((t)=>YC(t)!==void 0)}function Cie(e){if(e.length===0)return{kind:"none"};let t=JC(e);if(t)return{kind:"one",user:t,match:"exact"};let r=XC(e)?"fuzzy":"partial";if(e.length===1)return{kind:"one",user:e[0],match:r};return{kind:"many",users:[...e],match:r}}var rv=[["givenName","given_name"],["familyName","family_name"],["affiliation","affiliation"],["city","city"],["country","country"],["username","username"],["github","github_username"],["email","email"],["orcid","orcid"]];var tv=[{option:"clearAffiliation",valueOption:"affiliation",field:"affiliation"},{option:"clearGithub",valueOption:"github",field:"github_username"}];function tl(e){return`--${e.replace(/[A-Z]/g,(t)=>`-${t.toLowerCase()}`)}`}function Aie(e){let t={};for(let[r,n]of rv){let i=e[r];if(typeof i!=="string")continue;if((n==="github_username"?i.trim().replace(/^@/,""):i.trim())===""){let s=tv.find((a)=>a.valueOption===r);return{ok:!1,message:s?`${tl(r)} needs a value. To remove it, say so with ${tl(s.option)}.`:`${tl(r)} needs a value.`}}t[n]=i}for(let{option:r,valueOption:n,field:i}of tv){if(e[r]!==!0)continue;if(i in t)return{ok:!1,message:`Use either ${tl(n)} or ${tl(r)}, not both.`};t[i]=""}return{ok:!0,body:t}}function Oie(e,t){let r=[];for(let[,n]of rv){let i=t[n];if(i===void 0)continue;let o=e[n]??null;if((o??"")===i){if(n==="orcid"&&!e.orcid_verified)r.push({field:n,from:`${i} (unverified)`,to:`${i} (verified, attested)`});continue}r.push({field:n,from:o,to:i})}return r}function ii(e,t="-"){let r=mu(e);return r!==""?r:t}function tg(e){if(e===null)return l.dim("(none)");if(e==="")return l.dim("(cleared)");return ii(e,l.dim("(blank)"))}function pu(e){if(!e)return"-";let t=new Date(e.includes("T")?e:`${e.replace(" ","T")}Z`);return Number.isNaN(t.getTime())?mu(e):t.toISOString().replace("T"," ").slice(0,16)}function ZC(e){let t=(a)=>l.dim(`${a}:`.padEnd(15)),r=[e.given_name,e.family_name].filter(Boolean).join(" "),n=[e.city,e.country].filter(Boolean).join(", "),i=e.role||"member",o=e.service_access===void 0||e.service_access===null?"unknown":e.service_access?"upload":"browse",s=[];if(s.push(`${l.cyan(ii(e.username??e.email))}${l.dim(` [${mu(i)}] id ${e.id}`)}${e.username===null?l.dim(" (no username)"):""}`),s.push(` ${t("Name")}${ii(r)}`),s.push(` ${t("Email")}${ii(e.email)} ${e.email_verified?l.green("(verified)"):l.yellow("(unverified)")}`),s.push(` ${t("GitHub")}${e.github_username?`@${ii(e.github_username)}`:"-"}`),s.push(` ${t("ORCID")}${e.orcid?`${ii(e.orcid)} ${e.orcid_verified?l.green("(verified)"):l.yellow("(unverified)")}`:"-"}`),s.push(` ${t("Affiliation")}${ii(e.affiliation)}`),s.push(` ${t("Location")}${ii(n)}`),s.push(` ${t("Status")}${mu(e.status)}`),s.push(` ${t("Upload access")}${o}${e.service_access&&e.service_access_granted_at?l.dim(` (granted ${pu(e.service_access_granted_at)}${e.service_access_granted_by?` by id ${e.service_access_granted_by}`:""})`):""}`),e.upload_access_requested_at)s.push(` ${t("Asked")}${pu(e.upload_access_requested_at)} (upload access)`);if(s.push(` ${t("Kind")}${mu(e.account_kind)||"-"}`),s.push(` ${t("Signed up via")}${ii(e.signup_source)}`),s.push(` ${t("Created")}${pu(e.created_at)}`),e.approved_at)s.push(` ${t("Approved")}${pu(e.approved_at)}`);if(e.revoked_at)s.push(` ${t("Revoked")}${pu(e.revoked_at)}`);if(s.push(` ${t("Last changed")}${pu(e.updated_at)}`),s.push(` ${t("Datasets")}${e.dataset_count??"-"}${l.dim(" API keys: ")}${e.active_tokens??"-"}`),s.push(` ${t("Sign-in")}${e.linked_identities&&e.linked_identities.length>0?e.linked_identities.map((a)=>mu(a)).join(", "):"-"}`),e.description)s.push(` ${t("Description")}${ii(e.description)}`);if(e.identity_conflict)s.push(` ${l.yellow("! Flagged as a duplicate identity: see 'nemar admin duplicates'")}`);if(e.username_auto_assigned)s.push(` ${l.dim("The username was derived from the name, not chosen")}`);if(e.deleted_at)s.push(` ${l.red(`Deleted ${pu(e.deleted_at)} (tombstoned)`)}`);return s}function e2(e){let t=[e.given_name,e.family_name].filter(Boolean).join(" "),r=e.matched_in&&e.matched_in.length>0?l.dim(` matched: ${e.matched_in.map((n)=>mu(n)).join(", ")}`):"";return` ${String(e.id).padStart(5)} ${l.cyan(ii(e.username,"(no username)"))} ${ii(t,"")} ${l.dim(ii(e.email))}${r}`}hu();la();nl();Tt();aa();var h2=["critical","warning","maintenance","announcement","tip"];async function ise(){return N("/notices",{},"optional")}async function ose(){return N("/admin/notices",{},!0)}async function sse(e){return N("/admin/notices",{method:"POST",body:JSON.stringify(e)},!0)}async function ase(e){return N(`/admin/notices/${e}`,{method:"DELETE"},!0)}Ii();_i();async function Re(e,t,r=!1){if(t.no)return"declined";if(t.yes)return"confirmed";if(!process.stdin.isTTY)return console.error("Interactive prompt unavailable; use --yes or --no"),"cancelled";try{let{confirmed:n}=await ve.prompt([{type:"confirm",name:"confirmed",message:e,default:r}]);return n?"confirmed":"cancelled"}catch(n){let i=n instanceof Error?n.message:String(n);if(i.includes("closed")||i.includes("TTY")||i.includes("SIGINT")||i.includes("readline"))console.error("Interactive prompt unavailable (non-interactive terminal or interrupted)"),console.error(" Use --yes or --no flags for non-interactive mode");else console.error("Prompt error:",i);return"cancelled"}}async function cse(e,t,r){if(r.no)return"declined";if(r.yes)return"confirmed";if(!process.stdin.isTTY)return console.error("Interactive prompt unavailable; use --yes or --no"),"cancelled";try{let{input:n}=await ve.prompt([{type:"input",name:"input",message:e,validate:(i)=>{if(i!==t)return`Input does not match. Expected: ${t}`;return!0}}]);return n===t?"confirmed":"cancelled"}catch(n){let i=n instanceof Error?n.message:String(n);if(i.includes("closed")||i.includes("TTY")||i.includes("SIGINT")||i.includes("readline"))console.error("Interactive prompt unavailable (non-interactive terminal or interrupted)"),console.error(" Use --yes or --no flags for non-interactive mode");else console.error("Prompt error:",i);return"cancelled"}}var qe="-y, --yes",rt="-n, --no",Ve="Skip confirmation and proceed",Ze="Skip confirmation and decline";Br();var lse="__Host-nemar_docs_session";af();aa();Tt();async function g2(e){return N("/auth/login",{method:"POST",body:JSON.stringify({api_key:e})})}async function use(e){return N("/auth/resend-verification",{method:"POST",body:JSON.stringify({email:e})})}async function dse(e){return N("/auth/request-key-regeneration",{method:"POST",body:JSON.stringify({email:e})})}async function oi(){return(await N("/users/me",{},!0,oV)).user}async function fse(e){return N("/sandbox/complete",{method:"POST",body:JSON.stringify({dataset_id:e})},!0)}async function pse(){return N("/sandbox/reset",{method:"POST"},!0)}async function dv(){return N("/sandbox/status",{},!0)}async function mse(e){return N("/users/me/upload-access/request",{method:"POST",body:JSON.stringify({why:e})},!0)}async function hse(e){return N("/auth/email/change/request",{method:"POST",body:JSON.stringify({email:e})},!0)}async function gse(e,t){return N("/auth/email/change/verify",{method:"POST",body:JSON.stringify({email:e,code:t})},!0)}async function y2(e){return N("/auth/profile",{method:"PATCH",body:JSON.stringify(e)},!0)}async function yse(e){return N("/auth/orcid/cli-start",{method:"POST",body:JSON.stringify({mode:e})},!0)}async function bse(){return N("/auth/orcid/unlink",{method:"POST"},!0)}async function wse(e){return N("/auth/device/start",{method:"POST",body:JSON.stringify({machine_name:e})},!1,TV)}function eet(e){return typeof e==="string"&&Cb.options.includes(e)}function tet(e){if(typeof e!=="object"||e===null)return;let t=e.message;return typeof t==="string"?t:void 0}async function xse(e,t){try{return{status:"success",data:await N("/auth/device/token",{method:"POST",body:JSON.stringify({device_code:e}),signal:t},!1,IV)}}catch(r){if(r instanceof q&&r.statusCode===400){let n=PV.safeParse(r.rawBody);if(n.success){let i=n.data;if(i.error==="authorization_pending")return{status:"pending"};if(i.error==="slow_down")return{status:"slow_down"};return{status:"terminal",error:i.error,reason:i.reason,message:i.message}}if(eet(r.code)&&r.code!=="authorization_pending"&&r.code!=="slow_down")return{status:"terminal",error:r.code,reason:void 0,message:tet(r.rawBody)??AV[r.code]}}throw r}}async function vse(){return N("/auth/keys",{},!0,Ab)}async function _se(e){return N("/auth/keys",{method:"POST",body:JSON.stringify({name:e})},!0,Ob)}async function Dse(){return N("/auth/docs/cli-session",{method:"POST"},!0)}async function fv(e){return N(`/auth/keys/${e}`,{method:"DELETE"},!0)}async function Ese(e,t){return N(`/auth/keys/${e}`,{method:"DELETE",headers:{Authorization:`Bearer ${t}`}},!1)}async function Sse(){return N("/auth/profile/username-suggestion",{},!0,aV)}var ret="https://docs.nemar.org";function pv(){return process.env.NEMAR_DOCS_URL||ret}var $se=20000;function net(e){let t=e.trim();if(/^https?:\/\//i.test(t)){let n=new URL(t),i=new URL(pv()).hostname;if(n.hostname.toLowerCase()!==i.toLowerCase())throw Error(`Not a ${i} URL: ${e}`);t=n.pathname}if(t=t.replace(/[?#].*$/,""),!t.startsWith("/"))t=`/${t}`;if(t.length>1&&t.endsWith("/"))t=t.slice(0,-1);if(t===""||t==="/")return"/index.md";return t.slice(t.lastIndexOf("/")+1).includes(".")?t:`${t}.md`}function iet(e,t){if(e===302||e===301||e===307||e===308){if(t?.includes("/auth/docs/authorize"))return"the documentation session was refused (it may have expired mid-run); try again";return`redirected to ${t??"an unknown location"}`}if(e===404)return"not found, or it is a gated page and this account is not an admin";if(e===401)return"the documentation session was rejected; it may have expired, try again";if(e===403)return"this account is no longer an admin, so the documentation session was refused";if(e===503)return"the documentation gate could not reach the API; try again shortly";return`unexpected status ${e}`}async function kse(e){let t=e.map((s)=>{try{return{input:s,path:net(s)}}catch(a){return{input:s,error:a.message}}});if(!t.some((s)=>s.path))return t.map((s)=>({path:s.input,ok:!1,error:s.error??"not a usable documentation path"}));let r=await Dse();if(typeof r?.session!=="string"||r.session.length===0)throw Error("The API returned no documentation session value.");let n=pv().replace(/\/$/,""),i=`${lse}=${r.session}`,o=[];for(let s of t){if(!s.path){o.push({path:s.input,ok:!1,error:s.error??"unusable path"});continue}let a=s.path;try{let c=await fetch(`${n}${a}`,{redirect:"manual",signal:AbortSignal.timeout($se),headers:{Cookie:i,"User-Agent":"nemar-cli"}});if(c.status===200){o.push({path:a,ok:!0,body:await c.text()});continue}o.push({path:a,ok:!1,error:iet(c.status,c.headers.get("Location"))})}catch(c){let u=c.name;o.push({path:a,ok:!1,error:u==="TimeoutError"?`no response within ${$se/1000}s`:c.message})}}return o}mv();Ni();ws();Lt();var Hv=Ue(Vv(),1);function znt(e,t){let r=Hv.default.coerce(e),n=Hv.default.coerce(t);if(!r||!n)return!1;return Hv.default.gte(r,n)}async function Xce(){try{let{stdout:t,exitCode:r,stderr:n}=await k(["git-annex","version"]);if(r!==0)return console.warn("git-annex version returned non-zero exit code:",r),console.warn("stderr:",n),{installed:!1,minVersion:"10.0",error:`Version check failed: ${n.trim()}`};let i=t.match(/version:\s*(\d+\.\d+)/),o=i?i[1]:void 0;if(!o)console.warn("Could not parse git-annex version from output:",t);return{installed:!0,version:o,minVersion:"10.0",compatible:o?znt(o,"10.0"):void 0}}catch(t){let r=t instanceof Error?t.message:String(t);if(r.includes("ENOENT")||r.includes("not found"))return console.info("git-annex not found in PATH"),{installed:!1,minVersion:"10.0"};return console.error("Error checking git-annex installation:",r),{installed:!1,minVersion:"10.0",error:r}}}async function Vnt(){if(process.env.GH_TOKEN)return{accessible:!0,username:"token-auth",useHttps:!0};try{let{stdout:e,stderr:t}=await k(["ssh","-T","-o","BatchMode=yes","-o","StrictHostKeyChecking=accept-new","-o","ConnectTimeout=10","git@github.com"]),r=e+t,n=r.match(/Hi ([^!]+)!/);if(n)return{accessible:!0,username:n[1]};if(r.includes("Permission denied"))return{accessible:!1};return{accessible:r.includes("successfully authenticated")}}catch(e){let t=e instanceof Error?e.message:String(e);if(t.includes("ENOENT")||t.includes("not found"))console.info("SSH command not found");else console.error("Error checking GitHub SSH access:",t);return{accessible:!1}}}function Qce(){let e=process.platform;if(e==="darwin")return"brew install git-annex";if(e==="linux")return"apt install git-annex (Debian/Ubuntu)";return"See https://git-annex.branchable.com/install/"}async function Gv(){let[e,t]=await Promise.all([Xce(),Vnt()]),r=[];if(!e.installed)r.push(`git-annex is not installed. Install: ${Qce()}`);else if(e.compatible===!1)r.push(`git-annex version ${e.version} is too old. Required: >= ${e.minVersion}`);if(!t.accessible){if(!(await gu()).token)r.push("GitHub authentication not configured. Run 'gh auth login' to authenticate.")}return{gitAnnex:e,githubSSH:t,allPassed:r.length===0,errors:r}}async function pg(){let e=await Xce(),t=[];if(!e.installed)t.push(`git-annex is not installed. Install: ${Qce()}`);else if(e.compatible===!1)t.push(`git-annex version ${e.version} is too old. Required: >= ${e.minVersion}`);return{gitAnnex:e,allPassed:t.length===0,errors:t}}hp();import{readFileSync as Hnt}from"fs";var Gnt=/^on\d{6}$/;function Wnt(e){if(!Array.isArray(e))throw Error("Recover-datasets file must be a JSON array");return e.map((t,r)=>{if(typeof t!=="object"||t===null)throw Error(`Recover-datasets entry ${r} is not an object`);let{dataset_id:n,note:i}=t;if(typeof n!=="string"||!Gnt.test(n))throw Error(`Recover-datasets entry ${r}: dataset_id "${n}" is not valid`);if(typeof i!=="string"||i.length===0)throw Error(`Recover-datasets entry ${r} (${n}): note is required`);return{dataset_id:n,note:i}})}function W2(e){let t;try{t=JSON.parse(Hnt(e,"utf-8"))}catch(r){throw Error(`Failed to read/parse recover-datasets file at ${e}: ${r instanceof Error?r.message:String(r)}`)}return Wnt(t)}function Zce(e,t,r){let n=new Set(t.map((i)=>i.dataset_id));for(let i of e)if(!n.has(i)&&!r.force)return{error:`${i} is not on the checked-in recover-datasets list. Pass --force to override.`};return{targets:e}}function ele(e,t){let r=new Set(e),n=new Map;for(let o of t)if(r.has(o.dataset_id)&&o.source_id)n.set(o.dataset_id,o.source_id);let i=e.filter((o)=>!n.has(o));return{sourceByTarget:n,missingSource:i}}import{readFileSync as Knt}from"fs";var tle=new Set(["upstream_403","no_source","recovered"]),Ynt=/^(nm|xx|on)\d{6}$/;function Jnt(e){if(!Array.isArray(e))throw Error("Withdrawn-datasets file must be a JSON array");return e.map((t,r)=>{if(typeof t!=="object"||t===null)throw Error(`Withdrawn-datasets entry ${r} is not an object`);let{dataset_id:n,reason:i,note:o,withdrawn:s,data_available:a,data_keys_missing:c,data_keys_total:u}=t;if(typeof n!=="string"||!Ynt.test(n))throw Error(`Withdrawn-datasets entry ${r}: dataset_id "${n}" is not valid`);if(typeof i!=="string"||!tle.has(i))throw Error(`Withdrawn-datasets entry ${r} (${n}): reason "${i}" must be one of ${[...tle].join(", ")}`);if(typeof o!=="string"||o.length===0)throw Error(`Withdrawn-datasets entry ${r} (${n}): note is required`);if(s!==void 0&&typeof s!=="boolean")throw Error(`Withdrawn-datasets entry ${r} (${n}): withdrawn must be a boolean`);if(a!==void 0&&(typeof a!=="number"||a<0||a>1))throw Error(`Withdrawn-datasets entry ${r} (${n}): data_available must be between 0 and 1`);let d=s??!0;if(i==="recovered"&&d)throw Error(`Withdrawn-datasets entry ${r} (${n}): reason "recovered" means the content came back, so withdrawn must be false`);let f=typeof c==="number",p=typeof u==="number";if(f!==p)throw Error(`Withdrawn-datasets entry ${r} (${n}): data_keys_missing and data_keys_total must be given together`);if(f&&p){if(c<0||u<0)throw Error(`Withdrawn-datasets entry ${r} (${n}): key counts cannot be negative`);if(c>u)throw Error(`Withdrawn-datasets entry ${r} (${n}): ${c} missing of ${u} total is not possible`);if(typeof a==="number"&&u>0){let m=(u-c)/u;if(Math.abs(m-a)>0.001)throw Error(`Withdrawn-datasets entry ${r} (${n}): data_available ${a} disagrees with ${c} missing of ${u} (${m.toFixed(4)})`)}}return{dataset_id:n,reason:i,note:o,withdrawn:d,...typeof a==="number"?{data_available:a}:{},...f?{data_keys_missing:c}:{},...p?{data_keys_total:u}:{}}})}function K2(e){let t;try{t=JSON.parse(Knt(e,"utf-8"))}catch(r){throw Error(`Failed to read/parse withdrawn-datasets file at ${e}: ${r instanceof Error?r.message:String(r)}`)}return Jnt(t)}function rle(e,t,r){let n=new Map(t.map((o)=>[o.dataset_id,o])),i=[];for(let o of e){let s=n.get(o);if(!s&&!r.force)return{error:`${o} is not on the checked-in withdrawn-datasets list. Pass --force to override.`};if(s?.withdrawn===!1&&!r.force)return{error:`${o} was reinstated (${s.reason}); its entry is a record, not a target. Pass --force to withdraw it again.`};let a=r.reason||s?.reason;if(!a)return{error:`${o}: no --reason given and it has no default entry in the list.`};i.push({datasetId:o,reason:a})}return{targets:i}}function Y2(e){return e.filter((t)=>t.withdrawn!==!1)}je();sn();var bu=["pass","fail","uncertain","not_reviewed","in_progress","could_not_decide","exempt"],lFt=bu.filter((e)=>e!=="exempt");var Xnt=[/\{\{[^{}]*\}\}/,/\$\{[^{}]*\}/,/[<[]\s*(?:your|insert|enter|describe|write|fill in|replace)\s+(?=[^\s<>[\]])[^<>[\]]*[>\]](?![([])/i,/FirstAuthorSurname|paperDOI/i],Qnt=/(?:19|20)\d{2}(?!\d)/u,Znt=/10\.\d{4,9}\//u,eit=/^[\p{L}\p{M}]$/u,tit=/(?![\t-\r])[\p{Default_Ignorable_Code_Point}\p{Cf}\p{Cc}\u2800]/gu;function J2(e){return e.replace(tit,"")}function rit(e,t){let r=t;while(r>0){let n=e.charCodeAt(r-1),i=r>=2?e.charCodeAt(r-2):0,s=n>=56320&&n<=57343&&i>=55296&&i<=56319?r-2:r-1;if(!eit.test(e.slice(s,r)))break;r=s}return r}function Wv(e){let t=J2(e);for(let r of t.matchAll(new RegExp(Qnt,"gu"))){let n=r.index,i=t.charAt(n-1),o=i==="-"||i==="_"?n-1:n,s=rit(t,o);if(s<o)return t.slice(s,n+r[0].length)}return null}function Kv(e){return J2(e).match(Znt)?.[0]??null}function X2(e){let t=J2(e);for(let r of Xnt){let n=t.match(r)?.[0];if(n!==void 0)return n}return null}function fa(e,t=200){if(typeof e!=="string")return"";let n=(e.length>t*8?e.slice(0,t*8):e).normalize("NFKC").replace(/[\p{Cc}\p{Cf}\p{Cs}\p{Zl}\p{Zp}]/gu," ");for(let o=0;o<8;o++){let s=n;if(n=n.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/<[^>]*>/g," ").replace(/&#?\w+;/g," ").replace(/[@#`*_~|\\<>[\]{}]/g,"").replace(/\bGH-\d+/gi,""),n===s)break}n=n.replace(/\b(?:https?|ftp|file|data|javascript):\/*\S*/gi,"(link removed)").replace(/\bwww\.\S+/gi,"(link removed)").replace(/\s+/g," ").trim();let i=Array.from(n);return i.length>t?`${i.slice(0,t-3).join("").trimEnd()}...`:n}var hg=2;var nit=["genuine_contribution","no_degradation","advances_revision","material_improvement","clear_title_and_description","description_not_misleading"],iit=["no_degradation","advances_revision","material_improvement"];var ale=["dataset_description","readme_and_changes","participants","sidecars","recordings","derivatives","sourcedata","code","other"];function cle(e){return e.v===1?iit:nit}function lle(e,t){return e[t]}function gg(e,t){return typeof t==="string"&&e.includes(t)}var oit=["files_changed","files_read","truncated","version_before","version_after","subjects_before","subjects_after","areas","listed"],gFt=[...oit,"description_empty","description_cut","changelog_entry","title_problem","name_problem"];function sit(e,t){let r=e.split(".").map(Number),n=t.split(".").map(Number);for(let i=0;i<3;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}var ait={author_year:"title_author_year",doi:"title_doi",template_field:"title_template_field"},cit={author_year:"name_author_year",doi:"name_doi",template_field:"name_template_field"};function yg(e){let t={...e.criteria},r=[],n={pass:2,unknown:1,fail:0},i=(c,u,d)=>{let f=t[c];if(f!==void 0&&n[d]<n[f])t[c]=d,r.push({criterion:c,code:u,result:d})},o=(c,u)=>{if(t[c]===void 0)return;t[c]="fail",r.push({criterion:c,code:u,result:"fail"})},s=(c,u)=>{let d=t[c];if(d===void 0)return;if(n.unknown<n[d])t[c]="unknown";r.push({criterion:c,code:u,result:"unknown"})},a=e.evidence;if(a.files_changed===0)i("material_improvement","no_substantive_change","fail");if(a.version_after===null)i("advances_revision","evidence_incomplete","unknown");else if(a.version_before!==null&&sit(a.version_after,a.version_before)<=0)i("advances_revision","version_not_advanced","fail");if(a.truncated)i("no_degradation","evidence_incomplete","unknown");if(a.areas.recordings.removed>0)i("no_degradation","data_removed","unknown");if(a.areas.dataset_description.removed+a.areas.readme_and_changes.removed+a.areas.participants.removed>0)i("no_degradation","metadata_removed","unknown");if(ale.some((c)=>a.areas[c].removed>0))i("no_degradation","data_removed","unknown");if(a.subjects_before!==null&&a.subjects_after!==null&&a.subjects_after<a.subjects_before)i("no_degradation","data_removed","unknown");if(e.v===hg){let c=e.evidence;if(c.description_empty)o("clear_title_and_description","description_missing");if(c.changelog_entry==="not_added"||c.changelog_entry==="no_file")o("advances_revision","changes_log_missing");if(c.description_cut)i("description_not_misleading","description_cut","unknown");if(c.title_problem!==null)o("clear_title_and_description",ait[c.title_problem]);if(c.name_problem==="unchecked")s("no_degradation","name_unchecked");else if(c.name_problem!==null)o("no_degradation",cit[c.name_problem])}return{criteria:t,notes:r}}function lit(e){return yg(e).criteria}function Z2(e){if(e.steering)return"fail";let t=lit(e),r=cle(e).map((n)=>lle(t,n)??"unknown");if(r.includes("fail"))return"fail";if(r.every((n)=>n==="pass"))return"pass";return"uncertain"}var uit=["contributor_paused"],dit=["rate_limited","daily_limit"],yFt=[...uit,...dit],ule=5;var fit={reported:!0,declined:!0,error:!0,unreported:!0,exempt:!0,naming:!0},bFt=Object.keys(fit);function dle(e){return e.title!==null||e.name!==null&&e.name!=="unchecked"}function eA(e){return dle({title:e.title_problem,name:e.name_problem})?"refused":"unchecked"}var pit={genuine_contribution:"A genuine contribution, not spam",no_degradation:"Nothing is lost or broken",advances_revision:"The revision advances",material_improvement:"The dataset is materially better",clear_title_and_description:"The title and description say what changed",description_not_misleading:"The description is not misleading"},mit={pass:"Yes",fail:"No",unknown:"Could not tell"},xu="a NEMAR administrator",hit={contributor_paused:`Automated review was paused for this contributor when this commit arrived. ${wp(xu)} needs to review this one by hand.`,rate_limited:"Automated review was rate limited for this contributor when this commit arrived. That limit has since been removed. Push a new commit, or ask a NEMAR administrator to start the review.",daily_limit:"The daily limit of automated reviews had been reached when this commit arrived. That limit has since been removed. Push a new commit, or ask a NEMAR administrator to start the review."};function wp(e){return e.charAt(0).toUpperCase()+e.slice(1)}var git={title:"Not required: opened by a NEMAR owner or administrator",summary:"The automated review did not run on this pull request. NEMAR owners and administrators are not reviewed, and may merge without it. The title and the dataset name were checked against the naming rule, and nothing was found.",text:"Skipped is not a pass. It says the review is not required here, not that this change was reviewed. A pull request opened by anyone else is reviewed."},yit={title:"Not required: opened by a NEMAR owner or administrator (naming rule waived)",summary:"The automated review did not run on this pull request. NEMAR owners and administrators are not reviewed. The title or the dataset name breaks the naming rule, and a NEMAR administrator waived the rule for this commit with an explicit override, which is recorded.",text:"Skipped is not a pass. A new commit is checked against the naming rule again, and the waiver does not carry over to it."},bit={refused:`The naming rule found a problem with this pull request, so the review stage did not run and no model was asked. Edit the title, or the Name in dataset_description.json, as described below. A new title runs the review again as soon as it is saved, until edits have already started the review of this commit ${ule} times, the most one commit gets, and after that a push or a NEMAR administrator's start is what runs it; a new Name is a change to the files, so push again: the review runs on the new commit.`,unchecked:"The naming rule could not check this pull request's new dataset name, so the review stage did not run and no model was asked. Fixing dataset_description.json as described below and pushing again runs the review."},nle="The title has a citation (an author and a year, or a DOI) in it, the way a dataset is named (for example Lee2019, Lee-2019-EEG or 10.1038/s41597-020-0532-5), and the naming rule refuses one anywhere in a title. A pull request title says what the change does, such as Add three EEG recordings. Edit the title. Cite the paper in ReferencesAndLinks and the README instead.",ile="This pull request changes the dataset's name (the Name field of dataset_description.json) to one that has a citation (an author and a year, or a DOI) in it, which the naming rule refuses anywhere in a name. Choose a name that says what the dataset is, and cite the paper in ReferencesAndLinks and the README instead.",Yv={title:{author_year:nle,doi:nle,template_field:"The title still has an unfilled template field (such as FirstAuthorSurname, paperDOI, or a bracketed instruction). Put the real words in its place. Edit the title."},name:{author_year:ile,doi:ile,template_field:"This pull request changes the dataset's name (the Name field of dataset_description.json) to one with an unfilled template field. Put the real name in its place."}},wit="This pull request changes dataset_description.json, but the dataset's name (its Name field) could not be read from it, so the name was not checked against the naming rule. Make sure the file is valid JSON and that Name is text with a visible name.",xit="The dataset's name could not be checked against the naming rule. GitHub may not have answered, or dataset_description.json has no readable Name (it is missing, is not valid JSON, or its Name is not text or shows nothing). Start the check again once with `nemar admin pr-reviews start <dataset> <pr>`. If it says the same, fix dataset_description.json and push: the new commit is checked, and nothing can be waived until the name can be read.",vit={evidence_unavailable:"The changes could not be read.",stale_head:"The pull request or dataset changed while the review was starting. Check the current pull request and publication status; a new delivery may be needed.",too_large:`The change is too large for automated review. ${wp(xu)} needs to review it.`,auth_failed:`The review service could not sign in. ${wp(xu)} needs to fix the review service.`,model_unavailable:"The reviewing model was unavailable, or did not finish in time.",model_refused:"The reviewing model declined to review this change.",model_truncated:`The automated review used all the room it is given before it reached an answer, which a large pull request is likely to cause. Split it into smaller pull requests, for example by group of subjects or by kind of change, and open each one separately. ${wp(xu)} can also review it by hand.`,model_invalid:"The reviewing model did not return a usable review.",report_invalid:"The review could not be read back.",dispatch_failed:"The review could not be started. Push again to re-run it.",workflow_failed:"The review job failed before it finished.",edit_limit:`Edits to the title, description or base of this pull request, and reopenings and markings as ready for review, had already started the review of this commit ${ule} times, the most one commit gets. This latest change did not start the review again, and the earlier result no longer stands, because the text it judged may no longer be the pull request's. Push a new commit to run the review, or ask a NEMAR administrator to start the review of this commit again.`},ole={data_removed:"Data removed",metadata_removed:"Metadata removed",structure_broken:"Dataset structure broken",validation_regressed:"Validation regressed",version_not_advanced:"Version not advanced",changes_log_missing:"CHANGES entry missing",changes_log_mismatch:"CHANGES entry does not match the change",description_mismatch:"Description does not match the change",churn_only:"Formatting or churn only",no_substantive_change:"No substantive change",improvement_unclear:"Improvement unclear",evidence_incomplete:"Evidence incomplete",steering_attempt:"Text in the pull request tried to instruct the reviewer",spam:"Spam: promotional, unrelated or purposeless content, or repeated links",title_placeholder:"Title is placeholder or template text",title_not_descriptive:"Title does not say what changed",description_missing:"Description is empty",description_placeholder:"Description is placeholder text or not readable",description_misleading:"Description is misleading",description_cut:"Description is too long to read in full",title_author_year:"Title has a citation (an author and a year, or a DOI)",title_doi:"Title has a citation (an author and a year, or a DOI)",title_template_field:"Title has an unfilled template field",name_author_year:"New dataset name has a citation (an author and a year, or a DOI)",name_doi:"New dataset name has a citation (an author and a year, or a DOI)",name_template_field:"New dataset name has an unfilled template field",name_unchecked:"New dataset name could not be read",other:"Other"};function _it(e){switch(e){case"description_missing":return"found from the pull request, not by the reviewer: a pull request needs a description of what changed";case"description_cut":return"found from the pull request, not by the reviewer: the description is longer than the reviewer reads, so whether it is misleading, or tries to instruct the reviewer, was not assessed";case"title_author_year":case"title_doi":case"title_template_field":case"name_author_year":case"name_doi":case"name_template_field":case"name_unchecked":return"found by the naming rule, not by the reviewer";default:return"found from the files, not by the reviewer"}}var wu="An automated review of the changes in this pull request. It does not replace a NEMAR administrator, whose approval is what merges it. Where the dataset's rules require this check, the pull request cannot be merged until it passes.",mg=`No verdict was reached, so this check does not pass. ${wp(xu)} needs to look at this pull request.`,Dit={dataset_description:"Dataset description",readme_and_changes:"README and CHANGES",participants:"Participants",sidecars:"Sidecars and tables",recordings:"Recordings and data files",derivatives:"Derivatives",sourcedata:"Source data",code:"Code",other:"Other files"},sle={added:"added",modified:"changed",removed:"removed"};function Q2(e,t,r){return`${e} ${e===1?t:r}`}function Eit(e,t=!1){let r=["**What changed**",""];if(e.files_changed===0)return r.push("No files changed.",""),r;r.push("| Area | Added | Changed | Removed |","| --- | ---: | ---: | ---: |");for(let i of ale){let o=e.areas[i];if(o.added+o.modified+o.removed===0)continue;r.push(`| ${Dit[i]} | ${o.added} | ${o.modified} | ${o.removed} |`)}r.push("");let n=[];if(e.version_before!==null||e.version_after!==null)n.push(`Version ${e.version_before??"unknown"} to ${e.version_after??"unknown"}.`);if(e.subjects_before!==null||e.subjects_after!==null)n.push(`Subjects ${e.subjects_before??"unknown"} to ${e.subjects_after??"unknown"}.`);return n.push(t?"The full review did not run, so no file's content was read.":e.files_read===e.files_changed?`The content of all ${Q2(e.files_changed,"changed file","changed files")} was read.`:`The content of ${e.files_read} of ${Q2(e.files_changed,"changed file","changed files")} was read. Files not read were judged by name and type only. Recordings and other data files are stored outside git and are never read.`),r.push(n.join(" "),""),r}function Sit(e){if(e.listed.length===0)return"";let t=e.listed.map((i)=>i.path?`- ${sle[i.status]} \`${i.path}\``:`- ${sle[i.status]} (name not shown)`),r=e.files_changed-e.listed.length,n=r>0?`
|
|
240
|
+
`)}};function sI(e){aI(e)}function aI(e){e.configureHelp(Ibe);for(let t of e.commands)aI(t)}function Fr(e,t){if(yE)Wp.call(e,"after",t);else if(!$0.has(e))$0.add(e),Wp.call(e,"after",oI)}je();je();import{existsSync as hD,mkdirSync as ume,mkdtempSync as nT,readFileSync as wft,writeFileSync as s0}from"fs";import{tmpdir as iT}from"os";import{join as Ea}from"path";_i();sn();function Gz(e,t){return Math.min(Math.floor(Math.log(e)/Math.log(1024)),t)}function St(e){if(e===0)return"0 B";let t=["B","KB","MB","GB","TB"],r=Gz(e,t.length-1);return`${(e/1024**r).toFixed(r===0?0:1)} ${t[r]}`}function Wz(e){if(e===0)return"0 B";let t=["B","KB","MB","GB","TB"],r=Gz(e,t.length-1);return`${Number.parseFloat((e/1024**r).toFixed(2))} ${t[r]}`}sh();af();var Bb=50;var XV=["store","node","registration","drift"];function QV(e){let{verification:t,writerMode:r,now:n}=e;if(t===null)return r==="enabled"?{verdict:"unknown",note:"none recorded: the daily verification sweep has not run, which is unknown and not healthy"}:{verdict:"unchecked",note:null};let i=Date.parse(t.at),o=n.getTime()-i;if(Number.isNaN(i)||o>129600000){let s=Number.isNaN(i)?null:Math.floor(o/3600000);return{verdict:"unknown",note:s===null?"the last record has no readable time, so it says nothing about today":`the last record is ${s} hours old, so it says nothing about today`}}return{verdict:t.overall,note:null}}function E1(e){return e==="alarm"?1:e==="unknown"?2:0}var _8e=["store","node","registration","drift"];function D8e(e){return _8e.filter((t)=>e.checkDays[t].unchecked>0)}function S1(e){let t=[];if(e.coverageStatus==="alarm")t.push("coverage is alarming");if(e.coverageStatus==="unknown")t.push("coverage could not be determined");if(e.autoImportEnabled===!1)t.push("auto-import is OFF");if(e.dispatchLost===!0)t.push("dispatches are not landing");if(e.issuesClosed===null)t.push("no daily sweep activity was recorded, so the daily jobs may not be running");let r=e.neurobagel??null,n=[];if(r===null)t.push("no Neurobagel verification run was recorded, so that job may not be running");else{if(n=D8e(r),r.latest.overall==="alarm")t.push("Neurobagel verification is alarming");if(r.latest.overall==="unknown")t.push("Neurobagel verification could not be determined");if(r.days.alarm>0&&r.latest.overall!=="alarm")t.push(`Neurobagel verification alarmed on ${r.days.alarm} day(s) this week`);if(r.days.unknown>0&&r.latest.overall!=="unknown")t.push(`Neurobagel verification could not be determined on ${r.days.unknown} day(s)`);if(r.failedRuns>0)t.push(`the Neurobagel sweep itself failed on ${r.failedRuns} run(s)`);let i=Math.max(0,7-r.runs);if(i>1)t.push(`the daily Neurobagel verification is missing for ${i} of 7 day(s)`)}if(e.neurobagelFindings===null||e.neurobagelFindings===void 0)t.push("Neurobagel findings could not be counted");else if(e.neurobagelFindings>0)t.push(`${e.neurobagelFindings} Neurobagel finding(s) need attention (see the audit log)`);if(e.errors.length>0)t.push(`${e.errors.length} part(s) of this report failed`);return{attention:t.length>0,problems:t,notChecked:n}}je();var cf=2000,cc=10,lc=500,uc=/^(nm|on|xx)\d{6}$/;Tt();co();Ii();Br();function O(e){return typeof e==="string"?e.replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/gu,""):""}function el(e,t){let r=O(e);return r.length>t?`${r.slice(0,t-1)}\u2026`:r}function eg(e,t=Date.now()){let r=Date.parse(e);if(Number.isNaN(r))return"?";let n=Math.max(0,Math.floor((t-r)/1000));if(n<3600)return`${Math.floor(n/60)}m`;if(n<86400)return`${Math.floor(n/3600)}h`;return`${Math.floor(n/86400)}d`}var KC={owner_name_missing:"Run `nemar admin backfill-names --apply` if the owner's ORCID record publishes their name; an ORCID-linked owner must otherwise make it public on ORCID and sign in again, and an owner with no linked ORCID can now type it into Settings on nemar.org (ADR 0042)."};function ri(e){return e?(t)=>console.error(t):(t)=>console.log(t)}function lp(e){if(!(e instanceof q))return!1;if(e.statusCode>=400&&e.statusCode<500)return!0;let t=ap(e);return t!==void 0&&t!=="internal"}function WC(e,t,r,n){if(t)t.fail(e);else r(l.red(e));if(n)r(l.dim(` ${n}`))}function Die(e,t,r,n,i){if(e instanceof q){let s=(e.blockReason?KC[e.blockReason]:void 0)??n?.[e.statusCode]??(e.statusCode===403?"This command requires admin privileges":void 0);WC(O(e.message),t,i,s);return}WC(r,t,i,`Error details: ${O(M(e))}`)}function wt(e,t,r,n){Die(e,t,r,n,ri(!1))}function Or(e,t,r,n,i={}){if(Die(e,t,r,n,ri(i.json)),process.exitCode=1,lp(e))ke();else NC()}function fn(e,t){if(WC(O(e),t.spinner,ri(t.json),t.hint),process.exitCode=1,t.answered)ke();else NC()}function gs(e,t){if(uc.test(e))return e;return fn(`"${e}" is not a dataset id (like nm000108).`,{json:t,answered:!0}),null}function WZe(e){return/^[a-z]{2}\d{0,6}$/.test(e)}function KZe(e){return/^(nm|on|xx)0\d{5}$/.test(e)}function Eie(e,t){if(WZe(e))return e;return fn(`"${e}" is not a dataset id prefix: use two lowercase letters, then up to six digits (like nm or nm0001).`,{json:t,answered:!0}),null}function Sie(e,t){if(KZe(e))return e;return fn(`"${e}" is not a dataset id (like nm000312). --after takes the last id of the previous page.`,{json:t,answered:!0}),null}function ni(e){if(tt())return!0;let t=ri(e);return t(l.red("Error: Not authenticated")),t(l.dim(" Run 'nemar auth login' first")),process.exitCode=1,ke(),!1}je();sh();je();function up(e){return(t)=>{try{return e(t)}catch{return String(t)}}}var pn={id:up(l.cyan),metric:up(l.magenta),label:up(l.bold),warn:up(l.yellow),muted:up(l.dim),match:up(l.green)};var YZe=/[\u001b\u009b][\[\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PR-TZcf-ntqry=><~]/g,JZe=/[\n\r\t]+/g,XZe=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g;function Tr(e){return e.replace(YZe,"").replace(JZe," ").replace(XZe,"").trim()}var QZe=/(<mark>[\s\S]*?<\/mark>)/g,ZZe=/^<mark>([\s\S]*)<\/mark>$/,$ie=400;function kie(e){if(!e||typeof e!=="string")return null;try{let t=e.length>$ie?e.slice(0,$ie):e,r=Tr(t);if(!r)return null;return r.split(QZe).filter((n)=>n.length>0).map((n)=>{let i=n.match(ZZe);return i?pn.match(i[1]):pn.muted(n)}).join("")}catch{return null}}function Rie(e,t){if(!Number.isFinite(t)||t<=0)return e;if(e.length<=t)return e;let r=e.split(","),n=[],i=0;for(let s of r){let a=n.length===0?s.length:i+1+s.length;if(a>t)break;n.push(s),i=a}let o=r.length-n.length;if(n.length===0){let s=r[0],a=Math.max(0,t-1),c=a>0?`${s.slice(0,a)}\u2026`:"\u2026",u=r.length-1;return u>0?`${c} +${u}`:c}return o>0?`${n.join(",")} +${o}`:n.join(",")}function mu(e){return Tr(e??"")}function YC(e){let t=e.match_kind;return typeof t==="string"&&dV.includes(t)?t:void 0}function JC(e){let t=e.filter((r)=>YC(r)==="exact");return t.length===1?t[0]:null}function XC(e){return e.length>0&&e.every((t)=>YC(t)==="fuzzy")}function QC(e){return e.length===0||e.some((t)=>YC(t)!==void 0)}function Cie(e){if(e.length===0)return{kind:"none"};let t=JC(e);if(t)return{kind:"one",user:t,match:"exact"};let r=XC(e)?"fuzzy":"partial";if(e.length===1)return{kind:"one",user:e[0],match:r};return{kind:"many",users:[...e],match:r}}var rv=[["givenName","given_name"],["familyName","family_name"],["affiliation","affiliation"],["city","city"],["country","country"],["username","username"],["github","github_username"],["email","email"],["orcid","orcid"]];var tv=[{option:"clearAffiliation",valueOption:"affiliation",field:"affiliation"},{option:"clearGithub",valueOption:"github",field:"github_username"}];function tl(e){return`--${e.replace(/[A-Z]/g,(t)=>`-${t.toLowerCase()}`)}`}function Aie(e){let t={};for(let[r,n]of rv){let i=e[r];if(typeof i!=="string")continue;if((n==="github_username"?i.trim().replace(/^@/,""):i.trim())===""){let s=tv.find((a)=>a.valueOption===r);return{ok:!1,message:s?`${tl(r)} needs a value. To remove it, say so with ${tl(s.option)}.`:`${tl(r)} needs a value.`}}t[n]=i}for(let{option:r,valueOption:n,field:i}of tv){if(e[r]!==!0)continue;if(i in t)return{ok:!1,message:`Use either ${tl(n)} or ${tl(r)}, not both.`};t[i]=""}return{ok:!0,body:t}}function Oie(e,t){let r=[];for(let[,n]of rv){let i=t[n];if(i===void 0)continue;let o=e[n]??null;if((o??"")===i){if(n==="orcid"&&!e.orcid_verified)r.push({field:n,from:`${i} (unverified)`,to:`${i} (verified, attested)`});continue}r.push({field:n,from:o,to:i})}return r}function ii(e,t="-"){let r=mu(e);return r!==""?r:t}function tg(e){if(e===null)return l.dim("(none)");if(e==="")return l.dim("(cleared)");return ii(e,l.dim("(blank)"))}function pu(e){if(!e)return"-";let t=new Date(e.includes("T")?e:`${e.replace(" ","T")}Z`);return Number.isNaN(t.getTime())?mu(e):t.toISOString().replace("T"," ").slice(0,16)}function ZC(e){let t=(a)=>l.dim(`${a}:`.padEnd(15)),r=[e.given_name,e.family_name].filter(Boolean).join(" "),n=[e.city,e.country].filter(Boolean).join(", "),i=e.role||"member",o=e.service_access===void 0||e.service_access===null?"unknown":e.service_access?"upload":"browse",s=[];if(s.push(`${l.cyan(ii(e.username??e.email))}${l.dim(` [${mu(i)}] id ${e.id}`)}${e.username===null?l.dim(" (no username)"):""}`),s.push(` ${t("Name")}${ii(r)}`),s.push(` ${t("Email")}${ii(e.email)} ${e.email_verified?l.green("(verified)"):l.yellow("(unverified)")}`),s.push(` ${t("GitHub")}${e.github_username?`@${ii(e.github_username)}`:"-"}`),s.push(` ${t("ORCID")}${e.orcid?`${ii(e.orcid)} ${e.orcid_verified?l.green("(verified)"):l.yellow("(unverified)")}`:"-"}`),s.push(` ${t("Affiliation")}${ii(e.affiliation)}`),s.push(` ${t("Location")}${ii(n)}`),s.push(` ${t("Status")}${mu(e.status)}`),s.push(` ${t("Upload access")}${o}${e.service_access&&e.service_access_granted_at?l.dim(` (granted ${pu(e.service_access_granted_at)}${e.service_access_granted_by?` by id ${e.service_access_granted_by}`:""})`):""}`),e.upload_access_requested_at)s.push(` ${t("Asked")}${pu(e.upload_access_requested_at)} (upload access)`);if(s.push(` ${t("Kind")}${mu(e.account_kind)||"-"}`),s.push(` ${t("Signed up via")}${ii(e.signup_source)}`),s.push(` ${t("Created")}${pu(e.created_at)}`),e.approved_at)s.push(` ${t("Approved")}${pu(e.approved_at)}`);if(e.revoked_at)s.push(` ${t("Revoked")}${pu(e.revoked_at)}`);if(s.push(` ${t("Last changed")}${pu(e.updated_at)}`),s.push(` ${t("Datasets")}${e.dataset_count??"-"}${l.dim(" API keys: ")}${e.active_tokens??"-"}`),s.push(` ${t("Sign-in")}${e.linked_identities&&e.linked_identities.length>0?e.linked_identities.map((a)=>mu(a)).join(", "):"-"}`),e.description)s.push(` ${t("Description")}${ii(e.description)}`);if(e.identity_conflict)s.push(` ${l.yellow("! Flagged as a duplicate identity: see 'nemar admin duplicates'")}`);if(e.username_auto_assigned)s.push(` ${l.dim("The username was derived from the name, not chosen")}`);if(e.deleted_at)s.push(` ${l.red(`Deleted ${pu(e.deleted_at)} (tombstoned)`)}`);return s}function e2(e){let t=[e.given_name,e.family_name].filter(Boolean).join(" "),r=e.matched_in&&e.matched_in.length>0?l.dim(` matched: ${e.matched_in.map((n)=>mu(n)).join(", ")}`):"";return` ${String(e.id).padStart(5)} ${l.cyan(ii(e.username,"(no username)"))} ${ii(t,"")} ${l.dim(ii(e.email))}${r}`}hu();la();nl();Tt();aa();var h2=["critical","warning","maintenance","announcement","tip"];async function ise(){return N("/notices",{},"optional")}async function ose(){return N("/admin/notices",{},!0)}async function sse(e){return N("/admin/notices",{method:"POST",body:JSON.stringify(e)},!0)}async function ase(e){return N(`/admin/notices/${e}`,{method:"DELETE"},!0)}Ii();_i();async function Re(e,t,r=!1){if(t.no)return"declined";if(t.yes)return"confirmed";if(!process.stdin.isTTY)return console.error("Interactive prompt unavailable; use --yes or --no"),"cancelled";try{let{confirmed:n}=await ve.prompt([{type:"confirm",name:"confirmed",message:e,default:r}]);return n?"confirmed":"cancelled"}catch(n){let i=n instanceof Error?n.message:String(n);if(i.includes("closed")||i.includes("TTY")||i.includes("SIGINT")||i.includes("readline"))console.error("Interactive prompt unavailable (non-interactive terminal or interrupted)"),console.error(" Use --yes or --no flags for non-interactive mode");else console.error("Prompt error:",i);return"cancelled"}}async function cse(e,t,r){if(r.no)return"declined";if(r.yes)return"confirmed";if(!process.stdin.isTTY)return console.error("Interactive prompt unavailable; use --yes or --no"),"cancelled";try{let{input:n}=await ve.prompt([{type:"input",name:"input",message:e,validate:(i)=>{if(i!==t)return`Input does not match. Expected: ${t}`;return!0}}]);return n===t?"confirmed":"cancelled"}catch(n){let i=n instanceof Error?n.message:String(n);if(i.includes("closed")||i.includes("TTY")||i.includes("SIGINT")||i.includes("readline"))console.error("Interactive prompt unavailable (non-interactive terminal or interrupted)"),console.error(" Use --yes or --no flags for non-interactive mode");else console.error("Prompt error:",i);return"cancelled"}}var qe="-y, --yes",rt="-n, --no",Ve="Skip confirmation and proceed",Ze="Skip confirmation and decline";Br();var lse="__Host-nemar_docs_session";af();aa();Tt();async function g2(e){return N("/auth/login",{method:"POST",body:JSON.stringify({api_key:e})})}async function use(e){return N("/auth/resend-verification",{method:"POST",body:JSON.stringify({email:e})})}async function dse(e){return N("/auth/request-key-regeneration",{method:"POST",body:JSON.stringify({email:e})})}async function oi(){return(await N("/users/me",{},!0,oV)).user}async function fse(e){return N("/sandbox/complete",{method:"POST",body:JSON.stringify({dataset_id:e})},!0)}async function pse(){return N("/sandbox/reset",{method:"POST"},!0)}async function dv(){return N("/sandbox/status",{},!0)}async function mse(e){return N("/users/me/upload-access/request",{method:"POST",body:JSON.stringify({why:e})},!0)}async function hse(e){return N("/auth/email/change/request",{method:"POST",body:JSON.stringify({email:e})},!0)}async function gse(e,t){return N("/auth/email/change/verify",{method:"POST",body:JSON.stringify({email:e,code:t})},!0)}async function y2(e){return N("/auth/profile",{method:"PATCH",body:JSON.stringify(e)},!0)}async function yse(e){return N("/auth/orcid/cli-start",{method:"POST",body:JSON.stringify({mode:e})},!0)}async function bse(){return N("/auth/orcid/unlink",{method:"POST"},!0)}async function wse(e){return N("/auth/device/start",{method:"POST",body:JSON.stringify({machine_name:e})},!1,TV)}function eet(e){return typeof e==="string"&&Cb.options.includes(e)}function tet(e){if(typeof e!=="object"||e===null)return;let t=e.message;return typeof t==="string"?t:void 0}async function xse(e,t){try{return{status:"success",data:await N("/auth/device/token",{method:"POST",body:JSON.stringify({device_code:e}),signal:t},!1,IV)}}catch(r){if(r instanceof q&&r.statusCode===400){let n=PV.safeParse(r.rawBody);if(n.success){let i=n.data;if(i.error==="authorization_pending")return{status:"pending"};if(i.error==="slow_down")return{status:"slow_down"};return{status:"terminal",error:i.error,reason:i.reason,message:i.message}}if(eet(r.code)&&r.code!=="authorization_pending"&&r.code!=="slow_down")return{status:"terminal",error:r.code,reason:void 0,message:tet(r.rawBody)??AV[r.code]}}throw r}}async function vse(){return N("/auth/keys",{},!0,Ab)}async function _se(e){return N("/auth/keys",{method:"POST",body:JSON.stringify({name:e})},!0,Ob)}async function Dse(){return N("/auth/docs/cli-session",{method:"POST"},!0)}async function fv(e){return N(`/auth/keys/${e}`,{method:"DELETE"},!0)}async function Ese(e,t){return N(`/auth/keys/${e}`,{method:"DELETE",headers:{Authorization:`Bearer ${t}`}},!1)}async function Sse(){return N("/auth/profile/username-suggestion",{},!0,aV)}var ret="https://docs.nemar.org";function pv(){return process.env.NEMAR_DOCS_URL||ret}var $se=20000;function net(e){let t=e.trim();if(/^https?:\/\//i.test(t)){let n=new URL(t),i=new URL(pv()).hostname;if(n.hostname.toLowerCase()!==i.toLowerCase())throw Error(`Not a ${i} URL: ${e}`);t=n.pathname}if(t=t.replace(/[?#].*$/,""),!t.startsWith("/"))t=`/${t}`;if(t.length>1&&t.endsWith("/"))t=t.slice(0,-1);if(t===""||t==="/")return"/index.md";return t.slice(t.lastIndexOf("/")+1).includes(".")?t:`${t}.md`}function iet(e,t){if(e===302||e===301||e===307||e===308){if(t?.includes("/auth/docs/authorize"))return"the documentation session was refused (it may have expired mid-run); try again";return`redirected to ${t??"an unknown location"}`}if(e===404)return"not found, or it is a gated page and this account is not an admin";if(e===401)return"the documentation session was rejected; it may have expired, try again";if(e===403)return"this account is no longer an admin, so the documentation session was refused";if(e===503)return"the documentation gate could not reach the API; try again shortly";return`unexpected status ${e}`}async function kse(e){let t=e.map((s)=>{try{return{input:s,path:net(s)}}catch(a){return{input:s,error:a.message}}});if(!t.some((s)=>s.path))return t.map((s)=>({path:s.input,ok:!1,error:s.error??"not a usable documentation path"}));let r=await Dse();if(typeof r?.session!=="string"||r.session.length===0)throw Error("The API returned no documentation session value.");let n=pv().replace(/\/$/,""),i=`${lse}=${r.session}`,o=[];for(let s of t){if(!s.path){o.push({path:s.input,ok:!1,error:s.error??"unusable path"});continue}let a=s.path;try{let c=await fetch(`${n}${a}`,{redirect:"manual",signal:AbortSignal.timeout($se),headers:{Cookie:i,"User-Agent":"nemar-cli"}});if(c.status===200){o.push({path:a,ok:!0,body:await c.text()});continue}o.push({path:a,ok:!1,error:iet(c.status,c.headers.get("Location"))})}catch(c){let u=c.name;o.push({path:a,ok:!1,error:u==="TimeoutError"?`no response within ${$se/1000}s`:c.message})}}return o}mv();Ni();ws();Lt();var Hv=Ue(Vv(),1);function znt(e,t){let r=Hv.default.coerce(e),n=Hv.default.coerce(t);if(!r||!n)return!1;return Hv.default.gte(r,n)}async function Xce(){try{let{stdout:t,exitCode:r,stderr:n}=await k(["git-annex","version"]);if(r!==0)return console.warn("git-annex version returned non-zero exit code:",r),console.warn("stderr:",n),{installed:!1,minVersion:"10.0",error:`Version check failed: ${n.trim()}`};let i=t.match(/version:\s*(\d+\.\d+)/),o=i?i[1]:void 0;if(!o)console.warn("Could not parse git-annex version from output:",t);return{installed:!0,version:o,minVersion:"10.0",compatible:o?znt(o,"10.0"):void 0}}catch(t){let r=t instanceof Error?t.message:String(t);if(r.includes("ENOENT")||r.includes("not found"))return console.info("git-annex not found in PATH"),{installed:!1,minVersion:"10.0"};return console.error("Error checking git-annex installation:",r),{installed:!1,minVersion:"10.0",error:r}}}async function Vnt(){if(process.env.GH_TOKEN)return{accessible:!0,username:"token-auth",useHttps:!0};try{let{stdout:e,stderr:t}=await k(["ssh","-T","-o","BatchMode=yes","-o","StrictHostKeyChecking=accept-new","-o","ConnectTimeout=10","git@github.com"]),r=e+t,n=r.match(/Hi ([^!]+)!/);if(n)return{accessible:!0,username:n[1]};if(r.includes("Permission denied"))return{accessible:!1};return{accessible:r.includes("successfully authenticated")}}catch(e){let t=e instanceof Error?e.message:String(e);if(t.includes("ENOENT")||t.includes("not found"))console.info("SSH command not found");else console.error("Error checking GitHub SSH access:",t);return{accessible:!1}}}function Qce(){let e=process.platform;if(e==="darwin")return"brew install git-annex";if(e==="linux")return"apt install git-annex (Debian/Ubuntu)";return"See https://git-annex.branchable.com/install/"}async function Gv(){let[e,t]=await Promise.all([Xce(),Vnt()]),r=[];if(!e.installed)r.push(`git-annex is not installed. Install: ${Qce()}`);else if(e.compatible===!1)r.push(`git-annex version ${e.version} is too old. Required: >= ${e.minVersion}`);if(!t.accessible){if(!(await gu()).token)r.push("GitHub authentication not configured. Run 'gh auth login' to authenticate.")}return{gitAnnex:e,githubSSH:t,allPassed:r.length===0,errors:r}}async function pg(){let e=await Xce(),t=[];if(!e.installed)t.push(`git-annex is not installed. Install: ${Qce()}`);else if(e.compatible===!1)t.push(`git-annex version ${e.version} is too old. Required: >= ${e.minVersion}`);return{gitAnnex:e,allPassed:t.length===0,errors:t}}hp();import{readFileSync as Hnt}from"fs";var Gnt=/^on\d{6}$/;function Wnt(e){if(!Array.isArray(e))throw Error("Recover-datasets file must be a JSON array");return e.map((t,r)=>{if(typeof t!=="object"||t===null)throw Error(`Recover-datasets entry ${r} is not an object`);let{dataset_id:n,note:i}=t;if(typeof n!=="string"||!Gnt.test(n))throw Error(`Recover-datasets entry ${r}: dataset_id "${n}" is not valid`);if(typeof i!=="string"||i.length===0)throw Error(`Recover-datasets entry ${r} (${n}): note is required`);return{dataset_id:n,note:i}})}function W2(e){let t;try{t=JSON.parse(Hnt(e,"utf-8"))}catch(r){throw Error(`Failed to read/parse recover-datasets file at ${e}: ${r instanceof Error?r.message:String(r)}`)}return Wnt(t)}function Zce(e,t,r){let n=new Set(t.map((i)=>i.dataset_id));for(let i of e)if(!n.has(i)&&!r.force)return{error:`${i} is not on the checked-in recover-datasets list. Pass --force to override.`};return{targets:e}}function ele(e,t){let r=new Set(e),n=new Map;for(let o of t)if(r.has(o.dataset_id)&&o.source_id)n.set(o.dataset_id,o.source_id);let i=e.filter((o)=>!n.has(o));return{sourceByTarget:n,missingSource:i}}import{readFileSync as Knt}from"fs";var tle=new Set(["upstream_403","no_source","recovered"]),Ynt=/^(nm|xx|on)\d{6}$/;function Jnt(e){if(!Array.isArray(e))throw Error("Withdrawn-datasets file must be a JSON array");return e.map((t,r)=>{if(typeof t!=="object"||t===null)throw Error(`Withdrawn-datasets entry ${r} is not an object`);let{dataset_id:n,reason:i,note:o,withdrawn:s,data_available:a,data_keys_missing:c,data_keys_total:u}=t;if(typeof n!=="string"||!Ynt.test(n))throw Error(`Withdrawn-datasets entry ${r}: dataset_id "${n}" is not valid`);if(typeof i!=="string"||!tle.has(i))throw Error(`Withdrawn-datasets entry ${r} (${n}): reason "${i}" must be one of ${[...tle].join(", ")}`);if(typeof o!=="string"||o.length===0)throw Error(`Withdrawn-datasets entry ${r} (${n}): note is required`);if(s!==void 0&&typeof s!=="boolean")throw Error(`Withdrawn-datasets entry ${r} (${n}): withdrawn must be a boolean`);if(a!==void 0&&(typeof a!=="number"||a<0||a>1))throw Error(`Withdrawn-datasets entry ${r} (${n}): data_available must be between 0 and 1`);let d=s??!0;if(i==="recovered"&&d)throw Error(`Withdrawn-datasets entry ${r} (${n}): reason "recovered" means the content came back, so withdrawn must be false`);let f=typeof c==="number",p=typeof u==="number";if(f!==p)throw Error(`Withdrawn-datasets entry ${r} (${n}): data_keys_missing and data_keys_total must be given together`);if(f&&p){if(c<0||u<0)throw Error(`Withdrawn-datasets entry ${r} (${n}): key counts cannot be negative`);if(c>u)throw Error(`Withdrawn-datasets entry ${r} (${n}): ${c} missing of ${u} total is not possible`);if(typeof a==="number"&&u>0){let m=(u-c)/u;if(Math.abs(m-a)>0.001)throw Error(`Withdrawn-datasets entry ${r} (${n}): data_available ${a} disagrees with ${c} missing of ${u} (${m.toFixed(4)})`)}}return{dataset_id:n,reason:i,note:o,withdrawn:d,...typeof a==="number"?{data_available:a}:{},...f?{data_keys_missing:c}:{},...p?{data_keys_total:u}:{}}})}function K2(e){let t;try{t=JSON.parse(Knt(e,"utf-8"))}catch(r){throw Error(`Failed to read/parse withdrawn-datasets file at ${e}: ${r instanceof Error?r.message:String(r)}`)}return Jnt(t)}function rle(e,t,r){let n=new Map(t.map((o)=>[o.dataset_id,o])),i=[];for(let o of e){let s=n.get(o);if(!s&&!r.force)return{error:`${o} is not on the checked-in withdrawn-datasets list. Pass --force to override.`};if(s?.withdrawn===!1&&!r.force)return{error:`${o} was reinstated (${s.reason}); its entry is a record, not a target. Pass --force to withdraw it again.`};let a=r.reason||s?.reason;if(!a)return{error:`${o}: no --reason given and it has no default entry in the list.`};i.push({datasetId:o,reason:a})}return{targets:i}}function Y2(e){return e.filter((t)=>t.withdrawn!==!1)}je();sn();var bu=["pass","fail","uncertain","not_reviewed","in_progress","could_not_decide","exempt"],lFt=bu.filter((e)=>e!=="exempt");var Xnt=[/\{\{[^{}]*\}\}/,/\$\{[^{}]*\}/,/[<[]\s*(?:your|insert|enter|describe|write|fill in|replace)\s+(?=[^\s<>[\]])[^<>[\]]*[>\]](?![([])/i,/FirstAuthorSurname|paperDOI/i],Qnt=/(?:19|20)\d{2}(?!\d)/u,Znt=/10\.\d{4,9}\//u,eit=/^[\p{L}\p{M}]$/u,tit=/(?![\t-\r])[\p{Default_Ignorable_Code_Point}\p{Cf}\p{Cc}\u2800]/gu;function J2(e){return e.replace(tit,"")}function rit(e,t){let r=t;while(r>0){let n=e.charCodeAt(r-1),i=r>=2?e.charCodeAt(r-2):0,s=n>=56320&&n<=57343&&i>=55296&&i<=56319?r-2:r-1;if(!eit.test(e.slice(s,r)))break;r=s}return r}function Wv(e){let t=J2(e);for(let r of t.matchAll(new RegExp(Qnt,"gu"))){let n=r.index,i=t.charAt(n-1),o=i==="-"||i==="_"?n-1:n,s=rit(t,o);if(s<o)return t.slice(s,n+r[0].length)}return null}function Kv(e){return J2(e).match(Znt)?.[0]??null}function X2(e){let t=J2(e);for(let r of Xnt){let n=t.match(r)?.[0];if(n!==void 0)return n}return null}function fa(e,t=200){if(typeof e!=="string")return"";let n=(e.length>t*8?e.slice(0,t*8):e).normalize("NFKC").replace(/[\p{Cc}\p{Cf}\p{Cs}\p{Zl}\p{Zp}]/gu," ");for(let o=0;o<8;o++){let s=n;if(n=n.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/<[^>]*>/g," ").replace(/&#?\w+;/g," ").replace(/[@#`*_~|\\<>[\]{}]/g,"").replace(/\bGH-\d+/gi,""),n===s)break}n=n.replace(/\b(?:https?|ftp|file|data|javascript):\/*\S*/gi,"(link removed)").replace(/\bwww\.\S+/gi,"(link removed)").replace(/\s+/g," ").trim();let i=Array.from(n);return i.length>t?`${i.slice(0,t-3).join("").trimEnd()}...`:n}var hg=2;var nit=["genuine_contribution","no_degradation","advances_revision","material_improvement","clear_title_and_description","description_not_misleading"],iit=["no_degradation","advances_revision","material_improvement"];var ale=["dataset_description","readme_and_changes","participants","sidecars","recordings","derivatives","sourcedata","code","other"];function cle(e){return e.v===1?iit:nit}function lle(e,t){return e[t]}function gg(e,t){return typeof t==="string"&&e.includes(t)}var oit=["files_changed","files_read","truncated","version_before","version_after","subjects_before","subjects_after","areas","listed"],gFt=[...oit,"description_empty","description_cut","changelog_entry","title_problem","name_problem"];function sit(e,t){let r=e.split(".").map(Number),n=t.split(".").map(Number);for(let i=0;i<3;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}var ait={author_year:"title_author_year",doi:"title_doi",template_field:"title_template_field"},cit={author_year:"name_author_year",doi:"name_doi",template_field:"name_template_field"};function yg(e){let t={...e.criteria},r=[],n={pass:2,unknown:1,fail:0},i=(c,u,d)=>{let f=t[c];if(f!==void 0&&n[d]<n[f])t[c]=d,r.push({criterion:c,code:u,result:d})},o=(c,u)=>{if(t[c]===void 0)return;t[c]="fail",r.push({criterion:c,code:u,result:"fail"})},s=(c,u)=>{let d=t[c];if(d===void 0)return;if(n.unknown<n[d])t[c]="unknown";r.push({criterion:c,code:u,result:"unknown"})},a=e.evidence;if(a.files_changed===0)i("material_improvement","no_substantive_change","fail");if(a.version_after===null)i("advances_revision","evidence_incomplete","unknown");else if(a.version_before!==null&&sit(a.version_after,a.version_before)<=0)i("advances_revision","version_not_advanced","fail");if(a.truncated)i("no_degradation","evidence_incomplete","unknown");if(a.areas.recordings.removed>0)i("no_degradation","data_removed","unknown");if(a.areas.dataset_description.removed+a.areas.readme_and_changes.removed+a.areas.participants.removed>0)i("no_degradation","metadata_removed","unknown");if(ale.some((c)=>a.areas[c].removed>0))i("no_degradation","data_removed","unknown");if(a.subjects_before!==null&&a.subjects_after!==null&&a.subjects_after<a.subjects_before)i("no_degradation","data_removed","unknown");if(e.v===hg){let c=e.evidence;if(c.description_empty)o("clear_title_and_description","description_missing");if(c.changelog_entry==="not_added"||c.changelog_entry==="no_file")o("advances_revision","changes_log_missing");if(c.description_cut)i("description_not_misleading","description_cut","unknown");if(c.title_problem!==null)o("clear_title_and_description",ait[c.title_problem]);if(c.name_problem==="unchecked")s("no_degradation","name_unchecked");else if(c.name_problem!==null)o("no_degradation",cit[c.name_problem])}return{criteria:t,notes:r}}function lit(e){return yg(e).criteria}function Z2(e){if(e.steering)return"fail";let t=lit(e),r=cle(e).map((n)=>lle(t,n)??"unknown");if(r.includes("fail"))return"fail";if(r.every((n)=>n==="pass"))return"pass";return"uncertain"}var uit=["contributor_paused"],dit=["rate_limited","daily_limit"],yFt=[...uit,...dit],ule=5;var fit={reported:!0,declined:!0,error:!0,unreported:!0,exempt:!0,naming:!0},bFt=Object.keys(fit);function dle(e){return e.title!==null||e.name!==null&&e.name!=="unchecked"}function eA(e){return dle({title:e.title_problem,name:e.name_problem})?"refused":"unchecked"}var pit={genuine_contribution:"A genuine contribution, not spam",no_degradation:"Nothing is lost or broken",advances_revision:"The revision advances",material_improvement:"The dataset is materially better",clear_title_and_description:"The title and description say what changed",description_not_misleading:"The description is not misleading"},mit={pass:"Yes",fail:"No",unknown:"Could not tell"},xu="a NEMAR administrator",hit={contributor_paused:`Automated review was paused for this contributor when this commit arrived. ${wp(xu)} needs to review this one by hand.`,rate_limited:"Automated review was rate limited for this contributor when this commit arrived. That limit has since been removed. Push a new commit, or ask a NEMAR administrator to start the review.",daily_limit:"The daily limit of automated reviews had been reached when this commit arrived. That limit has since been removed. Push a new commit, or ask a NEMAR administrator to start the review."};function wp(e){return e.charAt(0).toUpperCase()+e.slice(1)}var git={title:"Not required: opened by a NEMAR owner or administrator",summary:"The automated review did not run on this pull request. NEMAR owners and administrators are not reviewed, and may merge without it. The title and the dataset name were checked against the naming rule, and nothing was found.",text:"Skipped is not a pass. It says the review is not required here, not that this change was reviewed. A pull request opened by anyone else is reviewed."},yit={title:"Not required: opened by a NEMAR owner or administrator (naming rule waived)",summary:"The automated review did not run on this pull request. NEMAR owners and administrators are not reviewed. The title or the dataset name breaks the naming rule, and a NEMAR administrator waived the rule for this commit with an explicit override, which is recorded.",text:"Skipped is not a pass. A new commit is checked against the naming rule again, and the waiver does not carry over to it."},bit={refused:`The naming rule found a problem with this pull request, so the review stage did not run and no model was asked. Edit the title, or the Name in dataset_description.json, as described below. A new title runs the review again as soon as it is saved, until edits have already started the review of this commit ${ule} times, the most one commit gets, and after that a push or a NEMAR administrator's start is what runs it; a new Name is a change to the files, so push again: the review runs on the new commit.`,unchecked:"The naming rule could not check this pull request's new dataset name, so the review stage did not run and no model was asked. Fixing dataset_description.json as described below and pushing again runs the review."},nle="The title has a citation (an author and a year, or a DOI) in it, the way a dataset is named (for example Lee2019, Lee-2019-EEG or 10.1038/s41597-020-0532-5), and the naming rule refuses one anywhere in a title. A pull request title says what the change does, such as Add three EEG recordings. Edit the title. Cite the paper in ReferencesAndLinks and the README instead.",ile="This pull request changes the dataset's name (the Name field of dataset_description.json) to one that has a citation (an author and a year, or a DOI) in it, which the naming rule refuses anywhere in a name. Choose a name that says what the dataset is, and cite the paper in ReferencesAndLinks and the README instead.",Yv={title:{author_year:nle,doi:nle,template_field:"The title still has an unfilled template field (such as FirstAuthorSurname, paperDOI, or a bracketed instruction). Put the real words in its place. Edit the title."},name:{author_year:ile,doi:ile,template_field:"This pull request changes the dataset's name (the Name field of dataset_description.json) to one with an unfilled template field. Put the real name in its place."}},wit="This pull request changes dataset_description.json, but the dataset's name (its Name field) could not be read from it, so the name was not checked against the naming rule. Make sure the file is valid JSON and that Name is text with a visible name.",xit="The dataset's name could not be checked against the naming rule. GitHub may not have answered, or dataset_description.json has no readable Name (it is missing, is not valid JSON, or its Name is not text or shows nothing). Start the check again once with `nemar admin pr-reviews start <dataset> <pr>`. If it says the same, fix dataset_description.json and push: the new commit is checked, and nothing can be waived until the name can be read.",vit={evidence_unavailable:"The changes could not be read.",stale_head:"The pull request or dataset changed while the review was starting. Check the current pull request and publication status; a new delivery may be needed.",too_large:`The change is too large for automated review. ${wp(xu)} needs to review it.`,auth_failed:`The review service could not sign in. ${wp(xu)} needs to fix the review service.`,model_unavailable:"The reviewing model was unavailable, or did not finish in time.",model_refused:"The reviewing model declined to review this change.",model_truncated:`The automated review used all the room it is given before it reached an answer, which a large pull request is likely to cause. Split it into smaller pull requests, for example by group of subjects or by kind of change, and open each one separately. ${wp(xu)} can also review it by hand.`,model_invalid:"The reviewing model did not return a usable review.",report_invalid:"The review could not be read back.",dispatch_failed:"The review could not be started. Push again to re-run it.",workflow_failed:"The review job failed before it finished.",edit_limit:`Edits to the title, description or base of this pull request, and reopenings and markings as ready for review, had already started the review of this commit ${ule} times, the most one commit gets. This latest change did not start the review again, and the earlier result no longer stands, because the text it judged may no longer be the pull request's. Push a new commit to run the review, or ask a NEMAR administrator to start the review of this commit again.`},ole={data_removed:"Data removed",metadata_removed:"Metadata removed",structure_broken:"Dataset structure broken",validation_regressed:"Validation regressed",version_not_advanced:"Version not advanced",changes_log_missing:"CHANGES entry missing",changes_log_mismatch:"CHANGES entry does not match the change",description_mismatch:"Description does not match the change",churn_only:"Formatting or churn only",no_substantive_change:"No substantive change",improvement_unclear:"Improvement unclear",evidence_incomplete:"Evidence incomplete",steering_attempt:"Text in the pull request tried to instruct the reviewer",spam:"Spam: promotional, unrelated or purposeless content, or repeated links",title_placeholder:"Title is placeholder or template text",title_not_descriptive:"Title does not say what changed",description_missing:"Description is empty",description_placeholder:"Description is placeholder text or not readable",description_misleading:"Description is misleading",description_cut:"Description is too long to read in full",title_author_year:"Title has a citation (an author and a year, or a DOI)",title_doi:"Title has a citation (an author and a year, or a DOI)",title_template_field:"Title has an unfilled template field",name_author_year:"New dataset name has a citation (an author and a year, or a DOI)",name_doi:"New dataset name has a citation (an author and a year, or a DOI)",name_template_field:"New dataset name has an unfilled template field",name_unchecked:"New dataset name could not be read",original_text_altered:"Original text changed",original_field_altered:"Original field changed",recording_replaced:"Recorded data changed",other:"Other"};function _it(e){switch(e){case"description_missing":return"found from the pull request, not by the reviewer: a pull request needs a description of what changed";case"description_cut":return"found from the pull request, not by the reviewer: the description is longer than the reviewer reads, so whether it is misleading, or tries to instruct the reviewer, was not assessed";case"title_author_year":case"title_doi":case"title_template_field":case"name_author_year":case"name_doi":case"name_template_field":case"name_unchecked":return"found by the naming rule, not by the reviewer";default:return"found from the files, not by the reviewer"}}var wu="An automated review of the changes in this pull request. It does not replace a NEMAR administrator, whose approval is what merges it. Where the dataset's rules require this check, the pull request cannot be merged until it passes.",mg=`No verdict was reached, so this check does not pass. ${wp(xu)} needs to look at this pull request.`,Dit={dataset_description:"Dataset description",readme_and_changes:"README and CHANGES",participants:"Participants",sidecars:"Sidecars and tables",recordings:"Recordings and data files",derivatives:"Derivatives",sourcedata:"Source data",code:"Code",other:"Other files"},sle={added:"added",modified:"changed",removed:"removed"};function Q2(e,t,r){return`${e} ${e===1?t:r}`}function Eit(e,t=!1){let r=["**What changed**",""];if(e.files_changed===0)return r.push("No files changed.",""),r;r.push("| Area | Added | Changed | Removed |","| --- | ---: | ---: | ---: |");for(let i of ale){let o=e.areas[i];if(o.added+o.modified+o.removed===0)continue;r.push(`| ${Dit[i]} | ${o.added} | ${o.modified} | ${o.removed} |`)}r.push("");let n=[];if(e.version_before!==null||e.version_after!==null)n.push(`Version ${e.version_before??"unknown"} to ${e.version_after??"unknown"}.`);if(e.subjects_before!==null||e.subjects_after!==null)n.push(`Subjects ${e.subjects_before??"unknown"} to ${e.subjects_after??"unknown"}.`);return n.push(t?"The full review did not run, so no file's content was read.":e.files_read===e.files_changed?`The content of all ${Q2(e.files_changed,"changed file","changed files")} was read.`:`The content of ${e.files_read} of ${Q2(e.files_changed,"changed file","changed files")} was read. Files not read were judged by name and type only. Recordings and other data files are stored outside git and are never read.`),r.push(n.join(" "),""),r}function Sit(e){if(e.listed.length===0)return"";let t=e.listed.map((i)=>i.path?`- ${sle[i.status]} \`${i.path}\``:`- ${sle[i.status]} (name not shown)`),r=e.files_changed-e.listed.length,n=r>0?`
|
|
241
241
|
- and ${Q2(r,"more file","more files")}, counted above`:"";return`<details><summary>Changed files (${e.listed.length} of ${e.files_changed})</summary>
|
|
242
242
|
|
|
243
243
|
${t.join(`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nemar-cli",
|
|
3
3
|
"packageManager": "bun@1.4.3",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.22-PR1863.caf1deb",
|
|
5
5
|
"description": "CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|