Skip to content

chore(review): inline review/fix prompts and add ws-reset workflow helper#1695

Merged
senamakel merged 3 commits into
tinyhumansai:mainfrom
senamakel:chore/review-prompts-ws-reset
May 14, 2026
Merged

chore(review): inline review/fix prompts and add ws-reset workflow helper#1695
senamakel merged 3 commits into
tinyhumansai:mainfrom
senamakel:chore/review-prompts-ws-reset

Conversation

@senamakel
Copy link
Copy Markdown
Member

@senamakel senamakel commented May 14, 2026

Summary

  • Extract pnpm review review and pnpm review fix agent prompts into self-contained templates under scripts/review/prompts/ so they no longer rely on Claude Code's named subagent registry — works with any LLM CLI via --agent.
  • Detect merge conflicts at sync time and inject a tailored "resolve-first" or "flag-as-blocker" block into the prompt depending on whether the run is fix (apply) or review (review-only).
  • Tighten push guidance in the fix prompt to point at the contributor's fork (already wired via pushRemote in sync_pr) so commits land on the actual PR head branch, not the maintainer's origin copy.
  • Add pnpm resetscripts/ws-reset.sh to hard-reset local main to upstream/main and refresh submodules, with a working-tree-dirty safety check (--force to override).
  • Add .claude/commands/ws-reset.md as the slash-command surface for the same flow inside Claude Code.

Problem

The previous pnpm review review / pnpm review fix scripts produced a one-liner prompt that told the agent to "use the pr-reviewer / pr-manager-lite agent" — only meaningful inside Claude Code where those named subagents exist. Other CLIs (codex, gemini, etc.) couldn't drive the same workflow.

Additionally, when the merged-in main introduced conflicts during sync_pr, the script only logged a warning. The downstream agent had no idea conflicts existed and would silently produce broken reviews / push half-merged trees.

Lastly, no quick way to reset the workspace back to a clean main after PR-review sessions.

Solution

  • Pull the full CodeRabbit-style review workflow and the review-fix-push workflow into editable Markdown templates (scripts/review/prompts/{review,fix}.md) with __PR__ / __REPO__ / __HEAD_REPO__ / __HEAD_BRANCH__ / __CONFLICT_BLOCK__ placeholders.
  • sync_pr now uses git merge --no-edit main and detects unresolved conflicts via git diff --name-only --diff-filter=U, exporting REVIEW_HAS_CONFLICTS and REVIEW_CONFLICT_FILES for callers.
  • review.sh / fix.sh substitute placeholders with awk (safer than sed for multi-line blocks) and inject context-appropriate conflict instructions.
  • scripts/ws-reset.sh bails out on a dirty tree unless --force is passed, then git fetch upstream, git checkout main, git reset --hard upstream/main, git submodule update --init --recursive.

Submission Checklist

  • N/A: workflow / tooling change — no behavior tests; manual verification via pnpm review review/fix and pnpm reset.
  • N/A: no production code paths touched; coverage gate unaffected.
  • N/A: no feature-matrix rows added/removed/renamed.
  • N/A: no feature IDs affected.
  • N/A: no new external network dependencies — all calls remain to gh / local git.
  • N/A: no release-cut surfaces touched.
  • N/A: no linked issue.

Impact

  • Runtime/platform: none — repo-level scripts and Claude Code slash command only. No production code changed.
  • Performance: none.
  • Security: none. pnpm reset is destructive on main but guarded by working-tree-dirty check; --force opt-in is required to override.
  • Compatibility: backwards-compatible. Old pnpm review review / pnpm review fix invocations work identically; the agent now receives a richer, agent-agnostic prompt.

Related

  • Closes:
  • Follow-up PR(s)/TODOs:

AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: chore/review-prompts-ws-reset
  • Commit SHA: 6e6ecff

Validation Run

  • N/A: workflow / tooling change — scripts are bash + markdown only, no app code touched.
  • N/A: no TypeScript code changed.
  • N/A: no focused tests applicable.
  • N/A: no Rust code changed.
  • N/A: no Tauri code changed.

Validation Blocked

  • command: N/A
  • error: N/A
  • impact: N/A

