@clipboard-health/ai-rules 2.15.9 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clipboard-health/ai-rules",
3
- "version": "2.15.9",
3
+ "version": "2.16.0",
4
4
  "description": "Pre-built AI agent rules for consistent coding standards.",
5
5
  "keywords": [
6
6
  "ai",
@@ -59,7 +59,12 @@ for my $section (@sections) {
59
59
  my $raw_file_name = trim($1);
60
60
  my $file_content = $2;
61
61
 
62
- while ($file_content =~ /`(\d+(?:-\d+)?)`:\s*(?:_[^_]+_\s*\|\s*_[^_]+_\s*)?\*\*([^*]+)\*\*\s*([\s\S]*?)(?=---|\n`\d|<\/blockquote>|$)/g) {
62
+ # Category prefix is optional. CodeRabbit emits 0–N `__` tags
63
+ # separated by `|` (e.g. `_⚠️ Potential issue_ | _🟠 Major_ | _⚡ Quick win_`
64
+ # or just `_💤 Low value_` on lower-confidence findings). The previous
65
+ # regex required exactly two tags and silently dropped one-tag and
66
+ # three-tag variants.
67
+ while ($file_content =~ /`(\d+(?:-\d+)?)`:\s*(?:_[^_]+_(?:\s*\|\s*_[^_]+_)*\s*)?\*\*([^*]+)\*\*\s*([\s\S]*?)(?=---|\n`\d|<\/blockquote>|$)/g) {
63
68
  my $line_range = $1;
64
69
  my $title = trim($2);
65
70
  my $clean_body = clean_comment_body(trim($3));
@@ -1,5 +1,5 @@
1
1
  ---
2
- allowed-tools: Bash(git checkout --branch:*), Bash(git add:*), Bash(git status:*), Bash(git push:*), Bash(git commit:*), Bash(gh pr view:*), Bash(gh pr create:*), Bash(git diff:*), Bash(git merge-base:*)
2
+ allowed-tools: Bash(git checkout --branch:*), Bash(git add:*), Bash(git status:*), Bash(git push:*), Bash(git commit:*), Bash(gh pr view:*), Bash(gh pr create:*), Bash(gh pr edit:*), Bash(git diff:*), Bash(git merge-base:*), Bash(bash scripts/find-session-id.sh:*)
3
3
  description: Commit, push, and open a PR. Use when the user wants to ship changes, create a pull request, or says things like 'commit and push', 'open a PR', 'ship it', 'send it', 'create a PR for this', or 'push this up'.
4
4
  ---
5
5
 
@@ -14,20 +14,14 @@ description: Commit, push, and open a PR. Use when the user wants to ship change
14
14
 
15
15
  ## Your task
16
16
 
17
- **First, decide from the context above. If `Commits ahead of default branch` is `(unknown)`, skip this decision and use the full flow below.**
17
+ If `Commits ahead of default branch` is `(unknown)`, `origin/HEAD` couldn't be resolved — stop and tell the user to run `git remote set-head origin -a` (or otherwise set the default branch) before retrying, since the simplify step also depends on it. Otherwise, if `Git status`, `Commits ahead of default branch`, and `Existing PR` are all empty/none, stop and reply `nothing to ship.`. Otherwise:
18
18
 
19
- - If `Git status` is empty AND `Commits ahead of default branch` is empty AND `Existing PR` is `none`: stop. Reply with `nothing to ship.` and do nothing else.
20
- - If `Git status` is empty but there are `Commits ahead of default branch` or an `Existing PR`: still run step 1 and step 2. Then re-check `git status --short`; skip step 3 only if it remains empty. Then continue with step 4 and step 5.
21
- - Otherwise: proceed with all steps below.
22
-
23
- Based on the above changes:
24
-
25
- 1. Create a new branch if on main (e.g., `feat/add-user-validation`, `fix/null-check-in-parser`)
26
- 2. Run the `simplify` skill on the files included in the PR before committing, pushing, or opening the PR. If the working tree is clean, run `simplify` against `git diff $(git merge-base HEAD origin/HEAD)..HEAD`. If the working tree has changes, run it against `git diff HEAD`; when local commits also exist, include `git diff $(git merge-base HEAD origin/HEAD)..HEAD` as additional PR context. Invoke the skill by name using this agent's normal skill invocation mechanism. Wait for the skill to finish, then include any resulting fixes in the commit step below.
27
- 3. Re-check `git status --short`. If there are changes, create a single conventional commit message.
28
- 4. Push the branch to origin
29
- 5. Check for an existing PR with `gh pr view`.
30
- - No PR exists: Create with `gh pr create`. Title = commit subject line. Description = brief explanation of **why**, not what. Append `<!-- commit-push-pr:created v1 -->` on its own line at the end of the PR description so skill-created PRs can be identified later.
31
- - PR exists: Report the URL and move on.
32
- 6. You have the capability to call multiple tools in a single response. After the `simplify` skill completes, do the remaining git and PR operations in a single message. Do not use any other tools or do anything else.
33
- 7. After tool calls complete, send one short final text response with the branch name and the full PR URL (e.g., `https://github.com/clipboardhealth/core-utils/pull/123`). Never use shorthand like `repo#123` — always output the complete URL so it is clickable.
19
+ 1. Create a new branch if on main (e.g., `feat/add-user-validation`, `fix/null-check-in-parser`).
20
+ 2. Run the `simplify` skill on the full PR diff `git diff $(git merge-base HEAD origin/HEAD)..HEAD` plus any uncommitted changes. When it returns, continue to step 3 in the same turn; do not stop.
21
+ 3. If `git status --short` shows changes, create a single conventional commit.
22
+ 4. Push the branch to origin.
23
+ 5. Look up the current agent session ID with `bash scripts/find-session-id.sh '<phrase>'`. Pass a distinctive verbatim chunk (≥10 words) from the most recent user message; see the script header for quoting constraints. On success the script prints `<agent> <id>`; otherwise nothing — if empty, omit the session ID line below.
24
+ 6. Check for an existing PR with `gh pr view`.
25
+ - No PR: create with `gh pr create`. Title = commit subject. Description = brief explanation of **why**, not what. Append `Agent session ID: <output of step 5>` (omit if step 5 produced no output) and `<!-- commit-push-pr:created v1 -->` on their own lines at the end.
26
+ - PR exists: refresh the body via `gh pr edit --body` so (a) the new commit's changes are reflected in the prose and (b) `Agent session ID: <output of step 5>` appears in the body append if missing, never remove or rewrite existing session ID lines so each contributing session is preserved. Then report the URL.
27
+ 7. End with one short text response: branch name and the full PR URL (e.g., `https://github.com/clipboardhealth/core-utils/pull/123`). Never use shorthand like `repo#123` — always output the complete URL.
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env bash
2
+ # find-session-id.sh — print the current agent session ID, or nothing.
3
+ # Output format on success: "<agent> <id>" (e.g. "codex 0193..." or "claude-code c8fb7000-...").
4
+ # Exits 0 either way; callers should treat empty output as "unknown, skip the line".
5
+ #
6
+ # Codex: reads $CODEX_THREAD_ID directly.
7
+ # Claude Code: greps the project's JSONL transcripts for a phrase the caller
8
+ # passes as $1. The phrase MUST come from a recent user message in the
9
+ # current session and MUST avoid: " ' \ tab newline (those are JSON-escaped
10
+ # on disk or break shell quoting). Non-ASCII is fine — Claude Code stores
11
+ # user messages verbatim, not as \uXXXX escapes.
12
+ #
13
+ # Usage: find-session-id.sh "<distinctive phrase>"
14
+
15
+ set -euo pipefail
16
+
17
+ if [ -n "${CODEX_THREAD_ID:-}" ]; then
18
+ echo "codex $CODEX_THREAD_ID"
19
+ exit 0
20
+ fi
21
+
22
+ phrase="${1:-}"
23
+ [ -n "$phrase" ] || exit 0
24
+
25
+ # Claude Code encodes both / and . as - in the project-dir name
26
+ # (e.g. /Users/x/.claude → -Users-x--claude).
27
+ project_dir="$HOME/.claude/projects/$(pwd | sed -e 's|/|-|g' -e 's|\.|-|g')"
28
+ [ -d "$project_dir" ] || exit 0
29
+
30
+ # -- guards against a phrase that starts with -. -m 1 stops scanning each
31
+ # transcript at the first hit (transcripts can be hundreds of MB).
32
+ matches=$(grep -lFm 1 -- "$phrase" "$project_dir"/*.jsonl 2>/dev/null || true)
33
+ [ -n "$matches" ] || exit 0
34
+
35
+ # Require exactly one match. Falling back to recency under multi-match would
36
+ # risk a wrong ID when concurrent sessions exist in the same project.
37
+ [ "$(printf '%s\n' "$matches" | wc -l)" -eq 1 ] || exit 0
38
+
39
+ echo "claude-code $(basename "$matches" .jsonl)"
@@ -4,59 +4,43 @@ description: Implement a plan file or direct request end-to-end, then hand off t
4
4
 
5
5
  # Go: Execute Work and Ship It
6
6
 
7
- Given a plan file or direct implementation request, implement the requested work, then invoke the `commit-push-pr` skill to commit, push, and open a PR.
7
+ Given a plan file or direct implementation request, implement the requested work, then invoke the `commit-push-pr` skill to create a PR.
8
8
 
9
9
  This skill is the bridge between intent and shipping. It does not re-plan or re-design unless the user asked for that. If the request is wrong or cannot be implemented safely, surface that; do not silently improvise.
10
10
 
11
- ## Phase 1: Understand the Input
11
+ ## Phase 1: Resolve the Input
12
12
 
13
- The user may invoke this skill with either a plan file path/identifier or a direct implementation request such as "add a button to the homepage to log in." Resolve the input in this order:
13
+ The user invokes this skill with either a plan file path/identifier or a direct request like "add a login button."
14
14
 
15
- 1. **Absolute path** (starts with `/`): read it directly only when it is inside the current workspace/repo root or the host's plans directory. If it is outside those roots, ask the user to confirm before reading it; if they do not confirm, stop and ask for an approved path.
16
- 2. **Relative path** (contains `/` or starts with `./`): resolve from the current working directory.
17
- 3. **Bare name** (no path separators, e.g. `my-plan` or `my-plan.md`): if the host exposes a plans directory, look there first. Use whatever directory the current host stores plan files in — do not hard-code a host-specific path. If no plan is found and the input is ambiguous, ask whether it is a plan identifier or an implementation request.
18
- 4. **Natural-language request** (for example, contains spaces or reads like an implementation task): treat it as the implementation request. There may be no separate plan file.
19
- 5. **No argument given**: ask the user to provide either the plan file path or the implementation request. Do not guess.
15
+ - **Path-like input** (absolute, relative, or bare name): try to read it. For bare names, check the host's plans directory first. Resolve the path first; if it lies outside the workspace/repo or the host's plans directory, ask the user to confirm before reading it (applies to both absolute and relative inputs — `..` escapes count). If the input doesn't resolve to a readable file, stop and tell the user do not reinterpret a missing path as a direct request.
16
+ - **Natural-language request**: treat as the implementation task. There may be no plan file.
17
+ - **No argument**: ask for either a plan path or the implementation request.
20
18
 
21
- If a path-like input does not exist or cannot be read, stop and tell the user. Do not reinterpret a missing path as a direct request.
19
+ When using a plan, read it fully before starting. Note **Critical files**, **Approach**, and **Verification** sections (or equivalents).
22
20
 
23
- When using a plan, read the entire plan before starting. Note the **Critical files**, **Approach**, and **Verification** sections (or their equivalents).
21
+ ## Phase 2: Implement
24
22
 
25
- ## Phase 2: Implement the Request
23
+ The plan or request is the source of truth for scope:
26
24
 
27
- Treat the plan or direct request as the source of truth for scope:
28
-
29
- - Make exactly the changes requested no more, no less. Do not add extra refactors, tests, or cleanup the request did not ask for.
30
- - If a plan references files, functions, or utilities that no longer exist, stop and surface the discrepancy before guessing.
31
- - If you discover the request is wrong (the codebase has moved, an assumption is invalid, a constraint was missed), stop and report. Do not silently rewrite the approach.
32
- - For direct implementation requests, inspect the relevant code before editing and use the repo's existing patterns.
33
- - Do **not** modify the plan file itself when working from a plan.
25
+ - Make exactly the changes requested no extra refactors, tests, or cleanup.
26
+ - If the plan references files or utilities that no longer exist, stop and report.
27
+ - If an assumption is invalid or a constraint was missed, stop and report. Do not silently rewrite the approach.
28
+ - Do not modify the plan file itself.
34
29
 
35
30
  ## Phase 3: Validate
36
31
 
37
- Validation should follow the repo's instructions and the cost profile of the repo. Some repos intentionally leave slow checks to CI; do not run broad or slow suites unless the repo instructions explicitly require them.
38
-
39
- Run validation in this order:
40
-
41
- 1. **Repo instructions.** Look up the repo's standard validation guidance. Common signals, in priority order:
42
- - An explicit instruction in the repo's agent or contributor instructions, such as `AGENTS.md`, `CLAUDE.md`, `CONTRIBUTING.md`, or an equivalent host-specific instruction file (e.g. "MUST run before opening PRs"). This wins over everything else.
43
- - A relevant `package.json` script when the repo instructions point to it, such as `affected`, `precommit`, `validate`, `check`, `verify`, `test`, `lint`, `typecheck`, or repo-equivalent.
44
- - A repo-specific equivalent in the rare case the project does not use `package.json`.
45
-
46
- If the repo primarily relies on git pre-commit or pre-push hooks and does not mandate a manual validation command, do not invent one. Let the hooks run during the `commit-push-pr` handoff.
47
-
48
- 2. **Request-specific verification.** If the plan or user request names specific checks, run them when they are practical and consistent with the repo instructions. If a requested check is clearly a slow CI-only suite, ask before running it.
49
-
50
- If any check you run fails, fix the failures and re-run the same check. Do not hand off to `commit-push-pr` with known failing checks unless the user explicitly accepts a pre-existing or unrelated failure.
32
+ - Read `AGENTS.md`, `CLAUDE.md`, `CONTRIBUTING.md`, or equivalent contributor instructions for the mandated pre-PR command (e.g. `npm run affected`). That wins over everything.
33
+ - If the repo relies on pre-commit/pre-push hooks and mandates no manual command, don't invent one — let the hooks run during the `commit-push-pr` handoff.
34
+ - If the plan names specific checks, run them when practical. Ask before running anything that's clearly a slow CI-only suite.
51
35
 
52
- ## Phase 4: Hand Off to commit-push-pr
36
+ Fix any failures before handing off. Do not hand off with known failing checks unless the user explicitly accepts a pre-existing or unrelated failure.
53
37
 
54
- Once implementation is complete and Phase 3 validation is satisfied, invoke the `commit-push-pr` skill by name using this agent's normal skill invocation mechanism.
38
+ ## Phase 4: Hand Off
55
39
 
56
- Do **not** commit, push, or open the PR yourself in this skill. Let `commit-push-pr` own the shipping flow.
40
+ Invoke the `commit-push-pr` skill. Do not commit, push, or open the PR yourself.
57
41
 
58
- If `commit-push-pr` reports `nothing to ship.` (the work resulted in no actual file changes), surface that to the user — it usually means the request was already implemented or was a no-op.
42
+ If `commit-push-pr` reports `nothing to ship.`, surface that.
59
43
 
60
44
  ## Phase 5: Final Output
61
45
 
62
- After `commit-push-pr` returns, ensure the user sees one short final response with the branch name and the full PR URL it produced. If the current host already surfaced that response, do not duplicate it. If `commit-push-pr` reported nothing to ship, say so plainly.
46
+ Ensure the user sees the branch name and full PR URL.