@mastra/factory 0.12.1-alpha.0 → 0.13.0-alpha.10

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 (211) hide show
  1. package/README.md +163 -0
  2. package/dist/auth.d.ts +2 -0
  3. package/dist/auth.d.ts.map +1 -1
  4. package/dist/auth.js +35 -3
  5. package/dist/auth.js.map +1 -1
  6. package/dist/boards/define-board.d.ts +42 -0
  7. package/dist/boards/define-board.d.ts.map +1 -0
  8. package/dist/boards/define-board.js +53 -0
  9. package/dist/boards/define-board.js.map +1 -0
  10. package/dist/boards/index.d.ts +12 -0
  11. package/dist/boards/index.d.ts.map +1 -0
  12. package/dist/boards/index.js +20 -0
  13. package/dist/boards/index.js.map +1 -0
  14. package/dist/boards/registry.d.ts +16 -0
  15. package/dist/boards/registry.d.ts.map +1 -0
  16. package/dist/boards/registry.js +27 -0
  17. package/dist/boards/registry.js.map +1 -0
  18. package/dist/boards/review.d.ts +4 -0
  19. package/dist/boards/review.d.ts.map +1 -0
  20. package/dist/boards/review.js +76 -0
  21. package/dist/boards/review.js.map +1 -0
  22. package/dist/boards/transition-policy.d.ts +63 -0
  23. package/dist/boards/transition-policy.d.ts.map +1 -0
  24. package/dist/boards/transition-policy.js +36 -0
  25. package/dist/boards/transition-policy.js.map +1 -0
  26. package/dist/boards/work-transition-policy.d.ts +3 -0
  27. package/dist/boards/work-transition-policy.d.ts.map +1 -0
  28. package/dist/boards/work-transition-policy.js +31 -0
  29. package/dist/boards/work-transition-policy.js.map +1 -0
  30. package/dist/boards/work.d.ts +4 -0
  31. package/dist/boards/work.d.ts.map +1 -0
  32. package/dist/boards/work.js +154 -0
  33. package/dist/boards/work.js.map +1 -0
  34. package/dist/factory.d.ts +6 -1
  35. package/dist/factory.d.ts.map +1 -1
  36. package/dist/factory.js +101 -10
  37. package/dist/factory.js.map +1 -1
  38. package/dist/index.d.ts +2 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +6 -1
  41. package/dist/integrations/github/acceptance-labels.d.ts +0 -1
  42. package/dist/integrations/github/acceptance-labels.d.ts.map +1 -1
  43. package/dist/integrations/github/acceptance-labels.js +2 -2
  44. package/dist/integrations/github/acceptance-labels.js.map +1 -1
  45. package/dist/integrations/github/default-rules.d.ts +194 -0
  46. package/dist/integrations/github/default-rules.d.ts.map +1 -0
  47. package/dist/integrations/github/default-rules.js +230 -0
  48. package/dist/integrations/github/default-rules.js.map +1 -0
  49. package/dist/integrations/github/integration.d.ts +4 -0
  50. package/dist/integrations/github/integration.d.ts.map +1 -1
  51. package/dist/integrations/github/integration.js +6 -0
  52. package/dist/integrations/github/integration.js.map +1 -1
  53. package/dist/integrations/github/provenance.d.ts +2 -0
  54. package/dist/integrations/github/provenance.d.ts.map +1 -1
  55. package/dist/integrations/github/provenance.js +3 -2
  56. package/dist/integrations/github/provenance.js.map +1 -1
  57. package/dist/integrations/github/routes.d.ts.map +1 -1
  58. package/dist/integrations/github/routes.js +15 -41
  59. package/dist/integrations/github/routes.js.map +1 -1
  60. package/dist/integrations/github/rules.d.ts +3 -1
  61. package/dist/integrations/github/rules.d.ts.map +1 -1
  62. package/dist/integrations/github/rules.js +36 -7
  63. package/dist/integrations/github/rules.js.map +1 -1
  64. package/dist/integrations/github/webhook.d.ts.map +1 -1
  65. package/dist/integrations/github/webhook.js +35 -3
  66. package/dist/integrations/github/webhook.js.map +1 -1
  67. package/dist/integrations/linear/agent-tools.d.ts +3 -3
  68. package/dist/integrations/linear/agent-tools.d.ts.map +1 -1
  69. package/dist/integrations/linear/agent-tools.js +5 -3
  70. package/dist/integrations/linear/agent-tools.js.map +1 -1
  71. package/dist/integrations/linear/default-rules.d.ts +44 -0
  72. package/dist/integrations/linear/default-rules.d.ts.map +1 -0
  73. package/dist/integrations/linear/default-rules.js +65 -0
  74. package/dist/integrations/linear/default-rules.js.map +1 -0
  75. package/dist/integrations/linear/integration.d.ts +5 -1
  76. package/dist/integrations/linear/integration.d.ts.map +1 -1
  77. package/dist/integrations/linear/integration.js +7 -1
  78. package/dist/integrations/linear/integration.js.map +1 -1
  79. package/dist/integrations/linear/issue-reconciler.d.ts +1 -1
  80. package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -1
  81. package/dist/integrations/linear/issue-reconciler.js +2 -1
  82. package/dist/integrations/linear/issue-reconciler.js.map +1 -1
  83. package/dist/integrations/linear/rules.d.ts +5 -1
  84. package/dist/integrations/linear/rules.d.ts.map +1 -1
  85. package/dist/integrations/linear/rules.js +5 -4
  86. package/dist/integrations/linear/rules.js.map +1 -1
  87. package/dist/integrations/platform/github/integration.d.ts +4 -0
  88. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  89. package/dist/integrations/platform/github/integration.js +6 -0
  90. package/dist/integrations/platform/github/integration.js.map +1 -1
  91. package/dist/integrations/platform/linear/integration.d.ts +5 -1
  92. package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
  93. package/dist/integrations/platform/linear/integration.js +9 -3
  94. package/dist/integrations/platform/linear/integration.js.map +1 -1
  95. package/dist/integrations/slack/slack.d.ts +3 -1
  96. package/dist/integrations/slack/slack.d.ts.map +1 -1
  97. package/dist/integrations/slack/slack.js +20 -2
  98. package/dist/integrations/slack/slack.js.map +1 -1
  99. package/dist/routes/attention-proposed.d.ts +3 -0
  100. package/dist/routes/attention-proposed.d.ts.map +1 -0
  101. package/dist/routes/attention-proposed.js +21 -0
  102. package/dist/routes/attention-proposed.js.map +1 -0
  103. package/dist/routes/attention-providers.d.ts +33 -4
  104. package/dist/routes/attention-providers.d.ts.map +1 -1
  105. package/dist/routes/attention-providers.js +180 -47
  106. package/dist/routes/attention-providers.js.map +1 -1
  107. package/dist/routes/attention.d.ts.map +1 -1
  108. package/dist/routes/attention.js +31 -30
  109. package/dist/routes/attention.js.map +1 -1
  110. package/dist/routes/config.d.ts +2 -0
  111. package/dist/routes/config.d.ts.map +1 -1
  112. package/dist/routes/config.js +3 -2
  113. package/dist/routes/config.js.map +1 -1
  114. package/dist/routes/projects.d.ts +9 -1
  115. package/dist/routes/projects.d.ts.map +1 -1
  116. package/dist/routes/projects.js +26 -5
  117. package/dist/routes/projects.js.map +1 -1
  118. package/dist/routes/supervisor.d.ts +23 -0
  119. package/dist/routes/supervisor.d.ts.map +1 -0
  120. package/dist/routes/supervisor.js +34 -0
  121. package/dist/routes/supervisor.js.map +1 -0
  122. package/dist/routes/surface.d.ts +3 -0
  123. package/dist/routes/surface.d.ts.map +1 -1
  124. package/dist/routes/surface.js +11 -6
  125. package/dist/routes/surface.js.map +1 -1
  126. package/dist/routes/work-items.d.ts +3 -0
  127. package/dist/routes/work-items.d.ts.map +1 -1
  128. package/dist/routes/work-items.js +60 -53
  129. package/dist/routes/work-items.js.map +1 -1
  130. package/dist/rules/defaults.d.ts.map +1 -1
  131. package/dist/rules/defaults.js +2 -418
  132. package/dist/rules/defaults.js.map +1 -1
  133. package/dist/rules/dispatcher.d.ts +1 -0
  134. package/dist/rules/dispatcher.d.ts.map +1 -1
  135. package/dist/rules/dispatcher.js +87 -26
  136. package/dist/rules/dispatcher.js.map +1 -1
  137. package/dist/rules/index.d.ts +2 -2
  138. package/dist/rules/index.d.ts.map +1 -1
  139. package/dist/rules/index.js +2 -2
  140. package/dist/rules/processor.d.ts +2 -0
  141. package/dist/rules/processor.d.ts.map +1 -1
  142. package/dist/rules/processor.js +10 -7
  143. package/dist/rules/processor.js.map +1 -1
  144. package/dist/rules/resolve.d.ts +4 -5
  145. package/dist/rules/resolve.d.ts.map +1 -1
  146. package/dist/rules/resolve.js +4 -9
  147. package/dist/rules/resolve.js.map +1 -1
  148. package/dist/rules/start-coordinator.d.ts +3 -16
  149. package/dist/rules/start-coordinator.d.ts.map +1 -1
  150. package/dist/rules/start-coordinator.js +12 -43
  151. package/dist/rules/start-coordinator.js.map +1 -1
  152. package/dist/rules/terminal-cleanup.d.ts +3 -1
  153. package/dist/rules/terminal-cleanup.d.ts.map +1 -1
  154. package/dist/rules/terminal-cleanup.js +5 -0
  155. package/dist/rules/terminal-cleanup.js.map +1 -1
  156. package/dist/rules/transition-service.d.ts +3 -0
  157. package/dist/rules/transition-service.d.ts.map +1 -1
  158. package/dist/rules/transition-service.js +56 -31
  159. package/dist/rules/transition-service.js.map +1 -1
  160. package/dist/rules/types.d.ts +18 -17
  161. package/dist/rules/types.d.ts.map +1 -1
  162. package/dist/rules/types.js +10 -2
  163. package/dist/rules/types.js.map +1 -1
  164. package/dist/rules/validation.d.ts.map +1 -1
  165. package/dist/rules/validation.js +2 -38
  166. package/dist/rules/validation.js.map +1 -1
  167. package/dist/sandbox/session-retirement.js +1 -1
  168. package/dist/session/org-seed.d.ts +1 -1
  169. package/dist/session/org-seed.js +1 -1
  170. package/dist/session/org-seed.js.map +1 -1
  171. package/dist/storage/domains/comments/domain.js +1 -1
  172. package/dist/storage/domains/comments/routes.js +1 -1
  173. package/dist/storage/domains/work-items/base.d.ts +54 -19
  174. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  175. package/dist/storage/domains/work-items/base.js +215 -38
  176. package/dist/storage/domains/work-items/base.js.map +1 -1
  177. package/dist/supervisor/health-worker.d.ts +17 -0
  178. package/dist/supervisor/health-worker.d.ts.map +1 -0
  179. package/dist/supervisor/health-worker.js +72 -0
  180. package/dist/supervisor/health-worker.js.map +1 -0
  181. package/dist/supervisor/health.d.ts +81 -0
  182. package/dist/supervisor/health.d.ts.map +1 -0
  183. package/dist/supervisor/health.js +244 -0
  184. package/dist/supervisor/health.js.map +1 -0
  185. package/dist/supervisor/instructions.d.ts +6 -0
  186. package/dist/supervisor/instructions.d.ts.map +1 -0
  187. package/dist/supervisor/instructions.js +64 -0
  188. package/dist/supervisor/instructions.js.map +1 -0
  189. package/dist/supervisor/read-tools.d.ts +41 -0
  190. package/dist/supervisor/read-tools.d.ts.map +1 -0
  191. package/dist/supervisor/read-tools.js +338 -0
  192. package/dist/supervisor/read-tools.js.map +1 -0
  193. package/dist/supervisor/session.d.ts +38 -0
  194. package/dist/supervisor/session.d.ts.map +1 -0
  195. package/dist/supervisor/session.js +63 -0
  196. package/dist/supervisor/session.js.map +1 -0
  197. package/dist/supervisor/write-tools.d.ts +26 -0
  198. package/dist/supervisor/write-tools.d.ts.map +1 -0
  199. package/dist/supervisor/write-tools.js +227 -0
  200. package/dist/supervisor/write-tools.js.map +1 -0
  201. package/dist/work-item-branch.d.ts +6 -0
  202. package/dist/work-item-branch.d.ts.map +1 -1
  203. package/dist/work-item-branch.js +15 -9
  204. package/dist/work-item-branch.js.map +1 -1
  205. package/dist/workspace.d.ts +3 -0
  206. package/dist/workspace.d.ts.map +1 -1
  207. package/dist/workspace.js +15 -5
  208. package/dist/workspace.js.map +1 -1
  209. package/factory-skills/configure-factory-rules/SKILL.md +42 -11
  210. package/factory-skills/factory-triage/SKILL.md +1 -1
  211. package/package.json +13 -7
