diff --git a/docs/commands.md b/docs/commands.md index abf197d..5e85f94 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -38,6 +38,27 @@ python3 scripts/validate_docs_sync.py ### tea CLI (Gitea Command Line Tool) +#### โŒ Comment Newline Escaping (`\n` rendered literally) +```bash +YES="" ~/bin/tea comment 374 "line1\nline2" +# Web UI shows "\n" as text instead of line breaks +``` +**๐Ÿ’ก Reason:** Inline string escaping is interpreted literally before comment submission. + +**โœ… Solution:** Use file-based helper to preserve multiline text +```bash +cat > /tmp/comment.md <<'EOF' +line1 +line2 +EOF + +scripts/tea_comment.sh 374 /tmp/comment.md +``` + +**๐Ÿ“ Notes:** +- `scripts/tea_comment.sh` accepts stdin with `-` as body source. +- The helper fails fast when body looks like escaped-newline text only. + #### โŒ TTY Error - Interactive Confirmation Fails ```bash ~/bin/tea issues create --repo X --title "Y" --description "Z" diff --git a/docs/workflow.md b/docs/workflow.md index 288fe70..ecbcdcd 100644 --- a/docs/workflow.md +++ b/docs/workflow.md @@ -70,6 +70,22 @@ Gitea ์ด์Šˆ/PR/์ฝ”๋ฉ˜ํŠธ ์ž‘์—… ์ „์— ๋ชจ๋“  ์—์ด์ „ํŠธ๋Š” ์•„๋ž˜๋ฅผ ๋จผ์ € Issue/PR ๋ณธ๋ฌธ ์ž‘์„ฑ ์‹œ ์ค„๋ฐ”๊ฟˆ(`\n`)์ด ๋ฌธ์ž์—ด ๊ทธ๋Œ€๋กœ ์ €์žฅ๋˜๋Š” ๋ฌธ์ œ๊ฐ€ ๋ฐ˜๋ณต๋  ์ˆ˜ ์žˆ๋‹ค. ์›์ธ์€ `-d "...\n..."` ํ˜•ํƒœ์—์„œ ์‰˜/CLI๊ฐ€ ์ด์Šค์ผ€์ดํ”„๋ฅผ ์‹ค์ œ ๊ฐœํ–‰์œผ๋กœ ํ•ด์„ํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. +์ฝ”๋ฉ˜ํŠธ๋„ ๋™์ผํ•œ ๋ฌธ์ œ๊ฐ€ ์ž์ฃผ ๋ฐœ์ƒํ•˜๋ฏ€๋กœ, ์ฝ”๋ฉ˜ํŠธ๋Š” ํŒŒ์ผ ๊ธฐ๋ฐ˜ ๋ž˜ํผ๋ฅผ ํ‘œ์ค€์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. + +```bash +# ๊ถŒ์žฅ: ํŒŒ์ผ/STDIN ๊ธฐ๋ฐ˜ ์ฝ”๋ฉ˜ํŠธ ๋“ฑ๋ก (์ค„๋ฐ”๊ฟˆ ๋ณด์กด) +cat > /tmp/review.md <<'EOF' +๋ฆฌ๋ทฐ ๋ฐ˜์˜ ์™„๋ฃŒํ–ˆ์Šต๋‹ˆ๋‹ค. + +- ํ•ญ๋ชฉ 1 +- ํ•ญ๋ชฉ 2 +EOF + +scripts/tea_comment.sh 374 /tmp/review.md +# ๋˜๋Š” +cat /tmp/review.md | scripts/tea_comment.sh 374 - +``` + ๊ถŒ์žฅ ํŒจํ„ด: ```bash diff --git a/scripts/tea_comment.sh b/scripts/tea_comment.sh new file mode 100755 index 0000000..1d4ca04 --- /dev/null +++ b/scripts/tea_comment.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# Safe helper for posting multiline Gitea comments without escaped-newline artifacts. + +set -euo pipefail + +if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ] || [ "$#" -lt 2 ]; then + cat <<'EOF' +Usage: + scripts/tea_comment.sh [repo] + +Examples: + scripts/tea_comment.sh 374 /tmp/comment.md + cat /tmp/comment.md | scripts/tea_comment.sh 374 - jihoson/The-Ouroboros + +Notes: + - Use file/stdin input to preserve real newlines. + - Passing inline strings with "\n" is intentionally avoided by this helper. +EOF + exit 1 +fi + +INDEX="$1" +BODY_SOURCE="$2" +REPO="${3:-jihoson/The-Ouroboros}" + +if [ "$BODY_SOURCE" = "-" ]; then + BODY="$(cat)" +else + if [ ! -f "$BODY_SOURCE" ]; then + echo "[FAIL] body file not found: $BODY_SOURCE" >&2 + exit 1 + fi + BODY="$(cat "$BODY_SOURCE")" +fi + +if [ -z "$BODY" ]; then + echo "[FAIL] empty comment body" >&2 + exit 1 +fi + +# Guard against the common escaped-newline mistake. +if [[ "$BODY" == *"\\n"* ]] && [[ "$BODY" != *$'\n'* ]]; then + echo "[FAIL] body appears to contain escaped newlines (\\n) instead of real line breaks" >&2 + echo "Use a multiline file/heredoc and pass that file to scripts/tea_comment.sh" >&2 + exit 1 +fi + +YES="" ~/bin/tea comment "$INDEX" --repo "$REPO" "$BODY" + diff --git a/scripts/validate_governance_assets.py b/scripts/validate_governance_assets.py index 79bc882..012138a 100644 --- a/scripts/validate_governance_assets.py +++ b/scripts/validate_governance_assets.py @@ -215,6 +215,7 @@ def main() -> int: [ "Session Handover Gate (Mandatory)", "session_handover_check.py --strict", + "scripts/tea_comment.sh", ], errors, ) @@ -223,6 +224,8 @@ def main() -> int: [ "Session Handover Preflight (Mandatory)", "session_handover_check.py --strict", + "Comment Newline Escaping", + "scripts/tea_comment.sh", ], errors, )