@triedotdev/mcp 1.0.149 → 1.0.154

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.
Files changed (125) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -36
  3. package/dist/{autonomy-config-ZCOSTMPD.js → autonomy-config-RKLZW4XL.js} +4 -4
  4. package/dist/{chat-store-OJLJCJFI.js → chat-store-O3IJ5PMN.js} +4 -4
  5. package/dist/{chunk-IXO4G4D3.js → chunk-2LAJKFWU.js} +2 -2
  6. package/dist/{chunk-23RJT5WT.js → chunk-3CYMLM35.js} +2 -2
  7. package/dist/{chunk-QH77RQB3.js → chunk-4ZAFQEP6.js} +5 -6
  8. package/dist/chunk-4ZAFQEP6.js.map +1 -0
  9. package/dist/{chunk-SH7H3WRU.js → chunk-7F2R2ITA.js} +4 -4
  10. package/dist/{chunk-SH7H3WRU.js.map → chunk-7F2R2ITA.js.map} +1 -1
  11. package/dist/{chunk-FG467PDD.js → chunk-ALSCZ7WR.js} +2 -2
  12. package/dist/{chunk-YOJGSRZK.js → chunk-CBAMZERA.js} +2 -2
  13. package/dist/{chunk-53KUI7RQ.js → chunk-EMJ7RVWB.js} +38 -13
  14. package/dist/{chunk-53KUI7RQ.js.map → chunk-EMJ7RVWB.js.map} +1 -1
  15. package/dist/{chunk-NKHO34UZ.js → chunk-FTOF3FHT.js} +3 -3
  16. package/dist/{chunk-LD7ZEFNY.js → chunk-FXZAABXO.js} +2 -2
  17. package/dist/{chunk-ZUEAHFSY.js → chunk-HD5H7YSW.js} +313 -61
  18. package/dist/chunk-HD5H7YSW.js.map +1 -0
  19. package/dist/{chunk-APMV77PU.js → chunk-JKEEQAG2.js} +1 -1
  20. package/dist/chunk-JKEEQAG2.js.map +1 -0
  21. package/dist/{chunk-FH335WL5.js → chunk-JYWGYUKX.js} +2 -2
  22. package/dist/{chunk-TIMIKBY2.js → chunk-KLMJKM63.js} +2 -2
  23. package/dist/{chunk-4C67GV3O.js → chunk-KYKADM7P.js} +2 -2
  24. package/dist/{chunk-CU5VDH6F.js → chunk-L4FODDDB.js} +2 -2
  25. package/dist/{chunk-ILGMFND2.js → chunk-LFNH3CSN.js} +4 -4
  26. package/dist/{chunk-GAL7OIYU.js → chunk-LJISDV3A.js} +15 -15
  27. package/dist/{chunk-72KSLD7A.js → chunk-NVZZUUEU.js} +5 -5
  28. package/dist/{chunk-7OJ6JIPL.js → chunk-OVSYTWUU.js} +7 -150
  29. package/dist/chunk-OVSYTWUU.js.map +1 -0
  30. package/dist/{chunk-B2AHQ2IR.js → chunk-OWSGJUUR.js} +12 -12
  31. package/dist/{chunk-HYNDXZAU.js → chunk-QAM5X5HM.js} +1535 -90
  32. package/dist/chunk-QAM5X5HM.js.map +1 -0
  33. package/dist/{chunk-OTQEFXHU.js → chunk-T7UAH7GE.js} +2 -2
  34. package/dist/{chunk-FPEMP54L.js → chunk-UL337UDQ.js} +2 -2
  35. package/dist/{chunk-F4NJ4CBP.js → chunk-WO7CC5FH.js} +2 -2
  36. package/dist/{chunk-5KJ4UJOY.js → chunk-XD2HKZVB.js} +2 -2
  37. package/dist/{chunk-V7AY2EJO.js → chunk-YEQXKKZQ.js} +2 -2
  38. package/dist/{chunk-ZDDE442Q.js → chunk-Z2E7X4WI.js} +8 -8
  39. package/dist/{chunk-ZDDE442Q.js.map → chunk-Z2E7X4WI.js.map} +1 -1
  40. package/dist/cli/create-agent.js +9 -41
  41. package/dist/cli/create-agent.js.map +1 -1
  42. package/dist/cli/main.js +58 -96
  43. package/dist/cli/main.js.map +1 -1
  44. package/dist/cli/yolo-daemon.js +65 -28
  45. package/dist/cli/yolo-daemon.js.map +1 -1
  46. package/dist/{client-INNE2GGZ.js → client-ZHOLZTRW.js} +4 -4
  47. package/dist/{codebase-index-FMIULFZQ.js → codebase-index-N37NDF2A.js} +4 -4
  48. package/dist/{fast-analyzer-CTT3MCPE.js → fast-analyzer-U6URGNQT.js} +6 -6
  49. package/dist/github-ingester-AR5A4RAC.js +11 -0
  50. package/dist/{goal-manager-IGUMDGCA.js → goal-manager-5QDITJKE.js} +8 -8
  51. package/dist/{goal-validator-DV6DRSGF.js → goal-validator-FU5QWDQT.js} +7 -7
  52. package/dist/graph-JO7GG65P.js +10 -0
  53. package/dist/{hypothesis-O72ZLVOW.js → hypothesis-JURDWVDC.js} +8 -8
  54. package/dist/incident-index-7CAXUNTL.js +11 -0
  55. package/dist/index.js +136 -1740
  56. package/dist/index.js.map +1 -1
  57. package/dist/{insight-store-Q62UGMTF.js → insight-store-AMEP5PPF.js} +4 -4
  58. package/dist/{issue-store-4FPABLC6.js → issue-store-RM3XLLKG.js} +5 -5
  59. package/dist/{ledger-43SIVE7X.js → ledger-PLE3C3X4.js} +14 -6
  60. package/dist/linear-ingester-NHFMKJBZ.js +11 -0
  61. package/dist/{output-manager-DZO5LGSG.js → output-manager-FX4V7ERT.js} +3 -3
  62. package/dist/{progress-PQVEM7BR.js → progress-PAYTY7BF.js} +2 -2
  63. package/dist/tiered-storage-3TUUR3L2.js +12 -0
  64. package/dist/trie-agent-QHPS4C5Z.js +27 -0
  65. package/dist/{vibe-code-signatures-ELEWJFGZ.js → vibe-code-signatures-J4GD4JOV.js} +3 -3
  66. package/dist/{vulnerability-signatures-EIJQX2TS.js → vulnerability-signatures-EIKOHFPK.js} +3 -3
  67. package/package.json +4 -6
  68. package/dist/chunk-7OJ6JIPL.js.map +0 -1
  69. package/dist/chunk-APMV77PU.js.map +0 -1
  70. package/dist/chunk-G76DYVGX.js +0 -136
  71. package/dist/chunk-G76DYVGX.js.map +0 -1
  72. package/dist/chunk-HYNDXZAU.js.map +0 -1
  73. package/dist/chunk-QH77RQB3.js.map +0 -1
  74. package/dist/chunk-ZUEAHFSY.js.map +0 -1
  75. package/dist/comprehension-46F7ZNKL.js +0 -821
  76. package/dist/comprehension-46F7ZNKL.js.map +0 -1
  77. package/dist/github-ingester-J2ZFYXVE.js +0 -11
  78. package/dist/graph-J4OGTYCO.js +0 -10
  79. package/dist/incident-index-BWW2UEY7.js +0 -11
  80. package/dist/linear-ingester-JRDQAIAA.js +0 -11
  81. package/dist/tiered-storage-VZL7KK64.js +0 -12
  82. package/dist/trie-agent-ET3DAP5Y.js +0 -27
  83. package/dist/workers/agent-worker.d.ts +0 -2
  84. package/dist/workers/agent-worker.js +0 -28
  85. package/dist/workers/agent-worker.js.map +0 -1
  86. /package/dist/{autonomy-config-ZCOSTMPD.js.map → autonomy-config-RKLZW4XL.js.map} +0 -0
  87. /package/dist/{chat-store-OJLJCJFI.js.map → chat-store-O3IJ5PMN.js.map} +0 -0
  88. /package/dist/{chunk-IXO4G4D3.js.map → chunk-2LAJKFWU.js.map} +0 -0
  89. /package/dist/{chunk-23RJT5WT.js.map → chunk-3CYMLM35.js.map} +0 -0
  90. /package/dist/{chunk-FG467PDD.js.map → chunk-ALSCZ7WR.js.map} +0 -0
  91. /package/dist/{chunk-YOJGSRZK.js.map → chunk-CBAMZERA.js.map} +0 -0
  92. /package/dist/{chunk-NKHO34UZ.js.map → chunk-FTOF3FHT.js.map} +0 -0
  93. /package/dist/{chunk-LD7ZEFNY.js.map → chunk-FXZAABXO.js.map} +0 -0
  94. /package/dist/{chunk-FH335WL5.js.map → chunk-JYWGYUKX.js.map} +0 -0
  95. /package/dist/{chunk-TIMIKBY2.js.map → chunk-KLMJKM63.js.map} +0 -0
  96. /package/dist/{chunk-4C67GV3O.js.map → chunk-KYKADM7P.js.map} +0 -0
  97. /package/dist/{chunk-CU5VDH6F.js.map → chunk-L4FODDDB.js.map} +0 -0
  98. /package/dist/{chunk-ILGMFND2.js.map → chunk-LFNH3CSN.js.map} +0 -0
  99. /package/dist/{chunk-GAL7OIYU.js.map → chunk-LJISDV3A.js.map} +0 -0
  100. /package/dist/{chunk-72KSLD7A.js.map → chunk-NVZZUUEU.js.map} +0 -0
  101. /package/dist/{chunk-B2AHQ2IR.js.map → chunk-OWSGJUUR.js.map} +0 -0
  102. /package/dist/{chunk-OTQEFXHU.js.map → chunk-T7UAH7GE.js.map} +0 -0
  103. /package/dist/{chunk-FPEMP54L.js.map → chunk-UL337UDQ.js.map} +0 -0
  104. /package/dist/{chunk-F4NJ4CBP.js.map → chunk-WO7CC5FH.js.map} +0 -0
  105. /package/dist/{chunk-5KJ4UJOY.js.map → chunk-XD2HKZVB.js.map} +0 -0
  106. /package/dist/{chunk-V7AY2EJO.js.map → chunk-YEQXKKZQ.js.map} +0 -0
  107. /package/dist/{client-INNE2GGZ.js.map → client-ZHOLZTRW.js.map} +0 -0
  108. /package/dist/{codebase-index-FMIULFZQ.js.map → codebase-index-N37NDF2A.js.map} +0 -0
  109. /package/dist/{fast-analyzer-CTT3MCPE.js.map → fast-analyzer-U6URGNQT.js.map} +0 -0
  110. /package/dist/{github-ingester-J2ZFYXVE.js.map → github-ingester-AR5A4RAC.js.map} +0 -0
  111. /package/dist/{goal-manager-IGUMDGCA.js.map → goal-manager-5QDITJKE.js.map} +0 -0
  112. /package/dist/{goal-validator-DV6DRSGF.js.map → goal-validator-FU5QWDQT.js.map} +0 -0
  113. /package/dist/{graph-J4OGTYCO.js.map → graph-JO7GG65P.js.map} +0 -0
  114. /package/dist/{hypothesis-O72ZLVOW.js.map → hypothesis-JURDWVDC.js.map} +0 -0
  115. /package/dist/{incident-index-BWW2UEY7.js.map → incident-index-7CAXUNTL.js.map} +0 -0
  116. /package/dist/{insight-store-Q62UGMTF.js.map → insight-store-AMEP5PPF.js.map} +0 -0
  117. /package/dist/{issue-store-4FPABLC6.js.map → issue-store-RM3XLLKG.js.map} +0 -0
  118. /package/dist/{ledger-43SIVE7X.js.map → ledger-PLE3C3X4.js.map} +0 -0
  119. /package/dist/{linear-ingester-JRDQAIAA.js.map → linear-ingester-NHFMKJBZ.js.map} +0 -0
  120. /package/dist/{output-manager-DZO5LGSG.js.map → output-manager-FX4V7ERT.js.map} +0 -0
  121. /package/dist/{progress-PQVEM7BR.js.map → progress-PAYTY7BF.js.map} +0 -0
  122. /package/dist/{tiered-storage-VZL7KK64.js.map → tiered-storage-3TUUR3L2.js.map} +0 -0
  123. /package/dist/{trie-agent-ET3DAP5Y.js.map → trie-agent-QHPS4C5Z.js.map} +0 -0
  124. /package/dist/{vibe-code-signatures-ELEWJFGZ.js.map → vibe-code-signatures-J4GD4JOV.js.map} +0 -0
  125. /package/dist/{vulnerability-signatures-EIJQX2TS.js.map → vulnerability-signatures-EIKOHFPK.js.map} +0 -0
