import { Command } from 'commander'; import { AuthStore } from '../lib/auth.js'; import { noAccountMessage } from '../lib/account-guidance.js'; import { getWorkspaceDir } from '../lib/init-command.js'; import { formatLoadReport, loadContext } from '../lib/load-context.js'; import { readStartupContext } from '../lib/load-startup-context.js'; export interface LoadCommandDependencies { authStore?: AuthStore; } /** Read the latest prepared report and current local persona/memory without synchronizing Hub or participation. */ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): Command { return new Command('load') .description('Read persona, memory and prepared capability information after connecting') .action(() => { const authStore = dependencies.authStore ?? new AuthStore(); const profile = authStore.getActive(); if (!profile) throw new Error(noAccountMessage('load')); let saved: ReturnType | undefined; try { saved = readStartupContext(getWorkspaceDir(), profile); } catch { // Local persona and memory remain available even without a prepared report. } console.log(JSON.stringify({ schema: 'ccl.load.v3', ...formatLoadReport(loadContext(authStore), saved) }, null, 2)); }); }