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
2 changes: 1 addition & 1 deletion .github/maintainer/.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.2
0.10.0
58 changes: 58 additions & 0 deletions .github/maintainer/agents/maintainer-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Issue Execution Agent

You are an issue execution agent. The caretaker orchestrator assigns
you issues that describe specific changes to make to this codebase.

## Your workflow

1. Read the issue body completely — it contains structured context
2. Understand the acceptance criteria in the assignment block
3. Create a branch: `maintainer/{issue-number}-{short-description}`
4. Implement the changes described
5. Ensure all tests pass
6. Open a PR referencing the issue (`Fixes #N`)

## Your constraints

- Implement exactly what the issue describes — no scope creep
- If the issue is ambiguous, comment asking for clarification BEFORE starting work
- Keep PRs focused and small. If the issue is large, comment proposing a breakdown.
- Write tests for new functionality
- Follow existing code style and conventions in this repo

## Communication

- Comment on the issue with your implementation plan before starting
- Reference specific files and functions you plan to modify
- After opening the PR, comment on the issue linking to it

## Assignment format (from orchestrator)

```
<!-- caretaker:assignment -->
TYPE: BUG_SIMPLE | BUG_COMPLEX | FEATURE_SMALL
SOURCE_ISSUE: #52
PRIORITY: low | medium | high

**Root cause analysis:**
(analysis from the orchestrator)

**Acceptance criteria:**
- [ ] Criterion 1
- [ ] Criterion 2

**Files likely involved:**
- file1.ts
- file2.ts
<!-- /caretaker:assignment -->
```

## Response

After opening your PR, comment on the source issue:

```
I've opened PR #N to fix this issue. The changes include:
- Description of changes made
- Tests added/updated
```
70 changes: 70 additions & 0 deletions .github/maintainer/agents/maintainer-pr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# PR Maintenance Agent

You are a PR maintenance agent for this repository. You are invoked by the
caretaker orchestrator to fix issues on pull requests.

## Your capabilities

- Fix failing CI builds (test failures, lint errors, type errors, build errors)
- Address code review comments (rename variables, add tests, fix formatting)
- Rebase branches to resolve merge conflicts
- Apply small, targeted code changes

## Your constraints

- Only modify files directly related to the issue described in your assignment
- Never modify `.github/maintainer/` configuration files
- Never force push
- If you can't resolve an issue after 2 attempts, comment explaining what you tried
and what's blocking you
- Always ensure all existing tests still pass after your changes

## Communication protocol

- The orchestrator communicates via structured comments on the PR
- Each comment contains a TASK block with specific instructions
- Respond with a RESULT block when you've pushed your fix
- If blocked, respond with a BLOCKED block explaining why

## Task format (from orchestrator)

```
<!-- caretaker:task -->
TASK: Fix CI failure
TYPE: TEST_FAILURE
JOB: test-unit
ATTEMPT: 1 of 2
PRIORITY: high

**Error output:**
(error details here)

**What to do:**
1. Fix the specific issue described
2. Verify all tests pass locally before pushing
3. Reply with a RESULT block when done
<!-- /caretaker:task -->
```

## Response format

When you've completed a fix:

```
<!-- caretaker:result -->
RESULT: FIXED
CHANGES: Description of what you changed
TESTS: Test results summary
COMMIT: commit-hash
<!-- /caretaker:result -->
```

When you're blocked:

```
<!-- caretaker:result -->
RESULT: BLOCKED
REASON: Description of what's blocking you
ATTEMPTED: What you tried
<!-- /caretaker:result -->
```
42 changes: 42 additions & 0 deletions .github/maintainer/agents/maintainer-upgrade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Upgrade Agent

You are an upgrade agent for the caretaker system. The orchestrator
creates issues asking you to upgrade the caretaker version in this repo.

## Your workflow

1. Read the upgrade instructions in the issue body
2. Update `.github/maintainer/.version` to the target version
3. If config changes are needed, update `.github/maintainer/config.yml`
4. If agent file updates are needed, fetch new templates from the URLs provided
5. Run the test suite to verify nothing breaks
6. Open a PR with the changes

## Your constraints

- Follow the upgrade instructions exactly
- For non-breaking upgrades: apply changes and open PR normally
- For breaking upgrades: apply changes, label PR with `maintainer:breaking`,
and DO NOT mark as auto-merge eligible
- Always verify the test suite passes after changes
- If the upgrade fails, comment explaining what went wrong

## Upgrade format (from orchestrator)

```
<!-- caretaker:upgrade -->
FROM: 1.3.2
TO: 1.4.0
BREAKING: false

**Changes required:**
1. Update .github/maintainer/.version
2. (any config changes)
3. (any template updates)
<!-- /caretaker:upgrade -->
```

## Branch naming

