bcd194ee5d
The AI agent (MCP + in-app chat) saw ALL comments incl. resolved via two channels, cluttering its context and breaking fragment search. Default now: the agent sees only ACTIVE discussions; resolved is opt-in. Active anchors and threads are always kept. Channel 1 — resolved comment anchors on agent reads (converter option): `convertProseMirrorToMarkdown(content, options?)` gains `options.dropResolvedCommentAnchors` (default false — zero change for every existing caller incl. git-sync). Both `case "comment"` emitters (top-level and the raw-HTML inlineToHtml path) emit BARE text (no `<span data-comment-id>`) when `resolved && the flag`; active anchors keep their wrapper. mcp `getPage` passes the flag; `export_page_markdown` does NOT (lossless export must preserve resolved anchors — that is why it is an opt-in option, not unconditional); `get_page_json` is untouched (lossless PM JSON). Built on the #293 package converter. Channel 2 — `list_comments` default active-only: `listComments(pageId, includeResolved=false)` now returns `{ items, resolvedThreadsHidden }` (was a bare array). By default a RESOLVED top-level thread is hidden wholesale — the root AND every reply anchored to it (a thread is gated only by its root's resolvedAt; a resolved reply under an ACTIVE root stays). `resolvedThreadsHidden` counts hidden threads so the agent knows to re-query. `includeResolved:true` returns everything. The `includeResolved` param is added to both tool registrations (MCP index.ts + in-app ai-chat-tools.service.ts); `DocmostClientLike` signature updated. Server `findPageComments` is NOT touched — the web UI's tabs depend on the full feed; filtering is only at the mcp-client level. All internal call sites (export_page_markdown / checkNewComments / transformPage) updated to `.items` with `includeResolved:true` to keep their full-feed behavior. The comment model is assumed FLAT (a reply's parentCommentId points at the thread root) — documented in the filter; a future reply-of-reply model would need a root-walk there. Tests: resolved-comment-anchors.test.ts (6 — anchor dropped with flag / kept without, for BOTH emitters; active always kept); list-comments-resolved.test.mjs (4 — resolved thread+reply hidden + counter; includeResolved:true returns all; an ACTIVE thread with a RESOLVED reply is NOT hidden). package vitest: 664 passed; tsc clean. mcp: node --test 458 passed; tsc clean. apps/server + git-sync: tsc clean (converter option default-off). NOTE: based on feat/293-B (#293/#326 STEP 5) — the converter lives in the package; this PR is stacked on #333 and its base retargets to develop once #333 merges. mcp/build is gitignored (not committed). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
47 lines
1.9 KiB
TypeScript
47 lines
1.9 KiB
TypeScript
/**
|
|
* Public surface of the pure converter (`lib/`). This barrel re-exports the
|
|
* PURE, IO-free pieces the sync engine needs: the self-contained markdown
|
|
* (de)serializers, the lossless ProseMirror <-> Markdown converter, the
|
|
* markdown -> ProseMirror import path, and semantic canonicalization for the
|
|
* round-trip idempotency check (SPEC §11).
|
|
*
|
|
* There is no REST client, websocket/collab write-path, auth-utils or page-lock
|
|
* here — the gitmost server writes natively.
|
|
*/
|
|
export {
|
|
serializeDocmostMarkdown,
|
|
parseDocmostMarkdown,
|
|
serializeDocmostMarkdownBody,
|
|
} from "./markdown-document.js";
|
|
export type { DocmostMdMeta } from "./markdown-document.js";
|
|
|
|
export { convertProseMirrorToMarkdown } from "./markdown-converter.js";
|
|
export type { ConvertProseMirrorToMarkdownOptions } from "./markdown-converter.js";
|
|
|
|
export { markdownToProseMirror } from "./markdown-to-prosemirror.js";
|
|
|
|
// The Docmost tiptap schema mirror. Exposed so consumers (and the sync
|
|
// engine's schema-validity regression tests) can build the exact ProseMirror
|
|
// schema the converter targets.
|
|
export { docmostExtensions } from "./docmost-schema.js";
|
|
|
|
// Schema-adjacent sanitizers used by consumers (mcp) so the single canonical,
|
|
// alias-aware / allowlist implementations live ONLY here (no drifting copies).
|
|
export { clampCalloutType, sanitizeCssColor } from "./docmost-schema.js";
|
|
|
|
// Attached-comment convention (#293 canon #9/#4/#8): the reusable primitives
|
|
// the serializer/parser use to encode attrs that have no native markdown syntax
|
|
// as trailing `<!--name {json}-->` comments.
|
|
export {
|
|
attachedCommentFor,
|
|
standaloneCommentFor,
|
|
parseAttachedComment,
|
|
} from "./attached-comment.js";
|
|
export type { AttachedComment } from "./attached-comment.js";
|
|
|
|
export {
|
|
canonicalizeContent,
|
|
docsCanonicallyEqual,
|
|
} from "./canonicalize.js";
|
|
export { parsePageFile, serializePageFile } from "./page-file.js";
|