@sentry/warden 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/.agents/skills/find-bugs/SKILL.md +75 -0
  2. package/.agents/skills/vercel-react-best-practices/AGENTS.md +2934 -0
  3. package/.agents/skills/vercel-react-best-practices/SKILL.md +136 -0
  4. package/.agents/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
  5. package/.agents/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
  6. package/.agents/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
  7. package/.agents/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
  8. package/.agents/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
  9. package/.agents/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
  10. package/.agents/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
  11. package/.agents/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
  12. package/.agents/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
  13. package/.agents/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
  14. package/.agents/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
  15. package/.agents/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
  16. package/.agents/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
  17. package/.agents/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
  18. package/.agents/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
  19. package/.agents/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
  20. package/.agents/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
  21. package/.agents/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
  22. package/.agents/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
  23. package/.agents/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
  24. package/.agents/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
  25. package/.agents/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
  26. package/.agents/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
  27. package/.agents/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
  28. package/.agents/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
  29. package/.agents/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
  30. package/.agents/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
  31. package/.agents/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
  32. package/.agents/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
  33. package/.agents/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
  34. package/.agents/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
  35. package/.agents/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
  36. package/.agents/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
  37. package/.agents/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
  38. package/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
  39. package/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
  40. package/.agents/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
  41. package/.agents/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
  42. package/.agents/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
  43. package/.agents/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
  44. package/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
  45. package/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
  46. package/.agents/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
  47. package/.agents/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
  48. package/.agents/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
  49. package/.agents/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
  50. package/.agents/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
  51. package/.agents/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
  52. package/.agents/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
  53. package/.agents/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
  54. package/.agents/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
  55. package/.agents/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
  56. package/.agents/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
  57. package/.agents/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
  58. package/.agents/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
  59. package/.agents/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
  60. package/.agents/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
  61. package/.claude/settings.json +57 -0
  62. package/.claude/settings.local.json +88 -0
  63. package/.claude/skills/agent-prompt/SKILL.md +54 -0
  64. package/.claude/skills/agent-prompt/references/agentic-patterns.md +94 -0
  65. package/.claude/skills/agent-prompt/references/anti-patterns.md +140 -0
  66. package/.claude/skills/agent-prompt/references/context-design.md +124 -0
  67. package/.claude/skills/agent-prompt/references/core-principles.md +75 -0
  68. package/.claude/skills/agent-prompt/references/model-guidance.md +118 -0
  69. package/.claude/skills/agent-prompt/references/output-formats.md +98 -0
  70. package/.claude/skills/agent-prompt/references/skill-structure.md +115 -0
  71. package/.claude/skills/agent-prompt/references/system-prompts.md +115 -0
  72. package/.claude/skills/notseer/SKILL.md +131 -0
  73. package/.claude/skills/skill-writer/SKILL.md +140 -0
  74. package/.claude/skills/testing-guidelines/SKILL.md +132 -0
  75. package/.claude/skills/warden-skill/SKILL.md +250 -0
  76. package/.claude/skills/warden-skill/references/config-schema.md +133 -0
  77. package/.dex/config.toml +2 -0
  78. package/.github/workflows/ci.yml +33 -0
  79. package/.github/workflows/release.yml +54 -0
  80. package/.github/workflows/warden.yml +40 -0
  81. package/AGENTS.md +89 -0
  82. package/CONTRIBUTING.md +60 -0
  83. package/LICENSE +105 -0
  84. package/README.md +43 -0
  85. package/SPEC.md +263 -0
  86. package/action.yml +87 -0
  87. package/assets/favicon.png +0 -0
  88. package/assets/warden-icon-bw.svg +5 -0
  89. package/assets/warden-icon-purple.png +0 -0
  90. package/assets/warden-icon-purple.svg +5 -0
  91. package/docs/.claude/settings.local.json +11 -0
  92. package/docs/astro.config.mjs +43 -0
  93. package/docs/package.json +19 -0
  94. package/docs/pnpm-lock.yaml +4000 -0
  95. package/docs/public/favicon.svg +5 -0
  96. package/docs/src/components/Code.astro +141 -0
  97. package/docs/src/components/PackageManagerTabs.astro +183 -0
  98. package/docs/src/components/Terminal.astro +212 -0
  99. package/docs/src/layouts/Base.astro +380 -0
  100. package/docs/src/pages/cli.astro +167 -0
  101. package/docs/src/pages/config.astro +394 -0
  102. package/docs/src/pages/guide.astro +449 -0
  103. package/docs/src/pages/index.astro +490 -0
  104. package/docs/src/styles/global.css +551 -0
  105. package/docs/tsconfig.json +3 -0
  106. package/docs/vercel.json +5 -0
  107. package/eslint.config.js +33 -0
  108. package/package.json +73 -0
  109. package/src/action/index.ts +1 -0
  110. package/src/action/main.ts +868 -0
  111. package/src/cli/args.test.ts +477 -0
  112. package/src/cli/args.ts +415 -0
  113. package/src/cli/commands/add.ts +447 -0
  114. package/src/cli/commands/init.test.ts +136 -0
  115. package/src/cli/commands/init.ts +132 -0
  116. package/src/cli/commands/setup-app/browser.ts +38 -0
  117. package/src/cli/commands/setup-app/credentials.ts +45 -0
  118. package/src/cli/commands/setup-app/manifest.ts +48 -0
  119. package/src/cli/commands/setup-app/server.ts +172 -0
  120. package/src/cli/commands/setup-app.ts +156 -0
  121. package/src/cli/commands/sync.ts +114 -0
  122. package/src/cli/context.ts +131 -0
  123. package/src/cli/files.test.ts +155 -0
  124. package/src/cli/files.ts +89 -0
  125. package/src/cli/fix.test.ts +310 -0
  126. package/src/cli/fix.ts +387 -0
  127. package/src/cli/git.test.ts +119 -0
  128. package/src/cli/git.ts +318 -0
  129. package/src/cli/index.ts +14 -0
  130. package/src/cli/main.ts +672 -0
  131. package/src/cli/output/box.ts +235 -0
  132. package/src/cli/output/formatters.test.ts +187 -0
  133. package/src/cli/output/formatters.ts +269 -0
  134. package/src/cli/output/icons.ts +13 -0
  135. package/src/cli/output/index.ts +44 -0
  136. package/src/cli/output/ink-runner.tsx +337 -0
  137. package/src/cli/output/jsonl.test.ts +347 -0
  138. package/src/cli/output/jsonl.ts +126 -0
  139. package/src/cli/output/reporter.ts +435 -0
  140. package/src/cli/output/tasks.ts +374 -0
  141. package/src/cli/output/tty.test.ts +117 -0
  142. package/src/cli/output/tty.ts +60 -0
  143. package/src/cli/output/verbosity.test.ts +40 -0
  144. package/src/cli/output/verbosity.ts +31 -0
  145. package/src/cli/terminal.test.ts +148 -0
  146. package/src/cli/terminal.ts +301 -0
  147. package/src/config/index.ts +3 -0
  148. package/src/config/loader.test.ts +313 -0
  149. package/src/config/loader.ts +103 -0
  150. package/src/config/schema.ts +168 -0
  151. package/src/config/writer.test.ts +119 -0
  152. package/src/config/writer.ts +84 -0
  153. package/src/diff/classify.test.ts +162 -0
  154. package/src/diff/classify.ts +92 -0
  155. package/src/diff/coalesce.test.ts +208 -0
  156. package/src/diff/coalesce.ts +133 -0
  157. package/src/diff/context.test.ts +226 -0
  158. package/src/diff/context.ts +201 -0
  159. package/src/diff/index.ts +4 -0
  160. package/src/diff/parser.test.ts +212 -0
  161. package/src/diff/parser.ts +149 -0
  162. package/src/event/context.ts +132 -0
  163. package/src/event/index.ts +2 -0
  164. package/src/event/schedule-context.ts +101 -0
  165. package/src/examples/examples.integration.test.ts +66 -0
  166. package/src/examples/index.test.ts +101 -0
  167. package/src/examples/index.ts +122 -0
  168. package/src/examples/setup.ts +25 -0
  169. package/src/index.ts +115 -0
  170. package/src/output/dedup.test.ts +419 -0
  171. package/src/output/dedup.ts +607 -0
  172. package/src/output/github-checks.test.ts +300 -0
  173. package/src/output/github-checks.ts +476 -0
  174. package/src/output/github-issues.ts +329 -0
  175. package/src/output/index.ts +5 -0
  176. package/src/output/issue-renderer.ts +197 -0
  177. package/src/output/renderer.test.ts +727 -0
  178. package/src/output/renderer.ts +217 -0
  179. package/src/output/stale.test.ts +375 -0
  180. package/src/output/stale.ts +155 -0
  181. package/src/output/types.ts +34 -0
  182. package/src/sdk/index.ts +1 -0
  183. package/src/sdk/runner.test.ts +806 -0
  184. package/src/sdk/runner.ts +1232 -0
  185. package/src/skills/index.ts +36 -0
  186. package/src/skills/loader.test.ts +300 -0
  187. package/src/skills/loader.ts +423 -0
  188. package/src/skills/remote.test.ts +704 -0
  189. package/src/skills/remote.ts +604 -0
  190. package/src/triggers/matcher.test.ts +277 -0
  191. package/src/triggers/matcher.ts +152 -0
  192. package/src/types/index.ts +194 -0
  193. package/src/utils/async.ts +18 -0
  194. package/src/utils/index.test.ts +84 -0
  195. package/src/utils/index.ts +50 -0
  196. package/tsconfig.json +25 -0
  197. package/vitest.config.ts +8 -0
  198. package/vitest.integration.config.ts +11 -0
  199. package/warden.toml +19 -0
