Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions .agent/scripts/quality-loop-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -226,24 +226,40 @@ get_pending_checks() {
# Arguments:
# $1 - Loop type (preflight, pr-review, postflight)
# $2 - Max iterations
# $3 - Options string
# $3 - Options string (key=value pairs separated by commas)
# Returns: 0
# Side effects: Creates .claude/quality-loop.local.md
# Side effects: Creates .agent/loop-state/quality-loop.local.md
create_state() {
local loop_type="$1"
local max_iterations="$2"
local options="$3"
local options_str="$3"

mkdir -p "$STATE_DIR"


# Convert options string to YAML object format
# Input: "auto_fix=true,wait_for_ci=false" -> " auto_fix: true\n wait_for_ci: false"
local options_yaml=""
if [[ -n "$options_str" ]]; then
options_yaml=$(echo "$options_str" | tr ',' '\n' | while IFS='=' read -r key value; do
[[ -z "$key" ]] && continue
# Handle boolean and numeric values without quotes
if [[ "$value" == "true" || "$value" == "false" || "$value" =~ ^[0-9]+$ ]]; then
echo " $key: $value"
else
echo " $key: \"$value\""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current implementation for quoting string values is not fully robust. It will produce invalid YAML if an option's value contains a double quote (") or a backslash (\). This could lead to YAML parsing errors, similar to the issue this PR aims to resolve. To make the value handling more robust, you should escape backslashes and double quotes before wrapping the value in quotes.

Suggested change
echo " $key: \"$value\""
value=${value//\\/\\\\}
value=${value//\"/\\\"}
echo " $key: \"$value\""

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value is double-quoted but not YAML-escaped, so values containing " or newlines could produce invalid frontmatter; consider sanitizing/escaping if any option values can be user-controlled.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

fi
done)
fi

cat > "$STATE_FILE" << EOF
---
type: $loop_type
iteration: 1
max_iterations: $max_iterations
status: running
started_at: "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
options: "$options"
options:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If options_str is empty, this will emit options: with a null value; if OpenCode strictly expects a record/mapping here, this may still fail schema validation in the no-options case.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

$options_yaml
checks_passed: []
checks_failed: []
fixes_applied: 0
Expand Down
Loading