pan-stack-cli 0.3.2 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/bin/pan.js +4 -4
  3. package/package.json +6 -8
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # pan-stack-cli
2
2
 
3
- Tài liệu đầy đủ (tạm thời): [docs/README.full.md](docs/README.full.md)
3
+ Full documentation (temporary): [docs/README.full.md](docs/README.full.md)
package/bin/pan.js CHANGED
@@ -89,7 +89,7 @@ positional:
89
89
 
90
90
  No args (or [manifest]) \u2192 clone ALL repos in the manifest.
91
91
  With <git-url> \u2192 derive project name from the URL, append one entry to
92
- 'repositories:' in .project.yaml (default path 'apps/<name>'), then clone
92
+ 'repositories:' in .project.yaml (default path 'repos/<name>'), then clone
93
93
  that repo. If the name already exists in the manifest, reuse the entry (no duplicate).
94
94
 
95
95
  Prints a compact summary table \u2014 does not stop on the first error.
@@ -407,7 +407,7 @@ positional:
407
407
 
408
408
  Kh\xF4ng tham s\u1ED1 (ho\u1EB7c [manifest]) \u2192 clone T\u1EA4T C\u1EA2 repo trong manifest.
409
409
  C\xF3 <git-url> \u2192 t\xE1ch t\xEAn d\u1EF1 \xE1n t\u1EEB URL, th\xEAm 1 entry v\xE0o 'repositories:' trong
410
- .project.yaml (path m\u1EB7c \u0111\u1ECBnh 'apps/<t\xEAn>'), r\u1ED3i clone repo \u0111\xF3. \u0110\xE3 c\xF3 t\xEAn trong
410
+ .project.yaml (path m\u1EB7c \u0111\u1ECBnh 'repos/<t\xEAn>'), r\u1ED3i clone repo \u0111\xF3. \u0110\xE3 c\xF3 t\xEAn trong
411
411
  manifest \u2192 d\xF9ng l\u1EA1i entry c\u0169 (kh\xF4ng th\xEAm tr\xF9ng).
412
412
 
413
413
  In b\u1EA3ng t\xF3m t\u1EAFt \u2014 kh\xF4ng d\u1EEBng \u1EDF l\u1ED7i \u0111\u1EA7u ti\xEAn.
@@ -697,7 +697,7 @@ ${e}
697
697
  `)}function Cp({workspaceRoot:t,hidden:e,scanned:n,managed:r}){let o=Mc.default.join(t,ey,ty),i=!to.default.existsSync(o);i&&(to.default.mkdirSync(Mc.default.dirname(o),{recursive:!0}),to.default.writeFileSync(o,CI(),"utf8"));let a=to.default.readFileSync(o,"utf8"),s=a.split(/\r?\n/),l=new Set(e),c=new Set(r),u=SI(s,l,c),d=AI(s,n),f=s.join(`
698
698
  `),h=i||u||d||f!==a;return f!==a&&to.default.writeFileSync(o,f,"utf8"),{settingsPath:o,created:i,changed:h,excluded:[...l].sort(),scanned:n.slice()}}var to,Mc,ey,ty,ls,Ap,sy=A(()=>{"use strict";to=L(require("fs")),Mc=L(require("path")),ey=".vscode",ty="settings.json",ls="files.exclude",Ap="git.scanRepositories"});function NI(t,e){let n=String(t??"").trim().toLowerCase();return n==="false"||n==="no"||n==="off"||n==="0"?!1:n==="true"||n==="yes"||n==="on"||n==="1"?!0:e}function II(t){return t.split(ds.default.sep).join("/").replace(/^\.\//,"").replace(/\/+$/,"")}function LI(t){let e=[],n=!1,r=null;for(let o=0;o<t.length;o+=1){let i=t[o]??"",a=i.trim();if(!a)continue;let s=i.length-i.trimStart().length;if(s===0){if(a.startsWith("#"))continue;n=/^repositories\s*:/.test(a),r=null;continue}if(!(!n||a.startsWith("#"))){if(s===2&&a.startsWith("- ")){r={keys:{},startLine:o,lastLine:o,visibleLine:-1,keyIndent:4},e.push(r);let l=a.slice(2).trim();if(l){let[c,u]=No(l);r.keys[c]=u,c===Bc&&(r.visibleLine=o)}continue}if(r&&s>=4){let[l,c]=No(a);r.keys[l]=c,r.lastLine=o,r.keyIndent=s,l===Bc&&(r.visibleLine=o)}}}return e}function ly(t){let e=us.default.readFileSync(t,"utf8").split(/\r?\n/);return{lines:e,entries:LI(e)}}function OI(t,e){let n=rn(t.keys.name);if(!n)return null;let r=II(rn(t.keys.path)||n);return r?{name:n,repoPath:r,description:rn(t.keys.description),visible:NI(t.keys[Bc],!0),declared:t.visibleLine>=0,sourcePath:e,sourceFile:ds.default.basename(e)}:null}function Rp(t=process.cwd()){let e=tn(t);if(!e)throw new Error("NO_MANIFEST");let n=ds.default.dirname(e),r=ds.default.join(n,RI),o=[],i=new Set;for(let a of[e,r])if(us.default.existsSync(a))for(let s of ly(a).entries){let l=OI(s,a);!l||i.has(l.repoPath)||(i.add(l.repoPath),o.push(l))}return{workspaceRoot:n,manifestPath:e,localManifestPath:r,repos:o}}function DI(t,e){if(!us.default.existsSync(t)||e.size===0)return 0;let{lines:n,entries:r}=ly(t),o=[];for(let i of r){let a=rn(i.keys.name),s=e.get(a);if(s===void 0)continue;let l=i.visibleLine>=0;if(s){l&&o.push({at:i.visibleLine,remove:1,insert:[]});continue}let c=`${" ".repeat(i.keyIndent)}${Bc}: false`;if(l){(n[i.visibleLine]??"")!==c&&o.push({at:i.visibleLine,remove:1,insert:[c]});continue}o.push({at:i.lastLine+1,remove:0,insert:[c]})}if(o.length===0)return 0;o.sort((i,a)=>a.at-i.at);for(let i of o)n.splice(i.at,i.remove,...i.insert);return us.default.writeFileSync(t,n.join(`
699
699
  `),"utf8"),o.length}function cy(t,e){let n=new Map;for(let o of t.repos){let i=e.get(o.name);if(i===void 0)continue;let a=n.get(o.sourcePath)??new Map;a.set(o.name,i),n.set(o.sourcePath,a)}let r=[];for(let[o,i]of n)DI(o,i)>0&&r.push(o);return r}var us,ds,RI,Bc,uy=A(()=>{"use strict";us=L(require("fs")),ds=L(require("path"));nn();Wl();RI=".project.local.yaml",Bc="visible"});var py={};be(py,{applyStates:()=>Ip,resolveStates:()=>Lp,runRepo:()=>jI,syncFromManifest:()=>Op});function dy(t){let e=t,n=String(e&&`${String(e.name)} ${String(e.message)}`||"");return/ExitPromptError|force closed|SIGINT|cancel/i.test(n)}function Vn(t){return z(t)}function Lp(t,{fresh:e}){let n=e?new Set:ay(t.workspaceRoot);return t.repos.map(r=>({repo:r,visible:r.declared?r.visible:!n.has(r.repoPath)}))}function Ip(t,e){let n=new Map(e.map(i=>[i.repo.name,i.visible])),r=cy(t,n),o=Cp({workspaceRoot:t.workspaceRoot,hidden:e.filter(i=>!i.visible).map(i=>i.repo.repoPath),scanned:e.filter(i=>i.visible).map(i=>i.repo.repoPath),managed:e.map(i=>i.repo.repoPath)});return{touched:r,sync:o}}function fy(t,e){let n=t.filter(i=>i.visible).length,r=t.length-n;for(let i of e.touched)console.log(fe(p("REPO_MANIFEST_UPDATED__PATH",{path:i})));let o=e.sync.created?"REPO_SETTINGS_CREATED__PATH":e.sync.changed?"REPO_SETTINGS_UPDATED__PATH":"REPO_SETTINGS_UNCHANGED__PATH";console.log((e.sync.changed?fe:Vn)(p(o,{path:e.sync.settingsPath}))),console.log(Vn(p("REPO_SUMMARY__VISIBLE_HIDDEN",{visible:n,hidden:r}))),r>0&&console.log(Vn(p("REPO_RELOAD_HINT")))}function Np(t){console.log(""),console.log(_e(`\u2500\u2500\u2500 ${p("REPO_LIST_TITLE")} \u2500\u2500\u2500`));let e=Math.max(...t.map(n=>n.repo.name.length),4);for(let n of t){let r=n.visible?fe(p("REPO_STATE_VISIBLE")):he(p("REPO_STATE_HIDDEN")),o=n.repo.sourceFile===".project.yaml"?"":` ${Vn(n.repo.sourceFile)}`;console.log(` ${n.repo.name.padEnd(e)} ${r} ${Vn(n.repo.repoPath)}${o}`)}console.log("")}async function PI(t){let e=t.map((i,a)=>({name:`${i.repo.name} ${Vn(`\u2014 ${i.repo.repoPath}`)}`,value:a,short:i.repo.name})),n=t.map((i,a)=>i.visible?a:-1).filter(i=>i>=0),r=Math.min(Math.max(t.length+2,8),24);try{let i=await cn({message:p("REPO_SELECT_MESSAGE"),choices:e,initialChecked:n,pageSize:r,hotkeys:[{key:"x",label:p("EXIT_LABEL"),value:"__exit__"}]});if(i.action!=="submit")return null;let a=new Set(i.values??[]);return t.map((s,l)=>a.has(l))}catch(i){if(String(i?.message)!=="no-core"){if(dy(i))return null;throw i}}let o=await Cn();if(!o||typeof o.checkbox!="function"||!process.stdin.isTTY)return console.error(p("REPO_NO_PICKER")),null;try{let i=await o.checkbox({message:p("REPO_SELECT_MESSAGE"),choices:t.map((s,l)=>({name:`${s.repo.name} ${Vn(`\u2014 ${s.repo.repoPath}`)}`,value:l,checked:s.visible})),pageSize:r}),a=new Set(i);return t.map((s,l)=>a.has(l))}catch(i){if(dy(i))return null;throw i}}function MI(){console.log(p("REPO_USAGE"))}function Op({startDir:t=process.cwd(),silent:e=!1}={}){let n=Rp(t);if(n.repos.length===0)return null;let r=Lp(n,{fresh:!1}),o=Cp({workspaceRoot:n.workspaceRoot,hidden:r.filter(i=>!i.visible).map(i=>i.repo.repoPath),scanned:r.filter(i=>i.visible).map(i=>i.repo.repoPath),managed:r.map(i=>i.repo.repoPath)});if(!e){let i=o.created?"REPO_SETTINGS_CREATED__PATH":o.changed?"REPO_SETTINGS_UPDATED__PATH":"REPO_SETTINGS_UNCHANGED__PATH";console.log((o.changed?fe:Vn)(p(i,{path:o.settingsPath}))),console.log(Vn(p("REPO_SUMMARY__VISIBLE_HIDDEN",{visible:o.scanned.length,hidden:o.excluded.length})))}return o}async function jI(t){if(t.includes("-h")||t.includes("--help")){MI();return}let e=t.includes("--fresh"),n=t.find(s=>!s.startsWith("-"))||"";if(n&&n!=="update"&&n!=="list")throw new Error(p("REPO_UNKNOWN_SUBCOMMAND__SUB",{sub:n}));let r;try{r=Rp()}catch{throw new Error(p("REPO_NO_MANIFEST"))}if(r.repos.length===0)throw new Error(p("REPO_NO_REPOS__PATH",{path:r.manifestPath}));let o=Lp(r,{fresh:e});if(n==="list"){Np(o);return}if(n==="update"){fy(o,Ip(r,o));return}if(!process.stdin.isTTY){Np(o),console.log(Vn(p("REPO_NON_TTY_HINT")));return}Np(o);let i=await PI(o);if(!i){console.log(p("EXITED"));return}let a=o.map((s,l)=>({...s,visible:i[l]??!1}));fy(a,Ip(r,a))}var Dp=A(()=>{"use strict";Rt();eo();ne();Bt();sy();uy()});var WI={};function my(t){if(!t.url)throw new Error(p("REPO_MISSING_URL__NAME",{name:t.name}));return t.url}function BI(t){let e=t.split(`
