@counterfact-labs/cli 0.1.3 → 0.2.4
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 +176 -42
- package/bundle/client-release.json +7 -0
- package/bundle/sealed.json +908 -0
- package/dist/adapters/anthropic.js +151 -0
- package/dist/adapters/completion.js +112 -0
- package/dist/adapters/durable-write.js +34 -0
- package/dist/adapters/files.js +144 -0
- package/dist/adapters/folder-path.js +6 -0
- package/dist/adapters/git-ignore.js +49 -0
- package/dist/adapters/git.js +44 -0
- package/dist/adapters/ignored-files.js +36 -0
- package/dist/adapters/instructions.js +35 -0
- package/dist/adapters/models.js +51 -0
- package/dist/adapters/output-paths.js +92 -0
- package/dist/adapters/prompt-cache.js +28 -0
- package/dist/adapters/public-instructions.js +36 -0
- package/dist/adapters/quality.js +6 -0
- package/dist/adapters/relay-plan.js +15 -0
- package/dist/adapters/release.js +62 -0
- package/dist/adapters/report.js +29 -0
- package/dist/adapters/repository-files.js +199 -0
- package/dist/adapters/repository-root.js +120 -0
- package/dist/adapters/results.js +9 -0
- package/dist/adapters/settings.js +26 -0
- package/dist/adapters/snapshot.js +68 -0
- package/dist/analysis-core/analysis/analysis-flags.js +1 -0
- package/dist/analysis-core/analysis/code-agents/skipped-files.js +1 -0
- package/dist/analysis-core/analysis/finding-quality/config.js +1 -0
- package/dist/analysis-core/analysis/finding-quality/policy.js +1 -0
- package/dist/analysis-core/analysis/headlines/attachment.js +1 -0
- package/dist/analysis-core/analysis/headlines/input.js +1 -0
- package/dist/analysis-core/analysis/headlines/types.js +1 -0
- package/dist/analysis-core/analysis/schemas.js +1 -0
- package/dist/analysis-core/analysis/source-notes/types.js +1 -0
- package/dist/analysis-core/chunks/2PSNOSJ2.js +1 -0
- package/dist/analysis-core/chunks/3227KXHF.js +1 -0
- package/dist/analysis-core/chunks/326F4XNG.js +1 -0
- package/dist/analysis-core/chunks/3CKW5JIF.js +1 -0
- package/dist/analysis-core/chunks/3GUKUEEJ.js +1 -0
- package/dist/analysis-core/chunks/3MTXB4MK.js +6 -0
- package/dist/analysis-core/chunks/4F6ZIHXU.js +1 -0
- package/dist/analysis-core/chunks/57M4OQJM.js +1 -0
- package/dist/analysis-core/chunks/6YCABS5T.js +1 -0
- package/dist/analysis-core/chunks/724WZMYW.js +2 -0
- package/dist/analysis-core/chunks/74FPPPIG.js +1 -0
- package/dist/analysis-core/chunks/7OYIBWX3.js +1 -0
- package/dist/analysis-core/chunks/D6AWHLRI.js +1 -0
- package/dist/analysis-core/chunks/DRGDIIFA.js +1 -0
- package/dist/analysis-core/chunks/E7TFIHC5.js +1 -0
- package/dist/analysis-core/chunks/EH3QQ3T4.js +1 -0
- package/dist/analysis-core/chunks/FSLWD2PE.js +1 -0
- package/dist/analysis-core/chunks/FTODBFQW.js +1 -0
- package/dist/analysis-core/chunks/HPIAEQHE.js +37 -0
- package/dist/analysis-core/chunks/HTLIRVP7.js +1 -0
- package/dist/analysis-core/chunks/IBCFGUHI.js +1 -0
- package/dist/analysis-core/chunks/IVDDV6CU.js +14 -0
- package/dist/analysis-core/chunks/J4AXGE5W.js +1 -0
- package/dist/analysis-core/chunks/JF4GYMOZ.js +1 -0
- package/dist/analysis-core/chunks/JKWTHRUR.js +1 -0
- package/dist/analysis-core/chunks/K5OTWBTT.js +22 -0
- package/dist/analysis-core/chunks/KU5DINLW.js +1 -0
- package/dist/analysis-core/chunks/MJGB25S5.js +1 -0
- package/dist/analysis-core/chunks/MXXNED6N.js +7 -0
- package/dist/analysis-core/chunks/NCWEOJVJ.js +6 -0
- package/dist/analysis-core/chunks/O652FQQH.js +1 -0
- package/dist/analysis-core/chunks/OFBJNHC6.js +1 -0
- package/dist/analysis-core/chunks/PYKAERZZ.js +1 -0
- package/dist/analysis-core/chunks/QDYMR6KS.js +1 -0
- package/dist/analysis-core/chunks/QMIXCT62.js +1 -0
- package/dist/analysis-core/chunks/QV2EOS7U.js +1 -0
- package/dist/analysis-core/chunks/SL27GMEN.js +1 -0
- package/dist/analysis-core/chunks/STZOC7LN.js +1 -0
- package/dist/analysis-core/chunks/T2SAP7OV.js +60 -0
- package/dist/analysis-core/chunks/T5TREZCQ.js +1 -0
- package/dist/analysis-core/chunks/T66VDFXF.js +1 -0
- package/dist/analysis-core/chunks/TDNTU4TF.js +1 -0
- package/dist/analysis-core/chunks/U5HOEVPE.js +1 -0
- package/dist/analysis-core/chunks/UEWL3GMQ.js +1 -0
- package/dist/analysis-core/chunks/V7BFUTM7.js +1 -0
- package/dist/analysis-core/chunks/VGYWI4X2.js +1 -0
- package/dist/analysis-core/chunks/Y7JGSUOA.js +1 -0
- package/dist/analysis-core/chunks/ZAA44GPI.js +1 -0
- package/dist/analysis-core/contracts/requests.js +1 -0
- package/dist/analysis-core/conventions/analysis-fit.js +1 -0
- package/dist/analysis-core/conventions/file-admission.js +1 -0
- package/dist/analysis-core/data/finding-types.js +1 -0
- package/dist/analysis-core/errors.js +1 -0
- package/dist/analysis-core/findings/presentation.js +1 -0
- package/dist/analysis-core/github/repo-key.js +1 -0
- package/dist/analysis-core/import/outside-loader-sources.js +1 -0
- package/dist/analysis-core/index.js +6 -0
- package/dist/analysis-core/llm/cache-policy.js +1 -0
- package/dist/analysis-core/llm/cost.js +1 -0
- package/dist/analysis-core/llm/execution.js +1 -0
- package/dist/analysis-core/llm/output-limit.js +1 -0
- package/dist/analysis-core/llm/slots.js +1 -0
- package/dist/analysis-core/llm/stable-json.js +1 -0
- package/dist/analysis-core/llm/structured-output-error.js +1 -0
- package/dist/analysis-core/map-limit.js +1 -0
- package/dist/analysis-core/requests/answer-formats.js +1 -0
- package/dist/analysis-core/requests/check-diagnostics.js +1 -0
- package/dist/analysis-core/requests/headline-request.js +1 -0
- package/dist/analysis-core/requests/instruction-text.js +1 -0
- package/dist/analysis-core/requests/local-plan.js +1 -0
- package/dist/analysis-core/requests/registry.js +1 -0
- package/dist/analysis-core/requests/schema-descriptions.js +1 -0
- package/dist/analysis-core/requests/shape-finding-input.js +1 -0
- package/dist/analysis-core/requests/template-version.js +1 -0
- package/dist/analysis-core/requests/tools.js +1 -0
- package/dist/analysis-core/settings.js +1 -0
- package/dist/bundle/seal/deserialise.js +75 -0
- package/dist/bundle/seal/encryption.js +25 -0
- package/dist/bundle/seal/metadata.js +69 -0
- package/dist/bundle/seal/open.js +38 -0
- package/dist/bundle/seal/planned-calls.js +20 -0
- package/dist/bundle/seal/signature.js +51 -0
- package/dist/cli/agent-folder.js +17 -0
- package/dist/cli/api-types.js +2 -0
- package/dist/cli/api.js +1 -0
- package/dist/{claude-code-permission.js → cli/claude-code-permission.js} +4 -3
- package/dist/cli/commands/analyze.js +75 -0
- package/dist/cli/commands/login.js +51 -0
- package/dist/cli/completion-recovery.js +18 -0
- package/dist/{context.js → cli/context.js} +8 -14
- package/dist/cli/development-relay.js +34 -0
- package/dist/cli/email-sign-in.js +56 -0
- package/dist/{git.js → cli/git.js} +12 -8
- package/dist/cli/intake-payload.js +18 -0
- package/dist/{main.js → cli/main.js} +23 -12
- package/dist/{mcp.js → cli/mcp.js} +109 -40
- package/dist/cli/output.js +10 -0
- package/dist/cli/relay-check.js +239 -0
- package/dist/cli/relay-preparation.js +33 -0
- package/dist/cli/sign-in-input.js +97 -0
- package/dist/{sign-in.js → cli/sign-in.js} +2 -1
- package/dist/cli/suggested-email.js +10 -0
- package/dist/cli/summary.js +30 -0
- package/dist/contract/cli-api-messages.js +5 -0
- package/dist/contract/cli-refusals.js +24 -0
- package/dist/contract/cli-version.js +1 -0
- package/dist/contract/console-url.js +8 -0
- package/dist/contract/console.js +131 -0
- package/dist/contract/email-sign-in-messages.js +18 -0
- package/dist/contract/messages.js +252 -0
- package/dist/contract/release-key.js +2 -0
- package/dist/contract/runtime-environment.js +37 -0
- package/dist/core/analysis/finding-quality/config.js +4 -0
- package/dist/core/analysis/run-to-end.js +55 -0
- package/dist/core/analysis/structural-run.js +16 -0
- package/dist/gatekeeper/attestation.js +67 -0
- package/dist/gatekeeper/certificate-algorithms.js +18 -0
- package/dist/gatekeeper/certificate-path.js +99 -0
- package/dist/gatekeeper/cli-api.js +174 -0
- package/dist/gatekeeper/client.js +76 -0
- package/dist/gatekeeper/connection-exchange.js +61 -0
- package/dist/gatekeeper/connection.js +140 -0
- package/dist/gatekeeper/console.js +175 -0
- package/dist/gatekeeper/loopback.js +5 -0
- package/dist/gatekeeper/model.js +70 -0
- package/dist/gatekeeper/production-attestation.js +149 -0
- package/dist/gatekeeper/trust/hardware.js +21 -0
- package/dist/gatekeeper/trust/policy.js +42 -0
- package/dist/gatekeeper/trust/production.json +25 -0
- package/dist/setup-pings/client.js +31 -0
- package/dist/setup-pings/contract.js +2 -0
- package/dist/setup-pings/policy.js +3 -0
- package/dist/setup-pings/state.js +261 -0
- package/dist/setup-pings/worker.js +95 -0
- package/dist/transport/base64url.js +9 -0
- package/dist/transport/http-response.js +89 -0
- package/dist/transport/tls-exporter.js +5 -0
- package/package.json +57 -11
- package/LICENSE +0 -1
- package/dist/api-types.js +0 -2
- package/dist/api.js +0 -97
- package/dist/commands/check.js +0 -104
- package/dist/commands/login.js +0 -9
- package/dist/files.js +0 -99
- package/dist/gitignore.js +0 -70
- package/dist/output.js +0 -23
- package/dist/secret-files.js +0 -5
- /package/dist/{browser.js → cli/browser.js} +0 -0
- /package/dist/{commands → cli/commands}/balance.js +0 -0
- /package/dist/{commands → cli/commands}/finding.js +0 -0
- /package/dist/{commands → cli/commands}/logout.js +0 -0
- /package/dist/{credentials.js → cli/credentials.js} +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { snapshotSettings } from "../analysis-core/settings.js";
|
|
2
|
+
// A run keeps its supplied switches even if the process environment later changes.
|
|
3
|
+
export function readJobSettings(env = process.env) {
|
|
4
|
+
return snapshotSettings(env);
|
|
5
|
+
}
|
|
6
|
+
export function readTransportSettings(env = process.env) {
|
|
7
|
+
return Object.freeze({ CF_LOCAL_RELAY: env.CF_LOCAL_RELAY, CF_RELAY_DEV: env.CF_RELAY_DEV, ANTHROPIC_API_KEY: env.ANTHROPIC_API_KEY,
|
|
8
|
+
...Object.fromEntries(["CF_RELAY_URL", "CF_CONSOLE_URL", "CF_CONSOLE_TOKEN", "CF_RELAY_DEV_TRUST", "CF_RELAY_DEV_BUNDLE", "CF_RELAY_DEV_RELEASE"].filter(key => env[key] !== undefined).map(key => [key, env[key]])) });
|
|
9
|
+
}
|
|
10
|
+
/** Only creation fills defaults; continuation consumes its saved snapshot unchanged. */
|
|
11
|
+
export function newRunSettings(caller, env = process.env) {
|
|
12
|
+
const choice = caller?.CF_FINDING_HEADLINES || env.CF_FINDING_HEADLINES || "0";
|
|
13
|
+
if (choice !== "0" && choice !== "1")
|
|
14
|
+
throw new Error("CF_FINDING_HEADLINES must be 0 or 1.");
|
|
15
|
+
const outside = caller?.CF_IMPORT_OUTSIDE_LOADERS || env.CF_IMPORT_OUTSIDE_LOADERS || "0";
|
|
16
|
+
const refuseTooLarge = caller?.CF_REFUSE_TOO_LARGE ?? env.CF_REFUSE_TOO_LARGE ?? "1";
|
|
17
|
+
return snapshotSettings({ ...(caller ?? env), CF_FINDING_HEADLINES: choice, CF_IMPORT_OUTSIDE_LOADERS: outside, CF_REFUSE_TOO_LARGE: refuseTooLarge });
|
|
18
|
+
}
|
|
19
|
+
/** The installed command selects the relay; source-only switches remain on the development runner. */
|
|
20
|
+
export function readCliSettings(env = process.env, emailSignIn) {
|
|
21
|
+
return Object.freeze({ settings: newRunSettings(undefined, env), transport: readTransportSettings(env),
|
|
22
|
+
baseUrl: env.COUNTERFACT_URL ?? env.CF_CONSOLE_URL, emailSignIn: emailSignIn ?? readEmailSignIn(env) });
|
|
23
|
+
}
|
|
24
|
+
export function readEmailSignIn(env = process.env) {
|
|
25
|
+
return env.CF_EMAIL_SIGN_IN !== "0";
|
|
26
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { realpath } from "node:fs/promises";
|
|
3
|
+
import { basename, relative, resolve } from "node:path";
|
|
4
|
+
import { mapLimit } from "../analysis-core/map-limit.js";
|
|
5
|
+
import { COMMITTED_FILES_MESSAGE } from "../contract/cli-refusals.js";
|
|
6
|
+
import { gitRepositoryRoot } from "./repository-root.js";
|
|
7
|
+
import { runGit } from "./git.js";
|
|
8
|
+
async function snapshotContext(folder, revision = "HEAD", selectionFolder = folder) {
|
|
9
|
+
const root = await realpath(resolve(folder));
|
|
10
|
+
const git = (...args) => runGit(root, args, { maxBuffer: 16 * 1024 * 1024, timeout: 10000 });
|
|
11
|
+
const found = await gitRepositoryRoot(async (args) => (await git(...args)).toString("utf8"));
|
|
12
|
+
if (found === null)
|
|
13
|
+
throw new Error();
|
|
14
|
+
const top = await realpath(found), prefix = relative(top, root).replaceAll("\\", "/");
|
|
15
|
+
const commit = (await git("rev-parse", "--verify", `${revision}^{commit}`)).toString("utf8").trim();
|
|
16
|
+
if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(commit))
|
|
17
|
+
throw new Error();
|
|
18
|
+
const selection = await realpath(resolve(selectionFolder));
|
|
19
|
+
return { repository: `local/${basename(selection)}`, commit, read: async (path, repositoryRelative = false) => {
|
|
20
|
+
if (!path || path.includes("\\") || path.startsWith("/") || path.split("/").some(part => !part || part === "." || part === ".."))
|
|
21
|
+
throw new Error();
|
|
22
|
+
return git("cat-file", "blob", `${commit}:${prefix && !repositoryRelative ? `${prefix}/` : ""}${path}`);
|
|
23
|
+
} };
|
|
24
|
+
}
|
|
25
|
+
/** Compare captured bytes to Git objects, so upload never rereads a changing working file. */
|
|
26
|
+
export async function snapshotProvenance(folder, files, options = {}) {
|
|
27
|
+
try {
|
|
28
|
+
const context = await snapshotContext(folder, "HEAD", options.selectionFolder);
|
|
29
|
+
if (!Object.keys(files).length)
|
|
30
|
+
throw new Error();
|
|
31
|
+
const hashes = await mapLimit(Object.entries(files), 4, async ([path, text]) => {
|
|
32
|
+
if (!(await context.read(path)).equals(Buffer.from(text)))
|
|
33
|
+
throw new Error();
|
|
34
|
+
return { path, hash: createHash("sha256").update(text).digest("hex") };
|
|
35
|
+
});
|
|
36
|
+
return { repository: context.repository, commit: context.commit, files: hashes };
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
throw new Error(COMMITTED_FILES_MESSAGE);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Legacy recovery must prove the saved identity and hashes against this checkout, without reading working files. */
|
|
43
|
+
export async function matchesSnapshotProvenance(folder, saved) {
|
|
44
|
+
try {
|
|
45
|
+
if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/i.test(saved.commit) || !saved.files.length)
|
|
46
|
+
return false;
|
|
47
|
+
const context = await snapshotContext(folder, saved.commit);
|
|
48
|
+
if (saved.repository !== context.repository)
|
|
49
|
+
return false;
|
|
50
|
+
// Historical snapshots use either selection-relative or repository-relative coordinates, never a mixture.
|
|
51
|
+
for (const repositoryRelative of [false, true]) {
|
|
52
|
+
const matches = await mapLimit(saved.files, 4, async (file) => {
|
|
53
|
+
try {
|
|
54
|
+
return createHash("sha256").update(await context.read(file.path, repositoryRelative)).digest("hex") === file.hash.toLowerCase();
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (matches.every(Boolean))
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c}from"../chunks/OFBJNHC6.js";export{c as analysisFlagsOf,a as readAnalysisFlags,b as readParallelPassSettings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d}from"../../chunks/2PSNOSJ2.js";import"../../chunks/724WZMYW.js";export{b as mergeSkippedFiles,d as mergeUnlistedFileWarnings,a as scanSkippedFiles,c as skippedFileWarnings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as a,o as b,p as c,q as d,r as e,s as f}from"../../chunks/DRGDIIFA.js";import"../../chunks/6YCABS5T.js";import"../../chunks/SL27GMEN.js";import"../../chunks/3CKW5JIF.js";import"../../chunks/STZOC7LN.js";import"../../chunks/MJGB25S5.js";import"../../chunks/UEWL3GMQ.js";import"../../chunks/OFBJNHC6.js";import"../../chunks/3227KXHF.js";import"../../chunks/HPIAEQHE.js";import"../../chunks/74FPPPIG.js";import"../../chunks/EH3QQ3T4.js";import"../../chunks/JKWTHRUR.js";import"../../chunks/FSLWD2PE.js";import"../../chunks/JF4GYMOZ.js";import"../../chunks/3GUKUEEJ.js";import"../../chunks/T5TREZCQ.js";import"../../chunks/724WZMYW.js";export{f as assertFindingQualityPrompts,b as findingAnalysisTemplate,e as findingQualityConfigOf,a as findingQualityPromptNames,c as plannedFindingQualityCalls,d as readFindingQualityConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as a,j as b}from"../../chunks/MXXNED6N.js";import"../../chunks/U5HOEVPE.js";import"../../chunks/HPIAEQHE.js";import"../../chunks/74FPPPIG.js";import"../../chunks/EH3QQ3T4.js";import"../../chunks/JKWTHRUR.js";import"../../chunks/FSLWD2PE.js";import"../../chunks/JF4GYMOZ.js";import"../../chunks/3GUKUEEJ.js";import"../../chunks/T5TREZCQ.js";import"../../chunks/724WZMYW.js";export{a as assessFindings,b as rankFindings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d}from"../../chunks/O652FQQH.js";import"../../chunks/57M4OQJM.js";import"../../chunks/IBCFGUHI.js";import"../../chunks/HPIAEQHE.js";import"../../chunks/74FPPPIG.js";import"../../chunks/EH3QQ3T4.js";import"../../chunks/JKWTHRUR.js";import"../../chunks/FSLWD2PE.js";import"../../chunks/JF4GYMOZ.js";import"../../chunks/3GUKUEEJ.js";import"../../chunks/T5TREZCQ.js";import"../../chunks/724WZMYW.js";export{d as attachHeadlineResults,c as attachHeadlineRows,a as headlineTargetFingerprint,b as headlineWordingAt};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as b,b as c}from"../../chunks/FTODBFQW.js";import{c as a}from"../../chunks/ZAA44GPI.js";import"../../chunks/3227KXHF.js";import"../../chunks/O652FQQH.js";import"../../chunks/57M4OQJM.js";import"../../chunks/IBCFGUHI.js";import"../../chunks/HPIAEQHE.js";import"../../chunks/74FPPPIG.js";import"../../chunks/EH3QQ3T4.js";import"../../chunks/JKWTHRUR.js";import"../../chunks/FSLWD2PE.js";import"../../chunks/JF4GYMOZ.js";import"../../chunks/3GUKUEEJ.js";import"../../chunks/T5TREZCQ.js";import"../../chunks/724WZMYW.js";export{b as buildHeadlineInput,c as headlineInputHash,a as headlineRequest};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e}from"../../chunks/KU5DINLW.js";export{b as HEADLINE_REJECTION_REASONS,a as HEADLINE_RESULT_VERSION,c as headlineDiagnosticsSchema,d as headlineRejectionSchema,e as headlineValidationReportSchema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{lb as f,mb as g,nb as h,ob as i,ub as j,vb as k,wb as l,xb as m,yb as n,zb as o}from"../chunks/HPIAEQHE.js";import"../chunks/74FPPPIG.js";import{c as a,d as b,e as c,f as d,g as e}from"../chunks/EH3QQ3T4.js";import"../chunks/JKWTHRUR.js";import"../chunks/FSLWD2PE.js";import"../chunks/JF4GYMOZ.js";import"../chunks/3GUKUEEJ.js";import"../chunks/T5TREZCQ.js";import"../chunks/724WZMYW.js";export{j as MAX_FINDINGS,h as attachFiles,k as cleanFindings,m as cleanFixDelta,g as cleanFragment,d as findingsSchema,e as findingsSchemaFor,n as fingerprintOf,l as fixFingerprintOf,a as inspectFixSchema,i as mergeGraphs,f as normaliseBrand,o as numberLines,b as otherSiteSchema,c as rawFindingSchema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c}from"../../chunks/PYKAERZZ.js";import{a,c as b}from"../../chunks/UEWL3GMQ.js";import"../../chunks/FSLWD2PE.js";export{a as SOURCE_ROLES,c as rolesForCategory,b as sourceNotesSchema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as f}from"./724WZMYW.js";function g(o){return o.skippedFiles??(o.notRead??[]).map(({path:t,kind:r})=>({path:t,reason:r==="prompt-too-large"?"too-large":"allowance"}))}function u(...o){let t={"secret-content":-7,secret:-6,hidden:-5,excluded:-4,"wrong-type":-3,empty:-2,"out-of-scope":-1,"too-large":0,allowance:1,"tool-limit":2,"scan-limit":3,total:4,unreadable:5,missing:6},r=new Map;for(let n of o)for(let e of n??[]){let s=r.get(e.path);(!s||t[e.reason]<t[s.reason])&&r.set(e.path,e)}return[...r.values()]}function d(o,t=0){let r=u(o),n=(...i)=>r.filter(({reason:p})=>i.includes(p)).length,e=r.filter(i=>i.reason==="secret-content").map(i=>f(i.path)),s=n("too-large"),a=n("allowance","tool-limit"),l=n("total","scan-limit"),c=n("missing","unreadable");return s&&e.push(`${s} ${s===1?"file was":"files were"} too big to read.`),a&&e.push(`${a} ${a===1?"file wasn't":"files weren't"} read because the file allowance was reached.`),l&&e.push(`${l} ${l===1?"file wasn't":"files weren't"} read because the repository is large.`),c&&e.push(`${c} ${c===1?"file couldn't":"files couldn't"} be read, so some tools may be missing.`),t>0&&e.push(`${t} more ${t===1?"file wasn't":"files weren't"} read.`),e}function w(o,t){return t?[...o.filter(n=>{let e=/^(\d+) more (?:file wasn't|files weren't) read\.$/.exec(n);return e?(t+=Number(e[1]),!1):!0}),...d([],t)]:[...o]}export{g as a,u as b,d as c,w as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={explain:"claude-sonnet-5",generate:"claude-opus-5-5",grade:"claude-opus-5-5",mechanical:"claude-haiku-4-5",chat:"claude-sonnet-5"},a=64e3;export{e as a,a as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function w(r,i,s,c){let a=new Array(r.length),n=0,e=!1,l,h=async()=>{for(;n<r.length;){let t=n++;a[t]=await s(r[t],t)}},o=Array.from({length:Math.min(Math.max(1,i),r.length)},()=>h());if(await Promise.all(c?.settleStartedOnError?o.map(t=>t.catch(f=>{e||(e=!0,l=f)})):o),e)throw l;return a}export{w as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as C,b as F}from"./STZOC7LN.js";import{a as c}from"./MJGB25S5.js";import{z as t}from"zod";var O=Object.freeze(["CF_MULTI_PASS","CF_SPLIT_CHECK","CF_FINDING_CHECK","CF_SOURCE_NOTES","CF_PARALLEL_PASSES","CF_PASS_CONCURRENCY","CF_PARALLEL_SCOPE_CHECK","CF_FINDING_QUALITY","CF_FINDING_FULL_CONTEXT","CF_FINDING_PRECISION_RULES","CF_PROMPT_AGREE","CF_FINDING_SECOND_OPINION","CF_FINDING_RANKING","CF_FINDING_SEMANTIC_MATCHING","CF_FINDING_CODE_INPUTS","CF_FINDING_RECALL","CF_FINDING_RECALL_VARIANT","CF_FINDING_SECOND_OPINION_MODEL","CF_FINDING_SECOND_OPINION_PROVIDER","CF_FIX_EXPECTED_OUTCOME","CF_UNTRUSTED_CONTENT_CHECK","CF_FINDING_BETTER_AS_CODE","CF_CODE_AGENTS","CF_CODE_AGENTS_MODEL","CF_FINDING_DEDUPE","CF_ANALYSIS_IMPORTED_AGENTS","CF_RECALL_SIGNALS","CF_READING_NOTE_AGENT_ONLY","CF_SPLIT_HELPER_TOOLS","CF_CODE_PROMPT_LOADERS","CF_CODE_PROMPT_FUNCTIONS","CF_READING_PRIORITY","CF_LOCAL_SYMLINK_GUARD","CF_IMPORT_EXAMPLE_FILTER","CF_IMPORT_OUTSIDE_LOADERS","CF_SECRET_SCAN","CF_RESPECT_GITIGNORE","CF_IMPORT_COVERAGE","CF_IMPORT_MANIFEST","CF_IMPORT_SCOPED_SCAN","CF_IMPORT_INCLUDE_EXAMPLES","CF_IMPORT_WEAK_CODE_FALLBACK","CF_REFUSE_TOO_LARGE","CF_FINDING_HEADLINES","CF_IMPORT_LAYOUTS","CF_DISCOVERY_SKILLS","CF_IMPORT_CALLS","CF_PROMPT_CACHE","CF_MODEL_READER","CF_LEGACY_TOOL_LISTS"]),a=O.filter(e=>e!=="CF_IMPORT_OUTSIDE_LOADERS"&&e!=="CF_SECRET_SCAN"&&e!=="CF_RESPECT_GITIGNORE"&&e!=="CF_IMPORT_COVERAGE"&&e!=="CF_IMPORT_MANIFEST"&&e!=="CF_IMPORT_SCOPED_SCAN"&&e!=="CF_IMPORT_INCLUDE_EXAMPLES"&&e!=="CF_IMPORT_WEAK_CODE_FALLBACK"&&e!=="CF_REFUSE_TOO_LARGE");function N(e,_="request"){return Object.freeze(Object.fromEntries((_==="saved"?O:a).filter(i=>Object.hasOwn(e,i)).map(i=>[i,e[i]])))}var p=t.partialRecord(t.enum(a),t.string()),E=t.lazy(()=>t.union([t.string(),t.number(),t.boolean(),t.null(),t.array(E),t.record(t.string(),E)])),l=t.object({data:t.record(t.string(),E),settings:p,maxInputBytes:t.number().int().positive().optional()}).strict(),S=t.string().min(1).max(128).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]*$/),T=t.object({maxTokens:t.number().int().positive().optional(),effort:t.enum(["low","medium","high","max"]).optional(),thinking:t.literal("disabled").optional(),promptCache:t.boolean().optional()}).strict(),R=t.object({template:t.string().min(1),inputs:l,answerFormat:t.string().min(1),model:S,limits:T.optional()}).strict();function P(e,_={},o){let i={data:e.inputs,settings:N(_),...o===void 0?{}:{maxInputBytes:o}};return R.parse({...e,answerFormat:Object.hasOwn(r,e.template)?A(e.template,e.answerFormat,_):e.answerFormat,limits:{...e.limits,promptCache:c(_,{template:e.template},e.model).enabled},inputs:JSON.parse(JSON.stringify(i))})}var n=(e,..._)=>Object.freeze({role:e,answerFormats:Object.freeze(_)}),s=F().map(e=>e.name),r=Object.freeze({"derive-findings":n("required",...s),"derive-findings-legacy":n("required",...s),"derive-findings-no-outcome":n("required",...s),"derive-findings-legacy-no-outcome":n("required",...s),"benchmark-judge":n("required","judge"),"judge-code-prompt":n("optional","codeJudge"),"derive-structure":n("optional","structures"),"structure-recheck":n("optional","recheck"),"derive-shape":n("optional","shape"),"scope-items":n("optional","structureScope"),"scope-findings":n("optional","scope"),"check-findings":n("optional","check"),"check-findings-precision-v1":n("optional","check"),"second-opinion":n("optional","opinion"),"explain-sources":n("optional","sourceNotes"),"finding-headlines":n("optional","findingHeadlines")});function D(){return r}function f(e,_,o){let i=o??(e==="derive"?"derive-findings":"check-findings");if(!Object.keys(r).filter(I=>r[I].answerFormats.includes(e==="derive"?"findings":"check")).includes(i))throw new Error("Unknown analysis template");return e==="derive"&&!C(_).switches.expectedOutcome&&!i.endsWith("-no-outcome")?`${i}-no-outcome`:i}function A(e,_,o){let i=_==="findings"?C(o).name:_;if(!Object.hasOwn(r,e)||!r[e].answerFormats.includes(i))throw new Error("Unsupported template answer format");return i}function g(e,_,o){if(o(_),!Object.hasOwn(r,e)||r[e].role!=="optional")throw _}export{O as a,N as b,l as c,S as d,T as e,R as f,P as g,D as h,f as i,A as j,g as k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var l="This folder has more than one analysis can read. Choose a smaller folder, such as one agent's folder.",s=class extends Error{code;retryable;constructor(n,t,a){super(t),this.code=n,this.name="JobError",this.retryable=a?.retryable??!1}};function o(e){if(e instanceof s&&["org_spend_limit","lease_lost","cancelled","canceled","replay_miss"].includes(e.code)||e instanceof Error&&e.name==="AbortError"||e&&typeof e=="object"&&"kind"in e&&["spending_stop","lease_lost","cancelled"].includes(String(e.kind)))throw e}export{l as a,s as b,o as c};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var s=32768;function p(e){return e.map(n=>`${n.id} [${n.category}] ${n.title}
|
|
2
|
+
${n.sites.map(t=>` ${t.path}:${t.line??"?"} \u2014 ${t.excerpt??""}`).join(`
|
|
3
|
+
`)}`).join(`
|
|
4
|
+
`)}function o(e){if(e>32768)throw new Error("The split's finding input exceeds its reserved budget.")}function a(e){let{bundleText:n}=e;function t(i){if(!i.length)return"";let r=n("analysis-split-check-finding-input-1",{v0:p(i)});return o(Buffer.byteLength(`
|
|
5
|
+
|
|
6
|
+
${r}`)),r}return{SHAPE_FINDINGS_INPUT_BYTES:32768,shapeFindingsText:t}}export{s as a,p as b,o as c,a as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(t,u,n,e={}){let l=u.buildAnalysisCall(n);return e.onSend?.(u.callInputBytes(l)),t.structured({...l,...e.signal?{signal:e.signal}:{},...e.route===void 0?{}:{route:e.route}})}export{r as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(r){if(Array.isArray(r))return r.map(t);if(r!==null&&typeof r=="object"){let e=r,n={};for(let o of Object.keys(e).sort())Object.defineProperty(n,o,{value:t(e[o]),enumerable:!0,writable:!0,configurable:!0});return n}return r}function i(r){return t(r)}function f(r){return JSON.stringify(i(r))}export{i as a,f as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=Object.freeze({"benchmark-judge":"score_match","judge-code-prompt":"judge-code-prompt","derive-findings":"derive_findings","derive-findings-legacy":"derive_findings","derive-findings-no-outcome":"derive_findings","derive-findings-legacy-no-outcome":"derive_findings","derive-structure":"derive_structure","structure-recheck":"structure_recheck","derive-shape":"derive_shape","scope-items":"scope_check_structure","scope-findings":"scope_check","explain-sources":"explain_sources","finding-headlines":"finding_headlines","check-findings":"finding_check","check-findings-precision-v1":"finding_check","second-opinion":"finding_second_opinion"});function c(e){if(!Object.hasOwn(n,e))throw new Error("Unknown analysis template");return n[e]}function s(e){return Object.fromEntries(Object.entries(e).map(([i,r])=>[i,{...r,route:c(i)}]))}export{c as a,s as b};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var S=/example|placeholder|your[-_]?api[-_]?key|replace[-_]?me|redacted|changeme|dummy/i,_=/(?<![\w-])(?:sk-ant-(?:api\d{2}-)?([\w-]{32,})|sk-(?:proj-|svcacct-)([\w-]{32,})|sk-([A-Za-z0-9]{48})|(?:AKIA|ASIA)([A-Z0-9]{16})|gh[poru]_([A-Za-z0-9]{36,})|ghs_([A-Za-z0-9._-]{36,})|github_pat_([A-Za-z0-9]{22}_[A-Za-z0-9]{59})|xox[baprs]-([A-Za-z0-9-]{24,})|AIza([A-Za-z0-9_-]{35})|[sr]k_live_([A-Za-z0-9]{24,}))(?![\w-])/g,p=/\b(?:aws_secret_access_key|secretAccessKey)["']?\s*[:=]\s*["']?([A-Za-z0-9/+=]{40})(?![A-Za-z0-9/+=])/gi,d=/(?<![\w$-])([A-Za-z_$][\w$-]*)["']?\s*[:=]\s*(["'])([^"'\\\r\n]{20,})\2/g,E=/^[\t ]*([A-Z_][A-Z0-9_]*)[\t ]*=[\t ]*([A-Za-z0-9_+/=!:~@$%&*?^-]{20,})[\t ]*\r?$/gm,m=/https:\/\/hooks\.slack\.com\/services\/T[A-Z0-9]{8,}\/B[A-Z0-9]{8,}\/([A-Za-z0-9]{24,})(?![\w/-])/g,g=/(?<![\w.-])([A-Za-z0-9_-]{8,})\.([A-Za-z0-9_-]{8,})\.([A-Za-z0-9_-]{32,})(?![\w.-])/g,i=/-----BEGIN (?:(?:RSA |EC |DSA |OPENSSH |ENCRYPTED )?PRIVATE KEY|PGP PRIVATE KEY BLOCK)-----[\t ]*\r?\n(?:(?:Version|Comment|Proc-Type|DEK-Info):[^\r\n]*\r?\n|[\t ]*\r?\n)*[\t ]*[A-Za-z0-9+/]{32,}={0,2}[\t ]*(?:\r?\n|$)/;function h(n){let e=new Map;for(let s of n)e.set(s,(e.get(s)??0)+1);let t=0;for(let s of e.values()){let r=s/n.length;t-=r*Math.log2(r)}return t}function c(n,e){return!S.test(n)&&h(n)>=e}function f(n,e=!1){let t=n.replace(/([a-z0-9])([A-Z])/g,"$1_$2");return/(?:^|[_-])(?:page|pagination|cursor|continuation|csrf)[_-]?token(?:[_-]?name)?$/i.test(t)?!1:e?/(?:PASSWORD|SECRET|TOKEN|KEY)$/.test(n):/(?:^|[_-])(?:password|secret|token|api[_-]?key|access[_-]?key|private[_-]?key)$/i.test(t)}function u(n){if(/^(?:\$2[aby]\$|\$argon2(?:id|i|d)\$|sk_test_)/.test(n))return!1;let e=/^[a-f0-9]{32,}$/i.test(n)?3.5:4;return!/\s|\$\{|[<>]/.test(n)&&c(n,e)}function l(n){let e=Buffer.from(n,"base64url");if(e.toString("base64url")!==n)return null;let t=JSON.parse(e.toString("utf8"));return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:null}function y(n,e,t){if(n.length>4096||e.length>65536||t.length>2048)return!1;try{let s=l(n),r=l(e);if(!s||!r||typeof s.alg!="string")return!1;let A={HS256:[32],HS384:[48],HS512:[64],RS256:[256,384,512],RS384:[256,384,512],RS512:[256,384,512],PS256:[256,384,512],PS384:[256,384,512],PS512:[256,384,512],ES256:[64],ES384:[96],ES512:[132],EdDSA:[64]},a=Buffer.from(t,"base64url");return Object.keys(r).length>0&&["iss","sub","jti"].every(o=>r[o]===void 0||typeof r[o]=="string")&&["exp","iat","nbf"].every(o=>r[o]===void 0||typeof r[o]=="number"&&Number.isFinite(r[o]))&&(r.aud===void 0||typeof r.aud=="string"||Array.isArray(r.aud)&&r.aud.every(o=>typeof o=="string"))&&!!A[s.alg]?.includes(a.length)&&a.toString("base64url")===t&&c(t,3.5)}catch{return!1}}function z(n,e){if(!(!Z(n)||e===void 0)){if(i.test(e)||e.includes("\\n")&&i.test(e.replace(/\\r\\n|\\n/g,`
|
|
2
|
+
`)))return"secret-content";for(let t of e.matchAll(_)){let s=t.slice(1).find(r=>r!==void 0);if(c(s,3))return"secret-content"}for(let t of e.matchAll(p))if(c(t[1],4))return"secret-content";for(let t of e.matchAll(m))if(c(t[1],3))return"secret-content";for(let t of e.matchAll(d)){let s=t[1],r=t[3];if(f(s)&&u(r))return"secret-content"}for(let t of e.matchAll(E))if(f(t[1],!0)&&u(t[2]))return"secret-content";for(let t of e.matchAll(g))if(y(t[1],t[2],t[3]))return"secret-content"}}function Z(n){return n.CF_SECRET_SCAN!=="0"}function k(n){return`Skipped ${n}: contains what looks like an API key, password, token or private key.`}export{z as a,Z as b,k as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=["contradiction","ambiguity","description_mismatch"];function n(t){return typeof t=="string"&&i.includes(t)}export{i as a,n as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as G}from"./NCWEOJVJ.js";import{Aa as $,Ba as P,Ca as w,Fa as M,Ga as y,Ta as D,a as l,b as N,e as T,ga as E,o as C,qa as I,u as R,wa as F,za as _}from"./HPIAEQHE.js";import{a as b,c as x}from"./T5TREZCQ.js";var k="Some of this agent's files weren't read, so findings may be missing.";var B=r=>r.CF_READING_PRIORITY!=="0";var U=new Set(["system prompt","soul","knowledge","config","tools","mcp"]);function L(r){let t=new Set;for(let s of r.nodes)for(let f of s.files??[])U.has(f.role)&&t.add(f.path);let n=new Set(r.edges.filter(s=>s.kind==="delegates").map(s=>s.to));for(let s of r.nodes)n.has(s.id)&&s.sourceRef&&t.add(s.sourceRef.path);return t}function V(r){return new Set([...r.nodes,...r.edges].flatMap(t=>t.sourceRef?[t.sourceRef.path]:[]))}var p=6e4,j=r=>{if(r.length<=p)return r;let t=r.endsWith(E)?E:"";return(t?r.slice(0,-t.length):r).slice(0,p)+t};function Z(r,t){let n=[...r].filter(s=>t[s]!==void 0&&j(t[s])!==t[s]).sort();return n.length===0?null:`${n.length} core file${n.length===1?" was":"s were"} longer than ${p/1e3} KB, so only the first ${p/1e3} KB ${n.length===1?"was":"were"} read: ${n.join(", ")}`}var A=r=>r.split("/").slice(0,-1).join("/"),Y=/(agent|prompt|tool|llm|model)/i,z=2.5;function K(r,t){if(!B(r))return{enabled:!1,tierOf:()=>6};if(t.repos?.some(e=>e.kind==="github"&&b(e.root)))return v(r,t,t.repos);let n=t.scopes??(T(r)?G(r,t.paths):void 0),s=t.graph?L(t.graph):new Set,f=new Set(t.graph?.nodes.flatMap(e=>(e.files??[]).filter(o=>o.role==="code"&&l(o.path)).map(o=>o.path))??[]),i=new Set(t.graph?.nodes.flatMap(e=>(e.files??[]).filter(o=>o.role==="system prompt").map(o=>o.path))??[]),a=e=>N(e)&&(I.includes(e.split("/").pop().toLowerCase())||/(^|\/)system_prompt_[^/]+\.md$/i.test(e)||y.test(e)),c=e=>{if(s.has(e))return 1;if(f.has(e))return 2;let o=P(r,e,n),d=R(o,{nested:!0});if(d?.reference)return 5;if(d?.definition||F.test(o))return 4;if(d||/(^|\/)(docs?|references)\//i.test(o)||$.test(e.split("/").pop()))return 5;if(_(o)||w(r,e,n)&&_(e.split("/").pop())||a(e))return 1;if(l(e)){if(Y.test(e))return z;if(M.test(e))return 3}return 6};for(let e of t.paths)c(e)===1&&a(e)&&i.add(e);let m=[...i].flatMap(e=>{let o=A(e);return[o,...o?[A(o)]:[]]}),h=e=>l(e)&&m.some(o=>A(e)===o),u=new Map(t.paths.map(e=>{let o=c(e);return[e,o>2&&h(e)?2:o]})),g=[...u].filter(([e,o])=>o<=2&&l(e)).map(([e])=>e),O=D(Object.fromEntries(g.flatMap(e=>t.files?.[e]===void 0?[]:[[e,t.files[e]]])),t.paths);for(let e of O)l(e)&&!R(P(r,e,n),{nested:!0})&&(u.get(e)??6)>2&&u.set(e,2);return{enabled:!0,tierOf:e=>u.get(e)??c(e)}}function v(r,t,n){let s=new Map;for(let f of n){let i=f.kind==="github"?f.root:void 0,a=t.paths.filter(e=>f.files?.[e]!==void 0&&!s.has(e)),c=e=>x(e,i)??(f.files?.[e]!==void 0?e:null),m=e=>{let o=e?c(e.path):null;return o===null?null:{path:o}},h=t.graph&&{nodes:t.graph.nodes.map(e=>({...e,sourceRef:m(e.sourceRef),files:e.files?.flatMap(o=>{let d=c(o.path);return d===null?[]:[{...o,path:d}]})})),edges:t.graph.edges.map(e=>({...e,sourceRef:m(e.sourceRef)}))},u=a.flatMap(e=>{let o=c(e);return o===null?[]:[o]}),g=Object.fromEntries(a.flatMap(e=>{let o=c(e);return o===null||t.files?.[e]===void 0?[]:[[o,t.files[e]]]})),O=K(r,{paths:u,files:g,graph:h});for(let e of a)s.set(e,O.tierOf(c(e)??e))}return{enabled:!0,tierOf:f=>s.get(f)??6}}function H(r,t){return r.enabled?t.filter(n=>["too-large","total","allowance"].includes(n.reason)&&r.tierOf(n.path)<3).map(n=>n.path):[]}function W(r){return r.slice(0,3)}function q(r,t=!1){let n=W(r);if(!n.length)return;let s=t?". "+k:", so some findings may be missing";return`${n.join(", ")} ${n.length===1?"was":"were"} left out${s}`}function ue(r,t){return q(H(r,t))}function de(r,t){return r.enabled&&r.tierOf(t)<3}function me(r,t,n){let s=C.sourceFetch.codeFileBytes;return r.enabled&&r.tierOf(t)<3&&l(t)&&n>s?{size:s,readBytes:s}:{size:n}}function pe(r,t){return r.enabled&&r.tierOf(t)<3&&l(t)}function S(r){return r.split("/").length-1}function he(r,t,n){return w(r,t,n)?0:M.test(t)?1+Math.min(S(t),3)/10:S(t)<=2?2:S(t)<=4?3:4}function ge(r,t){return(r.tier??0)-(t.tier??0)||r.score-t.score||r.size-t.size}function Oe(r,t,n,s){return[...r].sort((f,i)=>(s?.enabled?s.tierOf(f)-s.tierOf(i):0)||Number(n.has(i))-Number(n.has(f))||t[f].length-t[i].length||(f<i?-1:1))}function Re(r,t,n,s){return[...r].sort((f,i)=>(s?.enabled?s.tierOf(f.path)-s.tierOf(i.path):0)||Number(t.has(i.path))-Number(t.has(f.path))||Number(n.has(i.path))-Number(n.has(f.path))||f.text.length-i.text.length)}export{B as a,L as b,V as c,j as d,Z as e,K as f,H as g,W as h,q as i,ue as j,de as k,me as l,pe as m,he as n,ge as o,Oe as p,Re as q};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D as O}from"./K5OTWBTT.js";import{a as N}from"./326F4XNG.js";import{b as F}from"./2PSNOSJ2.js";import{o as x}from"./HPIAEQHE.js";import{e as P}from"./T5TREZCQ.js";async function H(S,t){let a={entriesVisited:0,filesRead:0,bytesRead:0,truncated:!1},d=[],R=()=>({files:t.selected.files,selection:t.selection,skippedFiles:F(d),search:a});if(O(S,{selected:t.selected,codeAgentsFound:t.codeAgentsFound}).kind==="none")return R();let h=await t.port.context();if(!h)return R();let E=[];try{let r=e=>P(e,h.selectedRoot),L=e=>Object.fromEntries(Object.entries(e).map(([c,I])=>[r(c),I])),A={...t.selected,files:L(t.selected.files),root:h.selectedRoot,...t.selected.listedPaths?{listedPaths:t.selected.listedPaths.map(r)}:{},...t.selected.pointerFiles?{pointerFiles:L(t.selected.pointerFiles)}:{},...typeof t.selected.explicitPrompt=="string"?{explicitPrompt:r(t.selected.explicitPrompt)}:{}},l=await t.port.list();a.entriesVisited=l.entriesVisited,a.truncated=l.truncated;let w=new Map(l.entries.map(e=>[e.path,e])),u=new Set,p={},m=x.codeScan,b=()=>O(S,{selected:A,codeAgentsFound:t.codeAgentsFound,entries:l.entries,bodies:p,attemptedPaths:[...u],completeListing:!l.truncated}),n=b();for(;n.kind==="search"&&n.paths.length;){let e=[],c=0;for(let s of n.paths){let i=w.get(s);if(i.size>m.fileBytes){d.push({path:s,reason:"too-large"}),u.add(s);continue}let o=i.size+1;if(e.length>=4||a.filesRead+e.length>=m.files||a.bytesRead+c+o>m.bytes)break;e.push({entry:i,allowance:o}),c+=o}if(!e.length){if(n=b(),n.kind==="none"||!n.paths.length)break;a.truncated=!0,d.push(...n.paths.map(s=>({path:s,reason:"scan-limit"})));break}(await N(e,4,async({entry:s,allowance:i})=>{u.add(s.path),a.filesRead++;try{return await t.port.read(s,i)}catch(o){if(o instanceof Error&&o.name==="AbortError")throw o;return{text:null,bytesRead:i,refusal:"unreadable"}}},{settleStartedOnError:!0})).forEach((s,i)=>{let{entry:o,allowance:k}=e[i],z=Number.isSafeInteger(s.bytesRead)&&s.bytesRead>=0&&s.bytesRead<=k;a.bytesRead+=z?s.bytesRead:k,z&&s.text!==null&&!s.refusal&&s.bytesRead<=m.fileBytes&&s.bytesRead<k&&Buffer.byteLength(s.text)===s.bytesRead?p[o.path]=s.text:d.push({path:o.path,reason:s.refusal??"unreadable"})}),n=b()}let g=b();if(g.kind==="none"||!g.ownedPaths.length)return R();let f={...A.files};for(let e of g.ownedPaths)Object.hasOwn(p,e)&&(f[e]=p[e]);let v=e=>({...e,path:r(e.path),...e.ref===e.path?{ref:r(e.ref)}:{}}),B=t.selection.selected.map(v),M=new Set(B.map(e=>e.path)),j=g.ownedPaths.filter(e=>!M.has(e)&&Object.hasOwn(f,e)).map(e=>({...w.get(e),path:e,size:Buffer.byteLength(f[e]),ref:w.get(e)?.ref??e})),y=t.selection.readingNotes,V={files:f,root:h.selectedRoot,search:a,skippedFiles:F(d),selection:{...t.selection,selected:[...B,...j],totalBytes:t.selection.totalBytes+j.reduce((e,c)=>e+c.size,0),refused:t.selection.refused.map(e=>({...e,path:r(e.path)})),...y?{readingNotes:{instruction:y.instruction.map(r),code:y.code.map(r),agents:y.agents.map(r)}}:{}}};return E=Object.keys(f),V}finally{t.port.finish?.(E)}}export{H as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as U}from"./6YCABS5T.js";import{c as V}from"./SL27GMEN.js";import{i as b,j as v}from"./3CKW5JIF.js";import{c as y}from"./MJGB25S5.js";import{a as K}from"./OFBJNHC6.js";import{a as u,b as w}from"./3227KXHF.js";import{ub as Y}from"./HPIAEQHE.js";import{c as k,f as M}from"./JKWTHRUR.js";var l=u.chat,s=8,I=1,W=40,N=6e4,S=16e3,Q=8e4,f=4e3,q=1536,R=8192,B=1024;function h(e){return R+e*q+B}function A(e,t="legacy"){return t==="whole-file"?N+Q+f*e+4e3*4:N+(S+f)*e+4e3*2}function pe(e,t,o,n,c="legacy"){if(!o||t===0)return null;let r=Math.ceil(t/s),i=1+I,p=h(t)+(R+B)*(r-1),_={template:n};if(c==="whole-file"){let F=Math.floor(t/s),d=t%s,a=M(A(s,c))*F+(d?M(A(d,c)):0);return y(e,_,"Double-check findings",l,a*i,p*i)}let C=N*r+(S+f)*t;return y(e,_,"Double-check findings",l,(M(C)+4e3*r)*i,p*i)}var Ce=8e5;function L(e,t,o,n,c,r,i){return{routeId:U(t),templateId:t,answerFormatId:v(t,o,e),model:n,calls:c,maxInputBytes:r,maxInputTokens:2e5,maxOutputTokens:i??V({model:n})}}function X(e,t){let o=e.CF_FINDING_QUALITY==="1",n=o&&e.CF_FINDING_FULL_CONTEXT==="1",c=o&&e.CF_FINDING_PRECISION_RULES==="1",r=t?.check.name??(c?"check-findings-precision-v1":"check-findings");return{enabled:o,fullContext:n,precisionRules:c,prompts:{derive:t?.derive.name??"derive-findings-legacy",check:r==="check-findings-legacy"?"check-findings":r}}}function $(e){return X({},e.prompts).prompts}function G(e,t,{enabled:o,prompts:n}){return b(e,t,o?n[e]:void 0)}function Ae(e,t,o){return G(e,t,{enabled:o?.switches.enabled??!1,prompts:X({},o?.prompts).prompts})}function Fe(e,t,o,n){let c=K(e),r=X(e),{fullContext:i}=r,p=G("derive",e,r),_=G("check",e,r),C=i?"whole-file":"legacy";return{findings:o,derive:L(e,p,"findings",u.generate,t,n),check:c.findingCheck?L(e,_,"check",l,Math.ceil(o/s)*(I+1),Math.max(n,A(s,C)),h(s)):null}}function g(e){if(e&&typeof e=="object"){for(let t of Object.values(e))g(t);Object.freeze(e)}return e}function ee(e,t,o={}){let{enabled:n,fullContext:c,precisionRules:r,prompts:i}=X(e),p=m=>n&&e[m]==="1",_=p("CF_FINDING_SECOND_OPINION"),C=p("CF_FINDING_RANKING"),F=n&&e.CF_FINDING_SEMANTIC_MATCHING!=="0",d=o.codeInputs!==!1&&n&&e.CF_FINDING_CODE_INPUTS!=="0",a=[],x=e.CF_FINDING_RECALL_VARIANT,D=o.recall!==!1&&p("CF_FINDING_RECALL")&&(x==="request-18"||x==="two-sweeps")?x:"off";o.recall!==!1&&p("CF_FINDING_RECALL")&&D==="off"&&a.push("Recall was skipped: no supported variant was selected.");let P=null,H=null;if(o.recall===!1&&e.CF_FINDING_RECALL==="1"&&a.push("Recall isn't available in local checks yet, so CF_FINDING_RECALL has no effect."),o.codeInputs===!1&&e.CF_FINDING_CODE_INPUTS==="1"&&a.push("Code evidence isn't available in local checks yet, so CF_FINDING_CODE_INPUTS has no effect."),_&&o.secondOpinion===!1&&a.push("Second opinion was skipped: local analysis supports Anthropic only."),_&&o.secondOpinion!==!1){let m=e.CF_FINDING_SECOND_OPINION_MODEL??"",E=Object.hasOwn(k,m)?k[m]:void 0,O=k[l];E&&E.provider===e.CF_FINDING_SECOND_OPINION_PROVIDER&&E.provider!==O.provider&&E.input<=O.input&&E.output<=O.output&&(E.input<O.input||E.output<O.output)?(P=m,H=E.provider):a.push("Second opinion was skipped: configure a priced, cheaper model from a different provider.")}return g({ruleVersion:n?"precision-v1":"legacy",switches:{enabled:n,fullContext:c,precisionRules:r,secondOpinion:_,ranking:C,semanticMatching:F,codeInputs:d,recall:D!=="off"},prompts:{derive:t.promptVersion(i.derive,e),check:t.promptVersion(i.check,e)},models:{derive:u.generate,check:l,scope:u.mechanical,secondOpinion:P},caps:{coreBytes:N,siteBytes:S,findingTextBytes:f,siteWindowLines:W,citedBatchBytes:c?8e4:0,passBytes:15e4,passContextBytes:6e4,maxPasses:4,passFindings:D==="request-18"?18:Y,totalFindings:24,deriveOutputTokens:w,checkBatchSize:s,checkOutputTokens:h(s),checkMaxRetries:I,checkOverheadTokens:4e3,secondOpinionBatchSize:4,secondOpinionInputBytes:A(4)+(c?8e4:0),secondOpinionOutputTokens:2048,secondOpinionMaxRetries:I},recallVariant:D,displayPolicyVersion:C?"support-v1":"legacy",meaningMatchingVersion:F?"meaning-v1":"legacy",codeInputScopeVersion:d?"owned-code-v1":"legacy",secondOpinionProvider:H,diagnostics:a})}function De(e,t){return t?g(structuredClone(t)):ee({},e)}function ke(e,t,o={}){let n=$(e);e.switches.enabled&&t.assertPromptVersions([{...e.prompts.derive,name:n.derive},{...e.prompts.check,name:n.check}],o)}export{l as a,s as b,I as c,W as d,N as e,S as f,Q as g,f as h,h as i,A as j,pe as k,Ce as l,L as m,$ as n,Ae as o,Fe as p,ee as q,De as r,ke as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function d(i){if(!/^(?:@index|[A-Za-z_][A-Za-z0-9_-]*(?:\.[A-Za-z_][A-Za-z0-9_-]*)*)$/.test(i))throw new Error("Invalid value path");return i}function h(i){let c=[],l=[],t=c,r=0;for(;r<i.length;){let e=i.indexOf("{{",r);if(e===-1){t.push({kind:"text",value:i.slice(r)});break}e>r&&t.push({kind:"text",value:i.slice(r,e)});let a=i.indexOf("}}",e+2);if(a===-1)throw new Error("Unclosed template tag");let s=i.slice(e+2,a).trim();r=a+2;let u=/^#(if|each)\s+(.+)$/.exec(s);if(u){let n={kind:u[1],path:d(u[2]),children:[],open:i.slice(e,r),close:""};t.push(n),l.push({block:n,parent:t}),t=n.children}else if(s==="else"){let n=l.at(-1);if(!n||n.block.kind!=="if"||n.block.otherwise)throw new Error("Unexpected else");n.block.separator=i.slice(e,r),t=n.block.otherwise=[]}else if(s.startsWith("/")){let n=l.pop();if(!n||s!==`/${n.block.kind}`)throw new Error("Mismatched block end");n.block.close=i.slice(e,r),t=n.parent}else if(s.startsWith("include ")){let n=s.slice(8).trim();if(!/^[A-Za-z0-9_-]+$/.test(n))throw new Error("Invalid include name");t.push({kind:"include",value:n,raw:i.slice(e,r)})}else t.push({kind:"value",value:d(s),raw:i.slice(e,r)})}if(l.length)throw new Error("Unclosed template block");return c}function p(i,c){function l(t){return t.map(r=>{if(r.kind==="text")return r.value;if(r.kind==="value"||r.kind==="include")return r.raw;let e=r;return e.kind==="if"&&Object.hasOwn(c,e.path)?l(c[e.path]?e.children:e.otherwise??[]):e.open+l(e.children)+(e.otherwise?e.separator+l(e.otherwise):"")+e.close}).join("")}return l(h(i))}function w(i,c){if(i==="@index"){if(c.index===void 0)throw new Error("No current item");return c.index}let l=i.split("."),t=c.root;if(l[0]==="this"){if(c.index===void 0)throw new Error("No current item");t=c.current,l.shift()}for(let r of l){if(t===null||typeof t!="object"||!Object.hasOwn(t,r))throw new Error(`Missing value: ${i}`);t=t[r]}return t}function v(i,c,l={}){let t=new Map;function r(e,a,s){return e.map(u=>{if(u.kind==="text")return u.value;if(u.kind==="include"){let o=u.value;if(!Object.hasOwn(l,o))throw new Error(`Unknown include: ${o}`);if(s.includes(o))throw new Error(`Include cycle: ${o}`);return t.has(o)||t.set(o,h(l[o])),r(t.get(o),a,[...s,o])}if(u.kind==="value"){let o=w(u.value,a);if(o!==null&&typeof o=="object")throw new Error(`Expected scalar: ${u.value}`);return o===null?"":String(o)}let n=u,f=w(n.path,a);if(n.kind==="if"){let o=Array.isArray(f)?f.length>0:!!f;return r(o?n.children:n.otherwise??[],a,s)}if(!Array.isArray(f))throw new Error(`Expected array: ${n.path}`);return f.map((o,k)=>r(n.children,{root:a.root,current:o,index:k},s)).join("")}).join("")}return r(h(i),{root:c},[])}export{p as a,v as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as u,d as p}from"./FSLWD2PE.js";import{a as c,b as l,c as s,d as m,f as i}from"./JF4GYMOZ.js";function n(a,d={}){return JSON.stringify({bundleDescription:a,inputs:d})}import{z as e}from"zod";import{z as t}from"zod";var r=t.object({motivation:t.array(t.object({kind:t.string(),reason:t.string(),evidence:t.string()})),outcomes:t.array(t.object({improvement:t.string(),measurement:t.string()}))}),O=r.extend({motivation:r.shape.motivation.default([]),outcomes:r.shape.outcomes.default([])});var h=e.object({path:e.string().min(1),line:e.number().int().positive().nullable()}),f=e.object({label:e.string(),source:e.literal("mcp").optional(),brand:e.string().nullable().default(()=>null)}),x=["system prompt","soul","knowledge","skill","config","tools","mcp","template","reference","code"],y=e.object({filledAtRunTime:e.boolean().optional(),role:e.enum(x),label:e.string().nullable().default(()=>null),path:e.string().min(1),span:e.object({from:e.number().int(),to:e.number().int()}).optional()}),S=e.object({id:e.string().min(1),label:e.string().min(1),kind:e.enum(["entry","agent","tool","store","exit"]),desc:e.string(),meta:e.string().nullable(),sourceRef:h.nullable(),sourcePaths:e.array(e.string()).optional(),files:e.array(y).default(()=>[]),tools:e.array(f).default(()=>[])}),j=e.object({from:e.string().min(1),to:e.string().min(1),kind:e.enum(["invokes","delegates","reads","writes","emits"]),label:e.string().nullable(),sourceRef:h.nullable()}),_=e.object({nodes:e.array(S),edges:e.array(j),warnings:e.array(e.string())}),v=e.object({...r.shape,title:e.string().min(1).describe(n("analysis-wire-schemas-1")),approach:e.string().min(1).describe(n("analysis-wire-schemas-2")),kind:e.enum(["code","prompt"]),targetFiles:e.array(e.object({path:e.string().min(1),create:e.boolean().nullable()})),...i.shape});function o(a){return e.string().describe(n("analysis-wire-schemas-3",{v0:Object.values(a.enum).join(", ")}))}var w=e.object({nodes:e.array(e.object({id:e.string().min(1),change:o(s),label:e.string().nullable()})),edges:e.array(e.object({from:e.string().min(1),to:e.string().min(1),kind:o(m),change:o(s),detail:e.string().nullable()}))}),k=v.omit({motivation:!0,outcomes:!0}).extend({expectedOutcome:e.string().describe(n("analysis-wire-schemas-4")),summary:i.shape.summary.catch(null),impact:i.shape.impact.catch(null),objective:i.shape.objective.catch(null),blockedBy:i.shape.blockedBy.catch(null),confidence:o(l).nullable().catch(null),status:o(c).nullable().catch(null),alsoFixes:e.array(e.string()).nullable().default([]).catch(()=>[]),delta:w.nullable().catch(null)}),q=e.object({path:e.string().min(1),line:e.number().int().positive(),excerpt:e.string().trim().min(1)}),F=e.object({path:e.string(),line:e.number(),excerpt:e.string()}),b=a=>e.string().describe(n("analysis-wire-schemas-5",{v0:u(a).join(", ")})).nullable().catch(null),g=e.object({kind:e.enum(["ordering","reliability","coverage","cost","safety","correctness"]),severity:e.enum(["low","medium","high","critical"]),title:e.string().min(1).describe(n("analysis-wire-schemas-6")),cause:e.string().min(1),summary:e.string().describe(n("analysis-wire-schemas-7")).catch(""),site:e.object({path:e.string().min(1),line:e.number().int().positive().nullable()}).nullable(),excerpt:e.string().nullable(),category:b({}),otherSites:e.array(F).nullable().default([]).catch(()=>[]),question:e.string().describe(n("analysis-wire-schemas-8")).catch(""),fixes:e.array(k).min(1)}),E=e.object({findings:e.array(g)});function A(a){return p(a)?E:e.object({findings:e.array(g.extend({category:b(a)}))})}export{n as a,_ as b,k as c,q as d,g as e,E as f,A as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=t=>t.CF_UNTRUSTED_CONTENT_CHECK!=="0";function n(t){return t.CF_FINDING_BETTER_AS_CODE==="1"}var o=["contradiction","ambiguity","bypassable_requirement","stale_fact","description_mismatch","ungoverned_tool","untrusted_instructions","better_as_code"];function i(t){return o.filter(e=>(e!=="untrusted_instructions"||r(t))&&(e!=="better_as_code"||n(t)))}function _(t){return!n(t)&&r(t)}var p={contradiction:"Contradiction",ambiguity:"Ambiguity",bypassable_requirement:"Bypassable requirement",stale_fact:"Stale fact",description_mismatch:"Description mismatch",ungoverned_tool:"Ungoverned tool",untrusted_instructions:"Untrusted instructions",better_as_code:"Better as code",structure:"Structure",prompt_quality:"Prompt quality"};function l(t){return["contradiction","bypassable_requirement","stale_fact","description_mismatch","ungoverned_tool","untrusted_instructions"].includes(t)?2:1}function s(t){return typeof t=="string"&&o.includes(t)}function m(t,e){return s(t)&&i(e).includes(t)}export{r as a,n as b,i as c,_ as d,p as e,l as f,s as g,m as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p}from"./O652FQQH.js";import{b as l}from"./57M4OQJM.js";import{createHash as d}from"node:crypto";function u({repo:o,body:r}){let[t,...i]=r.evidence,n=r.split,s=e=>e.map(a=>({path:a.path??null,startLine:a.startLine,endLine:a.endLine}));return{kind:"structure",impact:r.kind,cause:r.cause,category:null,question:null,fixSummaries:[],site:t?{repo:o,path:t.path,line:t.line}:null,excerpt:t?.excerpt??null,otherSites:i.map(e=>({repo:o,path:e.path,line:e.line,excerpt:e.excerpt})),structure:{title:r.title,subKind:r.subKind,files:r.files.map(e=>({path:e.path,action:e.action,role:e.role,unit:e.unit,loadMode:e.loadMode,loadVia:e.loadVia,purpose:e.purpose})),segments:r.segments.map(e=>({path:e.path,startLine:e.startLine,endLine:e.endLine,to:e.to,disposition:e.disposition,into:e.into?{path:e.into.path,line:e.into.line}:null,reason:e.reason})),reorder:r.reorder?{path:r.reorder.path,startLine:r.reorder.startLine,endLine:r.reorder.endLine,steps:r.reorder.steps.map(e=>({from:e.from,reason:e.reason}))}:null,toolMoves:r.toolMoves.map(e=>({tool:e.tool,fromUnit:e.fromUnit,toUnit:e.toUnit,reason:e.reason})),split:n?{frontDoor:{job:n.frontDoor.job,skills:[...n.frontDoor.skills]},subAgents:n.subAgents.map(e=>({job:e.job,description:e.description,path:e.path,handoff:e.handoff??null,skills:e.skills.map(a=>({from:a.from,to:a.to})),tools:[...e.tools],movedKnowledge:s(e.movedKnowledge),neededKnowledge:s(e.neededKnowledge)}))}:null}}}function x(o,r=[]){return{evidence:[...o.map((t,i)=>({key:`f${i}`,kind:"finding",impact:t.kind,structure:null,cause:t.cause,category:t.category??null,question:t.question,site:t.site?{repo:t.siteRepo,path:t.site.path,line:t.site.line}:null,excerpt:t.excerpt,otherSites:t.otherSites.map(n=>({repo:n.repo,path:n.path,line:n.line,excerpt:n.excerpt})),fixSummaries:t.fixes.flatMap(n=>typeof n.summary=="string"&&n.summary.trim()?[n.summary]:[])})),...r.map((t,i)=>({key:`s${i}`,...u(t)}))],positions:[...o.map((t,i)=>({key:`f${i}`,target:"finding",index:i,fingerprint:p("finding",t)})),...r.map((t,i)=>({key:`s${i}`,target:"structure",index:i,fingerprint:p("structure",t)}))]}}function L(o,r){return d("sha256").update(l({batch:o,requestIdentity:r})).digest("hex")}export{x as a,L as b};
|