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,83 @@
|
|
|
1
|
+
/// <reference path="./assets.d.ts" />
|
|
2
|
+
|
|
3
|
+
// Authoritative asset manifest for pr-hero.
|
|
4
|
+
// Every packaged asset is imported using `with { type: "file" }` so Bun's compiler embeds them.
|
|
5
|
+
// compile.assets is a silent no-op on Bun 1.3.14 — this manifest is the permanent mechanism.
|
|
6
|
+
|
|
7
|
+
import consolidatePrompt from "../prompts/consolidate.md" with { type: "file" };
|
|
8
|
+
import lifecyclePrompt from "../prompts/default/deep-review-lifecycle.md" with {
|
|
9
|
+
type: "file",
|
|
10
|
+
};
|
|
11
|
+
import logicPrompt from "../prompts/default/deep-review-logic.md" with {
|
|
12
|
+
type: "file",
|
|
13
|
+
};
|
|
14
|
+
import parityPrompt from "../prompts/default/deep-review-parity.md" with {
|
|
15
|
+
type: "file",
|
|
16
|
+
};
|
|
17
|
+
import reliabilityPrompt from "../prompts/default/deep-review-reliability.md" with {
|
|
18
|
+
type: "file",
|
|
19
|
+
};
|
|
20
|
+
import resiliencePrompt from "../prompts/default/deep-review-resilience.md" with {
|
|
21
|
+
type: "file",
|
|
22
|
+
};
|
|
23
|
+
import refuterPrompt from "../prompts/default/review-refuter.md" with {
|
|
24
|
+
type: "file",
|
|
25
|
+
};
|
|
26
|
+
import scoutPrompt from "../prompts/scout.md" with { type: "file" };
|
|
27
|
+
import summarizerPrompt from "../prompts/summarizer.md" with { type: "file" };
|
|
28
|
+
import generalSkill from "../skills/crysk/SKILL.md" with { type: "file" };
|
|
29
|
+
import ciSetupAdmissionExample from "../skills/crysk-ci-setup/assets/admission-config.example.json" with {
|
|
30
|
+
type: "file",
|
|
31
|
+
};
|
|
32
|
+
import ciSetupWorkflow from "../skills/crysk-ci-setup/assets/workflow.yml" with {
|
|
33
|
+
type: "file",
|
|
34
|
+
};
|
|
35
|
+
import ciSetupAdmissionRef from "../skills/crysk-ci-setup/references/ci-admission.md" with {
|
|
36
|
+
type: "file",
|
|
37
|
+
};
|
|
38
|
+
import ciSetupOpenCodeRef from "../skills/crysk-ci-setup/references/opencode-ci.md" with {
|
|
39
|
+
type: "file",
|
|
40
|
+
};
|
|
41
|
+
import ciSetupSkill from "../skills/crysk-ci-setup/SKILL.md" with {
|
|
42
|
+
type: "file",
|
|
43
|
+
};
|
|
44
|
+
import triageAdjudicator from "../skills/crysk-loop/adjudicator.md" with {
|
|
45
|
+
type: "file",
|
|
46
|
+
};
|
|
47
|
+
import triageSkill from "../skills/crysk-loop/SKILL.md" with { type: "file" };
|
|
48
|
+
import prSkill from "../skills/crysk-pr/SKILL.md" with { type: "file" };
|
|
49
|
+
|
|
50
|
+
export const BUNDLED_AGENT_FILES: Record<string, string> = {
|
|
51
|
+
"deep-review-lifecycle.md": lifecyclePrompt,
|
|
52
|
+
"deep-review-logic.md": logicPrompt,
|
|
53
|
+
"deep-review-parity.md": parityPrompt,
|
|
54
|
+
"deep-review-reliability.md": reliabilityPrompt,
|
|
55
|
+
"deep-review-resilience.md": resiliencePrompt,
|
|
56
|
+
"review-refuter.md": refuterPrompt,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const CONSOLIDATE_PROMPT_PATH = consolidatePrompt;
|
|
60
|
+
export const SCOUT_PROMPT_PATH = scoutPrompt;
|
|
61
|
+
export const SUMMARIZER_PROMPT_PATH = summarizerPrompt;
|
|
62
|
+
|
|
63
|
+
export const TRIAGE_SKILL_FILES: Record<string, string> = {
|
|
64
|
+
"SKILL.md": triageSkill,
|
|
65
|
+
"adjudicator.md": triageAdjudicator,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const CI_SETUP_SKILL_FILES: Record<string, string> = {
|
|
69
|
+
"SKILL.md": ciSetupSkill,
|
|
70
|
+
"assets/admission-config.example.json":
|
|
71
|
+
ciSetupAdmissionExample as unknown as string,
|
|
72
|
+
"assets/workflow.yml": ciSetupWorkflow,
|
|
73
|
+
"references/ci-admission.md": ciSetupAdmissionRef,
|
|
74
|
+
"references/opencode-ci.md": ciSetupOpenCodeRef,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const PR_SKILL_FILES: Record<string, string> = {
|
|
78
|
+
"SKILL.md": prSkill,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const GENERAL_SKILL_FILES: Record<string, string> = {
|
|
82
|
+
"SKILL.md": generalSkill,
|
|
83
|
+
};
|
package/src/assets.d.ts
ADDED
package/src/assets.ts
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// Authority for packaged-asset resolution and self-invocation.
|
|
2
|
+
// Single authority across dev, npm, and compiled runtimes.
|
|
3
|
+
|
|
4
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import {
|
|
7
|
+
BUNDLED_AGENT_FILES,
|
|
8
|
+
CI_SETUP_SKILL_FILES,
|
|
9
|
+
CONSOLIDATE_PROMPT_PATH,
|
|
10
|
+
GENERAL_SKILL_FILES,
|
|
11
|
+
PR_SKILL_FILES,
|
|
12
|
+
SCOUT_PROMPT_PATH,
|
|
13
|
+
SUMMARIZER_PROMPT_PATH,
|
|
14
|
+
TRIAGE_SKILL_FILES,
|
|
15
|
+
} from "./asset-manifest";
|
|
16
|
+
|
|
17
|
+
export type AssetMode = "dev" | "npm" | "compiled";
|
|
18
|
+
|
|
19
|
+
export interface EngineAssets {
|
|
20
|
+
mode: AssetMode;
|
|
21
|
+
bundledAgentFiles: Record<string, string>; // logical filename → path, from the manifest (every mode)
|
|
22
|
+
defaultAgentsDir: string; // the prompts/default dir in dev/npm, or embedded asset directory when compiled
|
|
23
|
+
consolidatePromptPath: string;
|
|
24
|
+
scoutPromptPath: string;
|
|
25
|
+
summarizerPromptPath: string;
|
|
26
|
+
triageSkillFiles: Record<string, string>; // logical filename → path, from the manifest
|
|
27
|
+
ciSetupSkillFiles: Record<string, string>; // logical filename → path, from the manifest
|
|
28
|
+
prSkillFiles: Record<string, string>; // logical filename → path, from the manifest
|
|
29
|
+
generalSkillFiles: Record<string, string>; // logical filename → path, from the manifest
|
|
30
|
+
version: string; // baked at compile; package.json otherwise
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface SelfInvocation {
|
|
34
|
+
command: string; // absolute: the bun binary (dev/npm) or the compiled binary itself
|
|
35
|
+
args: string[]; // [absolute cli.ts] in dev/npm; [] when compiled
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
declare const __PRHERO_VERSION__: string | undefined;
|
|
39
|
+
|
|
40
|
+
export function detectAssetMode(): AssetMode {
|
|
41
|
+
// Bun compiled binaries embed files into /$bunfs/root/
|
|
42
|
+
if (
|
|
43
|
+
import.meta.dir.startsWith("/$bunfs") ||
|
|
44
|
+
import.meta.url.startsWith("file:///$bunfs")
|
|
45
|
+
) {
|
|
46
|
+
return "compiled";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Check if we are inside a node_modules package or no .git directory
|
|
50
|
+
const gitDir = path.resolve(import.meta.dir, "../.git");
|
|
51
|
+
if (import.meta.dir.includes("node_modules") || !existsSync(gitDir)) {
|
|
52
|
+
return "npm";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return "dev";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function resolveVersion(): string {
|
|
59
|
+
if (typeof __PRHERO_VERSION__ === "string" && __PRHERO_VERSION__.length > 0) {
|
|
60
|
+
return __PRHERO_VERSION__;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const pkgPath = path.resolve(import.meta.dir, "../package.json");
|
|
65
|
+
if (existsSync(pkgPath)) {
|
|
66
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
67
|
+
if (typeof pkg.version === "string") {
|
|
68
|
+
return pkg.version;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} catch {
|
|
72
|
+
// Ignore read errors
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return "0.3.0";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function resolveEngineAssets(): EngineAssets {
|
|
79
|
+
const mode = detectAssetMode();
|
|
80
|
+
const version = resolveVersion();
|
|
81
|
+
|
|
82
|
+
let defaultAgentsDir = path.dirname(BUNDLED_AGENT_FILES["review-refuter.md"]);
|
|
83
|
+
if (mode !== "compiled") {
|
|
84
|
+
const fsDefaultDir = path.resolve(import.meta.dir, "../prompts/default");
|
|
85
|
+
if (existsSync(fsDefaultDir)) {
|
|
86
|
+
defaultAgentsDir = fsDefaultDir;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
mode,
|
|
92
|
+
bundledAgentFiles: BUNDLED_AGENT_FILES,
|
|
93
|
+
defaultAgentsDir,
|
|
94
|
+
consolidatePromptPath: CONSOLIDATE_PROMPT_PATH,
|
|
95
|
+
scoutPromptPath: SCOUT_PROMPT_PATH,
|
|
96
|
+
summarizerPromptPath: SUMMARIZER_PROMPT_PATH,
|
|
97
|
+
triageSkillFiles: TRIAGE_SKILL_FILES,
|
|
98
|
+
ciSetupSkillFiles: CI_SETUP_SKILL_FILES,
|
|
99
|
+
prSkillFiles: PR_SKILL_FILES,
|
|
100
|
+
generalSkillFiles: GENERAL_SKILL_FILES,
|
|
101
|
+
version,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function selfInvocation(): SelfInvocation {
|
|
106
|
+
const mode = detectAssetMode();
|
|
107
|
+
if (mode === "compiled") {
|
|
108
|
+
return {
|
|
109
|
+
command: process.execPath,
|
|
110
|
+
args: [],
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
command: process.execPath,
|
|
116
|
+
args: [path.resolve(import.meta.dir, "cli.ts")],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// WHY: `npx pr-hero` runs from npm's temporary cache (~/.npm/_npx/<hash>/), which npm
|
|
121
|
+
// may delete at any time. An MCP config or a launchd plist that records that path
|
|
122
|
+
// breaks silently once it is gone, so registration refuses it and names the fix.
|
|
123
|
+
export const NPX_REGISTRATION_REFUSED =
|
|
124
|
+
"Crysk is running from npx's temporary cache; install crysk (npm i -g crysk) to register";
|
|
125
|
+
const NPX_CACHE_SEGMENT = /[\\/]_npx[\\/]/;
|
|
126
|
+
export function isNpxCacheInvocation(invocation: SelfInvocation): boolean {
|
|
127
|
+
return [invocation.command, ...invocation.args].some((part) =>
|
|
128
|
+
NPX_CACHE_SEGMENT.test(part),
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Read through resolveEngineAssets() rather than the constants in index.ts:
|
|
133
|
+
// the version a run is stamped with must be the one that would be published,
|
|
134
|
+
// and a hand-maintained duplicate drifts. That one resolver also covers the
|
|
135
|
+
// compiled binary, whose version is baked in at build time because its
|
|
136
|
+
// package.json is not shipped inside the executable.
|
|
137
|
+
// C4 O-0. `version` alone does not discriminate: for a source checkout it is
|
|
138
|
+
// package.json's, which said 0.1.0 from the scaffold commit onwards, so every
|
|
139
|
+
// run this engine has ever written — before and after a change that alters
|
|
140
|
+
// what every agent reads — reports the same engine. That is not a cosmetic gap. The Cal.com Martian
|
|
141
|
+
// baseline is ratified as valid ACROSS engine versions on the condition that
|
|
142
|
+
// the frontier is annotated (docs/martian-bench.md), and an artifact whose
|
|
143
|
+
// engine field cannot change cannot annotate anything.
|
|
144
|
+
//
|
|
145
|
+
// The revision is the git commit, which moves on its own and needs nobody to
|
|
146
|
+
// remember a bump — the failure mode this whole item exists to remove.
|
|
147
|
+
//
|
|
148
|
+
// PURE half, so the fallbacks are testable without a filesystem or a spawn.
|
|
149
|
+
export function deriveEngineIdentity(
|
|
150
|
+
pkg: { name?: string; version?: string },
|
|
151
|
+
revision: { ok: boolean; stdout: string },
|
|
152
|
+
): { name: string; version: string; revision?: string } {
|
|
153
|
+
const sha = revision.ok ? revision.stdout.trim() : "";
|
|
154
|
+
return {
|
|
155
|
+
name: pkg.name ?? "pr-hero",
|
|
156
|
+
version: pkg.version ?? "0.0.0",
|
|
157
|
+
// ABSENT rather than "unknown" when git cannot answer. A checkout without
|
|
158
|
+
// git, or a tarball install, still has to be able to run a review — a run
|
|
159
|
+
// that refused to start over a provenance field would trade a paid review
|
|
160
|
+
// for a string. Absent reads as "this run could not name its commit",
|
|
161
|
+
// which is exactly true, and it is also what every pre-C4 artifact says.
|
|
162
|
+
...(sha.length === 0 ? {} : { revision: sha }),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// The engine's own checkout root, for reading its revision. Computed HERE because
|
|
167
|
+
// this module is the single place allowed to derive a filesystem path from
|
|
168
|
+
// import.meta (packaging.test.ts pins that), and the answer depends on which file
|
|
169
|
+
// asks: import.meta.dir is the directory of the module that evaluates it. From
|
|
170
|
+
// src/ the parent is the checkout; from src/git/ the same expression lands on
|
|
171
|
+
// src/ itself.
|
|
172
|
+
//
|
|
173
|
+
// Moving engineIdentity into src/git/ with its own `path.join(import.meta.dir,
|
|
174
|
+
// "..")` intact did shift the path by one level. It did NOT produce a wrong
|
|
175
|
+
// revision, and that is worth stating precisely rather than overclaiming: git
|
|
176
|
+
// discovers the repository upward from any subdirectory, so `git -C src/` and
|
|
177
|
+
// `git -C <checkout>` return the same HEAD. The shift was invisible here only
|
|
178
|
+
// because git happened to be forgiving. The single-authority rule is what keeps
|
|
179
|
+
// a relocation from silently changing which path a module resolves, in a runtime
|
|
180
|
+
// where nothing upstream would absorb the mistake.
|
|
181
|
+
export function engineCheckoutRoot(): string {
|
|
182
|
+
return path.join(import.meta.dir, "..");
|
|
183
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// Where the product keeps its files during the pr-hero → Crysk rename. The new
|
|
2
|
+
// directory names win when they hold pr-hero state; the old ones are still
|
|
3
|
+
// found when they are all that exists, and nothing here ever moves a user's
|
|
4
|
+
// files (`doctor` prints the migration command instead). Filesystem lookups
|
|
5
|
+
// live here, not in brand.ts, because brand.ts must stay import-free.
|
|
6
|
+
|
|
7
|
+
import { existsSync } from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { LEGACY_WORKFLOW_FILE_NAME, WORKFLOW_FILE_NAME } from "./brand";
|
|
10
|
+
|
|
11
|
+
export const HOME_DIR_NAME = ".crysk";
|
|
12
|
+
export const LEGACY_HOME_DIR_NAME = ".prhero";
|
|
13
|
+
export const REPO_DIR_NAME = ".crysk";
|
|
14
|
+
export const LEGACY_REPO_DIR_NAME = ".prhero";
|
|
15
|
+
export const IGNORE_FILE_NAME = ".cryskignore";
|
|
16
|
+
export const LEGACY_IGNORE_FILE_NAME = ".prheroignore";
|
|
17
|
+
|
|
18
|
+
type Exists = (p: string) => boolean;
|
|
19
|
+
|
|
20
|
+
// What pr-hero itself writes into a home dir. The directory merely existing
|
|
21
|
+
// is not enough: creating an empty ~/.crysk (by hand, or an installer that
|
|
22
|
+
// only made bin/) must not hide the populated ~/.prhero beside it.
|
|
23
|
+
const HOME_STATE_MARKERS = [
|
|
24
|
+
"prhero.db",
|
|
25
|
+
"metrics.db",
|
|
26
|
+
"config.json",
|
|
27
|
+
"setup.json",
|
|
28
|
+
"watch.json",
|
|
29
|
+
"repos",
|
|
30
|
+
];
|
|
31
|
+
// The same idea for a repo: only these two files make a repo dir count.
|
|
32
|
+
const REPO_STATE_MARKERS = ["config.json", "gotchas.md"];
|
|
33
|
+
|
|
34
|
+
export function homeHasState(
|
|
35
|
+
homeDir: string,
|
|
36
|
+
exists: Exists = existsSync,
|
|
37
|
+
): boolean {
|
|
38
|
+
return HOME_STATE_MARKERS.some((m) => exists(path.join(homeDir, m)));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function repoDirHasState(
|
|
42
|
+
repoDir: string,
|
|
43
|
+
exists: Exists = existsSync,
|
|
44
|
+
): boolean {
|
|
45
|
+
return REPO_STATE_MARKERS.some((m) => exists(path.join(repoDir, m)));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// A new-named directory wins only while it holds state (or there is no legacy
|
|
49
|
+
// one to fall back to). Deliberate safety deviation from "new name wins as
|
|
50
|
+
// soon as it exists": that rule orphans every file under the old dir the
|
|
51
|
+
// moment someone creates the new one.
|
|
52
|
+
function resolveName(
|
|
53
|
+
parent: string,
|
|
54
|
+
name: string,
|
|
55
|
+
legacy: string,
|
|
56
|
+
exists: Exists,
|
|
57
|
+
hasState: (dir: string, exists: Exists) => boolean,
|
|
58
|
+
): string {
|
|
59
|
+
const fresh = path.join(parent, name);
|
|
60
|
+
const old = path.join(parent, legacy);
|
|
61
|
+
if (exists(fresh) && hasState(fresh, exists)) return name;
|
|
62
|
+
if (exists(old)) return legacy;
|
|
63
|
+
return name;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ~/.crysk when it has state; else ~/.prhero when that exists; else ~/.crysk
|
|
67
|
+
// (a fresh install). `exists` is injectable so a caller that already has a
|
|
68
|
+
// fake filesystem (doctor) gets the same answer it uses for every other path.
|
|
69
|
+
export function resolveHomeDir(home: string, exists: Exists = existsSync) {
|
|
70
|
+
return path.join(
|
|
71
|
+
home,
|
|
72
|
+
resolveName(
|
|
73
|
+
home,
|
|
74
|
+
HOME_DIR_NAME,
|
|
75
|
+
LEGACY_HOME_DIR_NAME,
|
|
76
|
+
exists,
|
|
77
|
+
homeHasState,
|
|
78
|
+
),
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// <root>/.crysk when it holds config.json or gotchas.md; else <root>/.prhero
|
|
83
|
+
// when that exists; else <root>/.crysk. Writers use the same answer, so an
|
|
84
|
+
// existing .prhero/ repo is updated in place.
|
|
85
|
+
export function resolveRepoDir(root: string, exists: Exists = existsSync) {
|
|
86
|
+
return path.join(
|
|
87
|
+
root,
|
|
88
|
+
resolveName(
|
|
89
|
+
root,
|
|
90
|
+
REPO_DIR_NAME,
|
|
91
|
+
LEGACY_REPO_DIR_NAME,
|
|
92
|
+
exists,
|
|
93
|
+
repoDirHasState,
|
|
94
|
+
),
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// The ignore file a working tree already has: .cryskignore first, then
|
|
99
|
+
// .prheroignore, else the new name (for writes).
|
|
100
|
+
export function resolveIgnoreFileName(
|
|
101
|
+
root: string,
|
|
102
|
+
exists: Exists = existsSync,
|
|
103
|
+
) {
|
|
104
|
+
const alwaysState = () => true;
|
|
105
|
+
return resolveName(
|
|
106
|
+
root,
|
|
107
|
+
IGNORE_FILE_NAME,
|
|
108
|
+
LEGACY_IGNORE_FILE_NAME,
|
|
109
|
+
exists,
|
|
110
|
+
alwaysState,
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// The review workflow file, relative to a repo root. A repo that already has the
|
|
115
|
+
// pre-rename `pr-hero.yml` keeps it (it is updated in place); every other repo,
|
|
116
|
+
// a fresh one included, gets `crysk.yml`. The code only ever acts on one file.
|
|
117
|
+
export const WORKFLOW_DIR = path.join(".github", "workflows");
|
|
118
|
+
export const WORKFLOW_RELATIVE_PATH = path.join(
|
|
119
|
+
WORKFLOW_DIR,
|
|
120
|
+
WORKFLOW_FILE_NAME,
|
|
121
|
+
);
|
|
122
|
+
export const LEGACY_WORKFLOW_RELATIVE_PATH = path.join(
|
|
123
|
+
WORKFLOW_DIR,
|
|
124
|
+
LEGACY_WORKFLOW_FILE_NAME,
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
export function resolveWorkflowRelativePath(
|
|
128
|
+
root: string,
|
|
129
|
+
exists: Exists = existsSync,
|
|
130
|
+
): string {
|
|
131
|
+
const legacyOnly =
|
|
132
|
+
exists(path.join(root, LEGACY_WORKFLOW_RELATIVE_PATH)) &&
|
|
133
|
+
!exists(path.join(root, WORKFLOW_RELATIVE_PATH));
|
|
134
|
+
return legacyOnly ? LEGACY_WORKFLOW_RELATIVE_PATH : WORKFLOW_RELATIVE_PATH;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Both files present means two workflows review every pull request: the reason
|
|
138
|
+
// setup refuses to write and doctor reports degraded. Undefined when at most
|
|
139
|
+
// one exists.
|
|
140
|
+
export function duplicateWorkflowProblem(
|
|
141
|
+
root: string,
|
|
142
|
+
exists: Exists = existsSync,
|
|
143
|
+
): string | undefined {
|
|
144
|
+
if (
|
|
145
|
+
!exists(path.join(root, WORKFLOW_RELATIVE_PATH)) ||
|
|
146
|
+
!exists(path.join(root, LEGACY_WORKFLOW_RELATIVE_PATH))
|
|
147
|
+
) {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
return (
|
|
151
|
+
`${WORKFLOW_RELATIVE_PATH} and ${LEGACY_WORKFLOW_RELATIVE_PATH} both exist, ` +
|
|
152
|
+
"so two workflows review every pull request twice; delete the one you do " +
|
|
153
|
+
"not want (keep the one your branch protection and secrets already rely on)"
|
|
154
|
+
);
|
|
155
|
+
}
|
package/src/brand.ts
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
// The product's names during the pr-hero → Crysk rename. Every contract
|
|
2
|
+
// writes the new name and, for one version, still reads the old one, so an
|
|
3
|
+
// install set up under pr-hero keeps working. Each legacy fallback lives here
|
|
4
|
+
// so the version that drops them deletes one module, not a hunt across src/.
|
|
5
|
+
|
|
6
|
+
const ENV_PREFIX = "CRYSK_";
|
|
7
|
+
const LEGACY_ENV_PREFIX = "PRHERO_";
|
|
8
|
+
|
|
9
|
+
export interface BrandEnvValue {
|
|
10
|
+
value: string;
|
|
11
|
+
// The variable that was read, so a message can name what the user set.
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Reads CRYSK_<suffix>, then PRHERO_<suffix>. The first non-empty value
|
|
16
|
+
// wins, so a CRYSK_ variable left empty during migration (a workflow `env:`
|
|
17
|
+
// entry wired to an unset repo variable) cannot hide the old install's value.
|
|
18
|
+
// When neither has a value but one is set, that one is returned as "", so a
|
|
19
|
+
// caller that only checks presence (NO_TUI) still sees it.
|
|
20
|
+
export function readBrandEnv(
|
|
21
|
+
env: Record<string, string | undefined>,
|
|
22
|
+
suffix: string,
|
|
23
|
+
): BrandEnvValue | undefined {
|
|
24
|
+
let present: BrandEnvValue | undefined;
|
|
25
|
+
for (const prefix of [ENV_PREFIX, LEGACY_ENV_PREFIX]) {
|
|
26
|
+
const name = `${prefix}${suffix}`;
|
|
27
|
+
const value = env[name];
|
|
28
|
+
if (value === undefined) continue;
|
|
29
|
+
if (value !== "") return { value, name };
|
|
30
|
+
present ??= { value, name };
|
|
31
|
+
}
|
|
32
|
+
return present;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Comment markers on PRs. Every marker constant is written in the new form
|
|
36
|
+
// (`<!-- crysk-<kind>`); the legacy form is derived from it here, so a reader
|
|
37
|
+
// passes the one constant it already has and still finds comments posted
|
|
38
|
+
// before the rename.
|
|
39
|
+
export const MARKER_OPEN = "<!-- crysk-";
|
|
40
|
+
const LEGACY_MARKER_OPEN = "<!-- pr-hero-";
|
|
41
|
+
|
|
42
|
+
// For a RegExp that must match either name: `^<!-- ${MARKER_BRAND_PATTERN}-report`.
|
|
43
|
+
export const MARKER_BRAND_PATTERN = "(?:crysk|pr-hero)";
|
|
44
|
+
|
|
45
|
+
function markerForms(prefix: string): string[] {
|
|
46
|
+
if (!prefix.startsWith(MARKER_OPEN)) {
|
|
47
|
+
throw new Error(`not a crysk marker prefix: ${JSON.stringify(prefix)}`);
|
|
48
|
+
}
|
|
49
|
+
return [prefix, LEGACY_MARKER_OPEN + prefix.slice(MARKER_OPEN.length)];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// The form `text` starts with, or undefined. Callers slice by the returned
|
|
53
|
+
// prefix's length: the two names differ in length.
|
|
54
|
+
export function matchMarkerPrefix(
|
|
55
|
+
text: string,
|
|
56
|
+
prefix: string,
|
|
57
|
+
): string | undefined {
|
|
58
|
+
return markerForms(prefix).find((form) => text.startsWith(form));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// The earliest occurrence of either form anywhere in `text`, for markers that
|
|
62
|
+
// sit inside a larger comment (the summary's state and admission blocks).
|
|
63
|
+
export function findMarker(
|
|
64
|
+
text: string,
|
|
65
|
+
prefix: string,
|
|
66
|
+
): { index: number; prefix: string } | undefined {
|
|
67
|
+
let best: { index: number; prefix: string } | undefined;
|
|
68
|
+
for (const form of markerForms(prefix)) {
|
|
69
|
+
const index = text.indexOf(form);
|
|
70
|
+
if (index !== -1 && (best === undefined || index < best.index)) {
|
|
71
|
+
best = { index, prefix: form };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return best;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// PR comment commands. Every command constant is written in the new form
|
|
78
|
+
// (`/crysk review`); the legacy `/pr-hero` form is derived from it here, so
|
|
79
|
+
// a maintainer's muscle memory and old docs keep working for one version.
|
|
80
|
+
const COMMAND_PREFIX = "/crysk";
|
|
81
|
+
const LEGACY_COMMAND_PREFIX = "/pr-hero";
|
|
82
|
+
|
|
83
|
+
// Both written forms of a command, new name first. The workflow template
|
|
84
|
+
// lists each one, because an Actions expression cannot match a pattern.
|
|
85
|
+
export function commandForms(command: string): string[] {
|
|
86
|
+
if (!command.startsWith(`${COMMAND_PREFIX} `)) {
|
|
87
|
+
throw new Error(`not a crysk command: ${JSON.stringify(command)}`);
|
|
88
|
+
}
|
|
89
|
+
return [
|
|
90
|
+
command,
|
|
91
|
+
LEGACY_COMMAND_PREFIX + command.slice(COMMAND_PREFIX.length),
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Exact match after trimming, and nothing else: no case folding, no inner
|
|
96
|
+
// whitespace tolerance, no trailing words. A loose match is how a quoted reply
|
|
97
|
+
// would start a paid review.
|
|
98
|
+
export function isCommand(text: string, command: string): boolean {
|
|
99
|
+
const trimmed = text.trim();
|
|
100
|
+
return commandForms(command).includes(trimmed);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// For near-miss detection: the text begins like the command, in either name.
|
|
104
|
+
export function startsWithCommand(text: string, command: string): boolean {
|
|
105
|
+
const trimmed = text.trim();
|
|
106
|
+
return commandForms(command).some((form) => trimmed.startsWith(form));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// The legacy spelling of a command. Every workflow accepts it during the
|
|
110
|
+
// rename, including one set up before it, which filters only `/pr-hero`, so it
|
|
111
|
+
// is the one to name where there is room for a single spelling.
|
|
112
|
+
export function legacyCommand(command: string): string {
|
|
113
|
+
return commandForms(command)[1] as string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Both spellings for a hint a person or an agent will act on. A workflow set
|
|
117
|
+
// up before the rename ignores `/crysk`, and floating action tags deliver the
|
|
118
|
+
// new hints to it, so a hint naming only `/crysk` would send the reader to a
|
|
119
|
+
// command that starts nothing.
|
|
120
|
+
export function commandHint(command: string, quote = "`"): string {
|
|
121
|
+
return (
|
|
122
|
+
`${quote}${command}${quote} (or ${quote}${legacyCommand(command)}${quote} ` +
|
|
123
|
+
"on a workflow set up before the rename)"
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Commit status contexts. The gate is a required check in users' branch
|
|
128
|
+
// protection, which names `pr-hero`; a head that stops getting that context
|
|
129
|
+
// blocks forever. So for one version every status is written on BOTH names, the
|
|
130
|
+
// new one first, and every reader treats the two as one gate. The version that
|
|
131
|
+
// drops the legacy name deletes LEGACY_STATUS_CONTEXT and the helpers below.
|
|
132
|
+
export const STATUS_CONTEXT = "crysk";
|
|
133
|
+
const LEGACY_STATUS_CONTEXT = "pr-hero";
|
|
134
|
+
|
|
135
|
+
// The context of a run that cannot move the gate: a local `review --pr` and the
|
|
136
|
+
// watcher. Its legacy form is `pr-hero/local`, derived the same way.
|
|
137
|
+
export const LOCAL_STATUS_CONTEXT = `${STATUS_CONTEXT}/local` as const;
|
|
138
|
+
|
|
139
|
+
// Both contexts a status written on `context` is published on, new name first.
|
|
140
|
+
// `context` is always a crysk context: a request is built in the new form, and the
|
|
141
|
+
// legacy form is derived from it here, as the marker and command helpers do.
|
|
142
|
+
export function statusContextForms(context: string): string[] {
|
|
143
|
+
if (context !== STATUS_CONTEXT && !context.startsWith(`${STATUS_CONTEXT}/`)) {
|
|
144
|
+
throw new Error(`not a crysk status context: ${JSON.stringify(context)}`);
|
|
145
|
+
}
|
|
146
|
+
return [
|
|
147
|
+
context,
|
|
148
|
+
LEGACY_STATUS_CONTEXT + context.slice(STATUS_CONTEXT.length),
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Whether a row's context is either name of `context` (the crysk form). `crysk` and
|
|
153
|
+
// `pr-hero/local` stay different gates: the local pair never answers for the gate.
|
|
154
|
+
export function isStatusContext(actual: string, context: string): boolean {
|
|
155
|
+
return statusContextForms(context).includes(actual);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// For picking between two rows with the same time: the legacy name loses to the new
|
|
159
|
+
// one, because the pair a run writes carries identical content on both.
|
|
160
|
+
export function isLegacyStatusContext(context: string): boolean {
|
|
161
|
+
return (
|
|
162
|
+
context === LEGACY_STATUS_CONTEXT ||
|
|
163
|
+
context.startsWith(`${LEGACY_STATUS_CONTEXT}/`)
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// A status description starts with the context name (`crysk: 2 blocking finding(s)`,
|
|
168
|
+
// `crysk skipped the review`). Statuses written before the rename start with
|
|
169
|
+
// `pr-hero` instead. A reader rewrites a legacy lead into the new one and then
|
|
170
|
+
// matches against the text this version writes, so one pattern serves both. Only a
|
|
171
|
+
// lead followed by `:` or a space is the brand: `pr-heroic` is not.
|
|
172
|
+
export function canonicalStatusText(text: string): string {
|
|
173
|
+
if (!text.startsWith(LEGACY_STATUS_CONTEXT)) return text;
|
|
174
|
+
const next = text.charAt(LEGACY_STATUS_CONTEXT.length);
|
|
175
|
+
if (next !== ":" && next !== " ") return text;
|
|
176
|
+
return STATUS_CONTEXT + text.slice(LEGACY_STATUS_CONTEXT.length);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// The bundled agent skills, by role, in sync order. The role key joins a skill
|
|
180
|
+
// to its pre-rename name: sync removes a legacy dir only once the skill of the
|
|
181
|
+
// same role is installed under the new name. Plain strings, so every site that
|
|
182
|
+
// lists skills (sync, inspect, remove, uninstall) reads this one list.
|
|
183
|
+
export const SKILL_NAMES = {
|
|
184
|
+
triage: "crysk-loop",
|
|
185
|
+
ciSetup: "crysk-ci-setup",
|
|
186
|
+
pr: "crysk-pr",
|
|
187
|
+
general: "crysk",
|
|
188
|
+
} as const;
|
|
189
|
+
|
|
190
|
+
export const LEGACY_SKILL_NAMES = {
|
|
191
|
+
triage: "pr-hero-triage",
|
|
192
|
+
ciSetup: "pr-hero-ci-setup",
|
|
193
|
+
pr: "pr-hero-pr",
|
|
194
|
+
general: "pr-hero",
|
|
195
|
+
} as const satisfies Record<keyof typeof SKILL_NAMES, string>;
|
|
196
|
+
|
|
197
|
+
// The key the agent MCP configs register this server under, and the key
|
|
198
|
+
// installs set up under pr-hero still hold. Register writes the first and
|
|
199
|
+
// retires the second; inspect and unregister read both.
|
|
200
|
+
export const MCP_SERVER_KEY = "crysk";
|
|
201
|
+
export const LEGACY_MCP_SERVER_KEY = "pr-hero";
|
|
202
|
+
|
|
203
|
+
// MCP tool names. The server advertises only the current prefix; a call under
|
|
204
|
+
// the legacy one is mapped onto it, so an agent prompt or skill written before
|
|
205
|
+
// the rename keeps working.
|
|
206
|
+
const MCP_TOOL_PREFIX = "crysk_";
|
|
207
|
+
const LEGACY_MCP_TOOL_PREFIX = "prhero_";
|
|
208
|
+
|
|
209
|
+
export function currentMcpToolName(name: string): string {
|
|
210
|
+
return name.startsWith(LEGACY_MCP_TOOL_PREFIX)
|
|
211
|
+
? MCP_TOOL_PREFIX + name.slice(LEGACY_MCP_TOOL_PREFIX.length)
|
|
212
|
+
: name;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// The standalone binary, as installed in <home>/bin and as a release asset
|
|
216
|
+
// prefix (`<name>-<target>`). The release carries both assets for one version,
|
|
217
|
+
// install.sh and `upgrade` install the first and keep the second as a link, so
|
|
218
|
+
// a shell alias, a CI script or an old binary's `pr-hero upgrade` keeps
|
|
219
|
+
// resolving. The version that drops the legacy name deletes LEGACY_BIN_NAME and
|
|
220
|
+
// the fallbacks that read it.
|
|
221
|
+
export const BIN_NAME = "crysk";
|
|
222
|
+
export const LEGACY_BIN_NAME = "pr-hero";
|
|
223
|
+
|
|
224
|
+
// CI identifiers. The workflow file new repos get, and the one a repo set up
|
|
225
|
+
// before the rename keeps (it is updated in place, never duplicated: two
|
|
226
|
+
// workflow files would review every pull request twice). Filesystem lookups
|
|
227
|
+
// that choose between them live in brand-paths.ts.
|
|
228
|
+
export const WORKFLOW_FILE_NAME = "crysk.yml";
|
|
229
|
+
export const LEGACY_WORKFLOW_FILE_NAME = "pr-hero.yml";
|
|
230
|
+
|
|
231
|
+
// The generated workflow's display name and the step that runs the action. A
|
|
232
|
+
// reader of the Actions API (the sandbox) matches runs of a workflow scaffolded
|
|
233
|
+
// before the rename too, so each has a legacy form.
|
|
234
|
+
export const WORKFLOW_DISPLAY_NAME = "Crysk Review";
|
|
235
|
+
export const LEGACY_WORKFLOW_DISPLAY_NAME = "pr-hero Review";
|
|
236
|
+
export const RUN_STEP_DISPLAY_NAME = "Run Crysk";
|
|
237
|
+
export const LEGACY_RUN_STEP_DISPLAY_NAME = "Run pr-hero";
|
|
238
|
+
|
|
239
|
+
// The artifact the action uploads the run directory as: `<prefix><pr>-<sha>`.
|
|
240
|
+
export const RUN_ARTIFACT_PREFIX = "crysk-run-";
|
|
241
|
+
export const LEGACY_RUN_ARTIFACT_PREFIX = "pr-hero-run-";
|
|
242
|
+
|
|
243
|
+
// The check run that is the durable CI admission ledger. A head first reviewed
|
|
244
|
+
// by an older release holds its attempts under the legacy name, so a reader
|
|
245
|
+
// accepts both: the attempt count must survive the rename. Only the new name
|
|
246
|
+
// is written.
|
|
247
|
+
export const ADMISSION_CHECK_RUN_NAME = "crysk/ci-admission";
|
|
248
|
+
export const LEGACY_ADMISSION_CHECK_RUN_NAME = "pr-hero/ci-admission";
|
|
249
|
+
|
|
250
|
+
export function isAdmissionCheckRunName(name: string): boolean {
|
|
251
|
+
return (
|
|
252
|
+
name === ADMISSION_CHECK_RUN_NAME ||
|
|
253
|
+
name === LEGACY_ADMISSION_CHECK_RUN_NAME
|
|
254
|
+
);
|
|
255
|
+
}
|