clud-bug 0.6.34 → 0.7.0-rc.11

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 (153) hide show
  1. package/README.md +20 -0
  2. package/bin/clud-bug.js +10 -1353
  3. package/data/canonical-v1.json +37 -0
  4. package/dist/cli/agents-md.d.ts +16 -0
  5. package/dist/cli/agents-md.d.ts.map +1 -0
  6. package/dist/cli/agents-md.js +226 -0
  7. package/dist/cli/agents-md.js.map +1 -0
  8. package/dist/cli/audit.d.ts +13 -0
  9. package/dist/cli/audit.d.ts.map +1 -0
  10. package/dist/cli/audit.js +90 -0
  11. package/dist/cli/audit.js.map +1 -0
  12. package/dist/cli/branch-protection.d.ts +57 -0
  13. package/dist/cli/branch-protection.d.ts.map +1 -0
  14. package/dist/cli/branch-protection.js +118 -0
  15. package/dist/cli/branch-protection.js.map +1 -0
  16. package/dist/cli/configure-github.d.ts +58 -0
  17. package/dist/cli/configure-github.d.ts.map +1 -0
  18. package/dist/cli/configure-github.js +242 -0
  19. package/dist/cli/configure-github.js.map +1 -0
  20. package/dist/cli/edit-workflow.d.ts +18 -0
  21. package/dist/cli/edit-workflow.d.ts.map +1 -0
  22. package/dist/cli/edit-workflow.js +43 -0
  23. package/dist/cli/edit-workflow.js.map +1 -0
  24. package/dist/cli/index.d.ts +9 -0
  25. package/dist/cli/index.d.ts.map +1 -0
  26. package/dist/cli/index.js +19 -0
  27. package/dist/cli/index.js.map +1 -0
  28. package/dist/cli/main.d.ts +3 -0
  29. package/dist/cli/main.d.ts.map +1 -0
  30. package/dist/cli/main.js +2067 -0
  31. package/dist/cli/main.js.map +1 -0
  32. package/dist/cli/skill-usage.d.ts +109 -0
  33. package/dist/cli/skill-usage.d.ts.map +1 -0
  34. package/dist/cli/skill-usage.js +380 -0
  35. package/dist/cli/skill-usage.js.map +1 -0
  36. package/dist/cli/skills.d.ts +56 -0
  37. package/dist/cli/skills.d.ts.map +1 -0
  38. package/dist/cli/skills.js +292 -0
  39. package/dist/cli/skills.js.map +1 -0
  40. package/dist/cli/update.d.ts +29 -0
  41. package/dist/cli/update.d.ts.map +1 -0
  42. package/dist/cli/update.js +205 -0
  43. package/dist/cli/update.js.map +1 -0
  44. package/dist/cli/usage.d.ts +142 -0
  45. package/dist/cli/usage.d.ts.map +1 -0
  46. package/dist/cli/usage.js +348 -0
  47. package/dist/cli/usage.js.map +1 -0
  48. package/dist/core/audit.d.ts +8 -0
  49. package/dist/core/audit.d.ts.map +1 -0
  50. package/dist/core/audit.js +47 -0
  51. package/dist/core/audit.js.map +1 -0
  52. package/dist/core/auto-resolve.d.ts +235 -0
  53. package/dist/core/auto-resolve.d.ts.map +1 -0
  54. package/dist/core/auto-resolve.js +293 -0
  55. package/dist/core/auto-resolve.js.map +1 -0
  56. package/dist/core/configure-github.d.ts +179 -0
  57. package/dist/core/configure-github.d.ts.map +1 -0
  58. package/dist/core/configure-github.js +289 -0
  59. package/dist/core/configure-github.js.map +1 -0
  60. package/dist/core/detect.d.ts +77 -0
  61. package/dist/core/detect.d.ts.map +1 -0
  62. package/dist/core/detect.js +262 -0
  63. package/dist/core/detect.js.map +1 -0
  64. package/dist/core/diff-findings.d.ts +96 -0
  65. package/dist/core/diff-findings.d.ts.map +1 -0
  66. package/dist/core/diff-findings.js +261 -0
  67. package/dist/core/diff-findings.js.map +1 -0
  68. package/dist/core/formal-review.d.ts +79 -0
  69. package/dist/core/formal-review.d.ts.map +1 -0
  70. package/dist/core/formal-review.js +71 -0
  71. package/dist/core/formal-review.js.map +1 -0
  72. package/dist/core/index.d.ts +17 -0
  73. package/dist/core/index.d.ts.map +1 -0
  74. package/dist/core/index.js +66 -0
  75. package/dist/core/index.js.map +1 -0
  76. package/dist/core/inline-threads.d.ts +160 -0
  77. package/dist/core/inline-threads.d.ts.map +1 -0
  78. package/dist/core/inline-threads.js +369 -0
  79. package/dist/core/inline-threads.js.map +1 -0
  80. package/dist/core/prompt-builder.d.ts +164 -0
  81. package/dist/core/prompt-builder.d.ts.map +1 -0
  82. package/dist/core/prompt-builder.js +419 -0
  83. package/dist/core/prompt-builder.js.map +1 -0
  84. package/dist/core/prompts.d.ts +9 -0
  85. package/dist/core/prompts.d.ts.map +1 -0
  86. package/dist/core/prompts.js +401 -0
  87. package/dist/core/prompts.js.map +1 -0
  88. package/dist/core/render-review.d.ts +6 -0
  89. package/dist/core/render-review.d.ts.map +1 -0
  90. package/dist/core/render-review.js +219 -0
  91. package/dist/core/render-review.js.map +1 -0
  92. package/dist/core/render.d.ts +13 -0
  93. package/dist/core/render.d.ts.map +1 -0
  94. package/dist/core/render.js +62 -0
  95. package/dist/core/render.js.map +1 -0
  96. package/dist/core/resolve-verifier.d.ts +46 -0
  97. package/dist/core/resolve-verifier.d.ts.map +1 -0
  98. package/dist/core/resolve-verifier.js +187 -0
  99. package/dist/core/resolve-verifier.js.map +1 -0
  100. package/dist/core/review-schema-zod.d.ts +240 -0
  101. package/dist/core/review-schema-zod.d.ts.map +1 -0
  102. package/dist/core/review-schema-zod.js +218 -0
  103. package/dist/core/review-schema-zod.js.map +1 -0
  104. package/dist/core/review-schema.d.ts +42 -0
  105. package/dist/core/review-schema.d.ts.map +1 -0
  106. package/dist/core/review-schema.js +156 -0
  107. package/dist/core/review-schema.js.map +1 -0
  108. package/dist/core/review-writeback.d.ts +193 -0
  109. package/dist/core/review-writeback.d.ts.map +1 -0
  110. package/dist/core/review-writeback.js +364 -0
  111. package/dist/core/review-writeback.js.map +1 -0
  112. package/dist/core/skills.d.ts +147 -0
  113. package/dist/core/skills.d.ts.map +1 -0
  114. package/dist/core/skills.js +726 -0
  115. package/dist/core/skills.js.map +1 -0
  116. package/dist/core/version.d.ts +2 -0
  117. package/dist/core/version.d.ts.map +1 -0
  118. package/dist/core/version.js +4 -0
  119. package/dist/core/version.js.map +1 -0
  120. package/package.json +37 -5
  121. package/{lib/agents-md.js → src/cli/agents-md.ts} +25 -14
  122. package/{lib/audit.js → src/cli/audit.ts} +37 -44
  123. package/{lib/branch-protection.js → src/cli/branch-protection.ts} +75 -11
  124. package/src/cli/configure-github.ts +329 -0
  125. package/{lib/edit-workflow.js → src/cli/edit-workflow.ts} +32 -11
  126. package/src/cli/index.ts +107 -0
  127. package/src/cli/main.ts +2204 -0
  128. package/{lib/skill-usage.js → src/cli/skill-usage.ts} +168 -94
  129. package/src/cli/skills.ts +386 -0
  130. package/{lib/update.js → src/cli/update.ts} +87 -27
  131. package/{lib/usage.js → src/cli/usage.ts} +167 -76
  132. package/src/core/audit.ts +53 -0
  133. package/src/core/auto-resolve.ts +488 -0
  134. package/src/core/configure-github.ts +497 -0
  135. package/{lib/detect.js → src/core/detect.ts} +100 -47
  136. package/src/core/diff-findings.ts +323 -0
  137. package/src/core/formal-review.ts +168 -0
  138. package/src/core/index.ts +250 -0
  139. package/src/core/inline-threads.ts +471 -0
  140. package/src/core/prompt-builder.ts +561 -0
  141. package/{lib/prompts.js → src/core/prompts.ts} +16 -2
  142. package/{lib/render-review.js → src/core/render-review.ts} +57 -25
  143. package/{lib/render.js → src/core/render.ts} +37 -17
  144. package/src/core/resolve-verifier.ts +228 -0
  145. package/src/core/review-schema-zod.ts +262 -0
  146. package/{lib/review-schema.js → src/core/review-schema.ts} +68 -5
  147. package/src/core/review-writeback.ts +565 -0
  148. package/{lib/skills.js → src/core/skills.ts} +456 -342
  149. package/src/core/version.ts +3 -0
  150. package/templates/clud-bug-review.md.tmpl +115 -0
  151. package/templates/workflow-py.yml.tmpl +80 -3
  152. package/templates/workflow-ts.yml.tmpl +80 -3
  153. package/templates/workflow.yml.tmpl +175 -8
