Repository navigation
Conversation
There was a problem hiding this comment.
Approve with nits (2 P3)
Scope: base main, merge base 77abdcb3, 1 commit, 5 files reviewed at 9e2aebab. Loaded ponytail-review; coderbook and karpathy-guidelines were not loaded (their criteria were applied from the review skill's checklist). Ran in a separate session.
Findings
P3
-
Pages that start with a BOM no longer get their links rewritten (
packages/document-files/src/index.ts:88-94)
micromark drops a leadingU+FEFFand does not count it inposition.offset, so every slice is off by one character. I ran the helper on"# T\n\n[a](t.md) x": the callback got"\n[a](t.md", not"[a](t.md)". InmemoryWikiFilesthe anchored regex then fails to match, so every internal link on that page is published unchanged and points at the old path. The old global regex handled this case. The output is never corrupted, because the slice goes back unchanged. Fix: strip a leading BOM before parsing and add it back to the result, or add the BOM length to the offsets. -
A link title that contains
](is no longer rewritten (apps/node-services/src/memory/published-memory-files.ts:89)
^(\[[\s\S]*\]\()is greedy, which the nested-code-label case needs, but it means[a](t.md "x ](y")matches the](inside the title. The href is parsed asy", the lookup fails, and the link stays unchanged. The old regex ([^\]\n]*label plus a title group) rewrote it. This is rare. A sturdier fix is to haverewriteMarkdownLinkSourcespass the parsed node (node.urland the label's end offset fromchildren.at(-1).position) so the caller doesn't parse the destination out of the source again.
Verified as fine
- Traversal order:
markdownNodes(packages/document-files/src/index.ts:70-77) is a pre-order DFS using a reversed-push stack, so link nodes arrive in document order and theoffsetcursor only moves forward. Links can't nest, so thestart < offsetguard never fires on valid input. - Offsets are JS string indices for CRLF, tabs in lists and blockquotes, and astral emoji. I ran the helper on
"# T\r\n\r\n- \t[a](t.md) b\r\n","> \t[a](t.md) 😀 [b](u.md)\n","😀😀 [a](t.md)\n"and"- a\n\t- [b](t.md)\n", and each slice was exactly the link source. - Escaped bracket
\[x](y), indented code, fenced code, quoted fences and inline code yield nolinknode, so their text is kept. A double backslash\\[a](t.md)is still treated as a real link, which is correct. - GFM autolink literals and email autolinks are
linknodes, but their source doesn't start with[, so the anchored regex returns them unchanged (published-memory-files.ts:89). - Reference-style links (
linkReference) and definitions are still not rewritten. Neither the old regex nor the new code rewrites them, and the PR body says so. - Labels that span lines (
[multi\nline](t.md)) are now rewritten. The old[^\]\n]*skipped them. This is an improvement, and continuation-line>prefixes are kept because they stay insidestart. - The unavailable-session path (
start.slice(1, -2)) still yields the label source, and the code-in-label case is covered by the new test. @linger/document-filesis already a node-services dependency (apps/node-services/package.json:35) and already depends onremark-parseandremark-gfm. No new dependency.- Publishing runs in the background
#projectWikireconcile (apps/node-services/src/memory/wiki-index.ts:328-347), not on the user message →provider_readypath. Parsing every page with remark costs nothing on the request path. - Both owning READMEs were updated. No contracts, env vars or CJK text added. No merge or fixup commits.
Process notes
None.
CI
Every reported check passed or was skipped (check (packages), repository-gate, web tests, web-static, check (teamhub-cli), check (web)). CI lists no node-services job, so I ran pnpm --filter @linger/node-services exec vitest run tests/memory/published-link-literals.test.ts tests/memory/personal-layout.test.ts --maxWorkers=1 locally: 2 files, 9 tests passed. I also ran a throwaway probe (since deleted) of rewriteMarkdownLinkSources on the edge cases above. Merge state is BLOCKED only because a review is still required.
Automated review by Claude Code
Automated review of 9e2aeba by Claude Code.
There was a problem hiding this comment.
Approve (0 P0, 0 P1, 0 P2, 0 P3)
Scope: follow-up on 9e2aeba, reviewing head 6adc5c1 against main (merge base 77abdcb). I reviewed 2 commits and 6 files. The coderbook, ponytail-review and karpathy-guidelines guidance was applied. The review ran in a separate session.
Previous findings
- P3: leading BOM shifts the parsed link offsets. Resolved.
packages/document-files/src/index.ts:88addsbomOffsetto both node offsets.labelEndis computed relative tonodeStart, so the BOM cancels out there. Coverage:preserves a leading BOM while rewriting exact link source rangesinindex.test.ts, and thea leading byte-order markcase inpublished-link-literals.test.ts. - P3: a title containing
](stopped the link from being rewritten. Resolved. The callback now receives the parsedurland the label boundary (labelEnd, from the end offset of the last label child). The destination regex runs only onlink.slice(labelEnd), so a](in the label or the title can no longer move the split. Coverage: thelink-like punctuation inside a titlecase and theit.each(["a", "a ](b", ""])boundary test.
Findings
None.
Verified as fine
- Label boundary.
- With an empty label (
[](t.md)), there are no children, solabelEndfalls back to1andlink.slice(1)starts with]((index.ts:103). The test covers this. - Nested brackets, escaped
\], hard breaks and image children all end at or before the closing], sostart = link.slice(0, labelEnd + 2)is always[label](once the destination regex has matched^\](. - The unavailable-session path,
start.slice(1, -2), still yields the raw label text (published-memory-files.ts:113).
- With an empty label (
- Link node types.
- Autolinks and GFM literal autolinks are also
linknodes, but they do not start with[, so the!link.startsWith("[")guard (published-memory-files.ts:94) leaves them untouched. - Reference links are
linkReference, which thenode.type !== "link"filter skips.
- Autolinks and GFM literal autolinks are also
- Using
node.urlinstead of the raw href.- mdast decodes escapes and character references, but not percent-encoding. Percent-encoded paths therefore resolve exactly as before, and
&-style references now resolve to the real file name. - For angle-bracket destinations, the URL comes back without the
<>, which matches the oldhref.replace(/^<|>$/gu, "").
- mdast decodes escapes and character references, but not percent-encoding. Percent-encoded paths therefore resolve exactly as before, and
- Patterns the regex still rejects. Parenthesized titles, titles containing
)and balanced parentheses in a destination still fail the destination regex. Those links are returned unchanged, the same as on the merge base, so nothing regresses. - Callback signature. The only caller of
rewriteMarkdownLinkSourcesispublished-memory-files.ts, so the new second argument breaks nothing. - Docs. Both READMEs are updated in the same PR (
apps/node-services/src/memory/README.md,packages/document-files/README.md). - English-only. No CJK appears in the added lines or in either commit message.
Process notes
- The branch is 338 commits behind
main.mainrequires up-to-date branches, so it needs a rebase. 6adc5c16only patches9e2aebabin response to review. Becausemainuses rebase merges, consider squashing it into9e2aebabwithgit rebase -i --autosquashso a single coherent commit lands.
CI
At review time, changes passed and check (packages), check (teamhub-cli), repository-gate, web-static and the web test shards were still pending; the remaining checks were skipped by path filtering. I ran no tests locally: there are no node_modules in this worktree, and nothing I suspected needed a run to confirm.
Automated review by Claude Code
Automated review of 6adc5c1 by Claude Code.
|
Both link-boundary findings from review 6052661333 are addressed in The helper adds the leading-BOM offset when slicing the original source, and passes the parsed URL plus the relative label end to the publisher. The publisher now starts its destination/title match after that label boundary. This keeps code inside labels intact and prevents The BOM helper regression and both publishing regressions failed on the previous head and now pass. The complete Document Files check passes 39 tests with types/lint; the two publishing/layout files pass 11 tests. The full Node Services check passes 2,720 tests across 269 files, with the existing 8 files / 51 tests skipped. Changed-file formatting, lint and English-only checks pass. The published tree matches the checked tree, and the selected hosted CI jobs also pass. |
What and why
Rewrite readable Wiki destinations only for actual inline Markdown links. Preserve inline, fenced, indented and quoted code, escaped link syntax and literal unavailable-meeting references. Real links still move to readable paths, including links with code inside their labels.
The shared Markdown helper accounts for the parser's leading-BOM offset and supplies the parsed URL and label boundary. Publishing can separate a nested-code label from a title containing
](without guessing the label boundary with a greedy expression. Surrounding source spelling, the BOM and title text are preserved.How it was verified
Comparison base:
77abdcb37f779f9c9d2de89fa245efa88d3f6584. Linux, Node 26.5.0 and pnpm 11.7.0. Current head:6adc5c1618223231490cc88f3f2f8c746518c2eb.9e2aebab(1 failed / 7 passed). Two real publishing regressions for a BOM and title punctuation also failed (2 failed / 9 passed across the two related files).pnpm --filter @linger/document-files checkpasses typecheck, lint and 39 tests across 3 files, including normal, empty and code-containing label boundaries.git diff --checkpasses.Complete owning-app gate
pnpm --filter @linger/node-services checkexits 0 on the published tree196c39db795295e713cc3affb702154aa887ebea: feature-catalog verification, typecheck and lint pass; 269 files passed, 8 skipped; 2,720 tests passed, 51 skipped. The normal suite configuration and a task-local temporary directory were used. Dependencies were installed with the frozen lockfile in an isolated worktree. No timeout or skip settings changed.Hosted run 45566451875 also passes all selected checks, including the package and web consumer jobs.
Boundary
The owning READMEs describe the behavior. The existing Markdown parser is reused; no dependency or network call is added. The tree is not serialized, so unrelated Markdown remains byte-for-byte intact. Reference definitions are not newly rewritten. Live-service/E2E results are not claimed.