@@ -1,111 +1,6 @@
1
1
  import { FactoryRuleValidationError, assertFactoryRules } from "./validation.js";
2
2
  //#region src/rules/defaults.ts
3
3
  const DEFAULT_FACTORY_RULE_VERSION = "factory-default-v1";
4
- function trustedGithubActor(context) {
5
- return context.actor.type === "github" && context.actor.trusted;
6
- }
7
- function githubActorLogin(context) {
8
- return context.actor.type === "github" ? context.actor.login : void 0;
9
- }
10
- function invokeIssueInvestigation(context) {
11
- return {
12
- type: "invokeSkill",
13
- idempotencyKey: `${context.ingress.id}:factory-triage`,
14
- role: "triage",
15
- skillName: "factory-triage",
16
- arguments: context.item.url ? `GitHub issue (${context.item.url})` : context.item.title
17
- };
18
- }
19
- function retriageGithubIssue(context) {
20
- if (!context.item || context.item.source !== "github-issue" || !context.item.url) return;
21
- if (context.actor.type === "github" && context.actor.factoryAuthored) return;
22
- const reason = context.event === "issueEdited" ? context.issueChange?.title && context.issueChange.body ? "issue title and body edited" : context.issueChange?.title ? "issue title edited" : "issue body edited" : context.event === "issueCommentDeleted" ? "comment deleted" : context.event === "issueCommentEdited" ? "comment edited" : "comment created";
23
- return {
24
- type: "invokeSkill",
25
- idempotencyKey: `${context.ingress.id}:factory-triage`,
26
- role: "triage",
27
- skillName: "factory-triage",
28
- arguments: `Re-triage GitHub issue (${context.item.url}) after ${reason}.`
29
- };
30
- }
31
- function investigateTriagedLinearIssue(context) {
32
- const identifier = context.item.sourceKey?.startsWith("linear:") ? context.item.sourceKey.slice(7) : context.item.title;
33
- return {
34
- type: "invokeSkill",
35
- idempotencyKey: `${context.ingress.id}:factory-triage-linear`,
36
- role: "triage",
37
- skillName: "factory-triage",
38
- arguments: `Linear issue ${identifier}${context.item.url ? ` (${context.item.url})` : ""}`
39
- };
40
- }
41
- function planWorkItem(context) {
42
- return {
43
- type: "invokeSkill",
44
- idempotencyKey: `${context.ingress.id}:factory-plan`,
45
- role: "plan",
46
- skillName: "factory-plan",
47
- arguments: context.item.url ? `Work item (${context.item.url})` : context.item.title
48
- };
49
- }
50
- const GITHUB_LOGIN = /^[a-zA-Z0-9](?:[a-zA-Z0-9]|-(?=[a-zA-Z0-9])){0,38}$/;
51
- /**
52
- * The reporter earns a `Co-Authored-By` trailer on the work their report caused.
53
- * Only a GitHub issue qualifies: Linear stamps a display name and a manual card
54
- * stamps nothing, and neither resolves to the GitHub identity a trailer needs.
55
- * Factory's own reports are skipped — crediting ourselves is noise.
56
- */
57
- function reporterCoAuthor(context) {
58
- if (context.source !== "issue") return void 0;
59
- const author = context.item.metadata?.author;
60
- if (typeof author !== "string" || !author) return void 0;
61
- if (author.endsWith("[bot]") || !GITHUB_LOGIN.test(author)) return void 0;
62
- return author;
63
- }
64
- /**
65
- * Building carries a prompt rather than a skill. The approved plan is already
66
- * the specification, so there is nothing for a skill document to add, and the
67
- * handoff a skill would define is unnecessary here: Building ends by opening a
68
- * pull request, which arrives as its own event and raises the Review card.
69
- */
70
- function buildWorkItem(context) {
71
- const subject = context.item.url ? `the approved plan for ${context.item.url}` : "the approved plan";
72
- const reporter = reporterCoAuthor(context);
73
- const credit = reporter ? ` The work was reported by @${reporter}: credit them on every commit with a \`Co-Authored-By: ${reporter} <ID+${reporter}@users.noreply.github.com>\` trailer, resolving ID with \`gh api users/${reporter} --jq .id\`.` : "";
74
- return {
75
- type: "invokeSkill",
76
- idempotencyKey: `${context.ingress.id}:build`,
77
- role: "work",
78
- prompt: `Implement ${subject}. Open a pull request when the work is ready for review.${credit}`
79
- };
80
- }
81
- function completeIssue(context) {
82
- return {
83
- type: "invokeSkill",
84
- idempotencyKey: `${context.ingress.id}:factory-complete-issue`,
85
- role: "triage",
86
- skillName: "factory-complete-issue",
87
- arguments: context.item.url ? `GitHub issue (${context.item.url})` : context.item.title
88
- };
89
- }
90
- function reviewPullRequest(context) {
91
- const supersedes = context.fromStage !== "intake";
92
- const skillName = context.fromStage === "done" ? "factory-rereview" : "factory-review";
93
- return {
94
- type: "invokeSkill",
95
- idempotencyKey: `${context.ingress.id}:${skillName}`,
96
- role: "review",
97
- skillName,
98
- arguments: context.item.url ? `GitHub pull request (${context.item.url})` : context.item.title,
99
- ...supersedes ? { cancelInFlight: true } : {}
100
- };
101
- }
102
- function onArrival(rule) {
103
- return (context) => {
104
- if (context.cause !== "linked_item_materialized") return;
105
- if (context.item.metadata?.autoStartCandidate !== true) return;
106
- return rule(context);
107
- };
108
- }
109
4
  function resultContent(value) {
110
5
  if (typeof value === "string") return value;
111
6
  if (!value || typeof value !== "object" || Array.isArray(value)) return;
@@ -121,286 +16,7 @@ function advanceApprovedPlan(context) {
121
16
  stage: "execute"
122
17
  };
123
18
  }