Behavior Changes

  • Intended behavior change: pnpm review review/fix now produces self-contained prompts (agent-agnostic) and surfaces merge conflicts to the agent.
  • User-visible effect: pnpm reset is now available; review-fix runs push to the contributor's fork (updating the actual PR) when run on a pr/<N> branch synced via sync_pr.

Parity Contract

  • Legacy behavior preserved: yes — old invocations work identically; default --agent claude continues to work.
  • Guard/fallback/dispatch parity checks: N/A — no dispatch paths changed.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): N/A
  • Canonical PR: N/A
  • Resolution: N/A

Summary by CodeRabbit

Release Notes

  • New Features

    • Added pnpm reset command to hard-reset workspace to upstream main and refresh submodules.
    • Enhanced PR review workflow with improved conflict detection and automatic conflict-file resolution guidance.
  • Improvements

    • Pre-push checks now provide clearer, conditional error guidance based on failure type—directing users to auto-fix formatting/lint issues or address manual failures.
  • Documentation

    • Updated documentation for workspace shortcuts and PR review workflow tools.

Review Change Stack

…lper

- Extract `pnpm review review` and `pnpm review fix` agent prompts into
  self-contained templates under `scripts/review/prompts/` so they no
  longer depend on Claude Code's named subagent registry (works with any
  LLM CLI via `--agent`).
- Detect merge conflicts at sync time and inject a tailored
  "resolve-first" or "flag-as-blocker" block into the prompt depending on
  whether the run is `fix` (apply) or `review` (review-only).
- Tighten push guidance in the fix prompt to point at the contributor's
  fork (already wired via `pushRemote` in `sync_pr`) so commits land on
  the actual PR head branch, not the maintainer's `origin` copy.
- Add `pnpm reset` -> `scripts/ws-reset.sh` to hard-reset local `main`
  to `upstream/main` and refresh submodules, with a working-tree-dirty
  safety check (`--force` to override).
- Add `.claude/commands/ws-reset.md` as the slash-command surface for
  the same flow inside Claude Code.
@senamakel senamakel requested a review from a team May 14, 2026 03:20
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

Warning

Rate limit exceeded

@senamakel has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 2 minutes and 26 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 531c52e3-98b7-4fbd-8453-06f95ae4e1f8

📥 Commits

Reviewing files that changed from the base of the PR and between 739eb76 and 95c4f80.

📒 Files selected for processing (6)
  • .claude/commands/ws-reset.md
  • scripts/shortcuts/review/fix.sh
  • scripts/shortcuts/review/lib.sh
  • scripts/shortcuts/review/prompts/review.md
  • scripts/shortcuts/review/review.sh
  • scripts/shortcuts/ws-reset.sh
📝 Walkthrough

Walkthrough

This PR refactors the codebase to support agent-agnostic, template-driven automation for PR review, PR fix, and issue work workflows. It introduces workspace reset utilities, adds merge conflict detection to PR sync, externalizes hardcoded prompts into Markdown templates with placeholder substitution, and provides new shortcut CLI scripts that orchestrate LLM-based review and fix tasks while preserving the ability to choose different AI agents.

Changes

Workspace reset, conflict-aware sync, and template-driven workflows

