feat(den): add cloud skill uploads and sync tracking (#1400)

Co-authored-by: src-opn <src-opn@users.noreply.github.com>
This commit is contained in:
Source Open
2026-04-08 12:58:54 -07:00
committed by GitHub
parent 319ac3ee79
commit e27abd50c3
9 changed files with 696 additions and 82 deletions

View File

@@ -33,16 +33,50 @@ function normalizeFrontmatterValue(value: string | undefined): string {
return normalized
}
function foldYamlBlockLines(lines: string[], mode: "literal" | "folded"): string {
const normalized = lines.map((line) => line.replace(/[ \t]+$/g, ""))
if (mode === "literal") {
return normalized.join("\n").trim()
}
const folded: string[] = []
let paragraph: string[] = []
const flushParagraph = () => {
if (paragraph.length === 0) {
return
}
folded.push(paragraph.join(" "))
paragraph = []
}
for (const line of normalized) {
if (!line.trim()) {
flushParagraph()
if (folded.length === 0 || folded[folded.length - 1] !== "") {
folded.push("")
}
continue
}
paragraph.push(line.trim())
}
flushParagraph()
return folded.join("\n").trim()
}
function parseFrontmatter(header: string): Record<string, string> {
const data: Record<string, string> = {}
const lines = header.split("\n")
for (const line of header.split("\n")) {
for (let index = 0; index < lines.length; index += 1) {
const line = lines[index] ?? ""
const trimmed = line.trim()
if (!trimmed) {
continue
}
const match = trimmed.match(/^([A-Za-z0-9_-]+)\s*:\s*(.*)$/)
const match = line.match(/^([A-Za-z0-9_-]+)\s*:\s*(.*)$/)
if (!match) {
continue
}
@@ -52,7 +86,44 @@ function parseFrontmatter(header: string): Record<string, string> {
continue
}
data[key] = normalizeFrontmatterValue(match[2])
const rawValue = (match[2] ?? "").trimEnd()
const blockScalarMatch = rawValue.match(/^([>|])[-+0-9]*$/)
if (blockScalarMatch) {
const mode = blockScalarMatch[1] === ">" ? "folded" : "literal"
const blockLines: string[] = []
let blockIndent: number | null = null
let nextIndex = index + 1
for (; nextIndex < lines.length; nextIndex += 1) {
const nextLine = lines[nextIndex] ?? ""
const nextTrimmed = nextLine.trim()
if (!nextTrimmed) {
blockLines.push("")
continue
}
const indent = nextLine.match(/^(\s*)/)?.[1]?.length ?? 0
if (blockIndent === null) {
if (indent === 0) {
break
}
blockIndent = indent
}
if (indent < blockIndent) {
break
}
blockLines.push(nextLine.slice(blockIndent))
}
data[key] = foldYamlBlockLines(blockLines, mode)
index = nextIndex - 1
continue
}
data[key] = normalizeFrontmatterValue(rawValue)
}
return data