700
- `).map(r=>r.trim()).filter(Boolean);return(e.find(r=>/^(fatal:|remote:|error:)/i.test(r))||e[e.length-1]||e[0]||"").slice(0,100)}function UI(t){return/permission denied|authentication failed|access denied|403|could not read username|invalid username or password/i.test(t)?"no-access":/repository .* not found|not found|does not exist|404/i.test(t)?"not-found":"failed"}function gy({name:t,url:e,destination:n,dryRun:r}){if(Pp.default.existsSync(n))return{name:t,exists:!0};if(r)return console.log(z(`[dry-run] git clone ${e} ${n}`)),{name:t,dryRun:!0};Pp.default.mkdirSync(Mp.default.dirname(n),{recursive:!0}),process.stdout.write(z(` \u21E9 ${t} ... `));let o=(0,hy.spawnSync)("git",["clone",e,n],gt({encoding:"utf8"})),i=o.status===0,a=(o.stderr||"").trim(),s=i?"ok":UI(a),l=i?p("CLONE_STATUS_CLONED"):s==="no-access"?p("CLONE_STATUS_NO_ACCESS"):s==="not-found"?p("CLONE_STATUS_NOT_FOUND"):p("BULK_STATUS_FAILED");return console.log((i?fe:s==="no-access"?he:Ce)(l)),{name:t,status:o.status,category:s,error:i?"":BI(a)}}function $I(t){if(t.dryRun)return{repo:t.name,result:z(p("BULK_STATUS_DRY_RUN")),note:""};if(t.exists)return{repo:t.name,result:Ze("skip",p("CLONE_STATUS_EXISTS")),note:""};if(!t.error)return{repo:t.name,result:Ze("ok",p("CLONE_STATUS_CLONED")),note:""};let e=t.category==="no-access"?p("CLONE_STATUS_NO_ACCESS"):t.category==="not-found"?p("CLONE_STATUS_NOT_FOUND"):p("BULK_STATUS_FAILED"),n=t.category==="no-access"?"warn":"fail";return{repo:t.name,result:Ze(n,e),note:z(t.error)}}function FI(){console.log(p("GIT_USAGE_CLONE",{common:ze()}))}function _y(t,e){let n=t.filter(c=>!c.dryRun&&!c.exists&&!c.error),r=t.filter(c=>c.exists),o=t.filter(c=>c.category==="no-access"),i=t.filter(c=>c.category==="not-found"),a=t.filter(c=>c.error&&c.category==="failed"),s=t.map($I),l=[];if(l.push(z(p("CLONE_FOOTER_COUNTS__TOTAL_CLONED_EXISTS_NOACCESS_NOTFOUND_FAILED",{total:t.length,cloned:n.length,exists:r.length,noAccess:o.length,notFound:i.length,failed:a.length}))),o.length){l.push(""),l.push(he(p("CLONE_NO_ACCESS_HEADER")));for(let c of o)l.push(` ${Qe(c.name)}`)}if(!e&&t.every(c=>c.exists)){console.log(""),console.log(_e(`\u2500\u2500\u2500 ${p("CLONE_TITLE")} \u2500\u2500\u2500`)),console.log(fe(p("CLONE_ALL_EXIST__N",{n:t.length})));for(let c of l)console.log(c)}else an({title:p("CLONE_TITLE"),rows:s,columns:Tt([{key:"repo",labelKey:"BULK_COL_REPO"},{key:"result",labelKey:"BULK_COL_RESULT"},{key:"note",labelKey:"BULK_COL_NOTE"}]),footerLines:l});(o.length||i.length||a.length)&&(process.exitCode=1)}function GI(t,{baseDirArg:e,dryRun:n}){let r=ob(t);if(!r)throw new Error(`Kh\xF4ng t\xE1ch \u0111\u01B0\u1EE3c t\xEAn d\u1EF1 \xE1n t\u1EEB URL: ${t}`);let{manifestPath:o,baseDir:i}=C0({baseDir:e||"."}),a=[];try{({repos:a}=$e({baseDir:e,allowFallback:!1}))}catch{a=[]}let s=a.find(d=>d.name===r),l=t,c=Mp.default.resolve(i,"apps",r);if(s)console.log(z(`\u2139\uFE0F '${r}' \u0111\xE3 c\xF3 trong manifest \u2014 d\xF9ng entry hi\u1EC7n c\xF3 (${s.url}).`)),l=my(s),c=s.destination;else{let d=`apps/${r}`;n?console.log(z(`[dry-run] + th\xEAm '${r}' v\xE0o ${o} (url: ${t}, path: ${d})`)):(ib(o,{name:r,url:t,path:d}),console.log(fe(`\u2713 \u0110\xE3 th\xEAm '${r}' v\xE0o ${o} (path: ${d})`)))}let u=gy({name:r,url:l,destination:c,dryRun:n});_y([u],n),n||by()}function by(){try{let t=Op({silent:!0});t?.changed&&console.log(z(p("REPO_SETTINGS_UPDATED__PATH",{path:t.settingsPath})))}catch{}}function HI(){let t=process.argv.slice(2);if(t.includes("-h")||t.includes("--help")){FI();return}let e=t.includes("--dry-run"),n=t.indexOf("--base-dir"),r=n>=0?t[n+1]:"",o=t.find((l,c)=>!l.startsWith("--")&&t[c-1]!=="--base-dir"&&rb(l));if(o){GI(o,{baseDirArg:r,dryRun:e});return}let i=St(t),{repos:a}=$e({manifestPath:i.manifest,baseDir:i.baseDir,allowFallback:!1}),s=a.map(l=>gy({name:l.name,url:my(l),destination:l.destination,dryRun:i.dryRun}));_y(s,i.dryRun),i.dryRun||by()}var Pp,Mp,hy,xy=A(()=>{"use strict";Pp=L(require("fs")),Mp=L(require("path")),hy=require("child_process");fr();Tn();Wl();Yr();Dp();Bt();ne();try{HI()}catch(t){console.error(t instanceof Error?t.message:String(t)),process.exit(1)}});var qI={};function KI({name:t,destination:e,dryRun:n,rebase:r}){if(!bt({name:t,destination:e}))return{name:t,skipped:!0};let o=qe(e)||p("GST_DETACHED"),i=["pull","--stat"];if(r&&i.push("--rebase"),n)return console.log(z(`[dry-run] (in ${e}) git ${i.join(" ")}`)),{name:t,branch:o,dryRun:!0};process.stdout.write(z(` \u21BB ${t} (${o}) ... `));let a=Ci(i,e),s=pb(a.stdout,a.stderr),l=s.conflict?Ai(e):[],c=a.status===0&&!s.conflict,u=s.upToDate?p("BULK_STATUS_UP_TO_DATE"):s.conflict?p("BULK_STATUS_CONFLICT"):s.mode!=="unknown"?N0(s.mode):c?p("BULK_STATUS_PULLED"):p("BULK_STATUS_FAILED");return console.log((c?fe:s.conflict?he:Ce)(u)),{name:t,branch:o,status:a.status,upToDate:s.upToDate,conflict:s.conflict,conflictFiles:l,mode:s.mode,filesChanged:s.filesChanged,insertions:s.insertions,deletions:s.deletions,error:a.status!==0&&!s.conflict?(a.stderr.split(`
700
+ `).map(r=>r.trim()).filter(Boolean);return(e.find(r=>/^(fatal:|remote:|error:)/i.test(r))||e[e.length-1]||e[0]||"").slice(0,100)}function UI(t){return/permission denied|authentication failed|access denied|403|could not read username|invalid username or password/i.test(t)?"no-access":/repository .* not found|not found|does not exist|404/i.test(t)?"not-found":"failed"}function gy({name:t,url:e,destination:n,dryRun:r}){if(Pp.default.existsSync(n))return{name:t,exists:!0};if(r)return console.log(z(`[dry-run] git clone ${e} ${n}`)),{name:t,dryRun:!0};Pp.default.mkdirSync(Mp.default.dirname(n),{recursive:!0}),process.stdout.write(z(` \u21E9 ${t} ... `));let o=(0,hy.spawnSync)("git",["clone",e,n],gt({encoding:"utf8"})),i=o.status===0,a=(o.stderr||"").trim(),s=i?"ok":UI(a),l=i?p("CLONE_STATUS_CLONED"):s==="no-access"?p("CLONE_STATUS_NO_ACCESS"):s==="not-found"?p("CLONE_STATUS_NOT_FOUND"):p("BULK_STATUS_FAILED");return console.log((i?fe:s==="no-access"?he:Ce)(l)),{name:t,status:o.status,category:s,error:i?"":BI(a)}}function $I(t){if(t.dryRun)return{repo:t.name,result:z(p("BULK_STATUS_DRY_RUN")),note:""};if(t.exists)return{repo:t.name,result:Ze("skip",p("CLONE_STATUS_EXISTS")),note:""};if(!t.error)return{repo:t.name,result:Ze("ok",p("CLONE_STATUS_CLONED")),note:""};let e=t.category==="no-access"?p("CLONE_STATUS_NO_ACCESS"):t.category==="not-found"?p("CLONE_STATUS_NOT_FOUND"):p("BULK_STATUS_FAILED"),n=t.category==="no-access"?"warn":"fail";return{repo:t.name,result:Ze(n,e),note:z(t.error)}}function FI(){console.log(p("GIT_USAGE_CLONE",{common:ze()}))}function _y(t,e){let n=t.filter(c=>!c.dryRun&&!c.exists&&!c.error),r=t.filter(c=>c.exists),o=t.filter(c=>c.category==="no-access"),i=t.filter(c=>c.category==="not-found"),a=t.filter(c=>c.error&&c.category==="failed"),s=t.map($I),l=[];if(l.push(z(p("CLONE_FOOTER_COUNTS__TOTAL_CLONED_EXISTS_NOACCESS_NOTFOUND_FAILED",{total:t.length,cloned:n.length,exists:r.length,noAccess:o.length,notFound:i.length,failed:a.length}))),o.length){l.push(""),l.push(he(p("CLONE_NO_ACCESS_HEADER")));for(let c of o)l.push(` ${Qe(c.name)}`)}if(!e&&t.every(c=>c.exists)){console.log(""),console.log(_e(`\u2500\u2500\u2500 ${p("CLONE_TITLE")} \u2500\u2500\u2500`)),console.log(fe(p("CLONE_ALL_EXIST__N",{n:t.length})));for(let c of l)console.log(c)}else an({title:p("CLONE_TITLE"),rows:s,columns:Tt([{key:"repo",labelKey:"BULK_COL_REPO"},{key:"result",labelKey:"BULK_COL_RESULT"},{key:"note",labelKey:"BULK_COL_NOTE"}]),footerLines:l});(o.length||i.length||a.length)&&(process.exitCode=1)}function GI(t,{baseDirArg:e,dryRun:n}){let r=ob(t);if(!r)throw new Error(`Kh\xF4ng t\xE1ch \u0111\u01B0\u1EE3c t\xEAn d\u1EF1 \xE1n t\u1EEB URL: ${t}`);let{manifestPath:o,baseDir:i}=C0({baseDir:e||"."}),a=[];try{({repos:a}=$e({baseDir:e,allowFallback:!1}))}catch{a=[]}let s=a.find(d=>d.name===r),l=t,c=Mp.default.resolve(i,"repos",r);if(s)console.log(z(`\u2139\uFE0F '${r}' \u0111\xE3 c\xF3 trong manifest \u2014 d\xF9ng entry hi\u1EC7n c\xF3 (${s.url}).`)),l=my(s),c=s.destination;else{let d=`repos/${r}`;n?console.log(z(`[dry-run] + th\xEAm '${r}' v\xE0o ${o} (url: ${t}, path: ${d})`)):(ib(o,{name:r,url:t,path:d}),console.log(fe(`\u2713 \u0110\xE3 th\xEAm '${r}' v\xE0o ${o} (path: ${d})`)))}let u=gy({name:r,url:l,destination:c,dryRun:n});_y([u],n),n||by()}function by(){try{let t=Op({silent:!0});t?.changed&&console.log(z(p("REPO_SETTINGS_UPDATED__PATH",{path:t.settingsPath})))}catch{}}function HI(){let t=process.argv.slice(2);if(t.includes("-h")||t.includes("--help")){FI();return}let e=t.includes("--dry-run"),n=t.indexOf("--base-dir"),r=n>=0?t[n+1]:"",o=t.find((l,c)=>!l.startsWith("--")&&t[c-1]!=="--base-dir"&&rb(l));if(o){GI(o,{baseDirArg:r,dryRun:e});return}let i=St(t),{repos:a}=$e({manifestPath:i.manifest,baseDir:i.baseDir,allowFallback:!1}),s=a.map(l=>gy({name:l.name,url:my(l),destination:l.destination,dryRun:i.dryRun}));_y(s,i.dryRun),i.dryRun||by()}var Pp,Mp,hy,xy=A(()=>{"use strict";Pp=L(require("fs")),Mp=L(require("path")),hy=require("child_process");fr();Tn();Wl();Yr();Dp();Bt();ne();try{HI()}catch(t){console.error(t instanceof Error?t.message:String(t)),process.exit(1)}});var qI={};function KI({name:t,destination:e,dryRun:n,rebase:r}){if(!bt({name:t,destination:e}))return{name:t,skipped:!0};let o=qe(e)||p("GST_DETACHED"),i=["pull","--stat"];if(r&&i.push("--rebase"),n)return console.log(z(`[dry-run] (in ${e}) git ${i.join(" ")}`)),{name:t,branch:o,dryRun:!0};process.stdout.write(z(` \u21BB ${t} (${o}) ... `));let a=Ci(i,e),s=pb(a.stdout,a.stderr),l=s.conflict?Ai(e):[],c=a.status===0&&!s.conflict,u=s.upToDate?p("BULK_STATUS_UP_TO_DATE"):s.conflict?p("BULK_STATUS_CONFLICT"):s.mode!=="unknown"?N0(s.mode):c?p("BULK_STATUS_PULLED"):p("BULK_STATUS_FAILED");return console.log((c?fe:s.conflict?he:Ce)(u)),{name:t,branch:o,status:a.status,upToDate:s.upToDate,conflict:s.conflict,conflictFiles:l,mode:s.mode,filesChanged:s.filesChanged,insertions:s.insertions,deletions:s.deletions,error:a.status!==0&&!s.conflict?(a.stderr.split(`
701
701
  `)[0]||"").slice(0,80):""}}function zI(t){if(t.skipped)return{repo:z(t.name),branch:"",result:z(p("BULK_STATUS_SKIPPED")),changes:"",conflict:""};if(t.dryRun)return{repo:t.name,branch:t.branch,result:z(p("BULK_STATUS_DRY_RUN")),changes:"",conflict:""};let e=t.upToDate?Ze("ok",p("BULK_STATUS_UP_TO_DATE")):t.conflict?Ze("warn",p("BULK_STATUS_CONFLICT")):t.error?Ze("fail",p("BULK_STATUS_FAILED")):Ze("ok",t.mode&&t.mode!=="unknown"?N0(t.mode):p("BULK_STATUS_PULLED")),n=t.filesChanged===1?p("BULK_FILES_ONE"):p("BULK_FILES_MANY"),r=t.filesChanged?`${t.filesChanged} ${n} ${fe("+"+t.insertions)} ${Ce("\u2212"+t.deletions)}`:z("\u2014"),o=t.conflictFiles?.length??0,i=t.conflict?he(`${o} ${o===1?p("BULK_FILES_ONE"):p("BULK_FILES_MANY")}`):z("\u2014");return{repo:t.name,branch:t.branch,result:e,changes:r,conflict:i}}function YI(){console.log(p("GIT_USAGE_PULL",{common:ze()}))}function VI(){let t=St(process.argv.slice(2),{defaults:{rebase:!1,noWorkspace:!1},handlers:{"--rebase":f=>{f.rebase=!0},"--no-workspace":f=>{f.noWorkspace=!0}}});if(t.help){YI();return}let{repos:e,workspaceRoot:n}=$e({manifestPath:t.manifest,baseDir:t.baseDir}),r=[];!t.noWorkspace&&at(n)&&r.push({name:"workspace",destination:n}),r.push(...e.map(f=>({name:f.name,destination:f.destination})));let o=r.map(f=>KI({name:f.name,destination:f.destination,dryRun:t.dryRun,rebase:!!t.rebase})),i=o.filter(f=>f.conflict),a=o.filter(f=>!f.skipped&&!f.dryRun&&!f.upToDate&&!f.conflict&&!f.error),s=o.filter(f=>f.error),l=o.filter(f=>f.upToDate),u=o.filter(f=>f.dryRun||!f.skipped&&!f.upToDate).map(zI),d=[];if(d.push(z(p("PULL_FOOTER_COUNTS__TOTAL_CHANGED_UPTODATE_CONFLICT_FAILED",{total:o.length,changed:a.length,upToDate:l.length,conflict:i.length,failed:s.length}))),i.length){d.push(""),d.push(_e(he(p("PULL_CONFLICT_HEADER"))));for(let f of i)d.push(` ${Qe(f.name)} (${f.branch}): ${f.conflictFiles?.join(", ")||"(git status)"}`)}if(u.length===0){console.log(""),console.log(_e(`\u2500\u2500\u2500 ${p("PULL_TITLE")} \u2500\u2500\u2500`)),console.log(fe(p("PULL_ALL_UP_TO_DATE__N",{n:o.length})));for(let f of d)console.log(f)}else an({title:p("PULL_TITLE"),rows:u,columns:Tt([{key:"repo",labelKey:"BULK_COL_REPO"},{key:"branch",labelKey:"BULK_COL_BRANCH"},{key:"result",labelKey:"BULK_COL_RESULT"},{key:"changes",labelKey:"BULK_COL_CHANGES"},{key:"conflict",labelKey:"BULK_COL_CONFLICT"}]),footerLines:d});(i.length||s.length)&&(process.exitCode=1)}var yy=A(()=>{"use strict";Tn();Ut();Yr();Bt();ne();try{VI()}catch(t){console.error(t instanceof Error?t.message:String(t)),process.exit(1)}});var e3={};function JI({name:t,destination:e,dryRun:n}){if(!bt({name:t,destination:e}))return{name:t,skipped:!0};let r=qe(e)||p("GST_DETACHED");if(n)return console.log(z(`[dry-run] (in ${e}) git fetch --all`)),{name:t,branch:r,dryRun:!0};process.stdout.write(z(` \u21E3 ${t} (${r}) ... `));let o=Ci(["fetch","--all","--prune"],e),i=mb(o.stdout,o.stderr),a=Ya(e),s=o.status===0,l=s?i.newBranches||i.updatedBranches||i.newTags?p("BULK_STATUS_UPDATED"):p("BULK_STATUS_OK"):p("BULK_STATUS_FAILED");return console.log((s?fe:Ce)(l)),{name:t,branch:r,status:o.status,...i,ahead:a?a.ahead:0,behind:a?a.behind:0,hasUpstream:!!a,error:s?"":(o.stderr.split(`