Layer / File(s) Summary
Workspace reset utility and integration
.claude/commands/ws-reset.md, package.json, scripts/shortcuts/ws-reset.sh
Introduces ws-reset.sh with strict Bash mode, --force and --help flags, pre-flight checks for Git state and upstream remote, and a guard against dirty working trees unless overridden. Registers pnpm reset entry point and includes command documentation.
PR sync conflict detection and environment export
scripts/shortcuts/review/lib.sh
Enhances sync_pr to detect merge conflicts when merging main into the PR branch, capturing unresolved file paths into REVIEW_CONFLICT_FILES on failed merge, and exporting REVIEW_HAS_CONFLICTS, REVIEW_CONFLICT_FILES, and REVIEW_PUSH_REMOTE for downstream use.
CodeRabbit-style review prompt template
scripts/shortcuts/review/prompts/review.md
Defines comprehensive PR review workflow covering metadata fetching, full-file content reading, multi-axis analysis (correctness, standards, testing, security, design, UX, documentation), finding classification by severity and confidence, and exact review body structure with approve/request-changes decision rules and guardrails.
PR fix playbook prompt template
scripts/shortcuts/review/prompts/fix.md
Provides nine-phase fix workflow: sanity checks, metadata/comment fetch, file reading and classification, fix application, quality suite execution (format/lint/typecheck/tests), commit/push with auto-fix handling, posting deferred items via gh api, structured final report, and guardrails for safe operations.
New shortcut entrypoint scripts for review and fix
scripts/shortcuts/review/review.sh, scripts/shortcuts/review/fix.sh
Agent-agnostic CLI scripts that parse PR number and optional --agent (defaulting to claude), load Markdown templates, conditionally inject conflict-warning blocks when REVIEW_HAS_CONFLICTS=1, substitute PR/repo/branch placeholders, and invoke the selected LLM agent with the fully constructed prompt.
Refactored old review/fix scripts to template-driven generation
scripts/review/review.sh, scripts/review/fix.sh
Updated to load Markdown templates instead of hardcoded prompts, validate template presence, conditionally build conflict-resolution blocks, and substitute placeholders via awk before appending user-provided extra-prompt.
Work issue-pickup workflow template and script
scripts/shortcuts/work/prompts/start.md, scripts/shortcuts/work/start.sh
Defines structured issue pickup workflow with implementation rules for Rust core, JSON-RPC E2E, and Tauri React UI; test expectations; debug logging conventions; and safety guardrails. Refactored start.sh to load template, safely escape multi-line issue body content, and substitute placeholders via awk.
Shortcuts infrastructure documentation
scripts/shortcuts/README.md, scripts/shortcuts/review/README.md, scripts/shortcuts/work/README.md, scripts/shortcuts/work/cli.sh
Adds comprehensive documentation for the shortcuts directory structure, describes prompt-template-driven design with placeholder substitution and agent-agnostic CLI forwarding, and updates all path references from scripts/review to scripts/shortcuts/review.
Enhanced pre-push hook error reporting
.husky/pre-push
Provides conditional, actionable failure guidance: format/lint failures advise git add -A && git commit before retry, while TypeScript/Rust/cmd-token failures note the lack of auto-fix paths. Maintains exit status 1 and wraps output with consistent delimiters.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • tinyhumansai/openhuman#849: Introduced the original scripts/review/* review workflow scripts; this PR refactors those scripts to use externalized templates and adds new scripts/shortcuts/review/* variants with conflict-aware instruction injection.

Poem

🐰 Templates tame the prompts wild and free,
Conflict blocks warn where merges be,
Shortcuts call the agents near,
Reset main with courage clear,
Workflows dance, at last so spry! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: extracting review/fix prompts into standalone templates and adding a ws-reset workflow helper script.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.claude/commands/ws-reset.md:
- Around line 8-15: The docs currently inline destructive git commands (git
fetch..., git checkout main, git reset --hard upstream/main, git submodule
update...) instead of using the guarded helper; replace that block with a single
call to the centralized script (bash scripts/ws-reset.sh) followed by git status
so the documentation uses scripts/ws-reset.sh (the guarded reset helper) and
avoids duplicating unsafe reset logic.

In `@scripts/review/fix.sh`:
- Line 52: The subshell call uses an unquoted expansion $(printf -- '- %s\n'
$REVIEW_CONFLICT_FILES) which breaks on filenames with spaces/globs; change it
to a quoted expansion or explicit iteration: either use $(printf -- '- %s\n'
"$REVIEW_CONFLICT_FILES") if REVIEW_CONFLICT_FILES is a single whitespace-safe
value, or (safer) replace with a loop like for f in
"${REVIEW_CONFLICT_FILES[@]}"; do printf -- '- %s\n' "$f"; done so printf
receives each conflict path as a single quoted argument (update the occurrence
of $(printf -- '- %s\n' $REVIEW_CONFLICT_FILES) accordingly).

In `@scripts/review/lib.sh`:
- Around line 120-124: The current merge failure path treats any git merge error
as a conflict; update the failed-merge branch to inspect actual unmerged files
(use git diff --name-only --diff-filter=U) and only set REVIEW_HAS_CONFLICTS and
REVIEW_CONFLICT_FILES when that list is non-empty (i.e., real conflicts); if
there are no unmerged files, exit/fail fast instead of continuing. Locate the if
! git merge --no-edit main; then block and change its body to compute the
unmerged files list, conditionally set REVIEW_HAS_CONFLICTS and
REVIEW_CONFLICT_FILES when non-empty, and otherwise abort the script with a
non-zero exit.