@@ -4,16 +4,16 @@ import {
4
4
  import {
5
5
  getTrieDirectory,
6
6
  getWorkingDirectory
7
- } from "./chunk-SH7H3WRU.js";
7
+ } from "./chunk-7F2R2ITA.js";
8
8
 
9
9
  // src/memory/ledger.ts
10
10
  import { createHash } from "crypto";
11
11
  import { mkdir, readFile, writeFile, stat, unlink } from "fs/promises";
12
- import { existsSync as existsSync2 } from "fs";
12
+ import { existsSync as existsSync4 } from "fs";
13
13
  import { createGzip, createGunzip } from "zlib";
14
14
  import { pipeline } from "stream/promises";
15
15
  import { createReadStream, createWriteStream } from "fs";
16
- import { join } from "path";
16
+ import { join as join3 } from "path";
17
17
 
18
18
  // src/agent/git.ts
19
19
  import { existsSync } from "fs";
@@ -23,7 +23,7 @@ import path from "path";
23
23
  import { exec, execFile, execSync } from "child_process";
24
24
  import { promisify } from "util";
25
25
 
26
- // src/skills/audit-logger.ts
26
+ // src/utils/audit-logger.ts
27
27
  function formatAuditLog(_entry) {
28
28
  return "Audit logging has been integrated into the decision ledger";
29
29
  }
