This should get you what you need. Please note that this creates new pathItems directly above each selected object for demonstration purposes. If you are not working with perfect squares, you must decide if you want the radius calculated using the target object's width or height (see script comments).
var doc = app.activeDocument;
var sel = doc.selection;
var color = new RGBColor();
color.red = 255;
color.green = color.blue = 0;
var target, targetBounds, width, height, radius, replacement;
for (var i = 0; i < sel.length; i++) {
// get info of the target rectangle (square)
target = sel[i];
targetBounds = target.geometricBounds;
width = targetBounds[2] - targetBounds[0];
height = targetBounds[1] - targetBounds[3];
// calculate radius at 12% of `width`, or if you prefer to use `height`
// just change the line below (doesn't matter if you are dealing with squares)
radius = width * 0.12; // change to width to `height` if you prefer
// create the replacement rounder rectangle
replacement = doc.pathItems.roundedRectangle(
targetBounds[1],
targetBounds[0],
width,
height,
radius,
radius
);
replacement.fillColor = color;
replacement.move(target, ElementPlacement.PLACEBEFORE);
}