@plune-ai/cairn 0.4.2 → 0.6.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 (262) hide show
  1. package/README.md +55 -261
  2. package/dist/agent/graph.d.ts +41 -0
  3. package/dist/agent/graph.d.ts.map +1 -1
  4. package/dist/agent/graph.js +110 -8
  5. package/dist/agent/graph.js.map +1 -1
  6. package/dist/agent/index.d.ts +34 -0
  7. package/dist/agent/index.d.ts.map +1 -1
  8. package/dist/agent/index.js +238 -54
  9. package/dist/agent/index.js.map +1 -1
  10. package/dist/agent/summary.d.ts +11 -0
  11. package/dist/agent/summary.d.ts.map +1 -1
  12. package/dist/agent/summary.js +10 -0
  13. package/dist/agent/summary.js.map +1 -1
  14. package/dist/analyze/index.d.ts +2 -0
  15. package/dist/analyze/index.d.ts.map +1 -1
  16. package/dist/analyze/index.js +1 -0
  17. package/dist/analyze/index.js.map +1 -1
  18. package/dist/api/adversarial.d.ts +38 -0
  19. package/dist/api/adversarial.d.ts.map +1 -0
  20. package/dist/api/adversarial.js +175 -0
  21. package/dist/api/adversarial.js.map +1 -0
  22. package/dist/api/cases.d.ts +105 -0
  23. package/dist/api/cases.d.ts.map +1 -0
  24. package/dist/api/cases.js +256 -0
  25. package/dist/api/cases.js.map +1 -0
  26. package/dist/api/coverage.d.ts +51 -0
  27. package/dist/api/coverage.d.ts.map +1 -0
  28. package/dist/api/coverage.js +80 -0
  29. package/dist/api/coverage.js.map +1 -0
  30. package/dist/api/openapi.d.ts +84 -0
  31. package/dist/api/openapi.d.ts.map +1 -0
  32. package/dist/api/openapi.js +119 -0
  33. package/dist/api/openapi.js.map +1 -0
  34. package/dist/api/runner.d.ts +58 -0
  35. package/dist/api/runner.d.ts.map +1 -0
  36. package/dist/api/runner.js +285 -0
  37. package/dist/api/runner.js.map +1 -0
  38. package/dist/api/scenario-runner.d.ts +22 -0
  39. package/dist/api/scenario-runner.d.ts.map +1 -0
  40. package/dist/api/scenario-runner.js +132 -0
  41. package/dist/api/scenario-runner.js.map +1 -0
  42. package/dist/api/scenarios.d.ts +31 -0
  43. package/dist/api/scenarios.d.ts.map +1 -0
  44. package/dist/api/scenarios.js +71 -0
  45. package/dist/api/scenarios.js.map +1 -0
  46. package/dist/api/testcase-docs.d.ts +12 -0
  47. package/dist/api/testcase-docs.d.ts.map +1 -0
  48. package/dist/api/testcase-docs.js +22 -0
  49. package/dist/api/testcase-docs.js.map +1 -0
  50. package/dist/artifacts/index.d.ts +23 -0
  51. package/dist/artifacts/index.d.ts.map +1 -1
  52. package/dist/artifacts/index.js +61 -1
  53. package/dist/artifacts/index.js.map +1 -1
  54. package/dist/artifacts/report.d.ts +29 -0
  55. package/dist/artifacts/report.d.ts.map +1 -1
  56. package/dist/artifacts/report.js +96 -0
  57. package/dist/artifacts/report.js.map +1 -1
  58. package/dist/artifacts/testcase-md.d.ts +27 -0
  59. package/dist/artifacts/testcase-md.d.ts.map +1 -1
  60. package/dist/artifacts/testcase-md.js +61 -0
  61. package/dist/artifacts/testcase-md.js.map +1 -1
  62. package/dist/browser/backends/playwright-lib.d.ts +12 -0
  63. package/dist/browser/backends/playwright-lib.d.ts.map +1 -1
  64. package/dist/browser/backends/playwright-lib.js +48 -3
  65. package/dist/browser/backends/playwright-lib.js.map +1 -1
  66. package/dist/browser/recovery.d.ts +42 -0
  67. package/dist/browser/recovery.d.ts.map +1 -0
  68. package/dist/browser/recovery.js +62 -0
  69. package/dist/browser/recovery.js.map +1 -0
  70. package/dist/browser/types.d.ts +7 -0
  71. package/dist/browser/types.d.ts.map +1 -1
  72. package/dist/checklist/index.d.ts +7 -0
  73. package/dist/checklist/index.d.ts.map +1 -1
  74. package/dist/checklist/index.js +14 -0
  75. package/dist/checklist/index.js.map +1 -1
  76. package/dist/ci/github.d.ts +83 -0
  77. package/dist/ci/github.d.ts.map +1 -0
  78. package/dist/ci/github.js +104 -0
  79. package/dist/ci/github.js.map +1 -0
  80. package/dist/ci/index.d.ts +14 -0
  81. package/dist/ci/index.d.ts.map +1 -0
  82. package/dist/ci/index.js +35 -0
  83. package/dist/ci/index.js.map +1 -0
  84. package/dist/ci/inputs.d.ts +93 -0
  85. package/dist/ci/inputs.d.ts.map +1 -0
  86. package/dist/ci/inputs.js +100 -0
  87. package/dist/ci/inputs.js.map +1 -0
  88. package/dist/ci/run.d.ts +51 -0
  89. package/dist/ci/run.d.ts.map +1 -0
  90. package/dist/ci/run.js +207 -0
  91. package/dist/ci/run.js.map +1 -0
  92. package/dist/ci/summary.d.ts +42 -0
  93. package/dist/ci/summary.d.ts.map +1 -0
  94. package/dist/ci/summary.js +45 -0
  95. package/dist/ci/summary.js.map +1 -0
  96. package/dist/cli/index.d.ts.map +1 -1
  97. package/dist/cli/index.js +65 -4
  98. package/dist/cli/index.js.map +1 -1
  99. package/dist/codegen/index.d.ts +13 -1
  100. package/dist/codegen/index.d.ts.map +1 -1
  101. package/dist/codegen/index.js +75 -0
  102. package/dist/codegen/index.js.map +1 -1
  103. package/dist/codegen/journey-setup.d.ts +14 -0
  104. package/dist/codegen/journey-setup.d.ts.map +1 -0
  105. package/dist/codegen/journey-setup.js +69 -0
  106. package/dist/codegen/journey-setup.js.map +1 -0
  107. package/dist/config/index.d.ts.map +1 -1
  108. package/dist/config/index.js +9 -0
  109. package/dist/config/index.js.map +1 -1
  110. package/dist/config/profiles.d.ts +6 -0
  111. package/dist/config/profiles.d.ts.map +1 -1
  112. package/dist/config/profiles.js +13 -0
  113. package/dist/config/profiles.js.map +1 -1
  114. package/dist/config/schema.d.ts +6 -0
  115. package/dist/config/schema.d.ts.map +1 -1
  116. package/dist/core/modalities/api.d.ts +27 -0
  117. package/dist/core/modalities/api.d.ts.map +1 -0
  118. package/dist/core/modalities/api.js +321 -0
  119. package/dist/core/modalities/api.js.map +1 -0
  120. package/dist/core/modalities/explore.d.ts.map +1 -1
  121. package/dist/core/modalities/explore.js +19 -1
  122. package/dist/core/modalities/explore.js.map +1 -1
  123. package/dist/core/registry.d.ts.map +1 -1
  124. package/dist/core/registry.js +4 -1
  125. package/dist/core/registry.js.map +1 -1
  126. package/dist/design/critique.d.ts +86 -0
  127. package/dist/design/critique.d.ts.map +1 -0
  128. package/dist/design/critique.js +62 -0
  129. package/dist/design/critique.js.map +1 -0
  130. package/dist/design/index.d.ts +2 -0
  131. package/dist/design/index.d.ts.map +1 -1
  132. package/dist/design/index.js +1 -0
  133. package/dist/design/index.js.map +1 -1
  134. package/dist/design/schema.d.ts +74 -0
  135. package/dist/design/schema.d.ts.map +1 -1
  136. package/dist/design/schema.js +22 -0
  137. package/dist/design/schema.js.map +1 -1
  138. package/dist/design/style.d.ts +18 -0
  139. package/dist/design/style.d.ts.map +1 -0
  140. package/dist/design/style.js +34 -0
  141. package/dist/design/style.js.map +1 -0
  142. package/dist/documentarian/index.d.ts +53 -0
  143. package/dist/documentarian/index.d.ts.map +1 -0
  144. package/dist/documentarian/index.js +135 -0
  145. package/dist/documentarian/index.js.map +1 -0
  146. package/dist/eval/coverage.d.ts +49 -0
  147. package/dist/eval/coverage.d.ts.map +1 -0
  148. package/dist/eval/coverage.js +60 -0
  149. package/dist/eval/coverage.js.map +1 -0
  150. package/dist/eval/gap-cases.d.ts +21 -0
  151. package/dist/eval/gap-cases.d.ts.map +1 -0
  152. package/dist/eval/gap-cases.js +27 -0
  153. package/dist/eval/gap-cases.js.map +1 -0
  154. package/dist/eval/legend.d.ts +3 -3
  155. package/dist/eval/legend.js +3 -3
  156. package/dist/eval/pilot.d.ts +4 -1
  157. package/dist/eval/pilot.d.ts.map +1 -1
  158. package/dist/eval/pilot.js +9 -2
  159. package/dist/eval/pilot.js.map +1 -1
  160. package/dist/flow/crawl.d.ts +66 -0
  161. package/dist/flow/crawl.d.ts.map +1 -0
  162. package/dist/flow/crawl.js +0 -0
  163. package/dist/flow/crawl.js.map +1 -0
  164. package/dist/flow/journey.d.ts +25 -0
  165. package/dist/flow/journey.d.ts.map +1 -0
  166. package/dist/flow/journey.js +51 -0
  167. package/dist/flow/journey.js.map +1 -0
  168. package/dist/flow/setup.d.ts +85 -0
  169. package/dist/flow/setup.d.ts.map +1 -0
  170. package/dist/flow/setup.js +65 -0
  171. package/dist/flow/setup.js.map +1 -0
  172. package/dist/index.d.ts +2 -1
  173. package/dist/index.d.ts.map +1 -1
  174. package/dist/knowledge/index.d.ts +30 -4
  175. package/dist/knowledge/index.d.ts.map +1 -1
  176. package/dist/knowledge/index.js +80 -22
  177. package/dist/knowledge/index.js.map +1 -1
  178. package/dist/llm/index.d.ts +2 -2
  179. package/dist/llm/index.d.ts.map +1 -1
  180. package/dist/llm/index.js +1 -1
  181. package/dist/llm/index.js.map +1 -1
  182. package/dist/llm/routing.d.ts.map +1 -1
  183. package/dist/llm/routing.js +8 -2
  184. package/dist/llm/routing.js.map +1 -1
  185. package/dist/llm/schema-lint.d.ts +9 -0
  186. package/dist/llm/schema-lint.d.ts.map +1 -0
  187. package/dist/llm/schema-lint.js +42 -0
  188. package/dist/llm/schema-lint.js.map +1 -0
  189. package/dist/llm/structured.d.ts +22 -0
  190. package/dist/llm/structured.d.ts.map +1 -1
  191. package/dist/llm/structured.js +42 -0
  192. package/dist/llm/structured.js.map +1 -1
  193. package/dist/mcp/server.d.ts +9 -0
  194. package/dist/mcp/server.d.ts.map +1 -0
  195. package/dist/mcp/server.js +49 -0
  196. package/dist/mcp/server.js.map +1 -0
  197. package/dist/mcp/tools.d.ts +149 -0
  198. package/dist/mcp/tools.d.ts.map +1 -0
  199. package/dist/mcp/tools.js +138 -0
  200. package/dist/mcp/tools.js.map +1 -0
  201. package/dist/observe/parse-aria.d.ts.map +1 -1
  202. package/dist/observe/parse-aria.js +11 -2
  203. package/dist/observe/parse-aria.js.map +1 -1
  204. package/dist/project/index.d.ts +70 -0
  205. package/dist/project/index.d.ts.map +1 -0
  206. package/dist/project/index.js +173 -0
  207. package/dist/project/index.js.map +1 -0
  208. package/dist/prompts/local/identify-elements.d.ts +1 -1
  209. package/dist/prompts/local/identify-elements.d.ts.map +1 -1
  210. package/dist/prompts/local/identify-elements.js +5 -2
  211. package/dist/prompts/local/identify-elements.js.map +1 -1
  212. package/dist/prompts/local/index.d.ts.map +1 -1
  213. package/dist/prompts/local/index.js +8 -0
  214. package/dist/prompts/local/index.js.map +1 -1
  215. package/dist/prompts/local/pilot-review.d.ts +1 -1
  216. package/dist/prompts/local/pilot-review.d.ts.map +1 -1
  217. package/dist/prompts/local/pilot-review.js +2 -1
  218. package/dist/prompts/local/pilot-review.js.map +1 -1
  219. package/dist/prompts/local/qa-case-critique.d.ts +8 -0
  220. package/dist/prompts/local/qa-case-critique.d.ts.map +1 -0
  221. package/dist/prompts/local/qa-case-critique.js +34 -0
  222. package/dist/prompts/local/qa-case-critique.js.map +1 -0
  223. package/dist/prompts/local/qa-gap-cases.d.ts +7 -0
  224. package/dist/prompts/local/qa-gap-cases.d.ts.map +1 -0
  225. package/dist/prompts/local/qa-gap-cases.js +22 -0
  226. package/dist/prompts/local/qa-gap-cases.js.map +1 -0
  227. package/dist/prompts/local/qa-journey-from-flow.d.ts +7 -0
  228. package/dist/prompts/local/qa-journey-from-flow.d.ts.map +1 -0
  229. package/dist/prompts/local/qa-journey-from-flow.js +29 -0
  230. package/dist/prompts/local/qa-journey-from-flow.js.map +1 -0
  231. package/dist/prompts/local/qa-setup-planner.d.ts +6 -0
  232. package/dist/prompts/local/qa-setup-planner.d.ts.map +1 -0
  233. package/dist/prompts/local/qa-setup-planner.js +28 -0
  234. package/dist/prompts/local/qa-setup-planner.js.map +1 -0
  235. package/dist/prompts/local/qa-testcase-from-ui.d.ts +1 -1
  236. package/dist/prompts/local/qa-testcase-from-ui.d.ts.map +1 -1
  237. package/dist/prompts/local/qa-testcase-from-ui.js +2 -0
  238. package/dist/prompts/local/qa-testcase-from-ui.js.map +1 -1
  239. package/dist/safety/guardrails.d.ts +36 -0
  240. package/dist/safety/guardrails.d.ts.map +1 -0
  241. package/dist/safety/guardrails.js +60 -0
  242. package/dist/safety/guardrails.js.map +1 -0
  243. package/dist/tui/hooks/use-runs.d.ts.map +1 -1
  244. package/dist/tui/hooks/use-runs.js +4 -1
  245. package/dist/tui/hooks/use-runs.js.map +1 -1
  246. package/dist/tui/screens/runs-list-screen.d.ts.map +1 -1
  247. package/dist/tui/screens/runs-list-screen.js +3 -1
  248. package/dist/tui/screens/runs-list-screen.js.map +1 -1
  249. package/dist/tui/screens/summary-screen.d.ts.map +1 -1
  250. package/dist/tui/screens/summary-screen.js +1 -1
  251. package/dist/tui/screens/summary-screen.js.map +1 -1
  252. package/dist/tui/types.d.ts +7 -1
  253. package/dist/tui/types.d.ts.map +1 -1
  254. package/dist/validate/index.d.ts +7 -3
  255. package/dist/validate/index.d.ts.map +1 -1
  256. package/dist/validate/index.js +22 -3
  257. package/dist/validate/index.js.map +1 -1
  258. package/dist/validate/runner.d.ts +61 -1
  259. package/dist/validate/runner.d.ts.map +1 -1
  260. package/dist/validate/runner.js +67 -4
  261. package/dist/validate/runner.js.map +1 -1
  262. package/package.json +5 -1