124
- function createdAfterFactory(createdAt, factoryCreatedAt) {
125
- if (!createdAt) return false;
126
- const sourceCreatedAt = Date.parse(createdAt);
127
- const projectCreatedAt = Date.parse(factoryCreatedAt);
128
- return Number.isFinite(sourceCreatedAt) && Number.isFinite(projectCreatedAt) && sourceCreatedAt > projectCreatedAt;
129
- }
130
- function issueOpened(context) {
131
- if (!context.issue) return;
132
- return {
133
- type: "upsertLinkedWorkItem",
134
- idempotencyKey: `${context.ingress.id}:issue-intake`,
135
- board: "work",
136
- source: "github-issue",
137
- sourceKey: `github-issue:${context.issue.number}`,
138
- title: context.issue.title,
139
- url: context.issue.url,
140
- stage: "intake",
141
- metadata: {
142
- githubRepositoryId: context.repository.id,
143
- githubIssueNumber: context.issue.number,
144
- ...context.issue.createdAt ? { sourceCreatedAt: context.issue.createdAt } : {},
145
- ...githubActorLogin(context) ? { author: githubActorLogin(context) } : {},
146
- authorTrusted: trustedGithubActor(context),
147
- autoStartCandidate: trustedGithubActor(context) && createdAfterFactory(context.issue.createdAt, context.factory.createdAt),
148
- assignees: context.issue.assignees ?? [],
149
- labels: context.issue.labels ?? []
150
- }
151
- };
152
- }
153
- function issueClosed(context) {
154
- if (!context.item || context.item.source !== "github-issue" || !context.issue) return;
155
- if (context.board !== "work") return;
156
- if (context.item.stages.some((stage) => stage === "done" || stage === "canceled")) return;
157
- const canceled = context.issue.stateReason === "not_planned" || context.issue.stateReason === "duplicate";
158
- return {
159
- type: "transition",
160
- idempotencyKey: `${context.ingress.id}:issue-closed`,
161
- board: "work",
162
- stage: canceled ? "canceled" : "done",
163
- message: { text: `GitHub issue #${context.issue.number} was closed${context.issue.stateReason ? ` (${context.issue.stateReason})` : ""}; this Work card was moved to ${canceled ? "Canceled" : "Done"}.` }
164
- };
165
- }
166
- function pullRequestOpened(context) {
167
- if (!context.pullRequest) return;
168
- const factoryAuthored = context.actor.type === "github" && context.actor.factoryAuthored;
169
- const autoStartCandidate = (trustedGithubActor(context) || factoryAuthored) && createdAfterFactory(context.pullRequest.createdAt, context.factory.createdAt);
170
- return {
171
- type: "upsertLinkedWorkItem",
172
- idempotencyKey: `${context.ingress.id}:pull-request-intake`,
173
- board: "review",
174
- source: "github-pr",
175
- sourceKey: `github-pr:${context.pullRequest.number}`,
176
- title: context.pullRequest.title,
177
- url: context.pullRequest.url,
178
- stage: "intake",
179
- metadata: {
180
- githubRepositoryId: context.repository.id,
181
- githubPullRequestNumber: context.pullRequest.number,
182
- ...context.pullRequest.createdAt ? { sourceCreatedAt: context.pullRequest.createdAt } : {},
183
- factoryAuthored,
184
- authorTrusted: trustedGithubActor(context),
185
- autoStartCandidate,
186
- state: context.pullRequest.state,
187
- draft: context.pullRequest.draft,
188
- merged: context.pullRequest.merged,
189
- assignees: context.pullRequest.assignees ?? [],
190
- requestedReviewers: context.pullRequest.requestedReviewers ?? [],
191
- labels: context.pullRequest.labels ?? [],
192
- headBranch: context.pullRequest.headBranch,
193
- baseBranch: context.pullRequest.baseBranch,
194
- ...githubActorLogin(context) ? { author: githubActorLogin(context) } : {}
195
- }
196
- };
197
- }
198
- function pullRequestMerged(context) {
199
- if (!context.item || !context.pullRequest?.merged) return;
200
- if (context.board === "review") return {
201
- type: "transition",
202
- idempotencyKey: `${context.ingress.id}:pull-request-merged`,
203
- board: "review",
204
- stage: "done",
205
- message: { text: `Pull request #${context.pullRequest.number} merged; this Review card was moved to Done. No further review is needed unless follow-up work was requested.` }
206
- };
207
- return {
208
- type: "sendMessage",
209
- idempotencyKey: `${context.ingress.id}:assess-work-completion`,
210
- role: "work",
211
- message: `Pull request #${context.pullRequest.number} merged. Assess whether the linked Work item is complete. Do not mark it Done solely because this PR merged; use factory_transition_work_item only after verifying the work.`
212
- };
213
- }
214
- function addressReviewFeedback(context) {
215
- if (!context.item || !context.pullRequest || !context.review) return;
216
- if (context.board !== "work") return;
217
- if (context.pullRequest.state !== "open" || context.pullRequest.merged) return;
218
- if (context.review.state.toLowerCase() !== "changes_requested") return;
219
- return {
220
- type: "sendMessage",
221
- idempotencyKey: `${context.ingress.id}:address-review-feedback`,
222
- role: "work",
223
- priority: "high",
224
- message: `Changes were requested on pull request #${context.pullRequest.number} (${context.review.url}). Read the review comments on this PR, address the ones you agree with, and push the fixes to the PR branch. Reply on GitHub to anything you are deliberately not changing, explaining why.`
225
- };
226
- }
227
- /**
228
- * Detects the `factory-review` handoff verdict in a comment body.
229
- *
230
- * GitHub forbids an app from reviewing a pull request it authored, so on
231
- * Factory-authored PRs the review skill falls back to posting its verdict as a
232
- * plain comment. That comment is the only signal the authoring agent gets, so
233
- * it has to be readable back out. The skill's handoff contract puts the verdict
234
- * on the first line (`Verdict: request changes`), so only that line is
235
- * inspected — a verdict quoted later in the findings must not count.
236
- */
237
- function requestsChangesVerdict(body) {
238
- const firstLine = body?.split("\n").map((line) => line.trim()).find((line) => line.length > 0);
239
- if (!firstLine) return false;
240
- const normalized = firstLine.replaceAll(/[*_`#>\s]+/g, " ").trim().toLowerCase();
241
- return /^verdict: ?(request changes|changes requested)$/.test(normalized);
242
- }
243
- function addressPullRequestComment(context) {
244
- if (!context.item || !context.pullRequest || !context.issueComment) return;
245
- if (context.board !== "work") return;
246
- if (context.pullRequest.state !== "open" || context.pullRequest.merged) return;
247
- if (context.actor.type === "github" && context.actor.factoryAuthored && !requestsChangesVerdict(context.issueComment.body)) return;
248
- return {
249
- type: "sendMessage",
250
- idempotencyKey: `${context.ingress.id}:address-pull-request-comment`,
251
- role: "work",
252
- priority: "high",
253
- message: `${context.issueComment.author ?? "Someone"} commented on pull request #${context.pullRequest.number} (${context.issueComment.url ?? context.pullRequest.url}). Read the comment, address it if you agree, and push the fixes to the PR branch. Reply on GitHub to anything you are deliberately not changing, explaining why.`
254
- };
255
- }
256
- function pullRequestClosed(context) {
257
- if (!context.item || !context.pullRequest || context.pullRequest.merged) return;
258
- if (context.board !== "review") return;
259
- return {
260
- type: "transition",
261
- idempotencyKey: `${context.ingress.id}:pull-request-closed`,
262
- board: "review",
263
- stage: "canceled",
264
- message: { text: `Pull request #${context.pullRequest.number} was closed without merging; this Review card was moved to Canceled.` }
265
- };
266
- }
267
- function reReviewRequestedPullRequest(context) {
268
- if (!context.item || context.board !== "review" || !context.reviewRequest?.factoryReviewer) return;
269
- if (!context.pullRequest || context.pullRequest.state !== "open" || context.pullRequest.merged) return;
270
- if (!trustedGithubActor(context)) return;
271
- if (context.actor.type === "github" && context.actor.factoryAuthored) return;
272
- if (context.item.stages.length === 1 && context.item.stages[0] === "review") return;
273
- return {
274
- type: "transition",
275
- idempotencyKey: `${context.ingress.id}:re-review-requested`,
276
- board: "review",
277
- stage: "review"
278
- };
279
- }
280
- function reReviewUpdatedPullRequest(context) {
281
- if (!context.item || context.board !== "review") return;
282
- if (!context.pullRequest || context.pullRequest.state !== "open" || context.pullRequest.merged) return;
283
- if (context.item.stages.some((stage) => stage === "intake")) return;
284
- const alreadyReviewing = context.item.stages.some((stage) => stage === "review");
285
- return {
286
- type: "transition",
287
- idempotencyKey: `${context.ingress.id}:re-review-updated`,
288
- board: "review",
289
- stage: "review",
290
- ...alreadyReviewing ? { reenter: true } : {}
291
- };
292
- }
293
- function linearIssueObserved(context) {
294
- if (context.item) return;
295
- return {
296
- type: "upsertLinkedWorkItem",
297
- idempotencyKey: `${context.ingress.id}:issue-triage`,
298
- board: "work",
299
- source: "linear-issue",
300
- sourceKey: `linear:${context.issue.identifier}`,
301
- title: `${context.issue.identifier}: ${context.issue.title}`,
302
- url: context.issue.url,
303
- stage: "triage",
304
- metadata: {
305
- linearIssueId: context.issue.id,
306
- identifier: context.issue.identifier,
307
- sourceCreatedAt: context.issue.createdAt,
308
- linearState: context.issue.state,
309
- linearStateType: context.issue.stateType,
310
- linearPriority: context.issue.priorityLabel,
311
- linearAssignee: context.issue.assignee,
312
- linearCreator: context.issue.creator,
313
- linearTeam: context.issue.team,
314
- labels: [...context.issue.labels],
315
- ...context.issue.assignee ? { assignee: context.issue.assignee } : {},
316
- ...context.issue.creator ? {
317
- creator: context.issue.creator,
318
- author: context.issue.creator
319
- } : {}
320
- }
321
- };
322
- }
323
- function linearIssueClosed(context) {
324
- if (!context.item || context.item.source !== "linear-issue") return;
325
- if (context.board !== "work") return;
326
- if (context.item.stages.some((stage) => stage === "done" || stage === "canceled")) return;
327
- const stateType = context.issue.stateType;
328
- if (stateType !== "completed" && stateType !== "canceled") return;
329
- const canceled = stateType === "canceled";
330
- return {
331
- type: "transition",
332
- idempotencyKey: `${context.ingress.id}:issue-closed`,
333
- board: "work",
334
- stage: canceled ? "canceled" : "done",
335
- message: { text: `Linear issue ${context.issue.identifier} was ${canceled ? "canceled" : "completed"}; this Work card was moved to ${canceled ? "Canceled" : "Done"}.` }
336
- };
337
- }
338
- const BUILT_IN_DEFAULTS = {
339
- work: {
340
- intake: { issue: { onEnter: onArrival(invokeIssueInvestigation) } },
341
- triage: {
342
- issue: { onEnter: invokeIssueInvestigation },
343
- linearIssue: { onEnter: investigateTriagedLinearIssue }
344
- },
345
- planning: {
346
- issue: { onEnter: planWorkItem },
347
- linearIssue: { onEnter: planWorkItem },
348
- manual: { onEnter: planWorkItem }
349
- },
350
- execute: {
351
- issue: { onEnter: buildWorkItem },
352
- linearIssue: { onEnter: buildWorkItem },
353
- manual: { onEnter: buildWorkItem }
354
- },
355
- done: { issue: { onEnter: completeIssue } }
356
- },
357
- review: {
358
- intake: { pullRequest: { onEnter: onArrival(reviewPullRequest) } },
359
- review: { pullRequest: { onEnter: reviewPullRequest } }
360
- },
361
- tools: { submit_plan: { onResult: advanceApprovedPlan } },
362
- github: {
363
- issueOpened: { onEvent: issueOpened },
364
- issueEdited: { onEvent: retriageGithubIssue },
365
- issueClosed: { onEvent: issueClosed },
366
- issueCommentCreated: { onEvent: retriageGithubIssue },
367
- issueCommentEdited: { onEvent: retriageGithubIssue },
368
- issueCommentDeleted: { onEvent: retriageGithubIssue },
369
- pullRequestOpened: { onEvent: pullRequestOpened },
370
- pullRequestUpdated: { onEvent: reReviewUpdatedPullRequest },
371
- pullRequestCommentCreated: { onEvent: addressPullRequestComment },
372
- pullRequestReviewRequested: { onEvent: reReviewRequestedPullRequest },
373
- pullRequestReviewSubmitted: { onEvent: addressReviewFeedback },
374
- pullRequestMerged: { onEvent: pullRequestMerged },
375
- pullRequestClosed: { onEvent: pullRequestClosed }
376
- },
377
- linear: {
378
- issueObserved: { onEvent: linearIssueObserved },
379
- issueClosed: { onEvent: linearIssueClosed }
380
- }
381
- };
382
- function mergeBoardRules(base, overrides) {
383
- const result = {};
384
- const stages = /* @__PURE__ */ new Set([...Object.keys(base ?? {}), ...Object.keys(overrides ?? {})]);
385
- for (const stage of stages) {
386
- const baseSources = base?.[stage];
387
- const overrideSources = overrides?.[stage];
388
- const sources = /* @__PURE__ */ new Set([...Object.keys(baseSources ?? {}), ...Object.keys(overrideSources ?? {})]);
389
- const mergedSources = {};
390
- for (const source of sources) {
391
- const baseLeaf = baseSources?.[source];
392
- const overrideLeaf = overrideSources?.[source];
393
- mergedSources[source] = {
394
- ...baseLeaf && "onEnter" in baseLeaf ? { onEnter: baseLeaf.onEnter } : {},
395
- ...baseLeaf && "onExit" in baseLeaf ? { onExit: baseLeaf.onExit } : {},
396
- ...overrideLeaf && "onEnter" in overrideLeaf ? { onEnter: overrideLeaf.onEnter } : {},
397
- ...overrideLeaf && "onExit" in overrideLeaf ? { onExit: overrideLeaf.onExit } : {}
398
- };
399
- }
400
- result[stage] = mergedSources;
401
- }
402
- return result;
403
- }
19
+ const BUILT_IN_DEFAULTS = { tools: { submit_plan: { onResult: advanceApprovedPlan } } };
404
20
  function mergeToolRules(base, overrides) {
405
21
  const result = {};
406
22
  for (const name of /* @__PURE__ */ new Set([...Object.keys(base ?? {}), ...Object.keys(overrides ?? {})])) {
@@ -413,40 +29,8 @@ function mergeToolRules(base, overrides) {
413
29
  }
414
30
  return result;
415
31
  }
416
- function mergeGithubRules(base, overrides) {
417
- const result = {};
418
- const events = /* @__PURE__ */ new Set([...Object.keys(base ?? {}), ...Object.keys(overrides ?? {})]);
419
- for (const event of events) {
420
- const baseLeaf = base?.[event];
421
- const overrideLeaf = overrides?.[event];
422
- result[event] = {
423
- ...baseLeaf && "onEvent" in baseLeaf ? { onEvent: baseLeaf.onEvent } : {},
424
- ...overrideLeaf && "onEvent" in overrideLeaf ? { onEvent: overrideLeaf.onEvent } : {}
425
- };
426
- }
427
- return result;
428
- }
429
- function mergeLinearRules(base, overrides) {
430
- const result = {};
431
- const events = /* @__PURE__ */ new Set([...Object.keys(base ?? {}), ...Object.keys(overrides ?? {})]);
432
- for (const event of events) {
433
- const baseLeaf = base?.[event];
434
- const overrideLeaf = overrides?.[event];
435
- result[event] = {
436
- ...baseLeaf && "onEvent" in baseLeaf ? { onEvent: baseLeaf.onEvent } : {},
437
- ...overrideLeaf && "onEvent" in overrideLeaf ? { onEvent: overrideLeaf.onEvent } : {}
438
- };
439
- }
440
- return result;
441
- }
442
32
  function mergeFactoryRuleOverrides(base, overrides = {}) {
443
- return {
444
- work: mergeBoardRules(base.work, overrides.work),
445
- review: mergeBoardRules(base.review, overrides.review),
446
- tools: mergeToolRules(base.tools, overrides.tools),
447
- github: mergeGithubRules(base.github, overrides.github),
448
- linear: mergeLinearRules(base.linear, overrides.linear)
449
- };
33
+ return { tools: mergeToolRules(base.tools, overrides.tools) };
450
34
  }
451
35
  function defaultFactoryRules(input) {
452
36
  if (typeof input?.version !== "string" || input.version.trim().length === 0) throw new FactoryRuleValidationError("Factory rule version is required.");
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.js","names":[],"sources":["../../src/rules/defaults.ts"],"sourcesContent":["import type {\n FactoryBoardRuleLeaf,\n FactoryBoardRules,\n FactoryGithubRuleLeaf,\n FactoryGithubEventName,\n FactoryGithubRuleContext,\n FactoryLinearEventName,\n FactoryLinearRuleContext,\n FactoryLinearRuleLeaf,\n FactoryRules,\n FactoryRulesOverrides,\n FactoryRuleSource,\n FactoryRuleStage,\n FactoryStageRuleContext,\n FactoryToolResultRuleContext,\n FactoryToolRuleLeaf,\n} from './types.js';\nimport { assertFactoryRules, FactoryRuleValidationError } from './validation.js';\n\nexport const DEFAULT_FACTORY_RULE_VERSION = 'factory-default-v1';\n\nfunction trustedGithubActor(context: Pick<FactoryStageRuleContext, 'actor'>): boolean {\n return context.actor.type === 'github' && context.actor.trusted;\n}\n\nfunction githubActorLogin(context: Pick<FactoryStageRuleContext, 'actor'>): string | undefined {\n return context.actor.type === 'github' ? context.actor.login : undefined;\n}\n\nfunction invokeIssueInvestigation(context: FactoryStageRuleContext) {\n return {\n type: 'invokeSkill',\n idempotencyKey: `${context.ingress.id}:factory-triage`,\n role: 'triage',\n skillName: 'factory-triage',\n arguments: context.item.url ? `GitHub issue (${context.item.url})` : context.item.title,\n } as const;\n}\n\nfunction retriageGithubIssue(context: FactoryGithubRuleContext) {\n if (!context.item || context.item.source !== 'github-issue' || !context.item.url) return;\n if (context.actor.type === 'github' && context.actor.factoryAuthored) return;\n\n const reason =\n context.event === 'issueEdited'\n ? context.issueChange?.title && context.issueChange.body\n ? 'issue title and body edited'\n : context.issueChange?.title\n ? 'issue title edited'\n : 'issue body edited'\n : context.event === 'issueCommentDeleted'\n ? 'comment deleted'\n : context.event === 'issueCommentEdited'\n ? 'comment edited'\n : 'comment created';\n return {\n type: 'invokeSkill',\n idempotencyKey: `${context.ingress.id}:factory-triage`,\n role: 'triage',\n skillName: 'factory-triage',\n arguments: `Re-triage GitHub issue (${context.item.url}) after ${reason}.`,\n } as const;\n}\n\nfunction investigateTriagedLinearIssue(context: FactoryStageRuleContext) {\n const identifier = context.item.sourceKey?.startsWith('linear:')\n ? context.item.sourceKey.slice('linear:'.length)\n : context.item.title;\n return {\n type: 'invokeSkill',\n idempotencyKey: `${context.ingress.id}:factory-triage-linear`,\n role: 'triage',\n skillName: 'factory-triage',\n arguments: `Linear issue ${identifier}${context.item.url ? ` (${context.item.url})` : ''}`,\n } as const;\n}\n\nfunction planWorkItem(context: FactoryStageRuleContext) {\n return {\n type: 'invokeSkill',\n idempotencyKey: `${context.ingress.id}:factory-plan`,\n role: 'plan',\n skillName: 'factory-plan',\n arguments: context.item.url ? `Work item (${context.item.url})` : context.item.title,\n } as const;\n}\n\n// A GitHub login is alphanumeric with interior hyphens — no underscores, no\n// spaces. Checking the grammar rejects the placeholder the issue poller stamps\n// when the reporter's account is gone (`__unknown__`), which would otherwise\n// become a trailer crediting an account that does not exist.\nconst GITHUB_LOGIN = /^[a-zA-Z0-9](?:[a-zA-Z0-9]|-(?=[a-zA-Z0-9])){0,38}$/;\n\n/**\n * The reporter earns a `Co-Authored-By` trailer on the work their report caused.\n * Only a GitHub issue qualifies: Linear stamps a display name and a manual card\n * stamps nothing, and neither resolves to the GitHub identity a trailer needs.\n * Factory's own reports are skipped — crediting ourselves is noise.\n */\nfunction reporterCoAuthor(context: FactoryStageRuleContext) {\n if (context.source !== 'issue') return undefined;\n const author = context.item.metadata?.author;\n if (typeof author !== 'string' || !author) return undefined;\n if (author.endsWith('[bot]') || !GITHUB_LOGIN.test(author)) return undefined;\n return author;\n}\n\n/**\n * Building carries a prompt rather than a skill. The approved plan is already\n * the specification, so there is nothing for a skill document to add, and the\n * handoff a skill would define is unnecessary here: Building ends by opening a\n * pull request, which arrives as its own event and raises the Review card.\n */\nfunction buildWorkItem(context: FactoryStageRuleContext) {\n const subject = context.item.url ? `the approved plan for ${context.item.url}` : 'the approved plan';\n const reporter = reporterCoAuthor(context);\n // The trailer needs the reporter's numeric id, which intake does not stamp, so\n // the agent resolves it from the same issue it is already reading.\n const credit = reporter\n ? ` The work was reported by @${reporter}: credit them on every commit with a ` +\n `\\`Co-Authored-By: ${reporter} <ID+${reporter}@users.noreply.github.com>\\` trailer, ` +\n `resolving ID with \\`gh api users/${reporter} --jq .id\\`.`\n : '';\n return {\n type: 'invokeSkill',\n idempotencyKey: `${context.ingress.id}:build`,\n role: 'work',\n prompt: `Implement ${subject}. Open a pull request when the work is ready for review.${credit}`,\n } as const;\n}\n\nfunction completeIssue(context: FactoryStageRuleContext) {\n return {\n type: 'invokeSkill',\n idempotencyKey: `${context.ingress.id}:factory-complete-issue`,\n role: 'triage',\n skillName: 'factory-complete-issue',\n arguments: context.item.url ? `GitHub issue (${context.item.url})` : context.item.title,\n } as const;\n}\n\nfunction reviewPullRequest(context: FactoryStageRuleContext) {\n // A re-entry into Review (from any post-intake stage) supersedes whichever\n // review pass previously ran on this card: cancel any in-flight run before\n // dispatching a fresh one so we don't burn tokens on the stale pass and race\n // two agents on the same card. Cancellation is safe when nothing is in flight.\n const supersedes = context.fromStage !== 'intake';\n // The re-review skill only applies when a prior review pass actually completed\n // (the card is returning from `done`). A cancelled first-time review that\n // re-enters Review from `review` itself still has no prior pass to reconcile —\n // it gets the regular factory-review skill.\n const priorReviewCompleted = context.fromStage === 'done';\n const skillName = priorReviewCompleted ? 'factory-rereview' : 'factory-review';\n return {\n type: 'invokeSkill',\n idempotencyKey: `${context.ingress.id}:${skillName}`,\n role: 'review',\n skillName,\n arguments: context.item.url ? `GitHub pull request (${context.item.url})` : context.item.title,\n ...(supersedes ? { cancelInFlight: true } : {}),\n } as const;\n}\n\n// Fires only on webhook materialization, so an item filed by hand or re-synced\n// from source never suggests its own run.\nfunction onArrival<Effect>(rule: (context: FactoryStageRuleContext) => Effect) {\n return (context: FactoryStageRuleContext): Effect | undefined => {\n if (context.cause !== 'linked_item_materialized') return;\n if (context.item.metadata?.autoStartCandidate !== true) return;\n return rule(context);\n };\n}\n\nfunction resultContent(value: unknown): string | undefined {\n if (typeof value === 'string') return value;\n if (!value || typeof value !== 'object' || Array.isArray(value)) return;\n const content = (value as { content?: unknown }).content;\n return typeof content === 'string' ? content : undefined;\n}\n\n// Interactive-session path only: factory-plan never calls submit_plan — it\n// advances planning → execute via factory_transition_work_item directly.\nfunction advanceApprovedPlan(context: FactoryToolResultRuleContext) {\n if (\n context.result.status !== 'success' ||\n context.board !== 'work' ||\n context.item.stages.length !== 1 ||\n context.item.stages[0] !== 'planning' ||\n context.actor.type !== 'agent' ||\n context.actor.role !== 'plan' ||\n !resultContent(context.result.value)?.startsWith('Plan approved.')\n ) {\n return;\n }\n return {\n type: 'transition',\n idempotencyKey: `${context.ingress.id}:approved-plan`,\n board: 'work',\n stage: 'execute',\n } as const;\n}\n\nfunction createdAfterFactory(createdAt: string | undefined, factoryCreatedAt: string): boolean {\n if (!createdAt) return false;\n const sourceCreatedAt = Date.parse(createdAt);\n const projectCreatedAt = Date.parse(factoryCreatedAt);\n return Number.isFinite(sourceCreatedAt) && Number.isFinite(projectCreatedAt) && sourceCreatedAt > projectCreatedAt;\n}\n\nfunction issueOpened(context: FactoryGithubRuleContext) {\n if (!context.issue) return;\n // Everything arrives in Intake; arrival only stamps whether `onArrival` may\n // suggest this card's run without a person.\n return {\n type: 'upsertLinkedWorkItem',\n idempotencyKey: `${context.ingress.id}:issue-intake`,\n board: 'work',\n source: 'github-issue',\n sourceKey: `github-issue:${context.issue.number}`,\n title: context.issue.title,\n url: context.issue.url,\n stage: 'intake',\n metadata: {\n githubRepositoryId: context.repository.id,\n githubIssueNumber: context.issue.number,\n ...(context.issue.createdAt ? { sourceCreatedAt: context.issue.createdAt } : {}),\n ...(githubActorLogin(context) ? { author: githubActorLogin(context) } : {}),\n authorTrusted: trustedGithubActor(context),\n autoStartCandidate:\n trustedGithubActor(context) && createdAfterFactory(context.issue.createdAt, context.factory.createdAt),\n assignees: context.issue.assignees ?? [],\n labels: context.issue.labels ?? [],\n },\n } as const;\n}\n\nfunction issueClosed(context: FactoryGithubRuleContext) {\n if (!context.item || context.item.source !== 'github-issue' || !context.issue) return;\n if (context.board !== 'work') return;\n // Already off the board: nothing to reconcile.\n if (context.item.stages.some(stage => stage === 'done' || stage === 'canceled')) return;\n // Issue closure is a repository fact, not third-party input — no actor trust\n // gate. `not_planned` (and `duplicate`) means abandoned, everything else is\n // completed work.\n const canceled = context.issue.stateReason === 'not_planned' || context.issue.stateReason === 'duplicate';\n return {\n type: 'transition',\n idempotencyKey: `${context.ingress.id}:issue-closed`,\n board: 'work',\n stage: canceled ? 'canceled' : 'done',\n message: {\n text:\n `GitHub issue #${context.issue.number} was closed` +\n `${context.issue.stateReason ? ` (${context.issue.stateReason})` : ''}; ` +\n `this Work card was moved to ${canceled ? 'Canceled' : 'Done'}.`,\n },\n } as const;\n}\n\nfunction pullRequestOpened(context: FactoryGithubRuleContext) {\n if (!context.pullRequest) return;\n // A GitHub App bot is never a collaborator, so Factory's own PRs score\n // untrusted; their authorship is the trust signal.\n const factoryAuthored = context.actor.type === 'github' && context.actor.factoryAuthored;\n const autoStartCandidate =\n (trustedGithubActor(context) || factoryAuthored) &&\n createdAfterFactory(context.pullRequest.createdAt, context.factory.createdAt);\n return {\n type: 'upsertLinkedWorkItem',\n idempotencyKey: `${context.ingress.id}:pull-request-intake`,\n board: 'review',\n source: 'github-pr',\n sourceKey: `github-pr:${context.pullRequest.number}`,\n title: context.pullRequest.title,\n url: context.pullRequest.url,\n stage: 'intake',\n metadata: {\n githubRepositoryId: context.repository.id,\n githubPullRequestNumber: context.pullRequest.number,\n ...(context.pullRequest.createdAt ? { sourceCreatedAt: context.pullRequest.createdAt } : {}),\n factoryAuthored,\n authorTrusted: trustedGithubActor(context),\n autoStartCandidate,\n state: context.pullRequest.state,\n draft: context.pullRequest.draft,\n merged: context.pullRequest.merged,\n assignees: context.pullRequest.assignees ?? [],\n requestedReviewers: context.pullRequest.requestedReviewers ?? [],\n labels: context.pullRequest.labels ?? [],\n headBranch: context.pullRequest.headBranch,\n baseBranch: context.pullRequest.baseBranch,\n ...(githubActorLogin(context) ? { author: githubActorLogin(context) } : {}),\n },\n } as const;\n}\n\nfunction pullRequestMerged(context: FactoryGithubRuleContext) {\n if (!context.item || !context.pullRequest?.merged) return;\n if (context.board === 'review') {\n // The event is bound to the PR's own Review card: a merged PR is finished\n // review work, so always move the card to Done. The message only reaches\n // an active session (if any) — cards without one just move, instead of\n // failing retries against a binding that never existed.\n return {\n type: 'transition',\n idempotencyKey: `${context.ingress.id}:pull-request-merged`,\n board: 'review',\n stage: 'done',\n message: {\n text:\n `Pull request #${context.pullRequest.number} merged; this Review card was moved to Done. ` +\n 'No further review is needed unless follow-up work was requested.',\n },\n } as const;\n }\n // Provenance bound the event to the originating Work item instead: remind\n // its agent to assess completion — never auto-complete the Work item.\n return {\n type: 'sendMessage',\n idempotencyKey: `${context.ingress.id}:assess-work-completion`,\n role: 'work',\n message:\n `Pull request #${context.pullRequest.number} merged. Assess whether the linked Work item is complete. ` +\n 'Do not mark it Done solely because this PR merged; use factory_transition_work_item only after verifying the work.',\n } as const;\n}\n\nfunction addressReviewFeedback(context: FactoryGithubRuleContext) {\n if (!context.item || !context.pullRequest || !context.review) return;\n // Only the Work item that authored the PR can act on the feedback. Provenance\n // binds the event there; a Review card seeing its own posted review must not\n // react to it (that would loop the reviewer against itself).\n if (context.board !== 'work') return;\n // A closed or merged pull request has no branch left to push fixes to.\n if (context.pullRequest.state !== 'open' || context.pullRequest.merged) return;\n // `approved` needs no work, and `commented` (a review body with no verdict)\n // is how a reviewer leaves notes without blocking — only a verdict that asks\n // for changes should pull the author back in.\n if (context.review.state.toLowerCase() !== 'changes_requested') return;\n // The authoring thread is already subscribed to this PR (`gh pr create`\n // subscribes automatically), so it can read the individual line comments\n // from its own notification inbox — the message only has to wake it and\n // point at the review.\n return {\n type: 'sendMessage',\n idempotencyKey: `${context.ingress.id}:address-review-feedback`,\n role: 'work',\n priority: 'high',\n message:\n `Changes were requested on pull request #${context.pullRequest.number} (${context.review.url}). ` +\n 'Read the review comments on this PR, address the ones you agree with, and push the fixes to the PR branch. ' +\n 'Reply on GitHub to anything you are deliberately not changing, explaining why.',\n } as const;\n}\n\n/**\n * Detects the `factory-review` handoff verdict in a comment body.\n *\n * GitHub forbids an app from reviewing a pull request it authored, so on\n * Factory-authored PRs the review skill falls back to posting its verdict as a\n * plain comment. That comment is the only signal the authoring agent gets, so\n * it has to be readable back out. The skill's handoff contract puts the verdict\n * on the first line (`Verdict: request changes`), so only that line is\n * inspected — a verdict quoted later in the findings must not count.\n */\nfunction requestsChangesVerdict(body: string | undefined): boolean {\n const firstLine = body\n ?.split('\\n')\n .map(line => line.trim())\n .find(line => line.length > 0);\n if (!firstLine) return false;\n // Tolerate the markdown the skill wraps the line in (`**Verdict: ...**`).\n const normalized = firstLine\n .replaceAll(/[*_`#>\\s]+/g, ' ')\n .trim()\n .toLowerCase();\n // Match the verdict exactly so negated phrasings (\"Verdict: do not request\n // changes\") cannot wake the author.\n return /^verdict: ?(request changes|changes requested)$/.test(normalized);\n}\n\nfunction addressPullRequestComment(context: FactoryGithubRuleContext) {\n if (!context.item || !context.pullRequest || !context.issueComment) return;\n // Provenance binds the comment to the Work item that authored the PR — the\n // only session that can act on it. A Review card must not react to comments\n // on the PR it is reviewing.\n if (context.board !== 'work') return;\n if (context.pullRequest.state !== 'open' || context.pullRequest.merged) return;\n // `factoryAuthored` is one bit for the whole Factory, so Factory's own\n // comments are indistinguishable between roles — waking on all of them would\n // let the Work agent's own progress comments wake itself in a loop. The one\n // exception is the review verdict the Review run had to post as a comment\n // because GitHub refused a self-review: that is the handoff, and it only ever\n // asks for changes once per review, so it cannot sustain a loop.\n if (\n context.actor.type === 'github' &&\n context.actor.factoryAuthored &&\n !requestsChangesVerdict(context.issueComment.body)\n ) {\n return;\n }\n return {\n type: 'sendMessage',\n idempotencyKey: `${context.ingress.id}:address-pull-request-comment`,\n role: 'work',\n priority: 'high',\n message:\n `${context.issueComment.author ?? 'Someone'} commented on pull request #${context.pullRequest.number} ` +\n `(${context.issueComment.url ?? context.pullRequest.url}). Read the comment, address it if you agree, and push ` +\n 'the fixes to the PR branch. Reply on GitHub to anything you are deliberately not changing, explaining why.',\n } as const;\n}\n\nfunction pullRequestClosed(context: FactoryGithubRuleContext) {\n if (!context.item || !context.pullRequest || context.pullRequest.merged) return;\n if (context.board !== 'review') return;\n // A PR closed without merging is abandoned review work: clear the card off\n // the board instead of leaving it in Reviewing forever.\n return {\n type: 'transition',\n idempotencyKey: `${context.ingress.id}:pull-request-closed`,\n board: 'review',\n stage: 'canceled',\n message: {\n text:\n `Pull request #${context.pullRequest.number} was closed without merging; ` +\n 'this Review card was moved to Canceled.',\n },\n } as const;\n}\n\nfunction reReviewRequestedPullRequest(context: FactoryGithubRuleContext) {\n // Only a review re-requested *from Factory's own bot* restarts the review —\n // requesting a human reviewer is not Factory's signal.\n if (!context.item || context.board !== 'review' || !context.reviewRequest?.factoryReviewer) return;\n if (!context.pullRequest || context.pullRequest.state !== 'open' || context.pullRequest.merged) return;\n // Trusted (write/admin) requesters only: re-entering review checks out and\n // executes PR code, the same bar pullRequestOpened applies to auto-review.\n if (!trustedGithubActor(context)) return;\n if (context.actor.type === 'github' && context.actor.factoryAuthored) return;\n // Already in Reviewing: a review pass is pending or running; re-entering\n // would be a same-stage no-op anyway (stage rules only fire on change).\n if (context.item.stages.length === 1 && context.item.stages[0] === 'review') return;\n return {\n type: 'transition',\n idempotencyKey: `${context.ingress.id}:re-review-requested`,\n board: 'review',\n stage: 'review',\n } as const;\n}\n\nfunction reReviewUpdatedPullRequest(context: FactoryGithubRuleContext) {\n if (!context.item || context.board !== 'review') return;\n if (!context.pullRequest || context.pullRequest.state !== 'open' || context.pullRequest.merged) return;\n // Intake has not started a review pass yet, so a push there is just more of\n // the code the first pass will read. A push to a card sitting in Reviewing is\n // different: it invalidates whatever that pass is reading, so re-enter the\n // stage to supersede it. `reviewPullRequest` cancels the stale run and picks\n // the right skill for the entry it sees.\n if (context.item.stages.some(stage => stage === 'intake')) return;\n const alreadyReviewing = context.item.stages.some(stage => stage === 'review');\n return {\n type: 'transition',\n idempotencyKey: `${context.ingress.id}:re-review-updated`,\n board: 'review',\n stage: 'review',\n // Re-entry is the point when the card is already Reviewing: the stage's\n // entry rule is what cancels the superseded pass and starts one on the code\n // that just landed.\n ...(alreadyReviewing ? { reenter: true } : {}),\n } as const;\n}\n\nfunction linearIssueObserved(context: FactoryLinearRuleContext) {\n if (context.item) return;\n return {\n type: 'upsertLinkedWorkItem',\n idempotencyKey: `${context.ingress.id}:issue-triage`,\n board: 'work',\n source: 'linear-issue',\n sourceKey: `linear:${context.issue.identifier}`,\n title: `${context.issue.identifier}: ${context.issue.title}`,\n url: context.issue.url,\n stage: 'triage',\n metadata: {\n linearIssueId: context.issue.id,\n identifier: context.issue.identifier,\n sourceCreatedAt: context.issue.createdAt,\n linearState: context.issue.state,\n linearStateType: context.issue.stateType,\n linearPriority: context.issue.priorityLabel,\n linearAssignee: context.issue.assignee,\n linearCreator: context.issue.creator,\n linearTeam: context.issue.team,\n labels: [...context.issue.labels] as string[],\n ...(context.issue.assignee ? { assignee: context.issue.assignee } : {}),\n ...(context.issue.creator ? { creator: context.issue.creator, author: context.issue.creator } : {}),\n },\n } as const;\n}\n\nfunction linearIssueClosed(context: FactoryLinearRuleContext) {\n if (!context.item || context.item.source !== 'linear-issue') return;\n if (context.board !== 'work') return;\n // Already off the board: nothing to reconcile.\n if (context.item.stages.some(stage => stage === 'done' || stage === 'canceled')) return;\n // Only terminal state types trigger close.\n const stateType = context.issue.stateType;\n if (stateType !== 'completed' && stateType !== 'canceled') return;\n const canceled = stateType === 'canceled';\n return {\n type: 'transition',\n idempotencyKey: `${context.ingress.id}:issue-closed`,\n board: 'work',\n stage: canceled ? 'canceled' : 'done',\n message: {\n text: `Linear issue ${context.issue.identifier} was ${canceled ? 'canceled' : 'completed'}; this Work card was moved to ${canceled ? 'Canceled' : 'Done'}.`,\n },\n } as const;\n}\n\nconst BUILT_IN_DEFAULTS: FactoryRulesOverrides = {\n work: {\n intake: { issue: { onEnter: onArrival(invokeIssueInvestigation) } },\n triage: {\n issue: { onEnter: invokeIssueInvestigation },\n linearIssue: { onEnter: investigateTriagedLinearIssue },\n },\n planning: {\n issue: { onEnter: planWorkItem },\n linearIssue: { onEnter: planWorkItem },\n manual: { onEnter: planWorkItem },\n },\n execute: {\n issue: { onEnter: buildWorkItem },\n linearIssue: { onEnter: buildWorkItem },\n manual: { onEnter: buildWorkItem },\n },\n done: {\n issue: { onEnter: completeIssue },\n },\n },\n review: {\n intake: { pullRequest: { onEnter: onArrival(reviewPullRequest) } },\n review: { pullRequest: { onEnter: reviewPullRequest } },\n },\n tools: { submit_plan: { onResult: advanceApprovedPlan } },\n github: {\n issueOpened: { onEvent: issueOpened },\n issueEdited: { onEvent: retriageGithubIssue },\n issueClosed: { onEvent: issueClosed },\n issueCommentCreated: { onEvent: retriageGithubIssue },\n issueCommentEdited: { onEvent: retriageGithubIssue },\n issueCommentDeleted: { onEvent: retriageGithubIssue },\n pullRequestOpened: { onEvent: pullRequestOpened },\n pullRequestUpdated: { onEvent: reReviewUpdatedPullRequest },\n pullRequestCommentCreated: { onEvent: addressPullRequestComment },\n pullRequestReviewRequested: { onEvent: reReviewRequestedPullRequest },\n pullRequestReviewSubmitted: { onEvent: addressReviewFeedback },\n pullRequestMerged: { onEvent: pullRequestMerged },\n pullRequestClosed: { onEvent: pullRequestClosed },\n },\n linear: { issueObserved: { onEvent: linearIssueObserved }, issueClosed: { onEvent: linearIssueClosed } },\n};\n\nfunction mergeBoardRules(\n base: FactoryBoardRules | undefined,\n overrides: FactoryBoardRules | undefined,\n): FactoryBoardRules {\n const result: FactoryBoardRules = {};\n const stages = new Set([...Object.keys(base ?? {}), ...Object.keys(overrides ?? {})]) as Set<FactoryRuleStage>;\n for (const stage of stages) {\n const baseSources = base?.[stage];\n const overrideSources = overrides?.[stage];\n const sources = new Set([\n ...Object.keys(baseSources ?? {}),\n ...Object.keys(overrideSources ?? {}),\n ]) as Set<FactoryRuleSource>;\n const mergedSources: Partial<Record<FactoryRuleSource, FactoryBoardRuleLeaf>> = {};\n for (const source of sources) {\n const baseLeaf = baseSources?.[source];\n const overrideLeaf = overrideSources?.[source];\n mergedSources[source] = {\n ...(baseLeaf && 'onEnter' in baseLeaf ? { onEnter: baseLeaf.onEnter } : {}),\n ...(baseLeaf && 'onExit' in baseLeaf ? { onExit: baseLeaf.onExit } : {}),\n ...(overrideLeaf && 'onEnter' in overrideLeaf ? { onEnter: overrideLeaf.onEnter } : {}),\n ...(overrideLeaf && 'onExit' in overrideLeaf ? { onExit: overrideLeaf.onExit } : {}),\n };\n }\n result[stage] = mergedSources;\n }\n return result;\n}\n\nfunction mergeToolRules(\n base: Record<string, FactoryToolRuleLeaf> | undefined,\n overrides: Record<string, FactoryToolRuleLeaf> | undefined,\n): Record<string, FactoryToolRuleLeaf> {\n const result: Record<string, FactoryToolRuleLeaf> = {};\n for (const name of new Set([...Object.keys(base ?? {}), ...Object.keys(overrides ?? {})])) {\n const baseLeaf = base?.[name];\n const overrideLeaf = overrides?.[name];\n result[name] = {\n ...(baseLeaf && 'onResult' in baseLeaf ? { onResult: baseLeaf.onResult } : {}),\n ...(overrideLeaf && 'onResult' in overrideLeaf ? { onResult: overrideLeaf.onResult } : {}),\n };\n }\n return result;\n}\n\nfunction mergeGithubRules(\n base: FactoryRulesOverrides['github'],\n overrides: FactoryRulesOverrides['github'],\n): NonNullable<FactoryRulesOverrides['github']> {\n const result: Partial<Record<FactoryGithubEventName, FactoryGithubRuleLeaf>> = {};\n const events = new Set([...Object.keys(base ?? {}), ...Object.keys(overrides ?? {})]) as Set<FactoryGithubEventName>;\n for (const event of events) {\n const baseLeaf = base?.[event];\n const overrideLeaf = overrides?.[event];\n result[event] = {\n ...(baseLeaf && 'onEvent' in baseLeaf ? { onEvent: baseLeaf.onEvent } : {}),\n ...(overrideLeaf && 'onEvent' in overrideLeaf ? { onEvent: overrideLeaf.onEvent } : {}),\n };\n }\n return result;\n}\n\nfunction mergeLinearRules(\n base: FactoryRulesOverrides['linear'],\n overrides: FactoryRulesOverrides['linear'],\n): NonNullable<FactoryRulesOverrides['linear']> {\n const result: Partial<Record<FactoryLinearEventName, FactoryLinearRuleLeaf>> = {};\n const events = new Set([...Object.keys(base ?? {}), ...Object.keys(overrides ?? {})]) as Set<FactoryLinearEventName>;\n for (const event of events) {\n const baseLeaf = base?.[event];\n const overrideLeaf = overrides?.[event];\n result[event] = {\n ...(baseLeaf && 'onEvent' in baseLeaf ? { onEvent: baseLeaf.onEvent } : {}),\n ...(overrideLeaf && 'onEvent' in overrideLeaf ? { onEvent: overrideLeaf.onEvent } : {}),\n };\n }\n return result;\n}\n\nexport function mergeFactoryRuleOverrides(\n base: FactoryRulesOverrides,\n overrides: FactoryRulesOverrides = {},\n): Omit<FactoryRules, 'version'> {\n return {\n work: mergeBoardRules(base.work, overrides.work),\n review: mergeBoardRules(base.review, overrides.review),\n tools: mergeToolRules(base.tools, overrides.tools),\n github: mergeGithubRules(base.github, overrides.github),\n linear: mergeLinearRules(base.linear, overrides.linear),\n };\n}\n\nexport function defaultFactoryRules(input: { version: string; overrides?: FactoryRulesOverrides }): FactoryRules {\n if (typeof input?.version !== 'string' || input.version.trim().length === 0) {\n throw new FactoryRuleValidationError('Factory rule version is required.');\n }\n\n const rules: FactoryRules = {\n version: input.version.trim(),\n ...mergeFactoryRuleOverrides(BUILT_IN_DEFAULTS, input.overrides),\n };\n assertFactoryRules(rules);\n return rules;\n}\n\nexport function builtInFactoryRules(): FactoryRules {\n return defaultFactoryRules({ version: DEFAULT_FACTORY_RULE_VERSION });\n}\n"],"mappings":";;AAmBA,MAAa,+BAA+B;AAE5C,SAAS,mBAAmB,SAA0D;CACpF,OAAO,QAAQ,MAAM,SAAS,YAAY,QAAQ,MAAM;AAC1D;AAEA,SAAS,iBAAiB,SAAqE;CAC7F,OAAO,QAAQ,MAAM,SAAS,WAAW,QAAQ,MAAM,QAAQ,KAAA;AACjE;AAEA,SAAS,yBAAyB,SAAkC;CAClE,OAAO;EACL,MAAM;EACN,gBAAgB,GAAG,QAAQ,QAAQ,GAAG;EACtC,MAAM;EACN,WAAW;EACX,WAAW,QAAQ,KAAK,MAAM,iBAAiB,QAAQ,KAAK,IAAI,KAAK,QAAQ,KAAK;CACpF;AACF;AAEA,SAAS,oBAAoB,SAAmC;CAC9D,IAAI,CAAC,QAAQ,QAAQ,QAAQ,KAAK,WAAW,kBAAkB,CAAC,QAAQ,KAAK,KAAK;CAClF,IAAI,QAAQ,MAAM,SAAS,YAAY,QAAQ,MAAM,iBAAiB;CAEtE,MAAM,SACJ,QAAQ,UAAU,gBACd,QAAQ,aAAa,SAAS,QAAQ,YAAY,OAChD,gCACA,QAAQ,aAAa,QACnB,uBACA,sBACJ,QAAQ,UAAU,wBAChB,oBACA,QAAQ,UAAU,uBAChB,mBACA;CACV,OAAO;EACL,MAAM;EACN,gBAAgB,GAAG,QAAQ,QAAQ,GAAG;EACtC,MAAM;EACN,WAAW;EACX,WAAW,2BAA2B,QAAQ,KAAK,IAAI,UAAU,OAAO;CAC1E;AACF;A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Q,iBAAiB,KAAK,QAAQ,UAAU,MAAM;EACtD,QAAQ,iBAAiB,KAAK,QAAQ,UAAU,MAAM;CACxD;AACF;AAEA,SAAgB,oBAAoB,OAA6E;CAC/G,IAAI,OAAO,OAAO,YAAY,YAAY,MAAM,QAAQ,KAAK,CAAC,CAAC,WAAW,GACxE,MAAM,IAAI,2BAA2B,mCAAmC;CAG1E,MAAM,QAAsB;EAC1B,SAAS,MAAM,QAAQ,KAAK;EAC5B,GAAG,0BAA0B,mBAAmB,MAAM,SAAS;CACjE;CACA,mBAAmB,KAAK;CACxB,OAAO;AACT;AAEA,SAAgB,sBAAoC;CAClD,OAAO,oBAAoB,EAAE,SAAS,6BAA6B,CAAC;AACtE"}
1
+ {"version":3,"file":"defaults.js","names":[],"sources":["../../src/rules/defaults.ts"],"sourcesContent":["import type {\n FactoryRules,\n FactoryRulesOverrides,\n FactoryToolResultRuleContext,\n FactoryToolRuleLeaf,\n} from './types.js';\nimport { assertFactoryRules, FactoryRuleValidationError } from './validation.js';\n\nexport const DEFAULT_FACTORY_RULE_VERSION = 'factory-default-v1';\n\nfunction resultContent(value: unknown): string | undefined {\n if (typeof value === 'string') return value;\n if (!value || typeof value !== 'object' || Array.isArray(value)) return;\n const content = (value as { content?: unknown }).content;\n return typeof content === 'string' ? content : undefined;\n}\n\n// Interactive-session path only: factory-plan never calls submit_plan — it\n// advances planning → execute via factory_transition_work_item directly.\nfunction advanceApprovedPlan(context: FactoryToolResultRuleContext) {\n if (\n context.result.status !== 'success' ||\n context.board !== 'work' ||\n context.item.stages.length !== 1 ||\n context.item.stages[0] !== 'planning' ||\n context.actor.type !== 'agent' ||\n context.actor.role !== 'plan' ||\n !resultContent(context.result.value)?.startsWith('Plan approved.')\n ) {\n return;\n }\n return {\n type: 'transition',\n idempotencyKey: `${context.ingress.id}:approved-plan`,\n board: 'work',\n stage: 'execute',\n } as const;\n}\n\nconst BUILT_IN_DEFAULTS: FactoryRulesOverrides = {\n tools: { submit_plan: { onResult: advanceApprovedPlan } },\n};\n\nfunction mergeToolRules(\n base: Record<string, FactoryToolRuleLeaf> | undefined,\n overrides: Record<string, FactoryToolRuleLeaf> | undefined,\n): Record<string, FactoryToolRuleLeaf> {\n const result: Record<string, FactoryToolRuleLeaf> = {};\n for (const name of new Set([...Object.keys(base ?? {}), ...Object.keys(overrides ?? {})])) {\n const baseLeaf = base?.[name];\n const overrideLeaf = overrides?.[name];\n result[name] = {\n ...(baseLeaf && 'onResult' in baseLeaf ? { onResult: baseLeaf.onResult } : {}),\n ...(overrideLeaf && 'onResult' in overrideLeaf ? { onResult: overrideLeaf.onResult } : {}),\n };\n }\n return result;\n}\n\nexport function mergeFactoryRuleOverrides(\n base: FactoryRulesOverrides,\n overrides: FactoryRulesOverrides = {},\n): Omit<FactoryRules, 'version'> {\n return {\n tools: mergeToolRules(base.tools, overrides.tools),\n };\n}\n\nexport function defaultFactoryRules(input: { version: string; overrides?: FactoryRulesOverrides }): FactoryRules {\n if (typeof input?.version !== 'string' || input.version.trim().length === 0) {\n throw new FactoryRuleValidationError('Factory rule version is required.');\n }\n\n const rules: FactoryRules = {\n version: input.version.trim(),\n ...mergeFactoryRuleOverrides(BUILT_IN_DEFAULTS, input.overrides),\n };\n assertFactoryRules(rules);\n return rules;\n}\n\nexport function builtInFactoryRules(): FactoryRules {\n return defaultFactoryRules({ version: DEFAULT_FACTORY_RULE_VERSION });\n}\n"],"mappings":";;AAQA,MAAa,+BAA+B;AAE5C,SAAS,cAAc,OAAoC;CACzD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG;CACjE,MAAM,UAAW,MAAgC;CACjD,OAAO,OAAO,YAAY,WAAW,UAAU,KAAA;AACjD;AAIA,SAAS,oBAAoB,SAAuC;CAClE,IACE,QAAQ,OAAO,WAAW,aAC1B,QAAQ,UAAU,UAClB,QAAQ,KAAK,OAAO,WAAW,KAC/B,QAAQ,KAAK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herOptions {
35
35
  feedReader?: FactoryFeedReader;
36
36
  resolveLinkedWorkItemParentId?: (input: {
37
37
  orgId: string;
38
+ factoryProjectId: string;
38
39
  decision: Extract<FactoryCommitDecision, {
39
40
  type: 'upsertLinkedWorkItem';
40
41
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/rules/dispatcher.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAyC,MAAM,+BAA+B,CAAC;AAO5G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,KAAK,EACV,6BAA6B,EAI7B,WAAW,EACX,gBAAgB,EACjB,MAAM,uCAAuC,CAAC;AAG/C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,EAAE,qBAAqB,EAA4C,MAAM,YAAY,CAAC;AA4KlG,KAAK,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,EAAE,sBAAsB,CAAC,CAAC;AAGxF,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,6BAA6B,CAAC;IACtC,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gCAAgC;IAC/C,UAAU,EAAE,iBAAiB,CAAC;IAC9B,iBAAiB,EAAE,IAAI,CAAC,wBAAwB,EAAE,YAAY,CAAC,CAAC;IAChE,OAAO,EAAE,gBAAgB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wFAAwF;IACxF,gBAAgB,EAAE,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5F,8FAA8F;IAC9F,g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