refactor: use JSON file exchange instead of stdout parsing #234

Merged
shoko merged 1 commits from fix/issue-119 into main 2026-04-08 05:35:11 +02:00
Owner

Summary

Replace fragile Python stdout parsing with structured JSON file exchange.

Depends On

  • #116 (Foundation - Modularize Shell Script)

Changes

New helper functions in kugetsu-index.sh

  • read_json_file() - Read JSON file contents
  • write_json_file() - Write JSON with validation
  • get_json_value() - Get value by key from JSON file
  • set_json_value() - Set value by key in JSON file

Refactored functions

kugetsu-session.sh create_session()

  • Before: Used echo | python | grep pattern to parse session IDs via pipes
  • After: Writes JSON to temp files, reads with Python, compares sets

kugetsu-worktree.sh check_pr_status()

  • Before: curl | echo | python with stdout piping
  • After: Writes response to temp JSON file, reads directly with Python

Acceptance Criteria

  • No fragile stdout parsing remains in refactored functions
  • All IPC uses structured JSON files in refactored functions
  • Existing functionality unchanged (syntax check passed)

Backport Compatible

Internal improvement only, same behavior externally.


Closes #119

## Summary Replace fragile Python stdout parsing with structured JSON file exchange. ## Depends On - #116 (Foundation - Modularize Shell Script) ## Changes ### New helper functions in kugetsu-index.sh - `read_json_file()` - Read JSON file contents - `write_json_file()` - Write JSON with validation - `get_json_value()` - Get value by key from JSON file - `set_json_value()` - Set value by key in JSON file ### Refactored functions **kugetsu-session.sh `create_session()`** - Before: Used `echo | python | grep` pattern to parse session IDs via pipes - After: Writes JSON to temp files, reads with Python, compares sets **kugetsu-worktree.sh `check_pr_status()`** - Before: `curl | echo | python` with stdout piping - After: Writes response to temp JSON file, reads directly with Python ## Acceptance Criteria - [x] No fragile stdout parsing remains in refactored functions - [x] All IPC uses structured JSON files in refactored functions - [x] Existing functionality unchanged (syntax check passed) ## Backport Compatible Internal improvement only, same behavior externally. --- Closes #119
shoko added 1 commit 2026-04-08 05:11:41 +02:00
Replace fragile patterns like:
  python3 -c "import json; print(json.load(...))" | grep
  echo "$json" | python3 -c "import sys,json; ...
han approved these changes 2026-04-08 05:23:48 +02:00
han left a comment
First-time contributor

lgtm

lgtm
shoko merged commit 41c56a859c into main 2026-04-08 05:35:11 +02:00
Sign in to join this conversation.