702
702
  `)[0]||"").slice(0,80)}}function XI(t){if(t.skipped)return{repo:z(t.name),branch:"",result:z(p("BULK_STATUS_SKIPPED")),sync:"",refs:""};if(t.dryRun)return{repo:t.name,branch:t.branch,result:z(p("BULK_STATUS_DRY_RUN")),sync:"",refs:""};let e=t.error?Ze("fail",p("BULK_STATUS_FAILED")):Ze("ok",p("BULK_STATUS_FETCHED")),n;if(!t.hasUpstream)n=z(p("BULK_STATUS_NO_UPSTREAM"));else if(t.behind===0&&t.ahead===0)n=fe(p("BULK_STATUS_IN_SYNC"));else{let i=[];t.behind&&i.push(he(`${zr.down} ${t.behind}`)),t.ahead&&i.push(Qe(`${zr.up} ${t.ahead}`)),n=i.join(" ")}let r=[];t.newBranches&&r.push(p("BULK_REFS_NEW__N",{n:t.newBranches})),t.updatedBranches&&r.push(p("BULK_REFS_UPD__N",{n:t.updatedBranches})),t.newTags&&r.push(p("BULK_REFS_TAGS__N",{n:t.newTags})),t.prunedRefs&&r.push(p("BULK_REFS_PRUNED__N",{n:t.prunedRefs}));let o=r.length?r.join(" \xB7 "):z("\u2014");return{repo:t.name,branch:t.branch,result:e,sync:n,refs:o}}function QI(){console.log(p("GIT_USAGE_FETCH",{common:ze()}))}function ZI(){let t=St(process.argv.slice(2),{defaults:{noWorkspace:!1},handlers:{"--no-workspace":m=>{m.noWorkspace=!0}}});if(t.help){QI();return}let{repos:e,workspaceRoot:n}=$e({manifestPath:t.manifest,baseDir:t.baseDir}),r=[];!t.noWorkspace&&at(n)&&r.push({name:"workspace",destination:n}),r.push(...e.map(m=>({name:m.name,destination:m.destination})));let o=r.map(m=>JI({name:m.name,destination:m.destination,dryRun:t.dryRun})),i=o.filter(m=>(m.behind??0)>0),a=o.filter(m=>m.error),s=m=>(m.newBranches||m.updatedBranches||m.newTags||m.prunedRefs||0)>0,l=m=>s(m)||(m.behind??0)>0||(m.ahead??0)>0||!!m.error,c=o.filter(m=>!m.skipped&&l(m)),u=o.length-c.length-o.filter(m=>m.skipped).length,f=o.filter(m=>m.dryRun||!m.skipped&&l(m)).map(XI),h=[];if(h.push(z(p("FETCH_FOOTER_COUNTS__TOTAL_CHANGED_INSYNC_BEHIND_FAILED",{total:o.length,changed:c.length,inSync:u,behind:i.length,failed:a.length}))),i.length){h.push(""),h.push(he(p("FETCH_BEHIND_HEADER")));for(let m of i)h.push(` ${Qe(m.name)} (${m.branch}): ${zr.down} ${m.behind}`)}if(f.length===0){console.log(""),console.log(_e(`\u2500\u2500\u2500 ${p("FETCH_TITLE")} \u2500\u2500\u2500`)),console.log(fe(p("FETCH_ALL_IN_SYNC__N",{n:o.length})));for(let m of h)console.log(m)}else an({title:p("FETCH_TITLE"),rows:f,columns:Tt([{key:"repo",labelKey:"BULK_COL_REPO"},{key:"branch",labelKey:"BULK_COL_BRANCH"},{key:"result",labelKey:"BULK_COL_RESULT"},{key:"sync",labelKey:"BULK_COL_SYNC"},{key:"refs",labelKey:"BULK_COL_NEW_REFS"}]),footerLines:h});a.length&&(process.exitCode=1)}var Ey=A(()=>{"use strict";Tn();Ut();Yr();Bt();ne();try{ZI()}catch(t){console.error(t instanceof Error?t.message:String(t)),process.exit(1)}});var i3={};function wy(t){if(!t.filesChanged&&!t.insertions&&!t.deletions)return z("\u2014");let e=t.filesChanged===1?p("BULK_FILES_ONE"):p("BULK_FILES_MANY");return`${t.filesChanged?`${t.filesChanged} ${e} `:""}${fe("+"+(t.insertions||0))} ${Ce("\u2212"+(t.deletions||0))}`}function t3({name:t,destination:e,dryRun:n,setUpstream:r}){if(!bt({name:t,destination:e}))return{name:t,skipped:!0};let o=qe(e)||p("GST_DETACHED"),i=Ya(e),a=i?i.ahead:0,s=a>0?fb(e):{insertions:0,deletions:0,filesChanged:0},l=["push"];if(r&&l.push("-u","origin","HEAD"),n)return console.log(z(`[dry-run] (in ${e}) git ${l.join(" ")}`)),{name:t,branch:o,dryRun:!0,commitsAhead:a,...s};process.stdout.write(z(` \u2191 ${t} (${o}) ... `));let c=Ci(l,e),u=hb(c.stdout,c.stderr),d=c.status===0&&!u.rejected,f=u.rejected?p("BULK_STATUS_REJECTED"):u.upToDate?p("BULK_STATUS_UP_TO_DATE"):u.pushed?p("BULK_STATUS_PUSHED"):d?p("BULK_STATUS_OK"):p("BULK_STATUS_FAILED");return console.log((d?fe:Ce)(f)),{name:t,branch:o,commitsAhead:a,insertions:s.insertions,deletions:s.deletions,filesChanged:s.filesChanged,status:c.status,pushed:u.pushed,upToDate:u.upToDate,rejected:u.rejected,mrLink:u.mrLink,refs:u.refs,error:c.status!==0&&!u.rejected?(c.stderr.split(`
