patchwork-os 0.2.0-beta.10.canary.106 → 0.2.0-beta.10.canary.107

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchwork-os",
3
- "version": "0.2.0-beta.10.canary.106",
3
+ "version": "0.2.0-beta.10.canary.107",
4
4
  "description": "Your personal AI runtime, local-first. Patchwork OS gives any AI model a consistent set of tools, YAML recipes, a delegation policy with approval queue, and a durable trace memory — all on your machine, all under your policy.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,187 @@
1
+ # yaml-language-server: $schema=https://raw.githubusercontent.com/patchworkos/recipes/main/schema/recipe.v1.json
2
+ apiVersion: patchwork.sh/v1
3
+ version: 1.0.0
4
+ name: incident-to-pr
5
+ description: |
6
+ FLAGSHIP — the end-to-end AI-native incident-response loop. Turns a
7
+ production incident into a reviewed, ready-to-merge pull request. Every
8
+ primitive Patchwork added during the connector + judge→refine campaign
9
+ shows up here in one pipeline:
10
+
11
+ 1. investigate — an agent root-causes the incident against THIS repo
12
+ using the read/git tools it has via MCP (no writes).
13
+ 2. draft_fix — an agent writes the smallest correct patch + a PR
14
+ title/body. This is the draft the judge reviews.
15
+ 3. review_fix — a JUDGE step (agent.kind: judge) gives the draft a
16
+ cold-eyes senior-engineer review. On `request_changes`
17
+ it DRIVES the judge→refine loop: the draft step is
18
+ re-run with the judge's fix-list injected, up to
19
+ `max_revisions` cycles, until the judge approves. This
20
+ is the moat — quality is gated by an AI reviewer, not
21
+ by hope.
22
+ 4. open_pr — an agent opens the PR via the githubCreatePR MCP tool.
23
+ Opening a PR is a high-risk WRITE, so the runtime
24
+ approval gate pauses here for a human to sign off — the
25
+ human-in-the-loop checkpoint before anything lands.
26
+ 5. notify — posts the PR link + judge verdict to Slack.
27
+
28
+ REQUIREMENTS
29
+ - Bridge running with `--driver subprocess` so the agent steps have MCP
30
+ tool access (read files, git, githubCreatePR).
31
+ - GitHub connector connected (for the PR) and Slack connector connected
32
+ (for the alert) — visit /connections, or `patchwork connect github` /
33
+ `patchwork connect slack`.
34
+ - An approval gate of "high" or "all" to exercise the open_pr pause
35
+ (with the gate off, the PR opens unattended).
36
+
37
+ MANUAL RUN
38
+ patchwork recipe run incident-to-pr \
39
+ --var INCIDENT_TITLE="checkout 500s on /api/pay" \
40
+ --var STACK_TRACE="TypeError: cannot read 'id' of undefined at pay.ts:42"
41
+
42
+ WEBHOOK CONVERSION (PagerDuty / Sentry / Datadog)
43
+ Replace the trigger block with:
44
+ trigger:
45
+ type: webhook
46
+ path: /hooks/incident-to-pr
47
+ and reference {{payload.title}} / {{payload.body}} in place of the vars.
48
+
49
+ trigger:
50
+ type: manual
51
+ vars:
52
+ - name: INCIDENT_TITLE
53
+ description: "One-line incident summary (seeds the PR title)"
54
+ required: true
55
+ - name: STACK_TRACE
56
+ description: "Stack trace / error text to root-cause (optional, recommended)"
57
+ required: false
58
+ - name: SEVERITY
59
+ description: "critical | high | medium | low"
60
+ required: false
61
+ default: "high"
62
+ - name: SLACK_CHANNEL
63
+ description: "Slack channel for the resolution alert"
64
+ required: false
65
+ default: "#incidents"
66
+
67
+ steps:
68
+ - id: investigate
69
+ agent:
70
+ driver: claude-code
71
+ prompt: |
72
+ A production incident has fired. Root-cause it against THIS repository.
73
+
74
+ Incident: {{INCIDENT_TITLE}}
75
+ Severity: {{SEVERITY}}
76
+ Stack trace / error:
77
+ {{STACK_TRACE}}
78
+
79
+ Use the read and git tools available to you — read files, search the
80
+ codebase, inspect recent commits and run git blame on the implicated
81
+ files. Do NOT write any files in this step.
82
+
83
+ Respond with a concise root-cause analysis containing:
84
+ - the offending file(s) and line(s)
85
+ - what is going wrong and why
86
+ - the commit that most likely introduced it (if identifiable)
87
+ - the smallest correct fix you would make
88
+ into: investigation
89
+ risk: low
90
+
91
+ - id: draft_fix
92
+ awaits:
93
+ - investigate
94
+ agent:
95
+ driver: claude-code
96
+ prompt: |
97
+ Using the root-cause analysis below, write a concrete, MINIMAL fix.
98
+
99
+ Root-cause analysis:
100
+ {{investigation}}
101
+
102
+ Output exactly these four markdown sections and nothing else:
103
+
104
+ ## PR title
105
+ <conventional-commit-style title, <= 70 chars>
106
+
107
+ ## Summary
108
+ <2-4 sentences: what the bug was and how this change fixes it>
109
+
110
+ ## Patch
111
+ <a unified diff of the smallest change that fixes the root cause —
112
+ touch as few lines as possible; no drive-by refactors>
113
+
114
+ ## Test
115
+ <the test you would add or modify to prove the fix (a diff), or a
116
+ short note if existing coverage already exercises the path>
117
+
118
+ Do NOT write files in this step — only emit the four sections.
119
+ into: fix_draft
120
+ risk: low
121
+
122
+ - id: review_fix
123
+ awaits:
124
+ - draft_fix
125
+ agent:
126
+ kind: judge
127
+ reviews: fix_draft
128
+ max_revisions: 2
129
+ on_exhausted: proceed
130
+ driver: claude-code
131
+ prompt: |
132
+ You are a senior engineer doing a cold-eyes review of the proposed
133
+ fix below BEFORE it becomes a pull request. Judge it on:
134
+ - correctness: does it actually fix the root cause?
135
+ - minimality: smallest possible change, nothing unrelated?
136
+ - safety: regression risk, edge cases, missing guards?
137
+ - tests: is there a test that would FAIL without the fix?
138
+ - PR hygiene: clear, accurate title and summary?
139
+
140
+ Return a verdict: approve | request_changes | unparseable.
141
+ If request_changes, list concrete, actionable fixes — each one a
142
+ specific change the author must make. Those drive the revision loop;
143
+ the draft is regenerated with your fix-list and re-reviewed.
144
+ into: review
145
+ risk: low
146
+
147
+ - id: open_pr
148
+ awaits:
149
+ - review_fix
150
+ agent:
151
+ driver: claude-code
152
+ prompt: |
153
+ The fix below has passed judge review. Open a pull request for it.
154
+
155
+ Approved fix:
156
+ {{fix_draft}}
157
+
158
+ Do this:
159
+ 1. Create a branch off the default branch named
160
+ fix/<short-slug-derived-from-the-PR-title>.
161
+ 2. Apply the change from the "## Patch" section and add the test
162
+ from the "## Test" section.
163
+ 3. Open a pull request using the githubCreatePR tool, with the
164
+ "## PR title" as the title and the "## Summary" — followed by a
165
+ line "Fixes incident: {{INCIDENT_TITLE}}" — as the body.
166
+
167
+ Opening a PR is a write action; it will pause at the approval gate
168
+ for a human to confirm before it lands. After it succeeds, respond
169
+ with ONLY this JSON object (no markdown fences):
170
+ {"prUrl": "<url>", "prNumber": <number>, "branch": "<branch>"}
171
+
172
+ If the GitHub connector is not connected, respond with:
173
+ {"error": "GitHub connector not connected — visit /connections"}
174
+ into: pr
175
+ risk: high
176
+
177
+ - id: notify
178
+ awaits:
179
+ - open_pr
180
+ tool: slack.post_message
181
+ channel: "{{SLACK_CHANNEL}}"
182
+ text: |
183
+ :white_check_mark: Incident fix ready for review
184
+ *Incident:* {{INCIDENT_TITLE}} ({{SEVERITY}})
185
+ *Pull request:* {{pr}}
186
+ *Judge review:* {{review}}
187
+ risk: medium