jonah-fleet 1.13.0 → 1.15.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.
@@ -1,5 +1,13 @@
1
1
  # Prompt Optimizer
2
2
 
3
+ <!--
4
+ ================================================================================
5
+ TIER 1: STATIC INVARIANT PREFIX
6
+ Routine objective, Definition of Done, constraints, instructions, and logging.
7
+ 100% cacheable across all runs and repositories.
8
+ ================================================================================
9
+ -->
10
+
3
11
  ## Objective
4
12
 
5
13
  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.
@@ -133,3 +141,38 @@ After completing (SUCCESS or FAILURE), record run execution details to `.jonah-f
133
141
  ```
134
142
  - Follow the Routine Issue Logging & Telemetry Protocol in `ORCHESTRATION.md`. Never commit run logs to git branches.
135
143
 
144
+ <!--
145
+ ================================================================================
146
+ TIER 2: SEMI-STABLE PROJECT RULES
147
+ Repository rules from AGENTS.md, manifest configurations, and LESSONS.md.
148
+ Cacheable across consecutive runs within the same repository.
149
+ ================================================================================
150
+ -->
151
+
152
+ ## Repository Rules & Project Context (Tier 2)
153
+
154
+ In this tier, Prompt Optimizer ingests semi-stable repository conventions, operational memory, and configuration rules that change infrequently across consecutive runs in the same repository:
155
+
156
+ 1. **Repository Conventions (`AGENTS.md`)**: Read `AGENTS.md` (or `CLAUDE.md` / `GEMINI.md`) for baseline project guidelines, prompt conventions, and test commands.
157
+ 2. **Operational Memory (`LESSONS.md`)**: Scan `LESSONS.md` to identify candidate lessons for graduation into automated linter rules or CI workflow checks, and archive stale entries to `LESSONS_ARCHIVE.md`.
158
+ 3. **Fleet Manifest (`agents-manifest.json`)**: Ingest per-routine budget overrides, enabled routines, and model assignments to evaluate against the 70% weekly token ceiling (~8.75M tokens).
159
+ 4. **Engineering Skills (`.agents/skills/`)**: Leverage `writing-for-agents` to prune prompt sprawl and apply leading words.
160
+
161
+ <!--
162
+ ================================================================================
163
+ TIER 3: DYNAMIC TAIL PAYLOAD
164
+ Target issue / PR data, git diff, active branch, timestamps, and runtime vars.
165
+ Appended strictly at the tail of the prompt to preserve prefix cache validity.
166
+ ================================================================================
167
+ -->
168
+
169
+ ## Dynamic Context & Execution Payload (Tier 3)
170
+
171
+ The dynamic execution context for this optimization sweep is injected strictly at the tail of the prompt:
172
+
173
+ - **Scan Boundary**: Incremental window timestamp established in Step 0.
174
+ - **Runtime Metadata**: `$ROUTINE_ISSUE_NUMBER`, `$GITHUB_RUN_ID`, and runner timestamp.
175
+ - **In-Window Telemetry**: Routine log issues (`routine-log`), failure categories, and token consumption data.
176
+ - **Prefix Caching Invariant**: Harnesses and runners MUST NEVER interpolate dynamic timestamps, run IDs, or target identifiers into Tier 1 or Tier 2 prefix blocks.
177
+
178
+
@@ -1,5 +1,13 @@
1
1
  # Peer Review
2
2
 
3
+ <!--
4
+ ================================================================================
5
+ TIER 1: STATIC INVARIANT PREFIX
6
+ Routine objective, Definition of Done, constraints, instructions, and logging.
7
+ 100% cacheable across all runs and repositories.
8
+ ================================================================================
9
+ -->
10
+
3
11
  ## Objective
4
12
 
5
13
  Review a pull request (in Targeted mode for a specific `$PR_NUMBER`, or in Scan mode selecting the highest-priority open PR), evaluate code quality, security, and specification compliance via multi-angle subagent code reviews (`/code-review`), and take exactly one final action: squash-merge if clean, or post findings and bounce the PR back to draft (`gh pr ready <N> --undo`) for in-session author fixes.
@@ -174,3 +182,38 @@ After completing (SUCCESS or FAILURE), record run execution details to `.jonah-f
174
182
  - **Next**: Routine finished; issue closed by harness" || true
175
183
  ```
176
184
  - Follow the Routine Issue Logging & Telemetry Protocol in `ORCHESTRATION.md`. Never commit run logs to git branches.
