v0.1.5: standalone-readability pass — delink --strip provenance mode ([TT-NNNN]), Tier-2 dangling refs neutralized, verify/review-code giant skills split into reference/ on-demand files; guards now runtime-neutral (bun|node)

This commit is contained in:
2026-09-25 00:09:37 +08:00
parent d6567b1842
commit 88204a90c8
74 changed files with 1417 additions and 1358 deletions
+23 -3
View File
@@ -3,12 +3,20 @@
import fs from "node:fs"
import path from "node:path"
const ROOT = path.resolve(import.meta.dir, "..")
// Runtime-neutral: works under bun and node>=20.9 (--experimental-strip-types).
const scriptDir = (import.meta as { dir?: string }).dir
?? new URL(".", import.meta.url).pathname
const ROOT = path.resolve(scriptDir, "..")
const MANIFEST_PATH = path.join(ROOT, "core", "CORE-MANIFEST.json")
const CHECK = process.argv.includes("--check")
// --strip: rewrite remaining `[org-internal #NNNN]` annotations to a compact
// provenance form `[TT-NNNN]` (org ticket id, non-navigable in the standalone
// repo) and fold the wordy placeholder away. Idempotent like the base pass.
const STRIP = process.argv.includes("--strip")
const REF_RE = /\B#(\d{3,5})\b/g
const PLACEHOLDER = "org-internal"
const STRIP_RE = /\[org-internal[ \t]*#(\d{3,5})\]/g
interface Mapping {
core: string
@@ -61,6 +69,16 @@ function transformContent(content: string): { next: string; count: number } {
return { next, count }
}
// --strip pass: `[org-internal #NNNN]` → `[TT-NNNN]` (provenance-only ticket id).
function stripContent(content: string): { next: string; count: number } {
let count = 0
const next = content.replace(STRIP_RE, (_match, digits: string) => {
count++
return `[TT-${digits}]`
})
return { next, count }
}
export function transformContentForTest(content: string): { next: string; count: number } {
return transformContent(content)
}
@@ -73,7 +91,8 @@ let replacedTotal = 0
for (const rel of files) {
const fullRel = `core/${rel}`
const content = fs.readFileSync(path.join(ROOT, "core", rel), "utf8")
const { next, count } = transformContent(content)
const result = STRIP ? stripContent(content) : transformContent(content)
const { next, count } = result
if (count === 0) continue
if (byteLocked.has(fullRel)) {
deferredLocked.push({ file: fullRel, count })
@@ -101,7 +120,8 @@ if (CHECK) {
process.exit(0)
}
console.log(`delink-core: replaced ${replacedTotal} refs across ${perFile.length} file(s)`)
const mode = STRIP ? "stripped" : "replaced"
console.log(`delink-core: ${mode} ${replacedTotal} refs across ${perFile.length} file(s)`)
const top = [...perFile, ...deferredLocked].sort((a, b) => b.count - a.count).slice(0, 10)
for (const p of top) console.log(` ${p.file}: ${p.count}`)
process.exit(0)