703
703
  `)[0]||"").slice(0,80):""}}function n3(t){if(t.skipped)return{repo:z(t.name),branch:"",result:z(p("BULK_STATUS_SKIPPED")),commits:"",changes:"",link:""};if(t.dryRun)return{repo:t.name,branch:t.branch,result:z(p("BULK_STATUS_DRY_RUN")),commits:String(t.commitsAhead||0),changes:wy(t),link:""};let e=t.rejected?Ze("fail",p("BULK_STATUS_REJECTED")):t.upToDate?Ze("ok",p("BULK_STATUS_UP_TO_DATE")):t.error?Ze("fail",p("BULK_STATUS_FAILED")):t.pushed?Ze("ok",p("BULK_STATUS_PUSHED")):Ze("ok",p("BULK_STATUS_OK")),n=t.commitsAhead?Qe(String(t.commitsAhead)):z("\u2014"),r=t.mrLink?Qe(t.mrLink):z("\u2014");return{repo:t.name,branch:t.branch,result:e,commits:n,changes:wy(t),link:r}}function r3(){console.log(p("GIT_USAGE_PUSH",{common:ze()}))}function o3(){let t=St(process.argv.slice(2),{defaults:{setUpstream:!1,noWorkspace:!1},handlers:{"--set-upstream":g=>{g.setUpstream=!0},"--no-workspace":g=>{g.noWorkspace=!0}}});if(t.help){r3();return}let{repos:e,workspaceRoot:n}=$e({manifestPath:t.manifest,baseDir:t.baseDir}),r=[];!t.noWorkspace&&at(n)&&r.push({name:"workspace",destination:n}),r.push(...e.map(g=>({name:g.name,destination:g.destination})));let o=r.map(g=>t3({name:g.name,destination:g.destination,dryRun:t.dryRun,setUpstream:!!t.setUpstream})),i=o.filter(g=>g.pushed),a=o.filter(g=>g.rejected),s=o.filter(g=>g.error),l=o.filter(g=>g.upToDate),c=o.filter(g=>g.mrLink),u=o.filter(g=>g.dryRun||g.pushed||g.rejected||g.error||g.mrLink),d=u.map(n3),h=(g=>g.reduce((_,k)=>({commits:_.commits+(k.commitsAhead||0),insertions:_.insertions+(k.insertions||0),deletions:_.deletions+(k.deletions||0)}),{commits:0,insertions:0,deletions:0}))(i.length?i:u.filter(g=>g.dryRun&&g.commitsAhead)),m=[];if(m.push(z(p("PUSH_FOOTER_COUNTS__TOTAL_PUSHED_UPTODATE_REJECTED_FAILED",{total:o.length,pushed:i.length,upToDate:l.length,rejected:a.length,failed:s.length}))),(h.commits>0||h.insertions>0||h.deletions>0)&&m.push(z(p("PUSH_FOOTER_LINES__COMMITS_ADD_DEL",{commits:h.commits,add:h.insertions,del:h.deletions}))),c.length){m.push(""),m.push(_e(p("PUSH_LINKS_HEADER")));for(let g of c)m.push(` ${Qe(g.name)} (${g.branch}): ${g.mrLink}`)}if(a.length){m.push(""),m.push(he(p("PUSH_REJECTED_HEADER")));for(let g of a)m.push(` ${g.name}`)}if(d.length===0){console.log(""),console.log(_e(`\u2500\u2500\u2500 ${p("PUSH_TITLE")} \u2500\u2500\u2500`)),console.log(fe(p("PUSH_ALL_UP_TO_DATE__N",{n:o.length})));for(let g of m)console.log(g)}else an({title:p("PUSH_TITLE"),rows:d,columns:Tt([{key:"repo",labelKey:"BULK_COL_REPO"},{key:"branch",labelKey:"BULK_COL_BRANCH"},{key:"result",labelKey:"BULK_COL_RESULT"},{key:"commits",labelKey:"BULK_COL_COMMITS",align:"r"},{key:"changes",labelKey:"BULK_COL_CHANGES"},{key:"link",labelKey:"BULK_COL_LINK"}]),footerLines:m});(a.length||s.length)&&(process.exitCode=1)}var vy=A(()=>{"use strict";Tn();Ut();Yr();Bt();ne();try{o3()}catch(t){console.error(t instanceof Error?t.message:String(t)),process.exit(1)}});var u3={};function a3(t){let e=new Map;for(let n of t){let r=n.match(/^(\S+)\s+(\S+)\s+\((fetch|push)\)$/);if(!r)continue;let[,o,i,a]=r;if(!o||!i||!a)continue;let s=e.get(o);s||(s={name:o,fetch:"",push:""},e.set(o,s)),a==="fetch"?s.fetch=i:s.push=i}return[...e.values()]}function ky({label:t,destination:e,dryRun:n}){if(n)return console.log(z(`[dry-run] (in ${e}) git remote -v`)),null;let r=qe(e)||p("GST_DETACHED"),o=a3(cb(e));return{name:t,branch:r,remotes:o}}function s3(t){if(t.skipped)return{repo:z(t.name),branch:"",remote:z(p("BULK_STATUS_SKIPPED")),fetch:"",push:""};let e=t.remotes??[],n=e.find(i=>i.name==="origin")||e[0];if(!n)return{repo:t.name,branch:t.branch,remote:z(p("GRV_NO_REMOTES")),fetch:"",push:""};let r=e.length>1?`${n.name} (+${e.length-1})`:n.name,o=n.push===n.fetch?z(p("GRV_PUSH_SAME_AS_FETCH")):n.push;return{repo:t.name,branch:t.branch,remote:r,fetch:n.fetch,push:o}}function l3(){console.log(p("GIT_USAGE_GRV",{common:ze()}))}function c3(){let t=St(process.argv.slice(2),{defaults:{noWorkspace:!1},handlers:{"--no-workspace":l=>{l.noWorkspace=!0}}});if(t.help){l3();return}let{repos:e,workspaceRoot:n}=$e({manifestPath:t.manifest,baseDir:t.baseDir}),r=[];if(!t.noWorkspace&&at(n)){let l=ky({label:"workspace",destination:n,dryRun:t.dryRun});l&&r.push(l)}for(let l of e){if(!bt({name:l.name,destination:l.destination})){r.push({name:l.name,skipped:!0});continue}let c=ky({label:l.name,destination:l.destination,dryRun:t.dryRun});c&&r.push(c)}if(t.dryRun)return;let o=r.filter(l=>!l.skipped&&(l.remotes?.length??0)===0),i=r.filter(l=>l.skipped),a=r.map(s3),s=[];s.push(z(`Total ${r.length} repos \xB7 ${r.length-o.length-i.length} with remotes \xB7 ${o.length} no remote \xB7 ${i.length} skipped`)),an({title:p("GRV_TITLE"),rows:a,columns:Tt([{key:"repo",labelKey:"BULK_COL_REPO"},{key:"branch",labelKey:"BULK_COL_BRANCH"},{key:"remote",labelKey:"GRV_COL_REMOTE"},{key:"fetch",labelKey:"GRV_COL_FETCH"},{key:"push",labelKey:"GRV_COL_PUSH"}]),footerLines:s})}var Sy=A(()=>{"use strict";Tn();Ut();Yr();Bt();ne();try{c3()}catch(t){console.error(t instanceof Error?t.message:String(t)),process.exit(1)}});var m3={};function d3(t){return!t||t===p("GST_DETACHED")?he(t||p("GST_DETACHED")):fe(t)}function Ty({label:t,destination:e,dryRun:n}){if(n)return console.log(z(`[dry-run] (in ${e}) git rev-parse --abbrev-ref HEAD`)),null;let r=qe(e)||p("GST_DETACHED");return{name:t,branch:r}}function f3(t){return t.skipped?{repo:z(t.name),branch:z(p("BULK_STATUS_SKIPPED"))}:{repo:t.name,branch:d3(t.branch)}}function p3(){console.log(p("GIT_USAGE_BRANCH",{common:ze()}))}function h3(){let t=St(process.argv.slice(2),{defaults:{noWorkspace:!1},handlers:{"--no-workspace":s=>{s.noWorkspace=!0}}});if(t.help){p3();return}let{repos:e,workspaceRoot:n}=$e({manifestPath:t.manifest,baseDir:t.baseDir}),r=[];if(!t.noWorkspace&&at(n)){let s=Ty({label:"workspace",destination:n,dryRun:t.dryRun});s&&r.push(s)}for(let s of e){if(!bt({name:s.name,destination:s.destination})){r.push({name:s.name,skipped:!0});continue}let l=Ty({label:s.name,destination:s.destination,dryRun:t.dryRun});l&&r.push(l)}if(t.dryRun)return;let o=r.filter(s=>s.skipped),i=r.map(f3),a=[];a.push(z(p("BRANCH_FOOTER_COUNTS__TOTAL_SKIPPED",{total:r.length,skipped:o.length}))),an({title:p("BRANCH_TITLE"),rows:i,columns:Tt([{key:"repo",labelKey:"BULK_COL_REPO"},{key:"branch",labelKey:"BULK_COL_BRANCH"}]),footerLines:a})}var Ay=A(()=>{"use strict";Tn();Ut();Yr();Bt();ne();try{h3()}catch(t){console.error(t instanceof Error?t.message:String(t)),process.exit(1)}});function g3(t){let e=Oe(["rev-parse","--abbrev-ref","@{u}"],{cwd:t});if(e.status!==0||!e.stdout)return{hasUpstream:!1,ahead:0,behind:0};let n=Oe(["rev-list","--left-right","--count","HEAD...@{u}"],{cwd:t});if(n.status!==0)return{hasUpstream:!0,ahead:0,behind:0};let[r=0,o=0]=n.stdout.split(/\s+/).map(i=>parseInt(i,10)||0);return{hasUpstream:!0,ahead:r,behind:o}}function Cy(t){let e=qe(t),n=Oe(["status","--porcelain"],{cwd:t});if(n.status!==0)return{branch:e,error:n.stderr||"git status failed",total:0,staged:0,unstaged:0,untracked:0,ahead:0,behind:0,hasUpstream:!1,inProgress:""};let r=n.stdout.split(/\r?\n/).map(u=>u.trimEnd()).filter(Boolean),o=0,i=0,a=0;for(let u of r){let d=u[0],f=u[1];if(d==="?"&&f==="?"){a+=1;continue}d!==" "&&(o+=1),f!==" "&&(i+=1)}let{hasUpstream:s,ahead:l,behind:c}=g3(t);return{branch:e,total:r.length,staged:o,unstaged:i,untracked:a,ahead:l,behind:c,hasUpstream:s,inProgress:Yl(t)}}function _3({staged:t,unstaged:e,untracked:n}){let r=[];return t>0&&r.push(p("BULK_BREAKDOWN_STAGED__N",{n:t})),e>0&&r.push(p("BULK_BREAKDOWN_UNSTAGED__N",{n:e})),n>0&&r.push(p("BULK_BREAKDOWN_UNTRACKED__N",{n})),r.join(" \xB7 ")}function b3(t){if(t.error)return Ce(p("BULK_STATUS_ERROR"));if(!t.hasUpstream)return z(p("BULK_STATUS_NO_UPSTREAM"));if(t.behind===0&&t.ahead===0)return fe(p("BULK_STATUS_IN_SYNC"));let e=[];return t.behind&&e.push(he(`${Uc.down} ${t.behind}`)),t.ahead&&e.push(Qe(`${Uc.up} ${t.ahead}`)),e.join(" ")}function x3(t){if(t.inProgress==="merge")return Ce(p("BULK_STATUS_MERGING"));if(t.inProgress==="rebase")return Ce(p("BULK_STATUS_REBASING"));if(t.error)return Ce(p("BULK_STATUS_ERROR"));if(t.total===0)return fe(p("BULK_STATUS_CLEAN"));let e=t.total===1?p("BULK_FILES_ONE"):p("BULK_FILES_MANY");return he(`${t.total} ${e}`)}function Ry({results:t,totalRepos:e}){let n=t.filter(l=>l.total>0||l.inProgress),r=t.filter(l=>l.error),i=t.filter(l=>l.total>0||l.inProgress||l.error).map(l=>({repo:l.error?Ce(l.name):Qe(l.name),branch:l.branch||z(p("GST_DETACHED")),state:x3(l),breakdown:l.total>0?z(_3(l)):z("\u2014"),sync:b3(l)})),a=n.reduce((l,c)=>l+c.total,0),s=e-n.length-r.length;if(console.log(""),console.log(_e(`\u2500\u2500\u2500 ${p("GST_TITLE")} \u2500\u2500\u2500`)),console.log(z(`${Uc.info} ${p("GST_FOOTER_COUNTS__TOTAL_DIRTY_FILES_CLEAN_ERRORS",{total:e,dirty:n.length,files:a,clean:s,errors:r.length})}`)),i.length>0?console.log(R0(Tt([{key:"repo",labelKey:"BULK_COL_REPO"},{key:"branch",labelKey:"BULK_COL_BRANCH"},{key:"state",labelKey:"BULK_COL_STATE"},{key:"breakdown",labelKey:"BULK_COL_BREAKDOWN"},{key:"sync",labelKey:"BULK_COL_SYNC"}]),i)):(console.log(""),console.log(fe(p("GST_ALL_CLEAN__N",{n:e})))),r.length>0){console.log(""),console.log(_e(he(`${Uc.warn} ${p("GST_ERRORS_HEADER")}`)));for(let l of r)console.log(` \u2022 ${l.name}: ${l.error}`)}}var Uc,Ny=A(()=>{"use strict";Bt();Ut();ne();Yr();Uc={ok:"\u2705",warn:"\u26A0\uFE0F",info:"\u2139\uFE0F",skip:"\u23ED\uFE0F",up:"\u2191",down:"\u2193"}});var v3={};function Iy({label:t,destination:e,dryRun:n,gitArgs:r}){let o=r.length>0?r.join(" "):"";if(n){console.log(p("GST_DRY_RUN_STATUS__DIR_ARGS",{dir:e,args:o}).trim());return}console.log(p("GST_SECTION__LABEL",{label:t})),console.log(e),ub(e,r),console.log("")}function Ly({name:t,destination:e,dryRun:n}){if(n)return{name:t,destination:e,branch:"",total:0,staged:0,unstaged:0,untracked:0,ahead:0,behind:0,hasUpstream:!1,inProgress:"",dryRun:!0};let r=Cy(e);return{name:t,destination:e,...r}}function y3({totalRepos:t,includeWorkspace:e,repoCount:n}){console.log(""),console.log("[dry-run] gst summary"),console.log(`[dry-run] would scan ${t} repo(s)`+(e?" (workspace + manifest)":" (manifest only)")),console.log(p("GST_DRY_RUN_COUNT__N",{n}))}function E3(){console.log(p("GIT_USAGE_GST",{common:ze()}))}function w3(){let t=St(process.argv.slice(2),{defaults:{noWorkspace:!1,verbose:!1,gitArgs:[]},passthrough:!0,handlers:{"--no-workspace":a=>{a.noWorkspace=!0},"--verbose":a=>{a.verbose=!0}}});if(t.help){E3();return}let e=t.gitArgs||[],n=t.verbose||e.length>0,{repos:r,workspaceRoot:o}=$e({manifestPath:t.manifest,baseDir:t.baseDir});if(n){!t.noWorkspace&&at(o)&&Iy({label:"workspace",destination:o,dryRun:t.dryRun,gitArgs:e});for(let a of r)bt({name:a.name,destination:a.destination})&&Iy({label:a.name,destination:a.destination,dryRun:t.dryRun,gitArgs:e});return}let i=[];!t.noWorkspace&&at(o)&&i.push(Ly({name:"workspace",destination:o,dryRun:t.dryRun}));for(let a of r)bt({name:a.name,destination:a.destination})&&i.push(Ly({name:a.name,destination:a.destination,dryRun:t.dryRun}));if(t.dryRun){y3({totalRepos:i.length,includeWorkspace:!t.noWorkspace&&at(o),repoCount:r.length});return}Ry({title:"gst summary",results:i,totalRepos:i.length})}var Oy=A(()=>{"use strict";Tn();Ut();Ny();ne();try{w3()}catch(t){console.error(t instanceof Error?t.message:String(t)),process.exit(1)}});async function Dy(){return jp===null&&(jp=Promise.resolve().then(()=>(mn(),hn)).catch(()=>null)),jp}function $c(t){if(!t)return!1;let e=t,n=String(e.name||"");return n==="ExitPromptError"||n==="CancelPromptError"||/User force closed/i.test(String(e.message||""))}function Py({repos:t,workspaceRoot:e,includeWorkspace:n}){let r=[];n&&at(e)&&r.push({name:"workspace",destination:e,label:"workspace (stack root)"});for(let o of t)r.push({name:o.name,destination:o.destination,label:o.name});return r}function k3(t,e){let n=String(e||"").trim();return n?t.filter(r=>r.name===n):[]}function My(t){return String(t||"").split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function S3(t,e){let n=new Set,r=[],o=[];for(let i of e){let a=String(i||"").trim();if(!a)continue;let s=t.find(l=>l.name===a);if(!s){o.push(a);continue}n.has(s.name)||(n.add(s.name),r.push(s))}return{picked:r,missing:o}}function T3(t,e){return new Promise((n,r)=>{let o=$p.default.createInterface({input:process.stdin,output:process.stdout});console.log(""),console.log(e),console.log(` 1. ${p("REPO_SELECT_ALL__N",{n:t.length})}`),t.forEach((i,a)=>{console.log(` ${a+2}. ${i.label}`),console.log(` ${i.destination}`)}),console.log(""),o.question(p("REPO_SELECT_SINGLE_PROMPT"),i=>{o.close();let a=Number.parseInt(String(i).trim(),10);if(!Number.isFinite(a)||a<1||a>t.length+1){r(new Error(p("REPO_SELECT_INVALID")));return}if(a===1){n(t);return}let s=t[a-2];n(s?[s]:[])})})}async function A3(t,{message:e}={}){let n=e||p("REPO_SELECT_PROMPT_MSG"),r=[{name:p("REPO_SELECT_ALL__N",{n:t.length}),value:Bp,short:"all"},...t.map(a=>({name:`${a.label} ${Up(a.destination)}`,value:a,short:a.name}))],o=[{key:"x",label:p("EXIT_LABEL"),value:"__exit__"}];try{let a=await Pe({message:n,choices:r,pageSize:Math.min(Math.max(t.length+2,8),20),hotkeys:o});return a==="__exit__"&&(console.log(p("EXITED")),process.exit(0)),a===Bp?t.slice():[a]}catch(a){if(String(a?.message)!=="no-core")throw $c(a)?new Error(p("REPO_SELECT_CANCELLED")):a}let i=await Dy();if(!i||typeof i.select!="function")return T3(t,n);try{let a=await i.select({message:n,choices:[...r,new i.Separator,{name:`x ${p("EXIT_LABEL")}`,value:"__exit__",short:"x"}],pageSize:Math.min(Math.max(t.length+2,8),20),loop:!1,theme:ft(!1)});return a==="__exit__"&&(console.log(p("EXITED")),process.exit(0)),a===Bp?t.slice():[a]}catch(a){throw $c(a)?new Error(p("REPO_SELECT_CANCELLED")):a}}async function jy({repos:t,workspaceRoot:e,includeWorkspace:n,selection:r,message:o}){let i=Py({repos:t,workspaceRoot:e,includeWorkspace:n});if(i.length===0)throw new Error(p("REPO_SELECT_NO_REPO_SYNC"));let a=String(r||"").trim();if(a==="all")return i;if(a){let s=k3(i,a);if(s.length===0){let l=i.map(c=>c.name).join(", ");throw new Error(p("REPO_SELECT_ONE_MISSING__PICKED_ALL",{picked:a,all:l}))}return s}return process.stdin.isTTY?A3(i,{message:o||p("REPO_SELECT_SYNCMAIN_MSG")}):i}function By(t,e){let n=new Set,r=[];for(let o of e){let i=Number.parseInt(String(o).trim(),10);if(!Number.isFinite(i)||i<1||i>t.length+1){let l=new Error(p("REPO_SELECT_INVALID_INDEX__RAW",{raw:String(o)}));throw l.code="INVALID_CHOICE",l}if(i===1)return t.slice();let a=i-2;if(n.has(a))continue;n.add(a);let s=t[a];s&&r.push(s)}return r}function C3(t,{action:e}={}){let n=e||p("REPO_SELECT_ACTION_CHOOSE");return new Promise((r,o)=>{let i=$p.default.createInterface({input:process.stdin,output:process.stdout});console.log(""),console.log(p("REPO_SELECT_MULTI_HELP__ACTION",{action:n})),console.log(` 1. ${p("REPO_SELECT_ALL__N",{n:t.length})}`),t.forEach((a,s)=>{console.log(` ${s+2}. ${a.label}`),console.log(` ${a.destination}`)}),console.log(""),i.question(p("REPO_SELECT_MULTI_PROMPT"),a=>{i.close();let s=String(a||"").trim();if(!s){o(new Error(p("REPO_SELECT_EMPTY_ANSWER")));return}if(s.toLowerCase()==="all"){r(t.slice());return}let l=My(s);if(l.length===0){o(new Error(p("REPO_SELECT_INVALID")));return}try{let c=By(t,l);if(c.length===0){o(new Error(p("REPO_SELECT_NONE_PICKED")));return}r(c)}catch(c){o(c)}})})}async function R3(t,{action:e}={}){let n=e||p("REPO_SELECT_ACTION_CHOOSE"),r=t.map((a,s)=>({name:`${a.label} ${Up(a.destination)}`,value:s,short:a.name})),o=[{key:"x",label:p("EXIT_LABEL"),value:"exit"}];try{let a=await cn({message:n,choices:r,hotkeys:o,pageSize:Math.min(Math.max(t.length+2,8),20)});a.action==="exit"&&(console.log(p("EXITED")),process.exit(0));let s=a.values||[];if(s.length===0)throw new Error(p("REPO_SELECT_NONE_PICKED"));return s.flatMap(l=>{let c=t[l];return c?[c]:[]})}catch(a){if(String(a?.message)!=="no-core")throw $c(a)?new Error(p("REPO_SELECT_CANCELLED")):a}let i=await Dy();if(!i||typeof i.checkbox!="function")return C3(t,{action:n});try{let a=await i.checkbox({message:n,choices:t.map(s=>({name:`${s.label} ${Up(s.destination)}`,value:s,short:s.name})),required:!0,pageSize:Math.min(Math.max(t.length+2,8),20),theme:ft(!0)});if(!Array.isArray(a)||a.length===0)throw new Error(p("REPO_SELECT_NONE_PICKED"));return a}catch(a){throw $c(a)?new Error(p("REPO_SELECT_CANCELLED")):a}}function Up(t){return!process.stdout.isTTY||process.env.NO_COLOR?`\u2014 ${t}`:`\x1B[2m\u2014 ${t}\x1B[0m`}async function Fc({repos:t,workspaceRoot:e,includeWorkspace:n,selection:r,action:o}){let i=o||p("REPO_SELECT_ACTION_DEFAULT"),a=Py({repos:t,workspaceRoot:e,includeWorkspace:n});if(a.length===0)throw new Error(p("REPO_SELECT_NO_REPO"));let s=String(r||"").trim();if(s.toLowerCase()==="all")return a.slice();if(s){let l=My(s);if(l.length>0&&l.every(f=>/^[0-9]+$/.test(f))){let f=By(a,l);if(f.length===0)throw new Error(p("REPO_SELECT_NONE_PICKED"));return f}let{picked:u,missing:d}=S3(a,l);if(d.length>0){let f=a.map(h=>h.name).join(", ");throw new Error(p("REPO_SELECT_MISSING__MISSING_ALL",{missing:d.join(", "),all:f}))}if(u.length===0)throw new Error(p("REPO_SELECT_NONE_PICKED"));return u}if(process.stdin.isTTY)return R3(a,{action:i});throw new Error(p("REPO_SELECT_NEED_NON_INTERACTIVE"))}var $p,jp,Bp,Gc=A(()=>{"use strict";$p=L(require("readline"));Ut();Mo();ne();Rt();jp=null;Bp="__all__"});var P3={};function N3(){console.log(p("GIT_USAGE_SYNC_MAIN",{common:ze()}))}function I3(t){let e={help:!1,manifest:"",baseDir:".",dryRun:!1,ref:"origin/main",rebase:!1,noWorkspace:!1,selection:""};for(let n=0;n<t.length;n+=1){let r=t[n];if(r!==void 0)if(r==="-h"||r==="--help")e.help=!0;else if(r==="--base-dir")e.baseDir=t[++n]||".";else if(r==="--dry-run")e.dryRun=!0;else if(r==="--ref")e.ref=t[++n]||"origin/main";else if(r==="--rebase")e.rebase=!0;else if(r==="--no-workspace")e.noWorkspace=!0;else{if(r.startsWith("-"))throw new Error(`Unexpected argument: ${r}`);if(Io(r)&&!e.manifest)e.manifest=r;else if(!e.selection)e.selection=r;else throw new Error(`Unexpected argument: ${r}`)}}return e}function Uy({name:t,branch:e,ref:n,files:r,mode:o}){let i=_e(Ce(`${Gt.conflict} [conflict] ${t} (${e})`)),a=he(p("SYNCMAIN_CONFLICT_SHORT__MODE_REF_N",{mode:o,ref:n,n:r.length}));console.log(`${i} \u2014 ${a}`);for(let s of r.slice(0,8))console.log(z(` \u2022 ${s}`));r.length>8&&console.log(z(` ${p("SYNCMAIN_MORE_FILES__N",{n:r.length-8})}`))}function L3({name:t,destination:e,dryRun:n,ref:r,rebase:o}){let i={name:t,destination:e,branch:"",status:"skipped",message:"",conflictFiles:[],mode:o?"rebase":"merge"};if(!bt({name:t,destination:e}))return i.message=p("SYNCMAIN_MSG_NOT_CLONED"),i;let a=qe(e);if(i.branch=a||p("SYNCMAIN_DETACHED_LABEL"),!a)return i.message=p("SYNCMAIN_MSG_DETACHED"),console.log(`${Gt.skip} [skip] ${t}: ${i.message}`),i;let s=Yl(e);if(s){let h=Ai(e);return i.status="conflict",i.conflictFiles=h,i.message=p("SYNCMAIN_MSG_IN_PROGRESS__MODE",{mode:s}),Uy({name:t,branch:a,ref:r,files:h,mode:s}),i}let l=Vl(e);if(l>0&&console.log(`${Gt.warn} ${he(p("SYNCMAIN_MSG_DIRTY__NAME_N",{name:t,n:l}))}`),n)return console.log(`[dry-run] (in ${e}) git fetch origin && git ${o?"rebase":"merge"} ${r}`),i.status="dry-run",i.message="dry-run",i;console.log(`[fetch] ${t}: ${e}`);let c=Oe(["fetch","origin"],{cwd:e});if(c.status!==0)return i.status="error",i.message=c.stderr||p("SYNCMAIN_MSG_FETCH_FAILED"),console.log(`${Gt.warn} ${he(`[warn] ${t}: ${i.message}`)}`),i;if(!Gn(e,r))return i.status="error",i.message=p("SYNCMAIN_MSG_REF_MISSING__REF",{ref:r}),console.log(`${Gt.warn} ${he(`[warn] ${t}: ${i.message}`)}`),i;let u=o?["rebase",r]:["merge","--no-edit",r];console.log(`[${i.mode}] ${t} (${a}) \u2190 ${r}`);let d=lb(u,{cwd:e,dryRun:!1,action:i.mode,name:t}),f=Ai(e);return f.length>0||d!==0?(i.status="conflict",i.conflictFiles=f.length>0?f:[p("SYNCMAIN_MSG_SEE_STATUS")],i.message=p("SYNCMAIN_MSG_CONFLICT__MODE",{mode:i.mode}),Uy({name:t,branch:a,ref:r,files:i.conflictFiles,mode:i.mode}),i):(i.status="ok",i.message=p("SYNCMAIN_MSG_UPDATED"),console.log(`${Gt.ok} ${fe(p("SYNCMAIN_MSG_SYNCED__NAME_BRANCH_REF",{name:t,branch:a,ref:r}))}`),i)}function O3(t,{ref:e,rebase:n}){let r=t.filter(s=>s.status==="ok"),o=t.filter(s=>s.status==="conflict"),i=t.filter(s=>s.status==="error"),a=t.filter(s=>s.status==="skipped"||s.status==="dry-run");if(console.log(""),console.log(_e(p("SYNCMAIN_HEADER"))),console.log(`${Gt.info} ${p("SYNCMAIN_INFO__REF_MODE_REPOS",{ref:e,mode:n?"rebase":"merge",repos:t.length})}`),console.log(p("SYNCMAIN_COUNTS__OK_CONFLICT_ERR_SKIP",{ok:r.length,conflict:o.length,err:i.length,skip:a.length})),o.length>0){console.log(""),console.log(_e(Ce(`${Gt.conflict} ${p("SYNCMAIN_CONFLICT_HEADER")}`)));for(let s of o){console.log(he(`
@@ -962,7 +962,7 @@ init();
962
962
  `).trim()),m.push("```"),m.push("")}}return m.push("---"),m.push(""),m.push(p("STATS_REVIEW_MD_AI_H2")),m.push(""),m.push(p("STATS_REVIEW_MD_AI_INTRO")),m.push(""),m.push(p("STATS_REVIEW_MD_AI_CRITERIA")),m.push(""),m.push(p("STATS_REVIEW_MD_AI_OUTRO")),m.join(`
963
963
  `)}function ME(t){try{return(0,BE.execFileSync)("git",t,{encoding:"utf8",maxBuffer:512*1024*1024})}catch(e){let n=e instanceof Error?e.message:String(e);throw new Error(p("STATS_GIT_ERROR__MSG",{msg:n.split(`
964
964
  `)[0]??""}))}}function I4(t){let e=[],n=null;for(let r of t.split(`
965
- `)){if(r.includes("")){n&&e.push(n);let[i,a,s,l,c]=r.split("");n={hash:i??"",date:a??"",name:s??"",email:l??"",subject:c||"",additions:0,deletions:0};continue}let o=r.match(/(\d+) insertion[s]?\(\+\)|(\d+) deletion[s]?\(-\)/g);if(o&&n)for(let i of o){let a=i.match(/(\d+) insertion/),s=i.match(/(\d+) deletion/);a?.[1]&&(n.additions+=parseInt(a[1],10)),s?.[1]&&(n.deletions+=parseInt(s[1],10))}}return n&&e.push(n),e}function L4(t){return String(t||"").replace(/\|/g,"\\|")}function $E(t,e){return ah.default.mkdirSync(jE.default.dirname(t),{recursive:!0}),ah.default.writeFileSync(t,e),t}var ah,jE,BE,FE=A(()=>{"use strict";ah=L(require("fs")),jE=L(require("path")),BE=require("child_process");Yc();ne()});var lh={};be(lh,{runStats:()=>P4});function O4(t){let e={_:[],open:!0,diff:!0};for(let n=0;n<t.length;n++){let r=t[n];r!==void 0&&(r==="--since"?e.since=t[++n]:r==="--from"?e.from=t[++n]:r==="--to"?e.to=t[++n]:r==="--member"||r==="-m"?e.member=t[++n]:r==="--project"||r==="-p"?e.project=t[++n]:r==="--port"?e.port=parseInt(t[++n]??"",10):r==="--out"||r==="-o"?e.out=t[++n]:r==="--no-open"?e.open=!1:r==="--no-diff"?e.diff=!1:r==="--head-only"?e.headOnly=!0:r==="--max-diff-lines"?e.maxDiffLines=parseInt(t[++n]??"",10):r.startsWith("--since=")?e.since=r.slice(8):e._.push(r))}return e}function qc(){let t=Hi.default.join(GE.default.homedir(),".pan-code-graph");return Jc.default.mkdirSync(t,{recursive:!0}),t}function sh(){let t=ki();if(t)return{repos:EE(t),source:`.project.yaml (${t.project})`};let e=vi(process.cwd());if(!e.length)throw new Error(p("STATS_NO_REPOS__CWD",{cwd:process.cwd()}));return console.log(p("STATS_FALLBACK_SCAN__CWD",{cwd:process.cwd()})),{repos:e,source:p("STATS_SOURCE_FALLBACK")}}function D4(){console.log(p("STATS_USAGE"))}async function P4(t){let e=O4(t),n=e._[0],r=n!==void 0&&["report","people","review"].includes(n)?e._.shift():"report";return e._[0]==="help"||e.help?D4():r==="review"?U4(e):r==="people"?B4(e):j4(e)}function M4(t){let{repos:e}=sh(),n=hs(t),r=!t.headOnly,o=r?p("STATS_SCOPE_ALL_BRANCHES"):p("STATS_SCOPE_HEAD_ONLY");console.log(p("STATS_SCAN_RANGE__N_SCOPE_LABEL",{n:e.length,scope:o,label:n.label}));let{commits:i,repoStatus:a}=nh(e,n,{allBranches:r}),s=rh(Hi.default.join(qc(),"alias-map.json"));return{repos:e,range:n,commits:i,repoStatus:a,aliasMap:s}}function j4(t){let{repos:e}=sh(),n=hs({}),r=!t.headOnly,o=r?p("STATS_SCOPE_ALL_BRANCHES"):p("STATS_SCOPE_HEAD_ONLY");console.log(p("STATS_SCAN_FULL__N_SCOPE",{n:e.length,scope:o}));let{commits:i,repoStatus:a}=nh(e,n,{allBranches:r}),s=rh(Hi.default.join(qc(),"alias-map.json")),l=i.map(h=>({e:Vc(h.email,s),n:h.name||h.email,t:h.ts,r:h.repoName,a:h.additions,d:h.deletions})),c=a.filter(h=>!h.available).map(h=>({name:h.name,reason:h.reason}));hs(t);let u={reposTotal:a.length,reposAvailable:a.filter(h=>h.available).length,unavailable:c,initialSince:t.since!=null?Number(t.since):null,initialFrom:t.from||null,initialTo:t.to||null,initialMembers:t.member?[t.member]:[]},d=NE(l,u),f=t.out||Hi.default.join(qc(),"report.html");Jc.default.writeFileSync(f,d),console.log(p("STATS_WROTE_REPORT__PATH_N",{path:f,n:l.length})),c.length&&console.log(p("STATS_UNAVAILABLE__N",{n:c.length})),DE(d,{port:t.port||4321,open:t.open})}function B4(t){let{commits:e,aliasMap:n}=M4(t),{members:r}=kE(e,n);console.log(p("STATS_PEOPLE_HEADER__N",{n:r.length}));for(let o of r)console.log(p("STATS_PEOPLE_ROW__N_NAME_EMAIL",{n:String(o.commits).padStart(5),name:o.name,email:o.email}))}function U4(t){if(!t.member||!t.project)throw new Error(p("STATS_REVIEW_NEED_FLAGS"));let{repos:e}=sh(),n=e.find(s=>s.name===t.project);if(!n)throw new Error(p("STATS_REVIEW_NO_PROJECT__PROJECT_NAMES",{project:t.project,names:e.map(s=>s.name).join(", ")}));if(!Jc.default.existsSync(n.dir))throw new Error(p("STATS_REVIEW_NOT_CLONED__PROJECT_DIR",{project:t.project,dir:n.dir}));let r=hs(t);console.log(p("STATS_REVIEW_BUILDING__MEMBER_PROJECT_LABEL",{member:t.member,project:t.project,label:r.label}));let o=UE(n,t.member,r,{withDiff:t.diff,maxDiffLines:t.maxDiffLines,allBranches:!t.headOnly}),i=`${t.project}_${t.member.replace(/[^a-z0-9]+/gi,"-")}`.toLowerCase(),a=t.out||Hi.default.join(qc(),`review-${i}.md`);$E(a,o),console.log(p("STATS_REVIEW_WROTE__PATH",{path:a})),console.log(p("STATS_REVIEW_HINT"))}var Jc,Hi,GE,ch=A(()=>{"use strict";Jc=L(require("fs")),Hi=L(require("path")),GE=L(require("os"));nn();wE();Yc();oh();SE();IE();PE();FE();ne()});var HE=U((fG,$4)=>{$4.exports={name:"pan-stack-cli",version:"0.3.2",description:"PAN Stack CLI \u2014 multi-repo git and project commands from .project.yaml",license:"MIT",bin:{pan:"bin/pan.js"},files:["bin"],scripts:{build:"node tools/pan-stack-cli/build.mjs",prepare:"node tools/pan-stack-cli/build.mjs",prepublishOnly:"node tools/pan-stack-cli/build.mjs",test:'tsc --noEmit && tsc -p tsconfig.test.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.web.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.e2e.json --noEmit && node --test "tools/pan-stack-plan/test/*.test.ts" "tools/pan-stack-cli/test/*.test.ts" && node --test tools/pan-cicd/test/',"test:pan-cicd":"node tools/pan-stack-cli/build.mjs && node --test tools/pan-cicd/test/","test:pan-stack-plan":'node --test "tools/pan-stack-plan/test/*.test.ts"',"test:pan-stack-cli":'node --test "tools/pan-stack-cli/test/*.test.ts"',typecheck:"tsc --noEmit && tsc -p tsconfig.test.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.web.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.e2e.json --noEmit","build:web":"node tools/pan-stack-plan/build-web.mjs",pretest:"node tools/pan-stack-plan/build-web.mjs","test:e2e":"playwright test -c tools/pan-stack-plan/playwright.config.ts"},engines:{node:">=18"},dependencies:{"@inquirer/core":"^11.2.1","@inquirer/prompts":"^8.5.2",serve:"^14.2.4"},keywords:["pan-stack","monorepo","git","cli"],repository:{type:"git",url:"https://github.com/doiya46/pan-stack.git",directory:".pan/pan-stack-cli"},devDependencies:{"@inquirer/testing":"^3.3.9","@playwright/test":"1.62.1","@radix-ui/react-dialog":"^1.1.23","@radix-ui/react-popover":"1.1.23","@radix-ui/react-separator":"^1.1.15","@radix-ui/react-slot":"^1.3.3","@radix-ui/react-switch":"^1.3.7","@radix-ui/react-tabs":"^1.1.21","@radix-ui/react-tooltip":"^1.2.16","@tailwindcss/cli":"4.3.3","@tailwindcss/typography":"0.5.20","@types/node":"22.18.8","@types/react":"^19.2.18","@types/react-dom":"^19.2.5","@types/sanitize-html":"2.16.0","class-variance-authority":"0.7.1",clsx:"2.1.1",cmdk:"1.1.1","csv-parse":"7.0.1","csv-stringify":"6.8.1",esbuild:"0.28.1",marked:"15.0.12",react:"19.2.8","react-dom":"19.2.8","react-markdown":"10.1.0","remark-gfm":"4.0.1","sanitize-html":"2.16.0","tailwind-merge":"3.6.0",tailwindcss:"4.3.3",typescript:"5.9.3"},optionalDependencies:{"@pan-stack/powerpoint":"^0.1.0"}}});var KE={};be(KE,{runInteractiveMenu:()=>G4});function F4(t){let e=t,n=String(e&&`${String(e.name)} ${String(e.message)}`||"");return/ExitPromptError|force closed|SIGINT|cancel/i.test(n)}async function uh({message:t,choices:e,hotkeys:n=[]}){try{return await Pe({message:t,choices:e,hotkeys:n})}catch(r){if(String(r?.message)!=="no-core")throw r;let o=await Cn();if(!o||typeof o.select!="function")return"__exit__";let i=n.map(s=>({name:`${s.key} ${s.label}`,value:s.value})),a=i.length?[...e,new o.Separator,...i]:e;return o.select({message:t,choices:a,pageSize:20,loop:!1,theme:ft(!1)})}}async function G4({printUsage:t,version:e}={}){let n=await lc(),r=await Cn();if(!n&&(!r||typeof r.select!="function"))return!1;let o=Hl().filter(i=>Wa(i).length>0).sort((i,a)=>br(i).localeCompare(br(a)));if(o.length===0)return console.log(p("NO_PAN_YAML_WITH_COMMANDS")),console.log(p("NO_PAN_YAML_BUT_GIT_STILL_WORKS")),!1;try{for(;;){let i=await uh({message:p("MENU_SELECT_PROJECT"),choices:o.map((f,h)=>({name:br(f),value:h,description:`${Wa(f).length} ${p("COMMANDS_LABEL")} \xB7 ${f.root}`})),hotkeys:[{key:"h",label:p("HELP_LABEL"),value:"__help__"},{key:"v",label:p("VERSION_LABEL"),value:"__version__"},{key:"x",label:p("EXIT_LABEL"),value:"__exit__"}]});if(i==="__exit__")return!0;if(i==="__version__"){console.log(`pan-stack-cli ${e||"?"}`);continue}if(i==="__help__"){typeof t=="function"&&t();continue}let a=typeof i=="number"?o[i]:void 0;if(!a)continue;let s=Wa(a),l=await uh({message:`[${br(a)}] ${p("MENU_SELECT_COMMAND")}`,choices:s.map(f=>({name:f.name+(f.aliases&&f.aliases.length?` (${f.aliases.join(", ")})`:"")+(f.hasTargets?` [${f.targets.join("|")}]`:""),value:f.name,description:f.description||""})),hotkeys:[{key:"b",label:p("BACK_LABEL"),value:"__back__"},{key:"x",label:p("EXIT_LABEL"),value:"__exit__"}]});if(l==="__exit__")return!0;if(l==="__back__")continue;let c=a.commands[String(l)],u=[];if(c&&c.targets&&Object.keys(c.targets).length>0){let f=Object.keys(c.targets),h=await uh({message:p("SELECT_TARGET__CMD",{cmd:l}),choices:[...f.map(m=>({name:m,value:m})),{name:p("DEFAULT_LABEL"),value:"__default__"}],hotkeys:[{key:"b",label:p("BACK_LABEL"),value:"__back__"}]});if(h==="__back__")continue;h!=="__default__"&&u.push(String(h))}console.error(`
965
+ `)){if(r.includes("")){n&&e.push(n);let[i,a,s,l,c]=r.split("");n={hash:i??"",date:a??"",name:s??"",email:l??"",subject:c||"",additions:0,deletions:0};continue}let o=r.match(/(\d+) insertion[s]?\(\+\)|(\d+) deletion[s]?\(-\)/g);if(o&&n)for(let i of o){let a=i.match(/(\d+) insertion/),s=i.match(/(\d+) deletion/);a?.[1]&&(n.additions+=parseInt(a[1],10)),s?.[1]&&(n.deletions+=parseInt(s[1],10))}}return n&&e.push(n),e}function L4(t){return String(t||"").replace(/\|/g,"\\|")}function $E(t,e){return ah.default.mkdirSync(jE.default.dirname(t),{recursive:!0}),ah.default.writeFileSync(t,e),t}var ah,jE,BE,FE=A(()=>{"use strict";ah=L(require("fs")),jE=L(require("path")),BE=require("child_process");Yc();ne()});var lh={};be(lh,{runStats:()=>P4});function O4(t){let e={_:[],open:!0,diff:!0};for(let n=0;n<t.length;n++){let r=t[n];r!==void 0&&(r==="--since"?e.since=t[++n]:r==="--from"?e.from=t[++n]:r==="--to"?e.to=t[++n]:r==="--member"||r==="-m"?e.member=t[++n]:r==="--project"||r==="-p"?e.project=t[++n]:r==="--port"?e.port=parseInt(t[++n]??"",10):r==="--out"||r==="-o"?e.out=t[++n]:r==="--no-open"?e.open=!1:r==="--no-diff"?e.diff=!1:r==="--head-only"?e.headOnly=!0:r==="--max-diff-lines"?e.maxDiffLines=parseInt(t[++n]??"",10):r.startsWith("--since=")?e.since=r.slice(8):e._.push(r))}return e}function qc(){let t=Hi.default.join(GE.default.homedir(),".pan-code-graph");return Jc.default.mkdirSync(t,{recursive:!0}),t}function sh(){let t=ki();if(t)return{repos:EE(t),source:`.project.yaml (${t.project})`};let e=vi(process.cwd());if(!e.length)throw new Error(p("STATS_NO_REPOS__CWD",{cwd:process.cwd()}));return console.log(p("STATS_FALLBACK_SCAN__CWD",{cwd:process.cwd()})),{repos:e,source:p("STATS_SOURCE_FALLBACK")}}function D4(){console.log(p("STATS_USAGE"))}async function P4(t){let e=O4(t),n=e._[0],r=n!==void 0&&["report","people","review"].includes(n)?e._.shift():"report";return e._[0]==="help"||e.help?D4():r==="review"?U4(e):r==="people"?B4(e):j4(e)}function M4(t){let{repos:e}=sh(),n=hs(t),r=!t.headOnly,o=r?p("STATS_SCOPE_ALL_BRANCHES"):p("STATS_SCOPE_HEAD_ONLY");console.log(p("STATS_SCAN_RANGE__N_SCOPE_LABEL",{n:e.length,scope:o,label:n.label}));let{commits:i,repoStatus:a}=nh(e,n,{allBranches:r}),s=rh(Hi.default.join(qc(),"alias-map.json"));return{repos:e,range:n,commits:i,repoStatus:a,aliasMap:s}}function j4(t){let{repos:e}=sh(),n=hs({}),r=!t.headOnly,o=r?p("STATS_SCOPE_ALL_BRANCHES"):p("STATS_SCOPE_HEAD_ONLY");console.log(p("STATS_SCAN_FULL__N_SCOPE",{n:e.length,scope:o}));let{commits:i,repoStatus:a}=nh(e,n,{allBranches:r}),s=rh(Hi.default.join(qc(),"alias-map.json")),l=i.map(h=>({e:Vc(h.email,s),n:h.name||h.email,t:h.ts,r:h.repoName,a:h.additions,d:h.deletions})),c=a.filter(h=>!h.available).map(h=>({name:h.name,reason:h.reason}));hs(t);let u={reposTotal:a.length,reposAvailable:a.filter(h=>h.available).length,unavailable:c,initialSince:t.since!=null?Number(t.since):null,initialFrom:t.from||null,initialTo:t.to||null,initialMembers:t.member?[t.member]:[]},d=NE(l,u),f=t.out||Hi.default.join(qc(),"report.html");Jc.default.writeFileSync(f,d),console.log(p("STATS_WROTE_REPORT__PATH_N",{path:f,n:l.length})),c.length&&console.log(p("STATS_UNAVAILABLE__N",{n:c.length})),DE(d,{port:t.port||4321,open:t.open})}function B4(t){let{commits:e,aliasMap:n}=M4(t),{members:r}=kE(e,n);console.log(p("STATS_PEOPLE_HEADER__N",{n:r.length}));for(let o of r)console.log(p("STATS_PEOPLE_ROW__N_NAME_EMAIL",{n:String(o.commits).padStart(5),name:o.name,email:o.email}))}function U4(t){if(!t.member||!t.project)throw new Error(p("STATS_REVIEW_NEED_FLAGS"));let{repos:e}=sh(),n=e.find(s=>s.name===t.project);if(!n)throw new Error(p("STATS_REVIEW_NO_PROJECT__PROJECT_NAMES",{project:t.project,names:e.map(s=>s.name).join(", ")}));if(!Jc.default.existsSync(n.dir))throw new Error(p("STATS_REVIEW_NOT_CLONED__PROJECT_DIR",{project:t.project,dir:n.dir}));let r=hs(t);console.log(p("STATS_REVIEW_BUILDING__MEMBER_PROJECT_LABEL",{member:t.member,project:t.project,label:r.label}));let o=UE(n,t.member,r,{withDiff:t.diff,maxDiffLines:t.maxDiffLines,allBranches:!t.headOnly}),i=`${t.project}_${t.member.replace(/[^a-z0-9]+/gi,"-")}`.toLowerCase(),a=t.out||Hi.default.join(qc(),`review-${i}.md`);$E(a,o),console.log(p("STATS_REVIEW_WROTE__PATH",{path:a})),console.log(p("STATS_REVIEW_HINT"))}var Jc,Hi,GE,ch=A(()=>{"use strict";Jc=L(require("fs")),Hi=L(require("path")),GE=L(require("os"));nn();wE();Yc();oh();SE();IE();PE();FE();ne()});var HE=U((fG,$4)=>{$4.exports={name:"pan-stack-cli",version:"0.3.5",description:"PAN Stack CLI \u2014 multi-repo git and project commands from .project.yaml",license:"MIT",bin:{pan:"bin/pan.js"},files:["bin"],scripts:{build:"node tools/pan-stack-cli/build.mjs",prepare:"node tools/pan-stack-cli/build.mjs",prepublishOnly:"node tools/pan-stack-cli/build.mjs",test:'tsc --noEmit && tsc -p tsconfig.test.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.web.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.e2e.json --noEmit && node --test "tools/pan-stack-plan/test/*.test.ts" "tools/pan-stack-cli/test/*.test.ts" && node --test tools/pan-cicd/test/',"test:pan-cicd":"node tools/pan-stack-cli/build.mjs && node --test tools/pan-cicd/test/","test:pan-stack-plan":'node --test "tools/pan-stack-plan/test/*.test.ts"',"test:pan-stack-cli":'node --test "tools/pan-stack-cli/test/*.test.ts"',typecheck:"tsc --noEmit && tsc -p tsconfig.test.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.web.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.e2e.json --noEmit","build:web":"node tools/pan-stack-plan/build-web.mjs",pretest:"node tools/pan-stack-plan/build-web.mjs","test:e2e":"playwright test -c tools/pan-stack-plan/playwright.config.ts"},engines:{node:">=18"},keywords:["pan-stack","monorepo","git","cli"],repository:{type:"git",url:"git+https://github.com/n46-labs/pan-stack-tools.git",directory:"pan-stack-cli"},devDependencies:{"@inquirer/core":"^11.2.1","@inquirer/prompts":"^8.5.2","@inquirer/testing":"^3.3.9","@playwright/test":"1.62.1","@radix-ui/react-dialog":"^1.1.23","@radix-ui/react-popover":"1.1.23","@radix-ui/react-separator":"^1.1.15","@radix-ui/react-slot":"^1.3.3","@radix-ui/react-switch":"^1.3.7","@radix-ui/react-tabs":"^1.1.21","@radix-ui/react-tooltip":"^1.2.16","@tailwindcss/cli":"4.3.3","@tailwindcss/typography":"0.5.20","@types/node":"22.18.8","@types/react":"^19.2.18","@types/react-dom":"^19.2.5","@types/sanitize-html":"2.16.0","class-variance-authority":"0.7.1",clsx:"2.1.1",cmdk:"1.1.1","csv-parse":"7.0.1","csv-stringify":"6.8.1",esbuild:"0.28.1",marked:"15.0.12",react:"19.2.8","react-dom":"19.2.8","react-markdown":"10.1.0","remark-gfm":"4.0.1","sanitize-html":"2.16.0",serve:"^14.2.4","tailwind-merge":"3.6.0",tailwindcss:"4.3.3",typescript:"5.9.3"},optionalDependencies:{"@pan-stack/powerpoint":"^0.1.0"}}});var KE={};be(KE,{runInteractiveMenu:()=>G4});function F4(t){let e=t,n=String(e&&`${String(e.name)} ${String(e.message)}`||"");return/ExitPromptError|force closed|SIGINT|cancel/i.test(n)}async function uh({message:t,choices:e,hotkeys:n=[]}){try{return await Pe({message:t,choices:e,hotkeys:n})}catch(r){if(String(r?.message)!=="no-core")throw r;let o=await Cn();if(!o||typeof o.select!="function")return"__exit__";let i=n.map(s=>({name:`${s.key} ${s.label}`,value:s.value})),a=i.length?[...e,new o.Separator,...i]:e;return o.select({message:t,choices:a,pageSize:20,loop:!1,theme:ft(!1)})}}async function G4({printUsage:t,version:e}={}){let n=await lc(),r=await Cn();if(!n&&(!r||typeof r.select!="function"))return!1;let o=Hl().filter(i=>Wa(i).length>0).sort((i,a)=>br(i).localeCompare(br(a)));if(o.length===0)return console.log(p("NO_PAN_YAML_WITH_COMMANDS")),console.log(p("NO_PAN_YAML_BUT_GIT_STILL_WORKS")),!1;try{for(;;){let i=await uh({message:p("MENU_SELECT_PROJECT"),choices:o.map((f,h)=>({name:br(f),value:h,description:`${Wa(f).length} ${p("COMMANDS_LABEL")} \xB7 ${f.root}`})),hotkeys:[{key:"h",label:p("HELP_LABEL"),value:"__help__"},{key:"v",label:p("VERSION_LABEL"),value:"__version__"},{key:"x",label:p("EXIT_LABEL"),value:"__exit__"}]});if(i==="__exit__")return!0;if(i==="__version__"){console.log(`pan-stack-cli ${e||"?"}`);continue}if(i==="__help__"){typeof t=="function"&&t();continue}let a=typeof i=="number"?o[i]:void 0;if(!a)continue;let s=Wa(a),l=await uh({message:`[${br(a)}] ${p("MENU_SELECT_COMMAND")}`,choices:s.map(f=>({name:f.name+(f.aliases&&f.aliases.length?` (${f.aliases.join(", ")})`:"")+(f.hasTargets?` [${f.targets.join("|")}]`:""),value:f.name,description:f.description||""})),hotkeys:[{key:"b",label:p("BACK_LABEL"),value:"__back__"},{key:"x",label:p("EXIT_LABEL"),value:"__exit__"}]});if(l==="__exit__")return!0;if(l==="__back__")continue;let c=a.commands[String(l)],u=[];if(c&&c.targets&&Object.keys(c.targets).length>0){let f=Object.keys(c.targets),h=await uh({message:p("SELECT_TARGET__CMD",{cmd:l}),choices:[...f.map(m=>({name:m,value:m})),{name:p("DEFAULT_LABEL"),value:"__default__"}],hotkeys:[{key:"b",label:p("BACK_LABEL"),value:"__back__"}]});if(h==="__back__")continue;h!=="__default__"&&u.push(String(h))}console.error(`
966
966
  \u25B6 pan ${l}${u.length?" "+u.join(" "):""} (${WE.default.basename(a.root)})
967
967
  `);let d=await Wc(a,String(l),u);if(!(d&&d.backed))return!0}}catch(i){if(F4(i))return console.error(`
968
968
  `+p("EXITED")),!0;throw i}}var WE,zE=A(()=>{"use strict";WE=L(require("path"));nn();Co();Kp();eo();Rt();Mo();ne()});var ew={};be(ew,{MANAGED_BY_PAN:()=>Ho,PRODUCTS_DIR:()=>Nn,PRODUCT_LAYOUT:()=>yr,SHARED_LAYOUT:()=>Qc,TEMPLATES:()=>ms,findTemplateDir:()=>dh,listProducts:()=>Wo,renderReadme:()=>ph,runBa:()=>nL});function z4(){console.log(p("BA_USAGE",{skill:Wi,productsDir:Nn}))}function Y4(t){let e={positional:[],dir:"",title:"",products:[],dryRun:!1,help:!1};for(let n=0;n<t.length;n+=1){let r=t[n];if(r!==void 0)if(r==="-h"||r==="--help")e.help=!0;else if(r==="--dry-run")e.dryRun=!0;else if(r==="--title")e.title=t[n+=1]||"";else if(r.startsWith("--title="))e.title=r.slice(8);else if(r==="--dir")e.dir=t[n+=1]||"";else if(r.startsWith("--dir="))e.dir=r.slice(6);else if(r==="--product")e.products.push(t[n+=1]||"");else if(r.startsWith("--product="))e.products.push(r.slice(10));else{if(r.startsWith("-"))throw new Error(p("BA_UNKNOWN_FLAG__FLAG",{flag:r}));e.positional.push(r)}}return e}function dh(t){let e=me.default.resolve(t);for(let n=0;n<8;n+=1){for(let o of VE){let i=me.default.join(e,o,"skills",Wi,"references","templates");if(se.default.existsSync(i)&&se.default.statSync(i).isDirectory())return i}let r=me.default.dirname(e);if(r===e)break;e=r}return null}function fh(t){let e=dh(t);if(e)return e;throw new Error(p("BA_TEMPLATE_NOT_FOUND__SKILL_SEARCHED_ROOT",{skill:Wi,searched:VE.map(n=>`${n}/skills/${Wi}/references/templates`).join(", "),root:t}))}function qE(t,e){try{return se.default.readFileSync(t,"utf8")===se.default.readFileSync(e,"utf8")}catch{return!1}}function Wo(t){let e=me.default.join(t,Nn);return se.default.existsSync(e)?se.default.readdirSync(e,{withFileTypes:!0}).filter(n=>n.isDirectory()&&!n.name.startsWith(".")).map(n=>n.name).sort():[]}function V4(t){return Wo(t).length>0}function JE(t){for(let e of se.default.readdirSync(t,{withFileTypes:!0}))if(!(e.name===".gitkeep"||e.name.startsWith(".")))if(e.isDirectory()){if(JE(me.default.join(t,e.name)))return!0}else return!0;return!1}function XE(t){if(!se.default.existsSync(t)||!se.default.statSync(t).isDirectory())return!1;for(let n of se.default.readdirSync(t,{withFileTypes:!0}))n.isDirectory()&&XE(me.default.join(t,n.name));return se.default.readdirSync(t).filter(n=>n!==".gitkeep").length?!1:(se.default.rmSync(me.default.join(t,".gitkeep"),{force:!0}),se.default.rmdirSync(t),!0)}function q4(t){return[...new Set(yr.map(([n])=>n.split("/")[0]??n))].filter(n=>{let r=me.default.join(t,n);return se.default.existsSync(r)&&JE(r)})}function Xc(t,e,n,r){let o=0;for(let[i]of e){let a=me.default.join(t,i);se.default.existsSync(a)||(o+=1,r(` + ${me.default.relative(process.cwd(),a)||i}`),n||(se.default.mkdirSync(a,{recursive:!0}),se.default.writeFileSync(me.default.join(a,".gitkeep"),W4)))}return o}function QE(t,e,n){let r=0;for(let o of ms.map(([i])=>i).concat("README.md")){let i=me.default.join(e,o),a=me.default.join(t,"00-templates",o);if(!se.default.existsSync(i)){o!=="README.md"&&console.error(p("BA_SKILL_MISSING_TEMPLATE__NAME",{name:o}));continue}se.default.existsSync(a)&&qE(i,a)||(r+=1,console.log(` ${se.default.existsSync(a)?"~":"+"} 00-templates/${o}`),n||(se.default.mkdirSync(me.default.dirname(a),{recursive:!0}),se.default.copyFileSync(i,a)))}return r}function ph(t,e){let n=e.length>0,r=Qc.map(([l,c])=>`| \`${l}/\` | ${c} |`).join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pan-stack-cli",
3
- "version": "0.3.2",
3
+ "version": "0.3.5",
4
4
  "description": "PAN Stack CLI — multi-repo git and project commands from .project.yaml",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -25,11 +25,6 @@
25
25
  "engines": {
26
26
  "node": ">=18"
27
27
  },
28
- "dependencies": {
29
- "@inquirer/core": "^11.2.1",
30
- "@inquirer/prompts": "^8.5.2",
31
- "serve": "^14.2.4"
32
- },
33
28
  "keywords": [
34
29
  "pan-stack",
35
30
  "monorepo",
@@ -38,10 +33,12 @@
38
33
  ],
39
34
  "repository": {
40
35
  "type": "git",
41
- "url": "https://github.com/doiya46/pan-stack.git",
42
- "directory": ".pan/pan-stack-cli"
36
+ "url": "git+https://github.com/n46-labs/pan-stack-tools.git",
37
+ "directory": "pan-stack-cli"
43
38
  },
44
39
  "devDependencies": {
40
+ "@inquirer/core": "^11.2.1",
41
+ "@inquirer/prompts": "^8.5.2",
45
42
  "@inquirer/testing": "^3.3.9",
46
43
  "@playwright/test": "1.62.1",
47
44
  "@radix-ui/react-dialog": "^1.1.23",
@@ -69,6 +66,7 @@
69
66
  "react-markdown": "10.1.0",
70
67
  "remark-gfm": "4.0.1",
71
68
  "sanitize-html": "2.16.0",
69
+ "serve": "^14.2.4",
72
70
  "tailwind-merge": "3.6.0",
73
71
  "tailwindcss": "4.3.3",
74
72
  "typescript": "5.9.3"