In `@scripts/review/prompts/review.md`:
- Line 149: Replace the unlabeled fenced code block that begins with "## PR
`#__PR__` — Review posted" by adding a language identifier (e.g., change the
opening "```" to "```text") so the block is labeled and markdownlint MD040 is
satisfied; ensure the closing fence remains "```" and no other content is
altered.

In `@scripts/review/review.sh`:
- Line 52: The printf invocation is expanding REVIEW_CONFLICT_FILES unquoted
which splits and glob-expands filenames; update the call that uses printf -- '-
%s\n' to safely expand REVIEW_CONFLICT_FILES by quoting the variable (or, if
REVIEW_CONFLICT_FILES is an array, use the array expansion form) so filenames
with spaces or glob chars are preserved—alternatively iterate over lines from
REVIEW_CONFLICT_FILES with a safe read (read -r) and call printf for each entry;
locate the printf line that references REVIEW_CONFLICT_FILES and replace the
unquoted expansion with a quoted/iterated-safe expansion.

In `@scripts/ws-reset.sh`:
- Around line 36-39: The current dirty-tree check using git diff --quiet HEAD --
misses untracked files; update the conditional that references the FORCE
variable to run git status --porcelain --untracked-files=all and treat any
non-empty output as a dirty tree, i.e., capture the status output and if it is
non-empty (and FORCE != 1) print the same error message and exit; locate the
check that uses the FORCE variable and the git diff command in the script and
replace it with a git status --porcelain --untracked-files=all based detection.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2e8267e4-2124-4f6a-baf9-2ad0af77a43a

📥 Commits

Reviewing files that changed from the base of the PR and between 5e6073b and 6e6ecff.

📒 Files selected for processing (8)
  • .claude/commands/ws-reset.md
  • package.json
  • scripts/review/fix.sh
  • scripts/review/lib.sh
  • scripts/review/prompts/fix.md
  • scripts/review/prompts/review.md
  • scripts/review/review.sh
  • scripts/ws-reset.sh

Comment thread .claude/commands/ws-reset.md
Comment thread scripts/shortcuts/review/fix.sh Outdated
Comment thread scripts/shortcuts/review/lib.sh
Comment thread scripts/shortcuts/review/prompts/review.md Outdated
Comment thread scripts/shortcuts/review/review.sh Outdated
Comment thread scripts/shortcuts/ws-reset.sh Outdated
- Move `scripts/review/`, `scripts/work/`, and `scripts/ws-reset.sh` under
  `scripts/shortcuts/` (preserved git history via `git mv`).
- Add `scripts/shortcuts/README.md` index documenting each shortcut and the
  shared design (prompts as Markdown templates with placeholders;
  `awk` substitution; agent-agnostic via `--agent`).
- Update `package.json` script paths and rewire `work/start.sh` to source
  `lib.sh` via the new relative path.
- Extract `pnpm work` agent prompt into `scripts/shortcuts/work/prompts/start.md`
  so it works with any LLM CLI (matches the `review` layout).
- Pre-push hook: keep the original "run all checks, accumulate, fail at
  end" structure, but emit a friendly closing message telling the user
  to re-commit and push after auto-fix paths. Split the message for
  format/lint (auto-fixed) vs. compile/Rust/cmd-tokens (must fix by hand).
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (4)
scripts/shortcuts/review/prompts/review.md (1)

149-149: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add a language tag to the fenced block.

Line 149 opens a code fence without a language, which can fail markdownlint MD040.

Proposed fix
-```
+```text
 ## PR `#__PR__` — Review posted
 ...
</details>

