@triedotdev/mcp 1.0.164 → 1.0.166
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -2
- package/dist/{chunk-5TRCQAOE.js → chunk-2Z3TQNNK.js} +16 -5
- package/dist/chunk-2Z3TQNNK.js.map +1 -0
- package/dist/{chunk-5BYSJ7XT.js → chunk-GTKYBOXL.js} +13 -2
- package/dist/{chunk-5BYSJ7XT.js.map → chunk-GTKYBOXL.js.map} +1 -1
- package/dist/{chunk-D6E4Q4I6.js → chunk-HOGKPDZA.js} +302 -58
- package/dist/chunk-HOGKPDZA.js.map +1 -0
- package/dist/{chunk-LR46VMIE.js → chunk-JEZ7XJQN.js} +5 -5
- package/dist/{chunk-ERMLZJTK.js → chunk-JNUOW2JS.js} +13 -13
- package/dist/{chunk-62JD7MIS.js → chunk-LG5CBK6A.js} +15 -35
- package/dist/chunk-LG5CBK6A.js.map +1 -0
- package/dist/{chunk-LLDZDU2Y.js → chunk-LR5M4RTN.js} +79 -1
- package/dist/chunk-LR5M4RTN.js.map +1 -0
- package/dist/{chunk-Y4B3VEL7.js → chunk-MVVPJ73K.js} +438 -202
- package/dist/chunk-MVVPJ73K.js.map +1 -0
- package/dist/chunk-OBQ74FOU.js +27 -0
- package/dist/chunk-OBQ74FOU.js.map +1 -0
- package/dist/{chunk-IRZXBQVQ.js → chunk-S36IO3EE.js} +134 -101
- package/dist/chunk-S36IO3EE.js.map +1 -0
- package/dist/{chunk-HFVPHQL3.js → chunk-TQOO6A4G.js} +9 -9
- package/dist/{chunk-OKK4QNK3.js → chunk-UXRW2YSP.js} +86 -12
- package/dist/chunk-UXRW2YSP.js.map +1 -0
- package/dist/{chunk-ACU3IXZG.js → chunk-ZKKKLRZZ.js} +7 -7
- package/dist/cli/main.js +215 -57
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/yolo-daemon.js +15 -14
- package/dist/cli/yolo-daemon.js.map +1 -1
- package/dist/{fast-analyzer-LLZ6FLP5.js → fast-analyzer-NJQO3TFD.js} +3 -3
- package/dist/{goal-manager-D6XKE3FY.js → goal-manager-DVX24UPZ.js} +5 -5
- package/dist/{goal-validator-4DDL7NBP.js → goal-validator-6Y5CDEMJ.js} +5 -5
- package/dist/{hypothesis-RI3Q33JB.js → hypothesis-UKPGOYY2.js} +5 -5
- package/dist/index.js +16 -15
- package/dist/index.js.map +1 -1
- package/dist/{issue-store-DUR5UTYK.js → issue-store-UZAPI5DU.js} +3 -3
- package/dist/{ledger-ZTR63P3L.js → ledger-CNFCJKHX.js} +8 -2
- package/dist/project-state-AHPA77SM.js +28 -0
- package/dist/server/mcp-server.js +16 -15
- package/dist/sync-M2FSWPBC.js +12 -0
- package/dist/{tiered-storage-FHHAJR4P.js → tiered-storage-OP74NPJY.js} +2 -2
- package/dist/tiered-storage-OP74NPJY.js.map +1 -0
- package/dist/{trie-agent-NYSPGZYS.js → trie-agent-6SWUHCVO.js} +12 -12
- package/dist/trie-agent-6SWUHCVO.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-5TRCQAOE.js.map +0 -1
- package/dist/chunk-62JD7MIS.js.map +0 -1
- package/dist/chunk-D6E4Q4I6.js.map +0 -1
- package/dist/chunk-IRZXBQVQ.js.map +0 -1
- package/dist/chunk-LLDZDU2Y.js.map +0 -1
- package/dist/chunk-OKK4QNK3.js.map +0 -1
- package/dist/chunk-Y4B3VEL7.js.map +0 -1
- /package/dist/{chunk-LR46VMIE.js.map → chunk-JEZ7XJQN.js.map} +0 -0
- /package/dist/{chunk-ERMLZJTK.js.map → chunk-JNUOW2JS.js.map} +0 -0
- /package/dist/{chunk-HFVPHQL3.js.map → chunk-TQOO6A4G.js.map} +0 -0
- /package/dist/{chunk-ACU3IXZG.js.map → chunk-ZKKKLRZZ.js.map} +0 -0
- /package/dist/{fast-analyzer-LLZ6FLP5.js.map → fast-analyzer-NJQO3TFD.js.map} +0 -0
- /package/dist/{goal-manager-D6XKE3FY.js.map → goal-manager-DVX24UPZ.js.map} +0 -0
- /package/dist/{goal-validator-4DDL7NBP.js.map → goal-validator-6Y5CDEMJ.js.map} +0 -0
- /package/dist/{hypothesis-RI3Q33JB.js.map → hypothesis-UKPGOYY2.js.map} +0 -0
- /package/dist/{issue-store-DUR5UTYK.js.map → issue-store-UZAPI5DU.js.map} +0 -0
- /package/dist/{ledger-ZTR63P3L.js.map → ledger-CNFCJKHX.js.map} +0 -0
- /package/dist/{tiered-storage-FHHAJR4P.js.map → project-state-AHPA77SM.js.map} +0 -0
- /package/dist/{trie-agent-NYSPGZYS.js.map → sync-M2FSWPBC.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
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,MAAM,cAAc;AACzD,SAAS,cAAAA,mBAAkB;AAC3B,SAAS,YAAY,oBAAoB;AACzC,SAAS,gBAAgB;AACzB,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,QAAAC,aAAY;;;ACNrB,SAAS,kBAAkB;AAC3B,OAAO,UAAU;;;ACQjB,SAAS,MAAM,UAAU,gBAAoC;AAC7D,SAAS,iBAAiB;;;AC2CnB,SAAS,eAAe,QAA4B;AACzD,SAAO;AACT;AAEO,SAAS,qBAAsC;AACpD,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,eAAe;AAAA,IACf,cAAc;AAAA,IACd,eAAe;AAAA,IACf,UAAU;AAAA,IACV,iBAAiB;AAAA,IACjB,sBAAsB;AAAA,IACtB,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,mBAAmB;AAAA,IACnB,qBAAqB;AAAA,EACvB;AACF;AAEO,SAAS,iBACd,WACA,aACA,aACA,YACgB;AAChB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,IAClC,UAAU,CAAC;AAAA,EACb;AACF;AAEO,SAAS,mBACd,OACA,SACA,OACgB;AAChB,QAAM,SAAyB;AAAA,IAC7B,GAAG;AAAA,IACH,cAAa,oBAAI,KAAK,GAAE,YAAY;AAAA,IACpC;AAAA,EACF;AACA,MAAI,UAAU,QAAW;AACvB,WAAO,QAAQ;AAAA,EACjB;AACA,SAAO;AACT;AAEA,eAAsB,kBAAkB,YAA2C;AAEnF;AAEA,eAAsB,mBAAmB,SAAiB,IAA2B;AACnF,SAAO,CAAC;AACV;;;AD9FA,I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B;AACpB,MAAI,mBAAmB;AACvB,MAAI,iBAAiB;AAErB,aAAW,SAAS,QAAQ;AAC1B,eAAW,SAAS,MAAM,SAAS;AACjC;AACA,YAAM,SAAS,MAAM,UAAU;AAE/B,UAAI,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"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|