galaxyrepowatch 1.0.1 → 1.0.3

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 +25 -0
  2. package/dist/cli.js +1 -1
  3. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # 🛡️ Galaxy Repo Watch — AI Guard
2
+
3
+ Enterprise-grade AI Git Review Guard powered by Gemini.
4
+
5
+ ⚠️ **DO NOT RUN `npm install`** ⚠️
6
+ This package is an automated installer. To set up AI Guard in your project, simply run the init command:
7
+
8
+ ```bash
9
+ npx galaxyrepowatch init
10
+ ```
11
+
12
+ ## What this does:
13
+ Running the command above will automatically:
14
+ 1. Install the required dependencies.
15
+ 2. Initialize Husky in your project.
16
+ 3. Configure a `pre-commit` hook to automatically review your code before every commit.
17
+ 4. Ask for your Gemini API key (only once) and save it locally.
18
+ 5. Create a `.repowatchrc` configuration file for custom rules.
19
+
20
+ ## How it works:
21
+ Every time you run `git commit`, the AI Guard will:
22
+ - Check your code for critical syntax errors.
23
+ - Scan for hardcoded secrets and passwords.
24
+ - Run a Gemini 2.5 Flash AI code review on your staged changes.
25
+ - Block the commit if the code exceeds the risk threshold (75/100).
package/dist/cli.js CHANGED
@@ -445,7 +445,7 @@ Additional information: BADCLIENT: Bad error code, ${T} not found in range ${c}.
445
445
  `),he=[],Ne="unknown",Ue=!1;for(let et of re){if(et.startsWith("diff --git ")){let Ht=et.match(/b\/(.+)$/);Ht&&(Ne=Ht[1],Ue=J7(Ne,GC.ignoredPaths))}Ue||he.push(et)}return he.join(`
446
446
  `)},P9e=GC.severityWeights;function Hht(Te){if(!Te.length)return 0;let re=0;for(let he of Te)re+=P9e[he.rule.severity.toUpperCase()]??0;return Math.min(re,60)}function Ght(Te){if(!Te.length)return 0;let re=0;for(let he of Te)re+=(P9e[he.severity.toUpperCase()]??0)*.7;return Math.min(re,50)}function $ht(Te,re){let he=[/\.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],Ne=0;for(let Ue of Te)he.some(Ht=>Ht.test(Ue))&&(/\.env/i.test(Ue)?Ne+=20:/\.(pem|key|p12|pfx)$/i.test(Ue)?Ne+=25:/credentials|secrets?/i.test(Ue)?Ne+=15:Ne+=10);return re.length>5e4&&(Ne+=5),re.length>25e4&&(Ne+=10),Math.min(Ne,30)}var Qht=(Te,re,he,Ne,Ue,et)=>{let Ht=zhe,wr=Hht(Te),br=Math.min(he*.5,50),on=$ht(et,Ue),Dr=Ght(re),kn=wr+br+on+Dr,Ae=Te.some(r_=>r_.rule.blockOnMatch),us=qht(Ue),ir=0;for(let r_ of x9e)r_.pattern.lastIndex=0,r_.pattern.test(us)&&(ir=Math.max(ir,r_.severity));let At=ir>=Ht,Bo=kn;Bo=Math.max(Bo,Ne.directImpactRiskScore),Bo=Math.max(Bo,ir),Bo=Math.min(100,Bo);let is=re.some(r_=>r_.fatal),Fo=Ae||At||is||kn>=Ht;return{score:Bo,level:k9e(Bo),shouldBlock:Fo}},d9e=async Te=>({id:"local-review-"+Date.now()}),zhe=parseInt(process.env.RISK_BLOCK_THRESHOLD??"",10)||GC.riskBlockThreshold;var Is={reset:"\x1B[0m",bold:"\x1B[1m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",cyan:"\x1B[36m",gray:"\x1B[90m"};function I0(Te){try{return(0,Sj.execSync)(Te,{encoding:"utf8",stdio:"pipe"}).trim()}catch(re){return Te.includes("eslint")&&re.stdout?re.stdout.toString():""}}function m9e(){if(N6){let Te=process.env.GITHUB_HEAD_REF||process.env.GITHUB_REF_NAME||process.env.CI_COMMIT_REF_NAME;if(Te)return Te}return I0("git rev-parse --abbrev-ref HEAD")||"unknown-branch"}function g9e(){if(N6){let Te=process.env.GITHUB_SHA||process.env.CI_COMMIT_SHA;if(Te)return Te}return I0("git rev-parse HEAD")||`tmp_${Date.now()}`}function h9e(){if(N6){let Te=process.env.GITLAB_USER_NAME||process.env.GITHUB_ACTOR;if(Te)return Te}return I0("git config user.name")||"CI Runner"}function y9e(){if(N6){let Te=process.env.GITLAB_USER_EMAIL;if(Te)return Te}return I0("git config user.email")||"ci-runner@example.com"}function Xht(){console.log(`
447
447
  ${Is.bold}${Is.cyan}\u{1F6E1}\uFE0F galaxyrepowatch \u2014 AI Git Review Guard${Is.reset}
448
- `)}function v9e(Te,re=30){let he=Te<25?Is.green:Te<50?Is.yellow:Is.red,Ne=Math.max(0,Math.min(re,Math.round(Te/100*re))),Ue="\u2588".repeat(Ne)+"\u2591".repeat(re-Ne);return`${he}${Ue}${Is.reset}`}async function Yht(){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:Ea}=require("child_process");Ea("npm install --save-dev husky galaxyrepowatch --legacy-peer-deps",{stdio:"inherit"}),Ea(`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..."),Ea("npx husky",{stdio:"inherit"});let xi=".husky/pre-commit";Ly.writeFileSync(xi,`#!/usr/bin/env bash
448
+ `)}function v9e(Te,re=30){let he=Te<25?Is.green:Te<50?Is.yellow:Is.red,Ne=Math.max(0,Math.min(re,Math.round(Te/100*re))),Ue="\u2588".repeat(Ne)+"\u2591".repeat(re-Ne);return`${he}${Ue}${Is.reset}`}async function Yht(){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:Ea}=require("child_process");Ea("npm install --save-dev husky galaxyrepowatch --legacy-peer-deps --ignore-scripts",{stdio:"inherit"}),Ea(`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..."),Ea("npx husky",{stdio:"inherit"});let xi=".husky/pre-commit";Ly.writeFileSync(xi,`#!/usr/bin/env bash
449
449
  if [ -f .env ]; then
450
450
  export $(grep -v '^#' .env | xargs)
451
451
  fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "galaxyrepowatch",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "AI-powered Git pre-commit guard. Blocks bad code, detects secrets, runs Gemini AI review on every commit.",
5
5
  "main": "dist/cli.js",
6
6
  "bin": {