jonah-fleet 1.0.0

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +133 -0
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.js +454 -0
  5. package/package.json +47 -0
  6. package/schema.json +49 -0
  7. package/templates/docs/AGENTS.template.md +54 -0
  8. package/templates/prompts/ORCHESTRATION.md +97 -0
  9. package/templates/prompts/_prompt-template.md +43 -0
  10. package/templates/prompts/autowork.md +125 -0
  11. package/templates/prompts/dependency-update-security-check.md +44 -0
  12. package/templates/prompts/issues-housekeeping.md +55 -0
  13. package/templates/prompts/optimizer.md +72 -0
  14. package/templates/prompts/peer-review.md +112 -0
  15. package/templates/prompts/product-planning.md +67 -0
  16. package/templates/skills/code-review/SKILL.md +87 -0
  17. package/templates/skills/code-review/agents/openai.yaml +3 -0
  18. package/templates/skills/codebase-design/DEEPENING.md +37 -0
  19. package/templates/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
  20. package/templates/skills/codebase-design/SKILL.md +114 -0
  21. package/templates/skills/codebase-design/agents/openai.yaml +3 -0
  22. package/templates/skills/diagnosing-bugs/SKILL.md +138 -0
  23. package/templates/skills/diagnosing-bugs/agents/openai.yaml +3 -0
  24. package/templates/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +44 -0
  25. package/templates/skills/domain-modeling/ADR-FORMAT.md +47 -0
  26. package/templates/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  27. package/templates/skills/domain-modeling/SKILL.md +74 -0
  28. package/templates/skills/domain-modeling/agents/openai.yaml +3 -0
  29. package/templates/skills/resolving-merge-conflicts/SKILL.md +14 -0
  30. package/templates/skills/resolving-merge-conflicts/agents/openai.yaml +3 -0
  31. package/templates/skills/tdd/SKILL.md +38 -0
  32. package/templates/skills/tdd/agents/openai.yaml +3 -0
  33. package/templates/skills/tdd/mocking.md +59 -0
  34. package/templates/skills/tdd/tests.md +77 -0
  35. package/templates/skills/to-spec/SKILL.md +75 -0
  36. package/templates/skills/to-spec/agents/openai.yaml +5 -0
  37. package/templates/skills/to-tickets/SKILL.md +105 -0
  38. package/templates/skills/to-tickets/agents/openai.yaml +5 -0
  39. package/templates/skills/triage/AGENT-BRIEF.md +207 -0
  40. package/templates/skills/triage/OUT-OF-SCOPE.md +105 -0
  41. package/templates/skills/triage/SKILL.md +112 -0
  42. package/templates/skills/triage/agents/openai.yaml +5 -0
  43. package/templates/skills/writing-for-agents/SKILL-MECHANICS.md +22 -0
  44. package/templates/skills/writing-for-agents/SKILL.md +81 -0
  45. package/templates/skills/writing-for-agents/agents/openai.yaml +3 -0
  46. package/templates/workflows/autowork-cron.yml +154 -0
  47. package/templates/workflows/dependency-check-cron.yml +85 -0
  48. package/templates/workflows/issues-housekeeping-cron.yml +85 -0
  49. package/templates/workflows/prompt-optimizer-cron.yml +85 -0
  50. package/templates/workflows/sync-fleet.yml +63 -0
  51. package/templates/workflows/trigger-autowork-on-bug.yml +101 -0
  52. package/templates/workflows/trigger-autowork-on-merge.yml +130 -0
  53. package/templates/workflows/trigger-review-routine.yml +141 -0
