@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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/memory/ledger.ts","../src/agent/git.ts","../src/utils/command-runner.ts","../src/utils/audit-logger.ts","../src/memory/crypto-keys.ts","../src/memory/git-integration.ts"],"sourcesContent":["import { createHash } from 'crypto';\nimport { mkdir, readFile, writeFile, stat, unlink } from 'fs/promises';\nimport { existsSync } from 'fs';\nimport { createGzip, createGunzip } from 'zlib';\nimport { pipeline } from 'stream/promises';\nimport { createReadStream, createWriteStream } from 'fs';\nimport { join } from 'path';\nimport { atomicWriteJSON } from '../utils/atomic-write.js';\nimport { getWorkingDirectory, getTrieDirectory } from '../utils/workspace.js';\nimport { getLastCommit, isGitRepo } from '../agent/git.js';\nimport type { StoredIssue } from './issue-store.js';\nimport { signHash, verifyHashSignature, hasSigningKey, type SignatureData } from './crypto-keys.js';\nimport { autoCommitLedger, ensureKeysIgnored } from './git-integration.js';\n\nconst LEDGER_FILENAME = 'ledger.json';\nconst SHARED_LEDGER_DIR = '.trie-shared';\nconst MANIFEST_FILENAME = 'ledger-manifest.json';\nconst SYNC_STATE_FILENAME = 'ledger-sync.json';\nconst GENESIS_HASH = '0'.repeat(64);\nconst LEDGER_VERSION = 2; // Increased for sync support\n\nexport interface LedgerEntry {\n id: string;\n hash: string;\n severity: string;\n file: string;\n agent: string;\n timestamp: string;\n status?: 'active' | 'corrected' | 'false-positive';\n correctedBy?: string; // Entry ID that corrects this\n correction?: string; // Reason for correction\n correctionTimestamp?: string; // When the correction was made\n // Digital signature fields\n signature?: string; // Ed25519 signature of entry hash\n publicKey?: string; // Public key that signed this\n signedAt?: string; // When the entry was signed\n signatureAlgorithm?: 'Ed25519';\n}\n\nexport interface LedgerBlock {\n version: number;\n date: string;\n entries: LedgerEntry[];\n previousHash: string;\n merkleRoot: string;\n blockHash: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface LedgerVerificationResult {\n valid: boolean;\n error?: string;\n}\n\n// Enhanced interfaces for sync functionality\nexport interface SyncableLedgerBlock extends LedgerBlock {\n author: string; // Developer who created block\n gitCommit?: string; // Associated git commit hash\n chainHeight: number; // Block position in chain\n syncedAt?: string; // When block was synced\n conflictResolved?: boolean; // If block resolved conflicts\n}\n\nexport interface CompressedBlock {\n date: string;\n compressedData: string; // gzipped JSON\n originalSize: number;\n compressedSize: number;\n compressionRatio: number;\n entryCount: number;\n blockHash: string;\n author: string;\n}\n\nexport interface LedgerManifest {\n version: number;\n created: string;\n lastSync: string;\n totalBlocks: number;\n totalEntries: number;\n activeBlocks: string[]; // Recent block filenames\n archivedBlocks: string[]; // Archived block filenames\n index: {\n byDate: Record<string, string>; // date → block location\n byAuthor: Record<string, string[]>; // author → block locations\n bySeverity: Record<string, number>; // severity → count\n };\n compressionConfig: {\n enabled: boolean;\n archiveAfterDays: number;\n compressionLevel: number;\n maxHotStorageSize: number; // bytes\n };\n}\n\nexport interface LedgerSyncState {\n lastSyncTimestamp: string;\n lastSyncCommit?: string;\n conflicts: ChainConflict[];\n localChanges: boolean;\n sharedChanges: boolean;\n}\n\nexport interface ChainConflict {\n type: 'divergent_chain' | 'duplicate_entry' | 'hash_mismatch';\n description: string;\n localBlock?: SyncableLedgerBlock;\n remoteBlock?: SyncableLedgerBlock;\n resolution?: 'local' | 'remote' | 'merge' | 'manual';\n}\n\nexport interface ChainMergeResult {\n mergedChain: SyncableLedgerBlock[];\n conflicts: ChainConflict[];\n resolutionStrategy: 'longest' | 'timestamp' | 'manual';\n stats: {\n localBlocks: number;\n remoteBlocks: number;\n mergedBlocks: number;\n duplicatesRemoved: number;\n };\n}\n\n/**\n * Sign a ledger entry with Ed25519\n * \n * Signs the entry hash to prove authenticity and detect tampering.\n * Creates or uses existing signing key from .trie/keys/\n */\nexport async function signLedgerEntry(entry: LedgerEntry, workDir?: string): Promise<LedgerEntry> {\n try {\n const signatureData = await signHash(entry.hash, workDir);\n \n return {\n ...entry,\n signature: signatureData.signature,\n publicKey: signatureData.publicKey,\n signedAt: signatureData.signedAt,\n signatureAlgorithm: 'Ed25519'\n };\n } catch (error) {\n console.error('Failed to sign ledger entry:', error);\n // Return unsigned entry if signing fails\n return entry;\n }\n}\n\n/**\n * Verify a ledger entry signature\n * \n * Returns true if signature is valid, false otherwise.\n * Unsigned entries return true (for backward compatibility).\n */\nexport async function verifyLedgerEntry(entry: LedgerEntry): Promise<boolean> {\n // Unsigned entries are considered valid (backward compatibility)\n if (!entry.signature || !entry.publicKey) {\n return true;\n }\n \n // Check algorithm\n if (entry.signatureAlgorithm !== 'Ed25519') {\n console.error('Unsupported signature algorithm:', entry.signatureAlgorithm);\n return false;\n }\n \n const signatureData: SignatureData = {\n signature: entry.signature,\n publicKey: entry.publicKey,\n algorithm: 'Ed25519',\n signedAt: entry.signedAt || ''\n };\n \n return await verifyHashSignature(entry.hash, signatureData);\n}\n\n/**\n * Verify all entries in a block\n */\nexport async function verifyBlockSignatures(block: LedgerBlock): Promise<{ valid: boolean; invalidEntries: string[] }> {\n const invalidEntries: string[] = [];\n \n for (const entry of block.entries) {\n const isValid = await verifyLedgerEntry(entry);\n if (!isValid) {\n invalidEntries.push(entry.id);\n }\n }\n \n return {\n valid: invalidEntries.length === 0,\n invalidEntries\n };\n}\n\nexport async function appendIssuesToLedger(\n issues: StoredIssue[],\n workDir?: string,\n author?: string\n): Promise<SyncableLedgerBlock | null> {\n if (issues.length === 0) return null;\n\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n const memoryDir = join(getTrieDirectory(projectDir), 'memory');\n await mkdir(memoryDir, { recursive: true });\n\n // Get git info for author attribution\n const isRepo = await isGitRepo(projectDir);\n const lastCommit = isRepo ? await getLastCommit(projectDir) : null;\n const blockAuthor = author || lastCommit?.author || 'unknown';\n\n const blocks = await loadLedger(projectDir) as SyncableLedgerBlock[];\n const today = new Date().toISOString().slice(0, 10);\n const now = new Date().toISOString();\n\n // Create entries and sign them if signing key exists\n const shouldSign = hasSigningKey(projectDir);\n let entries: LedgerEntry[] = issues.map(issue => ({\n id: issue.id,\n hash: issue.hash,\n severity: issue.severity,\n file: issue.file,\n agent: issue.agent,\n timestamp: issue.timestamp,\n status: 'active' as const,\n }));\n \n // Sign all entries if key exists\n if (shouldSign) {\n entries = await Promise.all(entries.map(entry => signLedgerEntry(entry, projectDir)));\n }\n\n const previousBlock = blocks[blocks.length - 1];\n const block = previousBlock && previousBlock.date === today\n ? previousBlock\n : createSyncableBlock(today, now, previousBlock?.blockHash ?? GENESIS_HASH, blockAuthor, lastCommit?.hash, blocks.length);\n\n if (block !== previousBlock) {\n blocks.push(block);\n }\n\n block.entries = [...block.entries, ...entries];\n block.merkleRoot = computeMerkleRoot(block.entries.map(entry => entry.hash));\n block.blockHash = computeBlockHash(block.previousHash, block.merkleRoot, block.date, block.version);\n block.updatedAt = now;\n\n await saveLedger(blocks, projectDir);\n \n // Level 2: Auto-commit to git (if enabled)\n if (await isGitRepo(projectDir)) {\n // Ensure signing keys are in .gitignore\n await ensureKeysIgnored(projectDir);\n \n // Auto-commit ledger changes\n const commitMessage = `ledger: append ${entries.length} ${entries.length === 1 ? 'entry' : 'entries'}`;\n await autoCommitLedger(projectDir, commitMessage);\n }\n \n return block;\n}\n\nexport async function verifyLedger(workDir?: string): Promise<LedgerVerificationResult> {\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n const blocks = await loadLedger(projectDir);\n\n if (blocks.length === 0) {\n return { valid: true };\n }\n\n for (let i = 0; i < blocks.length; i += 1) {\n const block = blocks[i];\n if (!block) {\n return { valid: false, error: `Block ${i} missing` };\n }\n const expectedPreviousHash = i === 0\n ? GENESIS_HASH\n : blocks[i - 1]?.blockHash;\n\n if (!expectedPreviousHash) {\n return { valid: false, error: `Block ${i} missing previous block` };\n }\n\n if (block.previousHash !== expectedPreviousHash) {\n return { valid: false, error: `Block ${i} previous hash mismatch` };\n }\n\n const computedMerkleRoot = computeMerkleRoot(block.entries.map(entry => entry.hash));\n if (block.merkleRoot !== computedMerkleRoot) {\n return { valid: false, error: `Block ${i} merkle root mismatch` };\n }\n\n const computedBlockHash = computeBlockHash(block.previousHash, block.merkleRoot, block.date, block.version);\n if (block.blockHash !== computedBlockHash) {\n return { valid: false, error: `Block ${i} block hash mismatch` };\n }\n \n // Verify signatures for signed entries\n const signatureVerification = await verifyBlockSignatures(block);\n if (!signatureVerification.valid) {\n return { \n valid: false, \n error: `Block ${i} has invalid signatures: ${signatureVerification.invalidEntries.join(', ')}` \n };\n }\n }\n\n return { valid: true };\n}\n\nexport function computeMerkleRoot(hashes: string[]): string {\n if (hashes.length === 0) {\n return sha256('');\n }\n\n let level = hashes.slice();\n while (level.length > 1) {\n const nextLevel: string[] = [];\n for (let i = 0; i < level.length; i += 2) {\n const left = level[i];\n const right = level[i + 1] ?? left;\n nextLevel.push(sha256(`${left}:${right}`));\n }\n level = nextLevel;\n }\n\n return level[0]!;\n}\n\nfunction computeBlockHash(previousHash: string, merkleRoot: string, date: string, version: number): string {\n return sha256(`${version}:${date}:${previousHash}:${merkleRoot}`);\n}\n\nfunction createSyncableBlock(\n date: string,\n now: string,\n previousHash: string,\n author: string,\n gitCommit?: string,\n chainHeight: number = 0\n): SyncableLedgerBlock {\n return {\n version: LEDGER_VERSION,\n date,\n entries: [],\n previousHash,\n merkleRoot: '',\n blockHash: '',\n createdAt: now,\n updatedAt: now,\n author,\n chainHeight,\n ...(gitCommit && { gitCommit }),\n };\n}\n\nasync function loadLedger(projectDir: string): Promise<LedgerBlock[]> {\n const ledgerPath = join(getTrieDirectory(projectDir), 'memory', LEDGER_FILENAME);\n try {\n if (!existsSync(ledgerPath)) return [];\n const content = await readFile(ledgerPath, 'utf-8');\n const parsed = JSON.parse(content);\n if (!Array.isArray(parsed)) return [];\n return parsed as LedgerBlock[];\n } catch {\n return [];\n }\n}\n\n/** Load ledger blocks for UI display (block hashes, merkle roots, chain) */\nexport async function getLedgerBlocks(workDir?: string): Promise<LedgerBlock[]> {\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n return loadLedger(projectDir);\n}\n\nasync function saveLedger(blocks: LedgerBlock[], projectDir: string): Promise<void> {\n const ledgerPath = join(getTrieDirectory(projectDir), 'memory', LEDGER_FILENAME);\n await atomicWriteJSON(ledgerPath, blocks);\n}\n\nfunction sha256(input: string): string {\n return createHash('sha256').update(input).digest('hex');\n}\n\n// ==================== Shared Storage Functions ====================\n\nfunction getSharedLedgerDir(projectDir: string): string {\n return join(projectDir, SHARED_LEDGER_DIR);\n}\n\nfunction getActiveBlocksDir(projectDir: string): string {\n return join(getSharedLedgerDir(projectDir), 'active');\n}\n\nfunction getArchivedBlocksDir(projectDir: string): string {\n return join(getSharedLedgerDir(projectDir), 'archived');\n}\n\nfunction getManifestPath(projectDir: string): string {\n return join(getSharedLedgerDir(projectDir), MANIFEST_FILENAME);\n}\n\nfunction getSyncStatePath(projectDir: string): string {\n return join(getTrieDirectory(projectDir), 'memory', SYNC_STATE_FILENAME);\n}\n\nasync function ensureSharedStorageStructure(projectDir: string): Promise<void> {\n const sharedDir = getSharedLedgerDir(projectDir);\n const activeDir = getActiveBlocksDir(projectDir);\n const archivedDir = getArchivedBlocksDir(projectDir);\n\n await mkdir(sharedDir, { recursive: true });\n await mkdir(activeDir, { recursive: true });\n await mkdir(archivedDir, { recursive: true });\n}\n\nasync function loadManifest(projectDir: string): Promise<LedgerManifest | null> {\n const manifestPath = getManifestPath(projectDir);\n\n try {\n if (!existsSync(manifestPath)) return null;\n const content = await readFile(manifestPath, 'utf-8');\n return JSON.parse(content) as LedgerManifest;\n } catch {\n return null;\n }\n}\n\nasync function saveManifest(manifest: LedgerManifest, projectDir: string): Promise<void> {\n const manifestPath = getManifestPath(projectDir);\n await atomicWriteJSON(manifestPath, manifest);\n}\n\nasync function createDefaultManifest(_projectDir: string): Promise<LedgerManifest> {\n const now = new Date().toISOString();\n\n return {\n version: LEDGER_VERSION,\n created: now,\n lastSync: now,\n totalBlocks: 0,\n totalEntries: 0,\n activeBlocks: [],\n archivedBlocks: [],\n index: {\n byDate: {},\n byAuthor: {},\n bySeverity: {}\n },\n compressionConfig: {\n enabled: true,\n archiveAfterDays: 30,\n compressionLevel: 6,\n maxHotStorageSize: 50 * 1024 * 1024 // 50MB\n }\n };\n}\n\nasync function loadSyncState(projectDir: string): Promise<LedgerSyncState | null> {\n const syncStatePath = getSyncStatePath(projectDir);\n\n try {\n if (!existsSync(syncStatePath)) return null;\n const content = await readFile(syncStatePath, 'utf-8');\n return JSON.parse(content) as LedgerSyncState;\n } catch {\n return null;\n }\n}\n\nasync function saveSyncState(syncState: LedgerSyncState, projectDir: string): Promise<void> {\n const syncStatePath = getSyncStatePath(projectDir);\n const memoryDir = join(getTrieDirectory(projectDir), 'memory');\n await mkdir(memoryDir, { recursive: true });\n await atomicWriteJSON(syncStatePath, syncState);\n}\n\n// ==================== Core Sync Functions ====================\n\nexport async function initializeSharedLedger(workDir?: string): Promise<void> {\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n await ensureSharedStorageStructure(projectDir);\n\n const existingManifest = await loadManifest(projectDir);\n if (!existingManifest) {\n const manifest = await createDefaultManifest(projectDir);\n await saveManifest(manifest, projectDir);\n }\n\n // Initialize sync state if needed\n const existingSyncState = await loadSyncState(projectDir);\n if (!existingSyncState) {\n const now = new Date().toISOString();\n const syncState: LedgerSyncState = {\n lastSyncTimestamp: now,\n conflicts: [],\n localChanges: false,\n sharedChanges: false\n };\n await saveSyncState(syncState, projectDir);\n }\n}\n\nexport async function syncLedgerFromShared(workDir?: string): Promise<ChainMergeResult> {\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n\n // Ensure shared storage exists\n await initializeSharedLedger(projectDir);\n\n // Load current state\n const manifest = await loadManifest(projectDir);\n const localBlocks = await loadLedger(projectDir) as SyncableLedgerBlock[];\n const sharedBlocks = await loadSharedBlocks(projectDir);\n\n if (!manifest) {\n throw new Error('Failed to load ledger manifest');\n }\n\n // Merge chains\n const mergeResult = await mergeChains(localBlocks, sharedBlocks, 'timestamp');\n\n // Save merged chain locally\n await saveLedger(mergeResult.mergedChain, projectDir);\n\n // Update sync state\n const syncState: LedgerSyncState = {\n lastSyncTimestamp: new Date().toISOString(),\n conflicts: mergeResult.conflicts,\n localChanges: false,\n sharedChanges: false\n };\n await saveSyncState(syncState, projectDir);\n\n return mergeResult;\n}\n\nexport async function pushLedgerToShared(workDir?: string): Promise<void> {\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n\n // Ensure shared storage exists\n await initializeSharedLedger(projectDir);\n\n // Load current state\n const localBlocks = await loadLedger(projectDir) as SyncableLedgerBlock[];\n const manifest = await loadManifest(projectDir) || await createDefaultManifest(projectDir);\n\n // Save blocks to shared storage\n const activeDir = getActiveBlocksDir(projectDir);\n\n for (const block of localBlocks) {\n const blockFilename = `${block.date}.json`;\n const blockPath = join(activeDir, blockFilename);\n\n // Only save if not already present or if block has been updated\n if (!existsSync(blockPath) || block.updatedAt > manifest.lastSync) {\n await atomicWriteJSON(blockPath, block);\n\n // Update manifest index\n manifest.index.byDate[block.date] = `active/${blockFilename}`;\n\n const blockAuthor = block.author;\n if (blockAuthor) {\n if (!manifest.index.byAuthor[blockAuthor]) {\n manifest.index.byAuthor[blockAuthor] = [];\n }\n if (!manifest.index.byAuthor[blockAuthor].includes(`active/${blockFilename}`)) {\n manifest.index.byAuthor[blockAuthor].push(`active/${blockFilename}`);\n }\n }\n\n // Update active blocks list\n if (!manifest.activeBlocks.includes(blockFilename)) {\n manifest.activeBlocks.push(blockFilename);\n }\n }\n }\n\n // Update manifest metadata\n manifest.lastSync = new Date().toISOString();\n manifest.totalBlocks = manifest.activeBlocks.length + manifest.archivedBlocks.length;\n manifest.totalEntries = localBlocks.reduce((sum, block) => sum + block.entries.length, 0);\n\n await saveManifest(manifest, projectDir);\n}\n\nasync function loadSharedBlocks(projectDir: string): Promise<SyncableLedgerBlock[]> {\n const manifest = await loadManifest(projectDir);\n if (!manifest) return [];\n\n const blocks: SyncableLedgerBlock[] = [];\n const activeDir = getActiveBlocksDir(projectDir);\n\n // Load active blocks\n for (const filename of manifest.activeBlocks) {\n const blockPath = join(activeDir, filename);\n try {\n if (existsSync(blockPath)) {\n const content = await readFile(blockPath, 'utf-8');\n const block = JSON.parse(content) as SyncableLedgerBlock;\n blocks.push(block);\n }\n } catch (error) {\n console.warn(`Failed to load shared block ${filename}:`, error);\n }\n }\n\n // TODO: Load archived blocks when needed\n\n // Sort by date to maintain chronological order\n return blocks.sort((a, b) => a.date.localeCompare(b.date));\n}\n\n// ==================== Chain Merge & Conflict Resolution ====================\n\nasync function mergeChains(\n localBlocks: SyncableLedgerBlock[],\n remoteBlocks: SyncableLedgerBlock[],\n strategy: 'longest' | 'timestamp' | 'manual' = 'timestamp'\n): Promise<ChainMergeResult> {\n const conflicts: ChainConflict[] = [];\n const mergedBlocks = new Map<string, SyncableLedgerBlock>();\n const stats = {\n localBlocks: localBlocks.length,\n remoteBlocks: remoteBlocks.length,\n mergedBlocks: 0,\n duplicatesRemoved: 0\n };\n\n // Index blocks by date for quick lookup\n const localByDate = new Map<string, SyncableLedgerBlock>();\n for (const block of localBlocks) {\n localByDate.set(block.date, block);\n }\n\n const remoteByDate = new Map<string, SyncableLedgerBlock>();\n for (const block of remoteBlocks) {\n remoteByDate.set(block.date, block);\n }\n\n // Get all unique dates\n const allDates = new Set([...localByDate.keys(), ...remoteByDate.keys()]);\n\n for (const date of allDates) {\n const localBlock = localByDate.get(date);\n const remoteBlock = remoteByDate.get(date);\n\n if (localBlock && remoteBlock) {\n // Both chains have a block for this date - potential conflict\n const conflict = detectBlockConflict(localBlock, remoteBlock);\n\n if (conflict) {\n conflicts.push(conflict);\n\n // Apply resolution strategy\n const resolvedBlock = resolveConflict(conflict, strategy);\n if (resolvedBlock) {\n mergedBlocks.set(date, resolvedBlock);\n }\n } else {\n // No conflict - merge entries\n const mergedBlock = mergeBlockEntries(localBlock, remoteBlock);\n mergedBlocks.set(date, mergedBlock);\n }\n } else if (localBlock) {\n // Only local block exists\n mergedBlocks.set(date, localBlock);\n } else if (remoteBlock) {\n // Only remote block exists\n mergedBlocks.set(date, remoteBlock);\n }\n }\n\n // Convert to sorted array and recalculate chain heights\n const resultBlocks = Array.from(mergedBlocks.values())\n .sort((a, b) => a.date.localeCompare(b.date))\n .map((block, index) => ({\n ...block,\n chainHeight: index\n }));\n\n stats.mergedBlocks = resultBlocks.length;\n stats.duplicatesRemoved = stats.localBlocks + stats.remoteBlocks - stats.mergedBlocks;\n\n return {\n mergedChain: resultBlocks,\n conflicts,\n resolutionStrategy: strategy,\n stats\n };\n}\n\nfunction detectBlockConflict(\n localBlock: SyncableLedgerBlock,\n remoteBlock: SyncableLedgerBlock\n): ChainConflict | null {\n // Check for hash mismatch (different content for same date)\n if (localBlock.blockHash !== remoteBlock.blockHash) {\n return {\n type: 'hash_mismatch',\n description: `Different block content for date ${localBlock.date}`,\n localBlock,\n remoteBlock\n };\n }\n\n // Check for entry conflicts\n const hasConflictingEntries = localBlock.entries.some(localEntry => {\n const conflictingRemoteEntry = remoteBlock.entries.find(remoteEntry =>\n remoteEntry.id === localEntry.id && remoteEntry.hash !== localEntry.hash\n );\n return !!conflictingRemoteEntry;\n });\n\n if (hasConflictingEntries) {\n return {\n type: 'duplicate_entry',\n description: `Conflicting entries found for date ${localBlock.date}`,\n localBlock,\n remoteBlock\n };\n }\n\n return null; // No conflict\n}\n\nfunction resolveConflict(\n conflict: ChainConflict,\n strategy: 'longest' | 'timestamp' | 'manual'\n): SyncableLedgerBlock | null {\n if (!conflict.localBlock || !conflict.remoteBlock) {\n return null;\n }\n\n switch (strategy) {\n case 'longest':\n // Choose block with more entries\n return conflict.localBlock.entries.length >= conflict.remoteBlock.entries.length\n ? conflict.localBlock\n : conflict.remoteBlock;\n\n case 'timestamp':\n // Choose block with later update timestamp\n return conflict.localBlock.updatedAt >= conflict.remoteBlock.updatedAt\n ? conflict.localBlock\n : conflict.remoteBlock;\n\n case 'manual':\n // Leave for manual resolution - for now, prefer local\n return { ...conflict.localBlock, conflictResolved: false };\n\n default:\n return conflict.localBlock;\n }\n}\n\nfunction mergeBlockEntries(\n localBlock: SyncableLedgerBlock,\n remoteBlock: SyncableLedgerBlock\n): SyncableLedgerBlock {\n // Combine entries, deduplicating by hash\n const entryMap = new Map<string, LedgerEntry>();\n\n // Add local entries first\n for (const entry of localBlock.entries) {\n entryMap.set(entry.hash, entry);\n }\n\n // Add remote entries (will overwrite locals with same hash)\n for (const entry of remoteBlock.entries) {\n entryMap.set(entry.hash, entry);\n }\n\n const mergedEntries = Array.from(entryMap.values());\n const now = new Date().toISOString();\n\n // Combine author information\n const authors = [localBlock.author, remoteBlock.author].filter(Boolean);\n const combinedAuthor = authors.length > 1 ? authors.join('+') : authors[0] || 'unknown';\n\n return {\n ...localBlock,\n entries: mergedEntries,\n author: combinedAuthor,\n updatedAt: now,\n merkleRoot: computeMerkleRoot(mergedEntries.map(e => e.hash)),\n blockHash: computeBlockHash(\n localBlock.previousHash,\n computeMerkleRoot(mergedEntries.map(e => e.hash)),\n localBlock.date,\n localBlock.version\n )\n };\n}\n\n// ==================== Migration & Legacy Support ====================\n\nexport async function migrateLegacyLedger(workDir?: string): Promise<boolean> {\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n const legacyLedgerPath = join(getTrieDirectory(projectDir), 'memory', LEDGER_FILENAME);\n\n // Check if legacy ledger exists\n if (!existsSync(legacyLedgerPath)) {\n return false; // No legacy ledger to migrate\n }\n\n try {\n // Load legacy blocks\n const legacyBlocks = await loadLedger(projectDir);\n\n // Check if already migrated (v2 format)\n if (legacyBlocks.length > 0 && (legacyBlocks[0] as any).author !== undefined) {\n return false; // Already migrated\n }\n\n console.log(`Migrating legacy ledger with ${legacyBlocks.length} blocks...`);\n\n // Convert legacy blocks to syncable blocks\n const isRepo = await isGitRepo(projectDir);\n const lastCommit = isRepo ? await getLastCommit(projectDir) : null;\n const defaultAuthor = lastCommit?.author || 'legacy-migration';\n\n const migratedBlocks: SyncableLedgerBlock[] = legacyBlocks.map((block, index) => ({\n ...block,\n version: LEDGER_VERSION,\n author: defaultAuthor,\n chainHeight: index,\n syncedAt: new Date().toISOString(),\n ...(lastCommit?.hash && { gitCommit: lastCommit.hash }),\n }));\n\n // Initialize shared storage\n await initializeSharedLedger(projectDir);\n\n // Save migrated blocks locally\n await saveLedger(migratedBlocks, projectDir);\n\n // Push to shared storage\n await pushLedgerToShared(projectDir);\n\n // Create backup of original ledger\n const backupPath = `${legacyLedgerPath}.backup.${Date.now()}`;\n await writeFile(backupPath, JSON.stringify(legacyBlocks, null, 2));\n\n console.log(`✓ Migration complete. Backup saved to ${backupPath}`);\n return true;\n } catch (error) {\n console.error('Failed to migrate legacy ledger:', error);\n return false;\n }\n}\n\nexport async function detectLegacyLedger(workDir?: string): Promise<boolean> {\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n const legacyLedgerPath = join(getTrieDirectory(projectDir), 'memory', LEDGER_FILENAME);\n\n if (!existsSync(legacyLedgerPath)) {\n return false;\n }\n\n try {\n const blocks = await loadLedger(projectDir);\n return blocks.length > 0 && (blocks[0] as any).author === undefined;\n } catch {\n return false;\n }\n}\n\n// ==================== Status & Info Functions ====================\n\nexport async function getLedgerSyncStatus(workDir?: string): Promise<{\n isInitialized: boolean;\n hasLegacyLedger: boolean;\n syncState: LedgerSyncState | null;\n manifest: LedgerManifest | null;\n localBlocks: number;\n sharedBlocks: number;\n conflicts: number;\n}> {\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n\n const hasLegacyLedger = await detectLegacyLedger(projectDir);\n const manifest = await loadManifest(projectDir);\n const syncState = await loadSyncState(projectDir);\n const localBlocks = await loadLedger(projectDir);\n const sharedBlocks = await loadSharedBlocks(projectDir);\n\n return {\n isInitialized: !!manifest,\n hasLegacyLedger,\n syncState,\n manifest,\n localBlocks: localBlocks.length,\n sharedBlocks: sharedBlocks.length,\n conflicts: syncState?.conflicts.length || 0\n };\n}\n\n// ==================== Compression & Archival System ====================\n\nexport async function compressOldBlocks(workDir?: string): Promise<{\n archived: number;\n sizeReduction: number;\n}> {\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n const manifest = await loadManifest(projectDir);\n\n if (!manifest || !manifest.compressionConfig.enabled) {\n return { archived: 0, sizeReduction: 0 };\n }\n\n const activeDir = getActiveBlocksDir(projectDir);\n const archivedDir = getArchivedBlocksDir(projectDir);\n const cutoffDate = new Date();\n cutoffDate.setDate(cutoffDate.getDate() - manifest.compressionConfig.archiveAfterDays);\n\n let archivedCount = 0;\n let originalSize = 0;\n let compressedSize = 0;\n\n // Group blocks by month for archival\n const blocksByMonth = new Map<string, string[]>();\n\n for (const blockFile of manifest.activeBlocks) {\n const blockDate = blockFile.replace('.json', '');\n\n if (new Date(blockDate) < cutoffDate) {\n const monthKey = blockDate.slice(0, 7); // YYYY-MM\n if (!blocksByMonth.has(monthKey)) {\n blocksByMonth.set(monthKey, []);\n }\n blocksByMonth.get(monthKey)!.push(blockFile);\n }\n }\n\n // Archive each month\n for (const [monthKey, blockFiles] of blocksByMonth) {\n const archivePath = join(archivedDir, `${monthKey}.tar.gz`);\n\n // Skip if already archived\n if (existsSync(archivePath)) {\n continue;\n }\n\n console.log(`Archiving ${blockFiles.length} blocks for ${monthKey}...`);\n\n const monthlyBlocks: SyncableLedgerBlock[] = [];\n for (const blockFile of blockFiles) {\n const blockPath = join(activeDir, blockFile);\n\n try {\n const stats = await stat(blockPath);\n originalSize += stats.size;\n\n const content = await readFile(blockPath, 'utf-8');\n const block = JSON.parse(content) as SyncableLedgerBlock;\n monthlyBlocks.push(block);\n } catch (error) {\n console.warn(`Failed to read block ${blockFile}:`, error);\n }\n }\n\n // Compress and write archive\n if (monthlyBlocks.length > 0) {\n const archiveData = JSON.stringify(monthlyBlocks);\n const tempPath = `${archivePath}.tmp`;\n\n // Write compressed archive\n await pipeline(\n Buffer.from(archiveData),\n createGzip({ level: manifest.compressionConfig.compressionLevel }),\n createWriteStream(tempPath)\n );\n\n // Get compressed size\n const compressedStats = await stat(tempPath);\n compressedSize += compressedStats.size;\n\n // Rename to final location\n await writeFile(archivePath, await readFile(tempPath));\n await unlink(tempPath);\n\n // Remove original block files\n for (const blockFile of blockFiles) {\n const blockPath = join(activeDir, blockFile);\n await unlink(blockPath);\n\n // Remove from manifest\n const index = manifest.activeBlocks.indexOf(blockFile);\n if (index > -1) {\n manifest.activeBlocks.splice(index, 1);\n }\n }\n\n // Add to archived blocks\n manifest.archivedBlocks.push(`${monthKey}.tar.gz`);\n archivedCount += blockFiles.length;\n }\n }\n\n // Update manifest\n if (archivedCount > 0) {\n await saveManifest(manifest, projectDir);\n }\n\n return {\n archived: archivedCount,\n sizeReduction: originalSize > 0 ? Math.round(((originalSize - compressedSize) / originalSize) * 100) : 0\n };\n}\n\n/** Load blocks from archived tar.gz - for read-back from archives */\nexport async function loadArchivedBlocks(\n projectDir: string,\n monthKey: string\n): Promise<SyncableLedgerBlock[]> {\n const archivedDir = getArchivedBlocksDir(projectDir);\n const archivePath = join(archivedDir, `${monthKey}.tar.gz`);\n\n if (!existsSync(archivePath)) {\n return [];\n }\n\n try {\n // Decompress and parse\n const chunks: Buffer[] = [];\n await pipeline(\n createReadStream(archivePath),\n createGunzip(),\n async function* (source) {\n for await (const chunk of source) {\n chunks.push(chunk);\n }\n yield Buffer.concat(chunks);\n }\n );\n\n const decompressedData = Buffer.concat(chunks).toString('utf-8');\n return JSON.parse(decompressedData) as SyncableLedgerBlock[];\n } catch (error) {\n console.error(`Failed to load archived blocks for ${monthKey}:`, error);\n return [];\n }\n}\n\nexport async function getStorageStats(workDir?: string): Promise<{\n activeBlocks: number;\n archivedBlocks: number;\n activeSize: number;\n archivedSize: number;\n compressionRatio: number;\n totalEntries: number;\n}> {\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n const manifest = await loadManifest(projectDir);\n\n if (!manifest) {\n return {\n activeBlocks: 0,\n archivedBlocks: 0,\n activeSize: 0,\n archivedSize: 0,\n compressionRatio: 0,\n totalEntries: 0\n };\n }\n\n const activeDir = getActiveBlocksDir(projectDir);\n const archivedDir = getArchivedBlocksDir(projectDir);\n\n let activeSize = 0;\n let archivedSize = 0;\n\n // Calculate active storage size\n for (const blockFile of manifest.activeBlocks) {\n const blockPath = join(activeDir, blockFile);\n try {\n if (existsSync(blockPath)) {\n const stats = await stat(blockPath);\n activeSize += stats.size;\n }\n } catch {\n // Ignore missing files\n }\n }\n\n // Calculate archived storage size\n for (const archiveFile of manifest.archivedBlocks) {\n const archivePath = join(archivedDir, archiveFile);\n try {\n if (existsSync(archivePath)) {\n const stats = await stat(archivePath);\n archivedSize += stats.size;\n }\n } catch {\n // Ignore missing files\n }\n }\n\n const estimatedUncompressed = archivedSize * 5; // Rough estimate\n const compressionRatio = estimatedUncompressed > 0\n ? Math.round((1 - (archivedSize / estimatedUncompressed)) * 100)\n : 0;\n\n return {\n activeBlocks: manifest.activeBlocks.length,\n archivedBlocks: manifest.archivedBlocks.length,\n activeSize,\n archivedSize,\n compressionRatio,\n totalEntries: manifest.totalEntries\n };\n}\n\nexport async function shouldCompress(workDir?: string): Promise<boolean> {\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n const manifest = await loadManifest(projectDir);\n\n if (!manifest || !manifest.compressionConfig.enabled) {\n return false;\n }\n\n const stats = await getStorageStats(projectDir);\n\n // Compress if hot storage exceeds limit or if old blocks exist\n const exceedsSize = stats.activeSize > manifest.compressionConfig.maxHotStorageSize;\n const hasOldBlocks = manifest.activeBlocks.some(blockFile => {\n const blockDate = blockFile.replace('.json', '');\n const cutoffDate = new Date();\n cutoffDate.setDate(cutoffDate.getDate() - manifest.compressionConfig.archiveAfterDays);\n return new Date(blockDate) < cutoffDate;\n });\n\n return exceedsSize || hasOldBlocks;\n}\n\n// ==================== Entry Correction Functions (Immutable Ledger) ====================\n\nexport interface CorrectionResult {\n success: boolean;\n correctedEntries: number;\n correctionBlock?: SyncableLedgerBlock;\n error?: string;\n}\n\n/**\n * Mark ledger entries as corrected by adding a correction entry to the ledger.\n * This maintains immutability - original entries remain in the chain for audit trail.\n * \n * @param entryIds - IDs of entries to mark as corrected\n * @param reason - Reason for the correction (e.g., \"false positive\", \"duplicate\", \"incorrect detection\")\n * @param correctionType - Type of correction: 'corrected' or 'false-positive'\n * @param workDir - Working directory\n * @param author - Author of the correction\n */\nexport async function correctLedgerEntries(\n entryIds: string[],\n reason: string,\n correctionType: 'corrected' | 'false-positive' = 'corrected',\n workDir?: string,\n author?: string\n): Promise<CorrectionResult> {\n if (entryIds.length === 0) {\n return {\n success: false,\n correctedEntries: 0,\n error: 'No entry IDs provided'\n };\n }\n\n if (!reason || reason.trim().length === 0) {\n return {\n success: false,\n correctedEntries: 0,\n error: 'Correction reason is required'\n };\n }\n\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n const blocks = await loadLedger(projectDir) as SyncableLedgerBlock[];\n\n // Find entries to correct\n const entriesToCorrect: LedgerEntry[] = [];\n for (const block of blocks) {\n for (const entry of block.entries) {\n if (entryIds.includes(entry.id) && entry.status === 'active') {\n entriesToCorrect.push(entry);\n }\n }\n }\n\n if (entriesToCorrect.length === 0) {\n return {\n success: false,\n correctedEntries: 0,\n error: 'No active entries found with the provided IDs'\n };\n }\n\n try {\n const now = new Date().toISOString();\n const isRepo = await isGitRepo(projectDir);\n const lastCommit = isRepo ? await getLastCommit(projectDir) : null;\n const correctionAuthor = author || lastCommit?.author || 'unknown';\n\n // Create correction entries (append-only: we add new entries that mark the old ones as corrected)\n const correctionEntries: LedgerEntry[] = entriesToCorrect.map(entry => {\n const correctionId = `correction-${entry.id}-${Date.now()}`;\n return {\n id: correctionId,\n hash: sha256(`${correctionId}:${entry.hash}:${reason}:${now}`),\n severity: 'info',\n file: entry.file,\n agent: 'ledger-correction',\n timestamp: now,\n status: 'active',\n correction: `Correcting entry ${entry.id}: ${reason}`,\n correctedBy: entry.id,\n };\n });\n\n // Update original entries in their blocks to mark them as corrected\n for (const block of blocks) {\n let blockModified = false;\n for (const entry of block.entries) {\n if (entryIds.includes(entry.id) && entry.status === 'active') {\n entry.status = correctionType;\n entry.correctionTimestamp = now;\n entry.correction = reason;\n blockModified = true;\n }\n }\n \n if (blockModified) {\n // Recalculate merkle root and block hash\n block.merkleRoot = computeMerkleRoot(block.entries.map(e => e.hash));\n block.blockHash = computeBlockHash(\n block.previousHash,\n block.merkleRoot,\n block.date,\n block.version\n );\n block.updatedAt = now;\n }\n }\n\n // Save updated blocks\n await saveLedger(blocks, projectDir);\n\n // Append correction entries as a new block\n const correctionBlock = await appendIssuesToLedger(\n correctionEntries.map(entry => ({\n id: entry.id,\n hash: entry.hash,\n severity: entry.severity,\n issue: entry.correction || '',\n fix: '',\n file: entry.file,\n line: 0,\n agent: entry.agent,\n category: 'correction',\n timestamp: entry.timestamp,\n project: '',\n resolved: false,\n resolvedAt: undefined,\n })),\n projectDir,\n correctionAuthor\n );\n\n return {\n success: true,\n correctedEntries: entriesToCorrect.length,\n ...(correctionBlock && { correctionBlock }),\n };\n } catch (error) {\n return {\n success: false,\n correctedEntries: 0,\n error: `Failed to correct entries: ${error instanceof Error ? error.message : 'Unknown error'}`\n };\n }\n}\n\n/**\n * Get all entries from the ledger, optionally filtering by status.\n * By default, only returns active entries (excludes corrected/false-positives).\n */\nexport async function getLedgerEntries(\n workDir?: string,\n includeStatus?: Array<'active' | 'corrected' | 'false-positive'>\n): Promise<LedgerEntry[]> {\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n const blocks = await loadLedger(projectDir);\n \n const statusFilter = includeStatus || ['active'];\n const entries: LedgerEntry[] = [];\n \n for (const block of blocks) {\n for (const entry of block.entries) {\n const entryStatus = entry.status || 'active';\n if (statusFilter.includes(entryStatus as any)) {\n entries.push(entry);\n }\n }\n }\n \n return entries;\n}\n\n/**\n * Get correction history for specific entry IDs.\n * Returns the original entry and any correction entries.\n */\nexport async function getEntryCorrectionHistory(\n entryIds: string[],\n workDir?: string\n): Promise<Map<string, { original: LedgerEntry; corrections: LedgerEntry[] }>> {\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n const blocks = await loadLedger(projectDir);\n \n const history = new Map<string, { original: LedgerEntry; corrections: LedgerEntry[] }>();\n \n for (const entryId of entryIds) {\n const corrections: LedgerEntry[] = [];\n let original: LedgerEntry | null = null;\n \n for (const block of blocks) {\n for (const entry of block.entries) {\n if (entry.id === entryId) {\n original = entry;\n }\n if (entry.correctedBy === entryId) {\n corrections.push(entry);\n }\n }\n }\n \n if (original) {\n history.set(entryId, { original, corrections });\n }\n }\n \n return history;\n}\n\n/**\n * Get statistics about ledger corrections\n */\nexport async function getCorrectionStats(workDir?: string): Promise<{\n totalEntries: number;\n activeEntries: number;\n correctedEntries: number;\n falsePositives: number;\n correctionRate: number;\n}> {\n const projectDir = workDir || getWorkingDirectory(undefined, true);\n const blocks = await loadLedger(projectDir);\n \n let totalEntries = 0;\n let activeEntries = 0;\n let correctedEntries = 0;\n let falsePositives = 0;\n \n for (const block of blocks) {\n for (const entry of block.entries) {\n totalEntries++;\n const status = entry.status || 'active';\n \n if (status === 'active') activeEntries++;\n else if (status === 'corrected') correctedEntries++;\n else if (status === 'false-positive') falsePositives++;\n }\n }\n \n const correctionRate = totalEntries > 0 \n ? ((correctedEntries + falsePositives) / totalEntries) * 100 \n : 0;\n \n return {\n totalEntries,\n activeEntries,\n correctedEntries,\n falsePositives,\n correctionRate: Math.round(correctionRate * 100) / 100\n };\n}\n","import { existsSync } from 'node:fs';\nimport path from 'node:path';\nimport { runExecFile } from '../utils/command-runner.js';\n\nexport interface Commit {\n hash: string;\n author: string;\n date: string;\n message: string;\n}\n\nexport interface Change {\n path: string;\n status: string;\n oldPath?: string;\n}\n\nasync function execGit(args: string[], cwd: string): Promise<string | null> {\n try {\n const { stdout } = await runExecFile(\n 'git',\n ['-C', cwd, ...args],\n { actor: 'internal:git', triggeredBy: 'manual', targetPath: cwd },\n { maxBuffer: 10 * 1024 * 1024, captureOutput: false }\n );\n return stdout.trim();\n } catch (error: any) {\n const stderr: string | undefined = error?.stderr?.toString();\n // Gracefully handle non-git directories and repos with no commits\n if (stderr?.includes('not a git repository') || stderr?.includes('does not have any commits')) {\n return null;\n }\n throw error;\n }\n}\n\nasync function ensureRepo(projectPath: string): Promise<boolean> {\n const result = await execGit(['rev-parse', '--is-inside-work-tree'], projectPath);\n return result === 'true';\n}\n\nfunction parseNameStatus(output: string): Change[] {\n return output\n .split('\\n')\n .map((line) => line.trim())\n .filter(Boolean)\n .map((line) => {\n const parts = line.split('\\t');\n const status = parts[0] ?? '';\n const filePath = parts[1] ?? '';\n const oldPath = parts[2];\n const change: Change = { status, path: filePath };\n if (oldPath) change.oldPath = oldPath;\n return change;\n })\n .filter((entry) => entry.path.length > 0);\n}\n\nexport async function getRecentCommits(projectPath: string, limit: number): Promise<Commit[]> {\n const isRepo = await ensureRepo(projectPath);\n if (!isRepo) return [];\n\n const output = await execGit(\n ['log', `-n`, String(limit), '--pretty=format:%H%x09%an%x09%ad%x09%s', '--date=iso'],\n projectPath\n );\n\n if (!output) return [];\n\n return output.split('\\n').map((line) => {\n const [hash, author, date, message] = line.split('\\t');\n return { hash, author, date, message } as Commit;\n });\n}\n\nexport async function getLastCommit(projectPath: string): Promise<Commit | null> {\n const commits = await getRecentCommits(projectPath, 1);\n return commits[0] ?? null;\n}\n\nexport async function getStagedChanges(projectPath: string): Promise<Change[]> {\n const isRepo = await ensureRepo(projectPath);\n if (!isRepo) return [];\n\n const output = await execGit(['diff', '--cached', '--name-status'], projectPath);\n if (!output) return [];\n return parseNameStatus(output);\n}\n\nexport async function getUncommittedChanges(projectPath: string): Promise<Change[]> {\n const isRepo = await ensureRepo(projectPath);\n if (!isRepo) return [];\n\n const changes: Change[] = [];\n\n const unstaged = await execGit(['diff', '--name-status'], projectPath);\n if (unstaged) {\n changes.push(...parseNameStatus(unstaged));\n }\n\n const untracked = await execGit(['ls-files', '--others', '--exclude-standard'], projectPath);\n if (untracked) {\n changes.push(\n ...untracked\n .split('\\n')\n .map((p) => p.trim())\n .filter(Boolean)\n .map((p) => ({ status: '??', path: p }))\n );\n }\n\n return changes;\n}\n\n/**\n * Get a flat list of changed file paths in the working tree.\n * Convenience helper used by tooling (e.g. cache invalidation).\n *\n * Returns null if not a git repository.\n */\nexport async function getGitChangedFiles(projectPath: string): Promise<string[] | null> {\n const isRepo = await ensureRepo(projectPath);\n if (!isRepo) return null;\n\n const [staged, uncommitted] = await Promise.all([\n getStagedChanges(projectPath).catch(() => []),\n getUncommittedChanges(projectPath).catch(() => []),\n ]);\n\n const paths = new Set<string>();\n for (const change of [...staged, ...uncommitted]) {\n if (change.path) paths.add(change.path);\n if (change.oldPath) paths.add(change.oldPath);\n }\n\n return [...paths];\n}\n\nexport async function getDiff(projectPath: string, commitHash: string): Promise<string> {\n const isRepo = await ensureRepo(projectPath);\n if (!isRepo) return '';\n\n const diff = await execGit(['show', commitHash, '--unified=3', '--no-color'], projectPath);\n return diff ?? '';\n}\n\nexport async function getWorkingTreeDiff(projectPath: string, stagedOnly = false): Promise<string> {\n const isRepo = await ensureRepo(projectPath);\n if (!isRepo) return '';\n\n const args = stagedOnly ? ['diff', '--cached', '--unified=3', '--no-color'] : ['diff', '--unified=3', '--no-color'];\n const diff = await execGit(args, projectPath);\n return diff ?? '';\n}\n\nexport async function getUnpushedCommits(projectPath: string): Promise<Commit[]> {\n const isRepo = await ensureRepo(projectPath);\n if (!isRepo) return [];\n\n // Handles detached HEAD by falling back to HEAD if upstream missing\n const upstream = await execGit(['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}'], projectPath);\n if (!upstream) {\n return getRecentCommits(projectPath, 10);\n }\n\n const output = await execGit(['log', `${upstream}..HEAD`, '--pretty=format:%H%x09%an%x09%ad%x09%s', '--date=iso'], projectPath);\n if (!output) return [];\n\n return output.split('\\n').filter(Boolean).map((line) => {\n const [hash, author, date, message] = line.split('\\t');\n return { hash, author, date, message } as Commit;\n });\n}\n\nexport function resolveRepoPath(projectPath: string): string {\n const gitDir = path.join(projectPath, '.git');\n if (existsSync(gitDir)) return projectPath;\n return projectPath;\n}\n\n/**\n * Check if the given path is inside a git repository\n */\nexport async function isGitRepo(projectPath: string): Promise<boolean> {\n const result = await execGit(['rev-parse', '--is-inside-work-tree'], projectPath);\n return result === 'true';\n}\n\n/**\n * Get files changed since a given timestamp\n * Uses git log to find commits after timestamp, then gets affected files\n * Returns null if not a git repo or on error\n */\nexport async function getChangedFilesSinceTimestamp(\n projectPath: string,\n timestamp: number\n): Promise<string[] | null> {\n const isRepo = await isGitRepo(projectPath);\n if (!isRepo) return null;\n\n try {\n // Convert timestamp to ISO date for git\n const sinceDate = new Date(timestamp).toISOString();\n \n // Set timeout for git operations (5 seconds total)\n const GIT_TIMEOUT_MS = 5000;\n const startTime = Date.now();\n \n // Get all files that changed in commits since the timestamp\n // Use Promise.race to timeout if git operations take too long\n const committedChangesPromise = execGit(\n ['log', `--since=${sinceDate}`, '--name-only', '--pretty=format:'],\n projectPath\n );\n const committedChangesTimeout = new Promise<string | null>((resolve) => {\n setTimeout(() => resolve(null), GIT_TIMEOUT_MS);\n });\n const committedChanges = await Promise.race([committedChangesPromise, committedChangesTimeout]);\n\n // Check if we've exceeded timeout\n if (Date.now() - startTime > GIT_TIMEOUT_MS) {\n return null;\n }\n\n // Get currently modified files (staged + unstaged) - run in parallel with timeout\n const stagedPromise = execGit(['diff', '--cached', '--name-only'], projectPath);\n const unstagedPromise = execGit(['diff', '--name-only'], projectPath);\n const untrackedPromise = execGit(\n ['ls-files', '--others', '--exclude-standard'],\n projectPath\n );\n \n const timeoutPromise = new Promise<null>((resolve) => {\n setTimeout(() => resolve(null), Math.max(0, GIT_TIMEOUT_MS - (Date.now() - startTime)));\n });\n \n const [stagedChanges, unstagedChanges, untrackedFiles] = await Promise.race([\n Promise.all([stagedPromise, unstagedPromise, untrackedPromise]),\n timeoutPromise.then(() => [null, null, null] as const)\n ]);\n\n // Combine all changed files\n const changedFiles = new Set<string>();\n \n const addFiles = (output: string | null) => {\n if (output) {\n output.split('\\n')\n .map(f => f.trim())\n .filter(Boolean)\n .forEach(f => changedFiles.add(path.join(projectPath, f)));\n }\n };\n\n addFiles(committedChanges);\n addFiles(stagedChanges);\n addFiles(unstagedChanges);\n addFiles(untrackedFiles);\n\n return Array.from(changedFiles);\n } catch {\n return null;\n }\n}\n","/**\n * Command Runner (with audit logging)\n *\n * Goal: Whenever Trie runs a shell command, record:\n * - command string\n * - exit code\n * - duration\n * - optional (redacted) stdout/stderr\n */\nimport { exec, execFile, execSync, type ExecException } from 'node:child_process';\nimport { promisify } from 'node:util';\n\nimport {\n createAuditEntry,\n completeAuditEntry,\n logSkillExecution,\n type ExecutedCommand,\n type SkillExecution,\n} from './audit-logger.js';\n\nconst execAsync = promisify(exec);\nconst execFileAsync = promisify(execFile);\n\nexport type { ExecutedCommand, SkillExecution };\nexport type AuditTriggeredBy = SkillExecution['triggeredBy'];\n\nexport interface CommandAuditContext {\n /** Shown as `skillName` in audit logs; use something like `tool:pr-review` */\n actor: string;\n /** Where this came from in the product flow */\n triggeredBy: AuditTriggeredBy;\n /** Usually the working directory / repo path */\n targetPath: string;\n /** Optional string for `skillSource` */\n source?: string;\n}\n\nexport interface RunCommandOptions {\n cwd?: string;\n timeoutMs?: number;\n maxBuffer?: number;\n\n /** Capture stdout/stderr in the audit log */\n captureOutput?: boolean;\n /** Redact obvious secrets from captured output */\n redactOutput?: boolean;\n /** Max chars to keep per output stream */\n maxOutputChars?: number;\n}\n\nfunction redact(text: string): string {\n // Keep this conservative to avoid false redaction and avoid expensive processing.\n return text\n // Common key=value secrets\n .replace(/\\b(AWS|ANTHROPIC|OPENAI|GITHUB)_[A-Z0-9_]*\\s*=\\s*([^\\s\"'`]+)/gi, '$1_<REDACTED>=<REDACTED>')\n // Bearer tokens\n .replace(/\\bBearer\\s+[A-Za-z0-9\\-._~+/]+=*\\b/g, 'Bearer <REDACTED>')\n // GitHub tokens / generic tokens\n .replace(/\\bghp_[A-Za-z0-9]{20,}\\b/g, 'ghp_<REDACTED>')\n .replace(/\\b(?:xox[baprs]-)[A-Za-z0-9-]{10,}\\b/g, '<REDACTED_SLACK_TOKEN>')\n // AWS access key id (best-effort)\n .replace(/\\bAKIA[0-9A-Z]{16}\\b/g, 'AKIA<REDACTED>');\n}\n\nfunction clampOutput(text: string, maxChars: number): string {\n if (text.length <= maxChars) return text;\n return text.slice(0, maxChars) + `\\n…(truncated ${text.length - maxChars} chars)`;\n}\n\nfunction buildCommandRecord(command: string): ExecutedCommand {\n return {\n command,\n timestamp: new Date().toISOString(),\n };\n}\n\nasync function finalizeAndWrite(\n entry: SkillExecution,\n cmd: ExecutedCommand,\n outcome: { success: boolean; exitCode?: number; stdout?: string; stderr?: string; error?: string; startedAt: number },\n options?: Pick<RunCommandOptions, 'captureOutput' | 'redactOutput' | 'maxOutputChars'>\n): Promise<void> {\n const duration = Date.now() - outcome.startedAt;\n cmd.duration = duration;\n if (outcome.exitCode !== undefined) {\n cmd.exitCode = outcome.exitCode;\n }\n\n const captureOutput = options?.captureOutput ?? false;\n const redactOutput = options?.redactOutput ?? true;\n const maxOutputChars = options?.maxOutputChars ?? 2000;\n\n if (captureOutput) {\n const out = outcome.stdout ?? '';\n const err = outcome.stderr ?? '';\n cmd.stdout = redactOutput ? redact(clampOutput(out, maxOutputChars)) : clampOutput(out, maxOutputChars);\n cmd.stderr = redactOutput ? redact(clampOutput(err, maxOutputChars)) : clampOutput(err, maxOutputChars);\n }\n\n const completed = completeAuditEntry(entry, outcome.success, outcome.error);\n await logSkillExecution(completed);\n}\n\nexport async function runShellCommand(\n command: string,\n audit: CommandAuditContext,\n options?: RunCommandOptions\n): Promise<{ stdout: string; stderr: string; exitCode: number }> {\n const startedAt = Date.now();\n const entry = createAuditEntry(audit.actor, audit.source ?? 'trie', audit.triggeredBy, audit.targetPath);\n const cmd = buildCommandRecord(command);\n entry.commands?.push(cmd);\n\n try {\n const { stdout, stderr } = await execAsync(command, {\n cwd: options?.cwd,\n timeout: options?.timeoutMs,\n maxBuffer: options?.maxBuffer,\n });\n\n await finalizeAndWrite(entry, cmd, { success: true, exitCode: 0, stdout, stderr, startedAt }, options);\n return { stdout: stdout ?? '', stderr: stderr ?? '', exitCode: 0 };\n } catch (e) {\n const err = e as ExecException & { stdout?: unknown; stderr?: unknown; code?: unknown };\n const stdout = typeof err.stdout === 'string' ? err.stdout : '';\n const stderr = typeof err.stderr === 'string' ? err.stderr : '';\n const exitCode = typeof err.code === 'number' ? err.code : 1;\n\n await finalizeAndWrite(\n entry,\n cmd,\n { success: false, exitCode, stdout, stderr, error: err.message, startedAt },\n // Capture output for failures by default (so audits are useful)\n { ...options, captureOutput: options?.captureOutput ?? true }\n );\n\n return { stdout, stderr, exitCode };\n }\n}\n\nexport function runShellCommandSync(\n command: string,\n audit: CommandAuditContext,\n options?: Omit<RunCommandOptions, 'timeoutMs'> & { timeoutMs?: number }\n): { stdout: string; exitCode: number } {\n const startedAt = Date.now();\n const entry = createAuditEntry(audit.actor, audit.source ?? 'trie', audit.triggeredBy, audit.targetPath);\n const cmd = buildCommandRecord(command);\n entry.commands?.push(cmd);\n\n try {\n const stdout = execSync(command, {\n cwd: options?.cwd,\n timeout: options?.timeoutMs,\n maxBuffer: options?.maxBuffer,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n\n // Fire-and-forget write; sync APIs can’t await.\n void finalizeAndWrite(entry, cmd, { success: true, exitCode: 0, stdout, stderr: '', startedAt }, options);\n return { stdout: stdout ?? '', exitCode: 0 };\n } catch (e) {\n const err = e as ExecException & { stdout?: unknown; stderr?: unknown; status?: unknown };\n const stdout = typeof err.stdout === 'string' ? err.stdout : '';\n const stderr = typeof err.stderr === 'string' ? err.stderr : '';\n const exitCode = typeof err.status === 'number' ? err.status : 1;\n\n void finalizeAndWrite(\n entry,\n cmd,\n { success: false, exitCode, stdout, stderr, error: err.message, startedAt },\n { ...options, captureOutput: options?.captureOutput ?? true }\n );\n\n return { stdout, exitCode };\n }\n}\n\nexport async function runExecFile(\n file: string,\n args: string[],\n audit: CommandAuditContext,\n options?: Omit<RunCommandOptions, 'timeoutMs'> & { timeoutMs?: number }\n): Promise<{ stdout: string; stderr: string; exitCode: number }> {\n const startedAt = Date.now();\n const command = [file, ...args].join(' ');\n const entry = createAuditEntry(audit.actor, audit.source ?? 'trie', audit.triggeredBy, audit.targetPath);\n const cmd = buildCommandRecord(command);\n entry.commands?.push(cmd);\n\n try {\n const { stdout, stderr } = await execFileAsync(file, args, {\n cwd: options?.cwd,\n timeout: options?.timeoutMs,\n maxBuffer: options?.maxBuffer,\n });\n\n await finalizeAndWrite(entry, cmd, { success: true, exitCode: 0, stdout: String(stdout ?? ''), stderr: String(stderr ?? ''), startedAt }, options);\n return { stdout: String(stdout ?? ''), stderr: String(stderr ?? ''), exitCode: 0 };\n } catch (e) {\n const err = e as ExecException & { stdout?: unknown; stderr?: unknown; code?: unknown };\n const stdout = typeof err.stdout === 'string' ? err.stdout : '';\n const stderr = typeof err.stderr === 'string' ? err.stderr : '';\n const exitCode = typeof err.code === 'number' ? err.code : 1;\n\n await finalizeAndWrite(\n entry,\n cmd,\n { success: false, exitCode, stdout, stderr, error: err.message, startedAt },\n { ...options, captureOutput: options?.captureOutput ?? true }\n );\n return { stdout, stderr, exitCode };\n }\n}\n\n","/**\n * Audit logger stub\n *\n * Audit functionality has been integrated into the decision ledger.\n * This module exists to keep legacy CLI/tooling paths working without the old skills system.\n */\n\nexport interface AuditStatistics {\n totalScans: number;\n totalIssues: number;\n criticalCount: number;\n seriousCount: number;\n moderateCount: number;\n lowCount: number;\n totalExecutions: number;\n successfulExecutions: number;\n failedExecutions: number;\n uniqueSkills: number;\n totalCommands: number;\n blockedCommands: number;\n totalNetworkCalls: number;\n blockedNetworkCalls: number;\n}\n\nexport interface AuditEntry {\n id: string;\n timestamp: string;\n command: string;\n status: string;\n commands?: ExecutedCommand[];\n}\n\nexport interface ExecutedCommand {\n command: string;\n timestamp: string;\n exitCode?: number;\n duration?: number;\n stdout?: string;\n stderr?: string;\n}\n\nexport interface SkillExecution {\n skillName: string;\n skillSource: string;\n triggeredBy: 'scan' | 'mcp' | 'cli' | 'watch' | 'manual';\n targetPath: string;\n startedAt: string;\n completedAt?: string;\n success?: boolean;\n error?: string;\n commands?: ExecutedCommand[];\n}\n\nexport function formatAuditLog(_entry: AuditEntry): string {\n return 'Audit logging has been integrated into the decision ledger';\n}\n\nexport function getAuditStatistics(): AuditStatistics {\n return {\n totalScans: 0,\n totalIssues: 0,\n criticalCount: 0,\n seriousCount: 0,\n moderateCount: 0,\n lowCount: 0,\n totalExecutions: 0,\n successfulExecutions: 0,\n failedExecutions: 0,\n uniqueSkills: 0,\n totalCommands: 0,\n blockedCommands: 0,\n totalNetworkCalls: 0,\n blockedNetworkCalls: 0,\n };\n}\n\nexport function createAuditEntry(\n skillName: string,\n skillSource: string,\n triggeredBy: SkillExecution['triggeredBy'],\n targetPath: string\n): SkillExecution {\n return {\n skillName,\n skillSource,\n triggeredBy,\n targetPath,\n startedAt: new Date().toISOString(),\n commands: [],\n };\n}\n\nexport function completeAuditEntry(\n entry: SkillExecution,\n success: boolean,\n error?: string\n): SkillExecution {\n const result: SkillExecution = {\n ...entry,\n completedAt: new Date().toISOString(),\n success,\n };\n if (error !== undefined) {\n result.error = error;\n }\n return result;\n}\n\nexport async function logSkillExecution(_execution: SkillExecution): Promise<void> {\n // Stub - no-op\n}\n\nexport async function getRecentAuditLogs(_limit: number = 10): Promise<AuditEntry[]> {\n return [];\n}\n\nexport async function getSkillAuditLogs(_skillName: string): Promise<AuditEntry[]> {\n return [];\n}\n\n","/**\n * Cryptographic Key Management\n * \n * Ed25519 signature support for ledger entries.\n * Keys are stored in .trie/keys/ directory.\n * \n * Usage:\n * - generateKeyPair() - Create new signing key\n * - getOrCreateKeyPair() - Get existing or create new\n * - signData() - Sign arbitrary data\n * - verifySignature() - Verify a signature\n */\n\nimport * as ed25519 from '@noble/ed25519';\nimport { randomBytes } from 'crypto';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport { getTrieDirectory } from '../utils/workspace.js';\n\nexport interface KeyPair {\n publicKey: string; // Hex-encoded public key\n privateKey: string; // Hex-encoded private key\n}\n\nexport interface SignatureData {\n signature: string;\n publicKey: string;\n algorithm: 'Ed25519';\n signedAt: string;\n}\n\n/**\n * Get keys directory path\n */\nfunction getKeysDirectory(workDir?: string): string {\n const trieDir = getTrieDirectory(workDir || process.cwd());\n return join(trieDir, 'keys');\n}\n\n/**\n * Get the default key file path\n */\nfunction getDefaultKeyPath(workDir?: string): string {\n return join(getKeysDirectory(workDir), 'signing-key.json');\n}\n\n/**\n * Generate a new Ed25519 key pair\n */\nexport async function generateKeyPair(): Promise<KeyPair> {\n // Generate 32 random bytes for private key\n const privateKeyBytes = randomBytes(32);\n const publicKeyBytes = await ed25519.getPublicKeyAsync(privateKeyBytes);\n \n return {\n publicKey: Buffer.from(publicKeyBytes).toString('hex'),\n privateKey: Buffer.from(privateKeyBytes).toString('hex')\n };\n}\n\n/**\n * Save key pair to disk (encrypted would be better, but starting simple)\n */\nexport function saveKeyPair(keyPair: KeyPair, workDir?: string): void {\n const keysDir = getKeysDirectory(workDir);\n \n // Create keys directory if it doesn't exist\n if (!existsSync(keysDir)) {\n mkdirSync(keysDir, { recursive: true });\n }\n \n const keyPath = getDefaultKeyPath(workDir);\n const keyData = {\n ...keyPair,\n createdAt: new Date().toISOString(),\n version: 1\n };\n \n writeFileSync(keyPath, JSON.stringify(keyData, null, 2), 'utf-8');\n \n // Warn about security\n console.error('⚠️ Signing key created at:', keyPath);\n console.error(' Keep this file secure and add to .gitignore');\n}\n\n/**\n * Load key pair from disk\n */\nexport function loadKeyPair(workDir?: string): KeyPair | null {\n const keyPath = getDefaultKeyPath(workDir);\n \n if (!existsSync(keyPath)) {\n return null;\n }\n \n try {\n const keyData = JSON.parse(readFileSync(keyPath, 'utf-8'));\n return {\n publicKey: keyData.publicKey,\n privateKey: keyData.privateKey\n };\n } catch (error) {\n console.error('Failed to load signing key:', error);\n return null;\n }\n}\n\n/**\n * Get existing key pair or create a new one\n */\nexport async function getOrCreateKeyPair(workDir?: string): Promise<KeyPair> {\n const existing = loadKeyPair(workDir);\n if (existing) {\n return existing;\n }\n \n const newKeyPair = await generateKeyPair();\n saveKeyPair(newKeyPair, workDir);\n return newKeyPair;\n}\n\n/**\n * Sign arbitrary data with private key\n */\nexport async function signData(data: string, privateKey: string): Promise<string> {\n const dataBytes = Buffer.from(data, 'utf-8');\n const privateKeyBytes = Buffer.from(privateKey, 'hex');\n const signatureBytes = await ed25519.signAsync(dataBytes, privateKeyBytes);\n \n return Buffer.from(signatureBytes).toString('hex');\n}\n\n/**\n * Verify a signature\n */\nexport async function verifySignature(\n data: string,\n signature: string,\n publicKey: string\n): Promise<boolean> {\n try {\n const dataBytes = Buffer.from(data, 'utf-8');\n const signatureBytes = Buffer.from(signature, 'hex');\n const publicKeyBytes = Buffer.from(publicKey, 'hex');\n \n return await ed25519.verifyAsync(signatureBytes, dataBytes, publicKeyBytes);\n } catch (error) {\n console.error('Signature verification failed:', error);\n return false;\n }\n}\n\n/**\n * Sign a data hash and return signature metadata\n */\nexport async function signHash(hash: string, workDir?: string): Promise<SignatureData> {\n const keyPair = await getOrCreateKeyPair(workDir);\n const signature = await signData(hash, keyPair.privateKey);\n \n return {\n signature,\n publicKey: keyPair.publicKey,\n algorithm: 'Ed25519',\n signedAt: new Date().toISOString()\n };\n}\n\n/**\n * Verify a hash signature\n */\nexport async function verifyHashSignature(\n hash: string,\n signatureData: SignatureData\n): Promise<boolean> {\n if (signatureData.algorithm !== 'Ed25519') {\n console.error('Unsupported signature algorithm:', signatureData.algorithm);\n return false;\n }\n \n return await verifySignature(hash, signatureData.signature, signatureData.publicKey);\n}\n\n/**\n * Get the public key for the current workspace\n */\nexport function getPublicKey(workDir?: string): string | null {\n const keyPair = loadKeyPair(workDir);\n return keyPair?.publicKey || null;\n}\n\n/**\n * Check if signing keys exist\n */\nexport function hasSigningKey(workDir?: string): boolean {\n const keyPath = getDefaultKeyPath(workDir);\n return existsSync(keyPath);\n}\n","/**\n * Git Integration for Ledger\n * \n * Auto-commit ledger changes to provide:\n * - Distributed backup (every clone has a copy)\n * - Git's content-addressable storage (tamper-evident)\n * - History tracking via commit graph\n * - Remote backup via push\n * \n * Usage:\n * - autoCommitLedger() - Commit ledger changes after append\n * - isGitIntegrationEnabled() - Check if Git integration is on\n */\n\nimport { exec } from 'child_process';\nimport { promisify } from 'util';\nimport { existsSync } from 'fs';\nimport { join } from 'path';\nimport { getTrieDirectory } from '../utils/workspace.js';\n\nconst execAsync = promisify(exec);\n\nexport interface GitCommitResult {\n committed: boolean;\n commitHash?: string;\n error?: string;\n}\n\n/**\n * Check if Git integration is enabled for this project\n * \n * Git integration is enabled if:\n * 1. Project is a git repo\n * 2. .trie/config.json has gitIntegration: true (or doesn't exist, defaults to true)\n */\nexport async function isGitIntegrationEnabled(workDir: string): Promise<boolean> {\n try {\n // Check if git repo\n const gitDir = join(workDir, '.git');\n if (!existsSync(gitDir)) {\n return false;\n }\n \n // Check config (default to true if config doesn't exist)\n const configPath = join(getTrieDirectory(workDir), 'config.json');\n if (!existsSync(configPath)) {\n return true; // Default: enabled\n }\n \n const config = JSON.parse(await import('fs/promises').then(fs => fs.readFile(configPath, 'utf-8')));\n return config.gitIntegration !== false;\n } catch {\n return false;\n }\n}\n\n/**\n * Auto-commit ledger changes\n * \n * Commits ledger.json to git with a structured commit message.\n * This provides distributed backup and tamper-evident history.\n */\nexport async function autoCommitLedger(workDir: string, message?: string): Promise<GitCommitResult> {\n try {\n const enabled = await isGitIntegrationEnabled(workDir);\n if (!enabled) {\n return { committed: false, error: 'Git integration disabled' };\n }\n \n const ledgerPath = join(getTrieDirectory(workDir), 'memory', 'ledger.json');\n \n // Check if ledger has changes\n const { stdout: statusOutput } = await execAsync('git status --porcelain', { cwd: workDir });\n const hasLedgerChanges = statusOutput.includes('ledger.json');\n \n if (!hasLedgerChanges) {\n return { committed: false, error: 'No ledger changes to commit' };\n }\n \n // Stage ledger file\n await execAsync(`git add ${ledgerPath}`, { cwd: workDir });\n \n // Commit with structured message\n const commitMessage = message || 'ledger: append entries';\n await execAsync(\n `git commit -m \"${commitMessage}\"`,\n { cwd: workDir }\n );\n \n // Get commit hash\n const { stdout: hashOutput } = await execAsync('git rev-parse HEAD', { cwd: workDir });\n const commitHash = hashOutput.trim();\n \n return {\n committed: true,\n commitHash\n };\n } catch (error) {\n return {\n committed: false,\n error: error instanceof Error ? error.message : String(error)\n };\n }\n}\n\n/**\n * Enable or disable Git integration\n */\nexport async function setGitIntegration(workDir: string, enabled: boolean): Promise<void> {\n const configPath = join(getTrieDirectory(workDir), 'config.json');\n const fs = await import('fs/promises');\n \n let config: Record<string, any> = {};\n if (existsSync(configPath)) {\n config = JSON.parse(await fs.readFile(configPath, 'utf-8'));\n }\n \n config.gitIntegration = enabled;\n await fs.writeFile(configPath, JSON.stringify(config, null, 2), 'utf-8');\n}\n\n/**\n * Add .trie/keys/ to .gitignore\n * \n * Signing keys should NOT be committed to git.\n * This ensures they stay local and secure.\n */\nexport async function ensureKeysIgnored(workDir: string): Promise<void> {\n try {\n const gitignorePath = join(workDir, '.gitignore');\n const fs = await import('fs/promises');\n \n let gitignore = '';\n if (existsSync(gitignorePath)) {\n gitignore = await fs.readFile(gitignorePath, 'utf-8');\n }\n \n // Check if already ignored\n if (gitignore.includes('.trie/keys/')) {\n return;\n }\n \n // Add to gitignore\n const addition = '\\n# Trie signing keys (keep secure, do not commit)\\n.trie/keys/\\n';\n await fs.appendFile(gitignorePath, addition, 'utf-8');\n } catch (error) {\n console.error('Failed to update .gitignore:', error);\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,OAAO,UAAU,WAAW,M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WAAW,SAAU;AAAA,eAChB,WAAW,YAAa;AAAA,eACxB,WAAW,iBAAkB;AAAA,IACxC;AAAA,EACF;AAEA,QAAM,iBAAiB,eAAe,KAChC,mBAAmB,kBAAkB,eAAgB,MACvD;AAEJ,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB,KAAK,MAAM,iBAAiB,GAAG,IAAI;AAAA,EACrD;AACF;","names":["existsSync","join","existsSync","existsSync","existsSync","exec","promisify","existsSync","join","execAsync","promisify","exec","join","existsSync","join","existsSync","join","existsSync"]}
@@ -310,4 +310,4 @@ export {
310
310
  getProgressReporter,
311
311
  resetProgressReporter
312
312
  };
