Merge remote-tracking branch 'origin/master' into worktree/docs-website

# Conflicts:
#	package.json
#	pnpm-lock.yaml
#	pnpm-workspace.yaml
#	scripts/verify-md-wrap.ts
This commit is contained in:
Yichen Jiang
2026-07-14 09:50:42 +08:00
145 changed files with 11502 additions and 583 deletions

View File

@@ -29,12 +29,11 @@
* Run: `tsx scripts/verify-md-wrap.ts`.
*/
import { globSync, readFileSync, realpathSync } from 'node:fs'
import { readFileSync } from 'node:fs'
import { relative, resolve } from 'node:path'
import { fromMarkdown } from 'mdast-util-from-markdown'
import { gfmFromMarkdown } from 'mdast-util-gfm'
import { gfm } from 'micromark-extension-gfm'
import type { Nodes } from 'mdast'
import { parseMarkdown, visitMarkdown } from './markdown.ts'
import { uniqueRepoFiles } from './repo-files.ts'
const root = resolve(import.meta.dirname, '..')
@@ -75,10 +74,10 @@ function findViolations(absPath: string): Violation[] {
const file = relative(root, absPath)
const source = readFileSync(absPath, 'utf8')
const parsedSource = maskVitePressStructure(source)
const tree = fromMarkdown(parsedSource, { extensions: [gfm()], mdastExtensions: [gfmFromMarkdown()] })
const tree = parseMarkdown(parsedSource)
const out: Violation[] = []
const visit = (node: Nodes): void => {
visitMarkdown(tree, (node: Nodes): boolean | void => {
if (node.type === 'paragraph' && node.position) {
const { start, end } = node.position
if (end.line > start.line) {
@@ -87,31 +86,15 @@ function findViolations(absPath: string): Violation[] {
}
// A paragraph's children are inline (text/emphasis/…); no nested
// paragraphs to find, so don't descend.
return
return false
}
if ('children' in node) {
for (const child of node.children) visit(child)
}
}
visit(tree)
})
return out
}
const seen = new Set<string>()
const all: Violation[] = []
let checked = 0
for (const pattern of PATTERNS) {
for (const match of globSync(pattern, { cwd: root })) {
const abs = resolve(root, match)
// CLAUDE.md symlinks resolve onto AGENTS.md; dedupe by real path so a file
// matched twice (or via symlink) is checked once.
const real = realpathSync(abs)
if (seen.has(real)) continue
seen.add(real)
checked++
all.push(...findViolations(abs))
}
}
const files = uniqueRepoFiles(root, PATTERNS)
const all = files.flatMap(file => findViolations(file.abs))
const checked = files.length
if (all.length === 0) {
console.log(`verify-md-wrap: ${checked} file(s) checked, no hard-wrapped prose paragraphs.`)