master
John Lauer ESC routing to 100%: the place-route loop (smaller signal vias, 13 parts moved, 114 commits, 0 unconnected), kicad-plac… df61ffd 1mo ago
#!/usr/bin/env python3
"""Stage the skills package (only package.json files[]) into a clean dir, pack it, and optionally publish.

    python3 tools/stage_pkg.py [--bump] [--publish] [--stage DIR]

--bump raises the patch version in package.json before staging. The runtime zip is a different artifact;
this is the container-side skills package only (kicad-bridge-publish skill, section 4).
"""
import argparse, json, os, shutil, subprocess, sys, tempfile
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ap = argparse.ArgumentParser(); ap.add_argument("--bump", action="store_true"); ap.add_argument("--publish", action="store_true"); ap.add_argument("--stage")
a = ap.parse_args()
pj = os.path.join(ROOT, "package.json"); d = json.load(open(pj))
if a.bump:
    x, y, z = d["version"].split("."); d["version"] = "%s.%s.%d" % (x, y, int(z) + 1)
    json.dump(d, open(pj, "w"), indent=2); open(pj, "a").write("\n")
stage = a.stage or tempfile.mkdtemp(prefix="kicad-bridge-pkg-")
for f in d["files"]:
    src = os.path.join(ROOT, f)
    if not os.path.exists(src):
        sys.exit("missing file listed in files[]: %s" % f)
    dst = os.path.join(stage, f); os.makedirs(os.path.dirname(dst), exist_ok=True); shutil.copy2(src, dst)
shutil.copy2(pj, os.path.join(stage, "package.json"))
missing = [p for p in os.listdir(os.path.join(ROOT, "skills")) if os.path.isdir(os.path.join(ROOT, "skills", p)) and "skills/%s/SKILL.md" % p not in d["files"]]
print("version %s, %d files staged in %s%s" % (d["version"], len(d["files"]), stage, "" if not missing else "; SKILLS NOT IN files[]: %s" % missing))
if missing:
    sys.exit(3)
subprocess.run(["adom-wiki", "pkg", "pack", "--out", os.path.join(stage, "pkg.tgz")], cwd=stage, check=True)
if a.publish:
    subprocess.run(["adom-wiki", "pkg", "publish", "--org", "adom", "--skip-lint", "--yes"], cwd=stage, check=True)