fix(kyberforge): resolve PR #144 review and audit round 2

- factory-audit: ./ and bare/absolute script checks scoped to command
  position (no false FAILs on ./src or printf); hook sources limited to
  .apm/hooks or package-root hooks/; Kiro-aware lowercase events;
  unfilled template placeholders FAIL; repo-only instructions FAIL at
  any scope; Vale description FAIL documented; bats 367 -> 378
- primitive-author: split-quote/spaced paths and handler-less entries
  promoted to Must; Step 4.2 renders into a scratch consumer instead of
  a no-op dry run; dispatch and gate hand-off trimmed
- apm-workflow 1.0.2: mutual boundary with primitive-author
- forge: no double package bump; gotcha wording
- skill-author: create keeps seeded 0.1.0 (ADR-0022); portable,
  retry-safe new-skill.sh; template and flow consistency fixes
- hook docs: cite the ADR-0019 correction; guard caveat

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
This commit is contained in:
2026-09-28 20:50:22 +00:00
parent df28351d3e
commit 965208bddd
29 changed files with 462 additions and 156 deletions

View File

@@ -40,7 +40,8 @@ Output:
Standalone mode: <path>/<skill-name>/
Exit codes:
0 Scaffold created successfully, or destination already exists (no-op)
0 Scaffold created, destination already complete (no-op), or a partial
scaffold from an earlier failed run repaired
1 Invalid arguments, missing path, or templates not found
EOF
}
@@ -152,20 +153,56 @@ else
TARGET="$TARGET_INPUT/$SKILL_NAME"
fi
# Destination already exists — treat as a no-op so retries are safe
# Files carrying the SKILL_NAME placeholder token.
SUBST_FILES=("SKILL.md" "tests/README.md")
# Replace SKILL_NAME in each placeholder file under dir $1. `sed -i` is not
# portable — GNU takes an optional attached suffix, BSD/macOS requires a
# separate suffix argument and reads the expression as one — so write to a
# temp file and move it over the original instead.
substitute_name() {
local dir="$1" rel f
for rel in "${SUBST_FILES[@]}"; do
f="$dir/$rel"
[[ -f "$f" ]] || continue
sed "s/SKILL_NAME/$SKILL_NAME/g" "$f" > "$f.tmp"
mv "$f.tmp" "$f"
done
}
# True if any placeholder file under dir $1 still carries the SKILL_NAME token.
has_placeholder() {
local dir="$1" rel
for rel in "${SUBST_FILES[@]}"; do
if [[ -f "$dir/$rel" ]] && grep -q 'SKILL_NAME' "$dir/$rel"; then
return 0
fi
done
return 1
}
if [[ -d "$TARGET" ]]; then
# A scaffold left half-built by an earlier failed run still carries the
# placeholder token; finish it instead of reporting a silent no-op.
if has_placeholder "$TARGET"; then
substitute_name "$TARGET"
echo "Repaired partial scaffold at '$TARGET' — substituted SKILL_NAME." >&2
exit 0
fi
echo "Scaffold already exists at '$TARGET' — nothing to do." >&2
exit 0
fi
mkdir -p "$(dirname "$TARGET")"
# Copy templates to destination
cp -r "$TEMPLATES_DIR" "$TARGET"
# Set skill name in templates
sed -i "s/SKILL_NAME/$SKILL_NAME/g" "$TARGET/SKILL.md"
sed -i "s/SKILL_NAME/$SKILL_NAME/g" "$TARGET/tests/README.md"
# Build in a sibling staging directory and rename it into place only once
# complete, so a failure mid-build never leaves a half-built $TARGET behind.
STAGING="$TARGET.partial.$$"
trap 'rm -rf "$STAGING"' EXIT
cp -r "$TEMPLATES_DIR" "$STAGING"
substitute_name "$STAGING"
mv "$STAGING" "$TARGET"
trap - EXIT
if [[ "$MODE" == "package" ]]; then
echo "Mode: package — type-bearing apm.yml found at '$PKG_ROOT'" >&2