```shell
#!/bin/bash
set -euo pipefail
nl -ba scripts/shortcuts/review/prompts/review.md | sed -n '146,153p'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/shortcuts/review/prompts/review.md` at line 149, The markdown code
fence opened on the snippet in review.md lacks a language tag (```), which
triggers markdownlint MD040; replace the bare fence with a tagged fence (e.g.,
change the opening "```" to "```text") so the fenced block is explicitly labeled
— update the fenced block around the PR review template (the block that starts
with "## PR `#__PR__` — Review posted") to use a language tag like "text".
scripts/shortcuts/review/lib.sh (1)

120-124: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fail fast when git merge fails without unmerged paths.

Line 120 currently classifies any merge failure as a conflict. If merge fails for another reason, the workflow continues with invalid state. Check unmerged files first; if none exist, abort.

Proposed fix
 if ! git merge --no-edit main; then
-  echo "[review] ! conflicts detected in PR #$pr, continuing."
-  REVIEW_HAS_CONFLICTS=1
   REVIEW_CONFLICT_FILES=$(git diff --name-only --diff-filter=U | sort -u)
+  if [ -z "$REVIEW_CONFLICT_FILES" ]; then
+    fail "git merge main failed for a non-conflict reason"
+    return 1
+  fi
+  echo "[review] ! conflicts detected in PR #$pr, continuing."
+  REVIEW_HAS_CONFLICTS=1
 fi
#!/bin/bash
set -euo pipefail
nl -ba scripts/shortcuts/review/lib.sh | sed -n '116,130p'
rg -n 'git merge --no-edit main|REVIEW_CONFLICT_FILES=.*diff-filter=U|if \[ -z "\$REVIEW_CONFLICT_FILES" \]' scripts/shortcuts/review/lib.sh
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/shortcuts/review/lib.sh` around lines 120 - 124, The current handling
after the failing git merge treats any merge error as a conflict; change the
logic around the git merge --no-edit main failure so you first collect unmerged
paths via git diff --name-only --diff-filter=U into REVIEW_CONFLICT_FILES, and
only if that list is non-empty set REVIEW_HAS_CONFLICTS=1 and continue; if
REVIEW_CONFLICT_FILES is empty, fail fast (exit non-zero) and do not proceed.
Update the block referencing REVIEW_HAS_CONFLICTS and REVIEW_CONFLICT_FILES to
implement this conditional check and early abort behavior.
scripts/shortcuts/review/fix.sh (1)

52-52: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Render conflict file list safely (quoted/line-wise).

Line 52 uses unquoted expansion for REVIEW_CONFLICT_FILES, which can corrupt filenames containing whitespace or glob characters.

Proposed fix
-$(printf -- '- %s\n' $REVIEW_CONFLICT_FILES)
+$(printf '%s\n' "$REVIEW_CONFLICT_FILES" | sed 's/^/- /')
#!/bin/bash
set -euo pipefail
nl -ba scripts/shortcuts/review/fix.sh | sed -n '47,54p'
rg -n '\$\(printf -- '\''- %s\\n'\'' \$REVIEW_CONFLICT_FILES\)' scripts/shortcuts/review/fix.sh
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/shortcuts/review/fix.sh` at line 52, The current command "$(printf --
'- %s\n' $REVIEW_CONFLICT_FILES)" performs unquoted word-splitting and globbing
on REVIEW_CONFLICT_FILES; change it to render filenames safely by iterating
line-wise and quoting each name, e.g. use: printf -- '- %s\n'
"${REVIEW_CONFLICT_FILES[@]}" if REVIEW_CONFLICT_FILES is an array, or otherwise
pipe the variable into a while-read loop (printf -- '%s\n'
"$REVIEW_CONFLICT_FILES" | while IFS= read -r f; do printf -- '- %s\n' "$f";
done) so each filename is handled quoted and without glob expansion.
scripts/shortcuts/review/review.sh (1)

52-52: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Quote conflict-file rendering to preserve filenames.

Line 52 expands REVIEW_CONFLICT_FILES unquoted, so spaces/globs in paths can be split incorrectly.