@@ -0,0 +1,79 @@
1
+ /** GitHub's `pulls.createReview` `event` enum, narrowed to the three we use. */
2
+ export type FormalReviewEvent = 'APPROVE' | 'REQUEST_CHANGES' | 'COMMENT';
3
+ /**
4
+ * GitHub `author_association` on a PR. Verbatim union from the REST API
5
+ * (per https://docs.github.com/en/rest/pulls/pulls — `author_association`).
6
+ *
7
+ * The "external" tier for §7.2.1 auto-approve gating is:
8
+ *
9
+ * { 'NONE', 'FIRST_TIME_CONTRIBUTOR', 'FIRST_TIMER', 'MANNEQUIN' }
10
+ *
11
+ * Everything else (OWNER, MEMBER, COLLABORATOR, CONTRIBUTOR) is the
12
+ * "org-trusted" tier and eligible for auto-approve on a clean review.
13
+ *
14
+ * `FIRST_TIMER` is the legacy spelling (October 2018 era); GitHub
15
+ * currently emits `FIRST_TIME_CONTRIBUTOR` but some PR fixtures in
16
+ * downstream tests still carry the old token. We keep both so the
17
+ * external-contributor gate doesn't silently regress on the next
18
+ * REST-API rename.
19
+ */
20
+ export type AuthorAssociation = 'OWNER' | 'MEMBER' | 'COLLABORATOR' | 'CONTRIBUTOR' | 'FIRST_TIME_CONTRIBUTOR' | 'FIRST_TIMER' | 'NONE' | 'MANNEQUIN';
21
+ /**
22
+ * SPEC §7.2.1 + §7.2 rule table.
23
+ *
24
+ * Order matters — earlier rows short-circuit later ones:
25
+ *
26
+ * | Priority | Condition | Event |
27
+ * |----------|--------------------------------------------------------|-----------------|
28
+ * | 1 | PR author === clud-bug[bot] | 'skip' |
29
+ * | 2 | authorAssociation ∈ EXTERNAL | 'COMMENT' |
30
+ * | 3 | criticalCount > 0 AND strictMode=true | REQUEST_CHANGES |
31
+ * | 4 | criticalCount > 0 AND strictMode=false | COMMENT |
32
+ * | 5 | minorCount > 0 (no critical) | COMMENT |
33
+ * | 6 | 0 critical + 0 minor | APPROVE |
34
+ *
35
+ * The external-contributor row (Priority 2) sits BETWEEN self-PR-skip
36
+ * and the severity-driven rules: external contributors who open a
37
+ * critical-finding PR still get COMMENT (NOT REQUEST_CHANGES — we don't
38
+ * block their PR on a bot review; that's a human reviewer's call to
39
+ * make). External contributors who open a clean PR also get COMMENT
40
+ * (NOT APPROVE — the §7.2.1 precondition #3 gate).
41
+ *
42
+ * The 'skip' verdict tells the caller NOT to invoke `pulls.createReview`
43
+ * — GitHub returns 422 when a user reviews their own PR, so we
44
+ * short-circuit before the network round-trip. Self-PRs land during D.7
45
+ * migration fan-out (the App opens cross-repo update PRs under its own
46
+ * identity).
47
+ */
48
+ export interface SelectReviewEventInput {
49
+ /** Count of `severity: critical` findings on the review. */
50
+ criticalCount: number;
51
+ /** Count of `severity: minor` findings on the review. */
52
+ minorCount: number;
53
+ /**
54
+ * `strictMode` flag read from `.clud-bug.json` at the PR's BASE ref.
55
+ * Older manifests may not carry this field — callers MUST pass
56
+ * `undefined` in that case so this function applies the safe default
57
+ * (false) rather than surprising users with REQUEST_CHANGES.
58
+ */
59
+ strictMode?: boolean;
60
+ /**
61
+ * GitHub login of the PR author. When it equals 'clud-bug[bot]' we
62
+ * skip the formal review entirely (GitHub disallows self-review with
63
+ * 422). This is the structural guard for D.7 migration fan-out PRs.
64
+ */
65
+ prAuthorLogin: string;
66
+ /**
67
+ * GitHub `author_association` on the PR. NEW in v0.7.0-rc.3 / SPEC
68
+ * §7.2.1: when this is in EXTERNAL_ASSOCIATIONS, a clean review gets
69
+ * COMMENT (not APPROVE) so external-contributor PRs require a human
70
+ * reviewer to satisfy the `required_approving_review_count: 1` floor.
71
+ *
72
+ * Callers that don't have this metadata (older webhook payloads,
73
+ * tests, etc.) should pass `'CONTRIBUTOR'` as the safe default — that
74
+ * tier is org-trusted and preserves pre-§7.2.1 behaviour.
75
+ */
76
+ authorAssociation: AuthorAssociation;
77
+ }
78
+ export declare function selectReviewEvent(input: SelectReviewEventInput): FormalReviewEvent | 'skip';
79
+ //# sourceMappingURL=formal-review.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formal-review.d.ts","sourceRoot":"","sources":["../../src/core/formal-review.ts"],"names":[],"mappings":"AAuBA,gFAAgF;AAChF,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,iBAAiB,GAAG,SAAS,CAAC;AAE1E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,iBAAiB,GACzB,OAAO,GACP,QAAQ,GACR,cAAc,GACd,aAAa,GACb,wBAAwB,GACxB,aAAa,GACb,MAAM,GACN,WAAW,CAAC;AAkBhB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,sBAAsB;IACrC,4DAA4D;IAC5D,aAAa,EAAE,MAAM,CAAC;IACtB,yDAAyD;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;;;;;OASG;IACH,iBAAiB,EAAE,iBAAiB,CAAC;CACtC;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,sBAAsB,GAC5B,iBAAiB,GAAG,MAAM,CAsC5B"}
@@ -0,0 +1,71 @@
1
+ // SPEC §7.2.1 formal-review event selector.
2
+ //
3
+ // This is the PURE half of clud-bug-app's `lib/formal-review.ts` (the
4
+ // Octokit-side `postFormalReview` IO wrapper stays App-side — it depends
5
+ // on `getInstallationOctokit` + `@octokit/rest` which we don't want to
6
+ // pull into core). The pure rule-table lives here so:
7
+ //
8
+ // 1. The npm workflow template's new post-step (added in v0.7.0-rc.3)
9
+ // can `import { selectReviewEvent } from 'clud-bug/core'` and post
10
+ // formal `pulls.createReview` calls under the workflow path — until
11
+ // this PR shipped, the workflow path NEVER satisfied the canonical
12
+ // ruleset's `required_approving_review_count: 1` floor because no
13
+ // APPROVE review was ever posted.
14
+ //
15
+ // 2. clud-bug-app (Phase 7 PR B) deletes its local copy and imports
16
+ // this version, gaining the §7.2.1 author_association extension
17
+ // (clud-bug-app's PR #40 shipped APPROVE without it, so the App
18
+ // currently auto-approves drive-by external-contributor PRs — a
19
+ // security bug closed by Phase 7 PR B's dep bump).
20
+ //
21
+ // Ported from clud-bug-app/lib/formal-review.ts (PR #40, MERGED 2026-06-10)
22
+ // with the §7.2.1 `authorAssociation` extension new in Phase 7 PR A.
23
+ /**
24
+ * Author-association values that route a clean-review APPROVE *down* to
25
+ * COMMENT per SPEC §7.2.1 precondition #3 ("PR author is an org member —
26
+ * NOT a first-time external contributor"). These authors still get a
27
+ * COMMENT review (so they SEE the bot's verdict) but the formal APPROVE
28
+ * vote stays withheld — a human reviewer must click Approve before the
29
+ * PR can merge under the canonical ruleset.
30
+ *
31
+ * Drive-by exploitation prevention: a malicious external contributor
32
+ * who opens a clean-looking PR cannot leverage clud-bug[bot]'s APPROVE
33
+ * vote to auto-merge.
34
+ */
35
+ const EXTERNAL_ASSOCIATIONS = new Set(['NONE', 'FIRST_TIME_CONTRIBUTOR', 'FIRST_TIMER', 'MANNEQUIN']);
36
+ export function selectReviewEvent(input) {
37
+ // Priority 1: self-PR guard. GitHub returns 422 on a self-review;
38
+ // we short-circuit before the network round-trip. Self-PRs land
39
+ // during D.7 migration fan-out (the App opens cross-repo update PRs
40
+ // under its own identity).
41
+ if (input.prAuthorLogin === 'clud-bug[bot]') {
42
+ return 'skip';
43
+ }
44
+ // Priority 2: external-contributor gate (SPEC §7.2.1 precondition #3).
45
+ // External contributors NEVER get APPROVE (no auto-merge bypass via
46
+ // drive-by) and NEVER get REQUEST_CHANGES (we don't block their PR on
47
+ // a bot review — that escalation is a human reviewer's call). They
48
+ // always get an advisory COMMENT so they see the bot's verdict.
49
+ if (EXTERNAL_ASSOCIATIONS.has(input.authorAssociation)) {
50
+ return 'COMMENT';
51
+ }
52
+ // Priority 6 (note: priorities 3-5 fall through to here when there
53
+ // are no findings): clean review on an org-trusted author → APPROVE.
54
+ // APPROVE flips the `required_approving_review_count: 1` ruleset and
55
+ // lets auto-merge fire under the canonical SPEC §7.2 ruleset.
56
+ if (input.criticalCount === 0 && input.minorCount === 0) {
57
+ return 'APPROVE';
58
+ }
59
+ // Priority 3 + 4: critical finding → gate on strictMode. Default
60
+ // `strictMode === undefined` → false (advisory-only). REQUEST_CHANGES
61
+ // blocks the PR until the author dismisses or fixes; we only honor
62
+ // it when the repo opted in.
63
+ if (input.criticalCount > 0) {
64
+ return input.strictMode === true ? 'REQUEST_CHANGES' : 'COMMENT';
65
+ }
66
+ // Priority 5: minor-only or preexisting-only finding → advisory
67
+ // COMMENT. We never REQUEST_CHANGES on a minor — those are noted,
68
+ // not blocking.
69
+ return 'COMMENT';
70
+ }
71
+ //# sourceMappingURL=formal-review.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formal-review.js","sourceRoot":"","sources":["../../src/core/formal-review.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,EAAE;AACF,sEAAsE;AACtE,yEAAyE;AACzE,uEAAuE;AACvE,sDAAsD;AACtD,EAAE;AACF,wEAAwE;AACxE,wEAAwE;AACxE,yEAAyE;AACzE,wEAAwE;AACxE,uEAAuE;AACvE,uCAAuC;AACvC,EAAE;AACF,sEAAsE;AACtE,qEAAqE;AACrE,qEAAqE;AACrE,qEAAqE;AACrE,wDAAwD;AACxD,EAAE;AACF,4EAA4E;AAC5E,qEAAqE;AAgCrE;;;;;;;;;;;GAWG;AACH,MAAM,qBAAqB,GAAmC,IAAI,GAAG,CAEnE,CAAC,MAAM,EAAE,wBAAwB,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;AA4DlE,MAAM,UAAU,iBAAiB,CAC/B,KAA6B;IAE7B,kEAAkE;IAClE,gEAAgE;IAChE,oEAAoE;IACpE,2BAA2B;IAC3B,IAAI,KAAK,CAAC,aAAa,KAAK,eAAe,EAAE,CAAC;QAC5C,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,uEAAuE;IACvE,oEAAoE;IACpE,sEAAsE;IACtE,mEAAmE;IACnE,gEAAgE;IAChE,IAAI,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACvD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,mEAAmE;IACnE,qEAAqE;IACrE,qEAAqE;IACrE,8DAA8D;IAC9D,IAAI,KAAK,CAAC,aAAa,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC,EAAE,CAAC;QACxD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,iEAAiE;IACjE,sEAAsE;IACtE,mEAAmE;IACnE,6BAA6B;IAC7B,IAAI,KAAK,CAAC,aAAa,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,CAAC;IAED,gEAAgE;IAChE,kEAAkE;IAClE,gBAAgB;IAChB,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,17 @@
1
+ export { reviewPrompt, type ReviewPromptOptions, type ReviewPromptLanguage } from './prompts.js';
2
+ export { REVIEW_SCHEMA, serializedReviewSchema, type ReviewData, type ReviewFinding, type ReviewSummaryCounts, type ReviewStatusHeader, type FindingSeverity, type PerSkillScanItem, type DedicatedSection, } from './review-schema.js';
3
+ export { renderReview, SEVERITY_LABEL } from './render-review.js';
4
+ export { detect, buildDescriptionLine, EXT_TO_LANG, DEP_TO_TERM, PY_DEP_TO_TERM, fileHistogram, firstParagraph, type DetectedSignals, type DescriptionLineSignals, } from './detect.js';
5
+ export { render, renderFile, pickTemplate, templateLanguage, DEFAULTS, type RenderDefaults, type RenderVars, type TemplateLanguage, } from './render.js';
6
+ export { durationToGitSince, renderAuditHeader, type AuditHeaderInput, } from './audit.js';
7
+ export { reviewSchema, crossCheckSchema, findingItemSchema, findingSchema, perSkillScanItemSchema, dedicatedSectionSchema, summaryCountsSchema, severitySchema, statusHeaderSchema, crossCheckVerdictSchema, severityValues, statusHeaderValues, flattenFindings, unflattenFindings, deriveSummaryCounts, deriveSkillsReferenced, buildReviewFromFindings, type Review, type CrossCheck, type CrossCheckVerdictSchema, type Severity, type StatusHeader, type SummaryCounts, type FindingItem, type PerSkillScanItem as ZodPerSkillScanItem, type DedicatedSection as ZodDedicatedSection, type Finding as ZodFinding, } from './review-schema-zod.js';
8
+ export { buildReviewPrompt, buildCrossCheckPrompt, buildConsensusPrompt, skillMatchesDiff, globMatch, truncatePatch, sliceUtf8Bytes, MAX_PATCH_BYTES_PER_FILE, DEFAULT_MAX_SKILL_BYTES, type BuildReviewPromptInput, type BuildCrossCheckPromptInput, type BuiltPrompt, type ChangedFile, type ChangedFileStatus, type PullRequestDiff, type PromptAppliesToRule, type PromptSkillFrontmatter, type PromptLoadedSkill, } from './prompt-builder.js';
9
+ export { renderReviewFile, renderMultiPassMarkdown, reviewFilePath, reviewCommitMessage, PROTOCOL_VERSION, WRITTEN_BY, SEVERITY_EMOJI as REVIEW_FILE_SEVERITY_EMOJI, type RenderReviewFileInput, type RenderedFindingRef, type CacheStats, type RenderMultiPassMarkdownInput, type MultiPassReview, type UnifiedFinding, type PassAttribution, type PassSource, type ReviewPassMode, type MultiPassVerdict, } from './review-writeback.js';
10
+ export { selectReviewEvent, type FormalReviewEvent, type AuthorAssociation, type SelectReviewEventInput, } from './formal-review.js';
11
+ export { parsePriorReviewFile, diffFindings, findingIdentity, type ParsedFinding, type ParsedReview, } from './diff-findings.js';
12
+ export { findingId, parseHeadLines, findingAnchorable, extractAnchorContext, renderThreadBody, extractFindingIdFromBody, parseThreadBody, planInlineThreads, REVIEW_THREADS_QUERY, REVIEW_THREADS_STATE_QUERY, RESOLVE_THREAD_MUTATION, ADD_REPLY_MUTATION, type Severity as InlineThreadSeverity, type FindingForThread, type DiffFile, type InlineCommentPlan, type PlanInlineThreadsResult, } from './inline-threads.js';
13
+ export { resolveAutoResolveConfig, readAutoResolveConfigFromCludBug, runAutoResolve, applyResolutionRules, renderAutoResolveMarker, DEFAULT_AUTO_RESOLVE_CONFIG, type AutoResolveConfig, type PriorThread, type PriorFinding, type ThreadAction, type AutoResolveInput, type AutoResolveResult, type VerifyOutcome, } from './auto-resolve.js';
14
+ export { VERIFIER_SYSTEM, buildVerifierPrompt, parseVerifierResponse, type VerifySingleFindingInput, } from './resolve-verifier.js';
15
+ export { applyCanonicalRuleset, loadCanonicalV1, type CanonicalRuleset, type OctokitLike, type ApplyCanonicalRulesetParams, type ApplyResult, } from './configure-github.js';
16
+ export { API_BASE, MAX_SKILLS, SkillsClient, normalizeList, rankAndCap, readReviewMode, readAppliesTo, appliesToPr, appliesToAuthor, partitionByReviewMode, extractPerSkillLine, selectReviewHeader, extractFirstReviewHeaderLine, selectReviewBody, extractStatsHeader, isCriticalReviewHeader, classifyPerSkillOutcome, parseFrontmatter, stripFrontmatter, type SkillDescriptor, type RankableSkill, type AppliesToRule, type SkillWithOptionalContent, type PrComment, type ReviewStatsHeader, type SkillFrontmatter, type SkillSource, type SkillReviewMode, type SkillKind, type VoiceScope, } from './skills.js';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACjG,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EACL,MAAM,EACN,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,cAAc,EACd,aAAa,EACb,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,sBAAsB,GAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,MAAM,EACN,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AAUpB,OAAO,EACL,YAAY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,EACpB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,66 @@
1
+ // Public API surface for `clud-bug/core` (consumed via the package's
2
+ // `./core` exports map → `dist/core/index.js`).
3
+ //
4
+ // Each line re-exports one core module's public symbols. Modules are
5
+ // added incrementally as the v0.7.0 TypeScript migration converts each
6
+ // lib/* JS file.
7
+ export { reviewPrompt } from './prompts.js';
8
+ export { REVIEW_SCHEMA, serializedReviewSchema, } from './review-schema.js';
9
+ export { renderReview, SEVERITY_LABEL } from './render-review.js';
10
+ export { detect, buildDescriptionLine, EXT_TO_LANG, DEP_TO_TERM, PY_DEP_TO_TERM, fileHistogram, firstParagraph, } from './detect.js';
11
+ export { render, renderFile, pickTemplate, templateLanguage, DEFAULTS, } from './render.js';
12
+ export { durationToGitSince, renderAuditHeader, } from './audit.js';
13
+ // Zod-typed wire-shape review + internal-shape helpers for the
14
+ // AI-Gateway consumer (clud-bug-app). The CLI-shape JSON Schema +
15
+ // CLI summary-comment renderer above stay first-class; the Zod port
16
+ // below is additive.
17
+ //
18
+ // Naming: the wire-shape `FindingItem` collides with neither CLI nor
19
+ // App existing exports. The internal-shape `Finding` (FindingItem +
20
+ // severity) is re-exported as `ZodFinding` to disambiguate from the
21
+ // CLI's `ReviewFinding`.
22
+ export { reviewSchema, crossCheckSchema, findingItemSchema, findingSchema, perSkillScanItemSchema, dedicatedSectionSchema, summaryCountsSchema, severitySchema, statusHeaderSchema, crossCheckVerdictSchema, severityValues, statusHeaderValues, flattenFindings, unflattenFindings, deriveSummaryCounts, deriveSkillsReferenced, buildReviewFromFindings, } from './review-schema-zod.js';
23
+ // AI-Gateway prompt builder (App's review pass). The CLI-shape
24
+ // `reviewPrompt` workflow-string above stays; this is additive.
25
+ export { buildReviewPrompt, buildCrossCheckPrompt, buildConsensusPrompt, skillMatchesDiff, globMatch, truncatePatch, sliceUtf8Bytes, MAX_PATCH_BYTES_PER_FILE, DEFAULT_MAX_SKILL_BYTES, } from './prompt-builder.js';
26
+ // SPEC §1.8.1 doc-file renderer (`docs/reviews/PR-<n>.md`). Renamed
27
+ // from the App's `renderReview` to `renderReviewFile` to disambiguate
28
+ // from the CLI's `renderReview` (summary PR-comment shape) above.
29
+ export { renderReviewFile, renderMultiPassMarkdown, reviewFilePath, reviewCommitMessage, PROTOCOL_VERSION, WRITTEN_BY, SEVERITY_EMOJI as REVIEW_FILE_SEVERITY_EMOJI, } from './review-writeback.js';
30
+ // SPEC §7.2.1 formal-review event selector. Pure rule-table half of
31
+ // clud-bug-app's `lib/formal-review.ts`; the Octokit-side IO wrapper
32
+ // (`postFormalReview`) stays App-side. v0.7.0-rc.3 adds the
33
+ // `authorAssociation` extension so a clean review on an external
34
+ // contributor's PR routes to COMMENT (not APPROVE) — the canonical
35
+ // ruleset's `required_approving_review_count: 1` floor then requires
36
+ // a human reviewer.
37
+ export { selectReviewEvent, } from './formal-review.js';
38
+ // SPEC §1.8.1 Resolved / Still-open block helpers. `parsePriorReviewFile`
39
+ // reads a prior `docs/reviews/PR-<n>.md`; `diffFindings` splits prior vs
40
+ // current into resolved + still-open lists that `renderReviewFile`
41
+ // emits as the §1.8.1 blocks. Identity scheme is shareable with future
42
+ // inline-thread anchoring in clud-bug-app.
43
+ export { parsePriorReviewFile, diffFindings, findingIdentity, } from './diff-findings.js';
44
+ // Wave 5a — D.2.X per-finding inline review threads. Pure helpers
45
+ // (anchor detection, comment rendering, plan partitioning) + the GraphQL
46
+ // constants the CLI's `post-inline-threads` verb invokes via `gh api`.
47
+ // `findingId` returns the SHA-256[:16] hash and is distinct from the
48
+ // plain-string `findingIdentity` above (both serve different matchers).
49
+ //
50
+ // Wave 5b additions: `parseThreadBody` (inverts renderThreadBody) +
51
+ // `ADD_REPLY_MUTATION` (for posting the auto-resolve marker reply
52
+ // before resolving a thread).
53
+ export { findingId, parseHeadLines, findingAnchorable, extractAnchorContext, renderThreadBody, extractFindingIdFromBody, parseThreadBody, planInlineThreads, REVIEW_THREADS_QUERY, REVIEW_THREADS_STATE_QUERY, RESOLVE_THREAD_MUTATION, ADD_REPLY_MUTATION, } from './inline-threads.js';
54
+ // Wave 5b — D.2.6 auto-resolve on fix-push. Pure rule tables + config
55
+ // merge + marker rendering. The CLI's `resolve-threads` verb owns the
56
+ // Anthropic Messages call + GraphQL mutations; `runAutoResolve` is
57
+ // pure modulo the injected verifier callback.
58
+ export { resolveAutoResolveConfig, readAutoResolveConfigFromCludBug, runAutoResolve, applyResolutionRules, renderAutoResolveMarker, DEFAULT_AUTO_RESOLVE_CONFIG, } from './auto-resolve.js';
59
+ export { VERIFIER_SYSTEM, buildVerifierPrompt, parseVerifierResponse, } from './resolve-verifier.js';
60
+ // SPEC §7 canonical-ruleset applier. Pure diff + idempotent-PATCH logic;
61
+ // CLI side wraps `gh api` in an Octokit-like adapter and the App passes
62
+ // its real Octokit instance. Shipped in v0.7.0-rc.4 for Marketplace prep
63
+ // (Phase 6 task #227).
64
+ export { applyCanonicalRuleset, loadCanonicalV1, } from './configure-github.js';
65
+ export { API_BASE, MAX_SKILLS, SkillsClient, normalizeList, rankAndCap, readReviewMode, readAppliesTo, appliesToPr, appliesToAuthor, partitionByReviewMode, extractPerSkillLine, selectReviewHeader, extractFirstReviewHeaderLine, selectReviewBody, extractStatsHeader, isCriticalReviewHeader, classifyPerSkillOutcome, parseFrontmatter, stripFrontmatter, } from './skills.js';
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,gDAAgD;AAChD,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,iBAAiB;AAEjB,OAAO,EAAE,YAAY,EAA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,EAChB,gBAAgB,GAYjB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,160 @@
1
+ export type Severity = 'critical' | 'minor' | 'preexisting';
2
+ /**
3
+ * Minimal shape this module needs from a review finding. Both the npm CLI
4
+ * and the App's `Finding` type satisfy this; the App also carries
5
+ * `reasoning` + nullable `file`/`line` which we tolerate via the optional
6
+ * fields below.
7
+ */
8
+ export interface FindingForThread {
9
+ severity: Severity;
10
+ skill: string;
11
+ file?: string;
12
+ line?: number;
13
+ summary: string;
14
+ reasoning?: string;
15
+ }
16
+ /**
17
+ * Per-file unified-diff entry. Matches the shape returned by `gh api
18
+ * repos/{owner}/{repo}/pulls/{n}/files` (after JSON.parse) AND
19
+ * `octokit.rest.pulls.listFiles(...).data` so the App can pass either
20
+ * directly.
21
+ */
22
+ export interface DiffFile {
23
+ filename: string;
24
+ patch?: string;
25
+ }
26
+ /**
27
+ * Hashes the canonical `${file}:${line}:${severity}:${skill}:${summary[:100]}`
28
+ * tuple to 16 hex characters. Stable across consumers — the App computes
29
+ * the same hash for the same finding, so threads posted by one consumer
30
+ * stay matchable by the other.
31
+ *
32
+ * Summary is truncated to 100 chars BEFORE hashing so small wording tweaks
33
+ * on subsequent review passes don't generate a fresh id and orphan the
34
+ * prior thread.
35
+ *
36
+ * Distinct from `findingIdentity` in `./diff-findings` (which returns the
37
+ * plain unhashed string — used by the Resolved/Still-open block matcher).
38
+ * Both helpers coexist on purpose: the unhashed string is human-readable
39
+ * for in-prose matching; the hash is short + collision-safe for embedding
40
+ * in `<!-- finding-id: ... -->` comment-body markers.
41
+ */
42
+ export declare function findingId(finding: {
43
+ file?: string;
44
+ line?: number;
45
+ severity: Severity;
46
+ skill: string;
47
+ summary: string;
48
+ }): string;
49
+ /**
50
+ * Returns the set of 1-indexed HEAD-side line numbers a unified-diff patch
51
+ * touches (added + context lines). GitHub only accepts inline review
52
+ * comments on lines that appear in the diff, so this gates whether a
53
+ * finding's `line` can become a thread.
54
+ *
55
+ * "Touched" = appears on the RIGHT side of the unified diff: added (`+`)
56
+ * lines OR unchanged context (` `) lines inside any hunk. Removed (`-`)
57
+ * lines are LEFT-side only and can't anchor inline comments.
58
+ *
59
+ * If `patch` is undefined (binary file, GitHub truncation) returns an empty
60
+ * set — the caller falls back to the summary comment for those findings.
61
+ */
62
+ export declare function parseHeadLines(patch: string | undefined): Set<number>;
63
+ /**
64
+ * Returns true when the finding's `(file, line)` can be anchored as an
65
+ * inline comment on the current diff. `diffFiles` is the per-file diff
66
+ * (as returned by `gh api repos/.../pulls/.../files`).
67
+ */
68
+ export declare function findingAnchorable(finding: {
69
+ file?: string;
70
+ line?: number;
71
+ }, diffFiles: ReadonlyArray<DiffFile>): boolean;
72
+ /**
73
+ * Builds the `{codeBefore, codeAfter, diffAtAnchor?}` triple Wave 5b's
74
+ * auto-resolve verifier consumes for a single finding, pulled out of the
75
+ * unified-diff hunk that touches the finding's line.
76
+ *
77
+ * Works entirely from the in-hand patch — no fresh API calls. The patch
78
+ * already encodes BEFORE (lines with `-` or context) and AFTER (lines with
79
+ * `+` or context) for every hunk the PR touches.
80
+ *
81
+ * Returns empty strings for `codeBefore`/`codeAfter` when the finding's
82
+ * file isn't in the diff at all. The verifier sees "unchanged" and
83
+ * typically returns NOT_ADDRESSED / UNCERTAIN, which is the correct
84
+ * behavior — an unchanged file isn't a fix.
85
+ */
86
+ export declare function extractAnchorContext(finding: {
87
+ file?: string;
88
+ line?: number;
89
+ }, diffFiles: ReadonlyArray<DiffFile>): {
90
+ codeBefore: string;
91
+ codeAfter: string;
92
+ diffAtAnchor?: string;
93
+ };
94
+ /**
95
+ * Body for a single inline-thread comment. Includes a hidden HTML marker
96
+ * carrying `findingId` so Wave 5b's auto-resolve can recover the canonical
97
+ * id from the thread's first comment body without persisting state.
98
+ */
99
+ export declare function renderThreadBody(finding: FindingForThread): string;
100
+ /**
101
+ * Extracts the hashed `findingId` from a thread comment body that was
102
+ * rendered by `renderThreadBody`. Returns null when the marker is absent
103
+ * (a manual reply, or a comment posted by a different tool).
104
+ *
105
+ * Used by Wave 5b's auto-resolve to re-derive finding ids from existing
106
+ * GitHub threads on a stateless re-run.
107
+ */
108
+ export declare function extractFindingIdFromBody(body: string): string | null;
109
+ /**
110
+ * Wave 5b — invert `renderThreadBody` to recover the original finding
111
+ * tuple from a bot-authored thread comment. The fix-push auto-resolve
112
+ * CLI verb uses this to reconstruct `PriorFinding` from the GraphQL
113
+ * `reviewThreads` response without persistent state.
114
+ *
115
+ * Returns null when the body doesn't match the canonical shape
116
+ * `<!-- finding-id: XX -->\n🔴|🟡 \`skill\`\n\nsummary[\n\nreasoning]`.
117
+ * Same start-anchored posture as `extractFindingIdFromBody` for anti-
118
+ * injection: a user reply that quotes the marker mid-body won't be
119
+ * misattributed as bot-authored.
120
+ */
121
+ export declare function parseThreadBody(body: string): {
122
+ findingId: string;
123
+ severity: Severity;
124
+ skill: string;
125
+ summary: string;
126
+ reasoning?: string;
127
+ } | null;
128
+ /**
129
+ * One entry in the createReview `comments[]` array. Matches GitHub's REST
130
+ * shape exactly so callers can JSON.stringify directly into a `gh api` body.
131
+ */
132
+ export interface InlineCommentPlan {
133
+ path: string;
134
+ line: number;
135
+ side: 'RIGHT';
136
+ body: string;
137
+ }
138
+ export interface PlanInlineThreadsResult {
139
+ /** Comment entries for the createReview `comments[]` field. */
140
+ comments: InlineCommentPlan[];
141
+ /** Findings the diff couldn't anchor (file or line not in any hunk). */
142
+ skipped: FindingForThread[];
143
+ /** Findings filtered out because severity is 'preexisting' (informational only). */
144
+ preexisting: FindingForThread[];
145
+ }
146
+ /**
147
+ * Partitions a flat findings list into the `comments[]` body for
148
+ * `POST /repos/:owner/:repo/pulls/:n/reviews` + the findings the caller
149
+ * should surface elsewhere (summary comment for `skipped`; never for
150
+ * `preexisting`).
151
+ *
152
+ * Pure function — no I/O. The CLI verb uses this to compute the API body;
153
+ * the App can use it after Wave 5c migration to share the same partitioning.
154
+ */
155
+ export declare function planInlineThreads(findings: ReadonlyArray<FindingForThread>, diffFiles: ReadonlyArray<DiffFile>): PlanInlineThreadsResult;
156
+ export declare const REVIEW_THREADS_QUERY = "\n query ReviewThreads($owner: String!, $repo: String!, $pr: Int!) {\n repository(owner: $owner, name: $repo) {\n pullRequest(number: $pr) {\n reviewThreads(first: 100) {\n nodes {\n id\n isResolved\n comments(first: 100) {\n nodes {\n databaseId\n path\n line\n originalLine\n body\n author {\n login\n }\n }\n }\n }\n }\n }\n }\n }\n";
157
+ export declare const REVIEW_THREADS_STATE_QUERY = "\n query ReviewThreadStates($owner: String!, $repo: String!, $pr: Int!) {\n repository(owner: $owner, name: $repo) {\n pullRequest(number: $pr) {\n reviewThreads(first: 100) {\n nodes {\n id\n isResolved\n comments(first: 1) {\n nodes {\n databaseId\n body\n }\n }\n }\n }\n }\n }\n }\n";
158
+ export declare const RESOLVE_THREAD_MUTATION = "\n mutation ResolveThread($threadId: ID!) {\n resolveReviewThread(input: { threadId: $threadId }) {\n thread {\n isResolved\n }\n }\n }\n";
159
+ export declare const ADD_REPLY_MUTATION = "\n mutation AddThreadReply($threadId: ID!, $body: String!) {\n addPullRequestReviewThreadReply(\n input: { pullRequestReviewThreadId: $threadId, body: $body }\n ) {\n comment {\n id\n body\n }\n }\n }\n";
160
+ //# sourceMappingURL=inline-threads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-threads.d.ts","sourceRoot":"","sources":["../../src/core/inline-threads.ts"],"names":[],"mappings":"AA6BA,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,aAAa,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAA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