diff --git a/skills/kugetsu/scripts/kugetsu b/skills/kugetsu/scripts/kugetsu index 3e847d0..d293a3c 100755 --- a/skills/kugetsu/scripts/kugetsu +++ b/skills/kugetsu/scripts/kugetsu @@ -481,6 +481,13 @@ write_index() { local issues_json="$3" local temp_file="$INDEX_FILE.tmp.$$" printf '{"base": %s, "pm_agent": %s, "issues": %s}\n' "$base" "$pm_agent" "$issues_json" > "$temp_file" + + if ! python3 -c "import json; json.load(open('$temp_file'))" 2>/dev/null; then + echo "Error: write_index would create malformed JSON, aborting. base=$base, pm_agent=$pm_agent, issues_json=$issues_json" >&2 + rm -f "$temp_file" + return 1 + fi + mv "$temp_file" "$INDEX_FILE" } diff --git a/skills/kugetsu/scripts/kugetsu-index.sh b/skills/kugetsu/scripts/kugetsu-index.sh index 8eec8c2..f1e6695 100755 --- a/skills/kugetsu/scripts/kugetsu-index.sh +++ b/skills/kugetsu/scripts/kugetsu-index.sh @@ -15,6 +15,13 @@ write_index() { local issues_json="$3" local temp_file="$INDEX_FILE.tmp.$$" printf '{"base": %s, "pm_agent": %s, "issues": %s}\n' "$base" "$pm_agent" "$issues_json" > "$temp_file" + + if ! python3 -c "import json; json.load(open('$temp_file'))" 2>/dev/null; then + echo "Error: write_index would create malformed JSON, aborting. base=$base, pm_agent=$pm_agent, issues_json=$issues_json" >&2 + rm -f "$temp_file" + return 1 + fi + mv "$temp_file" "$INDEX_FILE" }