@@ -71,9 +71,6 @@ async function logSkillExecution(_execution) {
71
71
  async function getRecentAuditLogs(_limit = 10) {
72
72
  return [];
73
73
  }
74
- async function getSkillAuditLogs(_skillName) {
75
- return [];
76
- }
77
74
 
78
75
  // src/utils/command-runner.ts
79
76
  var execAsync = promisify(exec);
@@ -319,6 +316,176 @@ async function getChangedFilesSinceTimestamp(projectPath, timestamp) {
319
316
  }
320
317
  }
321
318
 
319
+ // src/memory/crypto-keys.ts
320
+ import * as ed25519 from "@noble/ed25519";
321
+ import { randomBytes } from "crypto";
322
+ import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "fs";
323
+ import { join } from "path";
324
+ function getKeysDirectory(workDir) {
325
+ const trieDir = getTrieDirectory(workDir || process.cwd());
326
+ return join(trieDir, "keys");
327
+ }
328
+ function getDefaultKeyPath(workDir) {
329
+ return join(getKeysDirectory(workDir), "signing-key.json");
330
+ }
331
+ async function generateKeyPair() {
332
+ const privateKeyBytes = randomBytes(32);
333
+ const publicKeyBytes = await ed25519.getPublicKeyAsync(privateKeyBytes);
334
+ return {
335
+ publicKey: Buffer.from(publicKeyBytes).toString("hex"),
336
+ privateKey: Buffer.from(privateKeyBytes).toString("hex")
337
+ };
338
+ }
339
+ function saveKeyPair(keyPair, workDir) {
340
+ const keysDir = getKeysDirectory(workDir);
341
+ if (!existsSync2(keysDir)) {
342
+ mkdirSync(keysDir, { recursive: true });
343
+ }
344
+ const keyPath = getDefaultKeyPath(workDir);
345
+ const keyData = {
346
+ ...keyPair,
347
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
348
+ version: 1
349
+ };
350
+ writeFileSync(keyPath, JSON.stringify(keyData, null, 2), "utf-8");
351
+ console.error("\u26A0\uFE0F Signing key created at:", keyPath);
352
+ console.error(" Keep this file secure and add to .gitignore");
353
+ }
354
+ function loadKeyPair(workDir) {
355
+ const keyPath = getDefaultKeyPath(workDir);
356
+ if (!existsSync2(keyPath)) {
357
+ return null;
358
+ }
359
+ try {
360
+ const keyData = JSON.parse(readFileSync(keyPath, "utf-8"));
361
+ return {
362
+ publicKey: keyData.publicKey,
363
+ privateKey: keyData.privateKey
364
+ };
365
+ } catch (error) {
366
+ console.error("Failed to load signing key:", error);
367
+ return null;
368
+ }
369
+ }
370
+ async function getOrCreateKeyPair(workDir) {
371
+ const existing = loadKeyPair(workDir);
372
+ if (existing) {
373
+ return existing;
374
+ }
375
+ const newKeyPair = await generateKeyPair();
376
+ saveKeyPair(newKeyPair, workDir);
377
+ return newKeyPair;
378
+ }
379
+ async function signData(data, privateKey) {
380
+ const dataBytes = Buffer.from(data, "utf-8");
381
+ const privateKeyBytes = Buffer.from(privateKey, "hex");
382
+ const signatureBytes = await ed25519.signAsync(dataBytes, privateKeyBytes);
383
+ return Buffer.from(signatureBytes).toString("hex");
384
+ }
385
+ async function verifySignature(data, signature, publicKey) {
386
+ try {
387
+ const dataBytes = Buffer.from(data, "utf-8");
388
+ const signatureBytes = Buffer.from(signature, "hex");
389
+ const publicKeyBytes = Buffer.from(publicKey, "hex");
390
+ return await ed25519.verifyAsync(signatureBytes, dataBytes, publicKeyBytes);
391
+ } catch (error) {
392
+ console.error("Signature verification failed:", error);
393
+ return false;
394
+ }
395
+ }
396
+ async function signHash(hash, workDir) {
397
+ const keyPair = await getOrCreateKeyPair(workDir);
398
+ const signature = await signData(hash, keyPair.privateKey);
399
+ return {
400
+ signature,
401
+ publicKey: keyPair.publicKey,
402
+ algorithm: "Ed25519",
403
+ signedAt: (/* @__PURE__ */ new Date()).toISOString()
404
+ };
405
+ }
406
+ async function verifyHashSignature(hash, signatureData) {
407
+ if (signatureData.algorithm !== "Ed25519") {
408
+ console.error("Unsupported signature algorithm:", signatureData.algorithm);
409
+ return false;
410
+ }
411
+ return await verifySignature(hash, signatureData.signature, signatureData.publicKey);
412
+ }
413
+ function hasSigningKey(workDir) {
414
+ const keyPath = getDefaultKeyPath(workDir);
415
+ return existsSync2(keyPath);
416
+ }
417
+
418
+ // src/memory/git-integration.ts
419
+ import { exec as exec2 } from "child_process";
420
+ import { promisify as promisify2 } from "util";
421
+ import { existsSync as existsSync3 } from "fs";
422
+ import { join as join2 } from "path";
423
+ var execAsync2 = promisify2(exec2);
424
+ async function isGitIntegrationEnabled(workDir) {
425
+ try {
426
+ const gitDir = join2(workDir, ".git");
427
+ if (!existsSync3(gitDir)) {
428
+ return false;
429
+ }
430
+ const configPath = join2(getTrieDirectory(workDir), "config.json");
431
+ if (!existsSync3(configPath)) {
432
+ return true;
433
+ }
434
+ const config = JSON.parse(await import("fs/promises").then((fs) => fs.readFile(configPath, "utf-8")));
435
+ return config.gitIntegration !== false;
436
+ } catch {
437
+ return false;
438
+ }
439
+ }
440
+ async function autoCommitLedger(workDir, message) {
441
+ try {
442
+ const enabled = await isGitIntegrationEnabled(workDir);
443
+ if (!enabled) {
444
+ return { committed: false, error: "Git integration disabled" };
445
+ }
446
+ const ledgerPath = join2(getTrieDirectory(workDir), "memory", "ledger.json");
447
+ const { stdout: statusOutput } = await execAsync2("git status --porcelain", { cwd: workDir });
448
+ const hasLedgerChanges = statusOutput.includes("ledger.json");
449
+ if (!hasLedgerChanges) {
450
+ return { committed: false, error: "No ledger changes to commit" };
451
+ }
452
+ await execAsync2(`git add ${ledgerPath}`, { cwd: workDir });
453
+ const commitMessage = message || "ledger: append entries";
454
+ await execAsync2(
455
+ `git commit -m "${commitMessage}"`,
456
+ { cwd: workDir }
457
+ );
458
+ const { stdout: hashOutput } = await execAsync2("git rev-parse HEAD", { cwd: workDir });
459
+ const commitHash = hashOutput.trim();
460
+ return {
461
+ committed: true,
462
+ commitHash
463
+ };
464
+ } catch (error) {
465
+ return {
466
+ committed: false,
467
+ error: error instanceof Error ? error.message : String(error)
468
+ };
469
+ }
470
+ }
471
+ async function ensureKeysIgnored(workDir) {
472
+ try {
473
+ const gitignorePath = join2(workDir, ".gitignore");
474
+ const fs = await import("fs/promises");
475
+ let gitignore = "";
476
+ if (existsSync3(gitignorePath)) {
477
+ gitignore = await fs.readFile(gitignorePath, "utf-8");
478
+ }
479
+ if (gitignore.includes(".trie/keys/")) {
480
+ return;
481
+ }
482
+ const addition = "\n# Trie signing keys (keep secure, do not commit)\n.trie/keys/\n";
483
+ await fs.appendFile(gitignorePath, addition, "utf-8");
484
+ } catch (error) {
485
+ console.error("Failed to update .gitignore:", error);
486
+ }
487
+ }
488
+
322
489
  // src/memory/ledger.ts
