crysk 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/README.md +610 -2
- package/bin/pr-hero.js +166 -0
- package/config/models/anthropic.json +5 -0
- package/dist/SKILL-7e3725zn.md +496 -0
- package/dist/SKILL-7q35wcaz.md +66 -0
- package/dist/SKILL-9at22381.md +74 -0
- package/dist/SKILL-ex2hxxh3.md +134 -0
- package/dist/adjudicator-dtg2axnh.md +86 -0
- package/dist/admission-config.example-a9vqmmad.json +9 -0
- package/dist/ci-admission-camfbx2b.md +122 -0
- package/dist/cli.js +42292 -0
- package/dist/consolidate-ac0mnfyj.md +24 -0
- package/dist/deep-review-lifecycle-m698ybjp.md +362 -0
- package/dist/deep-review-logic-a6b1gczf.md +156 -0
- package/dist/deep-review-parity-0ec904db.md +120 -0
- package/dist/deep-review-reliability-qyakbjb9.md +125 -0
- package/dist/deep-review-resilience-3tz8y26e.md +118 -0
- package/dist/index.js +20190 -0
- package/dist/opencode-ci-7b0be64p.md +141 -0
- package/dist/review-refuter-j4e9gezy.md +71 -0
- package/dist/scout-yvp153q7.md +140 -0
- package/dist/summarizer-zca44nxa.md +18 -0
- package/dist/workflow-w1g9szna.yml +151 -0
- package/package.json +82 -4
- package/prompts/consolidate.md +24 -0
- package/prompts/default/PROVENANCE.md +18 -0
- package/prompts/default/deep-review-lifecycle.md +362 -0
- package/prompts/default/deep-review-logic.md +156 -0
- package/prompts/default/deep-review-parity.md +120 -0
- package/prompts/default/deep-review-reliability.md +125 -0
- package/prompts/default/deep-review-resilience.md +118 -0
- package/prompts/default/review-refuter.md +71 -0
- package/prompts/scout.md +140 -0
- package/prompts/summarizer.md +18 -0
- package/skills/crysk/SKILL.md +74 -0
- package/skills/crysk-ci-setup/SKILL.md +134 -0
- package/skills/crysk-ci-setup/assets/admission-config.example.json +9 -0
- package/skills/crysk-ci-setup/assets/workflow.yml +151 -0
- package/skills/crysk-ci-setup/references/ci-admission.md +122 -0
- package/skills/crysk-ci-setup/references/opencode-ci.md +141 -0
- package/skills/crysk-loop/SKILL.md +496 -0
- package/skills/crysk-loop/adjudicator.md +86 -0
- package/skills/crysk-pr/SKILL.md +66 -0
- package/src/agent-env.ts +1084 -0
- package/src/asset-manifest.ts +83 -0
- package/src/assets.d.ts +6 -0
- package/src/assets.ts +183 -0
- package/src/brand-paths.ts +155 -0
- package/src/brand.ts +255 -0
- package/src/ci/admission-ledger.ts +350 -0
- package/src/ci/classify-error.ts +73 -0
- package/src/ci/cli-record.ts +271 -0
- package/src/ci/force-comment.ts +39 -0
- package/src/ci/gates.ts +923 -0
- package/src/ci/outcome.ts +2181 -0
- package/src/ci/override.ts +187 -0
- package/src/ci/publish.ts +1639 -0
- package/src/ci/reporter.ts +626 -0
- package/src/ci/review-admission.ts +901 -0
- package/src/ci/review-levels.ts +310 -0
- package/src/ci/review-policy.ts +18 -0
- package/src/ci/review-risk.ts +184 -0
- package/src/ci/setup.ts +844 -0
- package/src/ci/trigger.ts +1353 -0
- package/src/cli.ts +348 -0
- package/src/commands/activity.ts +67 -0
- package/src/commands/ci-setup-questions.ts +397 -0
- package/src/commands/ci-setup.ts +381 -0
- package/src/commands/config.ts +99 -0
- package/src/commands/doctor.ts +108 -0
- package/src/commands/init.ts +139 -0
- package/src/commands/mcp.ts +10 -0
- package/src/commands/menu.ts +129 -0
- package/src/commands/post.ts +302 -0
- package/src/commands/skills.ts +83 -0
- package/src/commands/status.ts +173 -0
- package/src/commands/triage.ts +342 -0
- package/src/commands/uninstall.ts +37 -0
- package/src/commands/upgrade.ts +214 -0
- package/src/commands/usage.ts +98 -0
- package/src/compare/compare.ts +28 -0
- package/src/compare/floor-test.ts +471 -0
- package/src/compare/martian-adapter.ts +80 -0
- package/src/config/config.ts +267 -0
- package/src/corpus/corpus.ts +1094 -0
- package/src/corpus/preflight.ts +1789 -0
- package/src/diversity/accounting.ts +90 -0
- package/src/diversity/adjudication.ts +145 -0
- package/src/diversity/admission.ts +60 -0
- package/src/diversity/benchmark.ts +195 -0
- package/src/diversity/clustering.ts +285 -0
- package/src/diversity/errors.ts +7 -0
- package/src/diversity/identity.ts +285 -0
- package/src/diversity/index.ts +11 -0
- package/src/diversity/pipeline-integration.ts +448 -0
- package/src/diversity/projection.ts +57 -0
- package/src/diversity/self-contained.ts +68 -0
- package/src/diversity/target-validation.ts +179 -0
- package/src/doctor-migration.ts +209 -0
- package/src/doctor.ts +723 -0
- package/src/errors.ts +83 -0
- package/src/execution/admission.ts +75 -0
- package/src/execution/atomic-write.ts +35 -0
- package/src/execution/attempt-evidence.ts +415 -0
- package/src/execution/bucket-id.ts +136 -0
- package/src/execution/concurrency-limiter.ts +175 -0
- package/src/execution/contracts.ts +443 -0
- package/src/execution/failure-classification.ts +42 -0
- package/src/execution/failure-policy.ts +240 -0
- package/src/execution/harness.ts +2548 -0
- package/src/execution/settlement.ts +348 -0
- package/src/execution/spawned-process.ts +66 -0
- package/src/execution/spend-limiter.ts +424 -0
- package/src/execution/step-artifacts.ts +55 -0
- package/src/execution/usage-normalized.ts +469 -0
- package/src/git/git.ts +396 -0
- package/src/git/identity.ts +64 -0
- package/src/git/refs.ts +140 -0
- package/src/home-preflight.ts +443 -0
- package/src/home.ts +243 -0
- package/src/ignore-file.ts +336 -0
- package/src/ignore-read.ts +118 -0
- package/src/index.ts +34 -0
- package/src/legacy-launchd.ts +29 -0
- package/src/mcp/mcp.ts +150 -0
- package/src/mcp/preflight.ts +407 -0
- package/src/menu-context.ts +192 -0
- package/src/model/catalog.ts +251 -0
- package/src/model/exec-snapshots.ts +390 -0
- package/src/model/free-discovery.ts +302 -0
- package/src/model/provider-capabilities.ts +814 -0
- package/src/model/routing.ts +600 -0
- package/src/pr/admission.ts +847 -0
- package/src/pr/ci-admission-gate.ts +665 -0
- package/src/pr/ci-publish.ts +76 -0
- package/src/pr/discovery.ts +432 -0
- package/src/pr/inline.ts +507 -0
- package/src/pr/plan.ts +366 -0
- package/src/pr/posting.ts +115 -0
- package/src/pr/pr-status.ts +787 -0
- package/src/pr/pr.ts +3642 -0
- package/src/pr/preflight.ts +1031 -0
- package/src/pr/publish-outcome.ts +361 -0
- package/src/pr/range.ts +119 -0
- package/src/pr/reverts-preflight.ts +606 -0
- package/src/pr/reverts.ts +377 -0
- package/src/pr/review-pr.ts +927 -0
- package/src/pr/status.ts +154 -0
- package/src/pr/target.ts +388 -0
- package/src/pr/teardown.ts +437 -0
- package/src/pr/worktree-setup.ts +60 -0
- package/src/production-runtime.ts +1877 -0
- package/src/progress.ts +487 -0
- package/src/rereview/adjudicate.ts +89 -0
- package/src/rereview/classify.ts +362 -0
- package/src/rereview/identity.ts +211 -0
- package/src/rereview/plan.ts +308 -0
- package/src/rereview/prepare.ts +1025 -0
- package/src/rereview/state.ts +767 -0
- package/src/rereview/verify.ts +241 -0
- package/src/review/boundary.ts +105 -0
- package/src/review/consolidate.ts +246 -0
- package/src/review/dedupe.ts +368 -0
- package/src/review/drafts.ts +448 -0
- package/src/review/findings-conformance.ts +120 -0
- package/src/review/findings.ts +714 -0
- package/src/review/pipeline.ts +3977 -0
- package/src/review/preflight.ts +3575 -0
- package/src/review/prompt-set.ts +177 -0
- package/src/review/proof-refs.ts +187 -0
- package/src/review/report.ts +1821 -0
- package/src/review/review.ts +490 -0
- package/src/review/root-cause.ts +120 -0
- package/src/review/route-preflight.ts +289 -0
- package/src/review/run.ts +601 -0
- package/src/review/scout.ts +323 -0
- package/src/review/size-gate.ts +595 -0
- package/src/review/spec.ts +235 -0
- package/src/review/step-runner.ts +233 -0
- package/src/runner-authority.ts +596 -0
- package/src/security/binding-policy.ts +115 -0
- package/src/security/credential-broker.ts +773 -0
- package/src/security/evidence-redaction.ts +62 -0
- package/src/security/execution-authority.ts +27 -0
- package/src/security/redact.ts +71 -0
- package/src/security/workspace-read-broker.ts +466 -0
- package/src/server/client.ts +190 -0
- package/src/server/preflight.ts +217 -0
- package/src/server/server.ts +327 -0
- package/src/signal-handler.ts +50 -0
- package/src/store/activity.ts +413 -0
- package/src/store/backfill-preflight.ts +49 -0
- package/src/store/backfill.ts +141 -0
- package/src/store/gc-preflight.ts +206 -0
- package/src/store/gc.ts +424 -0
- package/src/store/metrics-preflight.ts +229 -0
- package/src/store/metrics.ts +236 -0
- package/src/store/preflight.ts +748 -0
- package/src/store/store.ts +693 -0
- package/src/system-tools.ts +355 -0
- package/src/transport-registry.ts +1124 -0
- package/src/transports/claude-code-cli.ts +1348 -0
- package/src/transports/opencode-admission.ts +515 -0
- package/src/transports/opencode-client.ts +3328 -0
- package/src/transports/opencode-evidence.ts +557 -0
- package/src/transports/opencode-mcp.ts +248 -0
- package/src/transports/opencode-sdk.ts +2294 -0
- package/src/transports/opencode-server.ts +535 -0
- package/src/triage/adjudication.ts +113 -0
- package/src/triage/reply.ts +125 -0
- package/src/triage/triage.ts +255 -0
- package/src/ui/activity.ts +173 -0
- package/src/ui/config-edit.ts +816 -0
- package/src/ui/config.ts +462 -0
- package/src/ui/menu.ts +1325 -0
- package/src/ui/plan.ts +1039 -0
- package/src/ui/primitives.ts +300 -0
- package/src/ui/progress.ts +298 -0
- package/src/ui/result.ts +552 -0
- package/src/ui/review-menu.ts +312 -0
- package/src/ui/select.ts +528 -0
- package/src/ui/tree.ts +178 -0
- package/src/uninstaller.ts +479 -0
- package/src/updater.ts +836 -0
- package/src/usage.ts +77 -0
- package/src/watch/preflight.ts +1389 -0
- package/src/watch/watch.ts +1235 -0
- package/src/wizard.ts +877 -0
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import {
|
|
5
|
+
duplicateWorkflowProblem,
|
|
6
|
+
LEGACY_WORKFLOW_RELATIVE_PATH,
|
|
7
|
+
WORKFLOW_RELATIVE_PATH,
|
|
8
|
+
} from "./brand-paths";
|
|
9
|
+
import { resolveOpenCodeAuthPath } from "./security/credential-broker";
|
|
10
|
+
|
|
11
|
+
export type SystemTool = "git" | "claude" | "gh" | "codegraph";
|
|
12
|
+
|
|
13
|
+
export interface SystemToolStatus {
|
|
14
|
+
installed: boolean;
|
|
15
|
+
version?: string;
|
|
16
|
+
authOk?: boolean; // gh, claude
|
|
17
|
+
repoIndexed?: boolean; // codegraph
|
|
18
|
+
hint?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface CheckSystemToolsOptions {
|
|
22
|
+
cwd?: string;
|
|
23
|
+
which?: (binary: string) => string | null | Promise<string | null>;
|
|
24
|
+
exec?: (
|
|
25
|
+
cmd: string[],
|
|
26
|
+
options?: { cwd?: string },
|
|
27
|
+
) => Promise<{ exitCode: number; stdout: string; stderr: string }>;
|
|
28
|
+
exists?: (path: string) => boolean;
|
|
29
|
+
env?: Record<string, string | undefined>;
|
|
30
|
+
home?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface InstallSystemToolOptions {
|
|
34
|
+
platform?: NodeJS.Platform;
|
|
35
|
+
which?: (binary: string) => string | null | Promise<string | null>;
|
|
36
|
+
exec?: (
|
|
37
|
+
cmd: string[],
|
|
38
|
+
options?: { cwd?: string },
|
|
39
|
+
) => Promise<{ exitCode: number; stdout: string; stderr: string }>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface InstallResult {
|
|
43
|
+
ok: boolean;
|
|
44
|
+
manualCommand?: string;
|
|
45
|
+
error?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function defaultExec(
|
|
49
|
+
cmd: string[],
|
|
50
|
+
options?: { cwd?: string; timeoutMs?: number },
|
|
51
|
+
): Promise<{ exitCode: number; stdout: string; stderr: string }> {
|
|
52
|
+
try {
|
|
53
|
+
const timeoutMs = options?.timeoutMs ?? 10_000;
|
|
54
|
+
const proc = Bun.spawn(cmd, {
|
|
55
|
+
cwd: options?.cwd,
|
|
56
|
+
stdin: "ignore",
|
|
57
|
+
stdout: "pipe",
|
|
58
|
+
stderr: "pipe",
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
62
|
+
try {
|
|
63
|
+
const timeoutPromise = new Promise<never>((_, reject) => {
|
|
64
|
+
timer = setTimeout(() => {
|
|
65
|
+
try {
|
|
66
|
+
proc.kill();
|
|
67
|
+
} catch {
|
|
68
|
+
// ignore
|
|
69
|
+
}
|
|
70
|
+
reject(
|
|
71
|
+
new Error(
|
|
72
|
+
`Command timed out after ${timeoutMs}ms: ${cmd.join(" ")}`,
|
|
73
|
+
),
|
|
74
|
+
);
|
|
75
|
+
}, timeoutMs);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const executionPromise = Promise.all([
|
|
79
|
+
new Response(proc.stdout).text(),
|
|
80
|
+
new Response(proc.stderr).text(),
|
|
81
|
+
proc.exited,
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
const [stdout, stderr, exitCode] = await Promise.race([
|
|
85
|
+
executionPromise,
|
|
86
|
+
timeoutPromise,
|
|
87
|
+
]);
|
|
88
|
+
return { exitCode, stdout, stderr };
|
|
89
|
+
} finally {
|
|
90
|
+
if (timer) clearTimeout(timer);
|
|
91
|
+
}
|
|
92
|
+
} catch (error) {
|
|
93
|
+
return { exitCode: 1, stdout: "", stderr: (error as Error).message };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export async function checkSystemTools(
|
|
98
|
+
options: CheckSystemToolsOptions = {},
|
|
99
|
+
): Promise<Record<SystemTool, SystemToolStatus>> {
|
|
100
|
+
const cwd = options.cwd ?? process.cwd();
|
|
101
|
+
const which = options.which ?? ((bin: string) => Bun.which(bin));
|
|
102
|
+
const exec = options.exec ?? defaultExec;
|
|
103
|
+
const exists = options.exists ?? existsSync;
|
|
104
|
+
const env = options.env ?? process.env;
|
|
105
|
+
const home = options.home ?? os.homedir();
|
|
106
|
+
|
|
107
|
+
// 1. git
|
|
108
|
+
const gitBin = await which("git");
|
|
109
|
+
let gitStatus: SystemToolStatus;
|
|
110
|
+
if (!gitBin) {
|
|
111
|
+
gitStatus = {
|
|
112
|
+
installed: false,
|
|
113
|
+
hint: "Install git: brew install git (macOS) or apt install git (Linux)",
|
|
114
|
+
};
|
|
115
|
+
} else {
|
|
116
|
+
const res = await exec([gitBin, "--version"]);
|
|
117
|
+
const versionMatch = res.stdout.match(/git version\s+([0-9.]+)/i);
|
|
118
|
+
gitStatus = {
|
|
119
|
+
installed: true,
|
|
120
|
+
version: versionMatch ? versionMatch[1] : undefined,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 2. claude
|
|
125
|
+
const claudeBin = await which("claude");
|
|
126
|
+
let claudeStatus: SystemToolStatus;
|
|
127
|
+
if (!claudeBin) {
|
|
128
|
+
claudeStatus = {
|
|
129
|
+
installed: false,
|
|
130
|
+
authOk: false,
|
|
131
|
+
hint: "Install Claude Code CLI: npm i -g @anthropic-ai/claude-code",
|
|
132
|
+
};
|
|
133
|
+
} else {
|
|
134
|
+
const res = await exec([claudeBin, "--version"]);
|
|
135
|
+
const version = res.stdout.trim().replace(/^claude-code\//, "");
|
|
136
|
+
|
|
137
|
+
// Check auth mechanisms
|
|
138
|
+
const hasToken =
|
|
139
|
+
Boolean(
|
|
140
|
+
env.CLAUDE_CODE_OAUTH_TOKEN &&
|
|
141
|
+
env.CLAUDE_CODE_OAUTH_TOKEN.trim().length > 0,
|
|
142
|
+
) ||
|
|
143
|
+
Boolean(env.ANTHROPIC_API_KEY && env.ANTHROPIC_API_KEY.trim().length > 0);
|
|
144
|
+
|
|
145
|
+
const hasSessionFile =
|
|
146
|
+
exists(path.join(home, ".claude.json")) ||
|
|
147
|
+
exists(path.join(home, ".claude", "session.json"));
|
|
148
|
+
|
|
149
|
+
const authOk = hasToken || hasSessionFile;
|
|
150
|
+
claudeStatus = {
|
|
151
|
+
installed: true,
|
|
152
|
+
version: version.length > 0 ? version : undefined,
|
|
153
|
+
authOk,
|
|
154
|
+
hint: authOk
|
|
155
|
+
? undefined
|
|
156
|
+
: "Run 'claude' in your terminal to complete login or set ANTHROPIC_API_KEY",
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// 3. gh
|
|
161
|
+
const ghStatus = await checkGhStatus({ which, exec });
|
|
162
|
+
|
|
163
|
+
// 4. codegraph
|
|
164
|
+
const codegraphBin = await which("codegraph");
|
|
165
|
+
const repoIndexed = exists(path.join(cwd, ".codegraph"));
|
|
166
|
+
let codegraphStatus: SystemToolStatus;
|
|
167
|
+
if (!codegraphBin) {
|
|
168
|
+
codegraphStatus = {
|
|
169
|
+
installed: false,
|
|
170
|
+
repoIndexed,
|
|
171
|
+
hint: "Install CodeGraph: brew install codegraph",
|
|
172
|
+
};
|
|
173
|
+
} else {
|
|
174
|
+
const versionRes = await exec([codegraphBin, "--version"]);
|
|
175
|
+
const versionMatch = versionRes.stdout.match(/codegraph\s+([0-9.]+)/i);
|
|
176
|
+
codegraphStatus = {
|
|
177
|
+
installed: true,
|
|
178
|
+
version: versionMatch ? versionMatch[1] : undefined,
|
|
179
|
+
repoIndexed,
|
|
180
|
+
hint: repoIndexed
|
|
181
|
+
? undefined
|
|
182
|
+
: "Run 'codegraph init' in this repository to index for code intelligence",
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
git: gitStatus,
|
|
188
|
+
claude: claudeStatus,
|
|
189
|
+
gh: ghStatus,
|
|
190
|
+
codegraph: codegraphStatus,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// gh alone: whether it is on PATH and whether `gh auth status` passes. Shared by
|
|
195
|
+
// checkSystemTools (doctor, the wizard) and `setup --ci`, which needs only gh.
|
|
196
|
+
export async function checkGhStatus(
|
|
197
|
+
options: Pick<CheckSystemToolsOptions, "which" | "exec"> = {},
|
|
198
|
+
): Promise<SystemToolStatus> {
|
|
199
|
+
const which = options.which ?? ((bin: string) => Bun.which(bin));
|
|
200
|
+
const exec = options.exec ?? defaultExec;
|
|
201
|
+
const ghBin = await which("gh");
|
|
202
|
+
if (!ghBin) {
|
|
203
|
+
return {
|
|
204
|
+
installed: false,
|
|
205
|
+
authOk: false,
|
|
206
|
+
hint: "Install GitHub CLI: brew install gh (macOS) or apt install gh (Linux)",
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const versionRes = await exec([ghBin, "--version"]);
|
|
210
|
+
const versionMatch = versionRes.stdout.match(/gh version\s+([0-9.]+)/i);
|
|
211
|
+
const authRes = await exec([ghBin, "auth", "status"]);
|
|
212
|
+
const authOk = authRes.exitCode === 0;
|
|
213
|
+
return {
|
|
214
|
+
installed: true,
|
|
215
|
+
version: versionMatch ? versionMatch[1] : undefined,
|
|
216
|
+
authOk,
|
|
217
|
+
hint: authOk
|
|
218
|
+
? undefined
|
|
219
|
+
: "Run 'gh auth login' to authenticate with GitHub for PR reviews",
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export async function installSystemTool(
|
|
224
|
+
tool: SystemTool,
|
|
225
|
+
options: InstallSystemToolOptions = {},
|
|
226
|
+
): Promise<InstallResult> {
|
|
227
|
+
const platform = options.platform ?? process.platform;
|
|
228
|
+
const which = options.which ?? ((bin: string) => Bun.which(bin));
|
|
229
|
+
const exec = options.exec ?? defaultExec;
|
|
230
|
+
|
|
231
|
+
if (tool === "claude") {
|
|
232
|
+
const npmBin = (await which("npm")) ?? "npm";
|
|
233
|
+
const res = await exec(
|
|
234
|
+
[npmBin, "install", "-g", "@anthropic-ai/claude-code"],
|
|
235
|
+
{ timeoutMs: 300_000 },
|
|
236
|
+
);
|
|
237
|
+
return {
|
|
238
|
+
ok: res.exitCode === 0,
|
|
239
|
+
manualCommand: "npm install -g @anthropic-ai/claude-code",
|
|
240
|
+
error: res.exitCode === 0 ? undefined : res.stderr,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const brewBin = await which("brew");
|
|
245
|
+
if (platform === "darwin" && brewBin) {
|
|
246
|
+
const formula = tool === "codegraph" ? "codegraph" : tool;
|
|
247
|
+
const res = await exec([brewBin, "install", formula], {
|
|
248
|
+
timeoutMs: 300_000,
|
|
249
|
+
});
|
|
250
|
+
return {
|
|
251
|
+
ok: res.exitCode === 0,
|
|
252
|
+
manualCommand: `brew install ${formula}`,
|
|
253
|
+
error: res.exitCode === 0 ? undefined : res.stderr,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Linux or no brew
|
|
258
|
+
const manualCommands: Record<SystemTool, string> = {
|
|
259
|
+
git: "sudo apt-get install git",
|
|
260
|
+
claude: "npm install -g @anthropic-ai/claude-code",
|
|
261
|
+
gh: "sudo apt-get install gh",
|
|
262
|
+
codegraph: "brew install codegraph # or see codegraph docs",
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
return {
|
|
266
|
+
ok: false,
|
|
267
|
+
manualCommand: manualCommands[tool],
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// ---------------------------------------------------------------------------
|
|
272
|
+
// Pillar 3 Phase 4: CI diagnostics. Useful in BOTH contexts a `doctor` run
|
|
273
|
+
// can happen in — see spec.md §4.1's two scenarios:
|
|
274
|
+
// - Inside GitHub Actions: are the required secrets present? Presence
|
|
275
|
+
// only, NEVER a value, a prefix, or a length — see CLAUDE.md's "Never
|
|
276
|
+
// leak secrets into generated output" rule. Review auth is Anthropic
|
|
277
|
+
// env OR the OpenCode auth file at resolveOpenCodeAuthPath().
|
|
278
|
+
// - In a local repo: is a pr-hero workflow configured at all?
|
|
279
|
+
// Deliberately does NOT verify the workflow file is git-committed (spec's
|
|
280
|
+
// "present and committed" local scenario) — that needs a git call, and the
|
|
281
|
+
// existence check alone already answers the actionable question ("do I have
|
|
282
|
+
// one?") within Phase 4's line budget. Flagged as a scoped deviation, not a
|
|
283
|
+
// silent gap.
|
|
284
|
+
// ---------------------------------------------------------------------------
|
|
285
|
+
|
|
286
|
+
export interface CiConfigurationStatus {
|
|
287
|
+
configured: boolean;
|
|
288
|
+
message: string;
|
|
289
|
+
hint?: string;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export interface CheckCiConfigurationOptions {
|
|
293
|
+
cwd?: string;
|
|
294
|
+
isCi: boolean;
|
|
295
|
+
env?: Record<string, string | undefined>;
|
|
296
|
+
exists?: (p: string) => boolean;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export function checkCiConfiguration(
|
|
300
|
+
options: CheckCiConfigurationOptions,
|
|
301
|
+
): CiConfigurationStatus {
|
|
302
|
+
const env = options.env ?? process.env;
|
|
303
|
+
|
|
304
|
+
if (options.isCi) {
|
|
305
|
+
const exists = options.exists ?? existsSync;
|
|
306
|
+
const hasGithubToken = Boolean(env.GITHUB_TOKEN?.trim());
|
|
307
|
+
const hasClaudeAuth =
|
|
308
|
+
Boolean(env.ANTHROPIC_API_KEY?.trim()) ||
|
|
309
|
+
Boolean(env.CLAUDE_CODE_OAUTH_TOKEN?.trim());
|
|
310
|
+
const hasOpenCodeAuth = exists(resolveOpenCodeAuthPath(env));
|
|
311
|
+
const hasReviewAuth = hasClaudeAuth || hasOpenCodeAuth;
|
|
312
|
+
|
|
313
|
+
const missing: string[] = [];
|
|
314
|
+
if (!hasGithubToken) missing.push("GITHUB_TOKEN");
|
|
315
|
+
if (!hasReviewAuth) missing.push("ANTHROPIC_API_KEY");
|
|
316
|
+
|
|
317
|
+
if (missing.length === 0) {
|
|
318
|
+
return {
|
|
319
|
+
configured: true,
|
|
320
|
+
message:
|
|
321
|
+
"Required CI secrets are present (GITHUB_TOKEN, Anthropic/Claude or OpenCode auth)",
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
return {
|
|
325
|
+
configured: false,
|
|
326
|
+
message: `Missing required CI secret(s): ${missing.join(", ")}`,
|
|
327
|
+
hint: "Configure the missing secret(s) as repository secrets and pass them in the workflow's `with:` block — never echo their values.",
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const cwd = options.cwd ?? process.cwd();
|
|
332
|
+
const exists = options.exists ?? existsSync;
|
|
333
|
+
// Either file counts: a repo set up before the rename keeps pr-hero.yml. Both
|
|
334
|
+
// at once is a defect, not a configuration: two workflows review every PR.
|
|
335
|
+
const duplicate = duplicateWorkflowProblem(cwd, exists);
|
|
336
|
+
if (duplicate !== undefined) {
|
|
337
|
+
return { configured: false, message: duplicate };
|
|
338
|
+
}
|
|
339
|
+
for (const relative of [
|
|
340
|
+
WORKFLOW_RELATIVE_PATH,
|
|
341
|
+
LEGACY_WORKFLOW_RELATIVE_PATH,
|
|
342
|
+
]) {
|
|
343
|
+
if (exists(path.join(cwd, relative))) {
|
|
344
|
+
return {
|
|
345
|
+
configured: true,
|
|
346
|
+
message: `CI workflow configured (${relative})`,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return {
|
|
351
|
+
configured: false,
|
|
352
|
+
message: "No CI workflow configured",
|
|
353
|
+
hint: `Run 'crysk setup --ci' (or 'crysk ci init') to scaffold ${WORKFLOW_RELATIVE_PATH}`,
|
|
354
|
+
};
|
|
355
|
+
}
|