Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .agents/skills/checker/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: checker
description: Runs the same CI checks as the GitHub CI workflow locally. Use this skill before pushing commits to verify the code passes all CI checks.
---

# Checker Skill

This skill runs the same checks as the GitHub CI workflow.

## Description

Reads the GitHub CI workflow file and executes exactly the same checks locally.

## When to use

Use this skill before pushing commits to verify the code passes all CI checks locally.

## Implementation

When this skill is invoked, perform the following steps:

### Step 1: Read the CI workflow
Read `.github/workflows/ci.yaml` to identify the checks to run.

### Step 2: Execute the CI checks
Run exactly the same commands defined in the workflow file.

If any check fails, fix the issues and rerun until all checks pass.

## Output

- Print results of each check
- If any check fails, print the failure details
77 changes: 77 additions & 0 deletions .agents/skills/pusher/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
name: pusher
description: Stages, commits, and pushes changes to git. Runs cargo fmt before staging to ensure code is properly formatted. Creates a branch if on main and creates a PR if none exists.
---

# Pusher Skill

This skill stages, commits, and pushes changes to git.

## Essential Rule

**NEVER commit or push directly to the main branch.** Always create a feature branch first.

## Description

Format the source code with cargo fmt, then stage changes with git add, create a commit with git commit, and push to the remote with git push. Ensures changes are never pushed directly to main branch - creates a branch if on main, and creates a PR if none exists for the branch.

## When to use

Use this skill when you want to commit and push changes to the repository.


## Implementation

When this skill is invoked, perform the following steps:

### Step 1: Check current branch
Run `git branch --show-current` to determine the current branch.

### Step 2: Handle main branch (REQUIRED)
If on main branch:
- Changes to main brnach are **NOT allowed**
- Create a feature brach but do not ask the user for a new branch name
- Generate a branch name automatically based on the changes:
- Check git status or diff to understand what changed
- Use format: `<type>/<short-description>` where type is: feature/, fix/, refactor/, docs/, test/
- Example: if adding tests, use `test/add-phase5-integration-tests`
- Create and checkout the new branch with `git checkout -b <branch-name>`
- Set upstream with `git push -u origin <branch-name>`

### Step 3: Format the source code
Run `cargo fmt -- --check` to check if the code is formatted correctly.

If the code is not formatted correctly, run `cargo fmt` to format it automatically.

### Step 4: Stage the changes
Run `git add -A` to stage all changes.

### Step 5: Check the status
Run `git status` to see what will be committed.

### Step 6: Create a commit
Run `git commit` with an auto-generated commit message:
- Derive the message from the changes: summarize what files were changed and what was done
- Use conventional commit format: `<type>: <description>` where type is: feat, fix, refactor, docs, test, chore
- Examples:
- "test: add phase5 integration tests for admin auth and blog multilingual"
- "refactor: centralize validation code in admin_auth middleware"
- "feat: add lang Tera function for view context"

### Step 7: Push to the remote
Run `git push` to push the commit to the remote repository.

### Step 8: Create a PR if none exists
Check if a PR already exists for the branch:
- Run `gh pr list --head <branch-name>` to check for existing PR
- If no PR exists, create one automatically:
- Generate a title from the branch name (convert to title case, e.g., `test/add-phase5-integration-tests` → "Add phase5 integration tests")
- Generate a body summarizing the changes: list the files changed and summarize the commit message
- Use `gh pr create --title "<title>" --body "<body>"`

## Output

- Print the result of each step
- If any step fails, print the error and stop
- Print the commit SHA after a successful push
- Print the PR URL after creating a PR
48 changes: 48 additions & 0 deletions .agents/skills/release/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: release
description: Creates a git tag to trigger the release workflow. The release workflow builds binaries and creates a GitHub Release. This skill also publishes to crates.io.
---

# Release Skill

This skill creates a git tag to trigger the release workflow.

## Prerequisites

Before using this skill, you must:
1. Bump the version in `Cargo.toml`
2. Update `CHANGELOG.md` with the new version and release notes
3. Commit and push those changes to the main branch

## When to use

Use this skill when you want to release a new version to GitHub and crates.io.

## Implementation

When this skill is invoked, perform the following steps:

### Step 1: Get the version
Run `grep -m1 '^version' Cargo.toml` to get the current version from Cargo.toml.

### Step 2: Create the version tag
Create a git tag with the version from Step 1:
- Format: `v<version>` (e.g., `v1.0.14`)
- Run `git tag v<version>`

### Step 3: Push the tag to remote
Push the tag to the remote repository:
- Run `git push origin v<version>`
- This triggers the release workflow in `.github/workflows/release.yml`

### Step 4: Publish to crates.io
Publish the package to crates.io:
- Run `cargo publish`

## Output