package/schema.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "JonahFleetManifest",
4
+ "description": "Configuration manifest for Jonah Fleet autonomous agents",
5
+ "type": "object",
6
+ "properties": {
7
+ "$schema": {
8
+ "type": "string"
9
+ },
10
+ "version": {
11
+ "type": "string",
12
+ "description": "The pinned fleet version or semver range"
13
+ },
14
+ "preset": {
15
+ "type": "string",
16
+ "enum": ["minimal", "standard", "full", "custom"],
17
+ "default": "standard",
18
+ "description": "Selected routine bundle preset"
19
+ },
20
+ "routines": {
21
+ "type": "object",
22
+ "properties": {
23
+ "autowork": { "type": "boolean" },
24
+ "peer-review": { "type": "boolean" },
25
+ "optimizer": { "type": "boolean" },
26
+ "issues-housekeeping": { "type": "boolean" },
27
+ "dependency-update-security-check": { "type": "boolean" },
28
+ "product-planning": { "type": "boolean" }
29
+ },
30
+ "additionalProperties": false,
31
+ "description": "Granular routine toggles"
32
+ },
33
+ "skills": {
34
+ "type": "array",
35
+ "items": { "type": "string" },
36
+ "description": "List of core engineering skills to install/sync"
37
+ },
38
+ "autoUpdate": {
39
+ "type": "object",
40
+ "properties": {
41
+ "enabled": { "type": "boolean", "default": true },
42
+ "channel": { "type": "string", "enum": ["stable", "latest"], "default": "stable" }
43
+ },
44
+ "additionalProperties": false
45
+ }
46
+ },
47
+ "required": ["version", "preset", "routines", "skills"],
48
+ "additionalProperties": false
49
+ }
@@ -0,0 +1,54 @@
1
+ # AGENTS.md (also GEMINI.md & CLAUDE.md)
2
+
3
+ ## Project Overview
4
+
5
+ {Brief 1-2 paragraph description of the project, core capabilities, and target users.}
6
+
7
+ ## Tech Stack
8
+
9
+ - **Framework / Language**: {e.g. Next.js 15, TypeScript strict mode, Python 3.12, Go 1.23}
10
+ - **Backend / Database**: {e.g. PostgreSQL, Supabase, SQLite, Redis}
11
+ - **Styling / UI**: {e.g. Tailwind CSS, Radix UI, CSS Modules}
12
+ - **Testing**: {e.g. Vitest, Playwright, Jest, pytest}
13
+ - **Deployment**: {e.g. Vercel, Cloudflare, Docker, AWS}
14
+ - **Package Manager**: {e.g. npm, pnpm, yarn, uv, pip}
15
+
16
+ ## Development Workflows
17
+
18
+ ```bash
19
+ npm run dev # Start local development server
20
+ npm run build # Production build
21
+ npm run lint # ESLint / static linter
22
+ npm run type-check # Type verification (tsc --noEmit)
23
+ npm test # Run test suite
24
+ ```
25
+
26
+ ## Project Structure
27
+
28
+ ```
29
+ src/
30
+ app/ # App routes and views
31
+ components/ # UI components
32
+ lib/ # Domain logic and helpers
33
+ tests/ # Test suites
34
+ .agents/ # Local agent skills and configuration
35
+ .github/prompts/ # Autonomous agent routines (managed by jonah-fleet)
36
+ ```
37
+
38
+ ## Key Architecture Patterns
39
+
40
+ - **Separation of Concerns**: Keep business logic pure and isolated from UI rendering and framework adapters.
41
+ - **Error Handling**: Validate inputs at server and module boundaries. Return explicit structured errors.
42
+ - **Testing Philosophy**: Write regression unit tests for every bug fix and integration tests for key workflows.
43
+
44
+ ## Conventions
45
+
46
+ - **Language**: All code, comments, commit messages, and PR titles must be written in **English**.
47
+ - **Changelog**: Append user-facing changes to `CHANGELOG.md` under today's date section.
48
+ - **Antigravity Run Footer**: Every GitHub comment, issue edit, and PR description posted by automated Actions must end with `_Generated by [Antigravity](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID})_`.
49
+
50
+ ## Security Guidelines
51
+
52
+ - Auth boundaries required for all sensitive mutations.
53
+ - Never commit credentials, tokens, or secret keys to version control.
54
+ - Validate request inputs and sanitize outputs.
@@ -0,0 +1,97 @@
1
+ # Orchestration Model (Symphony Alignment)
2
+
3
+ How agent routines in this repository are dispatched, claimed, and reconciled — plus the single-source-of-truth definitions the routine prompts point at (Stale-claim, Log delivery fallback, Measurement issues). Extracted from `AGENTS.md` so this agent-system reference stays out of every session's auto-loaded context; `AGENTS.md` keeps the invariants and points here.
4
+
5
+ **Read this when** you need the claim protocol, the stale-claim conditions, the log-push rules, or the measurement-issue protocol — i.e. most Autowork, Peer Review, Analytics Review, and Issues Housekeeping runs.
6
+
7
+ This project's automation is a GitHub-native instance of the pattern formalized for orchestrating coding agents against an issue tracker. There is **no long-running orchestrator daemon**; the roles map onto GitHub primitives:
8
+
9
+ | Concept | Implementation in this repo |
10
+ |---|---|
11
+ | `WORKFLOW.md` (repo-owned config + prompt templates) | `AGENTS.md` (aliased as `GEMINI.md`/`CLAUDE.md`) + `.github/prompts/*.md` |
12
+ | Orchestrator (poll, dispatch, reconcile) | GitHub Actions triggers + scheduled routine sessions |
13
+ | Issue tracker | GitHub Issues |
14
+ | Agent runner | An ephemeral agent session (Antigravity CLI `agy`) in an isolated fresh clone |
15
+ | Tracker is reader/scheduler; mutations happen via agent tools | Routines only schedule; the agent session makes every GitHub write |
16
+
17
+ Dispatch is both **scheduled** and **event-driven**. All routines run as ephemeral agent sessions via **Antigravity CLI (`agy`)** powered by **Gemini 3.7 Flash (High reasoning)**. The routine suite is calibrated to operate within a **strict 70% weekly token ceiling across all routines combined**, supervised by `optimizer.md`:
18
+ - **Scheduled cron sweeps**: Autowork runs periodically (`autowork-cron.yml`), complemented by prompt optimization (`prompt-optimizer-cron.yml`), issues housekeeping (`issues-housekeeping-cron.yml`), and dependency security checks (`dependency-check-cron.yml`).
19
+ - **Event-driven triggers**: GitHub Actions workflows fire routines on events so work starts within seconds instead of waiting for scheduled ticks:
20
+ - `trigger-review-routine.yml` fires Peer Review when a PR is marked ready for review (with debounce on rapid pushes).
21
+ - `trigger-autowork-on-merge.yml` fires Autowork in **Targeted mode** when a PR merges to `main` and unblocks the next unit of chained work.
22
+ - `trigger-autowork-on-bug.yml` fires Autowork when an issue becomes a high-priority bug.
23
+
24
+ Both autowork triggers pass the target issue via environment variables (`ISSUE_NUMBER`, `ISSUE_URL`), putting autowork.md into **Targeted mode** (working the named issue ahead of Phase 1 convergence). Single-flight per issue is strictly enforced across both scheduled and event-driven runs.
25
+
26
+ Invariants deliberately upheld from this spec:
27
+
28
+ - **Single-flight per issue** — at most one run works an issue at a time, enforced by the autowork claim protocol (assign → read-back → earliest-timestamp tiebreak). For **umbrella** issues, single-flight is maintained at the *child-issue* level so slices progress cleanly.
29
+ - **Recover dead-run claims** — a crashed run's orphaned claim is released back to the pool rather than starving the issue, both opportunistically during candidate selection and periodically via issues housekeeping.
30
+ - **Reader/writer separation** — the routine that authors a PR never merges it; the Peer Review routine is the sole merge authority for **product** PRs. (Operational log-only PRs are exempt; see Log delivery fallback.)
31
+ - **Warm-Context Review Synchronization** — Autowork maintains an active warm session during implementation, polling for Peer Review's verdict. When Peer Review bounces a PR to draft with findings, Autowork immediately detects the draft state in-session, applies fixes directly to its warm working tree, and re-marks the PR ready—re-firing Peer Review for Round N+1 without cold-start overhead.
32
+
33
+ ---
34
+
35
+ ## Stale-Claim Definition
36
+
37
+ Single source of truth for both autowork candidate reclamation and housekeeping sweeps. An assigned issue is a *stale claim* (a dead autowork run's orphaned reservation, safe to release) only when **all** of these hold:
38
+
39
+ 1. **It is an autowork claim, not a manual one.** The issue carries a `🔒 Claimed by autowork run …` comment. An assigned issue with **no** such comment is never stale; leave it alone (it may be a person working manually).
40
+ 2. **No live work exists.** There is **no open PR** referencing the issue (`Closes #N`). An open PR is live, recoverable work that autowork Phase 1 owns — never reclaim it, at any age.
41
+ 3. **The claim is old.** The most recent `🔒 Claimed by autowork run …` comment's GitHub creation time (`created_at`) is **more than 6 hours** ago. Measure age from that `created_at` only — never the issue's `updated_at`.
42
+
43
+ **Releasing a stale claim is a destructive write and MUST be guarded:**
44
+ - **Re-read immediately before writing.** Re-read the issue (`issue_read`) right before the unassign and re-confirm conditions 1–3 still hold. If any no longer holds, abort the release and move on.
45
+ - **Remove only the named dead owner.** Unassign that specific login; never blindly clear all assignees.
46
+
47
+ ---
48
+
49
+ ## Routine Matching & Invocation
50
+
51
+ **Identify the applicable routine at the start of every conversation, before doing any work:**
52
+
53
+ 1. **Explicit invocation** — if the incoming prompt names a routine or was fired by a GitHub Actions workflow that references one, follow that routine's instruction file immediately.
54
+ 2. **Content match** — compare the task against the routine table below. When matching an interactive request from a human, name the matched routine and confirm before proceeding.
55
+ 3. **No match** — follow the general Working Practices, PR Workflow, and documentation rules with no routine-specific constraints.
56
+
57
+ | Routine | File | Applies when the conversation is about... |
58
+ |---|---|---|
59
+ | Autowork | `.github/prompts/autowork.md` | Converging on open work: addressing PR review comments, closing issues whose PRs merged, then claiming and implementing the highest-priority unclaimed issue |
60
+ | Peer Review | `.github/prompts/peer-review.md` | Reviewing a pull request (a named PR or scan mode) and merging it or leaving findings and bouncing to draft |
61
+ | Prompt Optimizer | `.github/prompts/optimizer.md` | Diagnosing failures, inefficiency, token anomalies, and analyzing resolved bugs to propose prompt/test/workflow fixes and upstream contributions |
62
+ | Issues Housekeeping | `.github/prompts/issues-housekeeping.md` | Sweeping open issues for staleness, duplicates, label drift, priority accuracy, and orphaned claims |
63
+ | Dependency Update & Security Check | `.github/prompts/dependency-update-security-check.md` | Checking dependencies for updates and known vulnerabilities, opening actionable PRs |
64
+ | Product Planning | `.github/prompts/product-planning.md` | Turning roadmap priorities into staged issues (`/to-tickets`) and formal PRDs (`/to-spec`) |
65
+
66
+ ---
67
+
68
+ ## Engineering Skills Integration
69
+
70
+ The routines invoke specialized engineering skills at key workflow checkpoints:
71
+
72
+ - **Autowork (`autowork.md`)**:
73
+ - `/diagnosing-bugs`: In Targeted mode or for `bug` issues — establishes reproduction feedback loop before patching.
74
+ - `/domain-modeling` & `/codebase-design`: Consults domain context and establishes deep module interfaces.
75
+ - `/tdd`: Drives red-green-refactor test-first implementation for each issue.
76
+ - `/code-review`: Evaluates Standards (`AGENTS.md`) and Spec (`## Tasks`) during pre-ready self-audit.
77
+ - `/resolving-merge-conflicts`: Resolves merge collisions by intent against primary sources when syncing with `origin/main`.
78
+ - **Peer Review (`peer-review.md`)**:
79
+ - `/code-review`: Drives multi-angle diff evaluation along Standards and Spec axes.
80
+ - `/resolving-merge-conflicts`: Resolves merge conflicts mechanically before squash-merging.
81
+ - **Issues Housekeeping (`issues-housekeeping.md`)**:
82
+ - `/triage`: Evaluates incoming issues into canonical roles.
83
+ - **Product Planning (`product-planning.md`)**:
84
+ - `/domain-modeling`: Pressure-tests proposals and records domain terms / ADRs.
85
+ - `/to-spec`: Authors formal PRDs for larger proposals.
86
+ - `/to-tickets`: Decomposes approved epics/proposals into dependency-linked issues.
87
+ - **Prompt Optimizer (`optimizer.md`)**:
88
+ - `/writing-for-agents`: Drafts crisp, token-efficient prompt and rule updates.
89
+
90
+ ---
91
+
92
+ ## Log Delivery Fallback
93
+
94
+ Single source of truth for every routine's Logging section:
95
+ 1. **Direct commit to `main` is default**: For operational run logs under `.github/prompts/logs/**`, commit directly to `main` via GitHub API or git push.
96
+ 2. **Draft PR fallback**: If direct push fails, commit the log to a dedicated, fresh branch and open a draft PR carrying only the log files.
97
+ 3. **Automated landing**: `auto-merge-log-prs.yml` or `issues-housekeeping.md` lands accumulated log PRs. Draft log PRs are never reviewed by Peer Review and do not count toward Autowork's backpressure limits.
@@ -0,0 +1,43 @@
1
+ # {Routine Name}
2
+
3
+ ## Objective
4
+
5
+ {One paragraph describing the goal. Be specific about scope — what is IN and OUT.}
6
+
7
+ ## Definition of Done
8
+
9
+ The run is SUCCESS only if ALL of these are true:
10
+
11
+ - [ ] {Concrete, binary criterion 1}
12
+ - [ ] {Concrete, binary criterion 2}
13
+ - [ ] {Concrete, binary criterion 3}
14
+
15
+ If any criterion cannot be met, stop immediately and log FAILURE with the reason.
16
+
17
+ ## Constraints
18
+
19
+ - **Max iterations**: {N} — after {N} tool call rounds without completing the Definition of Done, STOP. Log FAILURE with category `token_limit`. Do not retry the same failing approach.
20
+ - **Max scope**: {scope limit, e.g. "one issue per run", "one PR per run"}. Do not expand scope mid-run.
21
+ - **No speculative work**: only take actions directly required by the Definition of Done. Do not refactor adjacent code, open bonus issues, or add improvements not requested.
22
+ - **Language Requirement**: All GitHub issue titles, descriptions, task checklists, and comments MUST be written in **English**.
23
+ - **Session link footer**: sign every GitHub post with the Antigravity run footer (`_Generated by [Antigravity](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID})_`).
24
+
25
+ ## Negative examples (DO NOT do these)
26
+
27
+ - {Example of a wasteful pattern, e.g. "Do not re-read files you already read in this run"}
28
+ - {Example of scope creep, e.g. "Do not fix lint warnings unrelated to the task"}
29
+ - {Example of token burn, e.g. "Do not retry a failing API call more than twice"}
30
+
31
+ ## Instructions
32
+
33
+ {The actual task instructions go here — step by step.}
34
+
35
+ ## Logging
36
+
37
+ After completing (SUCCESS or FAILURE), write a log file to `.github/prompts/logs/{routine-name}/{timestamp}.md` following the schema in `.github/prompts/logs/_template.md`. Include:
38
+ - The prompt SHA (run `git rev-parse --short HEAD:.github/prompts/{routine-name}.md`)
39
+ - Every Definition of Done criterion with YES/NO and evidence
40
+ - Full execution trace with tool calls
41
+ - If FAILURE: root cause, category, and suggested fix
42
+
43
+ **Important**: Commit the log file directly to `main` and push — explicitly permitted for files under `.github/prompts/logs/**`. Follow the Log delivery fallback in `ORCHESTRATION.md` if direct push fails.
@@ -0,0 +1,125 @@
1
+ # Autowork
2
+
3
+ ## Objective
4
+
5
+ This routine runs in two modes, decided in Step 0. In **Scan mode** (a scheduled run, no issue named): converge on existing open work before starting anything new — priority order (1) address review comments on open PRs, (2) close issues whose PRs are merged, (3) only then pick a new issue. In **Targeted mode** (fired with a specific issue in the payload): work *that* issue as the run's objective, **ahead of** the convergence steps above — the fire exists to start its issue immediately, so an unrelated pending PR does not preempt it (Step 0.5); fall back to the Scan flow only if the target is ineligible. Either way, at most one issue may be **implemented** (code written, branch pushed) per run — the sole exception is batching up to 3 same-recipe slices of a single *umbrella* issue into one child issue + PR (step 12a); that batch is still one concern, not a second issue. Evaluating a candidate and finding it infeasible does not count as "working" it: in Scan mode, step 12's infeasible-continuation cap lets a run evaluate up to 3 candidates for feasibility before it must stop, so a single blocked issue can't consume an entire run without any other progress being attempted.
6
+
7
+ ## Definition of Done
8
+
9
+ This routine runs in two modes (Step 0): **Targeted** (a fire named an issue) and **Scan** (scheduled / no issue named). In **Targeted mode**, the run is SUCCESS if you claimed and implemented the target issue to a pushed draft PR (or documented why it is infeasible and released the claim, or ended via step 13's **collision bail** — a competing open PR discovered immediately before opening yours: branch pushed, claim comment annotated, no unassign, no second PR) — or, when the target was *ineligible* (closed / has an open PR / claimed by a live run), you fell back to the Scan flow and met the Scan criteria below.
10
+
11
+ In **Scan mode**, the run is SUCCESS only if ALL of these are true:
12
+
13
+ - [ ] Checked all open PRs for unresolved or unaddressed review comments and pushed fixes for any that are actionable
14
+ - [ ] Closed any issues whose corresponding PRs are all merged
15
+ - [ ] If no open PRs needed attention: picked the highest-priority *unclaimed* issue (P1 > P2 > P3); if it turned out to be already-done (step 10 — all its PRs merged), closed it and moved on to the next-priority candidate rather than stopping there; otherwise **claimed it before starting work** (see the Claim protocol), and either implemented a fix and **opened a draft pull request on GitHub via `gh pr create --draft`** or left a comment explaining why autonomous completion is blocked and released the claim, then repeated candidate selection for the next-priority issue per step 12's infeasible-continuation cap
16
+ - [ ] If an issue was implemented: successfully opened a draft pull request on GitHub via `gh pr create --draft` referencing the issue (`Closes #N`) in its body, verified the PR exists (a returned PR URL is mandatory), updated the issue's `## Tasks` checkboxes (`- [ ]` → `- [x]`) for every deliverable the PR ships, marked the PR ready for review (`gh pr ready <PR>`), and executed step 15's in-session review wait (never stop at merely pushing the branch or editing the issue; a pushed branch with no open PR on GitHub is a fatal invariant violation and must be logged as FAILURE)
17
+ - [ ] Did not open a new PR while any existing PR by this routine has unaddressed review comments (a finding you have replied to with a rationale counts as *addressed*, even if the thread is still technically unresolved) — **Targeted mode is exempt**
18
+ - [ ] Never worked an issue that was already actively claimed (assigned) by another live run, and confirmed sole ownership of the claim before writing any code — reclaiming a *stale* claim (a dead run's orphaned assignment, per step 10a) is permitted
19
+ - [ ] If work was an umbrella slice/batch (step 12a): the child issue created for it carries the required Summary/Tasks/Why/Complexity template and exactly one type/size/priority label, and the `🧭 Decomposition plan` markers were left `🔍 in review` until the child PR merges
20
+
21
+ If any criterion cannot be met, stop immediately and log FAILURE with the reason.
22
+
23
+ ## Constraints
24
+
25
+ - **Max iterations**: 65 — after 65 tool call rounds without completing the Definition of Done, STOP. Log FAILURE with category `token_limit`. Do not retry the same failing approach.
26
+ - **Max scope**: at most one issue may be **implemented** per run. Do not pick up a second, unrelated issue to implement after finishing (or abandoning mid-implementation) the first. (Umbrella slice batching up to 3 slices per step 12a is allowed).
27
+ - **No mid-run context switch**: priorities are evaluated ONCE, at the start of the run (Phase 1 → Phase 2). Finish the issue you started; the next run's Phase 1 will pick up newly surfaced work.
28
+ - **No speculative work**: only take actions directly required by the Definition of Done. Do not refactor adjacent code, open bonus issues, or add improvements not requested by the issue.
29
+ - **Single-flight per issue**: multiple autowork runs can execute concurrently. An issue is a shared resource — never begin implementing one without first claiming it (see the Claim protocol in Phase 2).
30
+ - **Language Requirement**: All GitHub issue titles, descriptions, task checklists, and comments MUST be written in **English**.
31
+ - **Session link footer**: sign every GitHub post (issue comments, PR comments, PR descriptions) with the Antigravity run footer (`_Generated by [Antigravity](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID})_`). Inline review-thread line comments are exempt.
32
+
33
+ ## Negative examples (DO NOT do these)
34
+
35
+ - Do not address a subset of review findings and stop — handle ALL findings in one run before stopping or marking the PR as ready.
36
+ - Do not mark a PR as ready for review without first re-fetching review threads *and PR-level comments* and confirming every finding matching step 2's trust & noise rules has been handled.
37
+ - Do not strand a PR in draft because you disagree with a finding — reply with your rationale, mark the PR ready, and let peer-review re-evaluate.
38
+ - Do not push a branch and stop without running `gh pr create --draft` to actually open the pull request — a pushed branch with no open PR cannot be picked up by the peer-review routine.
39
+ - Do not open a new PR if you already have 3+ open PRs — converge before creating more (**Scan mode only**; Targeted mode is exempt).
40
+ - Do not *implement* multiple *unrelated* issues in a single run.
41
+ - Do not close an issue just because it is old — only close if the work is done and PRs are merged.
42
+ - Do not attempt an issue that requires environment secrets, manual testing, or external service setup — mark it as infeasible with a comment.
43
+ - Do not start implementing an issue before claiming it (both assignment AND claim comment).
44
+ - Do not mark a PR ready while its `mergeable_state` is `dirty` — resolve merge conflicts first.
45
+
46
+ ## Instructions
47
+
48
+ ### Step 0: Determine Targeted vs Scan mode (before Phase 1)
49
+
50
+ This routine runs in two modes, decided here before any other work:
51
+ - **Targeted mode** — an environment variable `$ISSUE_NUMBER` (or explicit issue payload) names a target issue. Work *that* issue as the run's objective, **ahead of** Phase 1 convergence and the normal priority scan.
52
+ - **Scan mode** — no issue is named (a scheduled cron run). Run Phase 1, then select an issue by priority in Phase 2.
53
+
54
+ Check if `$ISSUE_NUMBER` environment variable is set (or scan invocation text for `#<number>` / `/issues/<number>`):
55
+ - **Found one → Targeted mode.** Record it as this run's target issue and proceed to Step 0.5.
56
+ - **None found → Scan mode.** Proceed as a scheduled run: Phase 1, then normal priority selection in Phase 2.
57
+
58
+ ### Step 0.5: Targeted mode — work the target issue first (only when Step 0 found one)
59
+
60
+ a. **Read the target issue and check eligibility.** Eligible = open, unassigned or reclaimable stale claim, no open PR (`Closes #N`), and not carrying `needs-human` or `needs-design`.
61
+ - **Ineligible** → fall back to Phase 1 and run the normal Scan flow.
62
+ b. **Eligible → claim, then implement.** Call `get_me` once to learn your own login (step 7), reclaim stale claim if applicable (step 10a), run Claim protocol (step 11), evaluate and implement per steps 12–13, open draft PR, and run in-session review wait (step 15).
63
+
64
+ ### Phase 1: Converge on open work (Scan mode; skipped in Targeted mode)
65
+
66
+ 1. List all open PRs authored by this routine.
67
+ 2. For each open PR, fetch ALL review threads and PR-level comments. Filter for actionable findings matching trust & noise rules (author login matching `get_me`, non-noise). Address every single one in this run — push fixes for actionable findings, reply to clarifying questions, and comment on deferred items.
68
+ 3. For PRs where you have addressed all findings:
69
+ 3a. **Pre-ready self-audit** (run before marking ready):
70
+ - **Automated review passes**: run `/code-review` (evaluating along Standards in `AGENTS.md` and Spec in the issue's `## Tasks`) and security review over the diff. Fix what they flag.
71
+ - **Repository conventions scan**: read and verify all rules and conventions specified in `AGENTS.md` (or `CLAUDE.md`/`GEMINI.md`), project-level skills in `.agents/skills/`, and project documentation.
72
+ - **Documentation accuracy**: update relevant docs (`ARCHITECTURE.md`, `CODEMAP.md`, `API.md`, `CHANGELOG.md` if maintained by repo).
73
+ - **Build & type-check verification**: run the repository's test, type-check, and lint commands from `AGENTS.md` (e.g. `npm test`, `npm run type-check`, `npm run lint`, `pytest`, `cargo test`). Confirm zero errors and zero test failures.
74
+ - **Clean-merge gate**: verify `git merge-tree origin/main HEAD` reports no conflicts.
75
+ Only mark the PR ready after passing every check above.
76
+ 3b. **Ping-pong cap**: If this same PR has bounced between draft and ready 3 or more times over the same substantive finding, stop re-marking it ready. Post a comment summarizing the disagreement for human resolution and leave the PR in draft.
77
+ 4. Check open issues that have linked merged PRs — close them.
78
+ 5. If any PR was updated in this phase, STOP — run is SUCCESS.
79
+
80
+ ### Phase 2: New work (only if Phase 1 had nothing to do)
81
+
82
+ 6. Count open PRs authored by automated sessions representing live reviewable work (excluding log-only PRs). If 3 or more non-log PRs are open, STOP — run is SUCCESS with "Too many open PRs, converging first".
83
+ 7. Call `get_me` once to learn your own GitHub account (`login`).
84
+ 8. List open issues sorted by priority labels (P1 > P2 > P3). Within the same priority tier, order by type (`bug`/`security` before others), then oldest first. Skip assigned issues (unless stale claim per `ORCHESTRATION.md`), issues with open PRs, issues labeled `needs-human` or `needs-design`, and issues under cross-run cooldown.
85
+ 9. If no eligible candidate exists, STOP — run is SUCCESS with "No unclaimed work available".
86
+ 10. If the candidate should be closed already (work done, PRs merged), close it and return to step 8.
87
+ 10a. **Stale-claim reclamation:** If candidate is a stale claim per `ORCHESTRATION.md`, re-read immediately before writing, unassign the dead owner, post reclamation comment, and proceed to claim.
88
+ 11. **Claim protocol:**
89
+ a. Re-read candidate issue immediately before claiming (`issue_read`). If assigned, abort and pick next candidate.
90
+ b. Claim atomically: assign yourself (`login` from step 7) AND post claim comment `🔒 Claimed by autowork run {timestamp}`.
91
+ c. Confirm sole ownership by counting `🔒 Claimed by autowork run` comments. Earliest `created_at` wins. If you lost the race, leave assignee as is, annotate your comment, and pick next candidate.
92
+ 12. Evaluate whether the claimed issue can be completed autonomously:
93
+ - Confirm your `🔒` claim comment is present on the issue.
94
+ - Read the issue description, linked code, and comment thread.
95
+ - If bug: use `/diagnosing-bugs` to establish reproduction test before fixing.
96
+ - If large/complex: use `/domain-modeling` and `/codebase-design`.
97
+ - If infeasible: comment explaining blocker, release claim (unassign), and select next candidate (up to 3 infeasible evaluations per run). If permanent blocker on 2nd strike, apply `needs-human` label and tag repo owner.
98
+ 12a. **Umbrella-issue handoff + batching:** If candidate is an umbrella epic:
99
+ - Read `🧭 Decomposition plan` comment (or create if first run).
100
+ - Pick next slice(s), batching up to 3 same-recipe slices into one child issue + PR.
101
+ - Create and claim child issue first, then update plan marker to `🚧 in progress — child #M`, release umbrella claim, and implement against child.
102
+ 13. **Implementation & PR creation:**
103
+ - Branch from freshly fetched `origin/main` with descriptive name (e.g. `feat/...` or `fix/...`).
104
+ - Drive implementation via `/tdd` (red-green-refactor).
105
+ - Run repository tests and verification.
106
+ - Check for competing open PRs immediately before creating PR. If collision, bail cleanly.
107
+ - Open draft PR via `gh pr create --draft --head <branch> --base main --title "<title>" --body "<body referencing Closes #N>"`.
108
+ - Verify PR URL returned. Update issue `## Tasks` checkboxes.
109
+ - Mark PR ready (`gh pr ready <PR>`).
110
+ 14. If run aborts before opening PR, release claim (unassign).
111
+ 15. **In-Session Peer Review Wait & Immediate Convergence (Warm Context):**
112
+ - Poll PR status for up to 10–12 minutes.
113
+ - If merged: record terminal SUCCESS and exit cleanly.
114
+ - If bounced to draft with findings: fetch review comments, apply fixes in active worktree, run tests, push fix commit, re-mark ready (`gh pr ready <PR>`), and complete run.
115
+ - If timeout (>12m): exit cleanly; scheduled cron will handle subsequent rounds.
116
+
117
+ ## Logging
118
+
119
+ After completing (SUCCESS or FAILURE), write a log file to `.github/prompts/logs/autowork/{timestamp}.md` following the schema in `.github/prompts/logs/_template.md`. Include:
120
+ - The prompt SHA (run `git rev-parse --short HEAD:.github/prompts/autowork.md`)
121
+ - Every Definition of Done criterion with YES/NO and evidence
122
+ - Full execution trace with tool calls
123
+ - If FAILURE: root cause, category, and suggested fix
124
+
125
+ **Important**: Commit the log file directly to `main` and push — explicitly permitted for files under `.github/prompts/logs/**`. Follow the Log delivery fallback in `ORCHESTRATION.md` if direct push fails.
@@ -0,0 +1,44 @@
1
+ # Dependency Update & Security Check
2
+
3
+ ## Objective
4
+
5
+ Check all dependencies for available updates and known security vulnerabilities, report findings grouped by severity, and create or update GitHub issues for actionable items. Security vulnerabilities are highest priority — a vulnerability is actionable even when the affected dependency is not outdated (e.g. a transitive dependency, or an advisory with no fix released yet).
6
+
7
+ ## Definition of Done
8
+
9
+ The run is SUCCESS only if ALL of these are true:
10
+
11
+ - [ ] Ran the project package manager's outdated check (`npm outdated`, `pip list --outdated`, `cargo outdated`, etc.) and collected outdated dependencies
12
+ - [ ] Ran dependency security audit (`npm audit`, `pip-audit`, `cargo audit`, etc.) and collected known vulnerabilities (including transitive dependencies)
13
+ - [ ] For each outdated dependency, determined: current vs latest version, update type (major/minor/patch), breaking changes, and security advisories
14
+ - [ ] For each vulnerability, determined: affected package, severity, direct vs transitive, and fixed version availability
15
+ - [ ] Created or updated a GitHub issue for each vulnerability and each major update
16
+ - [ ] If everything is up to date and no vulnerabilities were found, logged SUCCESS with "All dependencies current, no known vulnerabilities"
17
+
18
+ If any criterion cannot be met, stop immediately and log FAILURE with the reason.
19
+
20
+ ## Constraints
21
+
22
+ - **Max iterations**: 30 — after 30 tool call rounds without completing Definition of Done, STOP. Log FAILURE with category `token_limit`.
23
+ - **Max scope**: report and issue creation only. Do not open code PRs in this routine.
24
+ - **No speculative work**: check dependencies declared in the project's manifest files (`package.json`, `pyproject.toml`, `Cargo.toml`).
25
+ - **Language Requirement**: All GitHub issue titles, descriptions, task checklists, and comments MUST be written in **English**.
26
+
27
+ ## Instructions
28
+
29
+ 1. Run the outdated dependencies check for the repository's package manager.
30
+ 2. Run the security audit command to check for known CVEs/GHSA vulnerabilities across direct and transitive dependencies.
31
+ 3. For each outdated package, check current vs latest version and note breaking changes for major bumps.
32
+ 4. For each vulnerability, extract severity, package name, and remediation version.
33
+ 5. Search existing open issues before creating new ones to prevent duplicate tracking.
34
+ 6. Create or update issues with clear labels: `security` and `priority/P1` for known CVEs; `dependencies` and `priority/P3` for non-security major updates.
35
+ 7. If all dependencies are current and no vulnerabilities exist, confirm clean status.
36
+
37
+ ## Logging
38
+
39
+ After completing (SUCCESS or FAILURE), write a log file to `.github/prompts/logs/dependency-update-security-check/{timestamp}.md` following the schema in `.github/prompts/logs/_template.md`. Include:
40
+ - Prompt SHA
41
+ - Tally of audited dependencies and security findings
42
+ - List of created or updated issues
43
+
44
+ **Important**: Commit the log file directly to `main` and push. Follow the Log delivery fallback in `ORCHESTRATION.md` if direct push fails.
@@ -0,0 +1,55 @@
1
+ # Issues Housekeeping
2
+
3
+ ## Objective
4
+
5
+ Sweep all open issues for staleness, duplicates, batch-consolidation opportunities (sets of small related issues addressable together), label drift, priority accuracy, dependency status, and orphaned autowork claims, and land any accumulated draft log-only PRs. Fix what can be fixed and post a summary of changes made.
6
+
7
+ ## Definition of Done
8
+
9
+ The run is SUCCESS only if ALL of these are true:
10
+
11
+ - [ ] All open issues have been scanned
12
+ - [ ] Priority review completed: P1s re-evaluated, quick-win promotions considered, priority rubric enforced
13
+ - [ ] Duplicate & batch-consolidation check completed: overlapping issues closed with cross-references, small related issues consolidated
14
+ - [ ] Stale / obsolete check completed: premise-obsolete issues closed, idle issues resolved
15
+ - [ ] Label audit completed: every open issue has consistent type, size, and priority labels
16
+ - [ ] Dependency check completed: issues with `## Dependencies` verified against blocker status
17
+ - [ ] Orphaned-claim sweep completed: stale autowork claims (per `ORCHESTRATION.md`) released back to the unclaimed pool
18
+ - [ ] Draft log-only PR sweep completed: open draft PRs whose changed files are entirely under `.github/prompts/logs/**` undrafted and squash-merged
19
+ - [ ] Summary posted listing all changes made
20
+
21
+ If any criterion cannot be met, stop immediately and log FAILURE with the reason.
22
+
23
+ ## Constraints
24
+
25
+ - **Max iterations**: 40 — after 40 tool call rounds without completing Definition of Done, STOP. Log FAILURE with category `token_limit`.
26
+ - **Max scope**: housekeeping only. Do not implement code fixes or open feature PRs.
27
+ - **No speculative work**: only modify issue metadata (labels, status, comments, releasing stale assignees) and land draft log-only PRs.
28
+ - **Language Requirement**: All GitHub issue titles, descriptions, task checklists, and comments MUST be written in **English**.
29
+
30
+ ## Instructions
31
+
32
+ ### Phase 1: Quick Recovery & Clearing
33
+
34
+ 1. **Draft log-only PR sweep**: Undraft and squash-merge open draft PRs whose diffs are entirely under `.github/prompts/logs/**`.
35
+ 2. **Orphaned-claim sweep**: Sweep assigned issues. If an issue meets the 3 stale-claim conditions in `ORCHESTRATION.md` (autowork claim comment, no open PR, comment > 6 hours old), re-read immediately before writing, unassign the dead owner, and post a release comment.
36
+
37
+ ### Phase 2: Backlog Hygiene
38
+
39
+ 3. **Priority review**: Check open P1/P2/P3 issues. Promote critical bugs or unblocked items; demote items that lack immediate priority.
40
+ 4. **Duplicate & consolidation check**: Identify duplicate issues; close duplicates with cross-references. Consolidate small, related micro-tasks into batch issues.
41
+ 5. **Premise-obsolete & stale check**: If an issue's premise was resolved by already-merged PRs or recent refactors, close as completed with evidence.
42
+ 6. **Label audit**: Ensure open issues carry standard role labels (`needs-triage`, `ready-for-agent`, `needs-human`, etc.). Use `/triage` if classifying incoming issues.
43
+
44
+ ### Phase 3: Summary
45
+
46
+ 7. Post a summary comment or log recording all actions taken (priority shifts, closed duplicates, released claims, landed log PRs).
47
+
48
+ ## Logging
49
+
50
+ After completing (SUCCESS or FAILURE), write a log file to `.github/prompts/logs/issues-housekeeping/{timestamp}.md` following the schema in `.github/prompts/logs/_template.md`. Include:
51
+ - Prompt SHA
52
+ - Tally of issues audited, claims released, PRs merged
53
+ - List of closed or modified issues
54
+
55
+ **Important**: Commit the log file directly to `main` and push. Follow the Log delivery fallback in `ORCHESTRATION.md` if direct push fails.
@@ -0,0 +1,72 @@
1
+ # Prompt Optimizer
2
+
3
+ ## Objective
4
+
5
+ Scan recent agent run logs and closed issues, diagnose four classes of problem — **failures** (runs that logged FAILURE), **inefficiency** (runs burning excessive iterations or multi-loop PRs), **token consumption & cost anomalies** (runs trending toward weekly budget ceilings), and **preventable bugs & defect avoidance** (analyzing resolved bugs to determine root causes and authoring/review prevention checks) — and propose targeted prompt, template, test, and workflow fixes via pull requests.
6
+
7
+ Additionally, this routine acts as the **Upstream Evolution Bridge**: when a prompt improvement solves a generic orchestrator pattern (benefiting all fleet-connected projects), it proposes the fix upstream to the `jonah-fleet` repository (`juliendurandeu/jonah-fleet`).
8
+
9
+ ## Definition of Done
10
+
11
+ The run is SUCCESS if ALL of these are true:
12
+
13
+ - [ ] All log files from the incremental window in `.github/prompts/logs/` have been scanned
14
+ - [ ] Every FAILURE log has been categorized and analyzed
15
+ - [ ] Inefficiency and review loops per PR have been computed across SUCCESS logs
16
+ - [ ] Closed bug issues and merged bug-fix PRs in the window have been analyzed for systemic root causes
17
+ - [ ] For each fixable pattern:
18
+ - If project-specific: opened a local PR with a prompt, template, or test fix and marked ready for review
19
+ - If generic/fleet-wide: opened an upstream PR against `juliendurandeu/jonah-fleet` (or flagged via `npx jonah-fleet contribute`)
20
+ - [ ] Every PR links a tracking issue via `Closes #N`
21
+ - [ ] If no issues or optimization patterns are found, logged SUCCESS with "No issues to address"
22
+
23
+ If any criterion cannot be met, stop immediately and log FAILURE with the reason.
24
+
25
+ ## Constraints
26
+
27
+ - **Max iterations**: 30 — stop after 30 tool call rounds.
28
+ - **Max scope**: one PR per identified problem. Do not bundle unrelated fixes.
29
+ - **No speculative work**: only fix patterns evidenced by logs, closed bug issues, or reviewer findings.
30
+ - **Language Requirement**: All GitHub issue titles, descriptions, task checklists, and comments MUST be written in **English**.
31
+
32
+ ## Instructions
33
+
34
+ ### 0. Establish the incremental scan boundary
35
+
36
+ 1. Check `.github/prompts/logs/optimizer/` for the most recent optimizer log.
37
+ 2. Extract the timestamp as the scan boundary (or last 7 days if first run).
38
+
39
+ ### 1. Collect signals & analyze logs
40
+
41
+ 1. Scan in-window log files in `.github/prompts/logs/*/`.
42
+ 2. Extract failure categories: `prompt_unclear`, `data_issue`, `token_limit`, `infeasible_task`.
43
+ 3. Compute efficiency metrics: PRs with 3+ review rounds, high iteration usage.
44
+ 4. Analyze resolved bugs for missing checks in authoring (`autowork.md`) or review (`peer-review.md`).
45
+
46
+ ### 2. Formulate preventative improvements
47
+
48
+ Translate findings into concrete preventative improvements:
49
+ - Enhance pre-ready checklist in `autowork.md`
50
+ - Add automated verification tests or invariant checks
51
+ - Clarify ambiguous prompt instructions
52
+
53
+ ### 3. Open Fix PR (Local or Upstream Bridge)
54
+
55
+ - **Local Improvement**: If the fix touches repository-specific rules, local docs, or custom tests:
56
+ - Branch from `origin/main`, apply changes, and open PR via `gh pr create --draft`.
57
+ - Link tracking issue and mark ready for review (`gh pr ready <PR>`).
58
+ - **Generic / Fleet Improvement**: If the fix improves core prompt orchestration, claim protocols, or universal error handling:
59
+ - Open a PR against upstream `juliendurandeu/jonah-fleet` using the GitHub CLI:
60
+ ```bash
61
+ npx jonah-fleet contribute --title "fix(prompt): <description>" --body "<evidence from local run logs>"
62
+ ```
63
+ or branch and open a PR against upstream `juliendurandeu/jonah-fleet`.
64
+
65
+ ## Logging
66
+
67
+ After completing (SUCCESS or FAILURE), write a log file to `.github/prompts/logs/optimizer/{timestamp}.md` following the schema in `.github/prompts/logs/_template.md`. Include:
68
+ - Prompt SHA
69
+ - Analyzed logs count and identified patterns
70
+ - PRs opened (local or upstream)
71
+
72
+ **Important**: Commit the log file directly to `main` and push. Follow the Log delivery fallback in `ORCHESTRATION.md` if direct push fails.