galaxyrepowatch 2.0.5 → 2.0.6
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/cli.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -491,7 +491,7 @@ ${So.orange}INFO${So.reset} This report is informational only \u2014 it does not
|
|
|
491
491
|
`),se=[],ge="unknown",Ee=!1;for(let Je of q){if(Je.startsWith("diff --git ")){let Pt=Je.match(/b\/(.+)$/);Pt&&(ge=Pt[1],Ee=NA(ge,Px.ignoredPaths))}Ee||se.push(Je)}return se.join(`
|
|
492
492
|
`)},dLe=Px.severityWeights;function iyt(ne){if(!ne.length)return 0;let q=0;for(let se of ne)q+=dLe[se.rule.severity.toUpperCase()]??0;return Math.min(q,60)}function syt(ne){if(!ne.length)return 0;let q=0;for(let se of ne)q+=(dLe[se.severity.toUpperCase()]??0)*.7;return Math.min(q,50)}function ayt(ne,q){let se=[/\.env(\.|$)/i,/\.pem$/i,/\.key$/i,/\.p12$/i,/\.pfx$/i,/id_rsa/i,/id_dsa/i,/credentials/i,/secrets?\.(json|yml|yaml)$/i,/\.htpasswd$/i,/auth\.json$/i],ge=0;for(let Ee of s0e(ne))se.some(Pt=>Pt.test(Ee))&&(/\.env/i.test(Ee)?ge+=20:/\.(pem|key|p12|pfx)$/i.test(Ee)?ge+=25:/credentials|secrets?/i.test(Ee)?ge+=15:ge+=10);return q.length>5e4&&(ge+=5),q.length>25e4&&(ge+=10),Math.min(ge,30)}var oyt=(ne,q,se,ge,Ee,Je)=>{let Pt=cyt,cr=iyt(ne),rr=Math.min(se*.5,50),Hr=ayt(Je,Ee),Tr=syt(q),hn=cr+rr+Hr+Tr,De=ne.some(pu=>pu.rule.blockOnMatch),Yn=pLe(Ee),Ut=0;for(let pu of oLe)pu.pattern.lastIndex=0,pu.pattern.test(Yn)&&(Ut=Math.max(Ut,pu.severity));let bt=Ut>=Pt,Ao=hn;Ao=Math.max(Ao,ge.directImpactRiskScore),Ao=Math.max(Ao,Ut);let bs=q.some(pu=>pu.fatal||pu.severity==="CRITICAL"),mo="";bs?(mo="Fatal finding (e.g., syntax issue) detected.",Ao=100):De?(mo="Critical rule violation detected.",Ao=100):bt?(mo="Global blocker rule violation detected.",Ao=100):Ao>=Pt&&(mo=`Risk score of ${Ao.toFixed(0)} exceeds the threshold of ${Pt}.`),Ao=Math.min(100,Ao);let Vl=!!mo;return{score:Ao,level:cLe(Ao),shouldBlock:Vl,blockReason:mo}},K9e=async ne=>({id:"local-review-"+Date.now()}),cyt=parseInt(process.env.RISK_BLOCK_THRESHOLD??"",10)||Px.riskBlockThreshold;var Vn={reset:"\x1B[0m",bold:"\x1B[1m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",cyan:"\x1B[36m",gray:"\x1B[90m"};function L0(ne){try{return(0,Mj.execSync)(ne,{encoding:"utf8",stdio:"pipe"}).trim()}catch(q){return ne.includes("eslint")&&q.stdout?q.stdout.toString():""}}function Z9e(){if(W6){let ne=process.env.GITHUB_HEAD_REF||process.env.GITHUB_REF_NAME||process.env.CI_COMMIT_REF_NAME;if(ne)return ne}return L0("git rev-parse --abbrev-ref HEAD")||"unknown-branch"}function eLe(){if(W6){let ne=process.env.GITHUB_SHA||process.env.CI_COMMIT_SHA;if(ne)return ne}return L0("git rev-parse HEAD")||`tmp_${Date.now()}`}function tLe(){if(W6){let ne=process.env.GITLAB_USER_NAME||process.env.GITHUB_ACTOR;if(ne)return ne}return L0("git config user.name")||"CI Runner"}function rLe(){if(W6){let ne=process.env.GITLAB_USER_EMAIL;if(ne)return ne}return L0("git config user.email")||"ci-runner@example.com"}function lyt(){console.log(`
|
|
493
493
|
${Vn.bold}${Vn.cyan}\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557${Vn.reset}`),console.log(`${Vn.bold}${Vn.cyan}\u2551 \u{1F6E1}\uFE0F Galaxy RepoWatch \u2014 AI Guard \u2551${Vn.reset}`),console.log(`${Vn.bold}${Vn.cyan}\u2551 Pre-commit Code Review System \u2551${Vn.reset}`),console.log(`${Vn.bold}${Vn.cyan}\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D${Vn.reset}
|
|
494
|
-
`)}function nLe(ne,q=30){let se=ne<25?Vn.green:ne<50?Vn.yellow:Vn.red,ge=Math.max(0,Math.min(q,Math.round(ne/100*q))),Ee="\u2588".repeat(ge)+"\u2591".repeat(q-ge);return`${se}${Ee}${Vn.reset}`}async function uyt(){if(process.argv[2]==="init"){console.log("\\n\u{1F6E1}\uFE0F AI Guard \u2014 Enterprise Setup"),console.log("=================================================="),console.log(`\u{1F4C2} Installing into: ${process.cwd()}`),console.log("\\n\u{1F4E6} Installing AI Guard dependencies...");let{execSync:_s}=require("child_process");_s("npm install --save-dev husky galaxyrepowatch --legacy-peer-deps",{stdio:"inherit"}),_s(`node -e "const fs = require('fs'); const pkg = JSON.parse(fs.readFileSync('package.json')); pkg.scripts = pkg.scripts || {}; if (!pkg.scripts.prepare) { pkg.scripts.prepare = 'husky'; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); }"`),console.log("\\n\u{1F436} Initializing Husky..."),_s("npx husky",{stdio:"inherit"});let Js=".husky/pre-commit";jy.writeFileSync(Js,`#!/usr/bin/env bash
|
|
494
|
+
`)}function nLe(ne,q=30){let se=ne<25?Vn.green:ne<50?Vn.yellow:Vn.red,ge=Math.max(0,Math.min(q,Math.round(ne/100*q))),Ee="\u2588".repeat(ge)+"\u2591".repeat(q-ge);return`${se}${Ee}${Vn.reset}`}async function uyt(){if(process.argv[2]==="init"){console.log("\\n\u{1F6E1}\uFE0F AI Guard \u2014 Enterprise Setup"),console.log("=================================================="),console.log(`\u{1F4C2} Installing into: ${process.cwd()}`),console.log("\\n\u{1F4E6} Installing AI Guard dependencies...");let{execSync:_s}=require("child_process");_s("npm install --save-dev husky galaxyrepowatch --legacy-peer-deps --ignore-scripts",{stdio:"inherit"}),_s(`node -e "const fs = require('fs'); const pkg = JSON.parse(fs.readFileSync('package.json')); pkg.scripts = pkg.scripts || {}; if (!pkg.scripts.prepare) { pkg.scripts.prepare = 'husky'; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); }"`),console.log("\\n\u{1F436} Initializing Husky..."),_s("npx husky",{stdio:"inherit"});let Js=".husky/pre-commit";jy.writeFileSync(Js,`#!/usr/bin/env bash
|
|
495
495
|
# Load GEMINI_API_KEY and GEMINI_MODEL from .env if present
|
|
496
496
|
if [ -f .env ]; then
|
|
497
497
|
GEMINI_API_KEY_VAL=$(grep -E "^GEMINI_API_KEY=" .env | cut -d= -f2- | sed -e 's/^"//' -e 's/"$//' -e "s/^'//" -e "s/'$//")
|