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
package/README.md
CHANGED
|
@@ -257,6 +257,26 @@ Every Clud Bug review opens with a status line that tells you exactly what chang
|
|
|
257
257
|
|
|
258
258
|
Same format every time; zero values are always present so the line is easy to scan and parse.
|
|
259
259
|
|
|
260
|
+
### Auto-resolving review threads (optional PAT)
|
|
261
|
+
|
|
262
|
+
When you push a fix, Clud Bug re-checks each open review thread and, if it verifies the fix
|
|
263
|
+
landed, posts a **✅ Verified fixed** reply on that thread.
|
|
264
|
+
|
|
265
|
+
**Closing the thread automatically is optional.** GitHub doesn't let the built-in Actions
|
|
266
|
+
`GITHUB_TOKEN` resolve review threads, so by default Clud Bug posts the "verified fixed"
|
|
267
|
+
reply and you click **Resolve conversation** to dismiss it — no errors, nothing fails.
|
|
268
|
+
|
|
269
|
+
To have Clud Bug close verified threads for you (matching the hosted App):
|
|
270
|
+
|
|
271
|
+
1. Create a **fine-grained personal access token** scoped to this repo with **Pull
|
|
272
|
+
requests: write**.
|
|
273
|
+
2. Add it as a repository secret named **`CLUD_BUG_RESOLVE_PAT`** (Settings → Secrets and
|
|
274
|
+
variables → Actions → New repository secret).
|
|
275
|
+
|
|
276
|
+
The next fix-push then auto-closes verified threads. Without the secret everything still
|
|
277
|
+
works; threads just wait for a manual Resolve. The reply is idempotent — re-pushes that
|
|
278
|
+
don't change the code won't re-post, so the thread never gets spammed.
|
|
279
|
+
|
|
260
280
|
## Manual install (advanced)
|
|
261
281
|
|
|
262
282
|
If you don't want to use the CLI, you can install a generic workflow by hand:
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "Canonical branch protection ruleset for SkDD-conformant repos. Applied by `logmind init --configure-github`, `clud-bug init --configure-github`, and `reporulez`. Implements thrillmade/protocol SPEC §7. Schema-locked at v1; major bumps require coordinated tool releases.",
|
|
3
|
+
"version": "v1",
|
|
4
|
+
"spec_version": "0.1.2",
|
|
5
|
+
"branch_protection": {
|
|
6
|
+
"required_status_checks": {
|
|
7
|
+
"strict": true,
|
|
8
|
+
"contexts": [
|
|
9
|
+
"clud-bug-review",
|
|
10
|
+
"check-decisions",
|
|
11
|
+
"check-derived-docs",
|
|
12
|
+
"check-links",
|
|
13
|
+
"test"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
"required_pull_request_reviews": {
|
|
17
|
+
"required_approving_review_count": 1,
|
|
18
|
+
"dismiss_stale_reviews": false,
|
|
19
|
+
"require_code_owner_reviews": false
|
|
20
|
+
},
|
|
21
|
+
"required_conversation_resolution": true,
|
|
22
|
+
"enforce_admins": false,
|
|
23
|
+
"allow_force_pushes": false,
|
|
24
|
+
"allow_deletions": false,
|
|
25
|
+
"required_linear_history": false,
|
|
26
|
+
"allow_auto_merge": true,
|
|
27
|
+
"delete_branch_on_merge": true,
|
|
28
|
+
"squash_merge_commit_title": "PR_TITLE",
|
|
29
|
+
"squash_merge_commit_message": "PR_BODY"
|
|
30
|
+
},
|
|
31
|
+
"$notes": {
|
|
32
|
+
"required_approving_review_count": "1 — auto-satisfied by clud-bug[bot]'s APPROVE vote on clean reviews for org-member PRs (per SPEC §7.2.1). External-contributor PRs still need a human reviewer because the bot's APPROVE on first-time contributors is policy-gated. Repo-owners MAY raise above 1; tools MUST NOT lower below 1.",
|
|
33
|
+
"enforce_admins": "false so maintainers can land hotfixes outside the gate; the dogfood discipline expects this only for genuine emergencies (clud-bug review still runs but doesn't block)",
|
|
34
|
+
"contexts": "the four logmind workflow check names + clud-bug-review + a generic 'tests' context. Repos may add more, but MUST keep these. If a context name is renamed in workflow YAML, update the ruleset.",
|
|
35
|
+
"required_conversation_resolution": "true is the dogfood-defining rule: clud-bug findings must be resolved before merge"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { loadCanonicalV1, type OctokitLike } from '../core/configure-github.js';
|
|
2
|
+
export interface RunConfigureGithubOptions {
|
|
3
|
+
/** "owner/repo" target — required. */
|
|
4
|
+
target?: string | null;
|
|
5
|
+
/** Target branch (default `main`). */
|
|
6
|
+
branch?: string;
|
|
7
|
+
/** Render diff only; skip PATCH calls. */
|
|
8
|
+
dryRun?: boolean;
|
|
9
|
+
/** Suppress progress chatter; emit only the final `ok` summary. */
|
|
10
|
+
quiet?: boolean;
|
|
11
|
+
/** Emit the SPEC §3.23.1 status payload as JSON instead of key-colon-value. */
|
|
12
|
+
json?: boolean;
|
|
13
|
+
/** Resolver for the GitHub token (tests pass a stub). */
|
|
14
|
+
resolveToken?: () => Promise<string | null>;
|
|
15
|
+
/** Octokit factory (tests inject a fake; defaults to the gh-adapter). */
|
|
16
|
+
octokitFactory?: (token: string) => OctokitLike;
|
|
17
|
+
/** Stdout writer (tests capture). */
|
|
18
|
+
stdout?: (msg: string) => void;
|
|
19
|
+
/** Stderr writer (tests capture). */
|
|
20
|
+
stderr?: (msg: string) => void;
|
|
21
|
+
}
|
|
22
|
+
/** Resolved outcome of a configure-github run, for the §3.23.1 status payload. */
|
|
23
|
+
export interface ConfigureSummary {
|
|
24
|
+
owner: string;
|
|
25
|
+
repo: string;
|
|
26
|
+
/** True when the repo already matches canonical-v1 (idempotent no-op). */
|
|
27
|
+
alreadyCanonical: boolean;
|
|
28
|
+
/** True when this was a --dry-run (no PATCH calls made). */
|
|
29
|
+
dryRun: boolean;
|
|
30
|
+
/** Number of changes (applied, or pending for dry-run; 0 for a no-op). */
|
|
31
|
+
changes: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* SPEC §3.23.1 (NORMATIVE): emit a single-line status payload carrying
|
|
35
|
+
* `alreadyCanonical` + `rulesetVersion` as named fields — JSON for machine
|
|
36
|
+
* consumption, key-colon-value for humans.
|
|
37
|
+
*/
|
|
38
|
+
export declare function formatConfigureSummary(summary: ConfigureSummary, json: boolean): string;
|
|
39
|
+
/**
|
|
40
|
+
* Entry point — wired into `clud-bug.js` dispatch. Returns a Node-style
|
|
41
|
+
* exit code so the dispatcher can `process.exit()` deterministically. We
|
|
42
|
+
* don't call `process.exit` ourselves so tests can drive the function
|
|
43
|
+
* without taking down the harness.
|
|
44
|
+
*/
|
|
45
|
+
export declare function runConfigureGithub(options: RunConfigureGithubOptions): Promise<number>;
|
|
46
|
+
/**
|
|
47
|
+
* Builds an `OctokitLike` instance backed by `gh api` shell-outs. This
|
|
48
|
+
* lets us satisfy the structural interface without pulling in
|
|
49
|
+
* `@octokit/rest` as a runtime dep (~200KB). The App passes its real
|
|
50
|
+
* Octokit instance instead.
|
|
51
|
+
*/
|
|
52
|
+
export declare function ghCliOctokit(token: string): OctokitLike;
|
|
53
|
+
/**
|
|
54
|
+
* Re-exported so callers can preload the ruleset (e.g. for a `--show-ruleset`
|
|
55
|
+
* flag in future). Currently exists for parity with the App's pattern.
|
|
56
|
+
*/
|
|
57
|
+
export { loadCanonicalV1 };
|
|
58
|
+
//# sourceMappingURL=configure-github.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure-github.d.ts","sourceRoot":"","sources":["../../src/cli/configure-github.ts"],"names":[],"mappings":"AAwBA,OAAO,EAEL,eAAe,EACf,KAAK,WAAW,EAEjB,MAAM,6BAA6B,CAAC;AAErC,MAAM,WAAW,yBAAyB;IACxC,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mEAAmE;IACnE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,+EAA+E;IAC/E,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC5C,yEAAyE;IACzE,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,CAAC;IAChD,qCAAqC;IACrC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,qCAAqC;IACrC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAwBD,kFAAkF;AAClF,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,gBAAgB,EAAE,OAAO,CAAC;IAC1B,4DAA4D;IAC5D,MAAM,EAAE,OAAO,CAAC;IAChB,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAevF;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,MAAM,CAAC,CAwFjB;AAkBD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAyFvD;AAOD;;;GAGG;AACH,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
// `clud-bug configure-github` CLI command — applies the SPEC §7 canonical
|
|
2
|
+
// branch protection ruleset to a target repo.
|
|
3
|
+
//
|
|
4
|
+
// External users installing the App expect "best practice branch protection"
|
|
5
|
+
// applied automatically. This command lets them opt in offline + dry-run
|
|
6
|
+
// safely BEFORE the App's auto-setup runs server-side. Same core logic
|
|
7
|
+
// powers both paths (the App imports `applyCanonicalRuleset` from
|
|
8
|
+
// clud-bug/core; this CLI passes a `gh api`-wrapping adapter so users
|
|
9
|
+
// don't need `@octokit/rest` on their machine).
|
|
10
|
+
//
|
|
11
|
+
// Usage:
|
|
12
|
+
//
|
|
13
|
+
// clud-bug configure-github <owner>/<repo>
|
|
14
|
+
// clud-bug configure-github <owner>/<repo> --dry-run
|
|
15
|
+
// clud-bug configure-github <owner>/<repo> --branch develop
|
|
16
|
+
//
|
|
17
|
+
// Auth ladder:
|
|
18
|
+
//
|
|
19
|
+
// 1. `GITHUB_TOKEN` env var (CI-friendly, no `gh` install required)
|
|
20
|
+
// 2. `gh auth token` (developer workstation default)
|
|
21
|
+
//
|
|
22
|
+
// If neither produces a token, exits 1 with a recovery message.
|
|
23
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
24
|
+
import { applyCanonicalRuleset, loadCanonicalV1, } from '../core/configure-github.js';
|
|
25
|
+
const HELP = `clud-bug configure-github — apply SPEC §7 canonical branch protection.
|
|
26
|
+
|
|
27
|
+
Usage:
|
|
28
|
+
clud-bug configure-github <owner>/<repo> [options]
|
|
29
|
+
|
|
30
|
+
Options:
|
|
31
|
+
--dry-run Compute diff and print it, but do NOT call PATCH endpoints.
|
|
32
|
+
--branch <name> Target branch (default: main).
|
|
33
|
+
--quiet,-q Suppress progress chatter; emit only the final summary.
|
|
34
|
+
--json Emit the status payload as JSON (machine consumption).
|
|
35
|
+
--help,-h Show this help.
|
|
36
|
+
|
|
37
|
+
Auth (resolved in order):
|
|
38
|
+
1. GITHUB_TOKEN env var (CI-friendly)
|
|
39
|
+
2. \`gh auth token\` (developer workstation)
|
|
40
|
+
|
|
41
|
+
Exit codes:
|
|
42
|
+
0 success or already-canonical
|
|
43
|
+
1 auth missing, PATCH error, or unrecoverable transport failure
|
|
44
|
+
2 CLI usage error (missing target, bad flag)
|
|
45
|
+
`;
|
|
46
|
+
/**
|
|
47
|
+
* SPEC §3.23.1 (NORMATIVE): emit a single-line status payload carrying
|
|
48
|
+
* `alreadyCanonical` + `rulesetVersion` as named fields — JSON for machine
|
|
49
|
+
* consumption, key-colon-value for humans.
|
|
50
|
+
*/
|
|
51
|
+
export function formatConfigureSummary(summary, json) {
|
|
52
|
+
const { owner, repo, alreadyCanonical, dryRun, changes } = summary;
|
|
53
|
+
if (json) {
|
|
54
|
+
return (JSON.stringify({ owner, repo, alreadyCanonical, rulesetVersion: 'v1', dryRun, changes }) + '\n');
|
|
55
|
+
}
|
|
56
|
+
if (alreadyCanonical) {
|
|
57
|
+
return `ok configure-github: owner: ${owner} repo: ${repo} alreadyCanonical: true rulesetVersion: v1\n`;
|
|
58
|
+
}
|
|
59
|
+
const plural = changes === 1 ? '' : 's';
|
|
60
|
+
if (dryRun) {
|
|
61
|
+
return `ok configure-github: dry-run on ${owner}/${repo} — ${changes} change${plural} pending\n`;
|
|
62
|
+
}
|
|
63
|
+
return `ok configure-github: ${owner}/${repo} converged to canonical-v1 (${changes} change${plural})\n`;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Entry point — wired into `clud-bug.js` dispatch. Returns a Node-style
|
|
67
|
+
* exit code so the dispatcher can `process.exit()` deterministically. We
|
|
68
|
+
* don't call `process.exit` ourselves so tests can drive the function
|
|
69
|
+
* without taking down the harness.
|
|
70
|
+
*/
|
|
71
|
+
export async function runConfigureGithub(options) {
|
|
72
|
+
const { target, branch = 'main', dryRun = false, quiet = false, json = false, resolveToken = defaultResolveToken, octokitFactory = ghCliOctokit, stdout = (msg) => process.stdout.write(msg), stderr = (msg) => process.stderr.write(msg), } = options;
|
|
73
|
+
if (!target) {
|
|
74
|
+
stderr(HELP);
|
|
75
|
+
return 2;
|
|
76
|
+
}
|
|
77
|
+
const match = /^([^/]+)\/([^/]+)$/.exec(target);
|
|
78
|
+
if (!match) {
|
|
79
|
+
stderr(`clud-bug configure-github: target must be in owner/repo form, got "${target}".\n`);
|
|
80
|
+
return 2;
|
|
81
|
+
}
|
|
82
|
+
const [, owner, repo] = match;
|
|
83
|
+
const token = await resolveToken();
|
|
84
|
+
if (!token) {
|
|
85
|
+
stderr('clud-bug configure-github: no GitHub token found.\n' +
|
|
86
|
+
' Set GITHUB_TOKEN, or install + auth gh: brew install gh && gh auth login\n');
|
|
87
|
+
return 1;
|
|
88
|
+
}
|
|
89
|
+
if (!quiet) {
|
|
90
|
+
stdout(`\u{1F41B} configure-github: applying canonical-v1 ruleset to ${owner}/${repo} (branch=${branch})\n`);
|
|
91
|
+
}
|
|
92
|
+
// Single-call orchestration: the CLI previously called
|
|
93
|
+
// applyCanonicalRuleset twice in apply mode (dry-run first to display the
|
|
94
|
+
// planned changes, then a real call to apply). That two-read pattern
|
|
95
|
+
// opened a TOCTOU window — concurrent changes between the two reads
|
|
96
|
+
// could make the displayed list diverge from the actually-applied list,
|
|
97
|
+
// and the dry-run cost a redundant API round-trip every time. Drop the
|
|
98
|
+
// preview-first read: pass `dryRun` straight through. The function's
|
|
99
|
+
// idempotency contract (returns `alreadyCanonical: true` + empty changes
|
|
100
|
+
// on a no-op) means we don't need a separate "look before you leap"
|
|
101
|
+
// call. Users who want preview semantics run `--dry-run` first as a
|
|
102
|
+
// distinct invocation — idiomatic CLI behavior. Surfaced by PR #166
|
|
103
|
+
// reviewer (CTO follow-up 2026-06-17).
|
|
104
|
+
const octokit = octokitFactory(token);
|
|
105
|
+
let result;
|
|
106
|
+
try {
|
|
107
|
+
result = await applyCanonicalRuleset(octokit, {
|
|
108
|
+
owner,
|
|
109
|
+
repo,
|
|
110
|
+
branch,
|
|
111
|
+
dryRun,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
stderr(`clud-bug configure-github: ${dryRun ? 'failed to read current state' : 'PATCH failed'}: ${stringifyError(err)}\n`);
|
|
116
|
+
return 1;
|
|
117
|
+
}
|
|
118
|
+
if (result.alreadyCanonical) {
|
|
119
|
+
if (!quiet)
|
|
120
|
+
stdout(' No changes — repo already matches canonical-v1.\n');
|
|
121
|
+
stdout(formatConfigureSummary({ owner, repo, alreadyCanonical: true, dryRun, changes: 0 }, json));
|
|
122
|
+
return 0;
|
|
123
|
+
}
|
|
124
|
+
if (!quiet) {
|
|
125
|
+
const verb = dryRun ? 'Planned' : 'Applied';
|
|
126
|
+
stdout(` ${verb} changes (${result.changes.length}):\n`);
|
|
127
|
+
for (const c of result.changes)
|
|
128
|
+
stdout(` - ${c}\n`);
|
|
129
|
+
}
|
|
130
|
+
if (dryRun) {
|
|
131
|
+
stdout(formatConfigureSummary({ owner, repo, alreadyCanonical: false, dryRun: true, changes: result.changes.length }, json));
|
|
132
|
+
return 0;
|
|
133
|
+
}
|
|
134
|
+
stdout(formatConfigureSummary({ owner, repo, alreadyCanonical: false, dryRun: false, changes: result.changes.length }, json));
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Auth ladder: env var first, then `gh auth token`. Surfaces a token
|
|
139
|
+
* string on success or `null` if neither source has one (caller prints
|
|
140
|
+
* the recovery hint).
|
|
141
|
+
*/
|
|
142
|
+
async function defaultResolveToken() {
|
|
143
|
+
const fromEnv = process.env.GITHUB_TOKEN?.trim();
|
|
144
|
+
if (fromEnv)
|
|
145
|
+
return fromEnv;
|
|
146
|
+
const result = spawnSync('gh', ['auth', 'token'], { encoding: 'utf8' });
|
|
147
|
+
if (result.status === 0) {
|
|
148
|
+
const tok = result.stdout.trim();
|
|
149
|
+
if (tok)
|
|
150
|
+
return tok;
|
|
151
|
+
}
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Builds an `OctokitLike` instance backed by `gh api` shell-outs. This
|
|
156
|
+
* lets us satisfy the structural interface without pulling in
|
|
157
|
+
* `@octokit/rest` as a runtime dep (~200KB). The App passes its real
|
|
158
|
+
* Octokit instance instead.
|
|
159
|
+
*/
|
|
160
|
+
export function ghCliOctokit(token) {
|
|
161
|
+
// We pass GITHUB_TOKEN through the spawn env so gh's API surface picks
|
|
162
|
+
// it up consistently whether the user supplied env or gh auth.
|
|
163
|
+
const env = { ...process.env, GITHUB_TOKEN: token };
|
|
164
|
+
function ghApi(method, path, body) {
|
|
165
|
+
return new Promise((resolve, reject) => {
|
|
166
|
+
const args = ['api', '-X', method];
|
|
167
|
+
if (body !== undefined) {
|
|
168
|
+
args.push('--input', '-');
|
|
169
|
+
}
|
|
170
|
+
args.push(path);
|
|
171
|
+
// Add an Accept header so 404s return the structured error, not a
|
|
172
|
+
// friendlier shell hint. The wrapping err.message detection in
|
|
173
|
+
// `isBranchNotProtected` keys on the structured form.
|
|
174
|
+
args.push('-H', 'Accept: application/vnd.github+json');
|
|
175
|
+
const child = spawn('gh', args, {
|
|
176
|
+
env,
|
|
177
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
178
|
+
});
|
|
179
|
+
let stdout = '';
|
|
180
|
+
let stderr = '';
|
|
181
|
+
child.stdout.on('data', (d) => {
|
|
182
|
+
stdout += d.toString();
|
|
183
|
+
});
|
|
184
|
+
child.stderr.on('data', (d) => {
|
|
185
|
+
stderr += d.toString();
|
|
186
|
+
});
|
|
187
|
+
child.on('error', reject);
|
|
188
|
+
child.on('close', (code) => {
|
|
189
|
+
if (code !== 0) {
|
|
190
|
+
const httpMatch = /HTTP (\d{3})/.exec(stderr);
|
|
191
|
+
const status = httpMatch ? Number(httpMatch[1]) : undefined;
|
|
192
|
+
const err = new Error((stderr.trim() || stdout.trim() || `gh api exited ${code}`).slice(0, 500));
|
|
193
|
+
if (status !== undefined)
|
|
194
|
+
err.status = status;
|
|
195
|
+
reject(err);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
resolve(stdout ? JSON.parse(stdout) : {});
|
|
200
|
+
}
|
|
201
|
+
catch (parseErr) {
|
|
202
|
+
reject(parseErr);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
if (body !== undefined) {
|
|
206
|
+
child.stdin.end(JSON.stringify(body));
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
child.stdin.end();
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
repos: {
|
|
215
|
+
async getBranchProtection({ owner, repo, branch }) {
|
|
216
|
+
const data = await ghApi('GET', `/repos/${owner}/${repo}/branches/${branch}/protection`);
|
|
217
|
+
return { data: data };
|
|
218
|
+
},
|
|
219
|
+
async updateBranchProtection({ owner, repo, branch, ...rest }) {
|
|
220
|
+
return ghApi('PUT', `/repos/${owner}/${repo}/branches/${branch}/protection`, rest);
|
|
221
|
+
},
|
|
222
|
+
async get({ owner, repo }) {
|
|
223
|
+
const data = await ghApi('GET', `/repos/${owner}/${repo}`);
|
|
224
|
+
return { data: data };
|
|
225
|
+
},
|
|
226
|
+
async update({ owner, repo, ...rest }) {
|
|
227
|
+
return ghApi('PATCH', `/repos/${owner}/${repo}`, rest);
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function stringifyError(err) {
|
|
233
|
+
if (err instanceof Error)
|
|
234
|
+
return err.message;
|
|
235
|
+
return String(err);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Re-exported so callers can preload the ruleset (e.g. for a `--show-ruleset`
|
|
239
|
+
* flag in future). Currently exists for parity with the App's pattern.
|
|
240
|
+
*/
|
|
241
|
+
export { loadCanonicalV1 };
|
|
242
|
+
//# sourceMappingURL=configure-github.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure-github.js","sourceRoot":"","sources":["../../src/cli/configure-github.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,8CAA8C;AAC9C,EAAE;AACF,6EAA6E;AAC7E,yEAAyE;AACzE,uEAAuE;AACvE,kEAAkE;AAClE,sEAAsE;AACtE,gDAAgD;AAChD,EAAE;AACF,SAAS;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AE,IAAI,EAAE,IAAgE,EAAE,CAAC;YACpF,CAAC;YACD,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE;gBACnC,OAAO,KAAK,CAAC,OAAO,EAAE,UAAU,KAAK,IAAI,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;YACzD,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,GAAY;IAClC,IAAI,GAAG,YAAY,KAAK;QAAE,OAAO,GAAG,CAAC,OAAO,CAAC;IAC7C,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC;AAED;;;GAGG;AACH,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Stable marker embedded in our hook so re-runs — and upgrades from the old,
|
|
2
|
+
* broken `type: agent` hook — replace it in place. */
|
|
3
|
+
export declare const CLUD_BUG_HOOK_MARKER = "clud-bug-local-review";
|
|
4
|
+
/**
|
|
5
|
+
* Build the shell `command` of the commit-review hook. Pins to a FLOATING npm
|
|
6
|
+
* dist-tag (`next` by default) rather than an exact version, so every repo's hook
|
|
7
|
+
* auto-fetches the latest review recipe — no per-release re-pin rollout. (The
|
|
8
|
+
* original exact-pin guarded against a `latest` that predated the `review-prompt`
|
|
9
|
+
* verb; that verb now ships in every channel, so floating is safe + frictionless.)
|
|
10
|
+
* Max mode is advisory, so "always newest recipe" is the right default for a
|
|
11
|
+
* review tool. `pin` is overridable for a repo that wants a frozen, exact version.
|
|
12
|
+
*
|
|
13
|
+
* The command, in order:
|
|
14
|
+
* 1. Idempotency — skip if this exact HEAD was already surfaced (avoids a
|
|
15
|
+
* re-review on an amend-with-no-change or a double-fire). The reviewed SHA
|
|
16
|
+
* is recorded under `.git/` (untracked), reusing the "last-reviewed-sha"
|
|
17
|
+
* idea the hosted bot uses on PR comments.
|
|
18
|
+
* 2. Fetch a fresh recipe tailored to THIS repo: `review-prompt --trigger
|
|
19
|
+
* commit` (an instruction recipe — `git show HEAD` + the skills + the
|
|
20
|
+
* report format — NOT raw data; it is meant to be FOLLOWED by an agent).
|
|
21
|
+
* 3. Surface it to the session by printing it and `exit 2`, so `asyncRewake`
|
|
22
|
+
* shows it to the main agent as a system reminder. The agent then reviews
|
|
23
|
+
* the commit on the session subscription.
|
|
24
|
+
* 4. Any failure or empty output → `exit 0` (quiet; the commit is never blocked).
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildCommitReviewCommand(pin?: string): string;
|
|
27
|
+
/** One Claude Code hook entry: a tool matcher plus its hook list. */
|
|
28
|
+
export interface HookMatcherEntry {
|
|
29
|
+
matcher?: string;
|
|
30
|
+
hooks: Array<Record<string, unknown>>;
|
|
31
|
+
}
|
|
32
|
+
/** Minimal shape of the `.claude/settings.json` we read + merge into. */
|
|
33
|
+
export interface ClaudeSettings {
|
|
34
|
+
hooks?: Record<string, HookMatcherEntry[]>;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Builds the PostToolUse entry that runs the commit-review command: a native
|
|
39
|
+
* `type: command` hook, backgrounded (`async`), surfacing the recipe back to the
|
|
40
|
+
* session (`asyncRewake` + exit 2), firing only on `git commit` (`if`).
|
|
41
|
+
*/
|
|
42
|
+
export declare function buildLocalReviewHook(command: string): HookMatcherEntry;
|
|
43
|
+
/**
|
|
44
|
+
* Merges the clud-bug commit-review hook into an existing `.claude/settings.json`
|
|
45
|
+
* object. **Idempotent** (replaces any prior clud-bug entry — including the old
|
|
46
|
+
* `type: agent` one — rather than duplicating) and **non-clobbering** (preserves
|
|
47
|
+
* every other top-level key, event, and hook). Tolerates a missing/malformed
|
|
48
|
+
* `existing` value.
|
|
49
|
+
*/
|
|
50
|
+
export declare function mergeLocalReviewHook(existing: unknown, command: string): ClaudeSettings;
|
|
51
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/cli/hooks.ts"],"names":[],"mappings":"AAkBA;sDACsD;AACtD,eAAO,MAAM,oBAAoB,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,GAAE,MAAe,GAAG,MAAM,CAgCrE;AAED,qEAAqE;AACrE,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACvC;AAED,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAC3C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CActE;AAcD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAwBvF"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// Wave 6b (rc.17 fix) — Claude Code `type: command` commit-review hook scaffolding.
|
|
2
|
+
//
|
|
3
|
+
// `clud-bug init --with-hooks` writes a native Claude Code hook that, on every
|
|
4
|
+
// `git commit`, runs clud-bug's review recipe ON THIS SESSION'S SUBSCRIPTION
|
|
5
|
+
// (no API key), in the background (the commit never blocks).
|
|
6
|
+
//
|
|
7
|
+
// WHY `type: command`, NOT `type: agent`: a Claude Code `type: agent` hook
|
|
8
|
+
// spawns a subagent restricted to Read/Grep/Glob — it has NO Bash and the tool
|
|
9
|
+
// set is not configurable (see code.claude.com/docs/en/hooks: "spawn a subagent
|
|
10
|
+
// that can use tools like Read, Grep, and Glob"). The original Wave 6b hook used
|
|
11
|
+
// `type: agent` and told the subagent to run `npx clud-bug review-prompt` — a
|
|
12
|
+
// Bash CLI call an agent hook can never make — so the review NEVER ran for
|
|
13
|
+
// anyone. A `type: command` hook CAN run the CLI: it fetches the engine's recipe
|
|
14
|
+
// and surfaces it to the session via exit-2 (`asyncRewake`), so the MAIN agent —
|
|
15
|
+
// which has Bash, git, gh, and the subscription — performs the review. The hook
|
|
16
|
+
// exits 0 on any failure, so a review that can't run is a quiet no-op and the
|
|
17
|
+
// commit is NEVER blocked.
|
|
18
|
+
/** Stable marker embedded in our hook so re-runs — and upgrades from the old,
|
|
19
|
+
* broken `type: agent` hook — replace it in place. */
|
|
20
|
+
export const CLUD_BUG_HOOK_MARKER = 'clud-bug-local-review';
|
|
21
|
+
/**
|
|
22
|
+
* Build the shell `command` of the commit-review hook. Pins to a FLOATING npm
|
|
23
|
+
* dist-tag (`next` by default) rather than an exact version, so every repo's hook
|
|
24
|
+
* auto-fetches the latest review recipe — no per-release re-pin rollout. (The
|
|
25
|
+
* original exact-pin guarded against a `latest` that predated the `review-prompt`
|
|
26
|
+
* verb; that verb now ships in every channel, so floating is safe + frictionless.)
|
|
27
|
+
* Max mode is advisory, so "always newest recipe" is the right default for a
|
|
28
|
+
* review tool. `pin` is overridable for a repo that wants a frozen, exact version.
|
|
29
|
+
*
|
|
30
|
+
* The command, in order:
|
|
31
|
+
* 1. Idempotency — skip if this exact HEAD was already surfaced (avoids a
|
|
32
|
+
* re-review on an amend-with-no-change or a double-fire). The reviewed SHA
|
|
33
|
+
* is recorded under `.git/` (untracked), reusing the "last-reviewed-sha"
|
|
34
|
+
* idea the hosted bot uses on PR comments.
|
|
35
|
+
* 2. Fetch a fresh recipe tailored to THIS repo: `review-prompt --trigger
|
|
36
|
+
* commit` (an instruction recipe — `git show HEAD` + the skills + the
|
|
37
|
+
* report format — NOT raw data; it is meant to be FOLLOWED by an agent).
|
|
38
|
+
* 3. Surface it to the session by printing it and `exit 2`, so `asyncRewake`
|
|
39
|
+
* shows it to the main agent as a system reminder. The agent then reviews
|
|
40
|
+
* the commit on the session subscription.
|
|
41
|
+
* 4. Any failure or empty output → `exit 0` (quiet; the commit is never blocked).
|
|
42
|
+
*/
|
|
43
|
+
export function buildCommitReviewCommand(pin = 'next') {
|
|
44
|
+
return [
|
|
45
|
+
// Marker as a `#` comment (NOT a `:` no-op) so its free text can never break
|
|
46
|
+
// `sh` — a paren / quote / `$` in the marker line would be a syntax error
|
|
47
|
+
// under `: ...`. The dogfood caught this. `isOurHook` finds the marker here.
|
|
48
|
+
`# ${CLUD_BUG_HOOK_MARKER} v2 — clud-bug commit review on the session subscription`,
|
|
49
|
+
// Belt-and-suspenders gate. The `if: Bash(git commit *)` / `Bash(logmind log *)`
|
|
50
|
+
// field filters at the platform on Claude Code >= 2.1.85; OLDER CC ignores
|
|
51
|
+
// `if` and would fire this on EVERY Bash call (a review recipe after every
|
|
52
|
+
// command). Command hooks get the event JSON on stdin — re-check it here. If
|
|
53
|
+
// stdin is empty (a CC that doesn't pipe it), fall through and trust `if`.
|
|
54
|
+
`ev=$(cat 2>/dev/null)`,
|
|
55
|
+
`if [ -n "$ev" ]; then case "$ev" in *'git commit'*|*'logmind log'*) ;; *) exit 0 ;; esac; fi`,
|
|
56
|
+
`sha=$(git rev-parse HEAD 2>/dev/null) || exit 0`,
|
|
57
|
+
`gitdir=$(git rev-parse --git-dir 2>/dev/null) || exit 0`,
|
|
58
|
+
`marker="$gitdir/clud-bug-last-commit-review"`,
|
|
59
|
+
`[ "$(cat "$marker" 2>/dev/null)" = "$sha" ] && exit 0`,
|
|
60
|
+
// H4 — one retry on a transient npx/network blip (a stale lock, a slow
|
|
61
|
+
// registry) before giving up, so a hiccup doesn't silently skip the review.
|
|
62
|
+
// `|| recipe=` clears it on a NON-ZERO exit so partial/error stdout from a
|
|
63
|
+
// mid-run crash (or an old npm warning on stdout) is never mistaken for a
|
|
64
|
+
// valid recipe — only a clean, exit-0 run surfaces.
|
|
65
|
+
`recipe=$(npx clud-bug@${pin} review-prompt --trigger commit 2>/dev/null) || recipe=`,
|
|
66
|
+
`if [ -z "$recipe" ]; then sleep 1; recipe=$(npx clud-bug@${pin} review-prompt --trigger commit 2>/dev/null) || recipe=; fi`,
|
|
67
|
+
// H4 — when the recipe still can't be fetched, leave a diagnostic marker so a
|
|
68
|
+
// FAILED review is distinguishable from a CLEAN one (a clean review surfaces
|
|
69
|
+
// the recipe + the agent reports clean). Never blocks the commit.
|
|
70
|
+
`if [ -z "$recipe" ]; then printf '%s' "$sha" > "$gitdir/clud-bug-review-skipped" 2>/dev/null || true; exit 0; fi`,
|
|
71
|
+
`printf '%s' "$sha" > "$marker" 2>/dev/null || true`,
|
|
72
|
+
`printf '%s\\n\\n%s\\n' "clud-bug commit review (max mode — on this session's subscription): a commit was just made. Follow this recipe now — review that commit against the skills it names and surface any findings." "$recipe"`,
|
|
73
|
+
`exit 2`,
|
|
74
|
+
].join('\n');
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Builds the PostToolUse entry that runs the commit-review command: a native
|
|
78
|
+
* `type: command` hook, backgrounded (`async`), surfacing the recipe back to the
|
|
79
|
+
* session (`asyncRewake` + exit 2), firing only on `git commit` (`if`).
|
|
80
|
+
*/
|
|
81
|
+
export function buildLocalReviewHook(command) {
|
|
82
|
+
const base = { type: 'command', async: true, asyncRewake: true, timeout: 180, command };
|
|
83
|
+
return {
|
|
84
|
+
matcher: 'Bash',
|
|
85
|
+
hooks: [
|
|
86
|
+
{ ...base, if: 'Bash(git commit *)' },
|
|
87
|
+
// thrillmade repos (and any logmind user) commit via `logmind log`, which
|
|
88
|
+
// wraps `git commit` inside its own binary — so the Bash tool call is
|
|
89
|
+
// `logmind log ...`, which `Bash(git commit *)` never matches. Fire on it
|
|
90
|
+
// too, or max mode never triggers in a logmind repo. The idempotency
|
|
91
|
+
// SHA-marker means whichever path runs, a commit is reviewed exactly once.
|
|
92
|
+
{ ...base, if: 'Bash(logmind log *)' },
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function isOurHook(h) {
|
|
97
|
+
// Match our marker in `command` (current `type: command` hook) OR `prompt`
|
|
98
|
+
// (the old, broken `type: agent` hook) so a re-install / `clud-bug update`
|
|
99
|
+
// replaces either in place.
|
|
100
|
+
const field = h?.['command'] ?? h?.['prompt'];
|
|
101
|
+
return typeof field === 'string' && field.includes(CLUD_BUG_HOOK_MARKER);
|
|
102
|
+
}
|
|
103
|
+
function isCludBugReviewEntry(entry) {
|
|
104
|
+
return !!entry && Array.isArray(entry.hooks) && entry.hooks.some(isOurHook);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Merges the clud-bug commit-review hook into an existing `.claude/settings.json`
|
|
108
|
+
* object. **Idempotent** (replaces any prior clud-bug entry — including the old
|
|
109
|
+
* `type: agent` one — rather than duplicating) and **non-clobbering** (preserves
|
|
110
|
+
* every other top-level key, event, and hook). Tolerates a missing/malformed
|
|
111
|
+
* `existing` value.
|
|
112
|
+
*/
|
|
113
|
+
export function mergeLocalReviewHook(existing, command) {
|
|
114
|
+
const base = existing && typeof existing === 'object' ? { ...existing } : {};
|
|
115
|
+
const hooks = { ...(base.hooks ?? {}) };
|
|
116
|
+
const priorPost = Array.isArray(hooks.PostToolUse) ? hooks.PostToolUse : [];
|
|
117
|
+
// Preserve every non-clud-bug hook — including any the user co-located INSIDE
|
|
118
|
+
// our own matcher entry: drop only the hook(s) carrying our marker, never the
|
|
119
|
+
// whole entry.
|
|
120
|
+
const ours = buildLocalReviewHook(command);
|
|
121
|
+
const otherEntries = [];
|
|
122
|
+
const coLocatedUserHooks = [];
|
|
123
|
+
for (const entry of priorPost) {
|
|
124
|
+
if (isCludBugReviewEntry(entry)) {
|
|
125
|
+
for (const h of entry.hooks)
|
|
126
|
+
if (!isOurHook(h))
|
|
127
|
+
coLocatedUserHooks.push(h);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
otherEntries.push(entry);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const ourEntry = coLocatedUserHooks.length > 0 ? { ...ours, hooks: [...coLocatedUserHooks, ...ours.hooks] } : ours;
|
|
134
|
+
hooks.PostToolUse = [...otherEntries, ourEntry];
|
|
135
|
+
base.hooks = hooks;
|
|
136
|
+
return base;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/cli/hooks.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,6DAA6D;AAC7D,EAAE;AACF,2EAA2E;AAC3E,+EAA+E;AAC/E,gFAAgF;AAChF,iFAAiF;AACjF,8EAA8E;AAC9E,2EAA2E;AAC3E,iFAAiF;AACjF,iFAAiF;AACjF,gFAAgF;AAChF,8EAA8E;AAC9E,2BAA2B;AAE3B;sDACsD;AACtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAc,MAAM;IAC3D,OAAO;QACL,6EAA6E;QAC7E,0EAA0E;QAC1E,6EAA6E;QAC7E,KAAK,oBAAoB,0DAA0D;QACnF,iFAAiF;QACjF,2EAA2E;QAC3E,2EAA2E;QAC3E,6EAA6E;QAC7E,2EAA2E;QAC3E,uBAAuB;QACvB,8FAA8F;QAC9F,iDAAiD;QACjD,yDAAyD;QACzD,8CAA8C;QAC9C,uDAAuD;QACvD,uEAAuE;QACvE,4EAA4E;QAC5E,2EAA2E;QAC3E,0EAA0E;QAC1E,oDAAoD;QACpD,yBAAyB,GAAG,yDAAyD;QACrF,4DAA4D,GAAG,6DAA6D;QAC5H,8EAA8E;QAC9E,6EAA6E;QAC7E,kEAAkE;QAClE,kHAAkH;QAClH,oDAAoD;QACpD,kOAAkO;QAClO,QAAQ;KACT,CAAC,IAA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AAK,IAAI,EAAE,CAAC,EAAE,CAAC;IAC5E,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;IAE5E,8EAA8E;IAC9E,8EAA8E;IAC9E,eAAe;IACf,MAAM,IAAI,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,YAAY,GAAuB,EAAE,CAAC;IAC5C,MAAM,kBAAkB,GAAmC,EAAE,CAAC;IAC9D,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE,CAAC;QAC9B,IAAI,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK;gBAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;oBAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7E,CAAC;aAAM,CAAC;YACN,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IACD,MAAM,QAAQ,GACZ,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,kBAAkB,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACpG,KAAK,CAAC,WAAW,GAAG,CAAC,GAAG,YAAY,EAAE,QAAQ,CAAC,CAAC;IAChD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACnB,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export { renderBlock, detectSkillRelPath, upsertBlock, hasAgentsMdImport, remove
|
|
|
5
5
|
export { computeSkillUsageDelta, mergeSkillUsage, assessSkillHealth, formatHealthDashboard, DEFAULT_GH_RUNNER, fetchUsageArtifacts, aggregateUsageStream, type SkillDelta, type SkillUsageEntry, type SkillDeltaMap, type SkillUsageMap, type SkillHealthStatus, type SkillHealthRow, type GhRunResult, type GhRunner, type FetchUsageArtifactsOptions, type UsageArtifactRecord, } from './skill-usage.js';
|
|
6
6
|
export { PRICING, computeReviewCost, costPerLOC, cacheHitRate, extractTokensFromLog, rollup, formatRollup, type ModelPricing, type TokenCounts, type CostParts, type ReviewCost, type ExtractedTokens, type ReviewRecord, type RollupGroupStats, type RollupTotal, type RollupTrend, type RollupOutlier, type UnknownModelReview, type Rollup, type FormatRollupOptions, } from './usage.js';
|
|
7
7
|
export { runUpdate, type RunUpdateOptions, type UpdateChangeRecord, type UpdateSkippedRecord, type RunUpdateResult, } from './update.js';
|
|
8
|
+
export { runConfigureGithub, ghCliOctokit, type RunConfigureGithubOptions, } from './configure-github.js';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cli/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,EAC5B,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,mCAAmC,EACxC,KAAK,YAAY,GAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,GAAG,EACH,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,KAAK,SAAS,GACf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,MAAM,EACN,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,MAAM,EACX,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,EAC5B,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,eAAe,EACpB,KAA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B,GAC/B,MAAM,uBAAuB,CAAC"}
|
package/dist/cli/index.js
CHANGED
|
@@ -15,4 +15,5 @@ export { renderBlock, detectSkillRelPath, upsertBlock, hasAgentsMdImport, remove
|
|
|
15
15
|
export { computeSkillUsageDelta, mergeSkillUsage, assessSkillHealth, formatHealthDashboard, DEFAULT_GH_RUNNER, fetchUsageArtifacts, aggregateUsageStream, } from './skill-usage.js';
|
|
16
16
|
export { PRICING, computeReviewCost, costPerLOC, cacheHitRate, extractTokensFromLog, rollup, formatRollup, } from './usage.js';
|
|
17
17
|
export { runUpdate, } from './update.js';
|
|
18
|
+
export { runConfigureGithub, ghCliOctokit, } from './configure-github.js';
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,0CAA0C;AAC1C,EAAE;AACF,oEAAoE;AACpE,uEAAuE;AACvE,iBAAiB;AAEjB,oEAAoE;AACpE,oEAAoE;AACpE,0DAA0D;AAC1D,oCAAoC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,GAW7B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,GAAG,GAIJ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,WAAW,GAGZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,GAWrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,MAAM,EACN,YAAY,GAcb,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,SAAS,GAKV,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,0CAA0C;AAC1C,EAAE;AACF,oEAAoE;AACpE,uEAAuE;AACvE,iBAAiB;AAEjB,oEAAoE;AACpE,oEAAoE;AACpE,0DAA0D;AAC1D,oCAAoC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,GAW7B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,GAAG,GAIJ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,WAAW,GAGZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,GAWrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,MAAM,EACN,YAAY,GAcb,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,SAAS,GAKV,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,kBAAkB,EAClB,YAAY,GAEb,MAAM,uBAAuB,CAAC"}
|
package/dist/cli/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":"AAsRA,iBAAe,IAAI,kBAyClB;AAkgED,OAAO,EAAE,IAAI,EAAE,CAAC"}
|