Skip to content

Commit ce775fc

Browse files
authored
Carry forward seam doctor follow-up fixes (#4171)
## Summary - carry forward the post-merge #4121 seam-doctor/adoption fixes that landed on the closed branch after #4121 was squash-merged at `68db6f1` - teach `agent-workflow-seam-doctor` to scan 3+ backtick/tilde executable fences, reject too-short closers, accept same-character closers at least as long as the opener, reject info strings on closing fences, handle CRLF closers, and parse spaced info-string languages - clarify user-installed shared skill adoption: install `workflows/` with `skills/`, or keep repo-local workflow copies/launchers for skills that reference `.agents/workflows/...` - document the shared-pack status/upgrade path for Codex and Claude installs - keep the React on Rails compatibility copy aligned with `shakacode/agent-workflows@d38645b` ## Rationale #4121 created and referenced the public shared workflow repo, but two late P2 review findings arrived after the merged head. The shared repo already contains the fixes; this PR keeps the React on Rails compatibility copy and adoption docs in sync with the published pack. Current-head review on this follow-up also tightened the CommonMark closing-fence behavior, now fixed here and in the shared repo. The shared pack now also includes host-aware install/status/upgrade helpers inspired by the gstack upgrade flow: explicit status tokens, Codex/Claude host targets, network disclosure, rollback if a consumer seam validation fails, and preservation of unrelated user-installed agent files. Original #4121 review threads: - #4121 (comment) - #4121 (comment) ## Changelog Not user-visible; agent workflow docs/tooling only. ## Validation - `ruby .agents/bin/agent-workflow-seam-doctor-test.rb` -> 39 runs, 98 assertions, 0 failures - `.agents/bin/agent-workflow-seam-doctor --shared /Users/justin/codex/agent-workflows` -> PASS - `(cd /Users/justin/codex/agent-workflows && bin/validate)` -> PASS at `d38645b` - `git diff --check` in both `react_on_rails` and `agent-workflows` -> clean - `bin/ci-local --changed` -> docs-only, Docs Sidebar Check passed, no further CI needed - pre-commit hook -> trailing newlines, offline markdown links, Prettier passed - pre-push hook -> branch RuboCop no offenses; online markdown links 29 OK <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Changes are limited to agent workflow tooling and internal documentation; no application runtime, auth, or user-facing product code paths are modified. > > **Overview** > Syncs the repo’s agent-workflow compatibility copy with post-#4121 fixes from `shakacode/agent-workflows`, focused on **seam validation** and **adoption docs**. > > **`agent-workflow-seam-doctor`** now parses Markdown code fences closer to CommonMark: 3+ backtick/tilde openers, closers must match character and be at least as long as the opener (shorter closers stay inside the fence), closing lines with info strings do not close a fence, CRLF closers work via `chomp`, and spaced info strings (e.g. ` ``` bash`) still mark executable fences. A large new test suite covers long fences, mismatched delimiters, and non-executable fenced content. > > **Docs/skills** broaden “Codex batch” wording to **agent / Codex / Claude** batches in `AGENTS.md`, `pr-batch`, and contributor guides. Adoption and design docs add **`agent-workflows-status`** and **`upgrade-agent-workflows`** for Codex and Claude hosts, stress installing **`workflows/`** alongside **`skills/`**, and link the shared pack’s installation/upgrade guide. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 924b4eb. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 2c40bf8 commit ce775fc

8 files changed

Lines changed: 245 additions & 23 deletions

File tree

.agents/bin/agent-workflow-seam-doctor

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,31 @@ module AgentWorkflowSeamDoctor
206206
end
207207

208208
def update_fence_state(line, in_fence, fence_delimiter)
209-
fence = line.match(/^ {0,3}(```|~~~)([[:alnum:]_-]*)(?:\s.*)?$/)
209+
line = line.chomp
210+
211+
if in_fence
212+
closing_fence = line.match(/^ {0,3}(`{3,}|~{3,})[ \t]*$/)
213+
return nil if closing_fence.nil?
214+
215+
delimiter = closing_fence[1]
216+
# Mismatched closers stay inside the current fence.
217+
return nil unless closing_fence_delimiter?(delimiter, fence_delimiter)
218+
219+
return [false, false, nil]
220+
end
221+
222+
fence = line.match(/^ {0,3}(`{3,}|~{3,})(?:[ \t]*([[:alnum:]_-]+))?(?:[ \t].*)?$/)
210223
return nil if fence.nil?
211224

212225
delimiter = fence[1]
213-
# Mismatched closers stay inside the current fence.
214-
return nil if in_fence && delimiter != fence_delimiter
215-
return [false, false, nil] if in_fence
216-
217226
language = fence[2].to_s.downcase
218227
[true, EXECUTABLE_FENCE_LANGS.include?(language), delimiter]
219228
end
220229

230+
def closing_fence_delimiter?(delimiter, fence_delimiter)
231+
delimiter[0] == fence_delimiter[0] && delimiter.length >= fence_delimiter.length
232+
end
233+
221234
def placeholders_from_line(line, in_fence:, executable_fence:)
222235
placeholders = []
223236

.agents/bin/agent-workflow-seam-doctor-test.rb

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ def test_executable_placeholder_in_titled_code_fence_fails
279279
assert_includes out, "<follow-up prefix>"
280280
end
281281
end
282+
end
283+
284+
class AgentWorkflowSeamDoctorFenceTest < Minitest::Test
285+
include AgentWorkflowSeamDoctorTestHelpers
282286

283287
def test_executable_placeholder_in_tilde_code_fence_fails
284288
with_repo do |root|
@@ -296,6 +300,22 @@ def test_executable_placeholder_in_tilde_code_fence_fails
296300
end
297301
end
298302

303+
def test_executable_placeholder_in_long_code_fence_fails
304+
with_repo do |root|
305+
write_agents(root)
306+
write_skill(root, <<~MARKDOWN)
307+
````bash
308+
gh issue create --title "<follow-up prefix> Review feedback from PR #123"
309+
````
310+
MARKDOWN
311+
312+
out, status = run_doctor(root)
313+
314+
refute status.success?
315+
assert_includes out, "<follow-up prefix>"
316+
end
317+
end
318+
299319
def test_mismatched_fence_delimiter_does_not_close_executable_fence
300320
with_repo do |root|
301321
write_agents(root)
@@ -312,6 +332,139 @@ def test_mismatched_fence_delimiter_does_not_close_executable_fence
312332
assert_includes out, "<follow-up prefix>"
313333
end
314334
end
335+
end
336+
337+
class AgentWorkflowSeamDoctorFenceLengthTest < Minitest::Test
338+
include AgentWorkflowSeamDoctorTestHelpers
339+
340+
def test_shorter_closing_fence_does_not_close_long_executable_fence
341+
with_repo do |root|
342+
write_agents(root)
343+
write_skill(root, <<~MARKDOWN)
344+
````bash
345+
```
346+
gh issue create --title "<follow-up prefix> Review feedback from PR #123"
347+
````
348+
MARKDOWN
349+
350+
out, status = run_doctor(root)
351+
352+
refute status.success?
353+
assert_includes out, "<follow-up prefix>"
354+
end
355+
end
356+
357+
def test_shorter_closing_tilde_fence_does_not_close_long_tilde_fence
358+
with_repo do |root|
359+
write_agents(root)
360+
write_skill(root, <<~MARKDOWN)
361+
~~~~bash
362+
~~~
363+
gh issue create --title "<follow-up prefix> Review feedback from PR #123"
364+
~~~~
365+
MARKDOWN
366+
367+
out, status = run_doctor(root)
368+
369+
refute status.success?
370+
assert_includes out, "<follow-up prefix>"
371+
end
372+
end
373+
374+
def test_longer_closing_fence_closes_long_executable_fence
375+
with_repo do |root|
376+
write_agents(root)
377+
write_skill(root, <<~MARKDOWN)
378+
````bash
379+
echo ok
380+
`````
381+
<follow-up prefix>
382+
MARKDOWN
383+
384+
out, status = run_doctor(root)
385+
386+
assert status.success?, out
387+
end
388+
end
389+
390+
def test_longer_closing_tilde_fence_closes_long_tilde_fence
391+
with_repo do |root|
392+
write_agents(root)
393+
write_skill(root, <<~MARKDOWN)
394+
~~~~bash
395+
echo ok
396+
~~~~~
397+
<follow-up prefix>
398+
MARKDOWN
399+
400+
out, status = run_doctor(root)
401+
402+
assert status.success?, out
403+
end
404+
end
405+
406+
def test_closing_fence_with_info_string_stays_inside_executable_fence
407+
with_repo do |root|
408+
write_agents(root)
409+
write_skill(root, <<~MARKDOWN)
410+
````bash
411+
````bash
412+
gh issue create --title "<follow-up prefix> Review feedback from PR #123"
413+
````
414+
MARKDOWN
415+
416+
out, status = run_doctor(root)
417+
418+
refute status.success?
419+
assert_includes out, "<follow-up prefix>"
420+
end
421+
end
422+
423+
def test_crlf_closing_fence_closes_executable_fence
424+
with_repo do |root|
425+
write_agents(root)
426+
write_skill(root, "```bash\r\necho ok\r\n```\r\n<follow-up prefix>\r\n")
427+
428+
out, status = run_doctor(root)
429+
430+
assert status.success?, out
431+
end
432+
end
433+
434+
def test_spaced_info_string_on_long_non_executable_fence_is_not_executable
435+
with_repo do |root|
436+
write_agents(root)
437+
write_skill(root, <<~MARKDOWN)
438+
```` markdown
439+
<follow-up prefix>
440+
````
441+
MARKDOWN
442+
443+
out, status = run_doctor(root)
444+
445+
assert status.success?, out
446+
end
447+
end
448+
449+
def test_spaced_info_string_on_long_executable_fence_is_executable
450+
with_repo do |root|
451+
write_agents(root)
452+
write_skill(root, <<~MARKDOWN)
453+
```` bash
454+
gh issue create --title "<follow-up prefix> Review feedback from PR #123"
455+
````
456+
MARKDOWN
457+
458+
out, status = run_doctor(root)
459+
460+
refute status.success?
461+
assert_includes out, "<follow-up prefix>"
462+
end
463+
end
464+
end
465+
466+
class AgentWorkflowSeamDoctorFenceContentTest < Minitest::Test
467+
include AgentWorkflowSeamDoctorTestHelpers
315468

316469
def test_four_space_indented_fence_does_not_open_executable_fence
317470
with_repo do |root|

.agents/skills/pr-batch/SKILL.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: pr-batch
3-
description: Plan and safely launch batches of issue or PR work, especially when using Codex subagents, multiple worktrees, or multiple machines. Use when the user asks to run a Codex batch, process several issues or PRs, split work across agents or machines, or turn filters into a PR-processing plan and /goal prompt.
3+
description: Plan and safely launch batches of issue or PR work, especially when using Codex or Claude subagents, multiple worktrees, or multiple machines. Use when the user asks to run an agent batch, Codex batch, Claude batch, process several issues or PRs, split work across agents or machines, or turn filters into a PR-processing plan and /goal prompt.
44
argument-hint: '[exact issue/PR numbers or filters]'
55
---
66

@@ -16,7 +16,9 @@ Memorable invocation:
1616

1717
```text
1818
$pr-batch
19+
Run an agent batch
1920
Run a Codex batch
21+
Run a Claude batch
2022
```
2123

2224
Run `git fetch --prune origin main`, then use `.agents/workflows/pr-processing.md` as the deeper operating model for each issue, PR, review-fix pass, or merge-readiness item. If repo-local `.agents/skills/...` or `.agents/workflows/pr-processing.md` is missing in the checkout but present on `origin/main`, update the worktree before launching workers; if it remains missing, report repo workflow state as `UNKNOWN`.

.agents/workflows/pr-processing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ For high-concurrency issue or PR batches, use `.agents/skills/pr-batch/SKILL.md`
66

77
```text
88
$pr-batch
9+
Run an agent batch
910
Run a Codex batch
11+
Run a Claude batch
1012
```
1113

1214
For assistants without skill support, follow the high-concurrency batch launch rules below before using the rest of this workflow.

AGENTS.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ React on Rails is a Ruby gem + npm package that integrates React with Ruby on Ra
1111
skill directory and reused across repos; they must resolve repo-specific
1212
values through this repo's `AGENTS.md` seam. The canonical shared source is
1313
[`shakacode/agent-workflows`](https://github.com/shakacode/agent-workflows).
14+
Use that repo's `agent-workflows-status` and `upgrade-agent-workflows`
15+
helpers to keep installed Codex or Claude homes current.
1416
- `.agents/skills/`: repo-local skill copies/overrides plus repo-specific skills;
1517
`.claude/skills` is a symlink here so Claude Code exposes the same workflows as
1618
slash commands in this checkout.
@@ -35,8 +37,8 @@ React on Rails is a Ruby gem + npm package that integrates React with Ruby on Ra
3537
- When deciding whether an issue or proposed fix is worth doing, use `.agents/skills/evaluate-issue/SKILL.md`; a short invocation is `$evaluate-issue` or "Is this issue worth fixing?"
3638
- When the user wants a ready prompt for review-only GitHub issue triage or an all-open-issues audit, use `.agents/skills/plan-issue-triage/SKILL.md`; a short invocation is `$plan-issue-triage` or "Plan an issue triage"
3739
- When the user wants a generated whole-surface issue/PR inventory, dependency graph, and capacity-aware batch split, use `.agents/skills/triage/SKILL.md`; a short invocation is `$triage` or "Run triage"
38-
- When the user wants to choose issues or PRs for a future Codex batch, use `.agents/skills/plan-pr-batch/SKILL.md` to produce a ready `$pr-batch` goal; a short invocation is `$plan-pr-batch` or "Plan a Codex batch"
39-
- When the user wants a multi-issue or multi-PR Codex batch, use `.agents/skills/pr-batch/SKILL.md`; a short invocation is `$pr-batch` or "Run a Codex batch"
40+
- When the user wants to choose issues or PRs for a future agent/Codex/Claude batch, use `.agents/skills/plan-pr-batch/SKILL.md` to produce a ready `$pr-batch` goal; a short invocation is `$plan-pr-batch` or "Plan a PR batch"
41+
- When the user wants a multi-issue or multi-PR agent/Codex/Claude batch, use `.agents/skills/pr-batch/SKILL.md`; a short invocation is `$pr-batch`, "Run an agent batch", "Run a Codex batch", or "Run a Claude batch"
4042
- When the user wants to stop or cancel an in-flight Codex/Claude batch (for example to relaunch it with updated skills), follow the **Cancelling Or Stopping A Batch** protocol in `.agents/workflows/pr-processing.md#cancelling-or-stopping-a-batch`; there is no short skill invocation for this coordinator action
4143
- When the user wants to audit merged batch work, missed reviews, release-candidate risk, or possible bad merges, use `.agents/skills/post-merge-audit/SKILL.md`; reusable prompts live in `.agents/workflows/post-merge-audit.md`
4244
- When the user wants an adversarial PR review, red-team review, Claude/Codex comparison review, or a stricter pre-merge gate, use `.agents/skills/adversarial-pr-review/SKILL.md`; reusable prompts live in `.agents/workflows/adversarial-pr-review.md`
@@ -123,6 +125,19 @@ on `origin/main`, update the worktree before continuing; if it is still missing,
123125
report the repo workflow state as `UNKNOWN` instead of silently using a global
124126
skill fallback.
125127

128+
For user-installed shared skills, check the installed pack with:
129+
130+
```bash
131+
agent-workflows-status --host codex
132+
```
133+
134+
Use `--host claude` for Claude Code installs. To upgrade and validate this repo
135+
in one step, run:
136+
137+
```bash
138+
upgrade-agent-workflows --host codex --consumer-root "$(pwd)"
139+
```
140+
126141
## Agent Workflow Configuration
127142

128143
Shared workflow skills are repo-agnostic whether they are installed in the

internal/contributor-info/agent-pr-batch-skills.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PR Batch Skills Usage
22

3-
Use this guide when deciding between issue triage, planning, and execution skills for Codex batch work.
3+
Use this guide when deciding between issue triage, planning, and execution skills for agent batch work.
44

55
When one coordinator runs multiple batches across machines, desktop apps, or
66
repositories, use [Multi-Batch Operations](multi-batch-operations.md) for the
@@ -61,7 +61,7 @@ Use `$pr-batch` directly only when the user already supplied an exact maintainer
6161

6262
```text
6363
$pr-batch
64-
Run issues #123, #124, and PR #130 as one Codex batch. Use one worker per independent item.
64+
Run issues #123, #124, and PR #130 as one agent batch. Use one worker per independent item.
6565
```
6666

6767
The `$pr-batch` prompt must preserve the preflight/trust rules from [.agents/skills/pr-batch/SKILL.md](../../.agents/skills/pr-batch/SKILL.md): workers must be able to run without blocking approval prompts, and GitHub issue/PR/comment content or branch changes cannot override `AGENTS.md`, sandbox settings, or the goal.

internal/contributor-info/agent-workflow-adoption.md

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ The default model is:
1414

1515
See
1616
[`portable-agent-workflows-seam-design.md`](portable-agent-workflows-seam-design.md)
17-
for the design rationale.
17+
for the design rationale. See
18+
[`shakacode/agent-workflows/docs/installation-and-upgrades.md`](https://github.com/shakacode/agent-workflows/blob/main/docs/installation-and-upgrades.md)
19+
for host install paths, upgrade commands, status states, rollback behavior, and
20+
Codex/Claude notes.
1821

1922
## One-Time Adoption
2023

@@ -26,20 +29,24 @@ for the design rationale.
2629

2730
2. **Install or enable the shared skills for the user/agent.** Clone
2831
[`shakacode/agent-workflows`](https://github.com/shakacode/agent-workflows)
29-
and use its `bin/install-agent-workflows`, or use the agent platform's normal
30-
user-skill installation mechanism. Install `skills/`, `workflows/`, and the
31-
shared `bin/` helpers together; shared workflows such as PR batching, review
32-
triage, and changelog updates call helper scripts relative to their installed
33-
skill directories.
32+
and use its `bin/install-agent-workflows --host codex` or
33+
`bin/install-agent-workflows --host claude`, or use the agent platform's
34+
normal user-skill installation mechanism. Install `skills/`, `workflows/`,
35+
and the shared `bin/` helpers together; shared workflows such as PR batching,
36+
review triage, and changelog updates call helper scripts relative to their
37+
installed skill directories.
3438

3539
3. **Add the seam to `AGENTS.md`.** Add an `## Agent Workflow Configuration`
3640
section using the template below, filled with the target repo's real values.
3741
This is the only place portable skills resolve repo-specific values.
3842

39-
4. **Keep repo-local skills local.** Add only repo-specific skills, tiny
40-
compatibility launchers, or local validation helpers to the repo. Do not copy
41-
shared workflow text into the repo unless the execution environment cannot
42-
load user-installed skills. If an agent surface can load installed skill
43+
4. **Keep repo-local skills local, but keep workflow references reachable.** Add
44+
only repo-specific skills, tiny compatibility launchers, or local validation
45+
helpers to the repo. Do not copy shared workflow text into the repo unless
46+
the execution environment cannot load user-installed skills. Do not run an
47+
installed-skill-only setup with only `skills/`: install `workflows/` too, or
48+
keep repo-local workflow copies/launchers for skills that still reference
49+
`.agents/workflows/...`. If an agent surface can load installed skill
4350
Markdown but cannot execute the installed skill's `bin/` helpers, keep a
4451
local helper copy or compatibility launcher for that skill.
4552

@@ -102,6 +109,32 @@ when required seam keys are missing or executable snippets in the repo-local or
102109
installed shared skill Markdown still contain unresolved seam placeholders such
103110
as `<follow-up prefix>`.
104111

112+
## Keeping The Installed Pack Current
113+
114+
Use `agent-workflows-status` to check the installed pack against the recorded
115+
source clone:
116+
117+
```bash
118+
agent-workflows-status --host codex
119+
```
120+
121+
Stable status tokens are `UP_TO_DATE`, `UPGRADE_AVAILABLE`, `NOT_INSTALLED`, and
122+
`CHECK_FAILED`. Add `--fetch` only when a network check against `origin` is
123+
intended.
124+
125+
Use `upgrade-agent-workflows` to update the source clone, reinstall, and run the
126+
seam doctor against this repo:
127+
128+
```bash
129+
upgrade-agent-workflows \
130+
--host codex \
131+
--consumer-root /path/to/react_on_rails
132+
```
133+
134+
The upgrade helper backs up the current install and restores it if reinstall or
135+
consumer seam validation fails. Use `--host claude` for Claude Code installs and
136+
`--no-fetch` when the source clone has already been updated locally.
137+
105138
## Shared Vs Repo-Local Skills
106139

107140
Shared portable skills include PR batching, review handling, post-merge audit,
@@ -149,6 +182,8 @@ fallback until a public backend spec exists.
149182

150183
## Validation Checklist
151184

185+
- `agent-workflows-status --host <codex|claude>` reports `UP_TO_DATE`, or the
186+
upgrade decision is recorded.
152187
- `agent-workflow-seam-doctor --shared <path-to-shakacode/agent-workflows>` passes.
153188
- Markdown formatting and link checks pass for edited docs.
154189
- Skill `bin/` unit tests pass when the repo carries local helper scripts.

0 commit comments

Comments
 (0)