185
+
186
+ <!--
187
+ ================================================================================
188
+ TIER 2: SEMI-STABLE PROJECT RULES
189
+ Repository rules from AGENTS.md, manifest configurations, and LESSONS.md.
190
+ Cacheable across consecutive runs within the same repository.
191
+ ================================================================================
192
+ -->
193
+
194
+ ## Repository Rules & Project Context (Tier 2)
195
+
196
+ In this tier, Peer Review ingests semi-stable repository conventions, operational memory, and configuration rules that change infrequently across consecutive runs in the same repository:
197
+
198
+ 1. **Repository Conventions (`AGENTS.md`)**: Read `AGENTS.md` (or `CLAUDE.md` / `GEMINI.md`) for coding standards, architectural patterns, design system token purity, and required CI / test commands.
199
+ 2. **Operational Memory (`LESSONS.md`)**: Verify that any non-obvious quirks or gotchas captured on the active PR branch adhere to the 25-entry hard cap.
200
+ 3. **Fleet Manifest (`agents-manifest.json`)**: Ingest configured review models, round caps, and iteration ceilings.
201
+ 4. **Engineering Skills (`.agents/skills/`)**: Leverage `code-review`, `design-critique`, and `writing-for-agents` for structured evaluation.
202
+
203
+ <!--
204
+ ================================================================================
205
+ TIER 3: DYNAMIC TAIL PAYLOAD
206
+ Target issue / PR data, git diff, active branch, timestamps, and runtime vars.
207
+ Appended strictly at the tail of the prompt to preserve prefix cache validity.
208
+ ================================================================================
209
+ -->
210
+
211
+ ## Dynamic Context & Execution Payload (Tier 3)
212
+
213
+ The dynamic execution context for this specific review run is injected strictly at the tail of the prompt:
214
+
215
+ - **Target PR**: `$PR_NUMBER` (or `$PR_URL`), PR title, body, author, and review round N.
216
+ - **Runtime Metadata**: `$ROUTINE_ISSUE_NUMBER`, `$GITHUB_RUN_ID`, runner timestamp, and trigger event.
217
+ - **Pull Request Payload**: Head commit SHA, base branch diff, status check rollup (CI status), and unaddressed comments.
218
+ - **Prefix Caching Invariant**: Harnesses and runners MUST NEVER interpolate dynamic timestamps, run IDs, or target identifiers into Tier 1 or Tier 2 prefix blocks.
219
+
@@ -1,5 +1,13 @@
1
1
  # Product Planning
2
2
 
3
+ <!--
4
+ ================================================================================
5
+ TIER 1: STATIC INVARIANT PREFIX
6
+ Routine objective, Definition of Done, constraints, instructions, and logging.
7
+ 100% cacheable across all runs and repositories.
8
+ ================================================================================
9
+ -->
10
+
3
11
  ## Objective
4
12
 
5
13
  Turn strategy and evidence into **well-scoped, ready-to-build work** and a **current roadmap** — the "plan" between analytics/measurement and autowork's build phase. Each run reads roadmap priorities, closed measurement trackers (`RECOMMENDATION: [PIVOT | DEPRECATE | ITERATE]`), analytics signals, and user feedback to **propose** the next units of product work: new feature issues, feature pruning and deprecations, formal specs/PRDs for larger epics, backlog re-ranking recommendations, and roadmap updates.
@@ -80,3 +88,38 @@ Follow the Routine Issue Logging Protocol in `ORCHESTRATION.md`:
80
88
  - Staged or promoted proposals tally
81
89
  3. The surrounding execution harness will reconcile the corresponding GitHub issue.
82
90
 
