@akasecurity/ai-tc-claude-code 0.9.2 → 0.9.3
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/.claude-plugin/plugin.json +1 -1
- package/package.json +3 -3
- package/scripts/apply-suppressions.js +94 -45
- package/scripts/backfill.js +139 -47
- package/scripts/filescan.js +141 -49
- package/scripts/firstrun.js +93 -44
- package/scripts/intro.js +6 -5
- package/scripts/onboard.js +93 -44
- package/scripts/post-tool-use.js +139 -47
- package/scripts/pre-tool-use.js +139 -47
- package/scripts/query.js +93 -44
- package/scripts/reconcile.js +95 -46
- package/scripts/remediate.js +139 -47
- package/scripts/session-start.js +96 -47
- package/scripts/start-light.js +6 -5
- package/scripts/statusline.js +93 -44
- package/scripts/stop.js +7 -6
- package/scripts/user-prompt-submit.js +139 -47
package/scripts/reconcile.js
CHANGED
|
@@ -492,7 +492,7 @@ var require_ignore = __commonJS({
|
|
|
492
492
|
});
|
|
493
493
|
|
|
494
494
|
// ../../packages/plugin-sdk/src/config.ts
|
|
495
|
-
import { existsSync as
|
|
495
|
+
import { existsSync as existsSync4 } from "fs";
|
|
496
496
|
import { join as join6 } from "path";
|
|
497
497
|
|
|
498
498
|
// ../../packages/persistence/src/database.ts
|
|
@@ -23375,11 +23375,22 @@ function purgeSampleData(db) {
|
|
|
23375
23375
|
function linkHost(input, hostId) {
|
|
23376
23376
|
return hostId ? { ...input, hostId } : input;
|
|
23377
23377
|
}
|
|
23378
|
+
function closeQuietly(db) {
|
|
23379
|
+
try {
|
|
23380
|
+
db.close();
|
|
23381
|
+
} catch {
|
|
23382
|
+
}
|
|
23383
|
+
}
|
|
23378
23384
|
function openWithPragmas(file2) {
|
|
23379
23385
|
const db = new DatabaseSync(file2);
|
|
23380
|
-
|
|
23381
|
-
|
|
23382
|
-
|
|
23386
|
+
try {
|
|
23387
|
+
db.exec("PRAGMA journal_mode = WAL");
|
|
23388
|
+
db.exec("PRAGMA busy_timeout = 2000");
|
|
23389
|
+
db.exec("PRAGMA foreign_keys = ON");
|
|
23390
|
+
} catch (err) {
|
|
23391
|
+
closeQuietly(db);
|
|
23392
|
+
throw err;
|
|
23393
|
+
}
|
|
23383
23394
|
return db;
|
|
23384
23395
|
}
|
|
23385
23396
|
function backupLegacyStore(file2) {
|
|
@@ -23391,43 +23402,80 @@ function backupLegacyStore(file2) {
|
|
|
23391
23402
|
}
|
|
23392
23403
|
return backup;
|
|
23393
23404
|
}
|
|
23405
|
+
function openAndInitialize(file2) {
|
|
23406
|
+
let db = openWithPragmas(file2);
|
|
23407
|
+
try {
|
|
23408
|
+
if (isForeignSqliteLineage(db)) {
|
|
23409
|
+
db.close();
|
|
23410
|
+
const backup = backupLegacyStore(file2);
|
|
23411
|
+
db = openWithPragmas(file2);
|
|
23412
|
+
akaWarn(
|
|
23413
|
+
`Detected an older, incompatible (tenant-bearing) ${DB_FILENAME}; backed it up to ${backup} and created a fresh store.`
|
|
23414
|
+
);
|
|
23415
|
+
}
|
|
23416
|
+
applyMigrations(db, file2);
|
|
23417
|
+
tightenPerms(file2);
|
|
23418
|
+
const policies = new SqlitePoliciesRepository(db);
|
|
23419
|
+
const installedPacks = new SqliteInstalledPacksRepository(db);
|
|
23420
|
+
const repositories = {
|
|
23421
|
+
events: new SqliteEventsRepository(db),
|
|
23422
|
+
findings: new SqliteFindingsRepository(db),
|
|
23423
|
+
policies,
|
|
23424
|
+
installedPacks,
|
|
23425
|
+
scanLedger: new SqliteScanLedgerRepository(db),
|
|
23426
|
+
exceptions: new SqliteExceptionsRepository(db),
|
|
23427
|
+
resolutions: new SqliteResolutionsRepository(db),
|
|
23428
|
+
ruleProbeCache: new SqliteRuleProbeCacheRepository(db),
|
|
23429
|
+
security: new SqliteSecurityRepository(db),
|
|
23430
|
+
detections: new SqliteDetectionsRepository(db),
|
|
23431
|
+
shares: new SqliteSharesRepository(db),
|
|
23432
|
+
policyCatalog: new SqlitePolicyCatalogRepository(installedPacks),
|
|
23433
|
+
inventory: new SqliteInventoryRepository(db),
|
|
23434
|
+
inventoryAssets: new SqliteInventoryAssetsRepository(db),
|
|
23435
|
+
projectFiles: new SqliteProjectFilesRepository(db),
|
|
23436
|
+
activity: new SqliteActivityRepository(db),
|
|
23437
|
+
sourceProject: new SqliteSourceProjectRepository(db),
|
|
23438
|
+
auditEvents: new SqliteAuditEventsRepository(db),
|
|
23439
|
+
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
23440
|
+
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
23441
|
+
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
23442
|
+
configInventory: new SqliteConfigInventoryRepository(db)
|
|
23443
|
+
};
|
|
23444
|
+
policies.seedDefaults();
|
|
23445
|
+
return { db, ...repositories };
|
|
23446
|
+
} catch (err) {
|
|
23447
|
+
closeQuietly(db);
|
|
23448
|
+
throw err;
|
|
23449
|
+
}
|
|
23450
|
+
}
|
|
23394
23451
|
function openLocalDatabase(dir) {
|
|
23395
23452
|
ensureDataDirSync(dir);
|
|
23396
23453
|
const file2 = join(dir, DB_FILENAME);
|
|
23397
|
-
|
|
23398
|
-
|
|
23399
|
-
|
|
23400
|
-
|
|
23401
|
-
|
|
23402
|
-
|
|
23403
|
-
|
|
23404
|
-
|
|
23405
|
-
|
|
23406
|
-
|
|
23407
|
-
|
|
23408
|
-
|
|
23409
|
-
|
|
23410
|
-
|
|
23411
|
-
|
|
23412
|
-
|
|
23413
|
-
|
|
23414
|
-
|
|
23415
|
-
|
|
23416
|
-
|
|
23417
|
-
|
|
23418
|
-
|
|
23419
|
-
|
|
23420
|
-
|
|
23421
|
-
|
|
23422
|
-
const projectFiles = new SqliteProjectFilesRepository(db);
|
|
23423
|
-
const activity = new SqliteActivityRepository(db);
|
|
23424
|
-
const sourceProject = new SqliteSourceProjectRepository(db);
|
|
23425
|
-
const auditEvents = new SqliteAuditEventsRepository(db);
|
|
23426
|
-
const classifiedData = new SqliteClassifiedDataRepository(db);
|
|
23427
|
-
const inspectionDefinitions = new SqliteInspectionDefinitionsRepository(db);
|
|
23428
|
-
const inspectionFindings = new SqliteInspectionFindingsRepository(db);
|
|
23429
|
-
const configInventory = new SqliteConfigInventoryRepository(db);
|
|
23430
|
-
policies.seedDefaults();
|
|
23454
|
+
const {
|
|
23455
|
+
db,
|
|
23456
|
+
events,
|
|
23457
|
+
findings,
|
|
23458
|
+
policies,
|
|
23459
|
+
installedPacks,
|
|
23460
|
+
scanLedger,
|
|
23461
|
+
exceptions,
|
|
23462
|
+
resolutions,
|
|
23463
|
+
ruleProbeCache,
|
|
23464
|
+
security,
|
|
23465
|
+
detections,
|
|
23466
|
+
shares,
|
|
23467
|
+
policyCatalog,
|
|
23468
|
+
inventory,
|
|
23469
|
+
inventoryAssets,
|
|
23470
|
+
projectFiles,
|
|
23471
|
+
activity,
|
|
23472
|
+
sourceProject,
|
|
23473
|
+
auditEvents,
|
|
23474
|
+
classifiedData,
|
|
23475
|
+
inspectionDefinitions,
|
|
23476
|
+
inspectionFindings,
|
|
23477
|
+
configInventory
|
|
23478
|
+
} = openAndInitialize(file2);
|
|
23431
23479
|
function recordCapture(event, detected) {
|
|
23432
23480
|
failOpenTransaction(db, () => {
|
|
23433
23481
|
const sessionId = event.metadata?.sessionId;
|
|
@@ -23632,8 +23680,9 @@ import { createHash as createHash3 } from "crypto";
|
|
|
23632
23680
|
|
|
23633
23681
|
// ../../packages/persistence/src/fingerprint.ts
|
|
23634
23682
|
import { createHmac, randomBytes } from "crypto";
|
|
23635
|
-
import { readFileSync } from "fs";
|
|
23683
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
23636
23684
|
import { join as join2 } from "path";
|
|
23685
|
+
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
23637
23686
|
var KEY_FILENAME = "exception.key";
|
|
23638
23687
|
var KEY_MATERIAL_BYTES = 32;
|
|
23639
23688
|
function keyFilePath(dataDir2) {
|
|
@@ -23727,13 +23776,13 @@ function readJson(file2) {
|
|
|
23727
23776
|
}
|
|
23728
23777
|
|
|
23729
23778
|
// ../../packages/persistence/src/warn-era-cap.ts
|
|
23730
|
-
import { existsSync as
|
|
23779
|
+
import { existsSync as existsSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
23731
23780
|
import { join as join5 } from "path";
|
|
23732
23781
|
var MARKER = "warn-era-capped";
|
|
23733
23782
|
function capWarnEraEnforcementOnce(db, policyMode, dataDir2) {
|
|
23734
23783
|
if (policyMode !== "warn") return { capped: 0, skipped: "not-warn" };
|
|
23735
23784
|
const marker = join5(dataDir2, MARKER);
|
|
23736
|
-
if (
|
|
23785
|
+
if (existsSync3(marker)) return { capped: 0, skipped: "already-run" };
|
|
23737
23786
|
const capped = db.policies.capCategoryActions();
|
|
23738
23787
|
writeFileSync2(marker, `${new Date(Date.now()).toISOString()}
|
|
23739
23788
|
`, { mode: DATA_FILE_MODE });
|
|
@@ -23803,7 +23852,7 @@ function loadConfig(base = defaultDataDir()) {
|
|
|
23803
23852
|
try {
|
|
23804
23853
|
ensureLayoutDirSync(base);
|
|
23805
23854
|
const settingsFile = join6(settingsDir(base), "settings.json");
|
|
23806
|
-
if (
|
|
23855
|
+
if (existsSync4(settingsFile)) tightenFile(settingsFile);
|
|
23807
23856
|
} catch {
|
|
23808
23857
|
}
|
|
23809
23858
|
migrateLegacyLayout(base);
|
|
@@ -26806,7 +26855,7 @@ function scanText(text, ruleVersions) {
|
|
|
26806
26855
|
}
|
|
26807
26856
|
|
|
26808
26857
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
26809
|
-
import { existsSync as
|
|
26858
|
+
import { existsSync as existsSync5, readFileSync as readFileSync3, statSync } from "fs";
|
|
26810
26859
|
import { basename, dirname, isAbsolute, join as join7, sep as sep2 } from "path";
|
|
26811
26860
|
function resolveRepoIdentity(cwd) {
|
|
26812
26861
|
try {
|
|
@@ -26840,7 +26889,7 @@ function resolveRepoNwo(cwd) {
|
|
|
26840
26889
|
function findGitRoot(start) {
|
|
26841
26890
|
let dir = start;
|
|
26842
26891
|
for (; ; ) {
|
|
26843
|
-
if (
|
|
26892
|
+
if (existsSync5(join7(dir, ".git"))) return dir;
|
|
26844
26893
|
const parent = dirname(dir);
|
|
26845
26894
|
if (parent === dir) return void 0;
|
|
26846
26895
|
dir = parent;
|
|
@@ -26858,7 +26907,7 @@ function resolveGitContext(root) {
|
|
|
26858
26907
|
const target = /^gitdir:\s*(.+?)\s*$/m.exec(safeRead(dotGit) ?? "")?.[1];
|
|
26859
26908
|
if (!target) return void 0;
|
|
26860
26909
|
const gitdir = isAbsolute(target) ? target : join7(root, target);
|
|
26861
|
-
if (
|
|
26910
|
+
if (existsSync5(join7(gitdir, "config"))) {
|
|
26862
26911
|
return { configPath: join7(gitdir, "config"), headRoot: root };
|
|
26863
26912
|
}
|
|
26864
26913
|
const commonRaw = safeRead(join7(gitdir, "commondir"))?.trim();
|
|
@@ -26961,7 +27010,7 @@ import { basename as basename3, dirname as dirname2, sep as sep3 } from "path";
|
|
|
26961
27010
|
|
|
26962
27011
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
26963
27012
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
26964
|
-
import { existsSync as
|
|
27013
|
+
import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync6 } from "fs";
|
|
26965
27014
|
import { basename as basename4, join as join10, relative, sep as sep4 } from "path";
|
|
26966
27015
|
|
|
26967
27016
|
// ../../packages/plugin-sdk/src/runtime.ts
|
package/scripts/remediate.js
CHANGED
|
@@ -23389,11 +23389,22 @@ function purgeSampleData(db) {
|
|
|
23389
23389
|
function linkHost(input, hostId) {
|
|
23390
23390
|
return hostId ? { ...input, hostId } : input;
|
|
23391
23391
|
}
|
|
23392
|
+
function closeQuietly(db) {
|
|
23393
|
+
try {
|
|
23394
|
+
db.close();
|
|
23395
|
+
} catch {
|
|
23396
|
+
}
|
|
23397
|
+
}
|
|
23392
23398
|
function openWithPragmas(file2) {
|
|
23393
23399
|
const db = new DatabaseSync(file2);
|
|
23394
|
-
|
|
23395
|
-
|
|
23396
|
-
|
|
23400
|
+
try {
|
|
23401
|
+
db.exec("PRAGMA journal_mode = WAL");
|
|
23402
|
+
db.exec("PRAGMA busy_timeout = 2000");
|
|
23403
|
+
db.exec("PRAGMA foreign_keys = ON");
|
|
23404
|
+
} catch (err) {
|
|
23405
|
+
closeQuietly(db);
|
|
23406
|
+
throw err;
|
|
23407
|
+
}
|
|
23397
23408
|
return db;
|
|
23398
23409
|
}
|
|
23399
23410
|
function backupLegacyStore(file2) {
|
|
@@ -23405,43 +23416,80 @@ function backupLegacyStore(file2) {
|
|
|
23405
23416
|
}
|
|
23406
23417
|
return backup;
|
|
23407
23418
|
}
|
|
23419
|
+
function openAndInitialize(file2) {
|
|
23420
|
+
let db = openWithPragmas(file2);
|
|
23421
|
+
try {
|
|
23422
|
+
if (isForeignSqliteLineage(db)) {
|
|
23423
|
+
db.close();
|
|
23424
|
+
const backup = backupLegacyStore(file2);
|
|
23425
|
+
db = openWithPragmas(file2);
|
|
23426
|
+
akaWarn(
|
|
23427
|
+
`Detected an older, incompatible (tenant-bearing) ${DB_FILENAME}; backed it up to ${backup} and created a fresh store.`
|
|
23428
|
+
);
|
|
23429
|
+
}
|
|
23430
|
+
applyMigrations(db, file2);
|
|
23431
|
+
tightenPerms(file2);
|
|
23432
|
+
const policies = new SqlitePoliciesRepository(db);
|
|
23433
|
+
const installedPacks = new SqliteInstalledPacksRepository(db);
|
|
23434
|
+
const repositories = {
|
|
23435
|
+
events: new SqliteEventsRepository(db),
|
|
23436
|
+
findings: new SqliteFindingsRepository(db),
|
|
23437
|
+
policies,
|
|
23438
|
+
installedPacks,
|
|
23439
|
+
scanLedger: new SqliteScanLedgerRepository(db),
|
|
23440
|
+
exceptions: new SqliteExceptionsRepository(db),
|
|
23441
|
+
resolutions: new SqliteResolutionsRepository(db),
|
|
23442
|
+
ruleProbeCache: new SqliteRuleProbeCacheRepository(db),
|
|
23443
|
+
security: new SqliteSecurityRepository(db),
|
|
23444
|
+
detections: new SqliteDetectionsRepository(db),
|
|
23445
|
+
shares: new SqliteSharesRepository(db),
|
|
23446
|
+
policyCatalog: new SqlitePolicyCatalogRepository(installedPacks),
|
|
23447
|
+
inventory: new SqliteInventoryRepository(db),
|
|
23448
|
+
inventoryAssets: new SqliteInventoryAssetsRepository(db),
|
|
23449
|
+
projectFiles: new SqliteProjectFilesRepository(db),
|
|
23450
|
+
activity: new SqliteActivityRepository(db),
|
|
23451
|
+
sourceProject: new SqliteSourceProjectRepository(db),
|
|
23452
|
+
auditEvents: new SqliteAuditEventsRepository(db),
|
|
23453
|
+
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
23454
|
+
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
23455
|
+
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
23456
|
+
configInventory: new SqliteConfigInventoryRepository(db)
|
|
23457
|
+
};
|
|
23458
|
+
policies.seedDefaults();
|
|
23459
|
+
return { db, ...repositories };
|
|
23460
|
+
} catch (err) {
|
|
23461
|
+
closeQuietly(db);
|
|
23462
|
+
throw err;
|
|
23463
|
+
}
|
|
23464
|
+
}
|
|
23408
23465
|
function openLocalDatabase(dir) {
|
|
23409
23466
|
ensureDataDirSync(dir);
|
|
23410
23467
|
const file2 = join(dir, DB_FILENAME);
|
|
23411
|
-
|
|
23412
|
-
|
|
23413
|
-
|
|
23414
|
-
|
|
23415
|
-
|
|
23416
|
-
|
|
23417
|
-
|
|
23418
|
-
|
|
23419
|
-
|
|
23420
|
-
|
|
23421
|
-
|
|
23422
|
-
|
|
23423
|
-
|
|
23424
|
-
|
|
23425
|
-
|
|
23426
|
-
|
|
23427
|
-
|
|
23428
|
-
|
|
23429
|
-
|
|
23430
|
-
|
|
23431
|
-
|
|
23432
|
-
|
|
23433
|
-
|
|
23434
|
-
|
|
23435
|
-
|
|
23436
|
-
const projectFiles = new SqliteProjectFilesRepository(db);
|
|
23437
|
-
const activity = new SqliteActivityRepository(db);
|
|
23438
|
-
const sourceProject = new SqliteSourceProjectRepository(db);
|
|
23439
|
-
const auditEvents = new SqliteAuditEventsRepository(db);
|
|
23440
|
-
const classifiedData = new SqliteClassifiedDataRepository(db);
|
|
23441
|
-
const inspectionDefinitions = new SqliteInspectionDefinitionsRepository(db);
|
|
23442
|
-
const inspectionFindings = new SqliteInspectionFindingsRepository(db);
|
|
23443
|
-
const configInventory = new SqliteConfigInventoryRepository(db);
|
|
23444
|
-
policies.seedDefaults();
|
|
23468
|
+
const {
|
|
23469
|
+
db,
|
|
23470
|
+
events,
|
|
23471
|
+
findings,
|
|
23472
|
+
policies,
|
|
23473
|
+
installedPacks,
|
|
23474
|
+
scanLedger,
|
|
23475
|
+
exceptions,
|
|
23476
|
+
resolutions,
|
|
23477
|
+
ruleProbeCache,
|
|
23478
|
+
security,
|
|
23479
|
+
detections,
|
|
23480
|
+
shares,
|
|
23481
|
+
policyCatalog,
|
|
23482
|
+
inventory,
|
|
23483
|
+
inventoryAssets,
|
|
23484
|
+
projectFiles,
|
|
23485
|
+
activity,
|
|
23486
|
+
sourceProject,
|
|
23487
|
+
auditEvents,
|
|
23488
|
+
classifiedData,
|
|
23489
|
+
inspectionDefinitions,
|
|
23490
|
+
inspectionFindings,
|
|
23491
|
+
configInventory
|
|
23492
|
+
} = openAndInitialize(file2);
|
|
23445
23493
|
function recordCapture(event, detected) {
|
|
23446
23494
|
failOpenTransaction(db, () => {
|
|
23447
23495
|
const sessionId = event.metadata?.sessionId;
|
|
@@ -23653,8 +23701,9 @@ function computeFindingKey(input) {
|
|
|
23653
23701
|
|
|
23654
23702
|
// ../../packages/persistence/src/fingerprint.ts
|
|
23655
23703
|
import { createHmac, randomBytes } from "crypto";
|
|
23656
|
-
import { readFileSync } from "fs";
|
|
23704
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
23657
23705
|
import { join as join2 } from "path";
|
|
23706
|
+
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
23658
23707
|
var KEY_FILENAME = "exception.key";
|
|
23659
23708
|
var KEY_MATERIAL_BYTES = 32;
|
|
23660
23709
|
function keyFilePath(dataDir2) {
|
|
@@ -23678,6 +23727,46 @@ function parseKeyFile(raw) {
|
|
|
23678
23727
|
}
|
|
23679
23728
|
return { version: version2, material: bytes };
|
|
23680
23729
|
}
|
|
23730
|
+
var KEY_VERSION_TABLES = ["exceptions", "blocked_detections"];
|
|
23731
|
+
var SQLITE_ERROR = 1;
|
|
23732
|
+
var FLOOR_BUSY_TIMEOUT_MS = 250;
|
|
23733
|
+
var FloorUnreadableError = class extends Error {
|
|
23734
|
+
code = "floor-unreadable";
|
|
23735
|
+
constructor(cause) {
|
|
23736
|
+
super(
|
|
23737
|
+
`cannot read the stored fingerprint key versions: ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
23738
|
+
{ cause }
|
|
23739
|
+
);
|
|
23740
|
+
this.name = "FloorUnreadableError";
|
|
23741
|
+
}
|
|
23742
|
+
};
|
|
23743
|
+
function storedKeyVersionFloor(dataDir2) {
|
|
23744
|
+
const file2 = join2(dataDir2, DB_FILENAME);
|
|
23745
|
+
if (!existsSync2(file2)) return 0;
|
|
23746
|
+
let db;
|
|
23747
|
+
try {
|
|
23748
|
+
db = new DatabaseSync2(file2, { readOnly: true });
|
|
23749
|
+
db.exec(`PRAGMA busy_timeout = ${String(FLOOR_BUSY_TIMEOUT_MS)}`);
|
|
23750
|
+
let floor = 0;
|
|
23751
|
+
for (const table2 of KEY_VERSION_TABLES) {
|
|
23752
|
+
try {
|
|
23753
|
+
const row = getRow(
|
|
23754
|
+
db.prepare(`SELECT MAX(key_version) AS v FROM ${table2}`)
|
|
23755
|
+
);
|
|
23756
|
+
floor = Math.max(floor, row?.v ?? 0);
|
|
23757
|
+
} catch (err) {
|
|
23758
|
+
if (err.errcode !== SQLITE_ERROR) {
|
|
23759
|
+
throw new FloorUnreadableError(err);
|
|
23760
|
+
}
|
|
23761
|
+
}
|
|
23762
|
+
}
|
|
23763
|
+
return floor;
|
|
23764
|
+
} catch (err) {
|
|
23765
|
+
throw err instanceof FloorUnreadableError ? err : new FloorUnreadableError(err);
|
|
23766
|
+
} finally {
|
|
23767
|
+
db?.close();
|
|
23768
|
+
}
|
|
23769
|
+
}
|
|
23681
23770
|
function writeKeyFile(dataDir2, key) {
|
|
23682
23771
|
ensureDataDirSync(dataDir2);
|
|
23683
23772
|
const file2 = keyFilePath(dataDir2);
|
|
@@ -23702,7 +23791,10 @@ function loadOrCreateFingerprintKey(dataDir2) {
|
|
|
23702
23791
|
tightenFile(keyFilePath(dataDir2));
|
|
23703
23792
|
return existing;
|
|
23704
23793
|
}
|
|
23705
|
-
return writeKeyFile(dataDir2, {
|
|
23794
|
+
return writeKeyFile(dataDir2, {
|
|
23795
|
+
version: storedKeyVersionFloor(dataDir2) + 1,
|
|
23796
|
+
material: randomBytes(KEY_MATERIAL_BYTES)
|
|
23797
|
+
});
|
|
23706
23798
|
}
|
|
23707
23799
|
function fingerprintValue(key, raw) {
|
|
23708
23800
|
return createHmac("sha256", key.material).update(raw, "utf8").digest("hex");
|
|
@@ -23767,13 +23859,13 @@ function readJson(file2) {
|
|
|
23767
23859
|
}
|
|
23768
23860
|
|
|
23769
23861
|
// ../../packages/persistence/src/warn-era-cap.ts
|
|
23770
|
-
import { existsSync as
|
|
23862
|
+
import { existsSync as existsSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
23771
23863
|
import { join as join5 } from "path";
|
|
23772
23864
|
var MARKER = "warn-era-capped";
|
|
23773
23865
|
function capWarnEraEnforcementOnce(db, policyMode, dataDir2) {
|
|
23774
23866
|
if (policyMode !== "warn") return { capped: 0, skipped: "not-warn" };
|
|
23775
23867
|
const marker = join5(dataDir2, MARKER);
|
|
23776
|
-
if (
|
|
23868
|
+
if (existsSync3(marker)) return { capped: 0, skipped: "already-run" };
|
|
23777
23869
|
const capped = db.policies.capCategoryActions();
|
|
23778
23870
|
writeFileSync2(marker, `${new Date(Date.now()).toISOString()}
|
|
23779
23871
|
`, { mode: DATA_FILE_MODE });
|
|
@@ -23781,7 +23873,7 @@ function capWarnEraEnforcementOnce(db, policyMode, dataDir2) {
|
|
|
23781
23873
|
}
|
|
23782
23874
|
|
|
23783
23875
|
// ../../packages/plugin-sdk/src/config.ts
|
|
23784
|
-
import { existsSync as
|
|
23876
|
+
import { existsSync as existsSync4 } from "fs";
|
|
23785
23877
|
import { join as join6 } from "path";
|
|
23786
23878
|
|
|
23787
23879
|
// ../../packages/plugin-sdk/src/provider-env.ts
|
|
@@ -23837,7 +23929,7 @@ function loadConfig(base = defaultDataDir()) {
|
|
|
23837
23929
|
try {
|
|
23838
23930
|
ensureLayoutDirSync(base);
|
|
23839
23931
|
const settingsFile = join6(settingsDir(base), "settings.json");
|
|
23840
|
-
if (
|
|
23932
|
+
if (existsSync4(settingsFile)) tightenFile(settingsFile);
|
|
23841
23933
|
} catch {
|
|
23842
23934
|
}
|
|
23843
23935
|
migrateLegacyLayout(base);
|
|
@@ -26880,7 +26972,7 @@ function bundledDetections() {
|
|
|
26880
26972
|
}
|
|
26881
26973
|
|
|
26882
26974
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
26883
|
-
import { existsSync as
|
|
26975
|
+
import { existsSync as existsSync5, readFileSync as readFileSync3, statSync } from "fs";
|
|
26884
26976
|
import { basename, dirname, isAbsolute, join as join7, sep as sep2 } from "path";
|
|
26885
26977
|
function resolveRepo(cwd) {
|
|
26886
26978
|
try {
|
|
@@ -26903,7 +26995,7 @@ function resolveWorktreeRoot(cwd) {
|
|
|
26903
26995
|
function findGitRoot(start) {
|
|
26904
26996
|
let dir = start;
|
|
26905
26997
|
for (; ; ) {
|
|
26906
|
-
if (
|
|
26998
|
+
if (existsSync5(join7(dir, ".git"))) return dir;
|
|
26907
26999
|
const parent = dirname(dir);
|
|
26908
27000
|
if (parent === dir) return void 0;
|
|
26909
27001
|
dir = parent;
|
|
@@ -26921,7 +27013,7 @@ function resolveGitContext(root) {
|
|
|
26921
27013
|
const target = /^gitdir:\s*(.+?)\s*$/m.exec(safeRead(dotGit) ?? "")?.[1];
|
|
26922
27014
|
if (!target) return void 0;
|
|
26923
27015
|
const gitdir = isAbsolute(target) ? target : join7(root, target);
|
|
26924
|
-
if (
|
|
27016
|
+
if (existsSync5(join7(gitdir, "config"))) {
|
|
26925
27017
|
return { configPath: join7(gitdir, "config"), headRoot: root };
|
|
26926
27018
|
}
|
|
26927
27019
|
const commonRaw = safeRead(join7(gitdir, "commondir"))?.trim();
|
|
@@ -27015,7 +27107,7 @@ function applyCategoryPosture(posture, repo, mode = "fill-gaps") {
|
|
|
27015
27107
|
|
|
27016
27108
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
27017
27109
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
27018
|
-
import { existsSync as
|
|
27110
|
+
import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync6 } from "fs";
|
|
27019
27111
|
import { basename as basename4, join as join10, relative, sep as sep4 } from "path";
|
|
27020
27112
|
|
|
27021
27113
|
// ../../packages/plugin-sdk/src/raw-egress.ts
|