Skip to content

Commit 9b01484

Browse files
konsta95claude
andcommitted
plugin-dev: walk anchored mapping headers; count a block indentation indicator from its key
Fifth review of the validator (two findings, each shown against the previous commit with a fresh runtime observation): - `metadata: &meta` — a mapping header carrying only a node property — was taken for a scalar, so the first pass skipped the keys under it and an anchor defined there was never seen; `description: *trigger` then read as the literal `*trigger`. A header whose value is empty after its properties is walked into. - An explicit indentation indicator on a block scalar (`>2-`, `|2-`) was counted from column 0. YAML counts it from the indentation of the node's parent, so for an anchored block under a key indented two spaces the content starts at four; the text kept two spaces and a stray newline. The indicator is now added to the owning key's indent (zero for the description key itself, so nothing changes there). validate-agent.test.sh adds the three shapes (r36-r38): 92 shapes with the verdict equal to the product's plus policy on 92/92, text equal to the runtime's on 69/69. Against the previous commit's script r36-r38 fail. The suite passes under gawk, mawk, busybox awk and BWK awk. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 3627abc commit 9b01484

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎plugins/plugin-dev/skills/agent-development/scripts/validate-agent.sh‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ read_description() {
229229
if (hdr ~ /^[ \t]*(#.*)?$/) {
230230
kind = "block"; style = substr(val, 1, 1); flags = substr(val, 2); sub(/[ \t].*$/, "", flags)
231231
chomp = (flags ~ /-/) ? "strip" : (flags ~ /\+/) ? "keep" : "clip"
232-
if (match(flags, /[1-9]/)) ind = substr(flags, RSTART, 1) + 0
232+
if (match(flags, /[1-9]/)) ind = base_indent + substr(flags, RSTART, 1)
233233
state = "block"; return
234234
}
235235
kind = "invalid"; state = "done"; return
@@ -285,6 +285,7 @@ read_description() {
285285
na++; anchor_name[na] = name; anchor_line[na] = i; anchor_indent[na] = d; anchor_val[na] = val; anchor_valraw[na] = vraw
286286
}
287287
v = val; sub(/^[&!][^ \t]*[ \t]*/, "", v); sub(/^[&!][^ \t]*[ \t]*/, "", v)
288+
if (v ~ /^[ \t]*$/ || v ~ /^#/) continue
288289
if (v ~ /^["\047]/) { q = substr(v, 1, 1); if (!closes(substr(v, 2))) { inq = 1; continue } }
289290
skip_indent = d
290291
}

‎plugins/plugin-dev/skills/agent-development/scripts/validate-agent.test.sh‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@
7171
# was not collected, so `description: *trigger` read as the literal `*trigger`
7272
# quoted-retry `"description": |-` in a file whose other line triggers the loader's retry was
7373
# reported unreadable; the retry rewrites bare-key lines only, so the block stays
74+
# anchored-map `metadata: &meta` (a mapping header carrying only a node property) was taken
75+
# for a scalar, so the anchors defined under it were skipped
76+
# block-indent an explicit indentation indicator (`>2-`, `|2-`) on a nested anchored block was
77+
# counted from column 0 instead of from the key's indent, leaving two spaces and
78+
# a stray newline in the text
7479
#
7580
# Requirements: Claude Code 2.1.259 or newer on PATH (for `claude plugin validate --json`) and
7681
# jq. Without them the suite FAILS; it never skips, because a skipped suite reads as green.
@@ -472,6 +477,27 @@ metadata:
472477
other: value
473478
description: *trigger
474479
E
480+
mk r36-anchored-map <<'E'
481+
metadata: &meta
482+
summary: &trigger Use this agent when testing behavior. <example>alias</example>
483+
description: *trigger
484+
E
485+
mk r37-nested-folded-indent <<'E'
486+
metadata:
487+
summary: &trigger >2-
488+
Use this agent when
489+
testing behavior. <example>folded</example>
490+
other: value
491+
description: *trigger
492+
E
493+
mk r38-nested-literal-indent <<'E'
494+
metadata:
495+
summary: &trigger |2-
496+
Use this agent when testing behavior.
497+
<example>literal</example>
498+
other: value
499+
description: *trigger
500+
E
475501
printf -- '---\nname: r20-dq-escaped-tab-char\ndescription: "Use this agent when\\\tthe user asks <example>x</example>"\nmodel: sonnet\ncolor: blue\n---\n\n%s\n' "$BODY" > "$CORPUS/agents/r20-dq-escaped-tab-char.md"
476502
printf -- '---\r\nname: h14-crlf-dq-multi\r\ndescription: "Use this agent when the user asks for a test.\r\n <example>crlf quoted</example>"\r\nmodel: sonnet\r\ncolor: blue\r\n---\r\n\r\n%s\r\n' "$BODY" > "$CORPUS/agents/h14-crlf-dq-multi.md"
477503
printf -- '---\r\nname: h16-crlf-plain-multi\r\ndescription: Use this agent when the user asks for a test.\r\n <example>crlf plain</example>\r\nmodel: sonnet\r\ncolor: blue\r\n---\r\n\r\n%s\r\n' "$BODY" > "$CORPUS/agents/h16-crlf-plain-multi.md"
@@ -615,6 +641,9 @@ r32-quoted-plain-retry Use this agent when testing behavior. <example>plain</exa
615641
r33-nested-anchor Use this agent when testing behavior. <example>alias</example>
616642
r34-nested-anchor-block Use this agent when testing behavior. <example>nested</example>
617643
r35-nested-anchor-next-line Use this agent when testing behavior. <example>next</example>
644+
r36-anchored-map Use this agent when testing behavior. <example>alias</example>
645+
r37-nested-folded-indent Use this agent when testing behavior. <example>folded</example>
646+
r38-nested-literal-indent Use this agent when testing behavior.\n<example>literal</example>
618647
TABLE
619648
if [ $text_ok -eq $text_total ]; then pass "description text matches the runtime on $text_ok/$text_total shapes"; else flunk "description text: $text_ok/$text_total shapes match the runtime"; fi
620649

0 commit comments

Comments
 (0)