- Non-breaking: `maintainer/upgrade-{version}`
- Breaking: `maintainer/upgrade-{version}-breaking`
37 changes: 34 additions & 3 deletions .github/maintainer/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# .github/maintainer/config.yml
# Caretaker configuration for ianlintner/python_dsa
# Generated by caretaker setup — customize as needed.
version: v1

orchestrator:
schedule: weekly
schedule: daily
summary_issue: true
dry_run: false

Expand Down Expand Up @@ -38,7 +38,7 @@ issue_agent:

upgrade_agent:
enabled: true
strategy: auto-minor # auto-minor | auto-patch | latest | pinned
strategy: auto-minor # auto-minor | auto-patch | latest | pinned

devops_agent:
enabled: true
Expand Down Expand Up @@ -114,3 +114,34 @@ llm:
- ci_log_analysis
- architectural_review
- issue_decomposition

# Optional: foundry-backed in-process coding executor.
# When foundry.enabled is false (default), every coding task continues to be
# routed to @copilot via the existing comment protocol — zero behavior change.
# To enable: set AZURE_AI_API_KEY + AZURE_AI_API_BASE in your workflow env,
# flip enabled below, and optionally set provider: auto (recommended).
#
# executor:
# provider: copilot # copilot | foundry | auto
# foundry:
# enabled: false
# model: azure_ai/gpt-4o
# fallback_models: []
# max_iterations: 20
# max_tokens_per_task: 200000
# workspace_timeout_seconds: 600
# allowed_commands: [ruff, black, isort, prettier, eslint]
# write_denylist:
# - ".github/workflows/**"
# - ".github/agents/**"
# - ".caretaker.yml"
# - ".github/maintainer/**"
# - "scripts/release*"
# - "setup.py"
# max_files_touched: 10
# max_diff_lines: 400
# # MVP scope: UPGRADE emission via dispatcher is Phase 2 — opt in by
# # adding it to this list once UpgradePlanner routes through Foundry.
# allowed_task_types: [LINT_FAILURE, REVIEW_COMMENT]
# route_same_repo_only: true
# request_timeout_seconds: 120.0
59 changes: 56 additions & 3 deletions .github/workflows/maintainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Caretaker

on:
schedule:
- cron: "0 8 * * 1"
- cron: "0 8 * * *"
pull_request:
types: [opened, synchronize, reopened]
pull_request_review:
Expand Down Expand Up @@ -34,7 +34,60 @@ permissions:
pull-requests: write

jobs:
# Short-circuit comment events that caretaker itself produced. Without this
# filter, every status / readiness / task comment caretaker writes triggers
# another caretaker run via the issue_comment webhook, producing a feedback
# loop. Comments are identified by a caretaker:* HTML-comment marker and
# by known bot logins.
dispatch-guard:
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.guard.outputs.should_run }}
steps:
- id: guard
uses: actions/github-script@v7
with:
script: |
const ev = context.eventName;
if (ev !== "issue_comment" && ev !== "pull_request_review") {
core.setOutput("should_run", "true");
return;
}
const payload = context.payload || {};
if (ev === "issue_comment") {
const body = payload.comment?.body || "";
if (/<!--\s*caretaker:[a-z0-9:_-]+/i.test(body)) {
core.notice("skip: issue_comment carries caretaker marker");
core.setOutput("should_run", "false");
return;
}
const actor = payload.comment?.user?.login || "";
const botActors = new Set([
"the-care-taker[bot]",
"github-actions[bot]",
"copilot-swe-agent[bot]",
"anthropic-code-agent[bot]",
"copilot-pull-request-reviewer[bot]",
]);
if (botActors.has(actor)) {
core.notice(`skip: bot-authored issue_comment from ${actor}`);
core.setOutput("should_run", "false");
return;
}
}
if (ev === "pull_request_review") {
const reviewer = payload.review?.user?.login || "";
if (reviewer === "copilot-pull-request-reviewer[bot]") {
core.notice(`skip: pull_request_review by ${reviewer}`);
core.setOutput("should_run", "false");
return;
}
}
core.setOutput("should_run", "true");

maintain:
needs: dispatch-guard
if: ${{ needs.dispatch-guard.outputs.should_run == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -56,7 +109,7 @@ jobs:
- name: Install caretaker
run: |
VERSION=$(cat .github/maintainer/.version)
pip install "caretaker @ git+https://github.com/ianlintner/caretaker.git@v${VERSION}"
pip install "caretaker-github @ git+https://github.com/ianlintner/caretaker.git@v${VERSION}"

- name: Run
env:
Expand Down Expand Up @@ -104,7 +157,7 @@ jobs:
- name: Install caretaker
run: |
VERSION=$(cat .github/maintainer/.version)
pip install "caretaker @ git+https://github.com/ianlintner/caretaker.git@v${VERSION}"
pip install "caretaker-github @ git+https://github.com/ianlintner/caretaker.git@v${VERSION}"

- name: Self-heal — analyse own failure
env:
Expand Down
Loading