Fase 2: 04_sanitize.py - scrubbing de secretos de skills/agentes/plans (10 secretos unicos, gate en verde)
This commit is contained in:
@@ -0,0 +1,261 @@
|
||||
---
|
||||
name: aleleba-pr
|
||||
description: Full delivery pipeline — creates a branch if needed, commits, pushes, and opens a PR. Auto-detects GitHub vs Gitea and uses the right tool. All output (commits, PR titles, PR bodies) must be written in English. Triggers: "aleleba-pr", "create a PR", "push and PR", "ship this", "crea un PR", "crea una rama".
|
||||
effort: medium
|
||||
argument-hint: "[optional PR description]"
|
||||
---
|
||||
|
||||
# aleleba-pr — Commit, Push and PR
|
||||
|
||||
Custom delivery pipeline. Gets work into the remote repository with a well-written PR, regardless of whether the repo is on GitHub or Gitea.
|
||||
|
||||
**Language rule: ALL output must be in English** — commit messages, branch names, PR titles, PR bodies, table content, test plan steps. No exceptions.
|
||||
|
||||
## Safety rules
|
||||
|
||||
### NEVER
|
||||
- Force push (`--force`, `--force-with-lease`)
|
||||
- `git add -A` or `git add .` — always stage specific files
|
||||
- Add **ANY Claude attribution** — `Co-Authored-By: Claude`, "Generated with Claude Code", the 🤖 emoji,
|
||||
"created with Claude" or anything similar — in commit messages, PR titles, PR bodies, code comments, or
|
||||
anywhere else. No Claude signature, ever.
|
||||
- Push without explicit user confirmation
|
||||
- Use `HEAD` instead of the explicit branch name when pushing
|
||||
- **Commit on `main`, `master`, or `dev`** — always create a feature branch first with `git checkout -b {branch-name}` before any commit
|
||||
|
||||
### ALWAYS
|
||||
- Check the branch before any operation
|
||||
- Ask for confirmation before pushing
|
||||
- Use HEREDOC for commit messages
|
||||
- Derive the PR title from the current branch name
|
||||
- Write everything in English: commit messages, PR title, PR body, branch name slugs
|
||||
|
||||
---
|
||||
|
||||
## Pre-flight — Branch and platform check
|
||||
|
||||
This step runs **once at the start**.
|
||||
|
||||
### 1. Read repo context
|
||||
|
||||
```bash
|
||||
git branch --show-current
|
||||
git remote get-url origin
|
||||
git status --short
|
||||
git log --oneline -5
|
||||
```
|
||||
|
||||
### 2. Check if we are on a protected branch
|
||||
|
||||
**ALWAYS check the current branch before doing ANYTHING else — including commits.**
|
||||
If the current branch is `main`, `master`, or `dev` → **STOP and create a feature branch first. NEVER commit on these branches.**
|
||||
|
||||
**2a. Look for PRNameGenerator in the repo root:**
|
||||
|
||||
```bash
|
||||
ls PRNameGenerator.ts PRNameGenerator.js 2>/dev/null | head -1
|
||||
```
|
||||
|
||||
- If `PRNameGenerator.ts` exists: run `npx ts-node PRNameGenerator.ts`. Use the output as the new branch slug.
|
||||
- If `PRNameGenerator.js` exists: run `node PRNameGenerator.js`. Use the output as the new branch slug.
|
||||
|
||||
**2b. If no PRNameGenerator exists** → infer the branch name from the current diff:
|
||||
- Run `git diff --stat` to understand what changed
|
||||
- Use format `feat/description-with-hyphens` (new feature) or `fix/description-with-hyphens` (bug fix)
|
||||
- All lowercase, hyphen-separated, no special characters, **in English**
|
||||
- Examples: `feat/add-user-authentication`, `fix/null-pointer-on-login`
|
||||
|
||||
**2c. Create the branch — this MUST happen before any commit:**
|
||||
```bash
|
||||
git checkout -b {branch-name}
|
||||
```
|
||||
|
||||
Verify with `git branch --show-current` that you are now on the new branch before proceeding.
|
||||
|
||||
If already on a feature branch (not `main`, `master`, or `dev`) → proceed directly to Step 1.
|
||||
|
||||
### 3. Detect platform
|
||||
|
||||
Read the remote URL:
|
||||
- Contains `github.com` → **GitHub** mode (use `gh` CLI)
|
||||
- Contains `gitea.p-lao.com` → **Gitea** mode (use MCP `mcp__gitea__pull_request_write`)
|
||||
- Other domain → warn the user and ask which tool to use
|
||||
|
||||
### 4. Detect base branch
|
||||
|
||||
```bash
|
||||
git rev-parse --abbrev-ref origin/HEAD 2>/dev/null || echo "UNRESOLVED"
|
||||
```
|
||||
|
||||
If unresolved, try `main`, then `dev`, then `master`. Store as `{base-branch}`.
|
||||
|
||||
---
|
||||
|
||||
## Step 1: Commit (if there are pending changes)
|
||||
|
||||
Check working tree state:
|
||||
- **Clean tree AND unpushed commits exist** → skip directly to Step 2
|
||||
- **Nothing to commit and nothing to push** → report "Nothing to ship" and exit
|
||||
- **Uncommitted changes exist** → proceed with the commit
|
||||
|
||||
**Show the diff for review:**
|
||||
```bash
|
||||
git diff --stat
|
||||
git diff --name-only
|
||||
```
|
||||
|
||||
**Analyze the changes** to write a descriptive conventional commit message in English (`feat:`, `fix:`, `chore:`, `refactor:`, etc.).
|
||||
|
||||
**Stage specific files** (never `git add -A`):
|
||||
```bash
|
||||
git add {file1} {file2} ...
|
||||
```
|
||||
|
||||
**Create the commit with HEREDOC** — no Co-Authored-By or any authorship trailer:
|
||||
```bash
|
||||
git commit -m "$(cat <<'EOF'
|
||||
type: concise description in imperative mood in English
|
||||
|
||||
Explanation of what changed and why (if applicable), in English.
|
||||
EOF
|
||||
)"
|
||||
```
|
||||
|
||||
If a pre-commit hook fails → report the error, do NOT use `--no-verify`. Ask the user to fix it and retry.
|
||||
|
||||
---
|
||||
|
||||
## Step 2: Push
|
||||
|
||||
Show the commits about to be pushed:
|
||||
```bash
|
||||
git log origin/{base-branch}..HEAD --oneline 2>/dev/null || git log --oneline -5
|
||||
```
|
||||
|
||||
**Ask for explicit user confirmation** before pushing. Show:
|
||||
- Target: `origin/{branch-name}`
|
||||
- Number of commits to push
|
||||
- List of commits
|
||||
|
||||
Once confirmed:
|
||||
```bash
|
||||
git push origin {branch-name}
|
||||
```
|
||||
|
||||
If push fails because the branch has no upstream → add `-u`:
|
||||
```bash
|
||||
git push -u origin {branch-name}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Step 3: Create PR
|
||||
|
||||
**Build the title** from the current branch name:
|
||||
- Branch: `feat/add-user-auth` → Title: `feat/add-user-auth: Add user authentication`
|
||||
- The description after `:` must be a readable English summary of the diff changes
|
||||
|
||||
**Build the PR body** by analyzing the full diff. Everything must be written in English. **Do NOT append any
|
||||
Claude attribution footer** ("Generated with Claude Code", 🤖, etc.) — the PR body ends at the Test Plan:
|
||||
|
||||
```
|
||||
## Summary
|
||||
- {bullet 1 describing the main change}
|
||||
- {bullet 2 if there are more relevant changes}
|
||||
|
||||
## Changes
|
||||
| File | Change |
|
||||
|------|--------|
|
||||
| `path/to/file` | Description of the change |
|
||||
| ... | ... |
|
||||
|
||||
## Test Plan
|
||||
- [ ] {test step 1}
|
||||
- [ ] {test step 2}
|
||||
|
||||
```
|
||||
|
||||
### If GitHub:
|
||||
|
||||
```bash
|
||||
gh pr create \
|
||||
--title "{title}" \
|
||||
--body "$(cat <<'EOF'
|
||||
{body built above}
|
||||
EOF
|
||||
)"
|
||||
```
|
||||
|
||||
If an open PR already exists for this branch (`gh pr view 2>/dev/null`), update the body instead of creating a new one:
|
||||
```bash
|
||||
gh pr edit --body "$(cat <<'EOF'
|
||||
{body}
|
||||
EOF
|
||||
)"
|
||||
```
|
||||
|
||||
### If Gitea:
|
||||
|
||||
Extract `owner` and `repo` from the remote URL:
|
||||
- HTTPS: `https://gitea.p-lao.com/owner/repo.git` → `owner=owner`, `repo=repo`
|
||||
- SSH: `<<EMAIL_2>>:owner/repo.git` → same
|
||||
|
||||
Invoke the MCP tool:
|
||||
```
|
||||
mcp__gitea__pull_request_write:
|
||||
method: "create"
|
||||
owner: {owner}
|
||||
repo: {repo}
|
||||
head: {branch-name}
|
||||
base: {base-branch}
|
||||
title: {title}
|
||||
body: {body built above}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Step 4: Final report
|
||||
|
||||
Show a summary of what was done:
|
||||
|
||||
```
|
||||
═══════════════════════════════════════
|
||||
ALELEBA-PR — SHIP MANIFEST
|
||||
═══════════════════════════════════════
|
||||
Platform: GitHub / Gitea
|
||||
Branch: {branch-name}
|
||||
Base: {base-branch}
|
||||
PR: {pr-url}
|
||||
Status: DONE
|
||||
═══════════════════════════════════════
|
||||
```
|
||||
|
||||
Omit sections that did not apply (e.g., no commit step if the tree was already clean).
|
||||
|
||||
---
|
||||
|
||||
## Failure modes
|
||||
|
||||
| Situation | Behavior |
|
||||
|-----------|----------|
|
||||
| On protected branch | Auto-create feature branch using PRNameGenerator or inferred name |
|
||||
| PRNameGenerator fails | Warn, infer branch name from diff |
|
||||
| Push rejected (remote ahead) | Report error, suggest `git pull --rebase origin {branch}` |
|
||||
| `gh` not authenticated | Report, suggest `gh auth login` |
|
||||
| PR already exists (GitHub) | Update body with `gh pr edit` instead of creating new |
|
||||
| Gitea MCP fails | Report error and print the PR body so user can create it manually |
|
||||
| Nothing to ship | Report cleanly and exit without error |
|
||||
|
||||
---
|
||||
|
||||
## Usage examples
|
||||
|
||||
```
|
||||
/aleleba-pr
|
||||
```
|
||||
Full pipeline from any state.
|
||||
|
||||
```
|
||||
/aleleba-pr adds dark mode support
|
||||
```
|
||||
Uses the provided description as extra context for the PR title and body.
|
||||
Reference in New Issue
Block a user