@pretense/cli 0.6.19 → 0.6.20
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.
|
@@ -17,7 +17,7 @@ function versionFromPackageJson() {
|
|
|
17
17
|
return void 0;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
var PRETENSE_VERSION = (true ? "0.6.
|
|
20
|
+
var PRETENSE_VERSION = (true ? "0.6.20" : void 0) ?? versionFromPackageJson() ?? "0.0.0-unknown";
|
|
21
21
|
|
|
22
22
|
export {
|
|
23
23
|
PRETENSE_VERSION
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
PRETENSE_VERSION
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-N2GZIZAD.js";
|
|
5
5
|
import {
|
|
6
6
|
__commonJS,
|
|
7
7
|
__toESM,
|
|
@@ -16582,11 +16582,11 @@ function versionFromCliPackageJson() {
|
|
|
16582
16582
|
return void 0;
|
|
16583
16583
|
}
|
|
16584
16584
|
function productVersion() {
|
|
16585
|
-
return override ?? (true ? "0.6.
|
|
16585
|
+
return override ?? (true ? "0.6.20" : void 0) ?? versionFromCliPackageJson() ?? "0.0.0-unknown";
|
|
16586
16586
|
}
|
|
16587
16587
|
var UNKNOWN_COMMIT = "unknown";
|
|
16588
16588
|
function bakedCommitSha() {
|
|
16589
|
-
return "
|
|
16589
|
+
return "69ea69288cc5d8698de1a2bdb4e3c29c002596c6".length > 0 ? "69ea69288cc5d8698de1a2bdb4e3c29c002596c6" : UNKNOWN_COMMIT;
|
|
16590
16590
|
}
|
|
16591
16591
|
var FEATURE_TIERS = {
|
|
16592
16592
|
compliance_export: "pro",
|
|
@@ -17201,6 +17201,65 @@ function getTelemetryEmitter(dashboardUrl, pushToken) {
|
|
|
17201
17201
|
_emitter = new TelemetryEmitter(url, token);
|
|
17202
17202
|
return _emitter;
|
|
17203
17203
|
}
|
|
17204
|
+
var DEFAULT_UPLOAD_URL = "https://api.pretense.ai";
|
|
17205
|
+
var UPLOAD_TIMEOUT_MS = 5e3;
|
|
17206
|
+
var MAX_IN_FLIGHT2 = 64;
|
|
17207
|
+
var _inFlight = 0;
|
|
17208
|
+
var _dropped = 0;
|
|
17209
|
+
function telemetryDisabled() {
|
|
17210
|
+
const v = process.env["PRETENSE_NO_TELEMETRY"]?.trim().toLowerCase();
|
|
17211
|
+
return v === "1" || v === "true" || v === "yes" || v === "on";
|
|
17212
|
+
}
|
|
17213
|
+
function resolveUploadBaseUrl() {
|
|
17214
|
+
const raw2 = (process.env["PRETENSE_DASHBOARD_URL"] ?? DEFAULT_UPLOAD_URL).trim();
|
|
17215
|
+
if (!raw2) return DEFAULT_UPLOAD_URL;
|
|
17216
|
+
const normalized = /^https?:\/\//i.test(raw2) ? raw2 : `https://${raw2}`;
|
|
17217
|
+
try {
|
|
17218
|
+
const u = new URL(normalized);
|
|
17219
|
+
const path2 = u.pathname === "/" ? "" : u.pathname.replace(/\/$/, "");
|
|
17220
|
+
return `${u.origin}${path2}`;
|
|
17221
|
+
} catch {
|
|
17222
|
+
return DEFAULT_UPLOAD_URL;
|
|
17223
|
+
}
|
|
17224
|
+
}
|
|
17225
|
+
function resolveUploadKey(requestKey) {
|
|
17226
|
+
const dashboardKey = process.env["PRETENSE_DASHBOARD_API_KEY"]?.trim();
|
|
17227
|
+
if (dashboardKey) return dashboardKey;
|
|
17228
|
+
const rk = requestKey?.trim();
|
|
17229
|
+
return rk && rk.length > 0 ? rk : null;
|
|
17230
|
+
}
|
|
17231
|
+
function clampCount(n) {
|
|
17232
|
+
return Number.isFinite(n) && n > 0 ? Math.floor(n) : 0;
|
|
17233
|
+
}
|
|
17234
|
+
function uploadProxyUsage(event) {
|
|
17235
|
+
if (telemetryDisabled()) return;
|
|
17236
|
+
const key = resolveUploadKey(event.apiKey);
|
|
17237
|
+
if (!key) return;
|
|
17238
|
+
if (_inFlight >= MAX_IN_FLIGHT2) {
|
|
17239
|
+
_dropped++;
|
|
17240
|
+
return;
|
|
17241
|
+
}
|
|
17242
|
+
const url = `${resolveUploadBaseUrl()}/api/cli/log`;
|
|
17243
|
+
const signal = typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function" ? AbortSignal.timeout(UPLOAD_TIMEOUT_MS) : void 0;
|
|
17244
|
+
_inFlight++;
|
|
17245
|
+
void Promise.resolve().then(
|
|
17246
|
+
() => fetch(url, {
|
|
17247
|
+
method: "POST",
|
|
17248
|
+
headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
|
|
17249
|
+
// COUNTS + METADATA ONLY — never a secret value or request body.
|
|
17250
|
+
body: JSON.stringify({
|
|
17251
|
+
file_count: 0,
|
|
17252
|
+
identifiers_mutated: clampCount(event.identifiersMutated),
|
|
17253
|
+
secrets_blocked: clampCount(event.secretsBlocked),
|
|
17254
|
+
llm_provider: event.provider
|
|
17255
|
+
}),
|
|
17256
|
+
...signal ? { signal } : {}
|
|
17257
|
+
})
|
|
17258
|
+
).catch(() => {
|
|
17259
|
+
}).finally(() => {
|
|
17260
|
+
_inFlight--;
|
|
17261
|
+
});
|
|
17262
|
+
}
|
|
17204
17263
|
var riskScorer = new RiskScorer();
|
|
17205
17264
|
function detectUpstream(path2, overrideHeader) {
|
|
17206
17265
|
if (overrideHeader) return overrideHeader;
|
|
@@ -18076,6 +18135,15 @@ ${_upgradeTier === "enterprise" ? "Enterprise offers unlimited mutations \u2014
|
|
|
18076
18135
|
...skippedUnscannable > 0 ? { findings: ["skipped_unscannable_field"] } : {},
|
|
18077
18136
|
sourceIp: c.req.header("x-forwarded-for") ?? c.req.header("x-real-ip")
|
|
18078
18137
|
}));
|
|
18138
|
+
if (anyTokenized) {
|
|
18139
|
+
const usageKey = c.req.header("x-pretense-api-key") ?? c.req.header("authorization")?.replace(/^Bearer\s+/i, "");
|
|
18140
|
+
uploadProxyUsage({
|
|
18141
|
+
apiKey: usageKey,
|
|
18142
|
+
identifiersMutated: mutationsApplied,
|
|
18143
|
+
secretsBlocked: secretsTokenized,
|
|
18144
|
+
provider
|
|
18145
|
+
});
|
|
18146
|
+
}
|
|
18079
18147
|
const reverseMap = /* @__PURE__ */ new Map();
|
|
18080
18148
|
for (const [orig, syn] of globalMap.entries()) {
|
|
18081
18149
|
if (!secretMap.has(syn)) reverseMap.set(orig, syn);
|
|
@@ -21317,6 +21385,67 @@ function recordLocalAudit(rec, dbPath = localAuditDbPath()) {
|
|
|
21317
21385
|
}
|
|
21318
21386
|
}
|
|
21319
21387
|
|
|
21388
|
+
// src/usage-upload.ts
|
|
21389
|
+
init_esm_shims();
|
|
21390
|
+
var UPLOAD_TIMEOUT_MS2 = 3e3;
|
|
21391
|
+
function telemetryDisabled2() {
|
|
21392
|
+
const v = process.env["PRETENSE_NO_TELEMETRY"]?.trim().toLowerCase();
|
|
21393
|
+
return v === "1" || v === "true" || v === "yes" || v === "on";
|
|
21394
|
+
}
|
|
21395
|
+
function resolveUploadBaseUrl2() {
|
|
21396
|
+
const raw2 = process.env["PRETENSE_DASHBOARD_URL"]?.trim();
|
|
21397
|
+
if (!raw2) return getConfiguredApiRoot();
|
|
21398
|
+
const normalized = /^https?:\/\//i.test(raw2) ? raw2 : `https://${raw2}`;
|
|
21399
|
+
try {
|
|
21400
|
+
const u = new URL(normalized);
|
|
21401
|
+
const path2 = u.pathname === "/" ? "" : u.pathname.replace(/\/$/, "");
|
|
21402
|
+
return `${u.origin}${path2}`;
|
|
21403
|
+
} catch {
|
|
21404
|
+
return getConfiguredApiRoot();
|
|
21405
|
+
}
|
|
21406
|
+
}
|
|
21407
|
+
function resolveUploadKey2() {
|
|
21408
|
+
const dashboardKey = process.env["PRETENSE_DASHBOARD_API_KEY"]?.trim();
|
|
21409
|
+
if (dashboardKey) return dashboardKey;
|
|
21410
|
+
return readApiKey();
|
|
21411
|
+
}
|
|
21412
|
+
function clampCount2(n) {
|
|
21413
|
+
return Number.isFinite(n) && n > 0 ? Math.floor(n) : 0;
|
|
21414
|
+
}
|
|
21415
|
+
async function uploadUsage(event) {
|
|
21416
|
+
try {
|
|
21417
|
+
if (telemetryDisabled2()) return "skipped";
|
|
21418
|
+
const key = resolveUploadKey2();
|
|
21419
|
+
if (!key) return "skipped";
|
|
21420
|
+
const url = `${resolveUploadBaseUrl2()}/api/cli/log`;
|
|
21421
|
+
const controller = new AbortController();
|
|
21422
|
+
const timer = setTimeout(() => controller.abort(), UPLOAD_TIMEOUT_MS2);
|
|
21423
|
+
try {
|
|
21424
|
+
const resp = await fetch(url, {
|
|
21425
|
+
method: "POST",
|
|
21426
|
+
headers: {
|
|
21427
|
+
"content-type": "application/json",
|
|
21428
|
+
authorization: `Bearer ${key}`
|
|
21429
|
+
},
|
|
21430
|
+
// COUNTS + METADATA ONLY — never a secret value, an identifier name, or
|
|
21431
|
+
// file content. Field names match the `/api/cli/log` contract.
|
|
21432
|
+
body: JSON.stringify({
|
|
21433
|
+
file_count: clampCount2(event.fileCount),
|
|
21434
|
+
identifiers_mutated: clampCount2(event.identifiersMutated),
|
|
21435
|
+
secrets_blocked: clampCount2(event.secretsBlocked),
|
|
21436
|
+
llm_provider: event.llmProvider
|
|
21437
|
+
}),
|
|
21438
|
+
signal: controller.signal
|
|
21439
|
+
});
|
|
21440
|
+
return resp.ok ? "sent" : "failed";
|
|
21441
|
+
} finally {
|
|
21442
|
+
clearTimeout(timer);
|
|
21443
|
+
}
|
|
21444
|
+
} catch {
|
|
21445
|
+
return "failed";
|
|
21446
|
+
}
|
|
21447
|
+
}
|
|
21448
|
+
|
|
21320
21449
|
// src/commands/mutate.ts
|
|
21321
21450
|
var REVERSAL_MAP_VERSION = 3;
|
|
21322
21451
|
function preflightReversalMap(mapPath, absFile, content, contentSha, force) {
|
|
@@ -21618,6 +21747,12 @@ async function runMutate(file, opts = {}) {
|
|
|
21618
21747
|
detectorKinds: [...new Set(result.mutations.map((m) => m.type))],
|
|
21619
21748
|
file: absFile
|
|
21620
21749
|
});
|
|
21750
|
+
await uploadUsage({
|
|
21751
|
+
fileCount: 1,
|
|
21752
|
+
identifiersMutated: result.mutations.length,
|
|
21753
|
+
secretsBlocked,
|
|
21754
|
+
llmProvider: "cli-mutate"
|
|
21755
|
+
});
|
|
21621
21756
|
}
|
|
21622
21757
|
if (opts.showMap) {
|
|
21623
21758
|
console.error(JSON.stringify(result.mutations, null, 2));
|
package/dist/postinstall.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pretense/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.20",
|
|
4
4
|
"description": "Local-first AI firewall that mutates proprietary code before sending to LLM APIs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"typescript": "^5.4.0",
|
|
25
25
|
"vitest": "^1.0.0",
|
|
26
26
|
"@pretense/billing": "0.1.0",
|
|
27
|
-
"@pretense/compliance-engine": "0.1.0",
|
|
28
27
|
"@pretense/protocol": "0.1.0",
|
|
29
28
|
"@pretense/learner": "0.2.0",
|
|
30
29
|
"@pretense/mutator": "0.2.0",
|
|
31
|
-
"@pretense/
|
|
30
|
+
"@pretense/compliance-engine": "0.1.0",
|
|
32
31
|
"@pretense/scanner": "0.2.0",
|
|
33
32
|
"@pretense/scanner-rs": "0.2.0",
|
|
34
|
-
"@pretense/store": "0.2.0"
|
|
33
|
+
"@pretense/store": "0.2.0",
|
|
34
|
+
"@pretense/proxy": "0.1.0"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public",
|