MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / handleExport

Function handleExport

apps/kimi-code/src/cli/sub/export.ts:62–105  ·  view source on GitHub ↗
(
  deps: ExportDeps,
  sessionId: string | undefined,
  output: string | undefined,
  opts: ExportOptions,
)

Source from the content-addressed store, hash-verified

60}
61
62export async function handleExport(
63 deps: ExportDeps,
64 sessionId: string | undefined,
65 output: string | undefined,
66 opts: ExportOptions,
67): Promise<void> {
68 const requestedId = normalizeOptionalSessionId(sessionId);
69 const previousSummary = requestedId === undefined ? await findPreviousSession(deps) : undefined;
70
71 let resolvedId: string;
72 if (requestedId !== undefined) {
73 resolvedId = requestedId;
74 } else {
75 if (previousSummary === undefined) {
76 deps.stderr.write('No previous session found to export.\n');
77 deps.exit(1);
78 }
79 resolvedId = previousSummary.id;
80 if (!opts.yes) {
81 const confirmed = await deps.confirmPreviousSession(toPreviousSessionSummary(previousSummary));
82 if (!confirmed) {
83 deps.stdout.write('Export cancelled.\n');
84 return;
85 }
86 }
87 }
88
89 try {
90 const installSource = await deps.getInstallSource();
91 const shellEnv = deps.getShellEnv();
92 const result = await deps.exportSession({
93 id: resolvedId,
94 version: deps.version,
95 installSource,
96 shellEnv,
97 ...(output === undefined ? {} : { outputPath: output }),
98 ...(opts.includeGlobalLog ? { includeGlobalLog: true } : {}),
99 });
100 deps.stdout.write(`${result.zipPath}\n`);
101 } catch (error) {
102 deps.stderr.write(`${errorMessage(error)}\n`);
103 deps.exit(1);
104 }
105}
106
107export function registerExportCommand(parent: Command, deps?: Partial<ExportDeps>): void {
108 parent

Callers 2

runExportFunction · 0.90
registerExportCommandFunction · 0.85

Calls 7

findPreviousSessionFunction · 0.85
toPreviousSessionSummaryFunction · 0.85
errorMessageFunction · 0.70
writeMethod · 0.65
exitMethod · 0.65
exportSessionMethod · 0.45

Tested by 1

runExportFunction · 0.72