Proposed fix
-$(printf -- '- %s\n' $REVIEW_CONFLICT_FILES)
+$(printf '%s\n' "$REVIEW_CONFLICT_FILES" | sed 's/^/- /')
#!/bin/bash
set -euo pipefail
nl -ba scripts/shortcuts/review/review.sh | sed -n '47,54p'
rg -n '\$\(printf -- '\''- %s\\n'\'' \$REVIEW_CONFLICT_FILES\)' scripts/shortcuts/review/review.sh
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/shortcuts/review/review.sh` at line 52, The printf invocation expands
REVIEW_CONFLICT_FILES unquoted which allows word-splitting/globbing and breaks
filenames with spaces; replace the single unquoted expansion of
REVIEW_CONFLICT_FILES used with $(printf -- '- %s\n' $REVIEW_CONFLICT_FILES) by
iterating over the lines safely (e.g., feed REVIEW_CONFLICT_FILES into a while
IFS= read -r file; do printf -- '- %s\n' "$file"; done or convert
REVIEW_CONFLICT_FILES into an array and printf each element) and ensure you
always quote the per-file variable ("$file" or "${array[i]}") so filenames with
spaces or glob characters are preserved.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@scripts/shortcuts/review/fix.sh`:
- Line 52: The current command "$(printf -- '- %s\n' $REVIEW_CONFLICT_FILES)"
performs unquoted word-splitting and globbing on REVIEW_CONFLICT_FILES; change
it to render filenames safely by iterating line-wise and quoting each name, e.g.
use: printf -- '- %s\n' "${REVIEW_CONFLICT_FILES[@]}" if REVIEW_CONFLICT_FILES
is an array, or otherwise pipe the variable into a while-read loop (printf --
'%s\n' "$REVIEW_CONFLICT_FILES" | while IFS= read -r f; do printf -- '- %s\n'
"$f"; done) so each filename is handled quoted and without glob expansion.

In `@scripts/shortcuts/review/lib.sh`:
- Around line 120-124: The current handling after the failing git merge treats
any merge error as a conflict; change the logic around the git merge --no-edit
main failure so you first collect unmerged paths via git diff --name-only
--diff-filter=U into REVIEW_CONFLICT_FILES, and only if that list is non-empty
set REVIEW_HAS_CONFLICTS=1 and continue; if REVIEW_CONFLICT_FILES is empty, fail
fast (exit non-zero) and do not proceed. Update the block referencing
REVIEW_HAS_CONFLICTS and REVIEW_CONFLICT_FILES to implement this conditional
check and early abort behavior.

