Skip to content

Commit 84e76ed

Browse files
okamoto-awsShintaro Okamoto
andauthored
fix: blog draft — file output instead of stdout parsing (#68)
* fix: strip ANSI escape sequences from Kiro CLI output, strengthen instruction priority * fix: add NO_COLOR/TERM env and debug output to blog draft workflow * fix: have Kiro CLI write blog draft to file instead of stdout stdout parsing was unreliable (ANSI codes, empty output). Instead, instruct Kiro CLI to write directly to /tmp/blog-draft.md. --------- Co-authored-by: Shintaro Okamoto <shintaok@amazon.com>
1 parent c6d34a1 commit 84e76ed

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

.github/workflows/blog-draft.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ jobs:
5454
KIRO_API_KEY: ${{ secrets.KIRO_API_KEY }}
5555
PR_NUMBERS: ${{ inputs.pr_numbers }}
5656
BLOG_THEME: ${{ inputs.blog_theme }}
57+
NO_COLOR: "1"
58+
TERM: dumb
5759
run: |
5860
INSTRUCTION=""
5961
if [ -f /tmp/zenn-blog/instruction.md ]; then
@@ -87,16 +89,16 @@ jobs:
8789
PR データ:
8890
${PR_DATA}
8991
90-
Markdown のみを出力してください。余計な説明やコメントは不要です。"
92+
出力先: /tmp/blog-draft.md にMarkdownファイルとして書き出してください。
93+
ファイルの1行目に filename: sdpm-xxx.md の形式でファイル名を記載してください。"
9194
92-
kiro-cli chat --no-interactive --trust-all-tools "$PROMPT" > /tmp/blog-draft-raw.txt 2>/dev/null
95+
kiro-cli chat --no-interactive --trust-all-tools "$PROMPT" 2>/dev/null
9396
94-
# Strip ANSI escape sequences and TUI artifacts
95-
sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g; s/\x1b\][^\x07]*\x07//g; s/\[0m//g; s/\[2K//g; s/\[1G//g; s/\[1A//g; s/\[\?25[lh]//g' /tmp/blog-draft-raw.txt > /tmp/blog-draft-clean.txt
97+
echo "Output file: $(wc -c < /tmp/blog-draft.md 2>/dev/null || echo 'NOT FOUND') bytes"
9698
97-
grep '^> ' /tmp/blog-draft-clean.txt | sed 's/^> //' > /tmp/blog-draft.md
9899
if [ ! -s /tmp/blog-draft.md ]; then
99-
cp /tmp/blog-draft-clean.txt /tmp/blog-draft.md
100+
echo "::error::Kiro CLI did not produce /tmp/blog-draft.md"
101+
exit 1
100102
fi
101103
102104
FILENAME=$(head -5 /tmp/blog-draft.md | grep -oP 'filename:\s*\K\S+' || echo "")

0 commit comments

Comments
 (0)