323
490
  var LEDGER_FILENAME = "ledger.json";
324
491
  var SHARED_LEDGER_DIR = ".trie-shared";
@@ -326,10 +493,54 @@ var MANIFEST_FILENAME = "ledger-manifest.json";
326
493
  var SYNC_STATE_FILENAME = "ledger-sync.json";
327
494
  var GENESIS_HASH = "0".repeat(64);
328
495
  var LEDGER_VERSION = 2;
496
+ async function signLedgerEntry(entry, workDir) {
497
+ try {
498
+ const signatureData = await signHash(entry.hash, workDir);
499
+ return {
500
+ ...entry,
501
+ signature: signatureData.signature,
502
+ publicKey: signatureData.publicKey,
503
+ signedAt: signatureData.signedAt,
504
+ signatureAlgorithm: "Ed25519"
505
+ };
506
+ } catch (error) {
507
+ console.error("Failed to sign ledger entry:", error);
508
+ return entry;
509
+ }
510
+ }
511
+ async function verifyLedgerEntry(entry) {
512
+ if (!entry.signature || !entry.publicKey) {
513
+ return true;
514
+ }
515
+ if (entry.signatureAlgorithm !== "Ed25519") {
516
+ console.error("Unsupported signature algorithm:", entry.signatureAlgorithm);
517
+ return false;
518
+ }
519
+ const signatureData = {
520
+ signature: entry.signature,
521
+ publicKey: entry.publicKey,
522
+ algorithm: "Ed25519",
523
+ signedAt: entry.signedAt || ""
524
+ };
525
+ return await verifyHashSignature(entry.hash, signatureData);
526
+ }
527
+ async function verifyBlockSignatures(block) {
528
+ const invalidEntries = [];
529
+ for (const entry of block.entries) {
530
+ const isValid = await verifyLedgerEntry(entry);
531
+ if (!isValid) {
532
+ invalidEntries.push(entry.id);
533
+ }
534
+ }
535
+ return {
536
+ valid: invalidEntries.length === 0,
537
+ invalidEntries
538
+ };
539
+ }
329
540
  async function appendIssuesToLedger(issues, workDir, author) {
330
541
  if (issues.length === 0) return null;
331
542
  const projectDir = workDir || getWorkingDirectory(void 0, true);
332
- const memoryDir = join(getTrieDirectory(projectDir), "memory");
543
+ const memoryDir = join3(getTrieDirectory(projectDir), "memory");
333
544
  await mkdir(memoryDir, { recursive: true });
334
545
  const isRepo = await isGitRepo(projectDir);
335
546
  const lastCommit = isRepo ? await getLastCommit(projectDir) : null;
@@ -337,7 +548,8 @@ async function appendIssuesToLedger(issues, workDir, author) {
337
548
  const blocks = await loadLedger(projectDir);
338
549
  const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
339
550
  const now = (/* @__PURE__ */ new Date()).toISOString();
340
- const entries = issues.map((issue) => ({
551
+ const shouldSign = hasSigningKey(projectDir);
552
+ let entries = issues.map((issue) => ({
341
553
  id: issue.id,
342
554
  hash: issue.hash,
343
555
  severity: issue.severity,
@@ -346,6 +558,9 @@ async function appendIssuesToLedger(issues, workDir, author) {
346
558
  timestamp: issue.timestamp,
347
559
  status: "active"
348
560
  }));
561
+ if (shouldSign) {
562
+ entries = await Promise.all(entries.map((entry) => signLedgerEntry(entry, projectDir)));
563
+ }
349
564
  const previousBlock = blocks[blocks.length - 1];
350
565
  const block = previousBlock && previousBlock.date === today ? previousBlock : createSyncableBlock(today, now, previousBlock?.blockHash ?? GENESIS_HASH, blockAuthor, lastCommit?.hash, blocks.length);
351
566
  if (block !== previousBlock) {
@@ -356,6 +571,11 @@ async function appendIssuesToLedger(issues, workDir, author) {
356
571
  block.blockHash = computeBlockHash(block.previousHash, block.merkleRoot, block.date, block.version);
357
572
  block.updatedAt = now;
358
573
  await saveLedger(blocks, projectDir);
574
+ if (await isGitRepo(projectDir)) {
575
+ await ensureKeysIgnored(projectDir);
576
+ const commitMessage = `ledger: append ${entries.length} ${entries.length === 1 ? "entry" : "entries"}`;
577
+ await autoCommitLedger(projectDir, commitMessage);
578
+ }
359
579
  return block;
360
580
  }
361
581
  async function verifyLedger(workDir) {
@@ -382,7 +602,14 @@ async function verifyLedger(workDir) {
382
602
  }
383
603
  const computedBlockHash = computeBlockHash(block.previousHash, block.merkleRoot, block.date, block.version);
384
604
  if (block.blockHash !== computedBlockHash) {
385
- return { valid: false, error: `Block ${i} hash mismatch` };
605
+ return { valid: false, error: `Block ${i} block hash mismatch` };
606
+ }
607
+ const signatureVerification = await verifyBlockSignatures(block);
608
+ if (!signatureVerification.valid) {
609
+ return {
610
+ valid: false,
611
+ error: `Block ${i} has invalid signatures: ${signatureVerification.invalidEntries.join(", ")}`
612
+ };
386
613
  }
387
614
  }
388
615
  return { valid: true };
@@ -417,14 +644,14 @@ function createSyncableBlock(date, now, previousHash, author, gitCommit, chainHe
417
644
  createdAt: now,
418
645
  updatedAt: now,
419
646
  author,
420
- gitCommit,
421
- chainHeight
647
+ chainHeight,
648
+ ...gitCommit && { gitCommit }
422
649
  };
423
650
  }
424
651
  async function loadLedger(projectDir) {
425
- const ledgerPath = join(getTrieDirectory(projectDir), "memory", LEDGER_FILENAME);
652
+ const ledgerPath = join3(getTrieDirectory(projectDir), "memory", LEDGER_FILENAME);
426
653
  try {
427
- if (!existsSync2(ledgerPath)) return [];
654
+ if (!existsSync4(ledgerPath)) return [];
428
655
  const content = await readFile(ledgerPath, "utf-8");
429
656
  const parsed = JSON.parse(content);
430
657
  if (!Array.isArray(parsed)) return [];
@@ -438,26 +665,26 @@ async function getLedgerBlocks(workDir) {
438
665
  return loadLedger(projectDir);
439
666
  }
440
667
  async function saveLedger(blocks, projectDir) {
441
- const ledgerPath = join(getTrieDirectory(projectDir), "memory", LEDGER_FILENAME);
668
+ const ledgerPath = join3(getTrieDirectory(projectDir), "memory", LEDGER_FILENAME);
442
669
  await atomicWriteJSON(ledgerPath, blocks);
443
670
  }
444
671
  function sha256(input) {
445
672
  return createHash("sha256").update(input).digest("hex");
446
673
  }
447
674
  function getSharedLedgerDir(projectDir) {
448
- return join(projectDir, SHARED_LEDGER_DIR);
675
+ return join3(projectDir, SHARED_LEDGER_DIR);
449
676
  }
450
677
  function getActiveBlocksDir(projectDir) {
451
- return join(getSharedLedgerDir(projectDir), "active");
678
+ return join3(getSharedLedgerDir(projectDir), "active");
452
679
  }
453
680
  function getArchivedBlocksDir(projectDir) {
454
- return join(getSharedLedgerDir(projectDir), "archived");
681
+ return join3(getSharedLedgerDir(projectDir), "archived");
455
682
  }
456
683
  function getManifestPath(projectDir) {
457
- return join(getSharedLedgerDir(projectDir), MANIFEST_FILENAME);
684
+ return join3(getSharedLedgerDir(projectDir), MANIFEST_FILENAME);
458
685
  }
459
686
  function getSyncStatePath(projectDir) {
460
- return join(getTrieDirectory(projectDir), "memory", SYNC_STATE_FILENAME);
687
+ return join3(getTrieDirectory(projectDir), "memory", SYNC_STATE_FILENAME);
461
688
  }
462
689
  async function ensureSharedStorageStructure(projectDir) {
463
690
  const sharedDir = getSharedLedgerDir(projectDir);
@@ -470,7 +697,7 @@ async function ensureSharedStorageStructure(projectDir) {
470
697
  async function loadManifest(projectDir) {
471
698
  const manifestPath = getManifestPath(projectDir);
472
699
  try {
473
- if (!existsSync2(manifestPath)) return null;
700
+ if (!existsSync4(manifestPath)) return null;
474
701
  const content = await readFile(manifestPath, "utf-8");
475
702
  return JSON.parse(content);
476
703
  } catch {
@@ -481,7 +708,7 @@ async function saveManifest(manifest, projectDir) {
481
708
  const manifestPath = getManifestPath(projectDir);
482
709
  await atomicWriteJSON(manifestPath, manifest);
483
710
  }
484
- async function createDefaultManifest(projectDir) {
711
+ async function createDefaultManifest(_projectDir) {
485
712
  const now = (/* @__PURE__ */ new Date()).toISOString();
486
713
  return {
487
714
  version: LEDGER_VERSION,
@@ -508,7 +735,7 @@ async function createDefaultManifest(projectDir) {
508
735
  async function loadSyncState(projectDir) {
509
736
  const syncStatePath = getSyncStatePath(projectDir);
510
737
  try {
511
- if (!existsSync2(syncStatePath)) return null;
738
+ if (!existsSync4(syncStatePath)) return null;
512
739
  const content = await readFile(syncStatePath, "utf-8");
513
740
  return JSON.parse(content);
514
741
  } catch {
@@ -517,7 +744,7 @@ async function loadSyncState(projectDir) {
517
744
  }
518
745
  async function saveSyncState(syncState, projectDir) {
519
746
  const syncStatePath = getSyncStatePath(projectDir);
520
- const memoryDir = join(getTrieDirectory(projectDir), "memory");
747
+ const memoryDir = join3(getTrieDirectory(projectDir), "memory");
521
748
  await mkdir(memoryDir, { recursive: true });
522
749
  await atomicWriteJSON(syncStatePath, syncState);
523
750
  }
@@ -569,16 +796,17 @@ async function pushLedgerToShared(workDir) {
569
796
  const activeDir = getActiveBlocksDir(projectDir);
570
797
  for (const block of localBlocks) {
571
798
  const blockFilename = `${block.date}.json`;
572
- const blockPath = join(activeDir, blockFilename);
573
- if (!existsSync2(blockPath) || block.updatedAt > manifest.lastSync) {
799
+ const blockPath = join3(activeDir, blockFilename);
800
+ if (!existsSync4(blockPath) || block.updatedAt > manifest.lastSync) {
574
801
  await atomicWriteJSON(blockPath, block);
575
802
  manifest.index.byDate[block.date] = `active/${blockFilename}`;
576
- if (block.author) {
577
- if (!manifest.index.byAuthor[block.author]) {
578
- manifest.index.byAuthor[block.author] = [];
803
+ const blockAuthor = block.author;
804
+ if (blockAuthor) {
805
+ if (!manifest.index.byAuthor[blockAuthor]) {
806
+ manifest.index.byAuthor[blockAuthor] = [];
579
807
  }
580
- if (!manifest.index.byAuthor[block.author].includes(`active/${blockFilename}`)) {
581
- manifest.index.byAuthor[block.author].push(`active/${blockFilename}`);
808
+ if (!manifest.index.byAuthor[blockAuthor].includes(`active/${blockFilename}`)) {
809
+ manifest.index.byAuthor[blockAuthor].push(`active/${blockFilename}`);
582
810
  }
583
811
  }
584
812
  if (!manifest.activeBlocks.includes(blockFilename)) {
@@ -597,9 +825,9 @@ async function loadSharedBlocks(projectDir) {
597
825
  const blocks = [];
598
826
  const activeDir = getActiveBlocksDir(projectDir);
599
827
  for (const filename of manifest.activeBlocks) {
600
- const blockPath = join(activeDir, filename);
828
+ const blockPath = join3(activeDir, filename);
601
829
  try {
602
- if (existsSync2(blockPath)) {
830
+ if (existsSync4(blockPath)) {
603
831
  const content = await readFile(blockPath, "utf-8");
604
832
  const block = JSON.parse(content);
605
833
  blocks.push(block);
@@ -671,8 +899,6 @@ function detectBlockConflict(localBlock, remoteBlock) {
671
899
  remoteBlock
672
900
  };
673
901
  }
674
- const localEntryHashes = new Set(localBlock.entries.map((e) => e.hash));
675
- const remoteEntryHashes = new Set(remoteBlock.entries.map((e) => e.hash));
676
902
  const hasConflictingEntries = localBlock.entries.some((localEntry) => {
677
903
  const conflictingRemoteEntry = remoteBlock.entries.find(
678
904
  (remoteEntry) => remoteEntry.id === localEntry.id && remoteEntry.hash !== localEntry.hash
@@ -732,8 +958,8 @@ function mergeBlockEntries(localBlock, remoteBlock) {
732
958
  }
733
959
  async function migrateLegacyLedger(workDir) {
734
960
  const projectDir = workDir || getWorkingDirectory(void 0, true);
735
- const legacyLedgerPath = join(getTrieDirectory(projectDir), "memory", LEDGER_FILENAME);
736
- if (!existsSync2(legacyLedgerPath)) {
961
+ const legacyLedgerPath = join3(getTrieDirectory(projectDir), "memory", LEDGER_FILENAME);
962
+ if (!existsSync4(legacyLedgerPath)) {
737
963
  return false;
738
964
  }
739
965
  try {
@@ -749,9 +975,9 @@ async function migrateLegacyLedger(workDir) {
749
975
  ...block,
750
976
  version: LEDGER_VERSION,
751
977
  author: defaultAuthor,
752
- gitCommit: lastCommit?.hash,
753
978
  chainHeight: index,
754
- syncedAt: (/* @__PURE__ */ new Date()).toISOString()
979
+ syncedAt: (/* @__PURE__ */ new Date()).toISOString(),
980
+ ...lastCommit?.hash && { gitCommit: lastCommit.hash }
755
981
  }));
756
982
  await initializeSharedLedger(projectDir);
757
983
  await saveLedger(migratedBlocks, projectDir);
@@ -767,8 +993,8 @@ async function migrateLegacyLedger(workDir) {
767
993
  }
768
994
  async function detectLegacyLedger(workDir) {
769
995
  const projectDir = workDir || getWorkingDirectory(void 0, true);
770
- const legacyLedgerPath = join(getTrieDirectory(projectDir), "memory", LEDGER_FILENAME);
771
- if (!existsSync2(legacyLedgerPath)) {
996
+ const legacyLedgerPath = join3(getTrieDirectory(projectDir), "memory", LEDGER_FILENAME);
997
+ if (!existsSync4(legacyLedgerPath)) {
772
998
  return false;
773
999
  }
774
1000
  try {
@@ -810,7 +1036,6 @@ async function compressOldBlocks(workDir) {
810
1036
  let compressedSize = 0;
811
1037
  const blocksByMonth = /* @__PURE__ */ new Map();
812
1038
  for (const blockFile of manifest.activeBlocks) {
813
- const blockPath = join(activeDir, blockFile);
814
1039
  const blockDate = blockFile.replace(".json", "");
815
1040
  if (new Date(blockDate) < cutoffDate) {
816
1041
  const monthKey = blockDate.slice(0, 7);
@@ -821,14 +1046,14 @@ async function compressOldBlocks(workDir) {
821
1046
  }
822
1047
  }
823
1048
  for (const [monthKey, blockFiles] of blocksByMonth) {
824
- const archivePath = join(archivedDir, `${monthKey}.tar.gz`);
825
- if (existsSync2(archivePath)) {
1049
+ const archivePath = join3(archivedDir, `${monthKey}.tar.gz`);
1050
+ if (existsSync4(archivePath)) {
826
1051
  continue;
827
1052
  }
828
1053
  console.log(`Archiving ${blockFiles.length} blocks for ${monthKey}...`);
829
1054
  const monthlyBlocks = [];
830
1055
  for (const blockFile of blockFiles) {
831
- const blockPath = join(activeDir, blockFile);
1056
+ const blockPath = join3(activeDir, blockFile);
832
1057
  try {
833
1058
  const stats = await stat(blockPath);
834
1059
  originalSize += stats.size;
@@ -852,7 +1077,7 @@ async function compressOldBlocks(workDir) {
852
1077
  await writeFile(archivePath, await readFile(tempPath));
853
1078
  await unlink(tempPath);
854
1079
  for (const blockFile of blockFiles) {
855
- const blockPath = join(activeDir, blockFile);
1080
+ const blockPath = join3(activeDir, blockFile);
856
1081
  await unlink(blockPath);
857
1082
  const index = manifest.activeBlocks.indexOf(blockFile);
858
1083
  if (index > -1) {
@@ -871,6 +1096,31 @@ async function compressOldBlocks(workDir) {
871
1096
  sizeReduction: originalSize > 0 ? Math.round((originalSize - compressedSize) / originalSize * 100) : 0
872
1097
  };
873
1098
  }
1099
+ async function loadArchivedBlocks(projectDir, monthKey) {
1100
+ const archivedDir = getArchivedBlocksDir(projectDir);
1101
+ const archivePath = join3(archivedDir, `${monthKey}.tar.gz`);
1102
+ if (!existsSync4(archivePath)) {
1103
+ return [];
1104
+ }
1105
+ try {
1106
+ const chunks = [];
1107
+ await pipeline(
1108
+ createReadStream(archivePath),
1109
+ createGunzip(),
1110
+ async function* (source) {
1111
+ for await (const chunk of source) {
1112
+ chunks.push(chunk);
1113
+ }
1114
+ yield Buffer.concat(chunks);
1115
+ }
1116
+ );
1117
+ const decompressedData = Buffer.concat(chunks).toString("utf-8");
1118
+ return JSON.parse(decompressedData);
1119
+ } catch (error) {
1120
+ console.error(`Failed to load archived blocks for ${monthKey}:`, error);
1121
+ return [];
1122
+ }
1123
+ }
874
1124
  async function getStorageStats(workDir) {
875
1125
  const projectDir = workDir || getWorkingDirectory(void 0, true);
876
1126
  const manifest = await loadManifest(projectDir);
@@ -889,9 +1139,9 @@ async function getStorageStats(workDir) {
889
1139
  let activeSize = 0;
890
1140
  let archivedSize = 0;
891
1141
  for (const blockFile of manifest.activeBlocks) {
892
- const blockPath = join(activeDir, blockFile);
1142
+ const blockPath = join3(activeDir, blockFile);
893
1143
  try {
894
- if (existsSync2(blockPath)) {
1144
+ if (existsSync4(blockPath)) {
895
1145
  const stats = await stat(blockPath);
896
1146
  activeSize += stats.size;
897
1147
  }
@@ -899,16 +1149,15 @@ async function getStorageStats(workDir) {
899
1149
  }
900
1150
  }
901
1151
  for (const archiveFile of manifest.archivedBlocks) {
902
- const archivePath = join(archivedDir, archiveFile);
1152
+ const archivePath = join3(archivedDir, archiveFile);
903
1153
  try {
904
- if (existsSync2(archivePath)) {
1154
+ if (existsSync4(archivePath)) {
905
1155
  const stats = await stat(archivePath);
906
1156
  archivedSize += stats.size;
907
1157
  }
908
1158
  } catch {
909
1159
  }
910
1160
  }
911
- const totalSize = activeSize + archivedSize;
912
1161
  const estimatedUncompressed = archivedSize * 5;
913
1162
  const compressionRatio = estimatedUncompressed > 0 ? Math.round((1 - archivedSize / estimatedUncompressed) * 100) : 0;
914
1163
  return {
@@ -1014,16 +1263,16 @@ async function correctLedgerEntries(entryIds, reason, correctionType = "correcte
1014
1263
  id: entry.id,
1015
1264
  hash: entry.hash,
1016
1265
  severity: entry.severity,
1266
+ issue: entry.correction || "",
1267
+ fix: "",
1017
1268
  file: entry.file,
1269
+ line: 0,
1018
1270
  agent: entry.agent,
1019
- timestamp: entry.timestamp,
1020
- description: entry.correction || "",
1021
1271
  category: "correction",
1022
- line: 0,
1023
- column: 0,
1024
- context: "",
1025
- createdAt: entry.timestamp,
1026
- lastSeen: entry.timestamp
1272
+ timestamp: entry.timestamp,
1273
+ project: "",
1274
+ resolved: false,
1275
+ resolvedAt: void 0
1027
1276
  })),
1028
1277
  projectDir,
1029
1278
  correctionAuthor
@@ -1031,7 +1280,7 @@ async function correctLedgerEntries(entryIds, reason, correctionType = "correcte
1031
1280
  return {
1032
1281
  success: true,
1033
1282
  correctedEntries: entriesToCorrect.length,
1034
- correctionBlock: correctionBlock || void 0
1283
+ ...correctionBlock && { correctionBlock }
1035
1284
  };
1036
1285
  } catch (error) {
1037
1286
  return {
@@ -1109,7 +1358,6 @@ export {
1109
1358
  formatAuditLog,
1110
1359
  getAuditStatistics,
1111
1360
  getRecentAuditLogs,
1112
- getSkillAuditLogs,
1113
1361
  runShellCommandSync,
1114
1362
  getRecentCommits,
1115
1363
  getStagedChanges,
@@ -1119,6 +1367,9 @@ export {
1119
1367
  getWorkingTreeDiff,
1120
1368
  isGitRepo,
1121
1369
  getChangedFilesSinceTimestamp,
1370
+ signLedgerEntry,
1371
+ verifyLedgerEntry,
1372
+ verifyBlockSignatures,
1122
1373
  appendIssuesToLedger,
1123
1374
  verifyLedger,
1124
1375
  computeMerkleRoot,
@@ -1130,6 +1381,7 @@ export {
1130
1381
  detectLegacyLedger,
1131
1382
  getLedgerSyncStatus,
1132
1383
  compressOldBlocks,
1384
+ loadArchivedBlocks,
1133
1385
  getStorageStats,
1134
1386
  shouldCompress,
1135
1387
  correctLedgerEntries,
@@ -1137,4 +1389,4 @@ export {
1137
1389
  getEntryCorrectionHistory,
1138
1390
  getCorrectionStats
1139
1391
  };
1140
- //# sourceMappingURL=chunk-ZUEAHFSY.js.map
1392
+ //# sourceMappingURL=chunk-HD5H7YSW.js.map