@akasecurity/ai-tc-claude-code 0.9.7 → 0.9.8

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.
@@ -492,15 +492,14 @@ var require_ignore = __commonJS({
492
492
  });
493
493
 
494
494
  // src/apply-suppressions.ts
495
- import { existsSync as existsSync9, readFileSync as readFileSync12 } from "fs";
495
+ import { existsSync as existsSync10, readFileSync as readFileSync13 } from "fs";
496
496
  import { userInfo } from "os";
497
- import { dirname as dirname6, join as join18 } from "path";
497
+ import { dirname as dirname7, join as join20 } from "path";
498
498
  import { fileURLToPath as fileURLToPath4 } from "url";
499
499
 
500
- // ../../packages/persistence/src/database.ts
501
- import { randomUUID as randomUUID10 } from "crypto";
502
- import { join as join2, sep } from "path";
503
- import { DatabaseSync } from "node:sqlite";
500
+ // ../../packages/persistence/src/control-plane-credential.ts
501
+ import { chmodSync as chmodSync2, lstatSync as lstatSync2, readFileSync, rmSync as rmSync2, statSync } from "fs";
502
+ import { join } from "path";
504
503
 
505
504
  // ../../packages/schema/src/drizzle/sqlite-ddl.ts
506
505
  var SQLITE_MIGRATIONS = [
@@ -16204,6 +16203,124 @@ var ConfigScanRecord = external_exports.object({
16204
16203
  findings: external_exports.array(ConfigPostureFindingInput).optional()
16205
16204
  });
16206
16205
 
16206
+ // ../../packages/schema/src/zod/control-plane.ts
16207
+ var ATTACHED_CREDENTIAL_SPEC_VERSION = 1;
16208
+ var AttachedCredential = external_exports.object({
16209
+ specVersion: external_exports.literal(ATTACHED_CREDENTIAL_SPEC_VERSION),
16210
+ // The control-plane endpoint this credential was minted against.
16211
+ endpoint: external_exports.string().min(1),
16212
+ // The bearer credential itself. Never logged, never rendered — status
16213
+ // surfaces show `keyPrefix` and nothing else.
16214
+ apiKey: external_exports.string().min(1),
16215
+ // First few characters of the key, safe to display so a user can match the
16216
+ // credential against their organization's key list.
16217
+ keyPrefix: external_exports.string().min(1).max(16).optional(),
16218
+ mintedAt: external_exports.iso.datetime().optional()
16219
+ });
16220
+ var MAX_DATE_MS = 253402300799999;
16221
+ var MAX_INT4 = 2147483647;
16222
+ var StorePosturePack = external_exports.object({
16223
+ packId: external_exports.string().min(1),
16224
+ // 'namespace/packId'
16225
+ version: external_exports.string().min(1),
16226
+ enabled: external_exports.boolean(),
16227
+ // Stringified pass-through of the local store's `installed_packs.updated_at`
16228
+ // — the column format is store-version-dependent (epoch millis vs ISO), so
16229
+ // the wire shape assumes neither.
16230
+ updatedAt: external_exports.string().nullable()
16231
+ }).meta({ id: "StorePosturePack" });
16232
+ var StorePosturePolicyCounts = external_exports.object({
16233
+ total: external_exports.number().int().min(0),
16234
+ disabled: external_exports.number().int().min(0),
16235
+ // Exhaustive per-action map; the builder pre-fills every action with 0.
16236
+ //
16237
+ // Spelled out member-by-member rather than `z.record(ActionTaken, …)`. Zod
16238
+ // enforces exhaustiveness either way, but z.record emits `propertyNames` +
16239
+ // `additionalProperties` into a generated schema document, and a type
16240
+ // generator renders THAT with every key optional — a sender built against
16241
+ // the generated type would typecheck and still be rejected at runtime. An
16242
+ // explicit object emits `properties` + `required`, so generated types
16243
+ // demand all five.
16244
+ //
16245
+ // `satisfies Record<ActionTaken, …>` keeps the link to the enum: adding an
16246
+ // ActionTaken member is a COMPILE error here instead of silent drift.
16247
+ // `.strict()` is load-bearing — it rejects an unknown action key, which a
16248
+ // bare object would silently STRIP, accepting a miscounted map as valid.
16249
+ byAction: external_exports.object({
16250
+ warn: external_exports.number().int().min(0),
16251
+ redact: external_exports.number().int().min(0),
16252
+ block: external_exports.number().int().min(0),
16253
+ allow: external_exports.number().int().min(0),
16254
+ log: external_exports.number().int().min(0)
16255
+ }).strict()
16256
+ }).meta({ id: "StorePosturePolicyCounts" });
16257
+ var StorePosturePlugin = external_exports.object({
16258
+ /** Package name of the reporting plugin. */
16259
+ package: external_exports.string().min(1).max(200),
16260
+ version: external_exports.string().min(1).max(64),
16261
+ /** Version of the bundled core, when the build records one separately. */
16262
+ ossVersion: external_exports.string().max(64).nullable(),
16263
+ /**
16264
+ * `version` of the policy bundle this machine last fetched. Bounded at 200
16265
+ * rather than the 64 a bare sha256 hex digest needs today, so a later
16266
+ * format with an algorithm prefix does not start rejecting the channel.
16267
+ */
16268
+ policyBundleVersion: external_exports.string().max(200).nullable(),
16269
+ /** Epoch millis, on the CLIENT clock, of that fetch. */
16270
+ policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable()
16271
+ }).meta({ id: "StorePosturePlugin" });
16272
+ var StorePostureSnapshot = external_exports.object({
16273
+ deviceId: external_exports.guid(),
16274
+ hostname: external_exports.string().min(1).max(253),
16275
+ // Epoch millis on the CLIENT clock. Bounded by what a receiving store
16276
+ // accepts (see MAX_DATE_MS), not by what a JavaScript Date can hold.
16277
+ capturedAt: external_exports.number().int().min(0).max(MAX_DATE_MS),
16278
+ // False is a measurement, not an error state: "no local store exists on
16279
+ // this machine".
16280
+ storePresent: external_exports.boolean(),
16281
+ schemaVersion: external_exports.number().int().min(0).max(MAX_INT4).nullable(),
16282
+ // PRAGMA user_version
16283
+ findingsTotal: external_exports.number().int().min(0).max(MAX_INT4),
16284
+ // Epoch millis, bounded like `capturedAt` — see MAX_DATE_MS on what that
16285
+ // bound does and does not do. Worth stating for these two specifically:
16286
+ // they are read from the local store's own ROWS rather than from this
16287
+ // machine's clock, so a damaged or hand-edited store is enough to produce
16288
+ // an out-of-range value with no clock skew involved.
16289
+ findingsFirstAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
16290
+ findingsLastAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
16291
+ packs: external_exports.array(StorePosturePack).max(500),
16292
+ policyCounts: StorePosturePolicyCounts,
16293
+ // OPTIONAL, not nullable: a reporter that predates this member keeps
16294
+ // getting its 200 without a payload change.
16295
+ plugin: StorePosturePlugin.optional()
16296
+ }).meta({ id: "StorePostureSnapshot" });
16297
+ var CAPTURE_VERSION_PREFIX = "capture/";
16298
+ var RecordAuditEventRequest = AuditEventInput.extend({
16299
+ inspections: external_exports.array(ToolCallInspection).default([])
16300
+ }).refine((v) => v.inspections.every((i) => !i.ruleVersion.startsWith(CAPTURE_VERSION_PREFIX)), {
16301
+ message: `inspections[].ruleVersion must not start with \`${CAPTURE_VERSION_PREFIX}\` \u2014 that namespace is reserved for capture definitions the control plane mints itself`,
16302
+ path: ["inspections"]
16303
+ }).meta({ id: "RecordAuditEventRequest" });
16304
+ var IngestAck = external_exports.object({
16305
+ accepted: external_exports.number().int().nonnegative(),
16306
+ duplicates: external_exports.number().int().nonnegative()
16307
+ });
16308
+ var PRINTABLE = /^[^\p{Cc}\p{Cf}]*$/u;
16309
+ var printable = (max) => external_exports.string().max(max).regex(PRINTABLE, "must not contain control characters");
16310
+ var PluginWhoami = external_exports.object({
16311
+ tenantName: printable(200),
16312
+ userEmail: printable(320),
16313
+ role: printable(64),
16314
+ keyKind: printable(64),
16315
+ serverTime: printable(64)
16316
+ });
16317
+ var ControlPlaneErrorBody = external_exports.object({
16318
+ error: external_exports.object({
16319
+ code: external_exports.string().optional(),
16320
+ message: external_exports.string().optional()
16321
+ }).optional()
16322
+ });
16323
+
16207
16324
  // ../../packages/schema/src/zod/registry.ts
16208
16325
  var Namespace = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
16209
16326
  var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
@@ -18522,42 +18639,6 @@ function reviewSeverityRank(reasons) {
18522
18639
  return Math.min(...reasons.map((r) => REVIEW_SEVERITY_RANK[r]));
18523
18640
  }
18524
18641
 
18525
- // ../../packages/persistence/src/ids.ts
18526
- import { createHash } from "crypto";
18527
- function sha256Hex(input) {
18528
- return createHash("sha256").update(input).digest("hex");
18529
- }
18530
- function inventoryId(objectType, identityKey) {
18531
- return sha256Hex(canonicalIdentity(["inventory", objectType, identityKey]));
18532
- }
18533
- function sourceProjectId(url2) {
18534
- return sha256Hex(canonicalIdentity(["source_project", url2]));
18535
- }
18536
- function classifiedDataId(cls) {
18537
- return sha256Hex(canonicalIdentity(["classified_data", cls]));
18538
- }
18539
- function inspectionDefinitionId(ruleId, version2) {
18540
- return sha256Hex(canonicalIdentity(["inspection_definition", ruleId, version2]));
18541
- }
18542
- function llmCallId(sessionId, messageId) {
18543
- return sha256Hex(canonicalIdentity(["audit_event_llm_call", sessionId, messageId]));
18544
- }
18545
- function toolCallId(sessionId, toolUseId) {
18546
- return sha256Hex(canonicalIdentity(["audit_event_tool_call", sessionId, toolUseId]));
18547
- }
18548
- var NO_SESSION = "no_session";
18549
- var NO_PATH = "no_path";
18550
- function captureId(sessionId, contentHash, filePath = null) {
18551
- return sha256Hex(
18552
- canonicalIdentity(["capture", sessionId ?? NO_SESSION, contentHash, filePath ?? NO_PATH])
18553
- );
18554
- }
18555
-
18556
- // ../../packages/persistence/src/internal/snapshot.ts
18557
- import { randomUUID } from "crypto";
18558
- import { existsSync, readdirSync, renameSync as renameSync2, rmSync as rmSync2, statSync } from "fs";
18559
- import { basename, dirname, join } from "path";
18560
-
18561
18642
  // ../../packages/persistence/src/paths.ts
18562
18643
  import {
18563
18644
  chmodSync,
@@ -18606,7 +18687,46 @@ function tightenPerms(file2) {
18606
18687
  for (const path of [file2, ...dbSidecars(file2)]) chmodBestEffort(path, DATA_FILE_MODE);
18607
18688
  }
18608
18689
 
18690
+ // ../../packages/persistence/src/database.ts
18691
+ import { randomUUID as randomUUID10 } from "crypto";
18692
+ import { join as join3, sep } from "path";
18693
+ import { DatabaseSync } from "node:sqlite";
18694
+
18695
+ // ../../packages/persistence/src/ids.ts
18696
+ import { createHash } from "crypto";
18697
+ function sha256Hex(input) {
18698
+ return createHash("sha256").update(input).digest("hex");
18699
+ }
18700
+ function inventoryId(objectType, identityKey) {
18701
+ return sha256Hex(canonicalIdentity(["inventory", objectType, identityKey]));
18702
+ }
18703
+ function sourceProjectId(url2) {
18704
+ return sha256Hex(canonicalIdentity(["source_project", url2]));
18705
+ }
18706
+ function classifiedDataId(cls) {
18707
+ return sha256Hex(canonicalIdentity(["classified_data", cls]));
18708
+ }
18709
+ function inspectionDefinitionId(ruleId, version2) {
18710
+ return sha256Hex(canonicalIdentity(["inspection_definition", ruleId, version2]));
18711
+ }
18712
+ function llmCallId(sessionId, messageId) {
18713
+ return sha256Hex(canonicalIdentity(["audit_event_llm_call", sessionId, messageId]));
18714
+ }
18715
+ function toolCallId(sessionId, toolUseId) {
18716
+ return sha256Hex(canonicalIdentity(["audit_event_tool_call", sessionId, toolUseId]));
18717
+ }
18718
+ var NO_SESSION = "no_session";
18719
+ var NO_PATH = "no_path";
18720
+ function captureId(sessionId, contentHash, filePath = null) {
18721
+ return sha256Hex(
18722
+ canonicalIdentity(["capture", sessionId ?? NO_SESSION, contentHash, filePath ?? NO_PATH])
18723
+ );
18724
+ }
18725
+
18609
18726
  // ../../packages/persistence/src/internal/snapshot.ts
18727
+ import { randomUUID } from "crypto";
18728
+ import { existsSync, readdirSync, renameSync as renameSync2, rmSync as rmSync3, statSync as statSync2 } from "fs";
18729
+ import { basename, dirname, join as join2 } from "path";
18610
18730
  function backupPath(file2, tag) {
18611
18731
  return `${file2}.${tag}.${String(Date.now())}.${randomUUID().slice(0, 8)}.bak`;
18612
18732
  }
@@ -18616,15 +18736,15 @@ var STAGED_NAME_SUFFIX = `.bak${SNAPSHOT_STAGING_SUFFIX}`;
18616
18736
  var SNAPSHOT_STAGING_COPY = "copy";
18617
18737
  function createSnapshotStaging(backup) {
18618
18738
  const stage = `${backup}${SNAPSHOT_STAGING_SUFFIX}`;
18619
- rmSync2(stage, { recursive: true, force: true });
18739
+ rmSync3(stage, { recursive: true, force: true });
18620
18740
  mkdirOwnerOnlySync(stage);
18621
18741
  tightenDir(stage);
18622
- return { stage, copy: join(stage, SNAPSHOT_STAGING_COPY) };
18742
+ return { stage, copy: join2(stage, SNAPSHOT_STAGING_COPY) };
18623
18743
  }
18624
18744
  function idleMs(entry) {
18625
- for (const candidate of [join(entry, SNAPSHOT_STAGING_COPY), entry]) {
18745
+ for (const candidate of [join2(entry, SNAPSHOT_STAGING_COPY), entry]) {
18626
18746
  try {
18627
- return Date.now() - statSync(candidate).mtimeMs;
18747
+ return Date.now() - statSync2(candidate).mtimeMs;
18628
18748
  } catch {
18629
18749
  }
18630
18750
  }
@@ -18641,11 +18761,11 @@ function reapStalePartials(file2) {
18641
18761
  }
18642
18762
  for (const name of entries) {
18643
18763
  if (!name.startsWith(prefix) || !name.endsWith(STAGED_NAME_SUFFIX)) continue;
18644
- const staging = join(dir, name);
18764
+ const staging = join2(dir, name);
18645
18765
  try {
18646
18766
  const idle = idleMs(staging);
18647
18767
  if (idle !== null && idle > STALE_PARTIAL_MS) {
18648
- rmSync2(staging, { recursive: true, force: true });
18768
+ rmSync3(staging, { recursive: true, force: true });
18649
18769
  }
18650
18770
  } catch {
18651
18771
  }
@@ -18659,13 +18779,13 @@ function snapshotStore(db, backup) {
18659
18779
  renameSync2(copy, backup);
18660
18780
  } catch (error51) {
18661
18781
  try {
18662
- rmSync2(stage, { recursive: true, force: true });
18782
+ rmSync3(stage, { recursive: true, force: true });
18663
18783
  } catch {
18664
18784
  }
18665
18785
  throw error51;
18666
18786
  }
18667
18787
  try {
18668
- rmSync2(stage, { recursive: true, force: true });
18788
+ rmSync3(stage, { recursive: true, force: true });
18669
18789
  } catch {
18670
18790
  }
18671
18791
  }
@@ -18680,7 +18800,7 @@ function moveStoreAside(file2, backup) {
18680
18800
  renameSync2(sidecar, moved);
18681
18801
  undo.push([moved, sidecar]);
18682
18802
  } catch {
18683
- rmSync2(sidecar, { force: true });
18803
+ rmSync3(sidecar, { force: true });
18684
18804
  }
18685
18805
  }
18686
18806
  } catch (error51) {
@@ -18696,14 +18816,14 @@ function moveStoreAside(file2, backup) {
18696
18816
  }
18697
18817
  function discardStore(file2, backup) {
18698
18818
  try {
18699
- rmSync2(file2, { force: true });
18819
+ rmSync3(file2, { force: true });
18700
18820
  for (const sidecar of dbSidecars(file2)) {
18701
- rmSync2(sidecar, { force: true });
18821
+ rmSync3(sidecar, { force: true });
18702
18822
  }
18703
18823
  } catch (error51) {
18704
18824
  if (existsSync(file2)) {
18705
18825
  try {
18706
- rmSync2(backup, { force: true });
18826
+ rmSync3(backup, { force: true });
18707
18827
  } catch {
18708
18828
  }
18709
18829
  }
@@ -18935,10 +19055,31 @@ function applyMigrations(db, file2) {
18935
19055
  if (drained) applyLegacyDropMigration(db, file2);
18936
19056
  }
18937
19057
  }
19058
+ function readLegacyTables(db) {
19059
+ let holdsRows = false;
19060
+ const marks = [];
19061
+ for (const table2 of ["events", "findings"]) {
19062
+ try {
19063
+ const row = db.prepare(`SELECT count(*) AS n, ifnull(max(rowid), -1) AS hi FROM ${table2}`).get();
19064
+ if (row === void 0) {
19065
+ holdsRows = true;
19066
+ marks.push(`${table2}:unreadable`);
19067
+ continue;
19068
+ }
19069
+ if (row.n > 0) holdsRows = true;
19070
+ marks.push(`${table2}:${String(row.n)}:${String(row.hi)}`);
19071
+ } catch {
19072
+ holdsRows = true;
19073
+ marks.push(`${table2}:unreadable`);
19074
+ }
19075
+ }
19076
+ return { holdsRows, mark: marks.join("|") };
19077
+ }
18938
19078
  function applyLegacyDropMigration(db, file2) {
18939
19079
  const migration = SQLITE_MIGRATIONS.find((m) => m.tag === LEGACY_DROP_MIGRATION_TAG);
18940
19080
  if (!migration) return;
18941
- if (file2) {
19081
+ const before = file2 === void 0 ? void 0 : readLegacyTables(db);
19082
+ if (file2 !== void 0 && before?.holdsRows === true) {
18942
19083
  try {
18943
19084
  backupBeforeLegacyDrop(db, file2);
18944
19085
  } catch (error51) {
@@ -18952,6 +19093,12 @@ function applyLegacyDropMigration(db, file2) {
18952
19093
  () => {
18953
19094
  const alreadyDropped = db.prepare("SELECT 1 FROM migration_ledger WHERE tag = ?").get(migration.tag);
18954
19095
  if (alreadyDropped) return;
19096
+ if (before !== void 0 && readLegacyTables(db).mark !== before.mark) {
19097
+ akaWarn(
19098
+ "legacy events/findings rows changed after the pre-drop snapshot decision; deferring the drop so the next open can copy them first."
19099
+ );
19100
+ return;
19101
+ }
18955
19102
  for (const statement of splitStatements(migration.sql)) {
18956
19103
  db.exec(statement);
18957
19104
  }
@@ -25173,7 +25320,7 @@ function openAndInitialize(file2) {
25173
25320
  }
25174
25321
  function openLocalDatabase(dir) {
25175
25322
  ensureDataDirSync(dir);
25176
- const file2 = join2(dir, DB_FILENAME);
25323
+ const file2 = join3(dir, DB_FILENAME);
25177
25324
  reapStalePartials(file2);
25178
25325
  const {
25179
25326
  db,
@@ -25409,9 +25556,9 @@ import {
25409
25556
  closeSync,
25410
25557
  existsSync as existsSync2,
25411
25558
  openSync,
25412
- readFileSync,
25413
- rmSync as rmSync3,
25414
- statSync as statSync2,
25559
+ readFileSync as readFileSync2,
25560
+ rmSync as rmSync4,
25561
+ statSync as statSync3,
25415
25562
  writeFileSync as writeFileSync2
25416
25563
  } from "fs";
25417
25564
  import { hostname as hostname3 } from "os";
@@ -25422,26 +25569,26 @@ import { createHash as createHash3 } from "crypto";
25422
25569
 
25423
25570
  // ../../packages/persistence/src/fingerprint.ts
25424
25571
  import { createHmac, randomBytes } from "crypto";
25425
- import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
25426
- import { join as join3 } from "path";
25572
+ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
25573
+ import { join as join4 } from "path";
25427
25574
  import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
25428
25575
 
25429
25576
  // ../../packages/persistence/src/local-layout.ts
25430
25577
  import { renameSync as renameSync3 } from "fs";
25431
25578
  import { mkdir } from "fs/promises";
25432
25579
  import { homedir } from "os";
25433
- import { join as join4 } from "path";
25580
+ import { join as join5 } from "path";
25434
25581
  function defaultDataDir() {
25435
- return join4(homedir(), ".aka");
25582
+ return join5(homedir(), ".aka");
25436
25583
  }
25437
25584
  function settingsDir(base = defaultDataDir()) {
25438
- return join4(base, "settings");
25585
+ return join5(base, "settings");
25439
25586
  }
25440
25587
  function dataDir(base = defaultDataDir()) {
25441
- return join4(base, "data");
25588
+ return join5(base, "data");
25442
25589
  }
25443
25590
  function dbPath(base = defaultDataDir()) {
25444
- return join4(dataDir(base), "aka.db");
25591
+ return join5(dataDir(base), "aka.db");
25445
25592
  }
25446
25593
  function ensureLayoutDirSync(dir = defaultDataDir()) {
25447
25594
  ensureDataDirSync(dir);
@@ -25454,8 +25601,8 @@ function migrateLegacyLayout(base = defaultDataDir()) {
25454
25601
  for (const { name, dest } of moves) {
25455
25602
  try {
25456
25603
  ensureDataDirSync(dest);
25457
- const moved = join4(dest, name);
25458
- renameSync3(join4(base, name), moved);
25604
+ const moved = join5(dest, name);
25605
+ renameSync3(join5(base, name), moved);
25459
25606
  tightenFile(moved);
25460
25607
  } catch {
25461
25608
  }
@@ -25463,7 +25610,7 @@ function migrateLegacyLayout(base = defaultDataDir()) {
25463
25610
  }
25464
25611
 
25465
25612
  // ../../packages/persistence/src/managed-settings.ts
25466
- import { readFileSync as readFileSync3 } from "fs";
25613
+ import { readFileSync as readFileSync4 } from "fs";
25467
25614
  import { posix, win32 } from "path";
25468
25615
  function managedSettingsPaths(platform2 = process.platform) {
25469
25616
  if (platform2 === "darwin") {
@@ -25481,7 +25628,7 @@ function readManagedSettings(paths = managedSettingsPaths()) {
25481
25628
  for (const path of paths) {
25482
25629
  let text;
25483
25630
  try {
25484
- text = readFileSync3(path, "utf8");
25631
+ text = readFileSync4(path, "utf8");
25485
25632
  } catch {
25486
25633
  continue;
25487
25634
  }
@@ -25528,14 +25675,14 @@ function overlayManagedSettings(settings, managed, now = () => /* @__PURE__ */ n
25528
25675
  }
25529
25676
 
25530
25677
  // ../../packages/persistence/src/settings.ts
25531
- import { readFileSync as readFileSync4 } from "fs";
25532
- import { join as join5 } from "path";
25678
+ import { readFileSync as readFileSync5 } from "fs";
25679
+ import { join as join6 } from "path";
25533
25680
  var SETTINGS_FILENAME = "settings.json";
25534
25681
  function readWorkspaceSettings(base = defaultDataDir()) {
25535
25682
  return overlayManagedSettings(readUserSettings(base), readManagedSettings());
25536
25683
  }
25537
25684
  function readUserSettings(base) {
25538
- const record2 = readJson(join5(settingsDir(base), SETTINGS_FILENAME));
25685
+ const record2 = readJson(join6(settingsDir(base), SETTINGS_FILENAME));
25539
25686
  if (!record2) return defaultWorkspaceSettings();
25540
25687
  try {
25541
25688
  return WorkspaceSettings.parse(record2);
@@ -25546,13 +25693,17 @@ function readUserSettings(base) {
25546
25693
  function readJson(file2) {
25547
25694
  let text;
25548
25695
  try {
25549
- text = readFileSync4(file2, "utf8");
25696
+ text = readFileSync5(file2, "utf8");
25550
25697
  } catch {
25551
25698
  return null;
25552
25699
  }
25553
25700
  return parseJsonObject(text) ?? null;
25554
25701
  }
25555
25702
 
25703
+ // ../../packages/persistence/src/store-symlinks.ts
25704
+ import { existsSync as existsSync4, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
25705
+ import { dirname as dirname2, join as join7, resolve } from "path";
25706
+
25556
25707
  // ../../packages/persistence/src/vault/crypto.ts
25557
25708
  import {
25558
25709
  createCipheriv,
@@ -25565,19 +25716,19 @@ import {
25565
25716
  // ../../packages/persistence/src/vault/key-provider.ts
25566
25717
  import { execFileSync } from "child_process";
25567
25718
  import { randomBytes as randomBytes2 } from "crypto";
25568
- import { chmodSync as chmodSync2, readFileSync as readFileSync5, renameSync as renameSync4, rmSync as rmSync4, statSync as statSync3, writeFileSync as writeFileSync3 } from "fs";
25569
- import { join as join6 } from "path";
25719
+ import { chmodSync as chmodSync3, readFileSync as readFileSync6, renameSync as renameSync4, rmSync as rmSync5, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
25720
+ import { join as join8 } from "path";
25570
25721
 
25571
25722
  // ../../packages/persistence/src/vault/vault.ts
25572
25723
  import { randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
25573
25724
 
25574
25725
  // ../../packages/persistence/src/warn-era-cap.ts
25575
- import { existsSync as existsSync4, writeFileSync as writeFileSync4 } from "fs";
25576
- import { join as join7 } from "path";
25726
+ import { existsSync as existsSync5, writeFileSync as writeFileSync4 } from "fs";
25727
+ import { join as join9 } from "path";
25577
25728
 
25578
25729
  // ../../packages/plugin-sdk/src/config.ts
25579
- import { existsSync as existsSync5 } from "fs";
25580
- import { join as join8 } from "path";
25730
+ import { existsSync as existsSync6 } from "fs";
25731
+ import { join as join10 } from "path";
25581
25732
 
25582
25733
  // ../../packages/plugin-sdk/src/provider-env.ts
25583
25734
  var DEFAULT_ANTHROPIC_HOST = "api.anthropic.com";
@@ -25631,8 +25782,8 @@ function resolveProvider() {
25631
25782
  function loadConfig(base = defaultDataDir(), resolveProviderFn = resolveProvider) {
25632
25783
  try {
25633
25784
  ensureLayoutDirSync(base);
25634
- const settingsFile = join8(settingsDir(base), "settings.json");
25635
- if (existsSync5(settingsFile)) tightenFile(settingsFile);
25785
+ const settingsFile = join10(settingsDir(base), "settings.json");
25786
+ if (existsSync6(settingsFile)) tightenFile(settingsFile);
25636
25787
  } catch {
25637
25788
  }
25638
25789
  migrateLegacyLayout(base);
@@ -25655,9 +25806,9 @@ function resolveProviderSafe(resolveProviderFn) {
25655
25806
  }
25656
25807
 
25657
25808
  // ../../packages/plugin-sdk/src/config-inventory.ts
25658
- import { readdirSync as readdirSync2, readFileSync as readFileSync7, realpathSync, statSync as statSync5 } from "fs";
25809
+ import { readdirSync as readdirSync2, readFileSync as readFileSync8, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
25659
25810
  import { homedir as homedir2 } from "os";
25660
- import { basename as basename3, join as join10 } from "path";
25811
+ import { basename as basename3, join as join12 } from "path";
25661
25812
 
25662
25813
  // ../../packages/detections/src/egress/registry.ts
25663
25814
  var EXTRACTOR_VERSION = "1";
@@ -27347,10 +27498,10 @@ var localhost_ref_default = {
27347
27498
  severity: "low",
27348
27499
  matcher: {
27349
27500
  type: "regex",
27350
- pattern: "\\b(?:localhost|127\\.0\\.0\\.1|0\\.0\\.0\\.0|::1)\\b",
27501
+ pattern: "(?<![A-Za-z0-9_])(?:localhost|127\\.0\\.0\\.1|0\\.0\\.0\\.0|(?<![A-Za-z0-9_]\\[)::1(?!:|\\.[0-9]))(?![A-Za-z0-9_])",
27351
27502
  flags: "g"
27352
27503
  },
27353
- examples: ["localhost", "127.0.0.1"]
27504
+ examples: ["localhost", "127.0.0.1", "0.0.0.0", "::1"]
27354
27505
  };
27355
27506
 
27356
27507
  // ../../rules/core-code-context/stack-trace.json
@@ -28692,32 +28843,32 @@ function maskText(text) {
28692
28843
  }
28693
28844
 
28694
28845
  // ../../packages/plugin-sdk/src/repo.ts
28695
- import { existsSync as existsSync6, readFileSync as readFileSync6, statSync as statSync4 } from "fs";
28696
- import { basename as basename2, dirname as dirname2, isAbsolute, join as join9, sep as sep2 } from "path";
28846
+ import { existsSync as existsSync7, readFileSync as readFileSync7, statSync as statSync6 } from "fs";
28847
+ import { basename as basename2, dirname as dirname3, isAbsolute, join as join11, sep as sep2 } from "path";
28697
28848
 
28698
28849
  // ../../packages/plugin-sdk/src/events.ts
28699
28850
  import { createHash as createHash4, randomUUID as randomUUID13 } from "crypto";
28700
28851
 
28701
28852
  // ../../packages/plugin-sdk/src/isolated-scan.ts
28702
- import { existsSync as existsSync7 } from "fs";
28853
+ import { existsSync as existsSync8 } from "fs";
28703
28854
  import { fileURLToPath } from "url";
28704
28855
  import { Worker } from "worker_threads";
28705
28856
 
28706
28857
  // ../../packages/plugin-sdk/src/ignore-layers.ts
28707
28858
  var import_ignore = __toESM(require_ignore(), 1);
28708
- import { readFileSync as readFileSync8 } from "fs";
28709
- import { join as join11 } from "path";
28859
+ import { readFileSync as readFileSync9 } from "fs";
28860
+ import { join as join13 } from "path";
28710
28861
 
28711
28862
  // ../../packages/plugin-sdk/src/inventory-resolver.ts
28712
28863
  import { arch, hostname as hostname4, platform, release } from "os";
28713
28864
 
28714
28865
  // ../../packages/plugin-sdk/src/nudge.ts
28715
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "fs";
28716
- import { join as join12 } from "path";
28866
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "fs";
28867
+ import { join as join14 } from "path";
28717
28868
 
28718
28869
  // ../../packages/plugin-sdk/src/paths.ts
28719
- import { readdirSync as readdirSync3, realpathSync as realpathSync2 } from "fs";
28720
- import { basename as basename4, dirname as dirname3, sep as sep3 } from "path";
28870
+ import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
28871
+ import { basename as basename4, dirname as dirname4, sep as sep3 } from "path";
28721
28872
 
28722
28873
  // ../../packages/plugin-sdk/src/posture.ts
28723
28874
  function applyCategoryPosture(posture, repo, mode = "fill-gaps") {
@@ -28730,8 +28881,8 @@ function applyCategoryPosture(posture, repo, mode = "fill-gaps") {
28730
28881
  }
28731
28882
 
28732
28883
  // ../../packages/plugin-sdk/src/project-files.ts
28733
- import { existsSync as existsSync8, readdirSync as readdirSync4 } from "fs";
28734
- import { basename as basename5, join as join13 } from "path";
28884
+ import { existsSync as existsSync9, readdirSync as readdirSync4 } from "fs";
28885
+ import { basename as basename5, join as join15 } from "path";
28735
28886
 
28736
28887
  // ../../packages/plugin-sdk/src/provider-env-antigravity.ts
28737
28888
  var optionalBaseUrl2 = external_exports.preprocess((v) => {
@@ -28848,12 +28999,12 @@ async function applySetupTriageSuppressions(entries, writer, opts) {
28848
28999
  }
28849
29000
 
28850
29001
  // ../../packages/plugin-sdk/src/throttle.ts
28851
- import { mkdirSync as mkdirSync3, statSync as statSync6, writeFileSync as writeFileSync6 } from "fs";
28852
- import { join as join14 } from "path";
29002
+ import { mkdirSync as mkdirSync3, statSync as statSync8, writeFileSync as writeFileSync6 } from "fs";
29003
+ import { join as join16 } from "path";
28853
29004
 
28854
29005
  // ../../packages/setup-wizard/src/remediation/rotation-checklist.ts
28855
29006
  import { writeFileSync as writeFileSync7 } from "fs";
28856
- import { join as join15 } from "path";
29007
+ import { join as join17 } from "path";
28857
29008
 
28858
29009
  // ../../packages/setup-wizard/src/triage/dedupe.ts
28859
29010
  function dedupeKey(hit) {
@@ -28908,12 +29059,12 @@ function deriveFalsePositivePatterns(hits, rec, plan) {
28908
29059
  }
28909
29060
 
28910
29061
  // ../../packages/setup-wizard/src/triage/gate-display.ts
28911
- function findContext(entry, join19) {
28912
- const byFingerprint = join19.find(
29062
+ function findContext(entry, join21) {
29063
+ const byFingerprint = join21.find(
28913
29064
  (j) => j.valueFingerprint !== void 0 && j.valueFingerprint === entry.valueFingerprint
28914
29065
  );
28915
29066
  if (byFingerprint) return byFingerprint.maskedContext;
28916
- const byRuleAndMask = join19.find(
29067
+ const byRuleAndMask = join21.find(
28917
29068
  (j) => j.ruleId === entry.ruleId && j.maskedMatch === entry.maskedValue
28918
29069
  );
28919
29070
  return byRuleAndMask?.maskedContext;
@@ -28984,13 +29135,13 @@ function renderShowcase(showcase) {
28984
29135
 
28985
29136
  ${blocks.join("\n\n")}`;
28986
29137
  }
28987
- function renderSuppressionGate(entries, join19) {
29138
+ function renderSuppressionGate(entries, join21) {
28988
29139
  if (entries.length === 0) {
28989
29140
  return "No false-positive suppressions to confirm \u2014 nothing will be written.";
28990
29141
  }
28991
29142
  const header = entries.length === 1 ? "This looks like a false positive \u2014 take a look before I suppress it:" : `These ${String(entries.length)} look like false positives \u2014 take a look before I suppress them:`;
28992
29143
  const blocks = entries.map((entry, i) => {
28993
- const context = findContext(entry, join19);
29144
+ const context = findContext(entry, join21);
28994
29145
  const lines = [
28995
29146
  `${String(i + 1)}. ${entry.ruleId} [${entry.category}]`,
28996
29147
  ` value: ${entry.maskedValue}`,
@@ -29076,9 +29227,9 @@ function mergeRecommendations(verdicts) {
29076
29227
  }
29077
29228
 
29078
29229
  // ../../packages/setup-wizard/src/triage/plan-file.ts
29079
- import { mkdtempSync, readFileSync as readFileSync10, rmdirSync, rmSync as rmSync5, writeFileSync as writeFileSync8 } from "fs";
29230
+ import { mkdtempSync, readFileSync as readFileSync11, rmdirSync, rmSync as rmSync6, writeFileSync as writeFileSync8 } from "fs";
29080
29231
  import { tmpdir } from "os";
29081
- import { basename as basename6, dirname as dirname4, join as join16 } from "path";
29232
+ import { basename as basename6, dirname as dirname5, join as join18 } from "path";
29082
29233
  var SuppressionEntrySchema = external_exports.object({
29083
29234
  ruleId: external_exports.string(),
29084
29235
  category: DetectionCategory,
@@ -29133,19 +29284,19 @@ function serializePlan(plan, current) {
29133
29284
  function writePlanFile(plan, current, rawValues, deps = {}) {
29134
29285
  const serialized = serializePlan(plan, current);
29135
29286
  assertRawFree(serialized, rawValues);
29136
- const dir = (deps.mkTempDir ?? (() => mkdtempSync(join16(tmpdir(), "aka-plan-"))))();
29137
- const path = join16(dir, "setup-plan.json");
29287
+ const dir = (deps.mkTempDir ?? (() => mkdtempSync(join18(tmpdir(), "aka-plan-"))))();
29288
+ const path = join18(dir, "setup-plan.json");
29138
29289
  writeFileSync8(path, serialized, { encoding: "utf8", mode: 384 });
29139
29290
  return path;
29140
29291
  }
29141
29292
  function readPlanFile(path) {
29142
- const text = readFileSync10(path, "utf8");
29293
+ const text = readFileSync11(path, "utf8");
29143
29294
  const json2 = JSON.parse(text);
29144
29295
  return PersistedPlanSchema.parse(json2);
29145
29296
  }
29146
29297
  function deletePlanFile(path) {
29147
- rmSync5(path, { force: true });
29148
- const dir = dirname4(path);
29298
+ rmSync6(path, { force: true });
29299
+ const dir = dirname5(path);
29149
29300
  if (!basename6(dir).startsWith("aka-plan-")) return;
29150
29301
  try {
29151
29302
  rmdirSync(dir);
@@ -29213,8 +29364,8 @@ function buildJoinEntries(hits) {
29213
29364
  }
29214
29365
 
29215
29366
  // ../../packages/setup-wizard/src/triage/resolve.ts
29216
- function resolveSuppressions(rec, join19) {
29217
- const byId = new Map(join19.map((e) => [e.id, e]));
29367
+ function resolveSuppressions(rec, join21) {
29368
+ const byId = new Map(join21.map((e) => [e.id, e]));
29218
29369
  const entries = [];
29219
29370
  const skipped = [];
29220
29371
  for (const cat of rec.perCategory) {
@@ -29316,7 +29467,7 @@ function parseTriageStream(text) {
29316
29467
  return { hits, status: "complete" };
29317
29468
  }
29318
29469
  function planTriageWriteback(hits, rec) {
29319
- const join19 = buildJoinEntries(hits);
29470
+ const join21 = buildJoinEntries(hits);
29320
29471
  const rawValues = hits.map((h) => h.rawMatch);
29321
29472
  const skipped = [];
29322
29473
  const posture = {};
@@ -29356,7 +29507,7 @@ function planTriageWriteback(hits, rec) {
29356
29507
  }
29357
29508
  const { entries, skipped: resolveSkips } = resolveSuppressions(
29358
29509
  { perCategory: safeCategories, notes: rec.notes },
29359
- join19
29510
+ join21
29360
29511
  );
29361
29512
  skipped.push(...resolveSkips);
29362
29513
  let notes = rec.notes;
@@ -29366,7 +29517,7 @@ function planTriageWriteback(hits, rec) {
29366
29517
  if (err instanceof RawEgressError) notes = SCRUBBED_NOTES;
29367
29518
  else throw err;
29368
29519
  }
29369
- return { entries, posture, showcase, join: join19, notes, skipped };
29520
+ return { entries, posture, showcase, join: join21, notes, skipped };
29370
29521
  }
29371
29522
  function recommendedPosture(evidence) {
29372
29523
  return { ...severityFloorPosture(), ...evidence };
@@ -29635,9 +29786,9 @@ function parseRecommendation(text) {
29635
29786
 
29636
29787
  // src/triage/judge.ts
29637
29788
  import { execFileSync as execFileSync2 } from "child_process";
29638
- import { mkdtempSync as mkdtempSync2, readFileSync as readFileSync11, rmSync as rmSync6 } from "fs";
29789
+ import { mkdtempSync as mkdtempSync2, readFileSync as readFileSync12, rmSync as rmSync7 } from "fs";
29639
29790
  import { tmpdir as tmpdir2 } from "os";
29640
- import { dirname as dirname5, join as join17 } from "path";
29791
+ import { dirname as dirname6, join as join19 } from "path";
29641
29792
  import { fileURLToPath as fileURLToPath2 } from "url";
29642
29793
 
29643
29794
  // ../../packages/plugin-sdk/src/bare-command.ts
@@ -29728,8 +29879,8 @@ function planBareCommand(command, args, deps = {}) {
29728
29879
  return { file: command, args, options: {}, viaShell: false, resolved: void 0 };
29729
29880
  }
29730
29881
  const home = deps.home ?? homedir3();
29731
- const resolve = deps.resolve ?? resolveWindowsCommand;
29732
- const resolved = resolve(command, deps.env, home);
29882
+ const resolve2 = deps.resolve ?? resolveWindowsCommand;
29883
+ const resolved = resolve2(command, deps.env, home);
29733
29884
  if (resolved !== void 0 && isDirectlyExecutable(resolved)) {
29734
29885
  return { file: resolved, args, options: { cwd: home }, viaShell: false, resolved };
29735
29886
  }
@@ -29748,8 +29899,8 @@ function planBareCommand(command, args, deps = {}) {
29748
29899
  }
29749
29900
 
29750
29901
  // src/triage/judge.ts
29751
- var TRIAGE_DIR = dirname5(fileURLToPath2(import.meta.url));
29752
- var DEFAULT_RUBRIC_PATH = join17(
29902
+ var TRIAGE_DIR = dirname6(fileURLToPath2(import.meta.url));
29903
+ var DEFAULT_RUBRIC_PATH = join19(
29753
29904
  TRIAGE_DIR,
29754
29905
  "..",
29755
29906
  "..",
@@ -29786,7 +29937,7 @@ function judgeEnv(platform2 = process.platform) {
29786
29937
  CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1"
29787
29938
  };
29788
29939
  if (platform2 === "darwin") {
29789
- env.CLAUDE_CONFIG_DIR = mkdtempSync2(join17(tmpdir2(), "aka-judge-cfg-"));
29940
+ env.CLAUDE_CONFIG_DIR = mkdtempSync2(join19(tmpdir2(), "aka-judge-cfg-"));
29790
29941
  }
29791
29942
  return env;
29792
29943
  }
@@ -29821,7 +29972,7 @@ function runJudge(hits, deps) {
29821
29972
  if (typeof deps.spawn !== "function") {
29822
29973
  throw new TypeError("runJudge requires deps.spawn \u2014 there is no live-spawn fallback");
29823
29974
  }
29824
- const rubric = deps.loadRubric?.() ?? readFileSync11(DEFAULT_RUBRIC_PATH, "utf8");
29975
+ const rubric = deps.loadRubric?.() ?? readFileSync12(DEFAULT_RUBRIC_PATH, "utf8");
29825
29976
  const hitsJsonl = hits.map((h) => JSON.stringify(toJudgePayload(h))).join("\n");
29826
29977
  const fullPrompt = `${rubric}
29827
29978
 
@@ -29845,7 +29996,7 @@ ${hitsJsonl}
29845
29996
  } finally {
29846
29997
  if (platform2 === "darwin" && env.CLAUDE_CONFIG_DIR) {
29847
29998
  try {
29848
- rmSync6(env.CLAUDE_CONFIG_DIR, { recursive: true, force: true });
29999
+ rmSync7(env.CLAUDE_CONFIG_DIR, { recursive: true, force: true });
29849
30000
  } catch {
29850
30001
  }
29851
30002
  }
@@ -30090,11 +30241,11 @@ function resolveCreatedBy() {
30090
30241
  }
30091
30242
  }
30092
30243
  function loadRubric() {
30093
- const here = dirname6(fileURLToPath4(import.meta.url));
30094
- const shipped = join18(here, "triage-rubric.md");
30095
- if (existsSync9(shipped)) return readFileSync12(shipped, "utf8");
30096
- return readFileSync12(
30097
- join18(here, "..", "..", "..", "packages", "setup-wizard", "assets", "triage-rubric.md"),
30244
+ const here = dirname7(fileURLToPath4(import.meta.url));
30245
+ const shipped = join20(here, "triage-rubric.md");
30246
+ if (existsSync10(shipped)) return readFileSync13(shipped, "utf8");
30247
+ return readFileSync13(
30248
+ join20(here, "..", "..", "..", "packages", "setup-wizard", "assets", "triage-rubric.md"),
30098
30249
  "utf8"
30099
30250
  );
30100
30251
  }
@@ -30104,7 +30255,7 @@ async function main() {
30104
30255
  argv,
30105
30256
  // fd 0 = stdin; the wizard pipes `backfill.js --triage` into this on preview.
30106
30257
  // Called only on the preview path — the confirm path never reads a stream.
30107
- readStream: (streamPath) => streamPath !== void 0 ? readFileSync12(streamPath, "utf8") : readFileSync12(0, "utf8"),
30258
+ readStream: (streamPath) => streamPath !== void 0 ? readFileSync13(streamPath, "utf8") : readFileSync13(0, "utf8"),
30108
30259
  runJudge: (hits) => runJudge(hits, { spawn: spawnClaude, loadRubric }),
30109
30260
  // The distinct model-judge egress consent, read from settings.json. When it
30110
30261
  // is absent or stale the preview skips the judge instead of sending findings