@@ -0,0 +1,93 @@
1
+ /**
2
+ * INT-02 (#50) — CI / PR bot input layer.
3
+ *
4
+ * Parse + validate the GitHub Action's `inputs:` from the environment. GitHub passes each declared
5
+ * input as an `INPUT_<NAME>` env var (name upper-cased, spaces → `_`) — exactly what `@actions/core`
6
+ * reads — so this module needs no Actions toolkit dependency and stays trivially unit-testable by
7
+ * handing it a plain env record.
8
+ *
9
+ * Provider keys (ANTHROPIC_API_KEY, OPENROUTER_API_KEY, …) are NOT read here: they flow straight into
10
+ * `process.env` from repo secrets and are consumed by `resolveConfig`/`loadConfig` like everywhere
11
+ * else — never hardcoded, never echoed.
12
+ */
13
+ type Env = Record<string, string | undefined>;
14
+ /** Read one Action input from env, replicating `@actions/core.getInput` name→env mapping. */
15
+ export declare function getInput(env: Env, name: string): string | undefined;
16
+ /** The exploration mode the action drives — `explore` emits code (needed for a follow-up PR). */
17
+ export type CiMode = "explore" | "design";
18
+ /** Validated, normalized inputs for one CI run. Mirrors the `cairn explore`/`design` flag surface. */
19
+ export interface CiInputs {
20
+ url: string;
21
+ mode: CiMode;
22
+ session?: string;
23
+ checklist?: string;
24
+ style?: string;
25
+ routing?: string;
26
+ backend?: string;
27
+ channel?: string;
28
+ /** Write specs into the host project's Playwright `testDir` (#51) instead of greenfield `runs/`. */
29
+ intoProject: boolean;
30
+ projectDir?: string;
31
+ /** Optional glob filter on the PR's changed files — no match → the run is a no-op (changed-surface gate). */
32
+ paths: string[];
33
+ /** Post / update the summary comment on the PR. */
34
+ comment: boolean;
35
+ /** Open a follow-up PR carrying the generated tests (toggle, default off). */
36
+ openPr: boolean;
37
+ /** Branch name for the follow-up PR. */
38
+ prBranch: string;
39
+ /** Commit message for the follow-up PR. */
40
+ commitMessage: string;
41
+ /** Title for the follow-up PR (defaults from the commit message). */
42
+ prTitle: string;
43
+ }
44
+ /**
45
+ * Parse + validate inputs from `env`. Throws a single, clean error on the first problem (missing
46
+ * `url`, bad boolean, bad `mode`) so the action fails fast with an actionable message rather than
47
+ * deep inside the core run.
48
+ */
49
+ export declare function parseInputs(env?: Env): CiInputs;
50
+ /** GitHub-provided run context (repo, PR number, refs) — distinct from user-configured inputs. */
51
+ export interface CiContext {
52
+ /** `owner/repo` from `GITHUB_REPOSITORY`. */
53
+ owner: string;
54
+ repo: string;
55
+ /** PR number from the event payload (undefined when not a pull_request event). */
56
+ prNumber?: number;
57
+ /** Head branch (where a follow-up PR's commit lands / branches from). */
58
+ headRef?: string;
59
+ /** Base branch the PR targets. */
60
+ baseRef?: string;
61
+ /** REST API base (GitHub.com or GHES) — `GITHUB_API_URL`. */
62
+ apiUrl: string;
63
+ /** Auth token from env (`github-token` input → `INPUT_GITHUB-TOKEN`, falling back to `GITHUB_TOKEN`). */
64
+ token?: string;
65
+ /** True when the PR comes from a fork — the token is typically read-only, so write effects are skipped. */
66
+ isFork: boolean;
67
+ }
68
+ /** Minimal shape of the slice of the `pull_request` event payload we consume (for testable injection). */
69
+ export interface PullRequestEvent {
70
+ pull_request?: {
71
+ number?: number;
72
+ head?: {
73
+ ref?: string;
74
+ repo?: {
75
+ full_name?: string;
76
+ } | null;
77
+ };
78
+ base?: {
79
+ ref?: string;
80
+ repo?: {
81
+ full_name?: string;
82
+ } | null;
83
+ };
84
+ };
85
+ number?: number;
86
+ }
87
+ /**
88
+ * Build the run context from env + an already-parsed event payload (injected so tests need no file).
89
+ * `repoFullName` defaults from `GITHUB_REPOSITORY`; fork detection compares head/base repo full names.
90
+ */
91
+ export declare function buildContext(env?: Env, event?: PullRequestEvent): CiContext;
92
+ export {};
93
+ //# sourceMappingURL=inputs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../src/ci/inputs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAE9C,6FAA6F;AAC7F,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMnE;AAqBD,iGAAiG;AACjG,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE1C,sGAAsG;AACtG,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oGAAoG;IACpG,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6GAA6G;IAC7G,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,mDAAmD;IACnD,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AAE,KAAK,GAAE,gBAAqB,GAAG,SAAS,CAoB5F"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * INT-02 (#50) — CI / PR bot input layer.
3
+ *
4
+ * Parse + validate the GitHub Action's `inputs:` from the environment. GitHub passes each declared
5
+ * input as an `INPUT_<NAME>` env var (name upper-cased, spaces → `_`) — exactly what `@actions/core`
6
+ * reads — so this module needs no Actions toolkit dependency and stays trivially unit-testable by
7
+ * handing it a plain env record.
8
+ *
9
+ * Provider keys (ANTHROPIC_API_KEY, OPENROUTER_API_KEY, …) are NOT read here: they flow straight into
10
+ * `process.env` from repo secrets and are consumed by `resolveConfig`/`loadConfig` like everywhere
11
+ * else — never hardcoded, never echoed.
12
+ */
13
+ /** Read one Action input from env, replicating `@actions/core.getInput` name→env mapping. */
14
+ export function getInput(env, name) {
15
+ const key = `INPUT_${name.replace(/ /g, "_").toUpperCase()}`;
16
+ const raw = env[key];
17
+ if (raw === undefined)
18
+ return undefined;
19
+ const trimmed = raw.trim();
20
+ return trimmed === "" ? undefined : trimmed;
21
+ }
22
+ /** Parse a boolean input the way Actions' YAML truthiness works (`true`/`false`, case-insensitive). */
23
+ function getBool(env, name, fallback) {
24
+ const v = getInput(env, name)?.toLowerCase();
25
+ if (v === undefined)
26
+ return fallback;
27
+ if (v === "true")
28
+ return true;
29
+ if (v === "false")
30
+ return false;
31
+ throw new Error(`Input "${name}" must be "true" or "false" (got "${v}").`);
32
+ }
33
+ /** Split a multiline / comma-separated input into trimmed, non-empty entries. */
34
+ function getList(env, name) {
35
+ const raw = getInput(env, name);
36
+ if (!raw)
37
+ return [];
38
+ return raw
39
+ .split(/[\n,]/)
40
+ .map((s) => s.trim())
41
+ .filter(Boolean);
42
+ }
43
+ /**
44
+ * Parse + validate inputs from `env`. Throws a single, clean error on the first problem (missing
45
+ * `url`, bad boolean, bad `mode`) so the action fails fast with an actionable message rather than
46
+ * deep inside the core run.
47
+ */
48
+ export function parseInputs(env = process.env) {
49
+ const url = getInput(env, "url");
50
+ if (!url)
51
+ throw new Error('Required input "url" is missing.');
52
+ const modeRaw = (getInput(env, "mode") ?? "explore").toLowerCase();
53
+ if (modeRaw !== "explore" && modeRaw !== "design") {
54
+ throw new Error(`Input "mode" must be "explore" or "design" (got "${modeRaw}").`);
55
+ }
56
+ const mode = modeRaw;
57
+ const commitMessage = getInput(env, "commit-message") ?? "test: update generated Playwright tests (cairn)";
58
+ return {
59
+ url,
60
+ mode,
61
+ session: getInput(env, "session"),
62
+ checklist: getInput(env, "checklist"),
63
+ style: getInput(env, "style"),
64
+ routing: getInput(env, "routing"),
65
+ backend: getInput(env, "backend"),
66
+ channel: getInput(env, "channel"),
67
+ intoProject: getBool(env, "into-project", true),
68
+ projectDir: getInput(env, "project-dir"),
69
+ paths: getList(env, "paths"),
70
+ comment: getBool(env, "comment", true),
71
+ openPr: getBool(env, "open-pr", false),
72
+ prBranch: getInput(env, "pr-branch") ?? "cairn/update-tests",
73
+ commitMessage,
74
+ prTitle: getInput(env, "pr-title") ?? commitMessage,
75
+ };
76
+ }
77
+ /**
78
+ * Build the run context from env + an already-parsed event payload (injected so tests need no file).
79
+ * `repoFullName` defaults from `GITHUB_REPOSITORY`; fork detection compares head/base repo full names.
80
+ */
81
+ export function buildContext(env = process.env, event = {}) {
82
+ const repoFull = env.GITHUB_REPOSITORY ?? "";
83
+ const [owner = "", repo = ""] = repoFull.split("/");
84
+ const pr = event.pull_request;
85
+ const prNumber = pr?.number ?? event.number;
86
+ const headRepo = pr?.head?.repo?.full_name;
87
+ const baseRepo = pr?.base?.repo?.full_name ?? (repoFull || undefined);
88
+ const isFork = Boolean(headRepo && baseRepo && headRepo !== baseRepo);
89
+ return {
90
+ owner,
91
+ repo,
92
+ prNumber: typeof prNumber === "number" ? prNumber : undefined,
93
+ headRef: pr?.head?.ref ?? env.GITHUB_HEAD_REF,
94
+ baseRef: pr?.base?.ref ?? env.GITHUB_BASE_REF,
95
+ apiUrl: env.GITHUB_API_URL ?? "https://api.github.com",
96
+ token: getInput(env, "github-token") ?? env.GITHUB_TOKEN,
97
+ isFork,
98
+ };
99
+ }
100
+ //# sourceMappingURL=inputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputs.js","sourceRoot":"","sources":["../../src/ci/inputs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,6FAA6F;AAC7F,MAAM,UAAU,QAAQ,CAAC,GAAQ,EAAE,IAAY;IAC7C,MAAM,GAAG,GAAG,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;IAC7D,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACrB,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;AAC9C,CAAC;AAED,uGAAuG;AACvG,SAAS,OAAO,CAAC,GAAQ,EAAE,IAAY,EAAE,QAAiB;IACxD,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC;IAC7C,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IACrC,IAAI,CAAC,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAC9B,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAChC,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,qCAAqC,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AAED,iFAAiF;AACjF,SAAS,OAAO,CAAC,GAAQ,EAAE,IAAY;IACrC,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,OA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AAG,CAAC,eAAe;QAC7C,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,CAAC,eAAe;QAC7C,MAAM,EAAE,GAAG,CAAC,cAAc,IAAI,wBAAwB;QACtD,KAAK,EAAE,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC,IAAI,GAAG,CAAC,YAAY;QACxD,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { resolveConfig } from "../core/config.js";
2
+ import { runExploration, runDesign } from "../agent/index.js";
3
+ import { readInputFile } from "../fs/run-dir.js";
4
+ import { resolveStyleText } from "../design/style.js";
5
+ import type { CiContext, PullRequestEvent } from "./inputs.js";
6
+ import type { GitHubClient } from "./github.js";
7
+ import type { CiSummary } from "./summary.js";
8
+ type Env = Record<string, string | undefined>;
9
+ /** Injected seams — every dep defaults to the real implementation; tests pass mocks. */
10
+ export interface CiDeps {
11
+ resolveConfig: typeof resolveConfig;
12
+ runExploration: typeof runExploration;
13
+ runDesign: typeof runDesign;
14
+ /** Build the GitHub client for a context (default: REST). Skipped entirely when there is no token. */
15
+ makeGitHubClient: (ctx: CiContext) => GitHubClient;
16
+ readInputFile: typeof readInputFile;
17
+ resolveStyleText: typeof resolveStyleText;
18
+ /** Read a generated spec from disk (for the follow-up PR commit). */
19
+ readFile: (absPath: string) => Promise<string>;
20
+ /** Working directory used to relativize spec paths into repo-relative commit paths. */
21
+ cwd: () => string;
22
+ log: (msg: string) => void;
23
+ }
24
+ export declare const defaultDeps: CiDeps;
25
+ export interface CiRunResult {
26
+ /** True when the core run executed (false on a no-op gate). */
27
+ ranCore: boolean;
28
+ summary: CiSummary;
29
+ /** The comment that was posted/updated, when the comment effect ran. */
30
+ comment?: {
31
+ action: "created" | "updated";
32
+ id: number;
33
+ };
34
+ /** The follow-up PR, when the toggle ran it. */
35
+ followupPr?: {
36
+ url: string;
37
+ number: number;
38
+ };
39
+ /** Why a requested effect was skipped (fork / missing token / not a PR) — surfaced, never silent. */
40
+ skippedEffects: string[];
41
+ }
42
+ /** Does any glob match the file path? Empty glob list means "no filter" (always true at the call site). */
43
+ export declare function matchesAnyGlob(file: string, globs: string[]): boolean;
44
+ /**
45
+ * Run the CI / PR bot end to end. Reads inputs + context from `env`/`event` (injected so tests need no
46
+ * files), runs the core, and applies the GitHub effects guarded by toggles + permission reality (fork
47
+ * PRs and missing tokens are read-only — those effects are skipped with a logged reason, never crash).
48
+ */
49
+ export declare function runCi(env?: Env, event?: PullRequestEvent, deps?: CiDeps): Promise<CiRunResult>;
50
+ export {};
51
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/ci/run.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAY,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,aAAa,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAE9C,wFAAwF;AACxF,MAAM,WAAW,MAAM;IACrB,aAAa,EAAE,OAAO,aAAa,CAAC;IACpC,cAAc,EAAE,OAAO,cAAc,CAAC;IACtC,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,sGAAsG;IACtG,gBAAgB,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,YAAY,CAAC;IACnD,aAAa,EAAE,OAAO,aAAa,CAAC;IACpC,gBAAgB,EAAE,OAAO,gBAAgB,CAAC;IAC1C,qEAAqE;IACrE,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,uFAAuF;IACvF,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5B;AAED,eAAO,MAAM,WAAW,EAAE,MAUzB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,+DAA+D;IAC/D,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,SAAS,CAAC;IACnB,wEAAwE;IACxE,OAAO,CAAC,EAAE;QAAE,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,gDAAgD;IAChD,UAAU,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,qGAAqG;IACrG,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAeD,2GAA2G;AAC3G,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAGrE;AAsDD;;;;GAIG;AACH,wBAAsB,KAAK,CACzB,GAAG,GAAE,GAAiB,EACtB,KAAK,GAAE,gBAAqB,EAC5B,IAAI,GAAE,MAAoB,GACzB,OAAO,CAAC,WAAW,CAAC,CAiGtB"}
package/dist/ci/run.js ADDED
@@ -0,0 +1,207 @@
1
+ /**
2
+ * INT-02 (#50) — CI / PR bot orchestrator.
3
+ *
4
+ * A THIN wrapper over the shared core (same pattern as the MCP layer, #49): validate inputs → reuse
5
+ * `resolveConfig` (routing / cost / config) → call the SAME `runExploration` / `runDesign` the CLI
6
+ * calls → compose a summary → post it as the PR comment → OPTIONALLY open a follow-up PR with the
7
+ * generated tests. No new generation logic lives here; specs land via the #51 project-fit writer.
8
+ *
9
+ * Every external effect (core, GitHub API, fs, clock) is injected through {@link CiDeps}, so the whole
10
+ * flow is unit-testable with mocks — no browser, no LLM, no network.
11
+ */
12
+ import { join, relative, resolve } from "node:path";
13
+ import { readFile as fsReadFile } from "node:fs/promises";
14
+ import { resolveConfig } from "../core/config.js";
15
+ import { runExploration, runDesign } from "../agent/index.js";
16
+ import { readInputFile } from "../fs/run-dir.js";
17
+ import { resolveStyleText } from "../design/style.js";
18
+ import { parseInputs, buildContext } from "./inputs.js";
19
+ import { RestGitHubClient } from "./github.js";
20
+ import { renderCiSummary } from "./summary.js";
21
+ export const defaultDeps = {
22
+ resolveConfig,
23
+ runExploration,
24
+ runDesign,
25
+ makeGitHubClient: (ctx) => new RestGitHubClient(ctx),
26
+ readInputFile,
27
+ resolveStyleText,
28
+ readFile: (p) => fsReadFile(p, "utf8"),
29
+ cwd: () => process.cwd(),
30
+ log: (m) => process.stderr.write(`${m}\n`),
31
+ };
32
+ /** Translate a single glob (`*`, `**`, `?`) into an anchored RegExp over POSIX paths. */
33
+ function globToRegExp(glob) {
34
+ const escaped = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&");
35
+ // Single pass so a `*` emitted by an earlier replacement (e.g. inside `(?:.*/)?`) is not re-expanded.
36
+ const body = escaped.replace(/\*\*\/|\*\*|\*|\?/g, (m) => {
37
+ if (m === "**/")
38
+ return "(?:.*/)?"; // any directories (or none)
39
+ if (m === "**")
40
+ return ".*";
41
+ if (m === "*")
42
+ return "[^/]*";
43
+ return "."; // ?
44
+ });
45
+ return new RegExp(`^${body}$`);
46
+ }
47
+ /** Does any glob match the file path? Empty glob list means "no filter" (always true at the call site). */
48
+ export function matchesAnyGlob(file, globs) {
49
+ const posix = file.replace(/\\/g, "/");
50
+ return globs.some((g) => globToRegExp(g).test(posix));
51
+ }
52
+ /** Map inputs → the shared `ExploreInput` (config reused), exactly like the CLI/MCP adapters do. */
53
+ async function buildExploreInput(inputs, deps) {
54
+ const config = deps.resolveConfig({
55
+ backend: inputs.backend,
56
+ routing: inputs.routing,
57
+ channel: inputs.channel,
58
+ });
59
+ const checklistText = inputs.checklist ? await deps.readInputFile(inputs.checklist, "Checklist") : undefined;
60
+ const styleText = inputs.style ? await deps.resolveStyleText(inputs.style) : undefined;
61
+ return {
62
+ url: inputs.url,
63
+ config,
64
+ sessionName: inputs.session,
65
+ checklistText,
66
+ style: inputs.style,
67
+ styleText,
68
+ intoProject: inputs.intoProject,
69
+ projectDir: inputs.projectDir,
70
+ };
71
+ }
72
+ /** Absolute paths of the spec files Cairn wrote (project-fit ejection wins; else the greenfield sandbox). */
73
+ function generatedSpecPaths(result) {
74
+ if (result.projectSpecFiles?.length)
75
+ return result.projectSpecFiles;
76
+ if (result.suite)
77
+ return result.suite.files.map((f) => join(result.runDir, "tests", f.path));
78
+ return [];
79
+ }
80
+ /** Read the generated specs and turn them into repo-relative commit files for a follow-up PR. */
81
+ async function collectCommitFiles(result, deps) {
82
+ const root = deps.cwd();
83
+ const files = [];
84
+ for (const abs of generatedSpecPaths(result)) {
85
+ const content = await deps.readFile(abs);
86
+ const rel = relative(root, resolve(abs)).replace(/\\/g, "/");
87
+ files.push({ path: rel, content });
88
+ }
89
+ return files;
90
+ }
91
+ /** Build the compact validation roll-up the summary renders. */
92
+ function compactValidation(result) {
93
+ const v = result.validation;
94
+ if (!v)
95
+ return undefined;
96
+ return {
97
+ greenRatio: v.greenRatio,
98
+ passed: v.results.filter((r) => r.status === "passed").length,
99
+ failed: v.results.filter((r) => r.status === "failed").length,
100
+ flaky: v.flakyCount,
101
+ };
102
+ }
103
+ /**
104
+ * Run the CI / PR bot end to end. Reads inputs + context from `env`/`event` (injected so tests need no
105
+ * files), runs the core, and applies the GitHub effects guarded by toggles + permission reality (fork
106
+ * PRs and missing tokens are read-only — those effects are skipped with a logged reason, never crash).
107
+ */
108
+ export async function runCi(env = process.env, event = {}, deps = defaultDeps) {
109
+ const inputs = parseInputs(env);
110
+ const ctx = buildContext(env, event);
111
+ const skippedEffects = [];
112
+ // A token is required for any GitHub effect. Fork PRs get a read-only token under `pull_request`,
113
+ // so we also treat forks as "cannot write" (maintainers opt into pull_request_target deliberately).
114
+ const canWrite = Boolean(ctx.token) && !ctx.isFork && ctx.prNumber !== undefined;
115
+ const github = ctx.token ? deps.makeGitHubClient(ctx) : undefined;
116
+ if (!ctx.token)
117
+ skippedEffects.push("no github-token — GitHub effects skipped");
118
+ else if (ctx.isFork)
119
+ skippedEffects.push("fork PR (read-only token) — GitHub effects skipped");
120
+ else if (ctx.prNumber === undefined)
121
+ skippedEffects.push("not a pull_request event — GitHub effects skipped");
122
+ // Changed-surface gate: when `paths` is set, only run if the PR touched a matching file. Needs read
123
+ // access to the PR's files; if we can't read them we conservatively proceed (better a run than a miss).
124
+ if (inputs.paths.length > 0 && github && ctx.prNumber !== undefined) {
125
+ const changed = await github.listChangedFiles(ctx.prNumber);
126
+ const hit = changed.some((f) => matchesAnyGlob(f.filename, inputs.paths));
127
+ if (!hit) {
128
+ deps.log("No changed files match `paths` — skipping generation (no-op).");
129
+ const summary = {
130
+ mode: inputs.mode,
131
+ url: inputs.url,
132
+ caseCount: 0,
133
+ specCount: 0,
134
+ noOpReason: "no changed surfaces matched the configured `paths`",
135
+ };
136
+ const comment = inputs.comment && canWrite ? await github.upsertComment(ctx.prNumber, renderCiSummary(summary)) : undefined;
137
+ return { ranCore: false, summary, comment, skippedEffects };
138
+ }
139
+ }
140
+ // Core run (the same entry points the CLI uses).
141
+ deps.log(`Running cairn ${inputs.mode} against ${inputs.url} …`);
142
+ const exploreInput = await buildExploreInput(inputs, deps);
143
+ let result;
144
+ let exploreResult;
145
+ if (inputs.mode === "explore") {
146
+ exploreResult = await deps.runExploration(exploreInput);
147
+ result = exploreResult;
148
+ }
149
+ else {
150
+ result = await deps.runDesign(exploreInput);
151
+ }
152
+ const summary = {
153
+ mode: inputs.mode,
154
+ url: inputs.url,
155
+ runId: result.runId,
156
+ caseCount: result.testCases.length,
157
+ specCount: exploreResult ? generatedSpecPaths(exploreResult).length : 0,
158
+ validation: exploreResult ? compactValidation(exploreResult) : undefined,
159
+ pilot: exploreResult?.pilot
160
+ ? { verdict: exploreResult.pilot.verdict, reason: exploreResult.pilot.reason }
161
+ : undefined,
162
+ cost: { totalTokens: result.cost.totalTokens, totalCostUsd: result.cost.totalCostUsd },
163
+ projectTestDir: exploreResult?.projectTestDir,
164
+ };
165
+ // Optional follow-up PR — ONLY on explicit toggle, with writable context and actual specs to carry.
166
+ let followupPr;
167
+ if (inputs.openPr) {
168
+ if (inputs.mode !== "explore") {
169
+ skippedEffects.push("open-pr ignored — only `explore` mode produces code");
170
+ }
171
+ else if (!canWrite || !github) {
172
+ skippedEffects.push("open-pr requested but context is read-only — follow-up PR skipped");
173
+ }
174
+ else {
175
+ const files = await collectCommitFiles(exploreResult, deps);
176
+ if (files.length === 0) {
177
+ skippedEffects.push("open-pr requested but no specs were generated — follow-up PR skipped");
178
+ }
179
+ else {
180
+ const branch = `${inputs.prBranch}-${ctx.prNumber}`;
181
+ followupPr = await github.openFollowupPr({
182
+ branch,
183
+ baseBranch: ctx.headRef ?? ctx.baseRef ?? "main",
184
+ commitMessage: inputs.commitMessage,
185
+ title: inputs.prTitle,
186
+ body: `Generated by Cairn for #${ctx.prNumber}.`,
187
+ files,
188
+ });
189
+ summary.followupPr = followupPr;
190
+ deps.log(`Opened follow-up PR: ${followupPr.url}`);
191
+ }
192
+ }
193
+ }
194
+ // Summary comment (idempotent upsert) — last, so it reflects the follow-up PR.
195
+ let comment;
196
+ if (inputs.comment) {
197
+ if (canWrite && github && ctx.prNumber !== undefined) {
198
+ comment = await github.upsertComment(ctx.prNumber, renderCiSummary(summary));
199
+ deps.log(`${comment.action === "created" ? "Posted" : "Updated"} the summary comment.`);
200
+ }
201
+ else {
202
+ skippedEffects.push("comment requested but context is read-only — comment skipped");
203
+ }
204
+ }
205
+ return { ranCore: true, summary, comment, followupPr, skippedEffects };
206
+ }
207
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 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F,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;QACtF,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;AACzE,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * INT-02 (#50) — compose the PR summary comment from a CI run result.
3
+ *
4
+ * Pure string assembly (no I/O) so it is unit-testable directly. The output is GitHub-flavored
5
+ * markdown; the {@link ./github.ts} client stamps the idempotency marker before posting.
6
+ */
7
+ /** Validation roll-up (mirrors the compact shape the MCP layer already produces). */
8
+ export interface SummaryValidation {
9
+ greenRatio: number;
10
+ passed: number;
11
+ failed: number;
12
+ flaky: number;
13
+ }
14
+ /** Everything the comment renders — filled by the orchestrator from the core run result. */
15
+ export interface CiSummary {
16
+ mode: "explore" | "design";
17
+ url: string;
18
+ runId?: string;
19
+ caseCount: number;
20
+ specCount: number;
21
+ validation?: SummaryValidation;
22
+ pilot?: {
23
+ verdict: string;
24
+ reason: string;
25
+ };
26
+ cost?: {
27
+ totalTokens: number;
28
+ totalCostUsd: number | null;
29
+ };
30
+ /** Where specs were written into the host Playwright project (#51), when into-project ran. */
31
+ projectTestDir?: string;
32
+ /** The opened follow-up PR, when the toggle ran it. */
33
+ followupPr?: {
34
+ url: string;
35
+ number: number;
36
+ };
37
+ /** Set when the run was skipped (e.g. no changed surfaces) — renders a no-op note instead of metrics. */
38
+ noOpReason?: string;
39
+ }
40
+ /** Render the full comment body (without the hidden marker — the client adds that). */
41
+ export declare function renderCiSummary(s: CiSummary): string;
42
+ //# sourceMappingURL=summary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../src/ci/summary.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qFAAqF;AACrF,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,4FAA4F;AAC5F,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,KAAK,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,IAAI,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC5D,8FAA8F;IAC9F,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,UAAU,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,yGAAyG;IACzG,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAWD,uFAAuF;AACvF,wBAAgB,eAAe,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CA8BpD"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * INT-02 (#50) — compose the PR summary comment from a CI run result.
3
+ *
4
+ * Pure string assembly (no I/O) so it is unit-testable directly. The output is GitHub-flavored
5
+ * markdown; the {@link ./github.ts} client stamps the idempotency marker before posting.
6
+ */
7
+ const TITLE = "### 🪨 Cairn — generated UI tests";
8
+ /** Format a cost line, tolerating an unknown (null) USD total. */
9
+ function costLine(cost) {
10
+ if (!cost)
11
+ return "";
12
+ const usd = cost.totalCostUsd === null ? "n/a" : `$${cost.totalCostUsd.toFixed(4)}`;
13
+ return `- **Cost:** ${cost.totalTokens.toLocaleString("en-US")} tokens · ${usd}`;
14
+ }
15
+ /** Render the full comment body (without the hidden marker — the client adds that). */
16
+ export function renderCiSummary(s) {
17
+ if (s.noOpReason) {
18
+ return [TITLE, "", `No tests generated — ${s.noOpReason}.`].join("\n");
19
+ }
20
+ const lines = [TITLE, ""];
21
+ lines.push(`Ran \`cairn ${s.mode}\` against \`${s.url}\`.`, "");
22
+ lines.push(`- **Test cases:** ${s.caseCount}`);
23
+ if (s.mode === "explore")
24
+ lines.push(`- **Spec files:** ${s.specCount}`);
25
+ if (s.validation) {
26
+ const pct = Math.round(s.validation.greenRatio * 100);
27
+ lines.push(`- **Validation:** ${pct}% green — ${s.validation.passed} passed, ` +
28
+ `${s.validation.failed} failed, ${s.validation.flaky} flaky`);
29
+ }
30
+ if (s.pilot)
31
+ lines.push(`- **Pilot verdict:** ${s.pilot.verdict} — ${s.pilot.reason}`);
32
+ if (s.projectTestDir)
33
+ lines.push(`- **Written to:** \`${s.projectTestDir}\``);
34
+ const cost = costLine(s.cost);
35
+ if (cost)
36
+ lines.push(cost);
37
+ if (s.followupPr) {
38
+ lines.push("", `📦 Opened follow-up PR with the tests: ${s.followupPr.url} (#${s.followupPr.number}).`);
39
+ }
40
+ else if (s.mode === "explore" && s.specCount > 0) {
41
+ lines.push("", "_Tests were generated in the workflow run. Enable `open-pr` to receive them as a follow-up PR._");
42
+ }
43
+ return lines.join("\n");
44
+ }
45
+ //# sourceMappingURL=summary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summary.js","sourceRoot":"","sources":["../../src/ci/summary.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4BH,MAAM,KAAK,GAAG,mCAAmC,CAAC;AAElD,kEAAkE;AAClE,SAAS,QAAQ,CAAC,IAAuB;IACvC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,I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,CAAC,CAAC;IACvF,IAAI,CAAC,CAAC,cAAc;QAAE,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,cAAc,IAAI,CAAC,CAAC;IAC9E,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE3B,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;QACjB,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,0CAA0C,CAAC,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,CAAC,UAAU,CAAC,MAAM,IAAI,CAAC,CAAC;IAC1G,CAAC;SAAM,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;QACnD,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,iGAAiG,CAAC,CAAC;IACpH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AACH,OAAO,eAAe,CAAC;AAGvB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0CpC;;;GAGG;AACH,wBAAgB,YAAY,IAAI,OAAO,CA2YtC;AAED;;;GAGG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAiB5C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AACH,OAAO,eAAe,CAAC;AAGvB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2CpC;;;GAGG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAsdtC;AAED;;;GAGG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAiB5C"}