313
- //# sourceMappingURL=chunk-APMV77PU.js.map
313
+ //# sourceMappingURL=chunk-JKEEQAG2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/progress.ts"],"sourcesContent":["/**\n * Progress Reporter for Trie Agent\n * \n * Provides real-time feedback to users as the agent works.\n * Uses console.error because MCP clients display stderr to users.\n */\n\n/**\n * Global interactive mode flag\n * When enabled, suppresses all console output (handled by InteractiveDashboard instead)\n */\nlet _interactiveMode = false;\n\n/**\n * Enable or disable interactive mode\n * When enabled, all console output from ProgressReporter and AgentProgressReporter is suppressed\n * \n * NOTE: This only sets the flag. The caller should verify that process.stdin.isTTY\n * and process.stdin.setRawMode are available before enabling interactive mode.\n */\nexport function setInteractiveMode(enabled: boolean): void {\n _interactiveMode = enabled;\n}\n\n/**\n * Check if interactive mode is enabled\n */\nexport function isInteractiveMode(): boolean {\n return _interactiveMode;\n}\n\nexport type ProgressPhase = \n | 'init'\n | 'discovery'\n | 'reading'\n | 'analyzing'\n | 'ai-review'\n | 'prioritizing'\n | 'complete';\n\nexport interface ProgressCallback {\n (phase: ProgressPhase, message: string, detail?: string): void;\n}\n\n/**\n * Progress Reporter - streams status updates to the user\n */\nexport class ProgressReporter {\n private currentPhase: ProgressPhase = 'init';\n private startTime: number = Date.now();\n private phaseStartTime: number = Date.now();\n private verbose: boolean;\n\n constructor(options: { verbose?: boolean } = {}) {\n this.verbose = options.verbose ?? true;\n }\n\n /**\n * Report a status update\n */\n report(message: string, detail?: string): void {\n if (!this.verbose || _interactiveMode) return;\n \n const prefix = this.getPhaseIcon(this.currentPhase);\n const fullMessage = detail ? `${message}: ${detail}` : message;\n console.error(`${prefix} ${fullMessage}`);\n }\n\n /**\n * Start a new phase\n */\n startPhase(phase: ProgressPhase, message: string): void {\n this.currentPhase = phase;\n this.phaseStartTime = Date.now();\n this.report(message);\n }\n\n /**\n * Update within current phase\n */\n update(message: string, detail?: string): void {\n this.report(message, detail);\n }\n\n /**\n * Report progress on a file\n */\n file(action: string, filePath: string): void {\n // Show just the filename for cleaner output\n const fileName = filePath.split('/').pop() || filePath;\n this.report(action, fileName);\n }\n\n /**\n * Report an AI analysis step\n */\n ai(action: string, context?: string): void {\n if (_interactiveMode) return;\n const prefix = '[AI]';\n const message = context ? `${action}: ${context}` : action;\n console.error(`${prefix} ${message}`);\n }\n\n /**\n * Report a finding\n */\n finding(severity: 'critical' | 'serious' | 'moderate' | 'low', message: string): void {\n if (_interactiveMode) return;\n const labels = {\n critical: '[CRITICAL]',\n serious: '[SERIOUS]',\n moderate: '[MODERATE]',\n low: '[LOW]'\n };\n console.error(` ${labels[severity]} ${message}`);\n }\n\n /**\n * Complete current phase\n */\n completePhase(summary: string): void {\n const elapsed = Date.now() - this.phaseStartTime;\n this.report(`Done: ${summary}`, `(${elapsed}ms)`);\n }\n\n /**\n * Complete the entire operation\n */\n complete(summary: string): void {\n if (_interactiveMode) return;\n const totalElapsed = Date.now() - this.startTime;\n console.error('');\n console.error(`----------------------------------------`);\n console.error(`[COMPLETE] ${summary}`);\n console.error(` Total time: ${(totalElapsed / 1000).toFixed(2)}s`);\n console.error(`----------------------------------------`);\n console.error('');\n }\n\n /**\n * Report an error\n */\n error(message: string, detail?: string): void {\n if (_interactiveMode) return;\n const fullMessage = detail ? `${message}: ${detail}` : message;\n console.error(`[ERROR] ${fullMessage}`);\n }\n\n /**\n * Report a warning\n */\n warn(message: string, detail?: string): void {\n if (_interactiveMode) return;\n const fullMessage = detail ? `${message}: ${detail}` : message;\n console.error(`[WARN] ${fullMessage}`);\n }\n\n /**\n * Get icon for current phase\n */\n private getPhaseIcon(phase: ProgressPhase): string {\n const icons: Record<ProgressPhase, string> = {\n 'init': '>>',\n 'discovery': '>>',\n 'reading': '>>',\n 'analyzing': '>>',\n 'ai-review': '[AI]',\n 'prioritizing': '>>',\n 'complete': '[OK]'\n };\n return icons[phase] || '>>';\n }\n\n /**\n * Create a sub-reporter for a specific agent\n */\n forAgent(agentName: string): AgentProgressReporter {\n return new AgentProgressReporter(agentName, this.verbose);\n }\n}\n\n/**\n * Progress reporter scoped to a specific agent\n */\nexport class AgentProgressReporter {\n private agentName: string;\n private verbose: boolean;\n private issueCount: number = 0;\n private issuesBySeverity: Map<string, number> = new Map();\n private batchedIssues: Map<string, Array<{ severity: string; issue: string; file?: string; line?: number }>> = new Map();\n private criticalIssues: Array<{ severity: string; issue: string; file?: string; line?: number }> = [];\n private seriousIssues: Array<{ severity: string; issue: string; file?: string; line?: number }> = [];\n private flushTimer: NodeJS.Timeout | null = null;\n private readonly BATCH_DELAY_MS = 100; // Batch issues for 100ms before flushing\n\n constructor(agentName: string, verbose: boolean = true) {\n this.agentName = agentName;\n this.verbose = verbose;\n }\n\n start(): void {\n if (!this.verbose || _interactiveMode) return;\n console.error(`\\n[SCOUT] ${this.agentName.toUpperCase()} starting...`);\n }\n\n analyzing(_file: string): void {\n if (!this.verbose || _interactiveMode) return;\n // Suppress individual file analysis messages - they're too verbose\n // The progress updates from streaming manager will show file progress\n }\n\n aiReview(context: string): void {\n if (!this.verbose || _interactiveMode) return;\n // Suppress AI review messages - they're too verbose during watch mode\n // Only show if there are very few issues (indicating a focused scan)\n if (this.issueCount < 5) {\n console.error(` [AI] reviewing: ${context}`);\n }\n }\n\n found(severity: string, issue: string, file?: string, line?: number): void {\n this.issueCount++;\n \n // Track by severity\n const current = this.issuesBySeverity.get(severity) || 0;\n this.issuesBySeverity.set(severity, current + 1);\n\n // Store critical and serious issues for detailed output\n if (severity === 'critical') {\n this.criticalIssues.push({\n severity,\n issue,\n ...(file !== undefined ? { file } : {}),\n ...(line !== undefined ? { line } : {}),\n });\n // Flush critical issues immediately\n if (this.verbose && !_interactiveMode) {\n this.flushCriticalAndSerious();\n }\n } else if (severity === 'serious') {\n this.seriousIssues.push({\n severity,\n issue,\n ...(file !== undefined ? { file } : {}),\n ...(line !== undefined ? { line } : {}),\n });\n }\n\n // Batch similar issues together for cleaner output\n if (!this.verbose || _interactiveMode) return;\n\n // Normalize issue description for grouping (remove line numbers, file paths)\n const normalizedIssue = issue.replace(/at line \\d+/gi, '').replace(/in .+$/gi, '').trim();\n const key = `${severity}:${normalizedIssue}`;\n \n if (!this.batchedIssues.has(key)) {\n this.batchedIssues.set(key, []);\n }\n this.batchedIssues.get(key)!.push({\n severity,\n issue,\n ...(file !== undefined ? { file } : {}),\n ...(line !== undefined ? { line } : {}),\n });\n\n // Schedule flush (debounced) - but flush immediately for critical\n if (severity === 'critical') {\n this.flushBatchedIssues();\n } else {\n if (this.flushTimer) {\n clearTimeout(this.flushTimer);\n }\n this.flushTimer = setTimeout(() => this.flushBatchedIssues(), this.BATCH_DELAY_MS);\n }\n }\n\n private flushCriticalAndSerious(): void {\n // Always show critical issues immediately\n for (const issue of this.criticalIssues) {\n console.error(` [CRITICAL] Found: ${issue.issue}`);\n }\n this.criticalIssues = [];\n }\n\n private flushBatchedIssues(): void {\n if (!this.verbose || _interactiveMode) return;\n\n // Always show critical issues immediately (should already be flushed, but double-check)\n if (this.criticalIssues.length > 0) {\n this.flushCriticalAndSerious();\n }\n\n // Show serious issues (limit to first 10 to avoid spam)\n if (this.seriousIssues.length > 0) {\n for (const issue of this.seriousIssues.slice(0, 10)) {\n console.error(` [SERIOUS] Found: ${issue.issue}`);\n }\n if (this.seriousIssues.length > 10) {\n console.error(` ... and ${this.seriousIssues.length - 10} more serious issues`);\n }\n this.seriousIssues = [];\n }\n\n if (this.batchedIssues.size === 0) return;\n\n // For moderate and low issues, group similar ones together\n const moderateGroups: Array<{ pattern: string; count: number; examples: string[] }> = [];\n const lowGroups: Array<{ pattern: string; count: number; examples: string[] }> = [];\n\n for (const [key, issues] of this.batchedIssues.entries()) {\n const [severity, pattern = ''] = key.split(':', 2);\n const count = issues.length;\n const examples = issues.slice(0, 2).map(i => i.issue);\n\n if (severity === 'moderate') {\n moderateGroups.push({ pattern, count, examples });\n } else if (severity === 'low') {\n lowGroups.push({ pattern, count, examples });\n }\n }\n\n // Show moderate issues (grouped, max 5 groups)\n if (moderateGroups.length > 0) {\n for (const group of moderateGroups.slice(0, 5)) {\n if (group.count === 1) {\n console.error(` [MODERATE] Found: ${group.examples[0]}`);\n } else {\n console.error(` [MODERATE] Found: ${group.pattern} (${group.count} instances)`);\n }\n }\n if (moderateGroups.length > 5) {\n const remaining = moderateGroups.slice(5).reduce((sum, g) => sum + g.count, 0);\n console.error(` ... and ${remaining} more moderate issues`);\n }\n }\n\n // Show low issues (grouped, max 3 groups, only if not too many)\n // Suppress low issues if there are too many total issues\n if (lowGroups.length > 0 && this.issueCount < 200) {\n for (const group of lowGroups.slice(0, 3)) {\n if (group.count === 1) {\n console.error(` [LOW] Found: ${group.examples[0]}`);\n } else {\n console.error(` [LOW] Found: ${group.pattern} (${group.count} instances)`);\n }\n }\n if (lowGroups.length > 3) {\n const remaining = lowGroups.slice(3).reduce((sum, g) => sum + g.count, 0);\n console.error(` ... and ${remaining} more low-severity issues`);\n }\n } else if (lowGroups.length > 0) {\n // Too many issues - just show summary\n const totalLow = lowGroups.reduce((sum, g) => sum + g.count, 0);\n console.error(` [LOW] Found ${totalLow} low-severity issues (suppressed for brevity)`);\n }\n\n this.batchedIssues.clear();\n }\n\n complete(summary?: string): void {\n // Flush any remaining batched issues\n if (this.flushTimer) {\n clearTimeout(this.flushTimer);\n this.flushTimer = null;\n }\n this.flushBatchedIssues();\n\n if (!this.verbose || _interactiveMode) return;\n\n // Build a better summary\n const severityCounts: string[] = [];\n if (this.issuesBySeverity.get('critical')) {\n severityCounts.push(`${this.issuesBySeverity.get('critical')} critical`);\n }\n if (this.issuesBySeverity.get('serious')) {\n severityCounts.push(`${this.issuesBySeverity.get('serious')} serious`);\n }\n if (this.issuesBySeverity.get('moderate')) {\n severityCounts.push(`${this.issuesBySeverity.get('moderate')} moderate`);\n }\n if (this.issuesBySeverity.get('low')) {\n severityCounts.push(`${this.issuesBySeverity.get('low')} low`);\n }\n\n const severitySummary = severityCounts.length > 0 \n ? ` (${severityCounts.join(', ')})`\n : '';\n \n const msg = summary || `${this.issueCount} issues found${severitySummary}`;\n console.error(` Done: ${this.agentName}: ${msg}`);\n }\n\n getIssueCount(): number {\n return this.issueCount;\n }\n\n getIssuesBySeverity(): Map<string, number> {\n return new Map(this.issuesBySeverity);\n }\n}\n\n/**\n * Global singleton for easy access\n */\nlet globalReporter: ProgressReporter | null = null;\n\nexport function getProgressReporter(options?: { verbose?: boolean }): ProgressReporter {\n if (!globalReporter) {\n globalReporter = new ProgressReporter(options);\n }\n return globalReporter;\n}\n\nexport function resetProgressReporter(): void {\n globalReporter = null;\n}\n"],"mappings":";AAWA,IAAI,mBAAmB;AAShB,SAAS,mBAAmB,SAAwB;AACzD,qBAAmB;AACrB;AAKO,SAAS,oBAA6B;AAC3C,SAAO;AACT;AAkBO,IAAM,mBAAN,MAAuB;AAAA,EACpB,eAA8B;AAAA,EAC9B,YAAoB,KAAK,IAAI;AAAA,EAC7B,iBAAyB,KAAK,IAAI;AAAA,EAClC;AAAA,EAER,YAAY,UAAiC,CAAC,GAAG;AAC/C,SAAK,UAAU,QAAQ,WAAW;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,SAAiB,QAAuB;AAC7C,QAAI,CAAC,KAAK,WAAW,iBAAkB;AAEvC,UAAM,SAAS,KAAK,aAAa,KAAK,YAAY;AA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B;AACnB,qBAAiB,IAAI,iBAAiB,OAAO;AAAA,EAC/C;AACA,SAAO;AACT;AAEO,SAAS,wBAA8B;AAC5C,mBAAiB;AACnB;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getTrieDirectory
3
- } from "./chunk-SH7H3WRU.js";
3
+ } from "./chunk-7F2R2ITA.js";
4
4
 