91
+ <!--
92
+ ================================================================================
93
+ TIER 2: SEMI-STABLE PROJECT RULES
94
+ Repository rules from AGENTS.md, manifest configurations, and LESSONS.md.
95
+ Cacheable across consecutive runs within the same repository.
96
+ ================================================================================
97
+ -->
98
+
99
+ ## Repository Rules & Project Context (Tier 2)
100
+
101
+ In this tier, Product Planning ingests semi-stable repository conventions and strategic guidance:
102
+
103
+ 1. **Repository Conventions & Product Strategy (`AGENTS.md`, `ROADMAP.md`)**: Read `AGENTS.md` (or `CLAUDE.md` / `GEMINI.md`) and `ROADMAP.md` for current feature priorities, milestones, and architectural constraints.
104
+ 2. **Operational Memory (`LESSONS.md`)**: Ingest active operational gotchas to avoid proposing infeasible or recurring architectural patterns.
105
+ 3. **Fleet Manifest (`agents-manifest.json`)**: Ingest configured routine presets and budgets.
106
+ 4. **Engineering Skills (`.agents/skills/`)**: Leverage `domain-modeling` and `grill-me` when scoping epics and drafting specifications.
107
+
108
+ <!--
109
+ ================================================================================
110
+ TIER 3: DYNAMIC TAIL PAYLOAD
111
+ Target issue / PR data, git diff, active branch, timestamps, and runtime vars.
112
+ Appended strictly at the tail of the prompt to preserve prefix cache validity.
113
+ ================================================================================
114
+ -->
115
+
116
+ ## Dynamic Context & Execution Payload (Tier 3)
117
+
118
+ The dynamic execution context for this planning sweep is injected strictly at the tail of the prompt:
119
+
120
+ - **Planning Mode & Directives**: Mode indicator (`Propose` vs `Promote`) and operator approval tokens.
121
+ - **Input Artifacts**: Closed measurement trackers with `RECOMMENDATION: [PIVOT | DEPRECATE | ITERATE]`, open `🎨 Design Review` issues, and maintainer feedback.
122
+ - **Runtime Metadata**: `$ROUTINE_ISSUE_NUMBER`, `$GITHUB_RUN_ID`, and runner timestamp.
123
+ - **Prefix Caching Invariant**: Harnesses and runners MUST NEVER interpolate dynamic timestamps, run IDs, or target identifiers into Tier 1 or Tier 2 prefix blocks.
124
+
125
+
@@ -0,0 +1,313 @@
1
+ name: Analytics Review Scheduled Cron (agy)
2
+
3
+ # Scheduled execution of the Analytics Review routine using Antigravity CLI on Gemini 3.8 Flash.
4
+ # Queries Vercel, PostHog, and GitHub CI volume, executes §1–§7 checks, updates measurement trackers,
5
+ # stages product action directives into Product Planning, and logs to a two-phase routine run issue.
6
+
7
+ on:
8
+ schedule:
9
+ # Daily at 07:00 UTC (09:00 Paris CEST)
10
+ - cron: '0 7 * * *'
11
+ workflow_dispatch:
12
+
13
+ # Single-flight: do not run overlapping analytics review runs.
14
+ concurrency:
15
+ group: analytics-review-agent
16
+ cancel-in-progress: false
17
+
18
+ jobs:
19
+ run-analytics-review:
20
+ runs-on: ubuntu-latest
21
+ timeout-minutes: 60
22
+ permissions:
23
+ contents: write
24
+ issues: write
25
+ pull-requests: write
26
+ statuses: write
27
+ actions: read
28
+ steps:
29
+ - name: Checkout repository
30
+ uses: actions/checkout@v4
31
+ with:
32
+ fetch-depth: 0
33
+ persist-credentials: false
34
+
35
+ - name: Setup Node.js
36
+ uses: actions/setup-node@v4
37
+ with:
38
+ node-version: 22
39
+
40
+ - name: Configure Git author identity
41
+ env:
42
+ GH_TOKEN: ${{ secrets.GH_PAT || github.token }}
43
+ run: |
44
+ git config --global user.name "github-actions[bot]"
45
+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
46
+ git config --global --add safe.directory "$GITHUB_WORKSPACE"
47
+ gh auth setup-git
48
+
49
+ - name: Cache Antigravity CLI
50
+ id: cache-agy
51
+ uses: actions/cache@v4
52
+ with:
53
+ path: ~/.local/bin/agy
54
+ key: agy-cli-linux-amd64-v1
55
+
56
+ - name: Install Antigravity CLI
57
+ if: steps.cache-agy.outputs.cache-hit != 'true'
58
+ run: |
59
+ curl -fsSL https://antigravity.google/cli/install.sh | bash
60
+
61
+ - name: Add Antigravity CLI to PATH
62
+ run: echo "$HOME/.local/bin" >> $GITHUB_PATH
63
+
64
+ - name: Write Antigravity OAuth Token
65
+ env:
66
+ ANTIGRAVITY_OAUTH_TOKEN: ${{ secrets.ANTIGRAVITY_OAUTH_TOKEN || secrets.GEMINI_API_KEY }}
67
+ run: |
68
+ if [ -z "$ANTIGRAVITY_OAUTH_TOKEN" ]; then
69
+ echo "::error::Neither ANTIGRAVITY_OAUTH_TOKEN nor GEMINI_API_KEY secret is set; cannot authenticate Antigravity CLI." >&2
70
+ exit 1
71
+ fi
72
+ mkdir -p "$HOME/.gemini/antigravity-cli"
73
+ chmod 700 "$HOME/.gemini/antigravity-cli"
74
+ printf '%s' "$ANTIGRAVITY_OAUTH_TOKEN" > "$HOME/.gemini/antigravity-cli/antigravity-oauth-token"
75
+ chmod 600 "$HOME/.gemini/antigravity-cli/antigravity-oauth-token"
76
+
77
+ - name: Fast preflight credential validation (SwarmClaw Pattern #2)
78
+ run: |
79
+ if [ ! -s "$HOME/.gemini/antigravity-cli/antigravity-oauth-token" ]; then
80
+ echo "::error::Preflight credential check failed: Antigravity OAuth token file is missing or empty." >&2
81
+ exit 1
82
+ fi
83
+ echo "✓ Preflight credential validation passed."
84
+
85
+ - name: Discover and compile domain skills (SwarmClaw Pattern #4)
86
+ id: skills
87
+ run: |
88
+ SKILLS_LIST=""
89
+ if [ -f ".agents/skills/validate-data/SKILL.md" ]; then
90
+ SKILLS_LIST="Read and follow .agents/skills/validate-data/SKILL.md."
91
+ fi
92
+ echo "skills_prompt=$SKILLS_LIST" >> "$GITHUB_OUTPUT"
93
+
94
+ - name: Resolve routine configuration
95
+ id: routine-config
96
+ run: |
97
+ ROUTINE="analytics-review"
98
+ DEFAULT_MODEL="gemini-3.8-flash-high"
99
+ DEFAULT_TIMEOUT="50"
100
+
101
+ MODEL="$DEFAULT_MODEL"
102
+ TIMEOUT="$DEFAULT_TIMEOUT"
103
+
104
+ if [ -f "agents-manifest.json" ]; then
105
+ CONFIG_JSON=$(node -e '
106
+ try {
107
+ const fs = require("fs");
108
+ const m = JSON.parse(fs.readFileSync("agents-manifest.json", "utf8"));
109
+ const r = process.argv[1];
110
+ const model = m.models?.[r] || m.models?.default;
111
+ const timeout = m.budgets?.timeoutMinutes?.[r] || m.budgets?.timeoutMinutes?.default;
112
+ console.log(JSON.stringify({ model: model || "", timeout: timeout ? String(timeout) : "" }));
113
+ } catch (e) {
114
+ console.log(JSON.stringify({ model: "", timeout: "" }));
115
+ }
116
+ ' "$ROUTINE")
117
+
118
+ RESOLVED_MODEL=$(node -e "try { console.log(JSON.parse(process.argv[1]).model || ''); } catch {}" "$CONFIG_JSON")
119
+ RESOLVED_TIMEOUT=$(node -e "try { console.log(JSON.parse(process.argv[1]).timeout || ''); } catch {}" "$CONFIG_JSON")
120
+
121
+ if [ -n "$RESOLVED_MODEL" ]; then
122
+ MODEL="$RESOLVED_MODEL"
123
+ fi
124
+ if [ -n "$RESOLVED_TIMEOUT" ]; then
125
+ TIMEOUT="$RESOLVED_TIMEOUT"
126
+ fi
127
+ fi
128
+
129
+ echo "model=$MODEL" >> "$GITHUB_OUTPUT"
130
+ echo "print_timeout=${TIMEOUT}m" >> "$GITHUB_OUTPUT"
131
+ echo "Resolved routine configuration: model=$MODEL, timeout=${TIMEOUT}m"
132
+
133
+ - name: Initialize Routine Run Issue
134
+ id: run-issue
135
+ env:
136
+ GH_TOKEN: ${{ secrets.GH_PAT || github.token }}
137
+ EVENT_NAME: ${{ github.event_name }}
138
+ RUN_ID: ${{ github.run_id }}
139
+ SERVER_URL: ${{ github.server_url }}
140
+ REPOSITORY: ${{ github.repository }}
141
+ run: |
142
+ TIMESTAMP=$(date -u +"%Y-%m-%dT%H-%M-%SZ")
143
+ TITLE="[analytics-review] run ${TIMESTAMP}"
144
+ BODY="### Autonomous Routine Execution in Progress
145
+ - **Routine**: \`analytics-review\`
146
+ - **Timestamp**: \`${TIMESTAMP}\`
147
+ - **Trigger**: \`${EVENT_NAME}\`
148
+ - **Run ID**: [\`${RUN_ID}\`](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})
149
+
150
+ ---
151
+ _Generated by [Antigravity](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})_"
152
+ ISSUE_URL=$(gh issue create --title "$TITLE" --body "$BODY" --label "routine-log,routine:analytics-review,status:running,runner:github-actions")
153
+ ISSUE_NUMBER=$(echo "$ISSUE_URL" | grep -oE '[0-9]+$')
154
+ echo "issue_number=$ISSUE_NUMBER" >> "$GITHUB_OUTPUT"
155
+ echo "ROUTINE_ISSUE_NUMBER=$ISSUE_NUMBER" >> "$GITHUB_ENV"
156
+
157
+ - name: Run Analytics Review
158
+ timeout-minutes: 50
159
+ env:
160
+ GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
161
+ GOOGLE_API_KEY: ${{ secrets.GEMINI_API_KEY }}
162
+ ANTIGRAVITY_API_KEY: ${{ secrets.GEMINI_API_KEY }}
163
+ GH_TOKEN: ${{ secrets.GH_PAT || github.token }}
164
+ ROUTINE_ISSUE_NUMBER: ${{ steps.run-issue.outputs.issue_number }}
165
+ VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
166
+ POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
167
+ MODEL: ${{ steps.routine-config.outputs.model || 'gemini-3.8-flash-high' }}
168
+ PRINT_TIMEOUT: ${{ steps.routine-config.outputs.print_timeout || '50m' }}
169
+ SKILLS_PROMPT: ${{ steps.skills.outputs.skills_prompt }}
170
+ GITHUB_SERVER_URL: ${{ github.server_url }}
171
+ GITHUB_REPOSITORY: ${{ github.repository }}
172
+ GITHUB_RUN_ID: ${{ github.run_id }}
173
+ run: |
174
+ PROMPT="You are the Analytics Review routine for this repository. Read and follow the instructions in .github/prompts/analytics-review.md exactly. ${SKILLS_PROMPT}"
175
+
176
+ set +e
177
+ agy -p "$PROMPT" \
178
+ --model "$MODEL" \
179
+ --output-format text \
180
+ --print-timeout "$PRINT_TIMEOUT" \
181
+ --dangerously-skip-permissions 2>&1 | tee /tmp/agy.log
182
+ AGY_EXIT_CODE="${PIPESTATUS[0]}"
183
+ set -e
184
+
185
+ if [ "$AGY_EXIT_CODE" -ne 0 ]; then
186
+ if grep -qiE "Individual quota reached|quota reached" /tmp/agy.log; then
187
+ RESET_INFO=$(grep -oE "Resets in [^.]+" /tmp/agy.log | head -n 1 || echo "Resets in future window")
188
+ echo "QUOTA_PAUSED=true" >> "$GITHUB_ENV"
189
+ echo "QUOTA_RESET_INFO=$RESET_INFO" >> "$GITHUB_ENV"
190
+ echo "⚠️ LLM quota limit reached ($RESET_INFO). Pausing routine gracefully until next sweep."
191
+ exit 0
192
+ fi
193
+ exit "$AGY_EXIT_CODE"
194
+ fi
195
+
196
+ - name: Emit run summary
197
+ if: always()
198
+ run: |
199
+ if [ "$QUOTA_PAUSED" = "true" ]; then
200
+ echo "### ⏸️ Milestone: Routine Execution Quota-Paused" >> "$GITHUB_STEP_SUMMARY"
201
+ echo "- **Status**: LLM quota reached (\`${QUOTA_RESET_INFO}\`)" >> "$GITHUB_STEP_SUMMARY"
202
+ echo "- **Next Action**: Routine execution paused cleanly. Work will resume automatically on the next scheduled sweep after the quota window resets." >> "$GITHUB_STEP_SUMMARY"
203
+ else
204
+ REPORT_FILE=".jonah-fleet/run-report.md"
205
+ if [ -f "$REPORT_FILE" ] && [ -n "$GITHUB_STEP_SUMMARY" ]; then
206
+ cat "$REPORT_FILE" >> "$GITHUB_STEP_SUMMARY"
207
+ fi
208
+ fi
209
+
210
+ - name: Emit Fleet Telemetry (Opt-in)
211
+ if: always()
212
+ env:
213
+ GH_TOKEN: ${{ secrets.GH_PAT || github.token }}
214
+ TELEMETRY_ENDPOINT: ${{ secrets.JONAH_FLEET_TELEMETRY_ENDPOINT }}
215
+ GITHUB_REPOSITORY: ${{ github.repository }}
216
+ GITHUB_RUN_ID: ${{ github.run_id }}
217
+ GITHUB_RUN_NUMBER: ${{ github.run_number }}
218
+ run: |
219
+ REPORT_FILE=".jonah-fleet/run-report.md"
220
+ if [ -f "$REPORT_FILE" ]; then
221
+ npx --yes jonah-fleet telemetry --emit --log "$REPORT_FILE" --endpoint "$TELEMETRY_ENDPOINT" || true
222
+ fi
223
+
224
+ - name: Reconcile Routine Run Issue
225
+ if: always()
226
+ env:
227
+ GH_TOKEN: ${{ secrets.GH_PAT || github.token }}
228
+ ISSUE_NUMBER: ${{ steps.run-issue.outputs.issue_number }}
229
+ JOB_STATUS: ${{ job.status }}
230
+ EVENT_NAME: ${{ github.event_name }}
231
+ RUN_ID: ${{ github.run_id }}
232
+ SERVER_URL: ${{ github.server_url }}
233
+ REPOSITORY: ${{ github.repository }}
234
+ QUOTA_PAUSED: ${{ env.QUOTA_PAUSED }}
235
+ QUOTA_RESET_INFO: ${{ env.QUOTA_RESET_INFO }}
236
+ run: |
237
+ if [ -z "$ISSUE_NUMBER" ]; then
238
+ echo "No routine issue to reconcile."
239
+ exit 0
240
+ fi
241
+
242
+ if [ "$QUOTA_PAUSED" = "true" ]; then
243
+ RESET_STR="${QUOTA_RESET_INFO:-Resets in upcoming window}"
244
+ PAUSE_BODY="### ⏸️ Autonomous Routine Execution Quota-Paused
245
+ - **Routine**: \`analytics-review\`
246
+ - **Run ID**: [\`${RUN_ID}\`](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})
247
+ - **Trigger**: \`${EVENT_NAME}\`
248
+ - **Status**: LLM quota reached (\`${RESET_STR}\`)
249
+ - **Next Action**: Routine execution paused cleanly. Work will resume automatically on the next scheduled sweep after the quota window resets.
250
+
251
+ ---
252
+ _Generated by [Antigravity](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})_"
253
+
254
+ TEMP_BODY=$(mktemp)
255
+ echo "$PAUSE_BODY" > "$TEMP_BODY"
256
+ gh issue edit "$ISSUE_NUMBER" --body-file "$TEMP_BODY"
257
+ rm -f "$TEMP_BODY"
258
+
259
+ PAUSE_COMMENT=$(printf '%s\n' \
260
+ "### ⏸️ Milestone: Routine Execution Quota-Paused" \
261
+ "- **Routine**: \`analytics-review\`" \
262
+ "- **Status**: LLM quota reached (\`${RESET_STR}\`)" \
263
+ "- **Action Log**: [View GitHub Actions Run](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})" \
264
+ "- **Next Action**: Execution paused cleanly. The routine will resume automatically on the next scheduled sweep." \
265
+ "" \
266
+ "---" \
267
+ "_Generated by [Antigravity](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})_")
268
+ gh issue comment "$ISSUE_NUMBER" --body "$PAUSE_COMMENT" || true
269
+ gh issue edit "$ISSUE_NUMBER" --add-label "status:quota-paused" --remove-label "status:running"
270
+ gh issue close "$ISSUE_NUMBER" --reason completed
271
+ echo "⏸️ Routine run issue #$ISSUE_NUMBER closed with status:quota-paused."
272
+ exit 0
273
+ fi
274
+
275
+ REPORT_FILE=".jonah-fleet/run-report.md"
276
+
277
+ if [ -f "$REPORT_FILE" ]; then
278
+ BODY_CONTENT=$(cat "$REPORT_FILE")
279
+ else
280
+ BODY_CONTENT="### Autonomous Routine Execution Completed (${JOB_STATUS})
281
+ - **Routine**: \`analytics-review\`
282
+ - **Run ID**: [\`${RUN_ID}\`](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})
283
+ - **Trigger**: \`${EVENT_NAME}\`"
284
+ fi
285
+
286
+ FINAL_BODY="${BODY_CONTENT}
287
+
288
+ ---
289
+ _Generated by [Antigravity](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})_"
290
+
291
+ TEMP_BODY=$(mktemp)
292
+ echo "$FINAL_BODY" > "$TEMP_BODY"
293
+ gh issue edit "$ISSUE_NUMBER" --body-file "$TEMP_BODY"
294
+ rm -f "$TEMP_BODY"
295
+
296
+ if [ "$JOB_STATUS" = "success" ]; then
297
+ gh issue edit "$ISSUE_NUMBER" --add-label "status:success" --remove-label "status:running"
298
+ gh issue close "$ISSUE_NUMBER" --reason completed
299
+ echo "✓ Routine run issue #$ISSUE_NUMBER closed as completed."
300
+ else
301
+ INTERRUPTION_BODY=$(printf '%s\n' \
302
+ "### ❌ Milestone: Run Interrupted / Failed" \
303
+ "- **Routine**: \`analytics-review\`" \
304
+ "- **Status**: Workflow job failed or timed out (\`${JOB_STATUS}\`)" \
305
+ "- **Step**: Actions execution halted before normal completion" \
306
+ "- **Action Log**: [View GitHub Actions Run](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})" \
307
+ "" \
308
+ "---" \
309
+ "_Generated by [Antigravity](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})_")
310
+ gh issue comment "$ISSUE_NUMBER" --body "$INTERRUPTION_BODY" || true
311
+ gh issue edit "$ISSUE_NUMBER" --add-label "status:failure,needs-attention" --remove-label "status:running"
312
+ echo "⚠️ Routine run issue #$ISSUE_NUMBER left open for triage (status: $JOB_STATUS)."
313
+ fi
@@ -198,18 +198,38 @@ jobs:
198
198
  PROMPT="You are the Autowork routine for this repository. Read and follow the instructions in .github/prompts/autowork.md exactly. ${SKILLS_PROMPT} You are in Scan mode: check open PRs for review comments to fix, close merged issues, then pick the highest-priority unclaimed issue."
199
199
  fi
200
200
 
201
+ set +e
201
202
  agy -p "$PROMPT" \
202
203
  --model "$MODEL" \
203
204
  --output-format text \
204
205
  --print-timeout "$PRINT_TIMEOUT" \
205
- --dangerously-skip-permissions
206
+ --dangerously-skip-permissions 2>&1 | tee /tmp/agy.log
207
+ AGY_EXIT_CODE="${PIPESTATUS[0]}"
208
+ set -e
209
+
210
+ if [ "$AGY_EXIT_CODE" -ne 0 ]; then
211
+ if grep -qiE "Individual quota reached|quota reached" /tmp/agy.log; then
212
+ RESET_INFO=$(grep -oE "Resets in [^.]+" /tmp/agy.log | head -n 1 || echo "Resets in future window")
213
+ echo "QUOTA_PAUSED=true" >> "$GITHUB_ENV"
214
+ echo "QUOTA_RESET_INFO=$RESET_INFO" >> "$GITHUB_ENV"
215
+ echo "⚠️ LLM quota limit reached ($RESET_INFO). Pausing routine gracefully until next sweep."
216
+ exit 0
217
+ fi
218
+ exit "$AGY_EXIT_CODE"
219
+ fi
206
220
 
207
221
  - name: Emit run summary
208
222
  if: always()
209
223
  run: |
210
- REPORT_FILE=".jonah-fleet/run-report.md"
211
- if [ -f "$REPORT_FILE" ] && [ -n "$GITHUB_STEP_SUMMARY" ]; then
212
- cat "$REPORT_FILE" >> "$GITHUB_STEP_SUMMARY"
224
+ if [ "$QUOTA_PAUSED" = "true" ]; then
225
+ echo "### ⏸️ Milestone: Routine Execution Quota-Paused" >> "$GITHUB_STEP_SUMMARY"
226
+ echo "- **Status**: LLM quota reached (\`${QUOTA_RESET_INFO}\`)" >> "$GITHUB_STEP_SUMMARY"
227
+ echo "- **Next Action**: Routine execution paused cleanly. Work will resume automatically on the next scheduled sweep after the quota window resets." >> "$GITHUB_STEP_SUMMARY"
228
+ else
229
+ REPORT_FILE=".jonah-fleet/run-report.md"
230
+ if [ -f "$REPORT_FILE" ] && [ -n "$GITHUB_STEP_SUMMARY" ]; then
231
+ cat "$REPORT_FILE" >> "$GITHUB_STEP_SUMMARY"
232
+ fi
213
233
  fi
214
234
 
215
235
  - name: Emit Fleet Telemetry (Opt-in)
@@ -257,12 +277,47 @@ jobs:
257
277
  RUN_ID: ${{ github.run_id }}
258
278
  SERVER_URL: ${{ github.server_url }}
259
279
  REPOSITORY: ${{ github.repository }}
280
+ QUOTA_PAUSED: ${{ env.QUOTA_PAUSED }}
281
+ QUOTA_RESET_INFO: ${{ env.QUOTA_RESET_INFO }}
260
282
  run: |
261
283
  if [ -z "$ISSUE_NUMBER" ]; then
262
284
  echo "No routine issue to reconcile."
263
285
  exit 0
264
286
  fi
265
287
 
288
+ if [ "$QUOTA_PAUSED" = "true" ]; then
289
+ RESET_STR="${QUOTA_RESET_INFO:-Resets in upcoming window}"
290
+ PAUSE_BODY="### ⏸️ Autonomous Routine Execution Quota-Paused
291
+ - **Routine**: \`autowork\`
292
+ - **Run ID**: [\`${RUN_ID}\`](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})
293
+ - **Trigger**: \`${EVENT_NAME}\`
294
+ - **Status**: LLM quota reached (\`${RESET_STR}\`)
295
+ - **Next Action**: Routine execution paused cleanly. Work will resume automatically on the next scheduled sweep after the quota window resets.
296
+
297
+ ---
298
+ _Generated by [Antigravity](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})_"
299
+
300
+ TEMP_BODY=$(mktemp)
301
+ echo "$PAUSE_BODY" > "$TEMP_BODY"
302
+ gh issue edit "$ISSUE_NUMBER" --body-file "$TEMP_BODY"
303
+ rm -f "$TEMP_BODY"
304
+
305
+ PAUSE_COMMENT=$(printf '%s\n' \
306
+ "### ⏸️ Milestone: Routine Execution Quota-Paused" \
307
+ "- **Routine**: \`autowork\`" \
308
+ "- **Status**: LLM quota reached (\`${RESET_STR}\`)" \
309
+ "- **Action Log**: [View GitHub Actions Run](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})" \
310
+ "- **Next Action**: Execution paused cleanly. The routine will resume automatically on the next scheduled sweep." \
311
+ "" \
312
+ "---" \
313
+ "_Generated by [Antigravity](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})_")
314
+ gh issue comment "$ISSUE_NUMBER" --body "$PAUSE_COMMENT" || true
315
+ gh issue edit "$ISSUE_NUMBER" --add-label "status:quota-paused" --remove-label "status:running"
316
+ gh issue close "$ISSUE_NUMBER" --reason completed
317
+ echo "⏸️ Routine run issue #$ISSUE_NUMBER closed with status:quota-paused."
318
+ exit 0
319
+ fi
320
+
266
321
  REPORT_FILE=".jonah-fleet/run-report.md"
267
322
 
268
323
  if [ -f "$REPORT_FILE" ]; then
@@ -148,11 +148,39 @@ jobs:
148
148
  run: |
149
149
  PROMPT="You are the Dependency Update & Security Check routine. Read and follow .github/prompts/dependency-update-security-check.md exactly. Check dependencies for updates and vulnerabilities, and create or update tracking issues."
150
150
 
151
+ set +e
151
152
  agy -p "$PROMPT" \
152
153
  --model "$MODEL" \
153
154
  --output-format text \
154
155
  --print-timeout "$PRINT_TIMEOUT" \
155
- --dangerously-skip-permissions
156
+ --dangerously-skip-permissions 2>&1 | tee /tmp/agy.log
157
+ AGY_EXIT_CODE="${PIPESTATUS[0]}"
158
+ set -e
159
+
160
+ if [ "$AGY_EXIT_CODE" -ne 0 ]; then
161
+ if grep -qiE "Individual quota reached|quota reached" /tmp/agy.log; then
162
+ RESET_INFO=$(grep -oE "Resets in [^.]+" /tmp/agy.log | head -n 1 || echo "Resets in future window")
163
+ echo "QUOTA_PAUSED=true" >> "$GITHUB_ENV"
164
+ echo "QUOTA_RESET_INFO=$RESET_INFO" >> "$GITHUB_ENV"
165
+ echo "⚠️ LLM quota limit reached ($RESET_INFO). Pausing routine gracefully until next sweep."
166
+ exit 0
167
+ fi
168
+ exit "$AGY_EXIT_CODE"
169
+ fi
170
+
171
+ - name: Emit run summary
172
+ if: always()
173
+ run: |
174
+ if [ "$QUOTA_PAUSED" = "true" ]; then
175
+ echo "### ⏸️ Milestone: Routine Execution Quota-Paused" >> "$GITHUB_STEP_SUMMARY"
176
+ echo "- **Status**: LLM quota reached (\`${QUOTA_RESET_INFO}\`)" >> "$GITHUB_STEP_SUMMARY"
177
+ echo "- **Next Action**: Routine execution paused cleanly. Work will resume automatically on the next scheduled sweep after the quota window resets." >> "$GITHUB_STEP_SUMMARY"
178
+ else
179
+ REPORT_FILE=".jonah-fleet/run-report.md"
180
+ if [ -f "$REPORT_FILE" ] && [ -n "$GITHUB_STEP_SUMMARY" ]; then
181
+ cat "$REPORT_FILE" >> "$GITHUB_STEP_SUMMARY"
182
+ fi
183
+ fi
156
184
 
157
185
  - name: Reconcile Routine Run Issue
158
186
  if: always()
@@ -164,12 +192,47 @@ jobs:
164
192
  RUN_ID: ${{ github.run_id }}
165
193
  SERVER_URL: ${{ github.server_url }}
166
194
  REPOSITORY: ${{ github.repository }}
195
+ QUOTA_PAUSED: ${{ env.QUOTA_PAUSED }}
196
+ QUOTA_RESET_INFO: ${{ env.QUOTA_RESET_INFO }}
167
197
  run: |
168
198
  if [ -z "$ISSUE_NUMBER" ]; then
169
199
  echo "No routine issue to reconcile."
170
200
  exit 0
171
201
  fi
172
202
 
203
+ if [ "$QUOTA_PAUSED" = "true" ]; then
204
+ RESET_STR="${QUOTA_RESET_INFO:-Resets in upcoming window}"
205
+ PAUSE_BODY="### ⏸️ Autonomous Routine Execution Quota-Paused
206
+ - **Routine**: \`dependency-update-security-check\`
207
+ - **Run ID**: [\`${RUN_ID}\`](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})
208
+ - **Trigger**: \`${EVENT_NAME}\`
209
+ - **Status**: LLM quota reached (\`${RESET_STR}\`)
210
+ - **Next Action**: Routine execution paused cleanly. Work will resume automatically on the next scheduled sweep after the quota window resets.
211
+
212
+ ---
213
+ _Generated by [Antigravity](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})_"
214
+
215
+ TEMP_BODY=$(mktemp)
216
+ echo "$PAUSE_BODY" > "$TEMP_BODY"
217
+ gh issue edit "$ISSUE_NUMBER" --body-file "$TEMP_BODY"
218
+ rm -f "$TEMP_BODY"
219
+
220
+ PAUSE_COMMENT=$(printf '%s\n' \
221
+ "### ⏸️ Milestone: Routine Execution Quota-Paused" \
222
+ "- **Routine**: \`dependency-check\`" \
223
+ "- **Status**: LLM quota reached (\`${RESET_STR}\`)" \
224
+ "- **Action Log**: [View GitHub Actions Run](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})" \
225
+ "- **Next Action**: Execution paused cleanly. The routine will resume automatically on the next scheduled sweep." \
226
+ "" \
227
+ "---" \
228
+ "_Generated by [Antigravity](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID})_")
229
+ gh issue comment "$ISSUE_NUMBER" --body "$PAUSE_COMMENT" || true
230
+ gh issue edit "$ISSUE_NUMBER" --add-label "status:quota-paused" --remove-label "status:running"
231
+ gh issue close "$ISSUE_NUMBER" --reason completed
232
+ echo "⏸️ Routine run issue #$ISSUE_NUMBER closed with status:quota-paused."
233
+ exit 0
234
+ fi
235
+
173
236
  REPORT_FILE=".jonah-fleet/run-report.md"
174
237
 
175
238
  if [ -f "$REPORT_FILE" ]; then