In `@scripts/shortcuts/review/prompts/review.md`:
- Line 149: The markdown code fence opened on the snippet in review.md lacks a
language tag (```), which triggers markdownlint MD040; replace the bare fence
with a tagged fence (e.g., change the opening "```" to "```text") so the fenced
block is explicitly labeled — update the fenced block around the PR review
template (the block that starts with "## PR `#__PR__` — Review posted") to use a
language tag like "text".

In `@scripts/shortcuts/review/review.sh`:
- Line 52: The printf invocation expands REVIEW_CONFLICT_FILES unquoted which
allows word-splitting/globbing and breaks filenames with spaces; replace the
single unquoted expansion of REVIEW_CONFLICT_FILES used with $(printf -- '-
%s\n' $REVIEW_CONFLICT_FILES) by iterating over the lines safely (e.g., feed
REVIEW_CONFLICT_FILES into a while IFS= read -r file; do printf -- '- %s\n'
"$file"; done or convert REVIEW_CONFLICT_FILES into an array and printf each
element) and ensure you always quote the per-file variable ("$file" or
"${array[i]}") so filenames with spaces or glob characters are preserved.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 04a291bb-2d40-4866-bdfa-1cea53524d44

📥 Commits

Reviewing files that changed from the base of the PR and between 6e6ecff and 739eb76.

📒 Files selected for processing (18)
  • .husky/pre-push
  • package.json
  • scripts/shortcuts/README.md
  • scripts/shortcuts/review/README.md
  • scripts/shortcuts/review/cli.sh
  • scripts/shortcuts/review/coverage.sh
  • scripts/shortcuts/review/fix.sh
  • scripts/shortcuts/review/lib.sh
  • scripts/shortcuts/review/merge.sh
  • scripts/shortcuts/review/prompts/fix.md
  • scripts/shortcuts/review/prompts/review.md
  • scripts/shortcuts/review/review.sh
  • scripts/shortcuts/review/sync.sh
  • scripts/shortcuts/work/README.md
  • scripts/shortcuts/work/cli.sh
  • scripts/shortcuts/work/prompts/start.md
  • scripts/shortcuts/work/start.sh
  • scripts/shortcuts/ws-reset.sh
✅ Files skipped from review due to trivial changes (6)
  • package.json
  • scripts/shortcuts/review/README.md
  • scripts/shortcuts/work/README.md
  • scripts/shortcuts/README.md
  • scripts/shortcuts/work/cli.sh
  • .husky/pre-push

Apply six CodeRabbit suggestions on PR tinyhumansai#1695:

- `.claude/commands/ws-reset.md`: delegate to the guarded
  `scripts/shortcuts/ws-reset.sh` helper instead of inlining destructive
  `git reset --hard` steps, avoiding doc drift and data-loss risk.
- `scripts/shortcuts/ws-reset.sh`: replace `git diff --quiet HEAD --` with
  `git status --porcelain --untracked-files=all` so the dirty-tree guard
  catches untracked files too (matches the documented behavior).
- `scripts/shortcuts/review/lib.sh`: distinguish real merge conflicts from
  other merge failures — only set `REVIEW_HAS_CONFLICTS=1` when there are
  actually unmerged files; otherwise fail fast via the `fail` helper.
- `scripts/shortcuts/review/{fix,review}.sh`: quote `$REVIEW_CONFLICT_FILES`
  in the printf expansion (SC2086) so conflict paths with spaces or glob
  chars render correctly in the agent prompt.
- `scripts/shortcuts/review/prompts/review.md`: add `text` language tag to
  the final-report fenced code block (markdownlint MD040).
Copy link
Copy Markdown
Contributor

@graycyrus graycyrus left a comment

Choose a reason for hiding this comment

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

Walkthrough

This PR extracts the pnpm review review/fix agent prompts into self-contained Markdown templates under scripts/shortcuts/review/prompts/, making the workflow agent-agnostic. It also adds conflict detection in sync_pr, a pnpm reset workspace-reset helper, and improves the pre-push hook error messaging. Good direction overall — the templated approach is cleaner and the conflict surfacing is a real improvement.

Change Summary

File Change
scripts/review/scripts/shortcuts/review/ Directory rename
scripts/work/scripts/shortcuts/work/ Directory rename
scripts/shortcuts/review/prompts/{review,fix}.md New prompt templates
scripts/shortcuts/work/prompts/start.md New prompt template
scripts/shortcuts/review/{review,fix}.sh Rewritten to load + substitute templates
scripts/shortcuts/review/lib.sh Conflict detection + export vars
scripts/shortcuts/ws-reset.sh New workspace reset helper
.claude/commands/ws-reset.md Slash command for ws-reset
.husky/pre-push Better error messaging
package.json Updated script paths + reset

Findings

CodeRabbit already covered quoting issues in conflict-file expansion, the merge-failure handling in lib.sh, and the ws-reset command doc. I'm focusing on what it missed.

(2 issues below, posted as inline comments)


prompt=$(awk -v pr="$REVIEW_PR" -v repo="$REVIEW_REPO_RESOLVED" \
-v head_repo="$REVIEW_HEAD_REPO" -v head_branch="$REVIEW_HEAD_BRANCH" \
-v conflict="$conflict_block" '
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[major] start.sh has an esc() function that escapes \\\ and &\\& in awk gsub replacement strings (lines 128-130 in the new start.sh). Neither fix.sh nor review.sh do this.

This matters for conflict_block — it's multi-line markdown that could contain & in filenames or prose. Awk's gsub interprets & in the replacement as "the matched text", so an & in a conflict filename would silently corrupt the rendered prompt.

Suggested fix — add the same esc() wrapper from start.sh:

prompt=$(awk -v pr="$REVIEW_PR" -v repo="$REVIEW_REPO_RESOLVED" \
             -v head_repo="$REVIEW_HEAD_REPO" -v head_branch="$REVIEW_HEAD_BRANCH" \
             -v conflict="$conflict_block" '
  function esc(s) {
    gsub(/\\/, "\\\\", s); gsub(/&/, "\\\\&", s); return s
  }
  BEGIN {
    pr=esc(pr); repo=esc(repo); head_repo=esc(head_repo);
    head_branch=esc(head_branch); conflict=esc(conflict);
  }
  {
    gsub(/__PR__/, pr);
    ...
  }
' "$template")

Same applies to review.sh (line 60).

Comment thread .husky/pre-push
fi
echo "============================================================"
exit 1
fi No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[minor] File still ends without a trailing newline (\ No newline at end of file). POSIX requires text files to end with a newline, and some tools (notably wc -l, cat piping) behave unexpectedly without it. Easy fix — just add a blank line after fi.

@senamakel senamakel merged commit 6b2a90c into tinyhumansai:main May 14, 2026
24 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants