[object Object]

← back to Trending Dw

chore: lint guards (colorGate NaN, --rolls, json.loads) + refactor (dead imports) + version bump (session close)

8e9ac73eb41385d30d92b7426a7249b816e1ea14 · 2026-07-07 12:44:46 -0700 · Steve

Files touched

Diff

commit 8e9ac73eb41385d30d92b7426a7249b816e1ea14
Author: Steve <steve@designerwallcoverings.com>
Date:   Tue Jul 7 12:44:46 2026 -0700

    chore: lint guards (colorGate NaN, --rolls, json.loads) + refactor (dead imports) + version bump (session close)
---
 package.json                                  |   2 +-
 scripts/__pycache__/heal-tile.cpython-314.pyc | Bin 10237 -> 10480 bytes
 scripts/gapgen.js                             |   6 ++++--
 scripts/heal-tile.py                          |   8 +++++---
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/package.json b/package.json
index f20a855..bd3f33f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "trending-dw",
-  "version": "0.1.1",
+  "version": "0.1.2",
   "private": true,
   "description": "trending.designerwallcoverings.com — bestseller intelligence across Google + POD marketplaces",
   "main": "server.js",
diff --git a/scripts/__pycache__/heal-tile.cpython-314.pyc b/scripts/__pycache__/heal-tile.cpython-314.pyc
index 5db4859..f93fa9b 100644
Binary files a/scripts/__pycache__/heal-tile.cpython-314.pyc and b/scripts/__pycache__/heal-tile.cpython-314.pyc differ
diff --git a/scripts/gapgen.js b/scripts/gapgen.js
index a31f4f6..0e75fc3 100644
--- a/scripts/gapgen.js
+++ b/scripts/gapgen.js
@@ -21,7 +21,6 @@
  *   ids must be current GAP items in data/bestsellers.json (needsGeneration, no image).
  */
 const fs = require('fs');
-const os = require('os');
 const path = require('path');
 const { execSync } = require('child_process');
 
@@ -173,7 +172,9 @@ b = (im >> 4).reshape(-1, 3)
 _, c = np.unique(b, axis=0, return_counts=True)
 print(int((c >= c.sum() * float(sys.argv[2])).sum()))
 ` });
-  return parseInt(out.trim(), 10);
+  const n = parseInt(out.trim(), 10);
+  if (isNaN(n)) throw new Error('colorGate bad output: ' + out.slice(0, 80));
+  return n;
 }
 
 // ---- main -----------------------------------------------------------------
@@ -182,6 +183,7 @@ const args = process.argv.slice(2);
 let rolls = 2;
 const ri = args.indexOf('--rolls');
 if (ri >= 0) { rolls = parseInt(args[ri + 1], 10); args.splice(ri, 2); }
+if (isNaN(rolls) || rolls < 1) { console.error('--rolls requires a positive integer'); process.exit(1); }
 // --dry-run: resolve ids + build briefs and print them, but generate NOTHING
 // (no Replicate call, no spend). Use to validate targeting before paying.
 const di = args.indexOf('--dry-run');
diff --git a/scripts/heal-tile.py b/scripts/heal-tile.py
index 29d4de6..a6d8b32 100644
--- a/scripts/heal-tile.py
+++ b/scripts/heal-tile.py
@@ -23,6 +23,7 @@ Exit 0 if the healed tile PASSES seam (overall_max <= 5), else 1.
 """
 import argparse, json, subprocess, sys
 from pathlib import Path
+import numpy as np
 
 WALLCO_SEAM = Path('/Users/macstudio3/Projects/wallco-ai/scripts/seam-defect-boxes.py')
 PY = sys.executable  # run under the same interpreter (the .gapvenv python that has numpy+PIL)
@@ -35,14 +36,16 @@ def scan(png: Path) -> dict:
     r = subprocess.run([PY, str(WALLCO_SEAM), '--path', str(png)], capture_output=True, text=True, timeout=60)
     if r.returncode != 0:
         raise RuntimeError(f'seam scan failed: {r.stderr.strip()[:200]}')
-    return json.loads(r.stdout)
+    try:
+        return json.loads(r.stdout)
+    except json.JSONDecodeError as exc:
+        raise RuntimeError(f'seam scan bad JSON: {r.stdout[:200]}') from exc
 
 
 # ---- heal primitives (ported verbatim from wallco-ai/scripts/heal-seam-region.py) ----
 def heal_band_mid(arr, axis, idx, start, end):
     """axis='v': vertical seam at x=idx, healing rows [start:end];
        axis='h': horizontal seam at y=idx, healing cols [start:end]."""
-    import numpy as np
     H, W = arr.shape[:2]
     if axis == 'v':
         x0 = max(0, idx - BAND_PX // 2); x1 = min(W, idx + BAND_PX // 2)
@@ -104,7 +107,6 @@ def main():
         sys.exit(0 if before['verdict'] == 'PASS' else 1)
 
     from PIL import Image
-    import numpy as np
     arr = np.asarray(Image.open(src).convert('RGB')).copy()
     H, W = arr.shape[:2]
 

← 86ce32b trending: reship 10 vetted+deduped gap tiles (settlement-gat  ·  back to Trending Dw  ·  gapgen: cost guard — refuse paid Replicate by default (Steve 39b1dba →