@@ -0,0 +1,868 @@
1
+ import { readFileSync, appendFileSync } from 'node:fs';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { dirname, join } from 'node:path';
4
+ import { execSync } from 'node:child_process';
5
+ import { Octokit } from '@octokit/rest';
6
+ import { loadWardenConfig, resolveTrigger, type ResolvedTrigger } from '../config/loader.js';
7
+ import type { ScheduleConfig } from '../config/schema.js';
8
+ import { buildEventContext } from '../event/context.js';
9
+ import { buildScheduleEventContext } from '../event/schedule-context.js';
10
+ import { runSkill } from '../sdk/runner.js';
11
+ import { renderSkillReport } from '../output/renderer.js';
12
+ import { createOrUpdateIssue, createFixPR } from '../output/github-issues.js';
13
+ import {
14
+ createCoreCheck,
15
+ updateCoreCheck,
16
+ createSkillCheck,
17
+ updateSkillCheck,
18
+ failSkillCheck,
19
+ determineConclusion,
20
+ aggregateSeverityCounts,
21
+ } from '../output/github-checks.js';
22
+ import { matchTrigger, shouldFail, countFindingsAtOrAbove, countSeverity } from '../triggers/matcher.js';
23
+ import { resolveSkillAsync } from '../skills/loader.js';
24
+ import { filterFindingsBySeverity, SeverityThresholdSchema } from '../types/index.js';
25
+ import {
26
+ fetchExistingComments,
27
+ deduplicateFindings,
28
+ findingToExistingComment,
29
+ processDuplicateActions,
30
+ } from '../output/dedup.js';
31
+ import type { ExistingComment, DeduplicateResult } from '../output/dedup.js';
32
+ import { buildAnalyzedScope, findStaleComments, resolveStaleComments } from '../output/stale.js';
33
+ import type { EventContext, SkillReport, SeverityThreshold, UsageStats } from '../types/index.js';
34
+ import type { RenderResult } from '../output/types.js';
35
+ import { processInBatches, DEFAULT_CONCURRENCY } from '../utils/index.js';
36
+
37
+ /**
38
+ * Error Handling Policy
39
+ * =====================
40
+ *
41
+ * Fatal errors (setFailed - exit immediately):
42
+ * - Missing required inputs (API key, GitHub token, environment variables)
43
+ * - Environment setup failures (not running in GitHub Actions)
44
+ * - Claude Code CLI not found
45
+ * - Event payload parsing failures
46
+ * - Event context building failures
47
+ *
48
+ * Non-fatal errors (log warning + continue):
49
+ * - Individual trigger execution failures (accumulate and report)
50
+ * - GitHub check creation/update failures
51
+ * - Review comment posting failures
52
+ * - Stale comment resolution failures
53
+ *
54
+ * End-of-run failure conditions:
55
+ * - Findings exceed severity threshold (fail-on)
56
+ * - ALL triggers failed (no successful analysis)
57
+ */
58
+
59
+ /**
60
+ * Aggregate usage stats from multiple reports.
61
+ */
62
+ function aggregateUsage(reports: SkillReport[]): UsageStats | undefined {
63
+ const reportsWithUsage = reports.filter((r) => r.usage);
64
+ if (reportsWithUsage.length === 0) return undefined;
65
+
66
+ return {
67
+ inputTokens: reportsWithUsage.reduce((sum, r) => sum + (r.usage?.inputTokens ?? 0), 0),
68
+ outputTokens: reportsWithUsage.reduce((sum, r) => sum + (r.usage?.outputTokens ?? 0), 0),
69
+ cacheReadInputTokens: reportsWithUsage.reduce((sum, r) => sum + (r.usage?.cacheReadInputTokens ?? 0), 0),
70
+ cacheCreationInputTokens: reportsWithUsage.reduce((sum, r) => sum + (r.usage?.cacheCreationInputTokens ?? 0), 0),
71
+ costUSD: reportsWithUsage.reduce((sum, r) => sum + (r.usage?.costUSD ?? 0), 0),
72
+ };
73
+ }
74
+
75
+ interface ActionInputs {
76
+ anthropicApiKey: string;
77
+ githubToken: string;
78
+ configPath: string;
79
+ failOn?: SeverityThreshold;
80
+ commentOn?: SeverityThreshold;
81
+ maxFindings: number;
82
+ /** Max concurrent trigger executions */
83
+ parallel: number;
84
+ }
85
+
86
+ function getInputs(): ActionInputs {
87
+ const getInput = (name: string, required = false): string => {
88
+ // Check both hyphenated (native GitHub Actions) and underscored (composite action) formats
89
+ const hyphenEnv = `INPUT_${name.toUpperCase()}`;
90
+ const underscoreEnv = `INPUT_${name.toUpperCase().replace(/-/g, '_')}`;
91
+ const value = process.env[hyphenEnv] ?? process.env[underscoreEnv] ?? '';
92
+ if (required && !value) {
93
+ throw new Error(`Input required and not supplied: ${name}`);
94
+ }
95
+ return value;
96
+ };
97
+
98
+ // Check for API key: input first, then env vars as fallback
99
+ const anthropicApiKey =
100
+ getInput('anthropic-api-key') ||
101
+ process.env['WARDEN_ANTHROPIC_API_KEY'] ||
102
+ process.env['ANTHROPIC_API_KEY'] ||
103
+ '';
104
+
105
+ if (!anthropicApiKey) {
106
+ throw new Error(
107
+ 'Anthropic API key not found. Provide it via the anthropic-api-key input or set WARDEN_ANTHROPIC_API_KEY environment variable.'
108
+ );
109
+ }
110
+
111
+ const failOnInput = getInput('fail-on');
112
+ const failOn = SeverityThresholdSchema.safeParse(failOnInput).success
113
+ ? (failOnInput as SeverityThreshold)
114
+ : undefined;
115
+
116
+ const commentOnInput = getInput('comment-on');
117
+ const commentOn = SeverityThresholdSchema.safeParse(commentOnInput).success
118
+ ? (commentOnInput as SeverityThreshold)
119
+ : undefined;
120
+
121
+ return {
122
+ anthropicApiKey,
123
+ githubToken: getInput('github-token') || process.env['GITHUB_TOKEN'] || '',
124
+ configPath: getInput('config-path') || 'warden.toml',
125
+ failOn,
126
+ commentOn,
127
+ maxFindings: parseInt(getInput('max-findings') || '50', 10),
128
+ parallel: parseInt(getInput('parallel') || String(DEFAULT_CONCURRENCY), 10),
129
+ };
130
+ }
131
+
132
+ function setOutput(name: string, value: string | number): void {
133
+ const outputFile = process.env['GITHUB_OUTPUT'];
134
+ if (outputFile) {
135
+ const stringValue = String(value);
136
+ // Use heredoc format with random delimiter for multiline values
137
+ // Random delimiter prevents injection if value contains the delimiter
138
+ if (stringValue.includes('\n')) {
139
+ const delimiter = `ghadelim_${randomUUID()}`;
140
+ appendFileSync(outputFile, `${name}<<${delimiter}\n${stringValue}\n${delimiter}\n`);
141
+ } else {
142
+ appendFileSync(outputFile, `${name}=${stringValue}\n`);
143
+ }
144
+ }
145
+ }
146
+
147
+ function setFailed(message: string): never {
148
+ console.error(`::error::${message}`);
149
+ process.exit(1);
150
+ }
151
+
152
+ /**
153
+ * Find the Claude Code CLI executable path.
154
+ * Required in CI environments where the SDK can't auto-detect the CLI location.
155
+ */
156
+ function findClaudeCodeExecutable(): string {
157
+ // Check environment variable first (set by action.yml)
158
+ const envPath = process.env['CLAUDE_CODE_PATH'];
159
+ if (envPath) {
160
+ try {
161
+ execSync(`test -x "${envPath}"`, { encoding: 'utf-8' });
162
+ return envPath;
163
+ } catch {
164
+ // Path from env doesn't exist, continue to fallbacks
165
+ }
166
+ }
167
+
168
+ // Standard install location from claude.ai/install.sh
169
+ const homeLocalBin = `${process.env['HOME']}/.local/bin/claude`;
170
+ try {
171
+ execSync(`test -x "${homeLocalBin}"`, { encoding: 'utf-8' });
172
+ return homeLocalBin;
173
+ } catch {
174
+ // Not found in standard location
175
+ }
176
+
177
+ // Try which command
178
+ try {
179
+ const path = execSync('which claude', { encoding: 'utf-8' }).trim();
180
+ if (path) {
181
+ return path;
182
+ }
183
+ } catch {
184
+ // which command failed
185
+ }
186
+
187
+ // Other common installation paths as fallback
188
+ const commonPaths = ['/usr/local/bin/claude', '/usr/bin/claude'];
189
+
190
+ for (const p of commonPaths) {
191
+ try {
192
+ execSync(`test -x "${p}"`, { encoding: 'utf-8' });
193
+ return p;
194
+ } catch {
195
+ // Path doesn't exist or isn't executable
196
+ }
197
+ }
198
+
199
+ setFailed(
200
+ 'Claude Code CLI not found. Ensure Claude Code is installed via https://claude.ai/install.sh'
201
+ );
202
+ }
203
+
204
+ function logGroup(name: string): void {
205
+ console.log(`::group::${name}`);
206
+ }
207
+
208
+ function logGroupEnd(): void {
209
+ console.log('::endgroup::');
210
+ }
211
+
212
+ /**
213
+ * Log trigger error summary and fail if all triggers failed.
214
+ * Returns true if the action should fail due to all triggers failing.
215
+ */
216
+ function handleTriggerErrors(triggerErrors: string[], totalTriggers: number): void {
217
+ if (triggerErrors.length === 0) {
218
+ return;
219
+ }
220
+
221
+ logGroup('Trigger Errors Summary');
222
+ for (const err of triggerErrors) {
223
+ console.error(` - ${err}`);
224
+ }
225
+ logGroupEnd();
226
+
227
+ // Fail if ALL triggers failed (no successful analysis was performed)
228
+ if (triggerErrors.length === totalTriggers && totalTriggers > 0) {
229
+ setFailed(`All ${totalTriggers} trigger(s) failed: ${triggerErrors.join('; ')}`);
230
+ }
231
+ }
232
+
233
+ async function postReviewToGitHub(
234
+ octokit: Octokit,
235
+ context: EventContext,
236
+ result: RenderResult
237
+ ): Promise<void> {
238
+ if (!context.pullRequest) {
239
+ return;
240
+ }
241
+
242
+ // Only post PR reviews with inline comments - skip standalone summary comments
243
+ // as they add noise without providing actionable inline feedback
244
+ if (!result.review) {
245
+ return;
246
+ }
247
+
248
+ const { owner, name: repo } = context.repository;
249
+ const pullNumber = context.pullRequest.number;
250
+ const commitId = context.pullRequest.headSha;
251
+
252
+ const reviewComments = result.review.comments
253
+ .filter((c): c is typeof c & { path: string; line: number } => Boolean(c.path && c.line))
254
+ .map((c) => ({
255
+ path: c.path,
256
+ line: c.line,
257
+ side: c.side ?? ('RIGHT' as const),
258
+ body: c.body,
259
+ start_line: c.start_line,
260
+ start_side: c.start_line ? c.start_side ?? ('RIGHT' as const) : undefined,
261
+ }));
262
+
263
+ await octokit.pulls.createReview({
264
+ owner,
265
+ repo,
266
+ pull_number: pullNumber,
267
+ commit_id: commitId,
268
+ event: result.review.event,
269
+ body: result.review.body,
270
+ comments: reviewComments,
271
+ });
272
+ }
273
+
274
+ /**
275
+ * Get the default branch for a repository from the GitHub API.
276
+ */
277
+ async function getDefaultBranchFromAPI(
278
+ octokit: Octokit,
279
+ owner: string,
280
+ repo: string
281
+ ): Promise<string> {
282
+ const { data } = await octokit.repos.get({ owner, repo });
283
+ return data.default_branch;
284
+ }
285
+
286
+ /**
287
+ * Handle scheduled analysis events.
288
+ */
289
+ async function runScheduledAnalysis(
290
+ octokit: Octokit,
291
+ inputs: ActionInputs,
292
+ repoPath: string
293
+ ): Promise<void> {
294
+ logGroup('Loading configuration');
295
+ console.log(`Config path: ${inputs.configPath}`);
296
+ logGroupEnd();
297
+
298
+ const configFullPath = join(repoPath, inputs.configPath);
299
+ const config = loadWardenConfig(dirname(configFullPath));
300
+
301
+ // Find schedule triggers
302
+ const scheduleTriggers = config.triggers.filter((t) => t.event === 'schedule');
303
+ if (scheduleTriggers.length === 0) {
304
+ console.log('No schedule triggers configured');
305
+ setOutput('findings-count', 0);
306
+ setOutput('critical-count', 0);
307
+ setOutput('high-count', 0);
308
+ setOutput('summary', 'No schedule triggers configured');
309
+ return;
310
+ }
311
+
312
+ // Get repo info from environment
313
+ const githubRepository = process.env['GITHUB_REPOSITORY'];
314
+ if (!githubRepository) {
315
+ setFailed('GITHUB_REPOSITORY environment variable not set');
316
+ }
317
+ const [owner, repo] = githubRepository.split('/');
318
+ if (!owner || !repo) {
319
+ setFailed('Invalid GITHUB_REPOSITORY format');
320
+ }
321
+
322
+ const headSha = process.env['GITHUB_SHA'] ?? '';
323
+ if (!headSha) {
324
+ setFailed('GITHUB_SHA environment variable not set');
325
+ }
326
+
327
+ const defaultBranch = await getDefaultBranchFromAPI(octokit, owner, repo);
328
+
329
+ logGroup('Processing schedule triggers');
330
+ for (const trigger of scheduleTriggers) {
331
+ console.log(`- ${trigger.name}: ${trigger.skill}`);
332
+ }
333
+ logGroupEnd();
334
+
335
+ const allReports: SkillReport[] = [];
336
+ let totalFindings = 0;
337
+ const failureReasons: string[] = [];
338
+ const triggerErrors: string[] = [];
339
+ let shouldFailAction = false;
340
+
341
+ // Process each schedule trigger
342
+ for (const trigger of scheduleTriggers) {
343
+ const resolved = resolveTrigger(trigger, config);
344
+ logGroup(`Running trigger: ${trigger.name} (skill: ${resolved.skill})`);
345
+
346
+ try {
347
+ // Build context from paths filter
348
+ const patterns = resolved.filters?.paths ?? ['**/*'];
349
+ const ignorePatterns = resolved.filters?.ignorePaths;
350
+
351
+ const context = await buildScheduleEventContext({
352
+ patterns,
353
+ ignorePatterns,
354
+ repoPath,
355
+ owner,
356
+ name: repo,
357
+ defaultBranch,
358
+ headSha,
359
+ });
360
+
361
+ // Skip if no matching files
362
+ if (!context.pullRequest?.files.length) {
363
+ console.log(`No files match trigger ${trigger.name}`);
364
+ logGroupEnd();
365
+ continue;
366
+ }
367
+
368
+ console.log(`Found ${context.pullRequest.files.length} files matching patterns`);
369
+
370
+ // Run skill
371
+ const skill = await resolveSkillAsync(resolved.skill, repoPath, {
372
+ remote: resolved.remote,
373
+ });
374
+ const claudePath = findClaudeCodeExecutable();
375
+ const report = await runSkill(skill, context, {
376
+ apiKey: inputs.anthropicApiKey,
377
+ model: resolved.model,
378
+ maxTurns: trigger.maxTurns ?? config.defaults?.maxTurns,
379
+ batchDelayMs: config.defaults?.batchDelayMs,
380
+ pathToClaudeCodeExecutable: claudePath,
381
+ });
382
+ console.log(`Found ${report.findings.length} findings`);
383
+
384
+ allReports.push(report);
385
+ totalFindings += report.findings.length;
386
+
387
+ // Create/update issue with findings
388
+ const scheduleConfig: Partial<ScheduleConfig> = trigger.schedule ?? {};
389
+ const issueTitle = scheduleConfig.issueTitle ?? `Warden: ${trigger.name}`;
390
+
391
+ const issueResult = await createOrUpdateIssue(octokit, owner, repo, [report], {
392
+ title: issueTitle,
393
+ commitSha: headSha,
394
+ });
395
+
396
+ if (issueResult) {
397
+ console.log(`${issueResult.created ? 'Created' : 'Updated'} issue #${issueResult.issueNumber}`);
398
+ console.log(`Issue URL: ${issueResult.issueUrl}`);
399
+ }
400
+
401
+ // Create fix PR if enabled and there are fixable findings
402
+ if (scheduleConfig.createFixPR) {
403
+ const fixResult = await createFixPR(octokit, owner, repo, report.findings, {
404
+ branchPrefix: scheduleConfig.fixBranchPrefix ?? 'warden-fix',
405
+ baseBranch: defaultBranch,
406
+ baseSha: headSha,
407
+ repoPath,
408
+ triggerName: trigger.name,
409
+ });
410
+
411
+ if (fixResult) {
412
+ console.log(`Created fix PR #${fixResult.prNumber} with ${fixResult.fixCount} fixes`);
413
+ console.log(`PR URL: ${fixResult.prUrl}`);
414
+ }
415
+ }
416
+
417
+ // Check failure condition
418
+ const failOn = resolved.output?.failOn ?? inputs.failOn;
419
+ if (failOn && shouldFail(report, failOn)) {
420
+ shouldFailAction = true;
421
+ const count = countFindingsAtOrAbove(report, failOn);
422
+ failureReasons.push(`${trigger.name}: Found ${count} ${failOn}+ severity issues`);
423
+ }
424
+
425
+ logGroupEnd();
426
+ } catch (error) {
427
+ const errorMessage = error instanceof Error ? error.message : String(error);
428
+ triggerErrors.push(`${trigger.name}: ${errorMessage}`);
429
+ console.error(`::warning::Trigger ${trigger.name} failed: ${error}`);
430
+ logGroupEnd();
431
+ }
432
+ }
433
+
434
+ handleTriggerErrors(triggerErrors, scheduleTriggers.length);
435
+
436
+ // Set outputs
437
+ const criticalCount = countSeverity(allReports, 'critical');
438
+ const highCount = countSeverity(allReports, 'high');
439
+
440
+ setOutput('findings-count', totalFindings);
441
+ setOutput('critical-count', criticalCount);
442
+ setOutput('high-count', highCount);
443
+ setOutput('summary', allReports.map((r) => r.summary).join('\n') || 'Scheduled analysis complete');
444
+
445
+ if (shouldFailAction) {
446
+ setFailed(failureReasons.join('; '));
447
+ }
448
+
449
+ console.log(`\nScheduled analysis complete: ${totalFindings} total findings`);
450
+ }
451
+
452
+ async function run(): Promise<void> {
453
+ const inputs = getInputs();
454
+
455
+ if (!inputs.githubToken) {
456
+ setFailed('GitHub token is required');
457
+ }
458
+
459
+ const eventName = process.env['GITHUB_EVENT_NAME'];
460
+ const eventPath = process.env['GITHUB_EVENT_PATH'];
461
+ const repoPath = process.env['GITHUB_WORKSPACE'];
462
+
463
+ if (!eventName || !eventPath || !repoPath) {
464
+ setFailed('This action must be run in a GitHub Actions environment');
465
+ }
466
+
467
+ // Set both env vars so code using either will work
468
+ process.env['WARDEN_ANTHROPIC_API_KEY'] = inputs.anthropicApiKey;
469
+ process.env['ANTHROPIC_API_KEY'] = inputs.anthropicApiKey;
470
+
471
+ const octokit = new Octokit({ auth: inputs.githubToken });
472
+
473
+ // Route schedule events to dedicated handler
474
+ if (eventName === 'schedule' || eventName === 'workflow_dispatch') {
475
+ return runScheduledAnalysis(octokit, inputs, repoPath);
476
+ }
477
+
478
+ let eventPayload: unknown;
479
+ try {
480
+ eventPayload = JSON.parse(readFileSync(eventPath, 'utf-8'));
481
+ } catch (error) {
482
+ setFailed(`Failed to read event payload: ${error}`);
483
+ }
484
+
485
+ logGroup('Building event context');
486
+ console.log(`Event: ${eventName}`);
487
+ console.log(`Workspace: ${repoPath}`);
488
+ logGroupEnd();
489
+
490
+ let context: EventContext;
491
+ try {
492
+ context = await buildEventContext(eventName, eventPayload, repoPath, octokit);
493
+ } catch (error) {
494
+ setFailed(`Failed to build event context: ${error}`);
495
+ }
496
+
497
+ logGroup('Loading configuration');
498
+ console.log(`Config path: ${inputs.configPath}`);
499
+ logGroupEnd();
500
+
501
+ const configFullPath = join(repoPath, inputs.configPath);
502
+ const config = loadWardenConfig(dirname(configFullPath));
503
+
504
+ // Resolve triggers with defaults and match
505
+ const resolvedTriggers = config.triggers.map((t) => resolveTrigger(t, config));
506
+ const matchedTriggers = resolvedTriggers.filter((t) => matchTrigger(t, context));
507
+
508
+ if (matchedTriggers.length === 0) {
509
+ console.log('No triggers matched for this event');
510
+ setOutput('findings-count', 0);
511
+ setOutput('critical-count', 0);
512
+ setOutput('high-count', 0);
513
+ setOutput('summary', 'No triggers matched');
514
+ return;
515
+ }
516
+
517
+ logGroup('Matched triggers');
518
+ for (const trigger of matchedTriggers) {
519
+ console.log(`- ${trigger.name}: ${trigger.skill}`);
520
+ }
521
+ logGroupEnd();
522
+
523
+ // Create core warden check (only for PRs)
524
+ let coreCheckId: number | undefined;
525
+ if (context.pullRequest) {
526
+ try {
527
+ const coreCheck = await createCoreCheck(octokit, {
528
+ owner: context.repository.owner,
529
+ repo: context.repository.name,
530
+ headSha: context.pullRequest.headSha,
531
+ });
532
+ coreCheckId = coreCheck.checkRunId;
533
+ console.log(`Created core check: ${coreCheck.url}`);
534
+ } catch (error) {
535
+ console.error(`::warning::Failed to create core check: ${error}`);
536
+ }
537
+ }
538
+
539
+ // Run triggers in parallel
540
+ const concurrency = config.runner?.concurrency ?? inputs.parallel;
541
+ const failureReasons: string[] = [];
542
+
543
+ interface TriggerResult {
544
+ triggerName: string;
545
+ report?: SkillReport;
546
+ renderResult?: RenderResult;
547
+ failOn?: typeof inputs.failOn;
548
+ commentOn?: typeof inputs.commentOn;
549
+ commentOnSuccess?: boolean;
550
+ checkRunUrl?: string;
551
+ maxFindings?: number;
552
+ error?: unknown;
553
+ }
554
+
555
+ const runSingleTrigger = async (trigger: ResolvedTrigger): Promise<TriggerResult> => {
556
+ logGroup(`Running trigger: ${trigger.name} (skill: ${trigger.skill})`);
557
+
558
+ // Create skill check (only for PRs)
559
+ let skillCheckId: number | undefined;
560
+ let skillCheckUrl: string | undefined;
561
+ if (context.pullRequest) {
562
+ try {
563
+ const skillCheck = await createSkillCheck(octokit, trigger.skill, {
564
+ owner: context.repository.owner,
565
+ repo: context.repository.name,
566
+ headSha: context.pullRequest.headSha,
567
+ });
568
+ skillCheckId = skillCheck.checkRunId;
569
+ skillCheckUrl = skillCheck.url;
570
+ } catch (error) {
571
+ console.error(`::warning::Failed to create skill check for ${trigger.skill}: ${error}`);
572
+ }
573
+ }
574
+
575
+ const failOn = trigger.output.failOn ?? inputs.failOn;
576
+ const commentOn = trigger.output.commentOn ?? inputs.commentOn;
577
+
578
+ try {
579
+ const skill = await resolveSkillAsync(trigger.skill, repoPath, {
580
+ remote: trigger.remote,
581
+ });
582
+ const claudePath = findClaudeCodeExecutable();
583
+ const report = await runSkill(skill, context, {
584
+ apiKey: inputs.anthropicApiKey,
585
+ model: trigger.model,
586
+ maxTurns: trigger.maxTurns ?? config.defaults?.maxTurns,
587
+ batchDelayMs: config.defaults?.batchDelayMs,
588
+ pathToClaudeCodeExecutable: claudePath,
589
+ });
590
+ console.log(`Found ${report.findings.length} findings`);
591
+
592
+ // Update skill check with results
593
+ if (skillCheckId && context.pullRequest) {
594
+ try {
595
+ await updateSkillCheck(octokit, skillCheckId, report, {
596
+ owner: context.repository.owner,
597
+ repo: context.repository.name,
598
+ headSha: context.pullRequest.headSha,
599
+ failOn,
600
+ commentOn,
601
+ });
602
+ } catch (error) {
603
+ console.error(`::warning::Failed to update skill check for ${trigger.skill}: ${error}`);
604
+ }
605
+ }
606
+
607
+ // Only render if we're going to post comments
608
+ const renderResult =
609
+ commentOn !== 'off'
610
+ ? renderSkillReport(report, {
611
+ maxFindings: trigger.output.maxFindings ?? inputs.maxFindings,
612
+ commentOn,
613
+ checkRunUrl: skillCheckUrl,
614
+ totalFindings: report.findings.length,
615
+ })
616
+ : undefined;
617
+
618
+ logGroupEnd();
619
+ return {
620
+ triggerName: trigger.name,
621
+ report,
622
+ renderResult,
623
+ failOn,
624
+ commentOn,
625
+ commentOnSuccess: trigger.output.commentOnSuccess,
626
+ checkRunUrl: skillCheckUrl,
627
+ maxFindings: trigger.output.maxFindings ?? inputs.maxFindings,
628
+ };
629
+ } catch (error) {
630
+ // Mark skill check as failed
631
+ if (skillCheckId && context.pullRequest) {
632
+ try {
633
+ await failSkillCheck(octokit, skillCheckId, error, {
634
+ owner: context.repository.owner,
635
+ repo: context.repository.name,
636
+ headSha: context.pullRequest.headSha,
637
+ });
638
+ } catch (checkError) {
639
+ console.error(`::warning::Failed to mark skill check as failed: ${checkError}`);
640
+ }
641
+ }
642
+
643
+ console.error(`::warning::Trigger ${trigger.name} failed: ${error}`);
644
+ logGroupEnd();
645
+ return { triggerName: trigger.name, error };
646
+ }
647
+ };
648
+
649
+ const results = await processInBatches(matchedTriggers, runSingleTrigger, concurrency);
650
+
651
+ // Fetch existing comments for deduplication (only for PRs)
652
+ // Keep original list separate for stale detection (modified list includes newly posted comments)
653
+ let fetchedComments: ExistingComment[] = [];
654
+ let existingComments: ExistingComment[] = [];
655
+ if (context.pullRequest) {
656
+ try {
657
+ fetchedComments = await fetchExistingComments(
658
+ octokit,
659
+ context.repository.owner,
660
+ context.repository.name,
661
+ context.pullRequest.number
662
+ );
663
+ existingComments = [...fetchedComments];
664
+ if (fetchedComments.length > 0) {
665
+ const wardenCount = fetchedComments.filter((c) => c.isWarden).length;
666
+ const externalCount = fetchedComments.length - wardenCount;
667
+ console.log(
668
+ `Found ${fetchedComments.length} existing comments for deduplication (${wardenCount} Warden, ${externalCount} external)`
669
+ );
670
+ }
671
+ } catch (error) {
672
+ console.warn(`::warning::Failed to fetch existing comments for deduplication: ${error}`);
673
+ }
674
+ }
675
+
676
+ // Post reviews to GitHub (sequentially to avoid rate limits)
677
+ const reports: SkillReport[] = [];
678
+ let shouldFailAction = false;
679
+
680
+ for (const result of results) {
681
+ if (result.report) {
682
+ reports.push(result.report);
683
+
684
+ // Post review to GitHub (renderResult is undefined when commentOn is 'off')
685
+ // Only post if there are findings (after commentOn filtering) OR commentOnSuccess is true
686
+ const filteredFindings = filterFindingsBySeverity(result.report.findings, result.commentOn);
687
+ const commentOnSuccess = result.commentOnSuccess ?? false;
688
+
689
+ if (result.renderResult && (filteredFindings.length > 0 || commentOnSuccess)) {
690
+ try {
691
+ // Deduplicate findings against existing comments
692
+ let findingsToPost = filteredFindings;
693
+ let dedupResult: DeduplicateResult | undefined;
694
+
695
+ if (existingComments.length > 0 && filteredFindings.length > 0) {
696
+ dedupResult = await deduplicateFindings(filteredFindings, existingComments, {
697
+ apiKey: inputs.anthropicApiKey,
698
+ currentSkill: result.report.skill,
699
+ });
700
+ findingsToPost = dedupResult.newFindings;
701
+
702
+ if (dedupResult.duplicateActions.length > 0) {
703
+ console.log(
704
+ `Found ${dedupResult.duplicateActions.length} duplicate findings for ${result.triggerName}`
705
+ );
706
+ }
707
+ }
708
+
709
+ // Process duplicate actions (update Warden comments, add reactions)
710
+ if (dedupResult && dedupResult.duplicateActions.length > 0) {
711
+ const actionCounts = await processDuplicateActions(
712
+ octokit,
713
+ context.repository.owner,
714
+ context.repository.name,
715
+ dedupResult.duplicateActions,
716
+ result.report.skill
717
+ );
718
+
719
+ if (actionCounts.updated > 0) {
720
+ console.log(`Updated ${actionCounts.updated} existing Warden comments with skill attribution`);
721
+ }
722
+ if (actionCounts.reacted > 0) {
723
+ console.log(`Added reactions to ${actionCounts.reacted} existing external comments`);
724
+ }
725
+ if (actionCounts.failed > 0) {
726
+ console.warn(`::warning::Failed to process ${actionCounts.failed} duplicate actions`);
727
+ }
728
+ }
729
+
730
+ // Only post if we have non-duplicate findings or commentOnSuccess is true
731
+ if (findingsToPost.length > 0 || commentOnSuccess) {
732
+ // Re-render with deduplicated findings if any were removed
733
+ const renderResultToPost =
734
+ findingsToPost.length !== filteredFindings.length
735
+ ? renderSkillReport(
736
+ { ...result.report, findings: findingsToPost },
737
+ {
738
+ maxFindings: result.maxFindings,
739
+ commentOn: result.commentOn,
740
+ checkRunUrl: result.checkRunUrl,
741
+ totalFindings: result.report.findings.length,
742
+ }
743
+ )
744
+ : result.renderResult;
745
+
746
+ await postReviewToGitHub(octokit, context, renderResultToPost);
747
+
748
+ // Add newly posted findings to existing comments for cross-trigger deduplication
749
+ // Only include findings up to maxFindings since that's what was actually posted
750
+ const postedFindings = result.maxFindings
751
+ ? findingsToPost.slice(0, result.maxFindings)
752
+ : findingsToPost;
753
+ for (const finding of postedFindings) {
754
+ const comment = findingToExistingComment(finding, result.report.skill);
755
+ if (comment) {
756
+ existingComments.push(comment);
757
+ }
758
+ }
759
+ }
760
+ } catch (error) {
761
+ console.error(`::warning::Failed to post review for ${result.triggerName}: ${error}`);
762
+ }
763
+ }
764
+
765
+ // Check if we should fail based on this trigger's config
766
+ if (result.failOn && shouldFail(result.report, result.failOn)) {
767
+ shouldFailAction = true;
768
+ const count = countFindingsAtOrAbove(result.report, result.failOn);
769
+ failureReasons.push(`${result.triggerName}: Found ${count} ${result.failOn}+ severity issues`);
770
+ }
771
+ }
772
+ }
773
+
774
+ // Collect trigger errors for summary
775
+ const triggerErrors = results
776
+ .filter((r) => r.error)
777
+ .map((r) => {
778
+ const errorMessage = r.error instanceof Error ? r.error.message : String(r.error);
779
+ return `${r.triggerName}: ${errorMessage}`;
780
+ });
781
+
782
+ handleTriggerErrors(triggerErrors, matchedTriggers.length);
783
+
784
+ // Resolve stale Warden comments (comments that no longer have matching findings)
785
+ // Use fetchedComments (not existingComments) to only check comments that have threadIds
786
+ // Only resolve if ALL triggers succeeded - otherwise findings may be missing due to failures
787
+ // Filter to only Warden comments - we don't resolve external comments
788
+ const allTriggersSucceeded = triggerErrors.length === 0;
789
+ const wardenComments = fetchedComments.filter((c) => c.isWarden);
790
+ if (context.pullRequest && wardenComments.length > 0 && allTriggersSucceeded) {
791
+ try {
792
+ const allFindings = reports.flatMap((r) => r.findings);
793
+ const scope = buildAnalyzedScope(context.pullRequest.files);
794
+ const staleComments = findStaleComments(wardenComments, allFindings, scope);
795
+
796
+ if (staleComments.length > 0) {
797
+ const resolvedCount = await resolveStaleComments(octokit, staleComments);
798
+ if (resolvedCount > 0) {
799
+ console.log(`Resolved ${resolvedCount} stale Warden comments`);
800
+ }
801
+ }
802
+ } catch (error) {
803
+ console.warn(`::warning::Failed to resolve stale comments: ${error}`);
804
+ }
805
+ } else if (!allTriggersSucceeded && wardenComments.length > 0) {
806
+ console.log('Skipping stale comment resolution due to trigger failures');
807
+ }
808
+
809
+ const totalFindings = reports.reduce((sum, r) => sum + r.findings.length, 0);
810
+ const criticalCount = countSeverity(reports, 'critical');
811
+ const highCount = countSeverity(reports, 'high');
812
+
813
+ setOutput('findings-count', totalFindings);
814
+ setOutput('critical-count', criticalCount);
815
+ setOutput('high-count', highCount);
816
+ setOutput('summary', reports.map((r) => r.summary).join('\n'));
817
+
818
+ // Update core check with overall summary
819
+ if (coreCheckId && context.pullRequest) {
820
+ try {
821
+ const summaryData = {
822
+ totalSkills: matchedTriggers.length,
823
+ totalFindings,
824
+ findingsBySeverity: aggregateSeverityCounts(reports),
825
+ totalDurationMs: reports.some((r) => r.durationMs !== undefined)
826
+ ? reports.reduce((sum, r) => sum + (r.durationMs ?? 0), 0)
827
+ : undefined,
828
+ totalUsage: aggregateUsage(reports),
829
+ findings: reports.flatMap((r) => r.findings),
830
+ skillResults: results.map((r) => ({
831
+ name: r.triggerName,
832
+ findingCount: r.report?.findings.length ?? 0,
833
+ conclusion: r.report
834
+ ? determineConclusion(r.report.findings, r.failOn)
835
+ : ('failure' as const),
836
+ durationMs: r.report?.durationMs,
837
+ usage: r.report?.usage,
838
+ })),
839
+ };
840
+
841
+ let coreConclusion: 'success' | 'failure' | 'neutral';
842
+ if (shouldFailAction) {
843
+ coreConclusion = 'failure';
844
+ } else if (totalFindings > 0) {
845
+ coreConclusion = 'neutral';
846
+ } else {
847
+ coreConclusion = 'success';
848
+ }
849
+
850
+ await updateCoreCheck(octokit, coreCheckId, summaryData, coreConclusion, {
851
+ owner: context.repository.owner,
852
+ repo: context.repository.name,
853
+ });
854
+ } catch (error) {
855
+ console.error(`::warning::Failed to update core check: ${error}`);
856
+ }
857
+ }
858
+
859
+ if (shouldFailAction) {
860
+ setFailed(failureReasons.join('; '));
861
+ }
862
+
863
+ console.log(`\nAnalysis complete: ${totalFindings} total findings`);
864
+ }
865
+
866
+ run().catch((error) => {
867
+ setFailed(`Unexpected error: ${error}`);
868
+ });