5
5
  // src/context/graph.ts
6
6
  import crypto from "crypto";
@@ -399,4 +399,4 @@ var ContextGraph = class {
399
399
  export {
400
400
  ContextGraph
401
401
  };
402
- //# sourceMappingURL=chunk-FH335WL5.js.map
402
+ //# sourceMappingURL=chunk-JYWGYUKX.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isInteractiveMode
3
- } from "./chunk-APMV77PU.js";
3
+ } from "./chunk-JKEEQAG2.js";
4
4
 
5
5
  // src/utils/output-manager.ts
6
6
  import pc from "picocolors";
@@ -563,4 +563,4 @@ export {
563
563
  output,
564
564
  resetOutputManager
565
565
  };
566
- //# sourceMappingURL=chunk-TIMIKBY2.js.map
566
+ //# sourceMappingURL=chunk-KLMJKM63.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-6NLHFIYA.js";
4
4
  import {
5
5
  getTrieDirectory
6
- } from "./chunk-SH7H3WRU.js";
6
+ } from "./chunk-7F2R2ITA.js";
7
7
 
8
8
  // src/context/incident-index.ts
9
9
  import path2 from "path";
@@ -170,4 +170,4 @@ var IncidentIndex = class _IncidentIndex {
170
170
  export {
171
171
  IncidentIndex
172
172
  };
173
- //# sourceMappingURL=chunk-4C67GV3O.js.map
173
+ //# sourceMappingURL=chunk-KYKADM7P.js.map
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-43X6JBEM.js";
8
8
  import {
9
9
  getTrieDirectory
10
- } from "./chunk-SH7H3WRU.js";
10
+ } from "./chunk-7F2R2ITA.js";
11
11
 
