clud-bug 0.7.0-rc.2 → 0.7.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/data/canonical-v1.json +37 -0
- package/dist/cli/configure-github.d.ts +58 -0
- package/dist/cli/configure-github.d.ts.map +1 -0
- package/dist/cli/configure-github.js +242 -0
- package/dist/cli/configure-github.js.map +1 -0
- package/dist/cli/hooks.d.ts +51 -0
- package/dist/cli/hooks.d.ts.map +1 -0
- package/dist/cli/hooks.js +138 -0
- package/dist/cli/hooks.js.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +1 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +949 -35
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/post-check-run.d.ts +16 -0
- package/dist/cli/post-check-run.d.ts.map +1 -0
- package/dist/cli/post-check-run.js +93 -0
- package/dist/cli/post-check-run.js.map +1 -0
- package/dist/cli/review-prompt.d.ts +43 -0
- package/dist/cli/review-prompt.d.ts.map +1 -0
- package/dist/cli/review-prompt.js +287 -0
- package/dist/cli/review-prompt.js.map +1 -0
- package/dist/cli/skills.d.ts +7 -0
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +42 -2
- package/dist/cli/skills.js.map +1 -1
- package/dist/cli/update-notifier.d.ts +17 -0
- package/dist/cli/update-notifier.d.ts.map +1 -0
- package/dist/cli/update-notifier.js +88 -0
- package/dist/cli/update-notifier.js.map +1 -0
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +60 -11
- package/dist/cli/update.js.map +1 -1
- package/dist/core/auto-resolve.d.ts +235 -0
- package/dist/core/auto-resolve.d.ts.map +1 -0
- package/dist/core/auto-resolve.js +293 -0
- package/dist/core/auto-resolve.js.map +1 -0
- package/dist/core/budget-plan.d.ts +125 -0
- package/dist/core/budget-plan.d.ts.map +1 -0
- package/dist/core/budget-plan.js +211 -0
- package/dist/core/budget-plan.js.map +1 -0
- package/dist/core/check-verdict.d.ts +31 -0
- package/dist/core/check-verdict.d.ts.map +1 -0
- package/dist/core/check-verdict.js +66 -0
- package/dist/core/check-verdict.js.map +1 -0
- package/dist/core/configure-github.d.ts +179 -0
- package/dist/core/configure-github.d.ts.map +1 -0
- package/dist/core/configure-github.js +289 -0
- package/dist/core/configure-github.js.map +1 -0
- package/dist/core/design.d.ts +37 -0
- package/dist/core/design.d.ts.map +1 -0
- package/dist/core/design.js +47 -0
- package/dist/core/design.js.map +1 -0
- package/dist/core/diff-findings.d.ts +96 -0
- package/dist/core/diff-findings.d.ts.map +1 -0
- package/dist/core/diff-findings.js +261 -0
- package/dist/core/diff-findings.js.map +1 -0
- package/dist/core/formal-review.d.ts +79 -0
- package/dist/core/formal-review.d.ts.map +1 -0
- package/dist/core/formal-review.js +71 -0
- package/dist/core/formal-review.js.map +1 -0
- package/dist/core/index.d.ts +15 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +53 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/inline-threads.d.ts +160 -0
- package/dist/core/inline-threads.d.ts.map +1 -0
- package/dist/core/inline-threads.js +369 -0
- package/dist/core/inline-threads.js.map +1 -0
- package/dist/core/multi-pass-aggregate.d.ts +161 -0
- package/dist/core/multi-pass-aggregate.d.ts.map +1 -0
- package/dist/core/multi-pass-aggregate.js +457 -0
- package/dist/core/multi-pass-aggregate.js.map +1 -0
- package/dist/core/plan-review.d.ts +57 -0
- package/dist/core/plan-review.d.ts.map +1 -0
- package/dist/core/plan-review.js +77 -0
- package/dist/core/plan-review.js.map +1 -0
- package/dist/core/prompt-builder.d.ts +18 -0
- package/dist/core/prompt-builder.d.ts.map +1 -1
- package/dist/core/prompt-builder.js +24 -2
- package/dist/core/prompt-builder.js.map +1 -1
- package/dist/core/render.d.ts.map +1 -1
- package/dist/core/render.js +1 -19
- package/dist/core/render.js.map +1 -1
- package/dist/core/resolve-verifier.d.ts +53 -0
- package/dist/core/resolve-verifier.d.ts.map +1 -0
- package/dist/core/resolve-verifier.js +204 -0
- package/dist/core/resolve-verifier.js.map +1 -0
- package/dist/core/review-context.d.ts +39 -0
- package/dist/core/review-context.d.ts.map +1 -0
- package/dist/core/review-context.js +99 -0
- package/dist/core/review-context.js.map +1 -0
- package/dist/core/review-plan.d.ts +219 -0
- package/dist/core/review-plan.d.ts.map +1 -0
- package/dist/core/review-plan.js +274 -0
- package/dist/core/review-plan.js.map +1 -0
- package/dist/core/review-writeback.d.ts +74 -0
- package/dist/core/review-writeback.d.ts.map +1 -1
- package/dist/core/review-writeback.js +71 -4
- package/dist/core/review-writeback.js.map +1 -1
- package/dist/core/skills.d.ts +25 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +100 -4
- package/dist/core/skills.js.map +1 -1
- package/dist/core/version.d.ts +2 -0
- package/dist/core/version.d.ts.map +1 -0
- package/dist/core/version.js +4 -0
- package/dist/core/version.js.map +1 -0
- package/package.json +11 -5
- package/src/cli/configure-github.ts +329 -0
- package/src/cli/hooks.ts +155 -0
- package/src/cli/index.ts +6 -0
- package/src/cli/main.ts +1031 -37
- package/src/cli/post-check-run.ts +115 -0
- package/src/cli/review-prompt.ts +355 -0
- package/src/cli/skills.ts +42 -2
- package/src/cli/update-notifier.ts +100 -0
- package/src/cli/update.ts +60 -11
- package/src/core/auto-resolve.ts +488 -0
- package/src/core/budget-plan.ts +324 -0
- package/src/core/check-verdict.ts +93 -0
- package/src/core/configure-github.ts +497 -0
- package/src/core/design.ts +73 -0
- package/src/core/diff-findings.ts +323 -0
- package/src/core/formal-review.ts +168 -0
- package/src/core/index.ts +188 -0
- package/src/core/inline-threads.ts +471 -0
- package/src/core/multi-pass-aggregate.ts +591 -0
- package/src/core/plan-review.ts +136 -0
- package/src/core/prompt-builder.ts +44 -2
- package/src/core/render.ts +10 -16
- package/src/core/resolve-verifier.ts +254 -0
- package/src/core/review-context.ts +106 -0
- package/src/core/review-plan.ts +485 -0
- package/src/core/review-writeback.ts +161 -4
- package/src/core/skills.ts +128 -5
- package/src/core/version.ts +3 -0
- package/templates/clud-bug-review.md.tmpl +115 -0
- package/templates/skills/design/design-system-consistency.md +41 -0
- package/templates/skills/design/frontend-a11y.md +41 -0
- package/templates/skills/design/visual-polish.md +41 -0
- package/templates/workflow-py.yml.tmpl +92 -2
- package/templates/workflow-ts.yml.tmpl +92 -2
- package/templates/workflow.yml.tmpl +173 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-resolve.js","sourceRoot":"","sources":["../../src/core/auto-resolve.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,uEAAuE;AACvE,mEAAmE;AACnE,uDAAuD;AACvD,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,kEAAkE;AAClE,iEAAiE;AACjE,iFAAiF;AACjF,EAAE;AACF,gEAAgE;AAChE,uEAAuE;AACvE,mEAAmE;AACnE,kEAAkE;AAClE,qBAAqB;AACrB,EAAE;AACF,iEAAiE;AACjE,oEAAoE;AACpE,YAAY;AACZ,uEAAuE;AACvE,sEAAsE;AACtE,oEAAoE;AACpE,oEAAoE;AACpE,yCAAyC;AACzC,qEAAqE;AACrE,iEAAiE;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA0BzC,MAAM,CAAC,MAAM,2BAA2B,GAAsB;IAC5D,IAAI,EAAE,UAAU;IAChB,yBAAyB,EAAE,iBAAiB;CAC7C,CAAC;AA+FF,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CACtC,GAAY,EACZ,SAAgC,GAAG,EAAE,GAAE,CAAC;IAExC,MAAM,QAAQ,GAAG,2BAA2B,CAAC;IAC7C,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;Q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AM,CAAC,GAAG,IAAI,IAAI,IAAI,IAAI,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAChG,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAEC,EACD,UAAuB;IAEvB,IAAI,MAAM,GAAoD,IAAI,CAAC;IACnE,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,CAAC,CAAC;YAAE,SAAS;QACjB,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC;QACpC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,SAAS;QACrC,MAAM,GAAG,GAAG,qBAAqB,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAChD,IAAI,GAAG;YAAE,MAAM,GAAG,GAAG,CAAC;IACxB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { ResolvedReviewPasses } from './review-plan.js';
|
|
2
|
+
/**
|
|
3
|
+
* Default per-PR cap. Real number lives in `env.REVIEW_SPEND_CAP_USD` once
|
|
4
|
+
* D.4 wires that env var — for now this is the hard-coded ceiling.
|
|
5
|
+
*
|
|
6
|
+
* $5 = a 3-pass review across 10 expensive skills (~30 calls × $0.15 avg).
|
|
7
|
+
* Anything above that is almost certainly a misconfigured `reviewPasses`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_PER_PR_CAP_USD = 5;
|
|
10
|
+
export interface BudgetEstimateInput {
|
|
11
|
+
/** Resolved per-skill config — one entry per skill in the catalog. */
|
|
12
|
+
resolved: ResolvedReviewPasses[];
|
|
13
|
+
/** Model slugs the orchestrator plans to route to, in pass order. */
|
|
14
|
+
roleModels: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Optional per-PR USD cap override. Defaults to `DEFAULT_PER_PR_CAP_USD`.
|
|
17
|
+
* D.4 wires per-install caps via `INSTALLS:{id}.spend_cap_usd`.
|
|
18
|
+
*/
|
|
19
|
+
perPrCapUsd?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Installation flag — `billing === 'exempt'` orgs bypass the cap entirely.
|
|
22
|
+
* D.4 reads this from the install record. For D.2.5, the orchestrator
|
|
23
|
+
* passes the env-allowlist result here.
|
|
24
|
+
*/
|
|
25
|
+
billingExempt?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface BudgetEstimate {
|
|
28
|
+
/** Total AI calls = sum(skill_count × pass_count). */
|
|
29
|
+
estimatedCalls: number;
|
|
30
|
+
/** Worst-case cost in USD across all planned calls. */
|
|
31
|
+
estimatedCostUsd: number;
|
|
32
|
+
/** Per-call ceiling used (max across the role models). */
|
|
33
|
+
perCallCeilingUsd: number;
|
|
34
|
+
/** The cap the estimate was checked against. */
|
|
35
|
+
capUsd: number;
|
|
36
|
+
}
|
|
37
|
+
export type BudgetVerdict = {
|
|
38
|
+
verdict: 'allow';
|
|
39
|
+
estimate: BudgetEstimate;
|
|
40
|
+
} | {
|
|
41
|
+
verdict: 'deny';
|
|
42
|
+
estimate: BudgetEstimate;
|
|
43
|
+
/** Friendly reason for the orchestrator's "we paused this review" comment. */
|
|
44
|
+
reason: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Returns the per-call USD ceiling — max across the role models.
|
|
48
|
+
*/
|
|
49
|
+
export declare function perCallCeiling(models: string[]): number;
|
|
50
|
+
/**
|
|
51
|
+
* Layer-1 cost gate. Decides whether the planned passes fit under the cap.
|
|
52
|
+
*
|
|
53
|
+
* Behavior matrix:
|
|
54
|
+
* billingExempt = true → allow (skip cap entirely)
|
|
55
|
+
* estimatedCostUsd > cap → deny + friendly reason
|
|
56
|
+
* estimatedCostUsd <= cap → allow
|
|
57
|
+
* resolved.length === 0 → allow (single-pass D.2.0 path)
|
|
58
|
+
*
|
|
59
|
+
* Until D.4 wires real per-install spending, callers see allow on every
|
|
60
|
+
* normal path — the deny branch only fires on truly absurd estimates.
|
|
61
|
+
*/
|
|
62
|
+
export declare function estimateBudget(input: BudgetEstimateInput): BudgetVerdict;
|
|
63
|
+
/**
|
|
64
|
+
* Exposed for tests + future D.4 wiring. Lets callers register a cost
|
|
65
|
+
* ceiling for a newly-routed model without editing this module.
|
|
66
|
+
*/
|
|
67
|
+
export declare function __setModelCeilingForTests(model: string, usd: number | null): void;
|
|
68
|
+
/**
|
|
69
|
+
* Default per-PR budget for D.2.6 verifier calls. The spec calls $0.10 the
|
|
70
|
+
* "5 findings × 3 fix-pushes" ceiling; we use 2x that as the cap so a
|
|
71
|
+
* sufficiently-large PR (20 threads × 3 fix-pushes = 60 calls) still fits.
|
|
72
|
+
*
|
|
73
|
+
* D.4 will plumb per-install caps; for D.2.6 we use a single repo-wide
|
|
74
|
+
* default. Installs in BILLING_EXEMPT_ORGS bypass this entirely.
|
|
75
|
+
*/
|
|
76
|
+
export declare const DEFAULT_VERIFIER_PER_PR_CAP_USD = 0.6;
|
|
77
|
+
export interface VerifierBudgetInput {
|
|
78
|
+
/** Number of open threads we plan to verify on this fix-push. */
|
|
79
|
+
threadCount: number;
|
|
80
|
+
/**
|
|
81
|
+
* Pass count from D.2.5 multi-pass — we call the verifier once per pass
|
|
82
|
+
* per thread (see resolve-verifier integration doc). Defaults to 1
|
|
83
|
+
* for single-pass installs.
|
|
84
|
+
*/
|
|
85
|
+
passesPerThread?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Optional per-PR cap override. Defaults to DEFAULT_VERIFIER_PER_PR_CAP_USD.
|
|
88
|
+
*/
|
|
89
|
+
perPrCapUsd?: number;
|
|
90
|
+
/** BILLING_EXEMPT installs bypass the cap. */
|
|
91
|
+
billingExempt?: boolean;
|
|
92
|
+
}
|
|
93
|
+
export interface VerifierBudgetEstimate {
|
|
94
|
+
/** Total verifier AI calls = threadCount × passesPerThread. */
|
|
95
|
+
estimatedCalls: number;
|
|
96
|
+
/** Worst-case cost. */
|
|
97
|
+
estimatedCostUsd: number;
|
|
98
|
+
/** Per-call ceiling used. */
|
|
99
|
+
perCallCeilingUsd: number;
|
|
100
|
+
/** Cap checked against. */
|
|
101
|
+
capUsd: number;
|
|
102
|
+
}
|
|
103
|
+
export type VerifierBudgetVerdict = {
|
|
104
|
+
verdict: 'allow';
|
|
105
|
+
estimate: VerifierBudgetEstimate;
|
|
106
|
+
} | {
|
|
107
|
+
verdict: 'deny';
|
|
108
|
+
estimate: VerifierBudgetEstimate;
|
|
109
|
+
/** Friendly reason for the orchestrator's "skipped: verifier-budget" log. */
|
|
110
|
+
reason: string;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Pre-flight gate for the D.2.6 fix-verifier. Called once per fix-push,
|
|
114
|
+
* BEFORE any verifier call runs. If denied, the orchestrator emits
|
|
115
|
+
* `skipped: budget` for the entire auto-resolve cycle and routes the
|
|
116
|
+
* threads through the heuristic fallback (see auto-resolve).
|
|
117
|
+
*
|
|
118
|
+
* Behavior:
|
|
119
|
+
* billingExempt = true → allow (bypass cap)
|
|
120
|
+
* estimated > cap → deny
|
|
121
|
+
* threadCount === 0 → allow with 0 calls (no-op fix-push, no threads to verify)
|
|
122
|
+
* otherwise → allow
|
|
123
|
+
*/
|
|
124
|
+
export declare function estimateVerifierBudget(input: VerifierBudgetInput): VerifierBudgetVerdict;
|
|
125
|
+
//# sourceMappingURL=budget-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget-plan.d.ts","sourceRoot":"","sources":["../../src/core/budget-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AA6D7D;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,IAAM,CAAC;AAM1C,MAAM,WAAW,mBAAmB;IAClC,sEAAsE;IACtE,QAAQ,EAAE,oBAAoB,EAAE,CA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AAC;IACvB,uBAAuB;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,6BAA6B;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,qBAAqB,GAC7B;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,sBAAsB,CAAA;CAAE,GACtD;IACE,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,sBAAsB,CAAC;IACjC,6EAA6E;IAC7E,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEN;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,mBAAmB,GACzB,qBAAqB,CAwBvB"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layer 1 cost gate — pre-flight estimator for multi-pass review.
|
|
3
|
+
*
|
|
4
|
+
* D.2.5 introduces a cost multiplier — a 3-pass review of a 5-skill catalog
|
|
5
|
+
* is 15 AI calls instead of 5. Without a gate, a misconfigured `reviewPasses`
|
|
6
|
+
* block can quietly burn through the AI Gateway budget on a single PR. This
|
|
7
|
+
* module decides BEFORE any AI call whether the review is cheap enough to
|
|
8
|
+
* run, and if not, returns a structured "deny" verdict the orchestrator
|
|
9
|
+
* surfaces as a friendly comment.
|
|
10
|
+
*
|
|
11
|
+
* Two layers, only the first lands in D.2.5:
|
|
12
|
+
*
|
|
13
|
+
* - Layer 1 (this module): per-PR estimate. Sums `skill_loads × pass_count`
|
|
14
|
+
* to produce an `estimatedCalls` count and an `estimatedCostUsd`
|
|
15
|
+
* ceiling. If `estimatedCostUsd > cap`, we deny.
|
|
16
|
+
*
|
|
17
|
+
* - Layer 2 (D.4 — NOT in this module): per-install rolling spend. Reads
|
|
18
|
+
* `INSTALLS:{id}.spend_usd_30d` from Redis. D.4 wires the actual gating;
|
|
19
|
+
* here we just stub the interface.
|
|
20
|
+
*
|
|
21
|
+
* The gate is BEST-EFFORT, intentionally pessimistic. We over-estimate cost
|
|
22
|
+
* (worst-case tokens × highest-tier model) because the alternative is the
|
|
23
|
+
* customer eating a surprise bill. A 20% over-estimate that occasionally
|
|
24
|
+
* causes a "we paused; raise the cap" comment is the right failure mode.
|
|
25
|
+
*
|
|
26
|
+
* Until D.4 wires real per-install budgets, this module always returns
|
|
27
|
+
* `{ verdict: 'allow' }`. The implementation is intentionally complete so
|
|
28
|
+
* D.4 can flip a single switch without changing the orchestrator surface.
|
|
29
|
+
*/
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
// Constants — worst-case cost ceilings
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
/**
|
|
34
|
+
* Rough USD-per-call ceiling across the model tiers we route to.
|
|
35
|
+
*
|
|
36
|
+
* Numbers are deliberately over-stated — we'd rather deny a borderline
|
|
37
|
+
* review than blow past a billing cap. Reconciled monthly from the AI
|
|
38
|
+
* Gateway dashboard; the D.4 billing module replaces this with live data.
|
|
39
|
+
*
|
|
40
|
+
* Picking the max(model) across the roles array keeps the math local — we
|
|
41
|
+
* don't need per-pass attribution for the estimate, only for billing
|
|
42
|
+
* reconciliation later.
|
|
43
|
+
*/
|
|
44
|
+
const MODEL_CEILING_USD = {
|
|
45
|
+
'anthropic/claude-haiku-4.5': 0.02,
|
|
46
|
+
'anthropic/claude-sonnet-4.6': 0.08,
|
|
47
|
+
'anthropic/claude-opus-4.6': 0.4,
|
|
48
|
+
'anthropic/claude-opus-4.7': 0.5,
|
|
49
|
+
'openai/gpt-5': 0.4,
|
|
50
|
+
'openai/gpt-5.2': 0.04,
|
|
51
|
+
'google/gemini-3-flash': 0.02,
|
|
52
|
+
'google/gemini-3.1-pro-preview': 0.3,
|
|
53
|
+
};
|
|
54
|
+
/** Fallback ceiling for unknown model slugs. Conservative. */
|
|
55
|
+
const DEFAULT_PER_CALL_USD = 0.5;
|
|
56
|
+
/**
|
|
57
|
+
* Default per-PR cap. Real number lives in `env.REVIEW_SPEND_CAP_USD` once
|
|
58
|
+
* D.4 wires that env var — for now this is the hard-coded ceiling.
|
|
59
|
+
*
|
|
60
|
+
* $5 = a 3-pass review across 10 expensive skills (~30 calls × $0.15 avg).
|
|
61
|
+
* Anything above that is almost certainly a misconfigured `reviewPasses`.
|
|
62
|
+
*/
|
|
63
|
+
export const DEFAULT_PER_PR_CAP_USD = 5.0;
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
// Estimator
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
/**
|
|
68
|
+
* Returns the per-call USD ceiling — max across the role models.
|
|
69
|
+
*/
|
|
70
|
+
export function perCallCeiling(models) {
|
|
71
|
+
if (models.length === 0)
|
|
72
|
+
return DEFAULT_PER_CALL_USD;
|
|
73
|
+
let max = 0;
|
|
74
|
+
for (const m of models) {
|
|
75
|
+
const c = MODEL_CEILING_USD[m] ?? DEFAULT_PER_CALL_USD;
|
|
76
|
+
if (c > max)
|
|
77
|
+
max = c;
|
|
78
|
+
}
|
|
79
|
+
return max;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Layer-1 cost gate. Decides whether the planned passes fit under the cap.
|
|
83
|
+
*
|
|
84
|
+
* Behavior matrix:
|
|
85
|
+
* billingExempt = true → allow (skip cap entirely)
|
|
86
|
+
* estimatedCostUsd > cap → deny + friendly reason
|
|
87
|
+
* estimatedCostUsd <= cap → allow
|
|
88
|
+
* resolved.length === 0 → allow (single-pass D.2.0 path)
|
|
89
|
+
*
|
|
90
|
+
* Until D.4 wires real per-install spending, callers see allow on every
|
|
91
|
+
* normal path — the deny branch only fires on truly absurd estimates.
|
|
92
|
+
*/
|
|
93
|
+
export function estimateBudget(input) {
|
|
94
|
+
const cap = input.perPrCapUsd ?? DEFAULT_PER_PR_CAP_USD;
|
|
95
|
+
const ceiling = perCallCeiling(input.roleModels);
|
|
96
|
+
// The orchestrator (runMultiPass) sends all skills in a SINGLE prompt
|
|
97
|
+
// each pass and loops only the max skill's count times. Real call count
|
|
98
|
+
// is max(counts), not sum(counts). Summing over-estimates linearly with
|
|
99
|
+
// catalog size, making multi-pass unreachable for medium+ skill sets.
|
|
100
|
+
const calls = input.resolved.length === 0
|
|
101
|
+
? 0
|
|
102
|
+
: input.resolved.reduce((max, r) => Math.max(max, r.count), 0);
|
|
103
|
+
const cost = calls * ceiling;
|
|
104
|
+
const estimate = {
|
|
105
|
+
estimatedCalls: calls,
|
|
106
|
+
estimatedCostUsd: cost,
|
|
107
|
+
perCallCeilingUsd: ceiling,
|
|
108
|
+
capUsd: cap,
|
|
109
|
+
};
|
|
110
|
+
if (input.billingExempt) {
|
|
111
|
+
return { verdict: 'allow', estimate };
|
|
112
|
+
}
|
|
113
|
+
if (cost > cap) {
|
|
114
|
+
return {
|
|
115
|
+
verdict: 'deny',
|
|
116
|
+
estimate,
|
|
117
|
+
reason: friendlyDenyReason({ cost, cap, calls, ceiling }),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return { verdict: 'allow', estimate };
|
|
121
|
+
}
|
|
122
|
+
function friendlyDenyReason(args) {
|
|
123
|
+
return [
|
|
124
|
+
`clud-bug paused this review — estimated cost \`$${args.cost.toFixed(2)}\``,
|
|
125
|
+
`exceeds the per-PR cap of \`$${args.cap.toFixed(2)}\`.`,
|
|
126
|
+
`(${args.calls} planned AI call${args.calls === 1 ? '' : 's'} ×`,
|
|
127
|
+
`worst-case \`$${args.ceiling.toFixed(2)}\` per call.)`,
|
|
128
|
+
'Lower `reviewPasses.count` in `.claude/skills/.clud-bug.json` and re-trigger.',
|
|
129
|
+
].join(' ');
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Exposed for tests + future D.4 wiring. Lets callers register a cost
|
|
133
|
+
* ceiling for a newly-routed model without editing this module.
|
|
134
|
+
*/
|
|
135
|
+
export function __setModelCeilingForTests(model, usd) {
|
|
136
|
+
if (usd === null) {
|
|
137
|
+
delete MODEL_CEILING_USD[model];
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
MODEL_CEILING_USD[model] = usd;
|
|
141
|
+
}
|
|
142
|
+
// ---------------------------------------------------------------------------
|
|
143
|
+
// D.2.6 — auto-resolve verifier cost surface
|
|
144
|
+
// ---------------------------------------------------------------------------
|
|
145
|
+
/**
|
|
146
|
+
* Per-call ceiling for the D.2.6 fix-verifier. Each verifier call is small —
|
|
147
|
+
* ~500 token I/O at Sonnet rates — so a more aggressive ceiling makes sense
|
|
148
|
+
* vs the main-review per-call ceiling. We over-state by ~2x to keep the
|
|
149
|
+
* "$0.10 per PR with 5 findings × 3 fix-pushes" plan budget honest.
|
|
150
|
+
*
|
|
151
|
+
* Sonnet 4.6 at $3/$15 per million tokens × 500 token I/O ≈ $0.005;
|
|
152
|
+
* we use $0.01 as the gate ceiling so a borderline-overbudget verifier doesn't
|
|
153
|
+
* silently silently flip the install over the cap.
|
|
154
|
+
*/
|
|
155
|
+
const VERIFIER_PER_CALL_CEILING_USD = 0.01;
|
|
156
|
+
/**
|
|
157
|
+
* Default per-PR budget for D.2.6 verifier calls. The spec calls $0.10 the
|
|
158
|
+
* "5 findings × 3 fix-pushes" ceiling; we use 2x that as the cap so a
|
|
159
|
+
* sufficiently-large PR (20 threads × 3 fix-pushes = 60 calls) still fits.
|
|
160
|
+
*
|
|
161
|
+
* D.4 will plumb per-install caps; for D.2.6 we use a single repo-wide
|
|
162
|
+
* default. Installs in BILLING_EXEMPT_ORGS bypass this entirely.
|
|
163
|
+
*/
|
|
164
|
+
export const DEFAULT_VERIFIER_PER_PR_CAP_USD = 0.6;
|
|
165
|
+
/**
|
|
166
|
+
* Pre-flight gate for the D.2.6 fix-verifier. Called once per fix-push,
|
|
167
|
+
* BEFORE any verifier call runs. If denied, the orchestrator emits
|
|
168
|
+
* `skipped: budget` for the entire auto-resolve cycle and routes the
|
|
169
|
+
* threads through the heuristic fallback (see auto-resolve).
|
|
170
|
+
*
|
|
171
|
+
* Behavior:
|
|
172
|
+
* billingExempt = true → allow (bypass cap)
|
|
173
|
+
* estimated > cap → deny
|
|
174
|
+
* threadCount === 0 → allow with 0 calls (no-op fix-push, no threads to verify)
|
|
175
|
+
* otherwise → allow
|
|
176
|
+
*/
|
|
177
|
+
export function estimateVerifierBudget(input) {
|
|
178
|
+
const cap = input.perPrCapUsd ?? DEFAULT_VERIFIER_PER_PR_CAP_USD;
|
|
179
|
+
const passes = input.passesPerThread ?? 1;
|
|
180
|
+
const calls = input.threadCount * Math.max(1, passes);
|
|
181
|
+
const cost = calls * VERIFIER_PER_CALL_CEILING_USD;
|
|
182
|
+
const estimate = {
|
|
183
|
+
estimatedCalls: calls,
|
|
184
|
+
estimatedCostUsd: cost,
|
|
185
|
+
perCallCeilingUsd: VERIFIER_PER_CALL_CEILING_USD,
|
|
186
|
+
capUsd: cap,
|
|
187
|
+
};
|
|
188
|
+
if (input.billingExempt) {
|
|
189
|
+
return { verdict: 'allow', estimate };
|
|
190
|
+
}
|
|
191
|
+
if (cost > cap) {
|
|
192
|
+
return {
|
|
193
|
+
verdict: 'deny',
|
|
194
|
+
estimate,
|
|
195
|
+
reason: friendlyVerifierDenyReason({ cost, cap, calls }),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
return { verdict: 'allow', estimate };
|
|
199
|
+
}
|
|
200
|
+
function friendlyVerifierDenyReason(args) {
|
|
201
|
+
return [
|
|
202
|
+
`clud-bug paused D.2.6 fix-verification — estimated cost`,
|
|
203
|
+
`\`$${args.cost.toFixed(2)}\` exceeds the per-PR cap of`,
|
|
204
|
+
`\`$${args.cap.toFixed(2)}\`. (${args.calls} planned verifier call${args.calls === 1 ? '' : 's'} ×`,
|
|
205
|
+
`worst-case \`$${VERIFIER_PER_CALL_CEILING_USD.toFixed(2)}\` per call.)`,
|
|
206
|
+
'Lower `autoResolve.max_threads_per_fix_push` in',
|
|
207
|
+
'`.claude/skills/.clud-bug.json` or set `autoResolve.mode = "heuristic"`',
|
|
208
|
+
'to opt out of verified-mode for this install.',
|
|
209
|
+
].join(' ');
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=budget-plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget-plan.js","sourceRoot":"","sources":["../../src/core/budget-plan.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,8EAA8E;AAC9E,uCAAuC;AACvC,8EAA8E;AAE9E;;;;;;;;;;GAUG;AACH,MAAM,iBAAiB,GAA2B;IAChD,4BAA4B,EAAE,IAAI;IAClC,6BAA6B,EAAE,IAAI;IACnC,2BAA2B,EAAE,GAAG;IAChC,2BAA2B,EAAE,GAAG;IAChC,cAAc,EAAE,GAAG;IACnB,gBAAgB,EAAE,IAAI;IACtB,uBAAuB,EAAE,IAAI;IAC7B,+BAA+B,EAAE,GAAG;CACrC,CAAC;AAEF,8DAA8D;AAC9D,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AA+C1C,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,MAAgB;IAC7C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,oBAAoB,CAAC;IACrD,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,IAAI,oBAAoB,CAAC;QACvD,IAAI,CAAC,GAAG,GAAG;YAAE,GAAG,GAAG,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,GAAG,GAAG,KAAK,CAAC,WAAW,IAAI,sBAAsB,CAAC;IACxD,MAAM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O;YACL,OAAO,EAAE,MAAM;YACf,QAAQ;YACR,MAAM,EAAE,0BAA0B,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;SACzD,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AACxC,CAAC;AAED,SAAS,0BAA0B,CAAC,IAInC;IACC,OAAO;QACL,yDAAyD;QACzD,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,8BAA8B;QACxD,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,KAAK,yBAAyB,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI;QACnG,iBAAiB,6BAA6B,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;QACxE,iDAAiD;QACjD,yEAAyE;QACzE,+CAA+C;KAChD,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** The check name MUST match consumer branch-protection rules. Do not rename. */
|
|
2
|
+
export declare const CLUD_BUG_CHECK_NAME = "clud-bug-review";
|
|
3
|
+
/** Outcome of a review, as the posting surface sees it. */
|
|
4
|
+
export type ReviewVerdict = 'clean' | 'critical' | 'failed';
|
|
5
|
+
/** The narrowed check-run conclusion set we emit. */
|
|
6
|
+
export type CheckConclusion = 'success' | 'neutral' | 'failure';
|
|
7
|
+
/** Which surface attested the review (drives the title + trust note). */
|
|
8
|
+
export type CheckSource = 'local' | 'ci';
|
|
9
|
+
export interface DerivedCheck {
|
|
10
|
+
conclusion: CheckConclusion;
|
|
11
|
+
title: string;
|
|
12
|
+
summary: string;
|
|
13
|
+
}
|
|
14
|
+
export interface DeriveCheckInput {
|
|
15
|
+
verdict: ReviewVerdict;
|
|
16
|
+
/** `.clud-bug.json` strictMode at the BASE ref. Default false (advisory). */
|
|
17
|
+
strictMode?: boolean;
|
|
18
|
+
/** Number of critical findings (for the title). */
|
|
19
|
+
criticalCount?: number;
|
|
20
|
+
/** 'local' (self-attested in-session) or 'ci' (Action). Default 'ci'. */
|
|
21
|
+
source?: CheckSource;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Derive the `clud-bug-review` check conclusion + title/summary from a review
|
|
25
|
+
* verdict. Pure. A `local` source appends a self-attested trust note so a
|
|
26
|
+
* reviewer can tell an in-session attestation from an independent CI check.
|
|
27
|
+
*/
|
|
28
|
+
export declare function deriveCheck(input: DeriveCheckInput): DerivedCheck;
|
|
29
|
+
/** Normalize a free-form verdict string (CLI input) to a `ReviewVerdict`. */
|
|
30
|
+
export declare function normalizeVerdict(raw: string | undefined): ReviewVerdict;
|
|
31
|
+
//# sourceMappingURL=check-verdict.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-verdict.d.ts","sourceRoot":"","sources":["../../src/core/check-verdict.ts"],"names":[],"mappings":"AAkBA,iFAAiF;AACjF,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD,2DAA2D;AAC3D,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE5D,qDAAqD;AACrD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAEhE,yEAAyE;AACzE,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,IAAI,CAAC;AAEzC,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,eAAe,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,aAAa,CAAC;IACvB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mDAAmD;IACnD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yEAAyE;IACzE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,YAAY,CAkCjE;AAED,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa,CAIvE"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Merge-gate verdict → GitHub check-run conclusion (H3). Shared, pure brain so
|
|
2
|
+
// every surface that posts the `clud-bug-review` check derives the same
|
|
3
|
+
// conclusion from a review outcome.
|
|
4
|
+
//
|
|
5
|
+
// The check name is HARD-CODED `clud-bug-review` everywhere — consumers attach
|
|
6
|
+
// branch-protection rules by that exact string (see clud-bug-app/lib/check-runs.ts).
|
|
7
|
+
//
|
|
8
|
+
// CONCLUSION MODEL for the local + Action surfaces (this module):
|
|
9
|
+
// clean → success (review ran, no critical findings)
|
|
10
|
+
// critical + strict → failure (BLOCKS merge — fix the criticals)
|
|
11
|
+
// critical + !strict → neutral (advisory; does not block)
|
|
12
|
+
// failed → neutral (couldn't run; never blocks — add signal, not outages)
|
|
13
|
+
//
|
|
14
|
+
// This intentionally differs from the HOSTED bot, whose check is success-on-run
|
|
15
|
+
// and whose strict-mode block is a separate `request_changes` formal review. In
|
|
16
|
+
// local/Action mode there is no formal review, so the check IS the gate — its
|
|
17
|
+
// conclusion reflects the findings directly.
|
|
18
|
+
/** The check name MUST match consumer branch-protection rules. Do not rename. */
|
|
19
|
+
export const CLUD_BUG_CHECK_NAME = 'clud-bug-review';
|
|
20
|
+
/**
|
|
21
|
+
* Derive the `clud-bug-review` check conclusion + title/summary from a review
|
|
22
|
+
* verdict. Pure. A `local` source appends a self-attested trust note so a
|
|
23
|
+
* reviewer can tell an in-session attestation from an independent CI check.
|
|
24
|
+
*/
|
|
25
|
+
export function deriveCheck(input) {
|
|
26
|
+
const { verdict, strictMode = false, criticalCount = 0, source = 'ci' } = input;
|
|
27
|
+
const selfAttested = source === 'local'
|
|
28
|
+
? ' (self-attested by a local max-mode review in the author’s session — not an independent CI check)'
|
|
29
|
+
: '';
|
|
30
|
+
let conclusion;
|
|
31
|
+
let title;
|
|
32
|
+
let summary;
|
|
33
|
+
if (verdict === 'clean') {
|
|
34
|
+
conclusion = 'success';
|
|
35
|
+
title = 'clud-bug review — clean';
|
|
36
|
+
summary = `No critical findings.${selfAttested}`;
|
|
37
|
+
}
|
|
38
|
+
else if (verdict === 'critical') {
|
|
39
|
+
const n = criticalCount > 0 ? `${criticalCount} ` : '';
|
|
40
|
+
if (strictMode) {
|
|
41
|
+
conclusion = 'failure';
|
|
42
|
+
title = `clud-bug review — ${n}critical (blocking)`;
|
|
43
|
+
summary = `${n}critical finding(s); strict mode blocks merge until they are resolved.${selfAttested}`;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
conclusion = 'neutral';
|
|
47
|
+
title = `clud-bug review — ${n}critical (advisory)`;
|
|
48
|
+
summary = `${n}critical finding(s); advisory only (strict mode off) — does not block merge.${selfAttested}`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// failed — never block on our own inability to run.
|
|
53
|
+
conclusion = 'neutral';
|
|
54
|
+
title = 'clud-bug review — could not run';
|
|
55
|
+
summary = `The review could not complete; the PR is not blocked. Re-run to retry.${selfAttested}`;
|
|
56
|
+
}
|
|
57
|
+
return { conclusion, title, summary };
|
|
58
|
+
}
|
|
59
|
+
/** Normalize a free-form verdict string (CLI input) to a `ReviewVerdict`. */
|
|
60
|
+
export function normalizeVerdict(raw) {
|
|
61
|
+
if (raw === 'clean' || raw === 'critical' || raw === 'failed')
|
|
62
|
+
return raw;
|
|
63
|
+
// Unknown/empty → 'failed' (safe: neutral check, never a false-green).
|
|
64
|
+
return 'failed';
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=check-verdict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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AG,SAAS,CAAC;YACvB,KAAK,GAAG,qBAAqB,CAAC,qBAAqB,CAAC;YACpD,OAAO,GAAG,GAAG,CAAC,+EAA+E,YAAY,EAAE,CAAC;QAC9G,CAAC;IACH,CAAC;SAAM,CAAC;QACN,oDAAoD;QACpD,UAAU,GAAG,SAAS,CAAC;QACvB,KAAK,GAAG,iCAAiC,CAAC;QAC1C,OAAO,GAAG,yEAAyE,YAAY,EAAE,CAAC;IACpG,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACxC,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,gBAAgB,CAAC,GAAuB;IACtD,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,UAAU,IAAI,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IAC1E,uEAAuE;IACvE,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical-v1.json structure. Frozen at v1; major bumps require
|
|
3
|
+
* coordinated tool releases per the protocol repo's `$comment` field.
|
|
4
|
+
*/
|
|
5
|
+
export interface CanonicalRuleset {
|
|
6
|
+
version: 'v1';
|
|
7
|
+
spec_version: string;
|
|
8
|
+
branch_protection: {
|
|
9
|
+
required_status_checks: {
|
|
10
|
+
strict: boolean;
|
|
11
|
+
contexts: string[];
|
|
12
|
+
};
|
|
13
|
+
required_pull_request_reviews: {
|
|
14
|
+
required_approving_review_count: number;
|
|
15
|
+
dismiss_stale_reviews: boolean;
|
|
16
|
+
require_code_owner_reviews: boolean;
|
|
17
|
+
};
|
|
18
|
+
required_conversation_resolution: boolean;
|
|
19
|
+
enforce_admins: boolean;
|
|
20
|
+
allow_force_pushes: boolean;
|
|
21
|
+
allow_deletions: boolean;
|
|
22
|
+
required_linear_history: boolean;
|
|
23
|
+
allow_auto_merge: boolean;
|
|
24
|
+
delete_branch_on_merge: boolean;
|
|
25
|
+
squash_merge_commit_title: string;
|
|
26
|
+
squash_merge_commit_message: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Loads the bundled canonical-v1 ruleset from `data/canonical-v1.json`.
|
|
31
|
+
* Memoized so repeated calls don't re-hit the filesystem.
|
|
32
|
+
*
|
|
33
|
+
* Throws a wrapped error if the JSON file is missing — that's an
|
|
34
|
+
* install-time defect (package.json `files` excluded `data/`), not a
|
|
35
|
+
* runtime concern, and the loud failure surfaces it immediately.
|
|
36
|
+
*/
|
|
37
|
+
export declare function loadCanonicalV1(): Promise<CanonicalRuleset>;
|
|
38
|
+
/**
|
|
39
|
+
* Minimal structural Octokit interface — only the methods we actually call.
|
|
40
|
+
*
|
|
41
|
+
* We intentionally don't import `@octokit/rest` types: that would force
|
|
42
|
+
* every consumer (App, CLI, future tools) to install Octokit at runtime
|
|
43
|
+
* even when they pass a `gh`-CLI-backed adapter. Keeping the shape
|
|
44
|
+
* structural lets the CLI's `gh`-wrapping adapter satisfy it without
|
|
45
|
+
* pulling in a 200KB dep.
|
|
46
|
+
*
|
|
47
|
+
* If `@octokit/rest`'s real method shapes ever drift, the adapter +
|
|
48
|
+
* runtime call sites are the only files that need updating; the rule
|
|
49
|
+
* table here stays Octokit-version-agnostic.
|
|
50
|
+
*/
|
|
51
|
+
export interface OctokitLike {
|
|
52
|
+
repos: {
|
|
53
|
+
/** Read branch protection state. Throws on 404 (no protection rule). */
|
|
54
|
+
getBranchProtection(params: {
|
|
55
|
+
owner: string;
|
|
56
|
+
repo: string;
|
|
57
|
+
branch: string;
|
|
58
|
+
}): Promise<{
|
|
59
|
+
data: {
|
|
60
|
+
required_status_checks?: {
|
|
61
|
+
strict?: boolean;
|
|
62
|
+
contexts?: string[];
|
|
63
|
+
} | null;
|
|
64
|
+
required_pull_request_reviews?: {
|
|
65
|
+
required_approving_review_count?: number;
|
|
66
|
+
dismiss_stale_reviews?: boolean;
|
|
67
|
+
require_code_owner_reviews?: boolean;
|
|
68
|
+
} | null;
|
|
69
|
+
required_conversation_resolution?: {
|
|
70
|
+
enabled?: boolean;
|
|
71
|
+
} | null;
|
|
72
|
+
enforce_admins?: {
|
|
73
|
+
enabled?: boolean;
|
|
74
|
+
} | null;
|
|
75
|
+
allow_force_pushes?: {
|
|
76
|
+
enabled?: boolean;
|
|
77
|
+
} | null;
|
|
78
|
+
allow_deletions?: {
|
|
79
|
+
enabled?: boolean;
|
|
80
|
+
} | null;
|
|
81
|
+
required_linear_history?: {
|
|
82
|
+
enabled?: boolean;
|
|
83
|
+
} | null;
|
|
84
|
+
};
|
|
85
|
+
}>;
|
|
86
|
+
/** PUT branch protection (the REST API does NOT support PATCH). */
|
|
87
|
+
updateBranchProtection(params: {
|
|
88
|
+
owner: string;
|
|
89
|
+
repo: string;
|
|
90
|
+
branch: string;
|
|
91
|
+
required_status_checks: {
|
|
92
|
+
strict: boolean;
|
|
93
|
+
contexts: string[];
|
|
94
|
+
} | null;
|
|
95
|
+
enforce_admins: boolean | null;
|
|
96
|
+
required_pull_request_reviews: {
|
|
97
|
+
required_approving_review_count: number;
|
|
98
|
+
dismiss_stale_reviews: boolean;
|
|
99
|
+
require_code_owner_reviews: boolean;
|
|
100
|
+
} | null;
|
|
101
|
+
restrictions: null;
|
|
102
|
+
required_conversation_resolution?: boolean;
|
|
103
|
+
required_linear_history?: boolean;
|
|
104
|
+
allow_force_pushes?: boolean;
|
|
105
|
+
allow_deletions?: boolean;
|
|
106
|
+
}): Promise<unknown>;
|
|
107
|
+
/** Read repo-level settings (delete_branch_on_merge, allow_auto_merge, etc). */
|
|
108
|
+
get(params: {
|
|
109
|
+
owner: string;
|
|
110
|
+
repo: string;
|
|
111
|
+
}): Promise<{
|
|
112
|
+
data: {
|
|
113
|
+
delete_branch_on_merge?: boolean;
|
|
114
|
+
allow_auto_merge?: boolean;
|
|
115
|
+
squash_merge_commit_title?: string;
|
|
116
|
+
squash_merge_commit_message?: string;
|
|
117
|
+
};
|
|
118
|
+
}>;
|
|
119
|
+
/** PATCH repo-level settings. */
|
|
120
|
+
update(params: {
|
|
121
|
+
owner: string;
|
|
122
|
+
repo: string;
|
|
123
|
+
delete_branch_on_merge?: boolean;
|
|
124
|
+
allow_auto_merge?: boolean;
|
|
125
|
+
squash_merge_commit_title?: string;
|
|
126
|
+
squash_merge_commit_message?: string;
|
|
127
|
+
}): Promise<unknown>;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export interface ApplyCanonicalRulesetParams {
|
|
131
|
+
owner: string;
|
|
132
|
+
repo: string;
|
|
133
|
+
/**
|
|
134
|
+
* Target branch (default: `main`). Most consumers will use `main`; this
|
|
135
|
+
* is exposed for downstream tools that converge non-`main` defaults.
|
|
136
|
+
*/
|
|
137
|
+
branch?: string;
|
|
138
|
+
/**
|
|
139
|
+
* The ruleset to apply. Defaults to the bundled `canonical-v1.json`
|
|
140
|
+
* (loaded via `loadCanonicalV1()` if absent). Future v2 callers pass
|
|
141
|
+
* an explicit ruleset; the type system pins the shape.
|
|
142
|
+
*/
|
|
143
|
+
ruleset?: CanonicalRuleset;
|
|
144
|
+
/**
|
|
145
|
+
* If true, compute diff only and skip all PATCH calls. The result still
|
|
146
|
+
* reports `changes: string[]` so the CLI can render the human-readable
|
|
147
|
+
* diff before applying.
|
|
148
|
+
*/
|
|
149
|
+
dryRun?: boolean;
|
|
150
|
+
}
|
|
151
|
+
export interface ApplyResult {
|
|
152
|
+
/** Human-readable diff lines, one per detected difference. Empty when alreadyCanonical. */
|
|
153
|
+
changes: string[];
|
|
154
|
+
/** True when the live state already matches every canonical setting. */
|
|
155
|
+
alreadyCanonical: boolean;
|
|
156
|
+
/** Schema version applied (always 'canonical-v1' for this build). */
|
|
157
|
+
ruleset: 'canonical-v1';
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Applies the canonical ruleset to a GitHub repo. Reads current state via
|
|
161
|
+
* the Octokit-like instance, diffs against `ruleset` (default
|
|
162
|
+
* `CANONICAL_V1`), and PATCHes only what differs. Idempotent: second call
|
|
163
|
+
* returns `alreadyCanonical: true` with no PATCH side effects.
|
|
164
|
+
*
|
|
165
|
+
* Behavior on partial mismatch:
|
|
166
|
+
*
|
|
167
|
+
* - `required_status_checks.contexts`: canonical contexts that are
|
|
168
|
+
* missing get added; extra contexts on the repo are preserved (superset
|
|
169
|
+
* contract — a repo that runs more CI gates legitimately needs them).
|
|
170
|
+
* - `required_approving_review_count`: canonical floor is 1; if the repo
|
|
171
|
+
* already requires more, we don't lower (raise-only contract).
|
|
172
|
+
* - All booleans (allow_force_pushes, allow_deletions, etc.): converge
|
|
173
|
+
* to the canonical value exactly.
|
|
174
|
+
*
|
|
175
|
+
* Throws on Octokit transport failure (auth, network, 403). The CLI
|
|
176
|
+
* wraps these with a friendly error message.
|
|
177
|
+
*/
|
|
178
|
+
export declare function applyCanonicalRuleset(octokit: OctokitLike, params: ApplyCanonicalRulesetParams): Promise<ApplyResult>;
|
|
179
|
+
//# sourceMappingURL=configure-github.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure-github.d.ts","sourceRoot":"","sources":["../../src/core/configure-github.ts"],"names":[],"mappings":"AA+CA;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,IAAI,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE;QACjB,sBAAsB,EAAE;YACtB,MAAM,EAAE,OAAO,CAAC;YAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;SACpB,CAAC;QACF,6BAA6B,EAAE;YAC7B,+BAA+B,EAAE,MAAM,CAAC;YACxC,qBAAqB,EAAE,OAAO,CAAC;YAC/B,0BAA0B,EAAE,OAAO,CAAC;SACrC,CAAC;QACF,gCAAgC,EAAE,OAAO,CAAC;QAC1C,cAAc,EAAE,OAAO,CAAC;QACxB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,eAAe,EAAE,OAAO,CAAC;QACzB,uBAAuB,EAAE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