MCPcopy Create free account
hub / github.com/anomalyco/opencode / readCommentMetadata

Function readCommentMetadata

packages/app/src/utils/comment-note.ts:38–54  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

36}
37
38export function readCommentMetadata(value: unknown) {
39 if (!value || typeof value !== "object") return
40 const meta = (value as { opencodeComment?: unknown }).opencodeComment
41 if (!meta || typeof meta !== "object") return
42 const path = (meta as { path?: unknown }).path
43 const comment = (meta as { comment?: unknown }).comment
44 if (typeof path !== "string" || typeof comment !== "string") return
45 const preview = (meta as { preview?: unknown }).preview
46 const origin = (meta as { origin?: unknown }).origin
47 return {
48 path,
49 selection: selection((meta as { selection?: unknown }).selection),
50 comment,
51 preview: typeof preview === "string" ? preview : undefined,
52 origin: origin === "review" || origin === "file" ? origin : undefined,
53 } satisfies PromptComment
54}
55
56export function formatCommentNote(input: { path: string; selection?: FileSelection; comment: string }) {
57 const start = input.selection ? Math.min(input.selection.startLine, input.selection.endLine) : undefined

Callers 1

fromPartFunction · 0.90

Calls 1

selectionFunction · 0.70

Tested by

no test coverage detected