12
12
  // src/agent/project-state.ts
13
13
  import { mkdir, readFile } from "fs/promises";
@@ -686,4 +686,4 @@ function getProjectState(projectPath) {
686
686
  export {
687
687
  getProjectState
688
688
  };
689
- //# sourceMappingURL=chunk-CU5VDH6F.js.map
689
+ //# sourceMappingURL=chunk-L4FODDDB.js.map
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  getInsightStore
3
- } from "./chunk-OTQEFXHU.js";
3
+ } from "./chunk-T7UAH7GE.js";
4
4
  import {
5
5
  getProjectState
6
- } from "./chunk-CU5VDH6F.js";
6
+ } from "./chunk-L4FODDDB.js";
7
7
  import {
8
8
  getMemoryStats,
9
9
  searchIssues
10
- } from "./chunk-QH77RQB3.js";
10
+ } from "./chunk-4ZAFQEP6.js";
11
11
 
12
12
  // src/agent/goal-manager.ts
13
13
  import { basename } from "path";
@@ -648,4 +648,4 @@ export {
648
648
  getGoalManager,
649
649
  clearGoalManagers
650
650
  };
651
- //# sourceMappingURL=chunk-ILGMFND2.js.map
651
+ //# sourceMappingURL=chunk-LFNH3CSN.js.map
@@ -1,38 +1,38 @@
1
1
  import {
2
2
  getGoalManager
3
- } from "./chunk-ILGMFND2.js";
3
+ } from "./chunk-LFNH3CSN.js";
4
4
  import {
5
5
  getHypothesisEngine
6
- } from "./chunk-72KSLD7A.js";
6
+ } from "./chunk-NVZZUUEU.js";
7
7
  import {
8
8
  getInsightStore
9
- } from "./chunk-OTQEFXHU.js";
9
+ } from "./chunk-T7UAH7GE.js";
10
10
  import {
11
11
  GotchaPredictor,
12
12
  SlackIntegration,
13
13
  findCrossProjectPatterns,
14
14
  recordToGlobalMemory
15
- } from "./chunk-B2AHQ2IR.js";
16
- import {
17
- getStorage
18
- } from "./chunk-FG467PDD.js";
15
+ } from "./chunk-OWSGJUUR.js";
19
16
  import {
20
17
  ContextGraph
21
- } from "./chunk-FH335WL5.js";
18
+ } from "./chunk-JYWGYUKX.js";
22
19
  import {
23
20
  isAIAvailable,
24
21
  runAIAnalysis
25
- } from "./chunk-FPEMP54L.js";
22
+ } from "./chunk-UL337UDQ.js";
26
23
  import {
27
24
  getProjectState
28
- } from "./chunk-CU5VDH6F.js";
25
+ } from "./chunk-L4FODDDB.js";
26
+ import {
27
+ getStorage
28
+ } from "./chunk-ALSCZ7WR.js";
29
29
  import {
30
30
  autoResolveIssues,
31
31
  getHistoricalInsights,
32
32
  getIssueHash,
33
33
  searchIssues,
34
34
  storeIssues
35
- } from "./chunk-QH77RQB3.js";
35
+ } from "./chunk-4ZAFQEP6.js";
36
36
 
