failproofai 0.0.14-beta.0 → 0.0.14-beta.1
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/.next/standalone/.codex/hooks.json +6 -6
- package/.next/standalone/.cursor/hooks.json +6 -6
- package/.next/standalone/.factory/hooks.json +9 -9
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +5 -5
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/required-server-files.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +15 -15
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +15 -15
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +10 -10
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/reminder/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +15 -15
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +15 -15
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +10 -10
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/page/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/policies/page/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +8 -8
- package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/projects/page/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0q2nbsl._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0xuaoik._.js +3 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1fwl2mz._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1mrihkj._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1myjm-d._.js +1 -1
- package/.next/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_01r25oi._.js +1 -1
- package/.next/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_09z9-p7._.js +1 -1
- package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__00cz9as._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__015_i4t._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__03lv-pe._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__042d3cd._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__09q1168._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0brjczq._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0h12me5._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0hdsupo._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0qeuy9c._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0s89hoe._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__07qfsfa._.js → [root-of-the-server]__0wp9w6i._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ynf7tx._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__11rtg6s._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__14dd6h8._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__170799-._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__17ai7sy._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1dky4g0._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1tkjqka._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__212nf49._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_087bt9w._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_1fvisnp._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_209u41o._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_html-to-image_es_index_0g5r64e.js → node_modules_html-to-image_es_index_12rjfea.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0-uvagv.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_03c7gi5.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_09p-8om.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0v-kfiu.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0xrgzyz.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_1806lsc.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_1j6dd-e.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_1sa65r-.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_posthog-node_dist_entrypoints_index_node_mjs_11bnuzn._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +5 -5
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +10 -10
- package/.next/standalone/.next/static/chunks/{13f1kmjea-0md.js → 02jcotghcxrbu.js} +1 -1
- package/.next/standalone/.next/static/chunks/{17sdztgbcc0fi.js → 0d5lypu1zs21r.js} +1 -1
- package/.next/standalone/.next/static/chunks/{2ufuwhv03yvtb.js → 0emg30_6svycu.js} +1 -1
- package/.next/standalone/.next/static/chunks/{1374x9bv_s_vg.js → 0o9wpnze1ey8y.js} +1 -1
- package/.next/standalone/.next/static/chunks/{454dyizqik6t9.js → 1359o5785rmve.js} +1 -1
- package/.next/standalone/.next/static/chunks/{43weu8f59tlix.js → 20tuctw38jbgw.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0405htbxay9vd.js → 2ldhnaweu9ew3.js} +1 -1
- package/.next/standalone/.next/static/chunks/{003uz088wbmz7.js → 2vav_x0_336ds.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0iinhn4417nk1.js → 3-ogr79xqbw0h.js} +1 -1
- package/.next/standalone/.next/static/chunks/36j05kb2x323i.css +2 -0
- package/.next/standalone/.next/static/chunks/{35-90m9py64d4.js → 3cg7x0joi2b98.js} +1 -1
- package/.next/standalone/.next/static/chunks/{2o3ql0n5owqsw.js → 3k87p-tijud-4.js} +1 -1
- package/.next/standalone/.next/static/chunks/{2m_tbl39fcedn.js → 3kmaqcp7rldad.js} +1 -1
- package/.next/standalone/.next/static/chunks/{turbopack-0vavqo2d-tlt3.js → turbopack-10hj8t5pf33tu.js} +1 -1
- package/.next/standalone/.opencode/plugins/failproofai.mjs +30 -11
- package/.next/standalone/app/components/global-error-listeners.tsx +27 -0
- package/.next/standalone/ci/cli-integration/Dockerfile +47 -0
- package/.next/standalone/ci/cli-integration/README.md +69 -0
- package/.next/standalone/ci/cli-integration/canary-policies.mjs +45 -0
- package/.next/standalone/ci/cli-integration/capture-tokens.sh +48 -0
- package/.next/standalone/ci/cli-integration/inject-tokens.sh +44 -0
- package/.next/standalone/ci/cli-integration/install-clis.sh +91 -0
- package/.next/standalone/ci/cli-integration/probe-cli.sh +208 -0
- package/.next/standalone/ci/cli-integration/report.js +74 -0
- package/.next/standalone/ci/cli-integration/run.sh +107 -0
- package/.next/standalone/components/reach-developers.tsx +1 -1
- package/.next/standalone/docker-hook-sync/Dockerfile +8 -4
- package/.next/standalone/lib/error-origin.ts +67 -0
- package/.next/standalone/lib/install-check.ts +231 -0
- package/.next/standalone/package.json +1 -3
- package/.next/standalone/server.js +1 -1
- package/README.md +1 -17
- package/bin/failproofai.mjs +11 -1
- package/dist/cli.mjs +479 -217
- package/lib/error-origin.ts +67 -0
- package/lib/install-check.ts +231 -0
- package/package.json +1 -3
- package/scripts/dev-hook.mjs +292 -0
- package/scripts/install-diagnosis.mjs +5 -8
- package/scripts/install-telemetry.mjs +12 -4
- package/scripts/translate-docs/cli.ts +47 -1
- package/scripts/translate-docs/mdx-translator.ts +133 -4
- package/scripts/translate-docs/readme-translator.ts +13 -5
- package/scripts/translate-docs/translator.ts +38 -2
- package/scripts/validate-mdx.ts +12 -4
- package/src/audit/cli.ts +41 -9
- package/src/hooks/tui.ts +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ge8e7w._.js +0 -3
- package/.next/standalone/.next/static/chunks/3r--yyjkp9_7b.css +0 -2
- package/scripts/postinstall.mjs +0 -242
- package/scripts/preuninstall.mjs +0 -131
- /package/.next/standalone/.next/static/{MNJWFb2jLRrxRKGFNK6Hy → LkN-JjmhKGmL-WklH7WVi}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{MNJWFb2jLRrxRKGFNK6Hy → LkN-JjmhKGmL-WklH7WVi}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{MNJWFb2jLRrxRKGFNK6Hy → LkN-JjmhKGmL-WklH7WVi}/_ssgManifest.js +0 -0
package/dist/cli.mjs
CHANGED
|
@@ -19,7 +19,7 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
|
19
19
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
20
20
|
|
|
21
21
|
// package.json
|
|
22
|
-
var version2 = "0.0.14-beta.
|
|
22
|
+
var version2 = "0.0.14-beta.1";
|
|
23
23
|
var init_package = () => {};
|
|
24
24
|
|
|
25
25
|
// src/posthog-key.ts
|
|
@@ -8314,6 +8314,242 @@ var init_handler = __esm(() => {
|
|
|
8314
8314
|
init_hook_logger();
|
|
8315
8315
|
});
|
|
8316
8316
|
|
|
8317
|
+
// scripts/install-telemetry.mjs
|
|
8318
|
+
import { createHmac, randomUUID } from "node:crypto";
|
|
8319
|
+
import { execSync as execSync4 } from "node:child_process";
|
|
8320
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync4, mkdirSync as mkdirSync5 } from "node:fs";
|
|
8321
|
+
import { homedir as homedir21, platform, arch, hostname, cpus } from "node:os";
|
|
8322
|
+
import { join as join24 } from "node:path";
|
|
8323
|
+
function hashToId3(raw) {
|
|
8324
|
+
return createHmac("sha256", NAMESPACE3).update(raw).digest("hex");
|
|
8325
|
+
}
|
|
8326
|
+
function getInstanceId3() {
|
|
8327
|
+
const idDir = join24(homedir21(), ".failproofai");
|
|
8328
|
+
const idFile = join24(idDir, "instance-id");
|
|
8329
|
+
try {
|
|
8330
|
+
const existing = readFileSync10(idFile, "utf-8").trim();
|
|
8331
|
+
if (existing)
|
|
8332
|
+
return existing;
|
|
8333
|
+
} catch {}
|
|
8334
|
+
try {
|
|
8335
|
+
const p = platform();
|
|
8336
|
+
if (p === "linux") {
|
|
8337
|
+
for (const machineIdPath of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
|
|
8338
|
+
try {
|
|
8339
|
+
const id2 = readFileSync10(machineIdPath, "utf-8").trim();
|
|
8340
|
+
if (id2)
|
|
8341
|
+
return hashToId3(id2);
|
|
8342
|
+
} catch {}
|
|
8343
|
+
}
|
|
8344
|
+
} else if (p === "darwin") {
|
|
8345
|
+
const out = execSync4("ioreg -rd1 -c IOPlatformExpertDevice", {
|
|
8346
|
+
encoding: "utf-8",
|
|
8347
|
+
timeout: 3000
|
|
8348
|
+
});
|
|
8349
|
+
const m = out.match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/);
|
|
8350
|
+
if (m?.[1])
|
|
8351
|
+
return hashToId3(m[1]);
|
|
8352
|
+
} else if (p === "win32") {
|
|
8353
|
+
const out = execSync4('reg query "HKLM\\SOFTWARE\\Microsoft\\Cryptography" /v MachineGuid', { encoding: "utf-8", timeout: 3000 });
|
|
8354
|
+
const m = out.match(/MachineGuid\s+REG_SZ\s+(\S+)/);
|
|
8355
|
+
if (m?.[1])
|
|
8356
|
+
return hashToId3(m[1]);
|
|
8357
|
+
}
|
|
8358
|
+
} catch {}
|
|
8359
|
+
try {
|
|
8360
|
+
const sysProps = [
|
|
8361
|
+
hostname(),
|
|
8362
|
+
homedir21(),
|
|
8363
|
+
platform(),
|
|
8364
|
+
arch(),
|
|
8365
|
+
cpus()[0]?.model ?? ""
|
|
8366
|
+
].join(":");
|
|
8367
|
+
return hashToId3(sysProps);
|
|
8368
|
+
} catch {}
|
|
8369
|
+
const id = randomUUID();
|
|
8370
|
+
try {
|
|
8371
|
+
mkdirSync5(idDir, { recursive: true });
|
|
8372
|
+
writeFileSync4(idFile, id, "utf-8");
|
|
8373
|
+
} catch {}
|
|
8374
|
+
return id;
|
|
8375
|
+
}
|
|
8376
|
+
async function trackInstallEvent(event, properties = {}, opts = {}) {
|
|
8377
|
+
if (process.env.FAILPROOFAI_TELEMETRY_DISABLED === "1")
|
|
8378
|
+
return;
|
|
8379
|
+
const version3 = opts.version ?? process.env.npm_package_version ?? "unknown";
|
|
8380
|
+
const body = JSON.stringify({
|
|
8381
|
+
api_key: process.env.FAILPROOFAI_POSTHOG_KEY ?? API_KEY3,
|
|
8382
|
+
event,
|
|
8383
|
+
distinct_id: getInstanceId3(),
|
|
8384
|
+
properties: {
|
|
8385
|
+
...properties,
|
|
8386
|
+
$lib: "failproofai-install",
|
|
8387
|
+
failproofai_version: version3,
|
|
8388
|
+
product: PRODUCT
|
|
8389
|
+
}
|
|
8390
|
+
});
|
|
8391
|
+
await fetch(process.env.FAILPROOFAI_POSTHOG_HOST ? `${process.env.FAILPROOFAI_POSTHOG_HOST}/capture/` : CAPTURE_URL3, {
|
|
8392
|
+
method: "POST",
|
|
8393
|
+
headers: { "Content-Type": "application/json" },
|
|
8394
|
+
body,
|
|
8395
|
+
signal: AbortSignal.timeout(opts.timeoutMs ?? 5000)
|
|
8396
|
+
});
|
|
8397
|
+
}
|
|
8398
|
+
var NAMESPACE3 = "failproofai-telemetry-v1", API_KEY3 = "phc_Ac1Ww1GqKc0z1SyrRWbmatEeQdlOQIsDEEdP8l8JRgX", CAPTURE_URL3 = "https://us.i.posthog.com/capture/", PRODUCT = "failproofai-oss";
|
|
8399
|
+
var init_install_telemetry = () => {};
|
|
8400
|
+
|
|
8401
|
+
// lib/install-check.ts
|
|
8402
|
+
var exports_install_check = {};
|
|
8403
|
+
__export(exports_install_check, {
|
|
8404
|
+
maybeReportInstall: () => maybeReportInstall,
|
|
8405
|
+
compareSemver: () => compareSemver,
|
|
8406
|
+
checkHooks: () => checkHooks
|
|
8407
|
+
});
|
|
8408
|
+
import { existsSync as existsSync10, readFileSync as readFileSync11, writeFileSync as writeFileSync5, mkdirSync as mkdirSync6 } from "node:fs";
|
|
8409
|
+
import { resolve as resolve9 } from "node:path";
|
|
8410
|
+
import { platform as platform2, arch as arch2, release, homedir as homedir22, hostname as hostname2 } from "node:os";
|
|
8411
|
+
import { createHmac as createHmac2 } from "node:crypto";
|
|
8412
|
+
function hashToId4(raw) {
|
|
8413
|
+
return createHmac2("sha256", NAMESPACE4).update(raw).digest("hex");
|
|
8414
|
+
}
|
|
8415
|
+
function lastVersionPath() {
|
|
8416
|
+
return resolve9(homedir22(), ".failproofai", "last-version");
|
|
8417
|
+
}
|
|
8418
|
+
function compareSemver(a, b) {
|
|
8419
|
+
const parse = (v) => {
|
|
8420
|
+
const m = /^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/.exec(v);
|
|
8421
|
+
if (!m)
|
|
8422
|
+
return null;
|
|
8423
|
+
return { nums: [Number(m[1]), Number(m[2]), Number(m[3])], pre: m[4] ?? null };
|
|
8424
|
+
};
|
|
8425
|
+
const pa = parse(a);
|
|
8426
|
+
const pb = parse(b);
|
|
8427
|
+
if (!pa || !pb)
|
|
8428
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
8429
|
+
for (let i = 0;i < 3; i++) {
|
|
8430
|
+
if (pa.nums[i] !== pb.nums[i])
|
|
8431
|
+
return pa.nums[i] < pb.nums[i] ? -1 : 1;
|
|
8432
|
+
}
|
|
8433
|
+
if (pa.pre === null && pb.pre === null)
|
|
8434
|
+
return 0;
|
|
8435
|
+
if (pa.pre === null)
|
|
8436
|
+
return 1;
|
|
8437
|
+
if (pb.pre === null)
|
|
8438
|
+
return -1;
|
|
8439
|
+
const ax = pa.pre.split(".");
|
|
8440
|
+
const bx = pb.pre.split(".");
|
|
8441
|
+
for (let i = 0;i < Math.max(ax.length, bx.length); i++) {
|
|
8442
|
+
const ai = ax[i], bi = bx[i];
|
|
8443
|
+
if (ai === undefined)
|
|
8444
|
+
return -1;
|
|
8445
|
+
if (bi === undefined)
|
|
8446
|
+
return 1;
|
|
8447
|
+
const aNum = /^\d+$/.test(ai), bNum = /^\d+$/.test(bi);
|
|
8448
|
+
if (aNum && bNum) {
|
|
8449
|
+
const d = Number(ai) - Number(bi);
|
|
8450
|
+
if (d !== 0)
|
|
8451
|
+
return d < 0 ? -1 : 1;
|
|
8452
|
+
} else if (aNum) {
|
|
8453
|
+
return -1;
|
|
8454
|
+
} else if (bNum) {
|
|
8455
|
+
return 1;
|
|
8456
|
+
} else if (ai !== bi) {
|
|
8457
|
+
return ai < bi ? -1 : 1;
|
|
8458
|
+
}
|
|
8459
|
+
}
|
|
8460
|
+
return 0;
|
|
8461
|
+
}
|
|
8462
|
+
function checkHooks() {
|
|
8463
|
+
const hooksConfigPath = resolve9(homedir22(), ".failproofai", "policies-config.json");
|
|
8464
|
+
if (!existsSync10(hooksConfigPath)) {
|
|
8465
|
+
return { configured: false, registered: false, policyCount: 0 };
|
|
8466
|
+
}
|
|
8467
|
+
let config;
|
|
8468
|
+
try {
|
|
8469
|
+
config = JSON.parse(readFileSync11(hooksConfigPath, "utf8"));
|
|
8470
|
+
} catch {
|
|
8471
|
+
return { configured: false, registered: false, policyCount: 0 };
|
|
8472
|
+
}
|
|
8473
|
+
if (!Array.isArray(config.enabledPolicies) || config.enabledPolicies.length === 0) {
|
|
8474
|
+
return { configured: false, registered: false, policyCount: 0 };
|
|
8475
|
+
}
|
|
8476
|
+
const policyCount = config.enabledPolicies.length;
|
|
8477
|
+
const settingsPath = resolve9(homedir22(), ".claude", "settings.json");
|
|
8478
|
+
if (!existsSync10(settingsPath))
|
|
8479
|
+
return { configured: true, registered: false, policyCount };
|
|
8480
|
+
let settings;
|
|
8481
|
+
try {
|
|
8482
|
+
settings = JSON.parse(readFileSync11(settingsPath, "utf8"));
|
|
8483
|
+
} catch {
|
|
8484
|
+
return { configured: true, registered: false, policyCount };
|
|
8485
|
+
}
|
|
8486
|
+
if (!settings?.hooks)
|
|
8487
|
+
return { configured: true, registered: false, policyCount };
|
|
8488
|
+
for (const matchers of Object.values(settings.hooks)) {
|
|
8489
|
+
if (!Array.isArray(matchers))
|
|
8490
|
+
continue;
|
|
8491
|
+
for (const matcher of matchers) {
|
|
8492
|
+
if (!matcher?.hooks)
|
|
8493
|
+
continue;
|
|
8494
|
+
if (matcher.hooks.some((h) => h[FAILPROOFAI_HOOK_MARKER2] === true)) {
|
|
8495
|
+
return { configured: true, registered: true, policyCount };
|
|
8496
|
+
}
|
|
8497
|
+
}
|
|
8498
|
+
}
|
|
8499
|
+
return { configured: true, registered: false, policyCount };
|
|
8500
|
+
}
|
|
8501
|
+
async function maybeReportInstall(version3) {
|
|
8502
|
+
try {
|
|
8503
|
+
const versionFile = lastVersionPath();
|
|
8504
|
+
let previousVersion = null;
|
|
8505
|
+
try {
|
|
8506
|
+
if (existsSync10(versionFile)) {
|
|
8507
|
+
previousVersion = readFileSync11(versionFile, "utf8").trim() || null;
|
|
8508
|
+
}
|
|
8509
|
+
} catch {}
|
|
8510
|
+
if (previousVersion === version3)
|
|
8511
|
+
return;
|
|
8512
|
+
const hooks = checkHooks();
|
|
8513
|
+
const events = [];
|
|
8514
|
+
if (previousVersion === null) {
|
|
8515
|
+
events.push(trackInstallEvent("first_install", {
|
|
8516
|
+
platform: platform2(),
|
|
8517
|
+
arch: arch2(),
|
|
8518
|
+
os_release: release(),
|
|
8519
|
+
node_version: process.versions.node
|
|
8520
|
+
}, { version: version3, timeoutMs: REPORT_TIMEOUT_MS }));
|
|
8521
|
+
} else {
|
|
8522
|
+
const cmp = compareSemver(previousVersion, version3);
|
|
8523
|
+
events.push(trackInstallEvent("version_changed", {
|
|
8524
|
+
from_version: previousVersion,
|
|
8525
|
+
to_version: version3,
|
|
8526
|
+
direction: cmp < 0 ? "upgrade" : "downgrade",
|
|
8527
|
+
platform: platform2(),
|
|
8528
|
+
arch: arch2()
|
|
8529
|
+
}, { version: version3, timeoutMs: REPORT_TIMEOUT_MS }));
|
|
8530
|
+
}
|
|
8531
|
+
events.push(trackInstallEvent("package_installed", {
|
|
8532
|
+
platform: platform2(),
|
|
8533
|
+
arch: arch2(),
|
|
8534
|
+
os_release: release(),
|
|
8535
|
+
node_version: process.versions.node,
|
|
8536
|
+
hostname_hash: hashToId4(hostname2()),
|
|
8537
|
+
hooks_configured: hooks.configured,
|
|
8538
|
+
hooks_registered: hooks.registered,
|
|
8539
|
+
enabled_policy_count: hooks.policyCount
|
|
8540
|
+
}, { version: version3, timeoutMs: REPORT_TIMEOUT_MS }));
|
|
8541
|
+
try {
|
|
8542
|
+
mkdirSync6(resolve9(homedir22(), ".failproofai"), { recursive: true });
|
|
8543
|
+
writeFileSync5(versionFile, version3, "utf8");
|
|
8544
|
+
} catch {}
|
|
8545
|
+
await Promise.all(events.map((p) => p.catch(() => {})));
|
|
8546
|
+
} catch {}
|
|
8547
|
+
}
|
|
8548
|
+
var FAILPROOFAI_HOOK_MARKER2 = "__failproofai_hook__", NAMESPACE4 = "failproofai-telemetry-v1", REPORT_TIMEOUT_MS = 5000;
|
|
8549
|
+
var init_install_check = __esm(() => {
|
|
8550
|
+
init_install_telemetry();
|
|
8551
|
+
});
|
|
8552
|
+
|
|
8317
8553
|
// node_modules/yaml/dist/nodes/identity.js
|
|
8318
8554
|
var require_identity = __commonJS((exports) => {
|
|
8319
8555
|
var ALIAS = Symbol.for("yaml.alias");
|
|
@@ -15305,32 +15541,32 @@ var init_dist = __esm(() => {
|
|
|
15305
15541
|
});
|
|
15306
15542
|
|
|
15307
15543
|
// src/hooks/integrations.ts
|
|
15308
|
-
import { execSync as
|
|
15309
|
-
import { readFileSync as
|
|
15310
|
-
import { resolve as
|
|
15544
|
+
import { execSync as execSync5 } from "node:child_process";
|
|
15545
|
+
import { readFileSync as readFileSync12, writeFileSync as writeFileSync6, existsSync as existsSync11, mkdirSync as mkdirSync7, unlinkSync as unlinkSync2 } from "node:fs";
|
|
15546
|
+
import { resolve as resolve10, dirname as dirname4 } from "node:path";
|
|
15311
15547
|
import { fileURLToPath } from "node:url";
|
|
15312
|
-
import { homedir as
|
|
15548
|
+
import { homedir as homedir23 } from "node:os";
|
|
15313
15549
|
function readJsonFile(path3) {
|
|
15314
|
-
if (!
|
|
15550
|
+
if (!existsSync11(path3))
|
|
15315
15551
|
return {};
|
|
15316
|
-
const raw =
|
|
15552
|
+
const raw = readFileSync12(path3, "utf8");
|
|
15317
15553
|
return JSON.parse(raw);
|
|
15318
15554
|
}
|
|
15319
15555
|
function writeJsonFile(path3, data) {
|
|
15320
|
-
|
|
15321
|
-
|
|
15556
|
+
mkdirSync7(dirname4(path3), { recursive: true });
|
|
15557
|
+
writeFileSync6(path3, JSON.stringify(data, null, 2) + `
|
|
15322
15558
|
`, "utf8");
|
|
15323
15559
|
}
|
|
15324
15560
|
function readYamlDoc(path3) {
|
|
15325
15561
|
try {
|
|
15326
|
-
return
|
|
15562
|
+
return existsSync11(path3) ? $parseDocument(readFileSync12(path3, "utf8")) : $parseDocument("");
|
|
15327
15563
|
} catch {
|
|
15328
15564
|
return $parseDocument("");
|
|
15329
15565
|
}
|
|
15330
15566
|
}
|
|
15331
15567
|
function writeYamlDoc(path3, doc) {
|
|
15332
|
-
|
|
15333
|
-
|
|
15568
|
+
mkdirSync7(dirname4(path3), { recursive: true });
|
|
15569
|
+
writeFileSync6(path3, doc.toString(), "utf8");
|
|
15334
15570
|
}
|
|
15335
15571
|
function isMarkedHook(hook) {
|
|
15336
15572
|
if (!hook || typeof hook !== "object")
|
|
@@ -15351,7 +15587,7 @@ function stripLegacyVersion(settings) {
|
|
|
15351
15587
|
function binaryExists(name) {
|
|
15352
15588
|
try {
|
|
15353
15589
|
const cmd = process.platform === "win32" ? `where ${name}` : `which ${name}`;
|
|
15354
|
-
|
|
15590
|
+
execSync5(cmd, { encoding: "utf8", stdio: "pipe" });
|
|
15355
15591
|
return true;
|
|
15356
15592
|
} catch {
|
|
15357
15593
|
return false;
|
|
@@ -15369,7 +15605,7 @@ function isMarkedCopilotHook(hook) {
|
|
|
15369
15605
|
return false;
|
|
15370
15606
|
}
|
|
15371
15607
|
function opencodePluginFilePath(settingsPath) {
|
|
15372
|
-
return
|
|
15608
|
+
return resolve10(dirname4(settingsPath), "plugins", "failproofai.mjs");
|
|
15373
15609
|
}
|
|
15374
15610
|
function buildOpenCodePluginShim(binaryPath, scope) {
|
|
15375
15611
|
const useNpx = scope === "project";
|
|
@@ -15584,8 +15820,8 @@ export default async function failproofaiPlugin({ client, directory }) {
|
|
|
15584
15820
|
function getPiExtensionPath() {
|
|
15585
15821
|
const fromEnv = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
15586
15822
|
if (fromEnv)
|
|
15587
|
-
return
|
|
15588
|
-
return
|
|
15823
|
+
return resolve10(fromEnv, "pi-extension");
|
|
15824
|
+
return resolve10(fileURLToPath(import.meta.url), "..", "..", "..", "pi-extension");
|
|
15589
15825
|
}
|
|
15590
15826
|
function isFailproofaiPiEntry(source) {
|
|
15591
15827
|
if (typeof source !== "string")
|
|
@@ -15596,8 +15832,8 @@ function isFailproofaiPiEntry(source) {
|
|
|
15596
15832
|
}
|
|
15597
15833
|
function makePiProjectRelativeEntry(extPath) {
|
|
15598
15834
|
const cwd = process.cwd();
|
|
15599
|
-
const cwdResolved =
|
|
15600
|
-
const extResolved =
|
|
15835
|
+
const cwdResolved = resolve10(cwd);
|
|
15836
|
+
const extResolved = resolve10(extPath);
|
|
15601
15837
|
if (extResolved.startsWith(cwdResolved + "/") || extResolved === cwdResolved) {
|
|
15602
15838
|
const fromSettingsDir = "../" + extResolved.slice(cwdResolved.length + 1);
|
|
15603
15839
|
return fromSettingsDir;
|
|
@@ -15607,8 +15843,8 @@ function makePiProjectRelativeEntry(extPath) {
|
|
|
15607
15843
|
function getOpenClawPluginPath() {
|
|
15608
15844
|
const fromEnv = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
15609
15845
|
if (fromEnv)
|
|
15610
|
-
return
|
|
15611
|
-
return
|
|
15846
|
+
return resolve10(fromEnv, "openclaw-plugin");
|
|
15847
|
+
return resolve10(fileURLToPath(import.meta.url), "..", "..", "..", "openclaw-plugin");
|
|
15612
15848
|
}
|
|
15613
15849
|
function isFailproofaiOpenClawPath(p) {
|
|
15614
15850
|
if (typeof p !== "string")
|
|
@@ -15644,14 +15880,14 @@ var init_integrations = __esm(() => {
|
|
|
15644
15880
|
scopes: HOOK_SCOPES,
|
|
15645
15881
|
eventTypes: HOOK_EVENT_TYPES,
|
|
15646
15882
|
getSettingsPath(scope, cwd) {
|
|
15647
|
-
const base = cwd ?
|
|
15883
|
+
const base = cwd ? resolve10(cwd) : process.cwd();
|
|
15648
15884
|
switch (scope) {
|
|
15649
15885
|
case "user":
|
|
15650
|
-
return
|
|
15886
|
+
return resolve10(homedir23(), ".claude", "settings.json");
|
|
15651
15887
|
case "project":
|
|
15652
|
-
return
|
|
15888
|
+
return resolve10(base, ".claude", "settings.json");
|
|
15653
15889
|
case "local":
|
|
15654
|
-
return
|
|
15890
|
+
return resolve10(base, ".claude", "settings.local.json");
|
|
15655
15891
|
}
|
|
15656
15892
|
},
|
|
15657
15893
|
readSettings(settingsPath) {
|
|
@@ -15723,7 +15959,7 @@ var init_integrations = __esm(() => {
|
|
|
15723
15959
|
},
|
|
15724
15960
|
hooksInstalledInSettings(scope, cwd) {
|
|
15725
15961
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
15726
|
-
if (!
|
|
15962
|
+
if (!existsSync11(settingsPath))
|
|
15727
15963
|
return false;
|
|
15728
15964
|
try {
|
|
15729
15965
|
const settings = this.readSettings(settingsPath);
|
|
@@ -15752,14 +15988,14 @@ var init_integrations = __esm(() => {
|
|
|
15752
15988
|
scopes: CODEX_HOOK_SCOPES,
|
|
15753
15989
|
eventTypes: CODEX_HOOK_EVENT_TYPES,
|
|
15754
15990
|
getSettingsPath(scope, cwd) {
|
|
15755
|
-
const base = cwd ?
|
|
15991
|
+
const base = cwd ? resolve10(cwd) : process.cwd();
|
|
15756
15992
|
switch (scope) {
|
|
15757
15993
|
case "user":
|
|
15758
|
-
return
|
|
15994
|
+
return resolve10(homedir23(), ".codex", "hooks.json");
|
|
15759
15995
|
case "project":
|
|
15760
|
-
return
|
|
15996
|
+
return resolve10(base, ".codex", "hooks.json");
|
|
15761
15997
|
case "local":
|
|
15762
|
-
return
|
|
15998
|
+
return resolve10(base, ".codex", "hooks.json");
|
|
15763
15999
|
}
|
|
15764
16000
|
},
|
|
15765
16001
|
readSettings(settingsPath) {
|
|
@@ -15839,7 +16075,7 @@ var init_integrations = __esm(() => {
|
|
|
15839
16075
|
},
|
|
15840
16076
|
hooksInstalledInSettings(scope, cwd) {
|
|
15841
16077
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
15842
|
-
if (!
|
|
16078
|
+
if (!existsSync11(settingsPath))
|
|
15843
16079
|
return false;
|
|
15844
16080
|
try {
|
|
15845
16081
|
const settings = this.readSettings(settingsPath);
|
|
@@ -15868,14 +16104,14 @@ var init_integrations = __esm(() => {
|
|
|
15868
16104
|
scopes: COPILOT_HOOK_SCOPES,
|
|
15869
16105
|
eventTypes: COPILOT_HOOK_EVENT_TYPES,
|
|
15870
16106
|
getSettingsPath(scope, cwd) {
|
|
15871
|
-
const base = cwd ?
|
|
16107
|
+
const base = cwd ? resolve10(cwd) : process.cwd();
|
|
15872
16108
|
switch (scope) {
|
|
15873
16109
|
case "user":
|
|
15874
|
-
return
|
|
16110
|
+
return resolve10(homedir23(), ".copilot", "hooks", "failproofai.json");
|
|
15875
16111
|
case "project":
|
|
15876
|
-
return
|
|
16112
|
+
return resolve10(base, ".github", "hooks", "failproofai.json");
|
|
15877
16113
|
case "local":
|
|
15878
|
-
return
|
|
16114
|
+
return resolve10(base, ".github", "hooks", "failproofai.json");
|
|
15879
16115
|
}
|
|
15880
16116
|
},
|
|
15881
16117
|
readSettings(settingsPath) {
|
|
@@ -15953,7 +16189,7 @@ var init_integrations = __esm(() => {
|
|
|
15953
16189
|
},
|
|
15954
16190
|
hooksInstalledInSettings(scope, cwd) {
|
|
15955
16191
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
15956
|
-
if (!
|
|
16192
|
+
if (!existsSync11(settingsPath))
|
|
15957
16193
|
return false;
|
|
15958
16194
|
try {
|
|
15959
16195
|
const settings = this.readSettings(settingsPath);
|
|
@@ -15982,14 +16218,14 @@ var init_integrations = __esm(() => {
|
|
|
15982
16218
|
scopes: CURSOR_HOOK_SCOPES,
|
|
15983
16219
|
eventTypes: CURSOR_HOOK_EVENT_TYPES,
|
|
15984
16220
|
getSettingsPath(scope, cwd) {
|
|
15985
|
-
const base = cwd ?
|
|
16221
|
+
const base = cwd ? resolve10(cwd) : process.cwd();
|
|
15986
16222
|
switch (scope) {
|
|
15987
16223
|
case "user":
|
|
15988
|
-
return
|
|
16224
|
+
return resolve10(homedir23(), ".cursor", "hooks.json");
|
|
15989
16225
|
case "project":
|
|
15990
|
-
return
|
|
16226
|
+
return resolve10(base, ".cursor", "hooks.json");
|
|
15991
16227
|
case "local":
|
|
15992
|
-
return
|
|
16228
|
+
return resolve10(base, ".cursor", "hooks.json");
|
|
15993
16229
|
}
|
|
15994
16230
|
},
|
|
15995
16231
|
readSettings(settingsPath) {
|
|
@@ -16056,7 +16292,7 @@ var init_integrations = __esm(() => {
|
|
|
16056
16292
|
},
|
|
16057
16293
|
hooksInstalledInSettings(scope, cwd) {
|
|
16058
16294
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
16059
|
-
if (!
|
|
16295
|
+
if (!existsSync11(settingsPath))
|
|
16060
16296
|
return false;
|
|
16061
16297
|
try {
|
|
16062
16298
|
const settings = this.readSettings(settingsPath);
|
|
@@ -16081,14 +16317,14 @@ var init_integrations = __esm(() => {
|
|
|
16081
16317
|
scopes: OPENCODE_HOOK_SCOPES,
|
|
16082
16318
|
eventTypes: OPENCODE_HOOK_EVENT_TYPES,
|
|
16083
16319
|
getSettingsPath(scope, cwd) {
|
|
16084
|
-
const base = cwd ?
|
|
16320
|
+
const base = cwd ? resolve10(cwd) : process.cwd();
|
|
16085
16321
|
switch (scope) {
|
|
16086
16322
|
case "user":
|
|
16087
|
-
return
|
|
16323
|
+
return resolve10(homedir23(), ".config", "opencode", "opencode.json");
|
|
16088
16324
|
case "project":
|
|
16089
|
-
return
|
|
16325
|
+
return resolve10(base, ".opencode", "opencode.json");
|
|
16090
16326
|
case "local":
|
|
16091
|
-
return
|
|
16327
|
+
return resolve10(base, ".opencode", "opencode.json");
|
|
16092
16328
|
}
|
|
16093
16329
|
},
|
|
16094
16330
|
readSettings(settingsPath) {
|
|
@@ -16099,7 +16335,7 @@ var init_integrations = __esm(() => {
|
|
|
16099
16335
|
},
|
|
16100
16336
|
buildHookEntry(_binaryPath, _eventType, scope) {
|
|
16101
16337
|
if (scope === "user") {
|
|
16102
|
-
const abs =
|
|
16338
|
+
const abs = resolve10(homedir23(), ".config", "opencode", "plugins", "failproofai.mjs");
|
|
16103
16339
|
return { spec: `file://${abs}`, [FAILPROOFAI_HOOK_MARKER]: true };
|
|
16104
16340
|
}
|
|
16105
16341
|
return { spec: OPENCODE_PLUGIN_REL_PATH, [FAILPROOFAI_HOOK_MARKER]: true };
|
|
@@ -16114,10 +16350,10 @@ var init_integrations = __esm(() => {
|
|
|
16114
16350
|
writeHookEntries(settings, binaryPath, scope) {
|
|
16115
16351
|
const s = settings;
|
|
16116
16352
|
const effectiveScope = scope ?? "project";
|
|
16117
|
-
const settingsPath = effectiveScope === "user" ?
|
|
16353
|
+
const settingsPath = effectiveScope === "user" ? resolve10(homedir23(), ".config", "opencode", "opencode.json") : resolve10(process.cwd(), ".opencode", "opencode.json");
|
|
16118
16354
|
const pluginPath = opencodePluginFilePath(settingsPath);
|
|
16119
|
-
|
|
16120
|
-
|
|
16355
|
+
mkdirSync7(dirname4(pluginPath), { recursive: true });
|
|
16356
|
+
writeFileSync6(pluginPath, buildOpenCodePluginShim(binaryPath, effectiveScope), "utf8");
|
|
16121
16357
|
if (!Array.isArray(s.plugin))
|
|
16122
16358
|
s.plugin = [];
|
|
16123
16359
|
const desired = effectiveScope === "user" ? `file://${pluginPath}` : OPENCODE_PLUGIN_REL_PATH;
|
|
@@ -16140,9 +16376,9 @@ var init_integrations = __esm(() => {
|
|
|
16140
16376
|
}
|
|
16141
16377
|
this.writeSettings(settingsPath, settings);
|
|
16142
16378
|
const pluginPath = opencodePluginFilePath(settingsPath);
|
|
16143
|
-
if (
|
|
16379
|
+
if (existsSync11(pluginPath)) {
|
|
16144
16380
|
try {
|
|
16145
|
-
const content =
|
|
16381
|
+
const content = readFileSync12(pluginPath, "utf8");
|
|
16146
16382
|
if (content.includes(FAILPROOFAI_HOOK_MARKER)) {
|
|
16147
16383
|
unlinkSync2(pluginPath);
|
|
16148
16384
|
if (removed === 0)
|
|
@@ -16154,7 +16390,7 @@ var init_integrations = __esm(() => {
|
|
|
16154
16390
|
},
|
|
16155
16391
|
hooksInstalledInSettings(scope, cwd) {
|
|
16156
16392
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
16157
|
-
if (!
|
|
16393
|
+
if (!existsSync11(settingsPath))
|
|
16158
16394
|
return false;
|
|
16159
16395
|
try {
|
|
16160
16396
|
const settings = this.readSettings(settingsPath);
|
|
@@ -16164,9 +16400,9 @@ var init_integrations = __esm(() => {
|
|
|
16164
16400
|
if (!hasEntry)
|
|
16165
16401
|
return false;
|
|
16166
16402
|
const pluginPath = opencodePluginFilePath(settingsPath);
|
|
16167
|
-
if (!
|
|
16403
|
+
if (!existsSync11(pluginPath))
|
|
16168
16404
|
return false;
|
|
16169
|
-
const content =
|
|
16405
|
+
const content = readFileSync12(pluginPath, "utf8");
|
|
16170
16406
|
return content.includes(FAILPROOFAI_HOOK_MARKER);
|
|
16171
16407
|
} catch {
|
|
16172
16408
|
return false;
|
|
@@ -16182,14 +16418,14 @@ var init_integrations = __esm(() => {
|
|
|
16182
16418
|
scopes: PI_HOOK_SCOPES,
|
|
16183
16419
|
eventTypes: PI_HOOK_EVENT_TYPES,
|
|
16184
16420
|
getSettingsPath(scope, cwd) {
|
|
16185
|
-
const base = cwd ?
|
|
16421
|
+
const base = cwd ? resolve10(cwd) : process.cwd();
|
|
16186
16422
|
switch (scope) {
|
|
16187
16423
|
case "user":
|
|
16188
|
-
return
|
|
16424
|
+
return resolve10(homedir23(), ".pi", "agent", "settings.json");
|
|
16189
16425
|
case "project":
|
|
16190
|
-
return
|
|
16426
|
+
return resolve10(base, ".pi", "settings.json");
|
|
16191
16427
|
case "local":
|
|
16192
|
-
return
|
|
16428
|
+
return resolve10(base, ".pi", "settings.json");
|
|
16193
16429
|
}
|
|
16194
16430
|
},
|
|
16195
16431
|
readSettings(settingsPath) {
|
|
@@ -16231,7 +16467,7 @@ var init_integrations = __esm(() => {
|
|
|
16231
16467
|
}
|
|
16232
16468
|
},
|
|
16233
16469
|
removeHooksFromFile(settingsPath) {
|
|
16234
|
-
if (!
|
|
16470
|
+
if (!existsSync11(settingsPath))
|
|
16235
16471
|
return 0;
|
|
16236
16472
|
const settings = this.readSettings(settingsPath);
|
|
16237
16473
|
if (!Array.isArray(settings.packages))
|
|
@@ -16246,7 +16482,7 @@ var init_integrations = __esm(() => {
|
|
|
16246
16482
|
},
|
|
16247
16483
|
hooksInstalledInSettings(scope, cwd) {
|
|
16248
16484
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
16249
|
-
if (!
|
|
16485
|
+
if (!existsSync11(settingsPath))
|
|
16250
16486
|
return false;
|
|
16251
16487
|
try {
|
|
16252
16488
|
const settings = this.readSettings(settingsPath);
|
|
@@ -16267,7 +16503,7 @@ var init_integrations = __esm(() => {
|
|
|
16267
16503
|
scopes: HERMES_HOOK_SCOPES,
|
|
16268
16504
|
eventTypes: HERMES_HOOK_EVENT_TYPES,
|
|
16269
16505
|
getSettingsPath() {
|
|
16270
|
-
return
|
|
16506
|
+
return resolve10(homedir23(), ".hermes", "config.yaml");
|
|
16271
16507
|
},
|
|
16272
16508
|
readSettings(settingsPath) {
|
|
16273
16509
|
return readYamlDoc(settingsPath);
|
|
@@ -16302,7 +16538,7 @@ var init_integrations = __esm(() => {
|
|
|
16302
16538
|
doc.set("hooks_auto_accept", true);
|
|
16303
16539
|
},
|
|
16304
16540
|
removeHooksFromFile(settingsPath) {
|
|
16305
|
-
if (!
|
|
16541
|
+
if (!existsSync11(settingsPath))
|
|
16306
16542
|
return 0;
|
|
16307
16543
|
const doc = readYamlDoc(settingsPath);
|
|
16308
16544
|
const js = doc.toJS() ?? {};
|
|
@@ -16335,7 +16571,7 @@ var init_integrations = __esm(() => {
|
|
|
16335
16571
|
},
|
|
16336
16572
|
hooksInstalledInSettings(scope, cwd) {
|
|
16337
16573
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
16338
|
-
if (!
|
|
16574
|
+
if (!existsSync11(settingsPath))
|
|
16339
16575
|
return false;
|
|
16340
16576
|
try {
|
|
16341
16577
|
const doc = readYamlDoc(settingsPath);
|
|
@@ -16360,7 +16596,7 @@ var init_integrations = __esm(() => {
|
|
|
16360
16596
|
scopes: OPENCLAW_HOOK_SCOPES,
|
|
16361
16597
|
eventTypes: OPENCLAW_HOOK_EVENT_TYPES,
|
|
16362
16598
|
getSettingsPath() {
|
|
16363
|
-
return
|
|
16599
|
+
return resolve10(homedir23(), ".openclaw", "openclaw.json");
|
|
16364
16600
|
},
|
|
16365
16601
|
readSettings(settingsPath) {
|
|
16366
16602
|
return readJsonFile(settingsPath);
|
|
@@ -16405,7 +16641,7 @@ var init_integrations = __esm(() => {
|
|
|
16405
16641
|
hooks.allowConversationAccess = true;
|
|
16406
16642
|
},
|
|
16407
16643
|
removeHooksFromFile(settingsPath) {
|
|
16408
|
-
if (!
|
|
16644
|
+
if (!existsSync11(settingsPath))
|
|
16409
16645
|
return 0;
|
|
16410
16646
|
const settings = this.readSettings(settingsPath);
|
|
16411
16647
|
const plugins = settings.plugins;
|
|
@@ -16434,7 +16670,7 @@ var init_integrations = __esm(() => {
|
|
|
16434
16670
|
},
|
|
16435
16671
|
hooksInstalledInSettings(scope, cwd) {
|
|
16436
16672
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
16437
|
-
if (!
|
|
16673
|
+
if (!existsSync11(settingsPath))
|
|
16438
16674
|
return false;
|
|
16439
16675
|
try {
|
|
16440
16676
|
const settings = this.readSettings(settingsPath);
|
|
@@ -16456,14 +16692,14 @@ var init_integrations = __esm(() => {
|
|
|
16456
16692
|
scopes: FACTORY_HOOK_SCOPES,
|
|
16457
16693
|
eventTypes: FACTORY_HOOK_EVENT_TYPES,
|
|
16458
16694
|
getSettingsPath(scope, cwd) {
|
|
16459
|
-
const base = cwd ?
|
|
16695
|
+
const base = cwd ? resolve10(cwd) : process.cwd();
|
|
16460
16696
|
switch (scope) {
|
|
16461
16697
|
case "user":
|
|
16462
|
-
return
|
|
16698
|
+
return resolve10(homedir23(), ".factory", "hooks.json");
|
|
16463
16699
|
case "project":
|
|
16464
|
-
return
|
|
16700
|
+
return resolve10(base, ".factory", "hooks.json");
|
|
16465
16701
|
case "local":
|
|
16466
|
-
return
|
|
16702
|
+
return resolve10(base, ".factory", "hooks.json");
|
|
16467
16703
|
}
|
|
16468
16704
|
},
|
|
16469
16705
|
readSettings(settingsPath) {
|
|
@@ -16531,7 +16767,7 @@ var init_integrations = __esm(() => {
|
|
|
16531
16767
|
},
|
|
16532
16768
|
hooksInstalledInSettings(scope, cwd) {
|
|
16533
16769
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
16534
|
-
if (!
|
|
16770
|
+
if (!existsSync11(settingsPath))
|
|
16535
16771
|
return false;
|
|
16536
16772
|
try {
|
|
16537
16773
|
const settings = this.readSettings(settingsPath);
|
|
@@ -16558,14 +16794,14 @@ var init_integrations = __esm(() => {
|
|
|
16558
16794
|
scopes: DEVIN_HOOK_SCOPES,
|
|
16559
16795
|
eventTypes: DEVIN_HOOK_EVENT_TYPES,
|
|
16560
16796
|
getSettingsPath(scope, cwd) {
|
|
16561
|
-
const base = cwd ?
|
|
16797
|
+
const base = cwd ? resolve10(cwd) : process.cwd();
|
|
16562
16798
|
switch (scope) {
|
|
16563
16799
|
case "user":
|
|
16564
|
-
return
|
|
16800
|
+
return resolve10(homedir23(), ".config", "devin", "config.json");
|
|
16565
16801
|
case "project":
|
|
16566
|
-
return
|
|
16802
|
+
return resolve10(base, ".devin", "config.json");
|
|
16567
16803
|
case "local":
|
|
16568
|
-
return
|
|
16804
|
+
return resolve10(base, ".devin", "config.json");
|
|
16569
16805
|
}
|
|
16570
16806
|
},
|
|
16571
16807
|
readSettings(settingsPath) {
|
|
@@ -16637,7 +16873,7 @@ var init_integrations = __esm(() => {
|
|
|
16637
16873
|
},
|
|
16638
16874
|
hooksInstalledInSettings(scope, cwd) {
|
|
16639
16875
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
16640
|
-
if (!
|
|
16876
|
+
if (!existsSync11(settingsPath))
|
|
16641
16877
|
return false;
|
|
16642
16878
|
try {
|
|
16643
16879
|
const settings = this.readSettings(settingsPath);
|
|
@@ -16667,14 +16903,14 @@ var init_integrations = __esm(() => {
|
|
|
16667
16903
|
scopes: ANTIGRAVITY_HOOK_SCOPES,
|
|
16668
16904
|
eventTypes: ANTIGRAVITY_HOOK_EVENT_TYPES,
|
|
16669
16905
|
getSettingsPath(scope, cwd) {
|
|
16670
|
-
const base = cwd ?
|
|
16906
|
+
const base = cwd ? resolve10(cwd) : process.cwd();
|
|
16671
16907
|
switch (scope) {
|
|
16672
16908
|
case "user":
|
|
16673
|
-
return
|
|
16909
|
+
return resolve10(homedir23(), ".gemini", "config", "hooks.json");
|
|
16674
16910
|
case "project":
|
|
16675
|
-
return
|
|
16911
|
+
return resolve10(base, ".agents", "hooks.json");
|
|
16676
16912
|
case "local":
|
|
16677
|
-
return
|
|
16913
|
+
return resolve10(base, ".agents", "hooks.json");
|
|
16678
16914
|
}
|
|
16679
16915
|
},
|
|
16680
16916
|
readSettings(settingsPath) {
|
|
@@ -16776,7 +17012,7 @@ var init_integrations = __esm(() => {
|
|
|
16776
17012
|
},
|
|
16777
17013
|
hooksInstalledInSettings(scope, cwd) {
|
|
16778
17014
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
16779
|
-
if (!
|
|
17015
|
+
if (!existsSync11(settingsPath))
|
|
16780
17016
|
return false;
|
|
16781
17017
|
try {
|
|
16782
17018
|
const settings = this.readSettings(settingsPath);
|
|
@@ -16808,14 +17044,14 @@ var init_integrations = __esm(() => {
|
|
|
16808
17044
|
scopes: GOOSE_HOOK_SCOPES,
|
|
16809
17045
|
eventTypes: GOOSE_HOOK_EVENT_TYPES,
|
|
16810
17046
|
getSettingsPath(scope, cwd) {
|
|
16811
|
-
const base = cwd ?
|
|
17047
|
+
const base = cwd ? resolve10(cwd) : process.cwd();
|
|
16812
17048
|
switch (scope) {
|
|
16813
17049
|
case "user":
|
|
16814
|
-
return
|
|
17050
|
+
return resolve10(homedir23(), ".agents", "plugins", "failproofai", "hooks", "hooks.json");
|
|
16815
17051
|
case "project":
|
|
16816
|
-
return
|
|
17052
|
+
return resolve10(base, ".agents", "plugins", "failproofai", "hooks", "hooks.json");
|
|
16817
17053
|
case "local":
|
|
16818
|
-
return
|
|
17054
|
+
return resolve10(base, ".agents", "plugins", "failproofai", "hooks", "hooks.json");
|
|
16819
17055
|
}
|
|
16820
17056
|
},
|
|
16821
17057
|
readSettings(settingsPath) {
|
|
@@ -16882,7 +17118,7 @@ var init_integrations = __esm(() => {
|
|
|
16882
17118
|
},
|
|
16883
17119
|
hooksInstalledInSettings(scope, cwd) {
|
|
16884
17120
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
16885
|
-
if (!
|
|
17121
|
+
if (!existsSync11(settingsPath))
|
|
16886
17122
|
return false;
|
|
16887
17123
|
try {
|
|
16888
17124
|
const settings = this.readSettings(settingsPath);
|
|
@@ -17050,7 +17286,7 @@ function renderLaunchBanner(version3, stdout = process.stdout) {
|
|
|
17050
17286
|
row("version", c.pink(version3)),
|
|
17051
17287
|
row("star", c.dim("https://github.com/failproofai/failproofai")),
|
|
17052
17288
|
row("docs", c.dim("https://docs.befailproof.ai/introduction")),
|
|
17053
|
-
row("discord", c.dim("https://discord.
|
|
17289
|
+
row("discord", c.dim("https://discord.befailproof.ai/")),
|
|
17054
17290
|
""
|
|
17055
17291
|
];
|
|
17056
17292
|
}
|
|
@@ -17145,7 +17381,7 @@ function runPrompt(p) {
|
|
|
17145
17381
|
`${c.dim(BAR)} ${c.dim(p.summaryFor(result))}`
|
|
17146
17382
|
]);
|
|
17147
17383
|
};
|
|
17148
|
-
return new Promise((
|
|
17384
|
+
return new Promise((resolve11) => {
|
|
17149
17385
|
hideCursor(stdout);
|
|
17150
17386
|
repaint(stdout, region, build());
|
|
17151
17387
|
readline.emitKeypressEvents(stdin);
|
|
@@ -17161,7 +17397,7 @@ function runPrompt(p) {
|
|
|
17161
17397
|
const finish = (result) => {
|
|
17162
17398
|
cleanup();
|
|
17163
17399
|
collapse(result);
|
|
17164
|
-
|
|
17400
|
+
resolve11(result);
|
|
17165
17401
|
};
|
|
17166
17402
|
function onKey(_s, key) {
|
|
17167
17403
|
if (!key)
|
|
@@ -17457,7 +17693,7 @@ async function promptPolicySelection(preSelected, options = {}) {
|
|
|
17457
17693
|
`);
|
|
17458
17694
|
lastLineCount = lines.length;
|
|
17459
17695
|
}
|
|
17460
|
-
return new Promise((
|
|
17696
|
+
return new Promise((resolve11) => {
|
|
17461
17697
|
render();
|
|
17462
17698
|
process.stdin.setRawMode(true);
|
|
17463
17699
|
process.stdin.resume();
|
|
@@ -17494,7 +17730,7 @@ async function promptPolicySelection(preSelected, options = {}) {
|
|
|
17494
17730
|
${dim(STEP_DONE)} Policies
|
|
17495
17731
|
${dim(BAR)} ${dim(`${selected.length} selected`)}
|
|
17496
17732
|
`);
|
|
17497
|
-
|
|
17733
|
+
resolve11(selected);
|
|
17498
17734
|
} else if (key.name === "escape") {
|
|
17499
17735
|
search = "";
|
|
17500
17736
|
cursor2 = 0;
|
|
@@ -17555,10 +17791,10 @@ __export(exports_manager, {
|
|
|
17555
17791
|
hooksInstalledInSettings: () => hooksInstalledInSettings,
|
|
17556
17792
|
getSettingsPath: () => getSettingsPath
|
|
17557
17793
|
});
|
|
17558
|
-
import { execSync as
|
|
17559
|
-
import { existsSync as
|
|
17560
|
-
import { resolve as
|
|
17561
|
-
import { homedir as
|
|
17794
|
+
import { execSync as execSync6 } from "node:child_process";
|
|
17795
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
17796
|
+
import { resolve as resolve11, basename as basename3 } from "node:path";
|
|
17797
|
+
import { homedir as homedir24, platform as platform3, arch as arch3, release as release2, hostname as hostname3 } from "node:os";
|
|
17562
17798
|
function getSettingsPath(scope, cwd) {
|
|
17563
17799
|
return claudeCode.getSettingsPath(scope, cwd);
|
|
17564
17800
|
}
|
|
@@ -17578,7 +17814,7 @@ function resolveFailproofaiBinary() {
|
|
|
17578
17814
|
return override.trim();
|
|
17579
17815
|
try {
|
|
17580
17816
|
const cmd = process.platform === "win32" ? "where failproofai" : "which failproofai";
|
|
17581
|
-
const result =
|
|
17817
|
+
const result = execSync6(cmd, { encoding: "utf8" }).trim();
|
|
17582
17818
|
return result.split(`
|
|
17583
17819
|
`)[0].trim();
|
|
17584
17820
|
} catch {
|
|
@@ -17664,7 +17900,7 @@ async function installHooksImpl(policyNames, scope = "user", cwd, includeBeta =
|
|
|
17664
17900
|
if (removeCustomHooks) {
|
|
17665
17901
|
delete configToWrite.customPoliciesPath;
|
|
17666
17902
|
} else if (customPoliciesPath) {
|
|
17667
|
-
configToWrite.customPoliciesPath =
|
|
17903
|
+
configToWrite.customPoliciesPath = resolve11(customPoliciesPath);
|
|
17668
17904
|
let validatedHooks = [];
|
|
17669
17905
|
try {
|
|
17670
17906
|
validatedHooks = await loadCustomHooks(configToWrite.customPoliciesPath, { strict: true });
|
|
@@ -17736,10 +17972,10 @@ Enabled ${selectedPolicies.length} policy(ies): ${selectedPolicies.join(", ")}
|
|
|
17736
17972
|
policies_added: policiesAdded,
|
|
17737
17973
|
policies_removed: policiesRemoved,
|
|
17738
17974
|
...source ? { source } : {},
|
|
17739
|
-
platform:
|
|
17740
|
-
arch:
|
|
17741
|
-
os_release:
|
|
17742
|
-
hostname_hash: hashToId2(
|
|
17975
|
+
platform: platform3(),
|
|
17976
|
+
arch: arch3(),
|
|
17977
|
+
os_release: release2(),
|
|
17978
|
+
hostname_hash: hashToId2(hostname3()),
|
|
17743
17979
|
has_custom_hooks_path: !!configToWrite.customPoliciesPath,
|
|
17744
17980
|
has_policy_params: !!(configToWrite.policyParams && Object.keys(configToWrite.policyParams).length > 0),
|
|
17745
17981
|
param_policy_names: configToWrite.policyParams ? Object.keys(configToWrite.policyParams) : [],
|
|
@@ -17826,10 +18062,10 @@ async function removeHooks(policyNames, scope = "user", cwd, opts) {
|
|
|
17826
18062
|
policies_removed: actuallyRemoved,
|
|
17827
18063
|
removed_count: actuallyRemoved.length,
|
|
17828
18064
|
...opts?.source ? { source: opts.source } : {},
|
|
17829
|
-
platform:
|
|
17830
|
-
arch:
|
|
17831
|
-
os_release:
|
|
17832
|
-
hostname_hash: hashToId2(
|
|
18065
|
+
platform: platform3(),
|
|
18066
|
+
arch: arch3(),
|
|
18067
|
+
os_release: release2(),
|
|
18068
|
+
hostname_hash: hashToId2(hostname3())
|
|
17833
18069
|
});
|
|
17834
18070
|
} catch {}
|
|
17835
18071
|
console.log(`Disabled ${policyNames.length - notEnabled.length} policy(ies).`);
|
|
@@ -17844,7 +18080,7 @@ async function removeHooks(policyNames, scope = "user", cwd, opts) {
|
|
|
17844
18080
|
const scopesToRemove = scope === "all" ? [...integration.scopes] : integration.scopes.includes(scope) ? [scope] : [];
|
|
17845
18081
|
for (const s of scopesToRemove) {
|
|
17846
18082
|
const settingsPath = integration.getSettingsPath(s, cwd);
|
|
17847
|
-
if (!
|
|
18083
|
+
if (!existsSync12(settingsPath)) {
|
|
17848
18084
|
if (scope !== "all" && selectedClis.length === 1) {
|
|
17849
18085
|
console.log("No settings file found. Nothing to remove.");
|
|
17850
18086
|
nothingToReport = true;
|
|
@@ -17884,10 +18120,10 @@ async function removeHooks(policyNames, scope = "user", cwd, opts) {
|
|
|
17884
18120
|
policies_removed: configBeforeRemoval.enabledPolicies,
|
|
17885
18121
|
removed_count: totalRemoved,
|
|
17886
18122
|
...opts?.source ? { source: opts.source } : {},
|
|
17887
|
-
platform:
|
|
17888
|
-
arch:
|
|
17889
|
-
os_release:
|
|
17890
|
-
hostname_hash: hashToId2(
|
|
18123
|
+
platform: platform3(),
|
|
18124
|
+
arch: arch3(),
|
|
18125
|
+
os_release: release2(),
|
|
18126
|
+
hostname_hash: hashToId2(hostname3())
|
|
17891
18127
|
});
|
|
17892
18128
|
} catch {}
|
|
17893
18129
|
if (scope === "all") {
|
|
@@ -18033,7 +18269,7 @@ Failproof AI Hook Policies
|
|
|
18033
18269
|
if (config.customPoliciesPath) {
|
|
18034
18270
|
console.log(`
|
|
18035
18271
|
── Custom Policies (${config.customPoliciesPath}) ───────────────────────`);
|
|
18036
|
-
if (!
|
|
18272
|
+
if (!existsSync12(config.customPoliciesPath)) {
|
|
18037
18273
|
console.log(` \x1B[31m✗ File not found: ${config.customPoliciesPath}\x1B[0m`);
|
|
18038
18274
|
} else {
|
|
18039
18275
|
const hooks = await loadCustomHooks(config.customPoliciesPath);
|
|
@@ -18048,10 +18284,10 @@ Failproof AI Hook Policies
|
|
|
18048
18284
|
}
|
|
18049
18285
|
console.log();
|
|
18050
18286
|
}
|
|
18051
|
-
const base = cwd ?
|
|
18287
|
+
const base = cwd ? resolve11(cwd) : process.cwd();
|
|
18052
18288
|
const conventionDirs = [
|
|
18053
|
-
{ label: "Project", dir:
|
|
18054
|
-
{ label: "User", dir:
|
|
18289
|
+
{ label: "Project", dir: resolve11(base, ".failproofai", "policies") },
|
|
18290
|
+
{ label: "User", dir: resolve11(homedir24(), ".failproofai", "policies") }
|
|
18055
18291
|
];
|
|
18056
18292
|
for (const { label, dir } of conventionDirs) {
|
|
18057
18293
|
const files = discoverPolicyFiles(dir);
|
|
@@ -18253,7 +18489,7 @@ async function promptCliTargetSelection(detected, action = "install") {
|
|
|
18253
18489
|
lastLineCount = lines.length;
|
|
18254
18490
|
}
|
|
18255
18491
|
const itemCount = options.length;
|
|
18256
|
-
return new Promise((
|
|
18492
|
+
return new Promise((resolve12) => {
|
|
18257
18493
|
render();
|
|
18258
18494
|
readline3.emitKeypressEvents(process.stdin);
|
|
18259
18495
|
const wasRaw = process.stdin.isRaw;
|
|
@@ -18286,7 +18522,7 @@ async function promptCliTargetSelection(detected, action = "install") {
|
|
|
18286
18522
|
cleanup();
|
|
18287
18523
|
process.stdout.write(`
|
|
18288
18524
|
`);
|
|
18289
|
-
|
|
18525
|
+
resolve12(options[cursor2].value);
|
|
18290
18526
|
}
|
|
18291
18527
|
}
|
|
18292
18528
|
process.stdin.on("keypress", onKey);
|
|
@@ -18439,7 +18675,7 @@ async function promptPolicySelection2(preSelected, options = {}) {
|
|
|
18439
18675
|
`);
|
|
18440
18676
|
lastLineCount = lines.length;
|
|
18441
18677
|
}
|
|
18442
|
-
return new Promise((
|
|
18678
|
+
return new Promise((resolve12) => {
|
|
18443
18679
|
render();
|
|
18444
18680
|
process.stdin.setRawMode(true);
|
|
18445
18681
|
process.stdin.resume();
|
|
@@ -18476,7 +18712,7 @@ async function promptPolicySelection2(preSelected, options = {}) {
|
|
|
18476
18712
|
${dim(STEP_DONE)} Policies
|
|
18477
18713
|
${dim(BAR)} ${dim(`${selected.length} selected`)}
|
|
18478
18714
|
`);
|
|
18479
|
-
|
|
18715
|
+
resolve12(selected);
|
|
18480
18716
|
} else if (key.name === "escape") {
|
|
18481
18717
|
search = "";
|
|
18482
18718
|
cursor2 = 0;
|
|
@@ -18656,12 +18892,12 @@ var init_api_server_client = __esm(() => {
|
|
|
18656
18892
|
// lib/atomic-write.ts
|
|
18657
18893
|
import {
|
|
18658
18894
|
chmodSync,
|
|
18659
|
-
existsSync as
|
|
18660
|
-
mkdirSync as
|
|
18895
|
+
existsSync as existsSync13,
|
|
18896
|
+
mkdirSync as mkdirSync8,
|
|
18661
18897
|
renameSync as renameSync3,
|
|
18662
18898
|
rmSync,
|
|
18663
18899
|
statSync as statSync11,
|
|
18664
|
-
writeFileSync as
|
|
18900
|
+
writeFileSync as writeFileSync7
|
|
18665
18901
|
} from "node:fs";
|
|
18666
18902
|
import { dirname as dirname5 } from "node:path";
|
|
18667
18903
|
import { randomBytes } from "node:crypto";
|
|
@@ -18669,11 +18905,11 @@ function writeJsonAtomically(filePath, value, opts = {}) {
|
|
|
18669
18905
|
const mode = opts.mode ?? 384;
|
|
18670
18906
|
const dirMode = opts.dirMode ?? 448;
|
|
18671
18907
|
const dir = dirname5(filePath);
|
|
18672
|
-
if (!
|
|
18673
|
-
|
|
18908
|
+
if (!existsSync13(dir))
|
|
18909
|
+
mkdirSync8(dir, { recursive: true, mode: dirMode });
|
|
18674
18910
|
const tmp = `${filePath}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`;
|
|
18675
18911
|
try {
|
|
18676
|
-
|
|
18912
|
+
writeFileSync7(tmp, JSON.stringify(value, null, 2), { mode });
|
|
18677
18913
|
try {
|
|
18678
18914
|
if ((statSync11(tmp).mode & 63) !== 0)
|
|
18679
18915
|
chmodSync(tmp, mode);
|
|
@@ -18693,24 +18929,24 @@ function writeJsonAtomically(filePath, value, opts = {}) {
|
|
|
18693
18929
|
var init_atomic_write = () => {};
|
|
18694
18930
|
|
|
18695
18931
|
// lib/auth/auth-store.ts
|
|
18696
|
-
import { existsSync as
|
|
18697
|
-
import { homedir as
|
|
18698
|
-
import { join as
|
|
18932
|
+
import { existsSync as existsSync14, readFileSync as readFileSync13, rmSync as rmSync2 } from "node:fs";
|
|
18933
|
+
import { homedir as homedir25 } from "node:os";
|
|
18934
|
+
import { join as join25 } from "node:path";
|
|
18699
18935
|
function getAuthDir() {
|
|
18700
18936
|
const override = process.env.FAILPROOFAI_AUTH_DIR;
|
|
18701
18937
|
if (override)
|
|
18702
18938
|
return override;
|
|
18703
|
-
return
|
|
18939
|
+
return join25(homedir25(), ".failproofai");
|
|
18704
18940
|
}
|
|
18705
18941
|
function getAuthFilePath() {
|
|
18706
|
-
return
|
|
18942
|
+
return join25(getAuthDir(), "auth.json");
|
|
18707
18943
|
}
|
|
18708
18944
|
function readAuth() {
|
|
18709
18945
|
const p = getAuthFilePath();
|
|
18710
|
-
if (!
|
|
18946
|
+
if (!existsSync14(p))
|
|
18711
18947
|
return null;
|
|
18712
18948
|
try {
|
|
18713
|
-
const raw =
|
|
18949
|
+
const raw = readFileSync13(p, "utf-8");
|
|
18714
18950
|
const parsed = JSON.parse(raw);
|
|
18715
18951
|
if (typeof parsed.access_token !== "string" || typeof parsed.refresh_token !== "string" || typeof parsed.access_expires_at !== "number" || typeof parsed.user !== "object" || !parsed.user || typeof parsed.user.id !== "string" || typeof parsed.user.email !== "string") {
|
|
18716
18952
|
return null;
|
|
@@ -18734,7 +18970,7 @@ function writeAuth(auth) {
|
|
|
18734
18970
|
}
|
|
18735
18971
|
function deleteAuth() {
|
|
18736
18972
|
const p = getAuthFilePath();
|
|
18737
|
-
if (
|
|
18973
|
+
if (existsSync14(p))
|
|
18738
18974
|
rmSync2(p, { force: true });
|
|
18739
18975
|
}
|
|
18740
18976
|
function authFromTokenResponse(token, existingUser) {
|
|
@@ -18811,13 +19047,13 @@ function prompt(question, opts = {}) {
|
|
|
18811
19047
|
orig(s);
|
|
18812
19048
|
};
|
|
18813
19049
|
}
|
|
18814
|
-
return new Promise((
|
|
19050
|
+
return new Promise((resolve12) => {
|
|
18815
19051
|
rl.question(question, (answer) => {
|
|
18816
19052
|
rl.close();
|
|
18817
19053
|
if (opts.hidden && process.stdin.isTTY)
|
|
18818
19054
|
process.stdout.write(`
|
|
18819
19055
|
`);
|
|
18820
|
-
|
|
19056
|
+
resolve12(answer.trim());
|
|
18821
19057
|
});
|
|
18822
19058
|
});
|
|
18823
19059
|
}
|
|
@@ -19059,8 +19295,8 @@ EXAMPLES
|
|
|
19059
19295
|
});
|
|
19060
19296
|
|
|
19061
19297
|
// lib/claude-sessions.ts
|
|
19062
|
-
import { readdirSync as readdirSync10, statSync as statSync12, existsSync as
|
|
19063
|
-
import { join as
|
|
19298
|
+
import { readdirSync as readdirSync10, statSync as statSync12, existsSync as existsSync15 } from "node:fs";
|
|
19299
|
+
import { join as join26, basename as basename4 } from "node:path";
|
|
19064
19300
|
function getClaudeProjectsRoot() {
|
|
19065
19301
|
return getClaudeProjectsPath();
|
|
19066
19302
|
}
|
|
@@ -19075,7 +19311,7 @@ function listClaudeProjects() {
|
|
|
19075
19311
|
return entries.filter((e) => e.isDirectory()).map((e) => ({
|
|
19076
19312
|
name: e.name,
|
|
19077
19313
|
cwd: decodeFolderName(e.name),
|
|
19078
|
-
path:
|
|
19314
|
+
path: join26(root, e.name)
|
|
19079
19315
|
}));
|
|
19080
19316
|
}
|
|
19081
19317
|
function listClaudeTranscripts(project) {
|
|
@@ -19091,7 +19327,7 @@ function listClaudeTranscripts(project) {
|
|
|
19091
19327
|
const sessionId = entry.name.slice(0, -".jsonl".length);
|
|
19092
19328
|
if (!UUID_RE2.test(sessionId))
|
|
19093
19329
|
continue;
|
|
19094
|
-
const transcriptPath =
|
|
19330
|
+
const transcriptPath = join26(project.path, entry.name);
|
|
19095
19331
|
try {
|
|
19096
19332
|
const s = statSync12(transcriptPath);
|
|
19097
19333
|
out.push({
|
|
@@ -19105,8 +19341,8 @@ function listClaudeTranscripts(project) {
|
|
|
19105
19341
|
});
|
|
19106
19342
|
} catch {}
|
|
19107
19343
|
} else if (entry.isDirectory() && UUID_RE2.test(entry.name)) {
|
|
19108
|
-
const subDir =
|
|
19109
|
-
if (!
|
|
19344
|
+
const subDir = join26(project.path, entry.name, "subagents");
|
|
19345
|
+
if (!existsSync15(subDir))
|
|
19110
19346
|
continue;
|
|
19111
19347
|
let subEntries;
|
|
19112
19348
|
try {
|
|
@@ -19118,7 +19354,7 @@ function listClaudeTranscripts(project) {
|
|
|
19118
19354
|
if (!sub.isFile() || !sub.name.endsWith(".jsonl"))
|
|
19119
19355
|
continue;
|
|
19120
19356
|
const agentId = sub.name.slice(0, -".jsonl".length);
|
|
19121
|
-
const transcriptPath =
|
|
19357
|
+
const transcriptPath = join26(subDir, sub.name);
|
|
19122
19358
|
try {
|
|
19123
19359
|
const s = statSync12(transcriptPath);
|
|
19124
19360
|
out.push({
|
|
@@ -20372,9 +20608,9 @@ var init_features = __esm(() => {
|
|
|
20372
20608
|
|
|
20373
20609
|
// src/audit/cache.ts
|
|
20374
20610
|
import { createHash } from "node:crypto";
|
|
20375
|
-
import { existsSync as
|
|
20376
|
-
import { join as
|
|
20377
|
-
import { homedir as
|
|
20611
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync9, readFileSync as readFileSync14, writeFileSync as writeFileSync8, chmodSync as chmodSync2 } from "node:fs";
|
|
20612
|
+
import { join as join27 } from "node:path";
|
|
20613
|
+
import { homedir as homedir26 } from "node:os";
|
|
20378
20614
|
function getEngineVersion() {
|
|
20379
20615
|
if (cachedEngineVersion)
|
|
20380
20616
|
return cachedEngineVersion;
|
|
@@ -20392,18 +20628,18 @@ function getDetectorVersion() {
|
|
|
20392
20628
|
return cachedDetectorVersion;
|
|
20393
20629
|
}
|
|
20394
20630
|
function getCachePathFor(transcriptPath) {
|
|
20395
|
-
const root =
|
|
20631
|
+
const root = join27(homedir26(), ".failproofai", "cache", "audit");
|
|
20396
20632
|
const key = createHash("sha1").update(transcriptPath).digest("hex");
|
|
20397
|
-
return
|
|
20633
|
+
return join27(root, `${key}.json`);
|
|
20398
20634
|
}
|
|
20399
20635
|
function readCachedTranscriptResult(transcriptPath, mtimeMs, sizeBytes) {
|
|
20400
20636
|
if (sizeBytes === 0)
|
|
20401
20637
|
return null;
|
|
20402
20638
|
const cachePath = getCachePathFor(transcriptPath);
|
|
20403
|
-
if (!
|
|
20639
|
+
if (!existsSync16(cachePath))
|
|
20404
20640
|
return null;
|
|
20405
20641
|
try {
|
|
20406
|
-
const raw =
|
|
20642
|
+
const raw = readFileSync14(cachePath, "utf-8");
|
|
20407
20643
|
const entry = JSON.parse(raw);
|
|
20408
20644
|
if (entry.schemaVersion !== CACHE_SCHEMA_VERSION)
|
|
20409
20645
|
return null;
|
|
@@ -20427,7 +20663,7 @@ function writeCachedTranscriptResult(transcriptPath, mtimeMs, sizeBytes, result)
|
|
|
20427
20663
|
return;
|
|
20428
20664
|
const cachePath = getCachePathFor(transcriptPath);
|
|
20429
20665
|
try {
|
|
20430
|
-
|
|
20666
|
+
mkdirSync9(join27(homedir26(), ".failproofai", "cache", "audit"), { recursive: true });
|
|
20431
20667
|
const entry = {
|
|
20432
20668
|
schemaVersion: CACHE_SCHEMA_VERSION,
|
|
20433
20669
|
cachedAt: Date.now(),
|
|
@@ -20437,7 +20673,7 @@ function writeCachedTranscriptResult(transcriptPath, mtimeMs, sizeBytes, result)
|
|
|
20437
20673
|
detectorVersion: getDetectorVersion(),
|
|
20438
20674
|
result
|
|
20439
20675
|
};
|
|
20440
|
-
|
|
20676
|
+
writeFileSync8(cachePath, JSON.stringify(entry), { encoding: "utf-8", mode: 384 });
|
|
20441
20677
|
try {
|
|
20442
20678
|
chmodSync2(cachePath, 384);
|
|
20443
20679
|
} catch {}
|
|
@@ -20799,10 +21035,10 @@ var init_audit = __esm(() => {
|
|
|
20799
21035
|
});
|
|
20800
21036
|
|
|
20801
21037
|
// src/audit/dashboard-cache.ts
|
|
20802
|
-
import { join as
|
|
20803
|
-
import { homedir as
|
|
21038
|
+
import { join as join28 } from "node:path";
|
|
21039
|
+
import { homedir as homedir27 } from "node:os";
|
|
20804
21040
|
function getCachePath() {
|
|
20805
|
-
return
|
|
21041
|
+
return join28(homedir27(), ".failproofai", "audit-dashboard.json");
|
|
20806
21042
|
}
|
|
20807
21043
|
function writeDashboardCache(params, result) {
|
|
20808
21044
|
try {
|
|
@@ -20892,14 +21128,14 @@ var POLL_INTERVAL_MS = 150, POLL_TIMEOUT_MS = 30000;
|
|
|
20892
21128
|
var init_open_browser = () => {};
|
|
20893
21129
|
|
|
20894
21130
|
// scripts/parse-script-args.ts
|
|
20895
|
-
import { resolve as
|
|
21131
|
+
import { resolve as resolve12 } from "path";
|
|
20896
21132
|
function parseStringFlag(flagName, errorLabel, inlineValue, args, index, options) {
|
|
20897
21133
|
const raw = inlineValue ?? args[index + 1];
|
|
20898
21134
|
if (raw === undefined || inlineValue === null && raw.startsWith("-")) {
|
|
20899
21135
|
console.error(`Error: ${flagName} requires ${errorLabel}`);
|
|
20900
21136
|
process.exit(1);
|
|
20901
21137
|
}
|
|
20902
|
-
const value = options?.resolve ?
|
|
21138
|
+
const value = options?.resolve ? resolve12(raw) : raw;
|
|
20903
21139
|
return { value, spliceCount: inlineValue !== null ? 1 : 2 };
|
|
20904
21140
|
}
|
|
20905
21141
|
function parseScriptArgs(argv) {
|
|
@@ -20947,21 +21183,21 @@ function parseScriptArgs(argv) {
|
|
|
20947
21183
|
var init_parse_script_args = () => {};
|
|
20948
21184
|
|
|
20949
21185
|
// scripts/install-diagnosis.mjs
|
|
20950
|
-
import { existsSync as
|
|
20951
|
-
import { dirname as dirname6, resolve as
|
|
20952
|
-
import { homedir as
|
|
21186
|
+
import { existsSync as existsSync17, readFileSync as readFileSync15, realpathSync } from "node:fs";
|
|
21187
|
+
import { dirname as dirname6, resolve as resolve13 } from "node:path";
|
|
21188
|
+
import { homedir as homedir28, platform as platform4 } from "node:os";
|
|
20953
21189
|
import { spawnSync } from "node:child_process";
|
|
20954
21190
|
function findPackageRoot(start) {
|
|
20955
21191
|
try {
|
|
20956
21192
|
let dir = realpathSync(start);
|
|
20957
|
-
if (
|
|
21193
|
+
if (existsSync17(dir) && !existsSync17(resolve13(dir, "package.json"))) {
|
|
20958
21194
|
dir = dirname6(dir);
|
|
20959
21195
|
}
|
|
20960
21196
|
while (true) {
|
|
20961
|
-
const pkgPath =
|
|
20962
|
-
if (
|
|
21197
|
+
const pkgPath = resolve13(dir, "package.json");
|
|
21198
|
+
if (existsSync17(pkgPath)) {
|
|
20963
21199
|
try {
|
|
20964
|
-
const pkg = JSON.parse(
|
|
21200
|
+
const pkg = JSON.parse(readFileSync15(pkgPath, "utf8"));
|
|
20965
21201
|
if (pkg.name === PKG_NAME)
|
|
20966
21202
|
return dir;
|
|
20967
21203
|
} catch {}
|
|
@@ -20979,7 +21215,7 @@ function readPackageVersion(packageRoot) {
|
|
|
20979
21215
|
if (!packageRoot)
|
|
20980
21216
|
return null;
|
|
20981
21217
|
try {
|
|
20982
|
-
const pkg = JSON.parse(
|
|
21218
|
+
const pkg = JSON.parse(readFileSync15(resolve13(packageRoot, "package.json"), "utf8"));
|
|
20983
21219
|
return typeof pkg.version === "string" ? pkg.version : null;
|
|
20984
21220
|
} catch {
|
|
20985
21221
|
return null;
|
|
@@ -20987,7 +21223,7 @@ function readPackageVersion(packageRoot) {
|
|
|
20987
21223
|
}
|
|
20988
21224
|
function resolvePathFirstBinary() {
|
|
20989
21225
|
try {
|
|
20990
|
-
const isWin =
|
|
21226
|
+
const isWin = platform4() === "win32";
|
|
20991
21227
|
const res = isWin ? spawnSync("where", [PKG_NAME], { encoding: "utf8" }) : spawnSync("sh", ["-c", `command -v ${PKG_NAME}`], { encoding: "utf8" });
|
|
20992
21228
|
if (res.status !== 0)
|
|
20993
21229
|
return null;
|
|
@@ -21005,16 +21241,16 @@ function locateNpmGlobal() {
|
|
|
21005
21241
|
const root = (res.stdout || "").trim();
|
|
21006
21242
|
if (!root)
|
|
21007
21243
|
return null;
|
|
21008
|
-
const candidate =
|
|
21009
|
-
return
|
|
21244
|
+
const candidate = resolve13(root, PKG_NAME);
|
|
21245
|
+
return existsSync17(resolve13(candidate, "package.json")) ? candidate : null;
|
|
21010
21246
|
} catch {
|
|
21011
21247
|
return null;
|
|
21012
21248
|
}
|
|
21013
21249
|
}
|
|
21014
21250
|
function locateBunGlobal() {
|
|
21015
21251
|
try {
|
|
21016
|
-
const candidate =
|
|
21017
|
-
return
|
|
21252
|
+
const candidate = resolve13(homedir28(), ".bun", "install", "global", "node_modules", PKG_NAME);
|
|
21253
|
+
return existsSync17(resolve13(candidate, "package.json")) ? candidate : null;
|
|
21018
21254
|
} catch {
|
|
21019
21255
|
return null;
|
|
21020
21256
|
}
|
|
@@ -21022,8 +21258,8 @@ function locateBunGlobal() {
|
|
|
21022
21258
|
function buildRecommendation(pathFirstBin) {
|
|
21023
21259
|
if (!pathFirstBin)
|
|
21024
21260
|
return null;
|
|
21025
|
-
const bunBinPrefix =
|
|
21026
|
-
const bunGlobalPrefix =
|
|
21261
|
+
const bunBinPrefix = resolve13(homedir28(), ".bun", "bin") + "/";
|
|
21262
|
+
const bunGlobalPrefix = resolve13(homedir28(), ".bun", "install", "global") + "/";
|
|
21027
21263
|
const isBun = pathFirstBin.startsWith(bunBinPrefix) || pathFirstBin.startsWith(bunGlobalPrefix);
|
|
21028
21264
|
if (isBun) {
|
|
21029
21265
|
return `rm -f ~/.bun/bin/${PKG_NAME} && rm -rf ~/.bun/install/global/node_modules/${PKG_NAME}`;
|
|
@@ -21103,8 +21339,8 @@ __export(exports_launch, {
|
|
|
21103
21339
|
launch: () => launch
|
|
21104
21340
|
});
|
|
21105
21341
|
import { spawn as spawn2 } from "child_process";
|
|
21106
|
-
import { realpathSync as realpathSync2, existsSync as
|
|
21107
|
-
import { resolve as
|
|
21342
|
+
import { realpathSync as realpathSync2, existsSync as existsSync18 } from "node:fs";
|
|
21343
|
+
import { resolve as resolve14, dirname as dirname7 } from "node:path";
|
|
21108
21344
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
21109
21345
|
import { createInterface as createInterface2 } from "node:readline";
|
|
21110
21346
|
function launch(mode) {
|
|
@@ -21119,9 +21355,9 @@ function launch(mode) {
|
|
|
21119
21355
|
process.env.PORT = port;
|
|
21120
21356
|
process.env.HOSTNAME = "0.0.0.0";
|
|
21121
21357
|
cmd = "node";
|
|
21122
|
-
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT ??
|
|
21123
|
-
const serverJsPath =
|
|
21124
|
-
if (!
|
|
21358
|
+
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT ?? resolve14(dirname7(realpathSync2(fileURLToPath2(import.meta.url))), "..");
|
|
21359
|
+
const serverJsPath = resolve14(packageRoot, ".next/standalone/server.js");
|
|
21360
|
+
if (!existsSync18(serverJsPath)) {
|
|
21125
21361
|
let shadowMessage = null;
|
|
21126
21362
|
try {
|
|
21127
21363
|
const diag = diagnoseShadow({ selfPackageRoot: packageRoot, selfVersion: version2 });
|
|
@@ -21332,9 +21568,20 @@ function printSummary(result) {
|
|
|
21332
21568
|
process.stdout.write(` ${line}
|
|
21333
21569
|
`);
|
|
21334
21570
|
}
|
|
21571
|
+
function auditCompletedProps(source, result) {
|
|
21572
|
+
return {
|
|
21573
|
+
source,
|
|
21574
|
+
events_scanned: result.eventsScanned,
|
|
21575
|
+
sessions_scanned: result.transcripts.scanned,
|
|
21576
|
+
total_hits: result.totals.hits,
|
|
21577
|
+
findings: result.results.length
|
|
21578
|
+
};
|
|
21579
|
+
}
|
|
21335
21580
|
async function runPostSetupAudit() {
|
|
21336
21581
|
if (process.env.FAILPROOFAI_NO_AUTO_AUDIT === "1")
|
|
21337
21582
|
return;
|
|
21583
|
+
const instanceId = getInstanceId2();
|
|
21584
|
+
trackHookEvent2(instanceId, "cli_audit_started", { source: "onboarding" });
|
|
21338
21585
|
process.stdout.write(`
|
|
21339
21586
|
${c(PINK2, "✦")} ${c(BOLD, "failproofai audit now running")} ${c(DIM2, "· ctrl+c to stop")}
|
|
21340
21587
|
|
|
@@ -21342,12 +21589,18 @@ async function runPostSetupAudit() {
|
|
|
21342
21589
|
let result;
|
|
21343
21590
|
try {
|
|
21344
21591
|
result = await runWithProgress({});
|
|
21345
|
-
} catch {
|
|
21592
|
+
} catch (err) {
|
|
21593
|
+
await trackHookEvent2(instanceId, "cli_audit_failed", {
|
|
21594
|
+
source: "onboarding",
|
|
21595
|
+
error_type: err instanceof Error ? err.name : "unknown",
|
|
21596
|
+
error_message: sanitizeErrorMessage(err)
|
|
21597
|
+
});
|
|
21346
21598
|
process.stdout.write(` ${c(PINK2, "!")} ${c(DIM2, "audit couldn't finish — run")} ${c(CYAN, "failproofai audit")} ${c(DIM2, "later.")}
|
|
21347
21599
|
|
|
21348
21600
|
`);
|
|
21349
21601
|
return;
|
|
21350
21602
|
}
|
|
21603
|
+
await trackHookEvent2(instanceId, "cli_audit_completed", auditCompletedProps("onboarding", result));
|
|
21351
21604
|
if (result.eventsScanned === 0) {
|
|
21352
21605
|
process.stdout.write(`
|
|
21353
21606
|
${c(DIM2, "no agent sessions to audit yet — come back after using your agent.")}
|
|
@@ -21386,13 +21639,7 @@ async function runAuditCli(args) {
|
|
|
21386
21639
|
die(`Audit failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
21387
21640
|
}
|
|
21388
21641
|
printSummary(result);
|
|
21389
|
-
await trackHookEvent2(instanceId, "cli_audit_completed",
|
|
21390
|
-
source: "cli",
|
|
21391
|
-
events_scanned: result.eventsScanned,
|
|
21392
|
-
sessions_scanned: result.transcripts.scanned,
|
|
21393
|
-
total_hits: result.totals.hits,
|
|
21394
|
-
findings: result.results.length
|
|
21395
|
-
});
|
|
21642
|
+
await trackHookEvent2(instanceId, "cli_audit_completed", auditCompletedProps("cli", result));
|
|
21396
21643
|
if (result.eventsScanned === 0) {
|
|
21397
21644
|
process.stdout.write(`
|
|
21398
21645
|
${c(DIM2, "no agent sessions found yet.")}
|
|
@@ -21453,9 +21700,9 @@ WHAT IT DOES
|
|
|
21453
21700
|
});
|
|
21454
21701
|
|
|
21455
21702
|
// src/hooks/manager.ts
|
|
21456
|
-
import { execSync as
|
|
21457
|
-
import { resolve as
|
|
21458
|
-
import { homedir as
|
|
21703
|
+
import { execSync as execSync7 } from "node:child_process";
|
|
21704
|
+
import { resolve as resolve15, basename as basename5 } from "node:path";
|
|
21705
|
+
import { homedir as homedir29, platform as platform5, arch as arch4, release as release3, hostname as hostname4 } from "node:os";
|
|
21459
21706
|
function getSettingsPath2(scope, cwd) {
|
|
21460
21707
|
return claudeCode.getSettingsPath(scope, cwd);
|
|
21461
21708
|
}
|
|
@@ -21475,7 +21722,7 @@ function resolveFailproofaiBinary2() {
|
|
|
21475
21722
|
return override.trim();
|
|
21476
21723
|
try {
|
|
21477
21724
|
const cmd = process.platform === "win32" ? "where failproofai" : "which failproofai";
|
|
21478
|
-
const result =
|
|
21725
|
+
const result = execSync7(cmd, { encoding: "utf8" }).trim();
|
|
21479
21726
|
return result.split(`
|
|
21480
21727
|
`)[0].trim();
|
|
21481
21728
|
} catch {
|
|
@@ -21561,7 +21808,7 @@ async function installHooksImpl2(policyNames, scope = "user", cwd, includeBeta =
|
|
|
21561
21808
|
if (removeCustomHooks) {
|
|
21562
21809
|
delete configToWrite.customPoliciesPath;
|
|
21563
21810
|
} else if (customPoliciesPath) {
|
|
21564
|
-
configToWrite.customPoliciesPath =
|
|
21811
|
+
configToWrite.customPoliciesPath = resolve15(customPoliciesPath);
|
|
21565
21812
|
let validatedHooks = [];
|
|
21566
21813
|
try {
|
|
21567
21814
|
validatedHooks = await loadCustomHooks(configToWrite.customPoliciesPath, { strict: true });
|
|
@@ -21633,10 +21880,10 @@ Enabled ${selectedPolicies.length} policy(ies): ${selectedPolicies.join(", ")}
|
|
|
21633
21880
|
policies_added: policiesAdded,
|
|
21634
21881
|
policies_removed: policiesRemoved,
|
|
21635
21882
|
...source ? { source } : {},
|
|
21636
|
-
platform:
|
|
21637
|
-
arch:
|
|
21638
|
-
os_release:
|
|
21639
|
-
hostname_hash: hashToId2(
|
|
21883
|
+
platform: platform5(),
|
|
21884
|
+
arch: arch4(),
|
|
21885
|
+
os_release: release3(),
|
|
21886
|
+
hostname_hash: hashToId2(hostname4()),
|
|
21640
21887
|
has_custom_hooks_path: !!configToWrite.customPoliciesPath,
|
|
21641
21888
|
has_policy_params: !!(configToWrite.policyParams && Object.keys(configToWrite.policyParams).length > 0),
|
|
21642
21889
|
param_policy_names: configToWrite.policyParams ? Object.keys(configToWrite.policyParams) : [],
|
|
@@ -21881,9 +22128,20 @@ function printSummary2(result) {
|
|
|
21881
22128
|
process.stdout.write(` ${line}
|
|
21882
22129
|
`);
|
|
21883
22130
|
}
|
|
22131
|
+
function auditCompletedProps2(source, result) {
|
|
22132
|
+
return {
|
|
22133
|
+
source,
|
|
22134
|
+
events_scanned: result.eventsScanned,
|
|
22135
|
+
sessions_scanned: result.transcripts.scanned,
|
|
22136
|
+
total_hits: result.totals.hits,
|
|
22137
|
+
findings: result.results.length
|
|
22138
|
+
};
|
|
22139
|
+
}
|
|
21884
22140
|
async function runPostSetupAudit2() {
|
|
21885
22141
|
if (process.env.FAILPROOFAI_NO_AUTO_AUDIT === "1")
|
|
21886
22142
|
return;
|
|
22143
|
+
const instanceId = getInstanceId2();
|
|
22144
|
+
trackHookEvent2(instanceId, "cli_audit_started", { source: "onboarding" });
|
|
21887
22145
|
process.stdout.write(`
|
|
21888
22146
|
${c2(PINK3, "✦")} ${c2(BOLD2, "failproofai audit now running")} ${c2(DIM3, "· ctrl+c to stop")}
|
|
21889
22147
|
|
|
@@ -21891,12 +22149,18 @@ async function runPostSetupAudit2() {
|
|
|
21891
22149
|
let result;
|
|
21892
22150
|
try {
|
|
21893
22151
|
result = await runWithProgress2({});
|
|
21894
|
-
} catch {
|
|
22152
|
+
} catch (err) {
|
|
22153
|
+
await trackHookEvent2(instanceId, "cli_audit_failed", {
|
|
22154
|
+
source: "onboarding",
|
|
22155
|
+
error_type: err instanceof Error ? err.name : "unknown",
|
|
22156
|
+
error_message: sanitizeErrorMessage(err)
|
|
22157
|
+
});
|
|
21895
22158
|
process.stdout.write(` ${c2(PINK3, "!")} ${c2(DIM3, "audit couldn't finish — run")} ${c2(CYAN2, "failproofai audit")} ${c2(DIM3, "later.")}
|
|
21896
22159
|
|
|
21897
22160
|
`);
|
|
21898
22161
|
return;
|
|
21899
22162
|
}
|
|
22163
|
+
await trackHookEvent2(instanceId, "cli_audit_completed", auditCompletedProps2("onboarding", result));
|
|
21900
22164
|
if (result.eventsScanned === 0) {
|
|
21901
22165
|
process.stdout.write(`
|
|
21902
22166
|
${c2(DIM3, "no agent sessions to audit yet — come back after using your agent.")}
|
|
@@ -21935,13 +22199,7 @@ async function runAuditCli2(args) {
|
|
|
21935
22199
|
die2(`Audit failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
21936
22200
|
}
|
|
21937
22201
|
printSummary2(result);
|
|
21938
|
-
await trackHookEvent2(instanceId, "cli_audit_completed",
|
|
21939
|
-
source: "cli",
|
|
21940
|
-
events_scanned: result.eventsScanned,
|
|
21941
|
-
sessions_scanned: result.transcripts.scanned,
|
|
21942
|
-
total_hits: result.totals.hits,
|
|
21943
|
-
findings: result.results.length
|
|
21944
|
-
});
|
|
22202
|
+
await trackHookEvent2(instanceId, "cli_audit_completed", auditCompletedProps2("cli", result));
|
|
21945
22203
|
if (result.eventsScanned === 0) {
|
|
21946
22204
|
process.stdout.write(`
|
|
21947
22205
|
${c2(DIM3, "no agent sessions found yet.")}
|
|
@@ -22014,16 +22272,16 @@ __export(exports_configure_wizard, {
|
|
|
22014
22272
|
buildPresetChoices: () => buildPresetChoices,
|
|
22015
22273
|
buildAgentChoices: () => buildAgentChoices
|
|
22016
22274
|
});
|
|
22017
|
-
import { existsSync as
|
|
22018
|
-
import { homedir as
|
|
22019
|
-
import { resolve as
|
|
22275
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync10, writeFileSync as writeFileSync9 } from "node:fs";
|
|
22276
|
+
import { homedir as homedir30 } from "node:os";
|
|
22277
|
+
import { resolve as resolve16, sep as sep5 } from "node:path";
|
|
22020
22278
|
async function emit(event, props) {
|
|
22021
22279
|
try {
|
|
22022
22280
|
await trackHookEvent2(getInstanceId2(), event, props);
|
|
22023
22281
|
} catch {}
|
|
22024
22282
|
}
|
|
22025
22283
|
function homeify(p) {
|
|
22026
|
-
const home =
|
|
22284
|
+
const home = homedir30();
|
|
22027
22285
|
if (p === home)
|
|
22028
22286
|
return "~";
|
|
22029
22287
|
if (p.startsWith(home + sep5))
|
|
@@ -22100,15 +22358,15 @@ function reviewLines(state) {
|
|
|
22100
22358
|
return lines;
|
|
22101
22359
|
}
|
|
22102
22360
|
function firstRunMarkerPath() {
|
|
22103
|
-
return
|
|
22361
|
+
return resolve16(homedir30(), ".failproofai", ".launcher-configured");
|
|
22104
22362
|
}
|
|
22105
22363
|
function hasSeenLauncher() {
|
|
22106
|
-
return
|
|
22364
|
+
return existsSync19(firstRunMarkerPath());
|
|
22107
22365
|
}
|
|
22108
22366
|
function markLauncherSeen() {
|
|
22109
22367
|
try {
|
|
22110
|
-
|
|
22111
|
-
|
|
22368
|
+
mkdirSync10(resolve16(homedir30(), ".failproofai"), { recursive: true });
|
|
22369
|
+
writeFileSync9(firstRunMarkerPath(), "1", "utf8");
|
|
22112
22370
|
} catch {}
|
|
22113
22371
|
}
|
|
22114
22372
|
function anyHooksInstalledGlobally() {
|
|
@@ -22248,8 +22506,8 @@ __export(exports_launch2, {
|
|
|
22248
22506
|
launch: () => launch2
|
|
22249
22507
|
});
|
|
22250
22508
|
import { spawn as spawn3 } from "child_process";
|
|
22251
|
-
import { realpathSync as realpathSync3, existsSync as
|
|
22252
|
-
import { resolve as
|
|
22509
|
+
import { realpathSync as realpathSync3, existsSync as existsSync20 } from "node:fs";
|
|
22510
|
+
import { resolve as resolve17, dirname as dirname8 } from "node:path";
|
|
22253
22511
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
22254
22512
|
import { createInterface as createInterface3 } from "node:readline";
|
|
22255
22513
|
function launch2(mode) {
|
|
@@ -22264,9 +22522,9 @@ function launch2(mode) {
|
|
|
22264
22522
|
process.env.PORT = port;
|
|
22265
22523
|
process.env.HOSTNAME = "0.0.0.0";
|
|
22266
22524
|
cmd = "node";
|
|
22267
|
-
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT ??
|
|
22268
|
-
const serverJsPath =
|
|
22269
|
-
if (!
|
|
22525
|
+
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT ?? resolve17(dirname8(realpathSync3(fileURLToPath3(import.meta.url))), "..");
|
|
22526
|
+
const serverJsPath = resolve17(packageRoot, ".next/standalone/server.js");
|
|
22527
|
+
if (!existsSync20(serverJsPath)) {
|
|
22270
22528
|
let shadowMessage = null;
|
|
22271
22529
|
try {
|
|
22272
22530
|
const diag = diagnoseShadow({ selfPackageRoot: packageRoot, selfVersion: version2 });
|
|
@@ -22360,17 +22618,17 @@ var init_cli_error2 = __esm(() => {
|
|
|
22360
22618
|
|
|
22361
22619
|
// bin/failproofai.mjs
|
|
22362
22620
|
import { realpathSync as realpathSync4 } from "fs";
|
|
22363
|
-
import { dirname as dirname9, resolve as
|
|
22621
|
+
import { dirname as dirname9, resolve as resolve18 } from "path";
|
|
22364
22622
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
22365
22623
|
// package.json
|
|
22366
|
-
var version = "0.0.14-beta.
|
|
22624
|
+
var version = "0.0.14-beta.1";
|
|
22367
22625
|
|
|
22368
22626
|
// bin/failproofai.mjs
|
|
22369
22627
|
if (!process.env.FAILPROOFAI_PACKAGE_ROOT) {
|
|
22370
|
-
process.env.FAILPROOFAI_PACKAGE_ROOT =
|
|
22628
|
+
process.env.FAILPROOFAI_PACKAGE_ROOT = resolve18(dirname9(realpathSync4(fileURLToPath4(import.meta.url))), "..");
|
|
22371
22629
|
}
|
|
22372
22630
|
if (!process.env.FAILPROOFAI_DIST_PATH) {
|
|
22373
|
-
process.env.FAILPROOFAI_DIST_PATH =
|
|
22631
|
+
process.env.FAILPROOFAI_DIST_PATH = resolve18(dirname9(realpathSync4(fileURLToPath4(import.meta.url))), "..", "dist");
|
|
22374
22632
|
}
|
|
22375
22633
|
var args = process.argv.slice(2);
|
|
22376
22634
|
if (args[0] === "p")
|
|
@@ -22423,6 +22681,10 @@ if (hookIdx >= 0) {
|
|
|
22423
22681
|
}
|
|
22424
22682
|
}
|
|
22425
22683
|
async function runCli() {
|
|
22684
|
+
try {
|
|
22685
|
+
const { maybeReportInstall: maybeReportInstall2 } = await Promise.resolve().then(() => (init_install_check(), exports_install_check));
|
|
22686
|
+
await maybeReportInstall2(version);
|
|
22687
|
+
} catch {}
|
|
22426
22688
|
const SUBCOMMANDS2 = ["policies", "policy", "auth", "audit", "config"];
|
|
22427
22689
|
if ((args.includes("--help") || args.includes("-h")) && !SUBCOMMANDS2.includes(args[0])) {
|
|
22428
22690
|
const extraArgs = args.filter((a) => a !== "--help" && a !== "-h");
|
|
@@ -22508,7 +22770,7 @@ EXAMPLES
|
|
|
22508
22770
|
LINKS
|
|
22509
22771
|
\u2B50 Star us: https://github.com/failproofai/failproofai
|
|
22510
22772
|
\uD83D\uDCD6 Docs: https://docs.befailproof.ai/introduction
|
|
22511
|
-
\uD83D\uDCAC Discord: https://discord.
|
|
22773
|
+
\uD83D\uDCAC Discord: https://discord.befailproof.ai/
|
|
22512
22774
|
`.trimStart());
|
|
22513
22775
|
process.exit(0);
|
|
22514
22776
|
}
|