-
Notifications
You must be signed in to change notification settings - Fork 9
simple script to parse claude's json messages #1989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3323225 to
304ef30
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 2 files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 2 files
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="scripts/extract-text.sh">
<violation number="1" location="scripts/extract-text.sh:2">
Filtering on a top-level type of "assistant" means the script never forwards Claude streaming events (which are typed message_start/message_delta/etc.), so it outputs nothing. Please match on the assistant role and feed the real content structure to jq.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
| @@ -0,0 +1,2 @@ | |||
| #!/usr/bin/env bash | |||
| grep --line-buffered -E '^\{"type":"assistant"' "$@" | jq --unbuffered -r '.message.content[]? | select(.type=="text") | .text' | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filtering on a top-level type of "assistant" means the script never forwards Claude streaming events (which are typed message_start/message_delta/etc.), so it outputs nothing. Please match on the assistant role and feed the real content structure to jq.
Prompt for AI agents
Address the following comment on scripts/extract-text.sh at line 2:
<comment>Filtering on a top-level type of "assistant" means the script never forwards Claude streaming events (which are typed message_start/message_delta/etc.), so it outputs nothing. Please match on the assistant role and feed the real content structure to jq.</comment>
<file context>
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+grep --line-buffered -E '^\{"type":"assistant"' "$@" | jq --unbuffered -r '.message.content[]? | select(.type=="text") | .text'
</file context>
Summary by cubic
Add a small bash script to parse Claude JSON logs and stream only assistant text content.
Works with stdin or files; uses line-buffered grep and unbuffered jq for real-time output.
Written for commit 93f7b19. Summary will update automatically on new commits.