- Print the version found in Cargo.toml
- Print the tag created
- Print confirmation of the tag push
- Print the output of cargo publish
- Explain that the release workflow will automatically build and create GitHub Release
136 changes: 136 additions & 0 deletions .pi/extensions/cargo-clippy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
import { isToolCallEventType } from "@mariozechner/pi-coding-agent";

export default function (pi: ExtensionAPI) {
// Track edited files per session (all turns) - use Set to deduplicate
const editedRustFiles = new Set<string>();
// Track if clippy has already run for current changes
let clippyRan = false;

// Track file edits throughout the session
pi.on("tool_call", async (event, ctx) => {
// Check for edit tool
if (isToolCallEventType("edit", event)) {
const path = event.input.path;
if (path.endsWith(".rs")) {
editedRustFiles.add(path);
// ctx.ui.notify(`Tracked rust file: ${path}`, "info");
// New edits mean we need to run clippy again
clippyRan = false;
}
}

// Check for write tool
if (isToolCallEventType("write", event)) {
const path = event.input.path;
if (path.endsWith(".rs")) {
editedRustFiles.add(path);
// ctx.ui.notify(`Tracked rust file: ${path}`, "info");
// New edits mean we need to run clippy again
clippyRan = false;
}
}
});

// Run check and clippy only at the end of the agent processing (agent_end)
// This fires once per user prompt, after all turns are complete
pi.on("agent_end", async (event, ctx) => {
// Skip if no Rust files were edited
if (editedRustFiles.size === 0) {
return;
}

// Skip if clippy already ran for current changes
if (clippyRan) {
return;
}

// Mark that we've run clippy - will reset if new edits happen in next prompt
clippyRan = true;

const uniqueFiles = [...editedRustFiles];
ctx.ui.notify(`🔍 Running cargo check on ${uniqueFiles.length} edited file(s): ${uniqueFiles.join(", ")}`, "info");

// First, run cargo check to catch compilation errors
ctx.ui.notify(`🔨 Running cargo check...`, "info");

const checkResult = await pi.exec("cargo", ["check", "-q"], {
cwd: ctx.cwd,
timeout: 120000, // 2 minutes
});

// If there are compilation errors, force agent to fix them
if (checkResult.code !== 0) {
const output = checkResult.stderr || checkResult.stdout;

ctx.ui.notify(`❌ Compilation errors found!`, "error");
ctx.ui.notify(output, "error");

// Pass raw output to the LLM asking to fix
await pi.sendUserMessage([
{
type: "text",
text: `Fix the following Rust compilation errors:\n\n${output}\n\nRun \`cargo check\` to verify after fixing.`
}
], { deliverAs: "followUp" });

// Keep tracking - agent needs to fix
clippyRan = false;
return;
}

ctx.ui.notify(`✅ Cargo check passed!`, "success");

ctx.ui.notify(`🔧 Running cargo clippy...`, "info");

// Try to auto-fix issues with cargo clippy --fix
const fixResult = await pi.exec("cargo", [
"clippy",
"--fix",
"--allow-dirty",
"--allow-staged",
], {
cwd: ctx.cwd,
timeout: 180000, // 3 minutes
});

// Check if any fixes were applied
if (fixResult.stdout.includes("Fixed") || fixResult.stderr.includes("Fixed")) {
ctx.ui.notify("✅ Applied clippy fixes automatically", "success");
}

// Now run clippy to check for issues
const clippyResult = await pi.exec("cargo", [
"clippy",
"-q", // no compilation messages
"--all-features"
], {
cwd: ctx.cwd,
timeout: 120000, // 2 minutes
});

// If clippy found issues, force agent to fix them
if (clippyResult.code !== 0) {
const output = clippyResult.stderr || clippyResult.stdout;

ctx.ui.notify(`⚠️ Clippy found issues!`, "warning");
ctx.ui.notify(output, "warning");

// Pass raw output to the LLM asking to fix
await pi.sendUserMessage([
{
type: "text",
text: `Fix the following clippy warnings/errors:\n\n${output}\n\nRun \`cargo clippy --all-features\` to verify after fixing.`
}
], { deliverAs: "followUp" });

// Keep tracking - agent needs to fix
clippyRan = false;
} else {
ctx.ui.notify(`✅ Cargo clippy passed!`, "success");

// Clear tracking now that we're done
editedRustFiles.clear();
}
});
}
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.0.14

- Upgrade crates and system dependencies.

## v1.0.13

- Upgrade crates.
Expand Down Expand Up @@ -106,5 +110,5 @@
- Add --user option.
- Add --batch-size option.
- Add --include-drafts flag.
- Fix calculation of number of review and exclude author.
- Fix calculation of number of reviews and exclude author.
- Fix calculation of number of approvals
Loading