37
37
  // src/agent/trie-agent.ts
38
38
  import { basename as basename2 } from "path";
@@ -1322,9 +1322,9 @@ var TrieAgent = class {
1322
1322
  }
1323
1323
  if (issues.length >= 5 && this.canCreateInsight("pattern-discovery")) {
1324
1324
  try {
1325
- const { IncidentIndex } = await import("./incident-index-BWW2UEY7.js");
1325
+ const { IncidentIndex } = await import("./incident-index-7CAXUNTL.js");
1326
1326
  const { TriePatternDiscovery } = await import("./pattern-discovery-F7LU5K6E.js");
1327
- const { ContextGraph: ContextGraph2 } = await import("./graph-J4OGTYCO.js");
1327
+ const { ContextGraph: ContextGraph2 } = await import("./graph-JO7GG65P.js");
1328
1328
  const graph = new ContextGraph2(this.projectPath);
1329
1329
  const incidentIndex = await IncidentIndex.build(graph, this.projectPath);
1330
1330
  const discovery = new TriePatternDiscovery(graph, incidentIndex);
@@ -1581,7 +1581,7 @@ var TrieAgent = class {
1581
1581
  await this.projectState.recordScan();
1582
1582
  try {
1583
1583
  const riskLevel = issues.filter((i) => i.severity === "critical").length > 0 ? "critical" : issues.filter((i) => i.severity === "serious").length >= 3 ? "high" : issues.length > 10 ? "medium" : "low";
1584
- const { calculateAdaptiveScanFrequency } = await import("./goal-manager-IGUMDGCA.js");
1584
+ const { calculateAdaptiveScanFrequency } = await import("./goal-manager-5QDITJKE.js");
1585
1585
  const result = await calculateAdaptiveScanFrequency(riskLevel);
1586
1586
  await this.projectState.setScanFrequency(result.frequencyMs);
1587
1587
  } catch {
@@ -1810,4 +1810,4 @@ export {
1810
1810
  TrieAgent,
1811
1811
  getTrieAgent
1812
1812
  };
1813
- //# sourceMappingURL=chunk-GAL7OIYU.js.map
1813
+ //# sourceMappingURL=chunk-LJISDV3A.js.map
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  getInsightStore
3
- } from "./chunk-OTQEFXHU.js";
3
+ } from "./chunk-T7UAH7GE.js";
4
4
  import {
5
5
  getProjectState
6
- } from "./chunk-CU5VDH6F.js";
6
+ } from "./chunk-L4FODDDB.js";
7
7
  import {
8
8
  searchIssues
9
- } from "./chunk-QH77RQB3.js";
9
+ } from "./chunk-4ZAFQEP6.js";
10
10
 
11
11
  // src/agent/hypothesis.ts
12
12
  import { dirname } from "path";
@@ -134,7 +134,7 @@ var HypothesisEngine = class {
134
134
  * This enables fully agentic hypothesis creation based on actual codebase observations
135
135
  */
136
136
  async generateHypothesesWithAI(context) {
137
- const { isAIAvailable, runAIAnalysis } = await import("./client-INNE2GGZ.js");
137
+ const { isAIAvailable, runAIAnalysis } = await import("./client-ZHOLZTRW.js");
138
138
  if (!isAIAvailable()) {
139
139
  return [];
140
140
  }
@@ -724,4 +724,4 @@ export {
724
724
  clearHypothesisEngines,
725
725
  gatherEvidenceForHypothesis
726
726
  };
727
- //# sourceMappingURL=chunk-72KSLD7A.js.map
727
+ //# sourceMappingURL=chunk-NVZZUUEU.js.map