@clipboard-health/ai-rules 2.15.10 → 2.16.1

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.10",
3
+ "version": "2.16.1",
4
4
  "description": "Pre-built AI agent rules for consistent coding standards.",
5
5
  "keywords": [
6
6
  "ai",
@@ -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
 
@@ -17,10 +17,11 @@ description: Commit, push, and open a PR. Use when the user wants to ship change
17
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
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. Wait for it to finish, then include any resulting fixes in the commit.
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
21
  3. If `git status --short` shows changes, create a single conventional commit.
22
22
  4. Push the branch to origin.
23
- 5. Check for an existing PR with `gh pr view`.
24
- - No PR: create with `gh pr create`. Title = commit subject. Description = brief explanation of **why**, not what. Append `<!-- commit-push-pr:created v1 -->` on its own line at the end so skill-created PRs can be identified later.
25
- - PR exists: report the URL and move on.
26
- 6. 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.
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)"