MCPcopy Index your code
hub / github.com/anomalyco/opencode / sanitize

Function sanitize

packages/opencode/src/cli/cmd/export.ts:163–220  ·  view source on GitHub ↗
(data: { info: Session.Info; messages: SessionV1.WithParts[] })

Source from the content-addressed store, hash-verified

161const partFn = part
162
163function sanitize(data: { info: Session.Info; messages: SessionV1.WithParts[] }) {
164 return {
165 info: {
166 ...data.info,
167 title: redact("session-title", data.info.id, data.info.title),
168 directory: redact("session-directory", data.info.id, data.info.directory),
169 summary: !data.info.summary
170 ? data.info.summary
171 : {
172 ...data.info.summary,
173 diffs: diff("session-diff", data.info.summary.diffs),
174 },
175 revert: !data.info.revert
176 ? data.info.revert
177 : {
178 ...data.info.revert,
179 snapshot:
180 data.info.revert.snapshot === undefined
181 ? undefined
182 : redact("revert-snapshot", data.info.id, data.info.revert.snapshot),
183 diff:
184 data.info.revert.diff === undefined
185 ? undefined
186 : redact("revert-diff", data.info.id, data.info.revert.diff),
187 },
188 },
189 messages: data.messages.map((msg) => ({
190 info:
191 msg.info.role === "user"
192 ? {
193 ...msg.info,
194 system: msg.info.system === undefined ? undefined : redact("system", msg.info.id, msg.info.system),
195 summary: !msg.info.summary
196 ? msg.info.summary
197 : {
198 ...msg.info.summary,
199 title:
200 msg.info.summary.title === undefined
201 ? undefined
202 : redact("summary-title", msg.info.id, msg.info.summary.title),
203 body:
204 msg.info.summary.body === undefined
205 ? undefined
206 : redact("summary-body", msg.info.id, msg.info.summary.body),
207 diffs: diff("message-diff", msg.info.summary.diffs),
208 },
209 }
210 : {
211 ...msg.info,
212 path: {
213 cwd: redact("cwd", msg.info.id, msg.info.path.cwd),
214 root: redact("root", msg.info.id, msg.info.path.root),
215 },
216 },
217 parts: msg.parts.map(partFn),
218 })),
219 }
220}

Callers 1

export.tsFile · 0.70

Calls 2

redactFunction · 0.85
diffFunction · 0.70

Tested by

no test coverage detected