diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6225614..db4d960 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -126,6 +126,10 @@ jobs: --merge \ --repo ${{ github.repository }} + - name: Delete release branch + run: | + git push origin --delete "${{ env.PR_BRANCH }}" + - name: Post success comment if: success() run: | diff --git a/package.json b/package.json index 499404a..a2ac293 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@salve-software/ai-workers", - "version": "0.1.1", + "version": "0.1.2", "description": "Central package for AI configurations and Claude Code rules.", "scripts": { "postinstall": "bash scripts/setup.sh" diff --git a/scripts/setup.sh b/scripts/setup.sh index 03edf94..8edbaa7 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -86,12 +86,5 @@ for file in "$AIWORKERS_DIR/src/rules"/*.md; do fi done -echo "" - -# Link settings.json -echo "Settings:" -ln -sfn "$AIWORKERS_DIR/settings.json" "$CLAUDE_DIR/settings.json" -echo " ✓ settings.json" - echo "" echo "Done. AIWorkers is fully linked to $CLAUDE_DIR" diff --git a/src/commands/land/SKILL.md b/src/commands/land/SKILL.md index d897b34..afcfdbc 100644 --- a/src/commands/land/SKILL.md +++ b/src/commands/land/SKILL.md @@ -35,15 +35,23 @@ Read and follow `.claude/skills/aiworkers/commit/SKILL.md`. Instruct the commit agent to: - Check if `.claude/.aiworkers-context.tmp` exists -- If yes: read its contents as the diff, then delete it with `rm .claude/.aiworkers-context.tmp` +- If yes: read its contents as the diff instead of running `git diff HEAD` - If no: run `git diff HEAD` normally -### 4. Run /pr (if requested) +### 4. Delete temp file + +After /commit completes (success or failure), the orchestrator deletes the temp file: +```bash +rm .claude/.aiworkers-context.tmp +``` + +### 5. Run /pr (if requested) If the user's original request included creating a PR, read and follow `.claude/skills/aiworkers/pr/SKILL.md`. ## Rules +- The orchestrator is solely responsible for saving and deleting `.claude/.aiworkers-context.tmp` — skills only read it, never delete it - Always delete `.claude/.aiworkers-context.tmp` after /commit, even if commit fails - If /branch fails, delete the tmp file before stopping - Never push the branch unless /pr is being run (which handles pushing itself) diff --git a/src/rules/skills-format.md b/src/rules/skills-format.md index 01d24d7..a98af8e 100644 --- a/src/rules/skills-format.md +++ b/src/rules/skills-format.md @@ -2,7 +2,7 @@ ## User-invokable commands (`/name`) -Commands are invoked directly by the user with `/name`. Use `commands//SKILL.md`: +Commands are invoked **only** when the user explicitly types `/name`. Claude must never auto-trigger a command based on context — that is exclusively for skills. Use `commands//SKILL.md`: ``` commands/ @@ -15,6 +15,19 @@ commands/ Examples: `/feature`, `/ship` +## Routing rule + +**Before invoking any skill or command, apply this decision tree — no exceptions:** + +1. Did the user's message contain the exact slash command text (e.g. `/aiworkers:land`, `/feature`)? + - **YES** → use the matching `commands//SKILL.md` + - **NO** → go to step 2 + +2. Find the relevant context-triggered skill in `skills/` and read its `SKILL.md` directly. + +**Never use `commands/` when the user did not type the slash command.** Pattern-matching intent (e.g. "commit my changes" → `/aiworkers:land`) is forbidden. Always route through `skills/` for natural language requests. + + ## Context-triggered skills Skills are invoked automatically by Claude when relevant — never by the user. Always include `user-invocable: false` in frontmatter. Use `skills//SKILL.md`: diff --git a/src/skills/commit/SKILL.md b/src/skills/commit/SKILL.md index f9859a8..ee9e759 100644 --- a/src/skills/commit/SKILL.md +++ b/src/skills/commit/SKILL.md @@ -30,7 +30,7 @@ Your job is to analyze the git changes and create conventional commits. ## Process -1. Run `git status` and `git diff HEAD` to understand what changed +1. If `.claude/.aiworkers-context.tmp` exists: read its contents as the diff. Otherwise run `git status` and `git diff HEAD` to understand what changed 2. Inspect specific files with `git diff HEAD -- ` as needed 3. Group related files by semantic context 4. For each group, determine the commit type and create the commit diff --git a/src/skills/pr/SKILL.md b/src/skills/pr/SKILL.md index b4a5365..9c64357 100644 --- a/src/skills/pr/SKILL.md +++ b/src/skills/pr/SKILL.md @@ -51,19 +51,36 @@ If `$ARGUMENTS` is provided, use it as the title instead. Use the gathered context (commits, feature.md content, branch name) to fill every section of the PR template. Do not leave placeholder comments unfilled. -### 6. Create the PR +### 6. Ensure base branch exists on remote +Before creating the PR, verify the base branch exists on the remote: +```bash +git ls-remote --exit-code origin 2>/dev/null +``` + +- If it exists: proceed normally. +- If it does **not** exist: create and push it from `main` as a fallback: ```bash -gh pr create --title "" --body "$(cat <<'EOF' +git checkout main +git checkout -b <base-branch> +git push -u origin <base-branch> +git checkout <current-branch> +``` + +Then continue with PR creation. + +### 7. Create the PR + +```bash +gh pr create --title "<title>" --base <base-branch> --body "$(cat <<'EOF' <filled template body> EOF )" ``` -### 7. Output the PR URL - +### 8. Output the PR URL Display: `✓ PR created: <URL>` @@ -72,6 +89,7 @@ Display: `✓ PR created: <URL>` ## Rules - If the branch has no upstream, push it automatically with `git push -u origin <branch>` before creating the PR +- If the base branch does not exist on the remote, create it from `main` and push it — then return to the current branch before creating the PR - Do not set reviewers, labels, or assignees — leave that to the user - If the branch has no commits ahead of base, stop and warn the user - **Never invent a PR body.** Always read the template file and use it as the body structure — including all emojis, sections, and checkboxes exactly as they appear