@descent-vtt/spec-brief 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +102 -0
- package/README.md +56 -6
- package/dist/archive.js.map +1 -1
- package/dist/brief.js.map +1 -1
- package/dist/cli.d.ts +18 -1
- package/dist/cli.js +273 -55
- package/dist/cli.js.map +1 -1
- package/dist/config.js +3 -2
- package/dist/config.js.map +1 -1
- package/dist/corpus.js +1 -0
- package/dist/corpus.js.map +1 -1
- package/dist/engine.d.ts +43 -0
- package/dist/engine.js +74 -12
- package/dist/engine.js.map +1 -1
- package/dist/fs.d.ts +15 -1
- package/dist/fs.js +21 -8
- package/dist/fs.js.map +1 -1
- package/dist/git.d.ts +11 -0
- package/dist/git.js +38 -4
- package/dist/git.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lint.js.map +1 -1
- package/dist/literal.d.ts +11 -0
- package/dist/literal.js +14 -0
- package/dist/literal.js.map +1 -0
- package/dist/markdown.js.map +1 -1
- package/dist/plugins.js +2 -0
- package/dist/plugins.js.map +1 -1
- package/dist/report.js +3 -2
- package/dist/report.js.map +1 -1
- package/dist/rules.js +2 -1
- package/dist/rules.js.map +1 -1
- package/dist/schedule.js.map +1 -1
- package/dist/schema.js.map +1 -1
- package/dist/scope.js.map +1 -1
- package/dist/text.js.map +1 -1
- package/dist/vendor/spec-core/markdown/frontmatter.js.map +1 -1
- package/dist/vendor/spec-core/markdown/headings.js.map +1 -1
- package/dist/vendor/spec-core/markdown/links.js.map +1 -1
- package/dist/vendor/spec-core/markdown/scan.js.map +1 -1
- package/dist/vendor/spec-core/pattern/automaton.js.map +1 -1
- package/dist/vendor/spec-core/pattern/charset.js.map +1 -1
- package/dist/vendor/spec-core/pattern/regex.js.map +1 -1
- package/dist/vendor/spec-core/text/lines.js.map +1 -1
- package/dist/vendor/spec-core/text/width.js.map +1 -1
- package/package.json +1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O;gBACjB,OAAO,EAAE,uBAAuB,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,CAAC,QAAQ,4BAA4B;gBACjH,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,IAAI,EAAE,CAAC;gBACP,KAAK,EAAE,KAAK,CAAC,EAAE,IAAI,SAAS;gBAC5B,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,8DAA8D,CAAC,CAAC,CAAC,wEAAwE;aACvJ,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QACD,MAAM,KAAK,GAAG,sBAAsB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QACjG,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAChH,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AAC1B,CAAC","sourcesContent":["/**\n * Waves, computed: which live briefs can run side by side, so that no two in\n * one wave can write the same file and every brief runs after the briefs it\n * depends on.\n *\n * Deciding what the rounds of a goal are is prose, and an agent's work. Given\n * the rounds, placing them is not: it is precedence-constrained colouring, and\n * a tool answers it the same way every time (ADR-0011). Briefs are taken in\n * dependency order, ties broken by id, and each goes into the lowest wave that\n * is after every live dependency's and holds nothing it collides with. A brief\n * with no scope cannot be proved apart from anything, so it shares its wave\n * with nobody. The greedy answer is not always the fewest waves - no fast\n * method promises that - but it is always a valid one, and the same one.\n *\n * Nothing is written here. `planWaves` says what `--write` would write, and\n * the engine writes it as the archive writes, as one transaction.\n */\n\nimport type { FileOp } from './archive.js';\nimport { type Brief, lineOfField } from './brief.js';\nimport { undecidedFinding, unscopedFinding } from './collisions.js';\nimport { byId, type Corpus, cycleSubject, dependencyCycles, liveDependencies, waitingOnDeferred } from './corpus.js';\nimport { editable, setEntryKeepingComment } from './frontmatter.js';\nimport { readingIn, WITNESS_BUDGET } from './glob.js';\nimport { configuredSeverity } from './lint.js';\nimport { meet, type Overlap, type Scope, scopeOf, witnessText } from './scope.js';\nimport { encodeLike } from './text.js';\nimport type { Finding } from './types.js';\n\nexport interface ScheduleOptions {\n /** The files the tree holds, which say whether a literal path is a file or a directory. */\n readonly repoFiles?: readonly string[] | null;\n /** How many states one witness search may visit before it answers `undecided`. */\n readonly budget?: number;\n}\n\n/** A wave a brief could not join, and the brief already there that kept it out. */\nexport type Passed =\n | { readonly wave: number; readonly reason: 'collision'; readonly brief: Brief; readonly overlaps: readonly Overlap[] }\n | { readonly wave: number; readonly reason: 'undecided'; readonly brief: Brief; readonly patterns: readonly (readonly [string, string])[] }\n /** One of the two declares no affectedFiles, and an unscoped brief runs alone. */\n | { readonly wave: number; readonly reason: 'unscoped'; readonly brief: Brief };\n\n/**\n * Why a declared wave does not hold: what `matrix` or `lint` would report as\n * an error if the brief ran there.\n */\nexport type Breach =\n /** A brief the matrix compares, declaring the same wave, whose scope meets this one's. Overlaps name this brief's pattern first. */\n | { readonly reason: 'collision'; readonly brief: Brief; readonly overlaps: readonly Overlap[] }\n /** A live dependency declaring the same wave or a later one. */\n | { readonly reason: 'dependency'; readonly brief: Brief; readonly wave: number }\n /** A live brief depending on this one, declaring the same wave or an earlier one. */\n | { readonly reason: 'dependent'; readonly brief: Brief; readonly wave: number };\n\nexport interface Placement {\n readonly brief: Brief;\n /** The wave its front matter declares; `null` when it declares none it can read. */\n readonly declared: number | null;\n readonly proposed: number;\n /** The live dependency in the latest wave, which sets the earliest wave this one may run in. */\n readonly after: { readonly brief: Brief; readonly wave: number } | null;\n /** Every wave from that earliest one that it could not join, in order. Overlaps and patterns name its own pattern first. */\n readonly passed: readonly Passed[];\n /** Declares no affectedFiles, so it shares its wave with nobody. */\n readonly unscoped: boolean;\n /**\n * Why the declared wave does not hold, when it is not the proposed one. Empty\n * when it holds - a person moved the brief, and `lint` and `matrix` accept\n * the wave - and when there is no declared wave to judge.\n */\n readonly breaches: readonly Breach[];\n}\n\n/** A live brief that can be placed in no wave, and the dependency that holds it. */\nexport interface Unplaced {\n readonly brief: Brief;\n readonly waitsOn: Brief;\n /** The dependency is deferred, is in a dependency cycle, or is itself unplaced. */\n readonly because: 'deferred' | 'cycle' | 'unplaced';\n}\n\nexport interface Schedule {\n /** The first wave: the lowest any scheduled brief declares, or 1 when none declares one. */\n readonly first: number;\n /** In the order they were placed: dependency order, ties by id. */\n readonly placements: readonly Placement[];\n /** By id. */\n readonly unplaced: readonly Unplaced[];\n /** Dependency cycles among the scheduled briefs, each as a path back to its start. */\n readonly cycles: readonly (readonly Brief[])[];\n /** Deferred briefs, which wait for their trigger and run in no wave. By id. */\n readonly deferred: readonly Brief[];\n}\n\nfunction label(brief: Brief): string {\n return brief.id ?? brief.name;\n}\n\nexport { byId } from './corpus.js';\n\n/** The first brief in a wave this one cannot share it with, or `null` when it can join. */\nfunction clash(own: Scope, wave: number, here: readonly Scope[], budget: number, files: readonly string[] | null): Passed | null {\n for (const other of here) {\n if (own.affected.length === 0 || other.affected.length === 0) return { wave, reason: 'unscoped', brief: other.brief };\n const meeting = meet(own, other, budget, files);\n if (meeting.overlaps.length > 0) return { wave, reason: 'collision', brief: other.brief, overlaps: meeting.overlaps };\n if (meeting.undecided.length > 0) return { wave, reason: 'undecided', brief: other.brief, patterns: meeting.undecided };\n }\n return null;\n}\n\n/** What a declared wave is judged against. */\ninterface Judge {\n /** The briefs the matrix compares: none deferred, none waiting on deferred work. */\n readonly compared: readonly Brief[];\n /** Every live brief's live dependencies, the briefs in the order of their ids. */\n readonly dependencies: ReadonlyMap<Brief, readonly Brief[]>;\n /** The scope of every brief the schedule places or compares. */\n readonly scopes: ReadonlyMap<Brief, Scope>;\n readonly budget: number;\n readonly files: readonly string[] | null;\n}\n\n/**\n * Why a brief's declared wave does not hold, judged as `lint` and `matrix`\n * judge it: against the waves the other briefs declare, not the ones proposed.\n * Collisions are with the briefs the matrix compares; the dependency order is\n * wave-order's, both ways, over every live brief.\n */\nfunction breachesOf(brief: Brief, wave: number, judge: Judge): Breach[] {\n const out: Breach[] = [];\n for (const dependency of judge.dependencies.get(brief) as Brief[]) {\n if (dependency.wave !== null && dependency.wave >= wave) out.push({ reason: 'dependency', brief: dependency, wave: dependency.wave });\n }\n for (const [other, needs] of judge.dependencies) {\n if (other.wave !== null && other.wave <= wave && needs.includes(brief)) out.push({ reason: 'dependent', brief: other, wave: other.wave });\n }\n for (const other of judge.compared) {\n if (other === brief || other.wave !== wave) continue;\n const overlaps = meet(judge.scopes.get(brief) as Scope, judge.scopes.get(other) as Scope, judge.budget, judge.files).overlaps;\n if (overlaps.length > 0) out.push({ reason: 'collision', brief: other, overlaps });\n }\n return out;\n}\n\nexport function schedule(corpus: Corpus, options: ScheduleOptions = {}): Schedule {\n const files = options.repoFiles ?? null;\n const reading = readingIn(files);\n const budget = options.budget ?? WITNESS_BUDGET;\n const deferred = corpus.live.filter((b) => b.status === 'deferred').sort(byId);\n const briefs = corpus.live.filter((b) => b.status !== 'deferred').sort(byId);\n // Of deferred briefs too: lint's wave-order reads every live brief's wave.\n // In the order of the ids, which is the order a brief's dependents are named in.\n const dependencies = new Map([...corpus.live].sort(byId).map((b) => [b, liveDependencies(corpus, b)]));\n const declared = briefs.flatMap((b) => (b.wave === null ? [] : [b.wave]));\n const first = declared.length === 0 ? 1 : Math.min(...declared);\n const scopes = new Map(briefs.map((b) => [b, scopeOf(b, reading)]));\n const waiting = new Set(waitingOnDeferred(corpus).map((w) => w.brief));\n const judge: Judge = { compared: briefs.filter((b) => !waiting.has(b)), dependencies, scopes, budget, files };\n\n const waveOf = new Map<Brief, number>();\n const occupants = new Map<number, Scope[]>();\n const placements: Placement[] = [];\n const pending = [...briefs];\n // Kahn's order, taking the least id whose dependencies are all placed. A\n // brief waiting on a deferred one, or on a cycle, is never taken.\n for (;;) {\n const next = pending.find((b) => (dependencies.get(b) as Brief[]).every((d) => waveOf.has(d)));\n if (next === undefined) break;\n pending.splice(pending.indexOf(next), 1);\n let after: Placement['after'] = null;\n for (const dependency of dependencies.get(next) as Brief[]) {\n const wave = waveOf.get(dependency) as number;\n if (after === null || wave > after.wave) after = { brief: dependency, wave };\n }\n const own = scopes.get(next) as Scope;\n const passed: Passed[] = [];\n let wave = after === null ? first : after.wave + 1;\n // Ends by construction: a wave past every occupied one is empty, and an empty wave takes anyone.\n for (;;) {\n const found = clash(own, wave, occupants.get(wave) ?? [], budget, files);\n if (found === null) break;\n passed.push(found);\n wave += 1;\n }\n waveOf.set(next, wave);\n occupants.set(wave, [...(occupants.get(wave) ?? []), own]);\n const breaches = next.wave === null || next.wave === wave ? [] : breachesOf(next, next.wave, judge);\n placements.push({ brief: next, declared: next.wave, proposed: wave, after, passed, unscoped: own.affected.length === 0, breaches });\n }\n\n const cycles = dependencyCycles(corpus).filter((cycle) => cycle.every((b) => b.status !== 'deferred'));\n const inCycle = new Set(cycles.flat());\n const unplaced = pending.map((brief): Unplaced => {\n const waitsOn = (dependencies.get(brief) as Brief[]).find((d) => !waveOf.has(d)) as Brief;\n const because = waitsOn.status === 'deferred' ? 'deferred' : inCycle.has(waitsOn) ? 'cycle' : 'unplaced';\n return { brief, waitsOn, because };\n });\n return { first, placements, unplaced, cycles, deferred };\n}\n\n/** The briefs whose declared wave the schedule would change. */\nexport function moves(s: Schedule): Placement[] {\n return s.placements.filter((p) => p.proposed !== p.declared);\n}\n\n/**\n * Whether a brief's declared wave holds: it is the proposed one, or one a\n * person chose that `lint` and `matrix` accept. The schedule is one valid\n * answer, not the only one (ADR-0011, amended).\n */\nexport function holds(p: Placement): boolean {\n return p.declared !== null && p.breaches.length === 0;\n}\n\n/** Why a declared wave does not hold, a clause each. */\nexport function breachReasons(p: Placement): string[] {\n return p.breaches.map((b) => {\n if (b.reason === 'collision') return `${label(b.brief)} there also writes ${witnessText(b.overlaps[0] as Overlap)}`;\n if (b.reason === 'dependency') return `it depends on ${label(b.brief)}, in wave ${b.wave}`;\n return `${label(b.brief)} depends on it, in wave ${b.wave}`;\n });\n}\n\n/** Why a brief is in its wave and not an earlier one, a clause each. */\nexport function reasons(p: Placement): string[] {\n const out: string[] = [];\n if (p.after !== null) out.push(`after ${label(p.after.brief)}, in wave ${p.after.wave}`);\n if (p.unscoped && p.passed.length > 0) out.push('it declares no affectedFiles, so it runs in a wave of its own');\n for (const passed of p.passed) {\n const there = `not wave ${passed.wave}, where ${label(passed.brief)}`;\n if (passed.reason === 'collision') {\n const [overlap] = passed.overlaps as [Overlap];\n out.push(`${there} also writes ${witnessText(overlap)} (\"${overlap.patterns[0]}\" and \"${overlap.patterns[1]}\")`);\n } else if (passed.reason === 'undecided') {\n out.push(`${there} may write the same files: the search could not decide within its budget`);\n } else if (!p.unscoped) {\n out.push(`${there} declares no affectedFiles and runs alone`);\n }\n }\n if (out.length === 0) out.push('nothing holds it later');\n return out;\n}\n\n/** The schedule as findings: cycles, briefs whose waves would move, briefs that run alone, and pairs it could not decide. */\nexport function scheduleFindings(corpus: Corpus, s: Schedule): Finding[] {\n const findings: Finding[] = [];\n const cycle = configuredSeverity(corpus, 'dependency-cycle');\n if (cycle !== null) {\n for (const members of s.cycles) {\n const start = members[0] as Brief;\n findings.push({\n rule: 'dependency-cycle',\n severity: cycle,\n message: `dependencies form a cycle, so no wave can hold them: ${members.map(label).join(' -> ')}`,\n file: start.file,\n line: lineOfField(start, 'dependsOn') + 1,\n brief: start.id ?? undefined,\n hint: 'a cycle can never become ready; remove the dependency that is not real',\n subject: cycleSubject(members),\n });\n }\n }\n const change = configuredSeverity(corpus, 'wave-schedule');\n if (change !== null) {\n // A wave a person chose that lint and matrix accept is theirs to keep: a\n // note, so that CI passes it. One missing, or one that does not hold, is\n // the rule's finding at its configured severity.\n for (const p of moves(s)) {\n const valid = holds(p);\n const was =\n p.declared === null\n ? 'declares no wave'\n : valid\n ? `declares wave ${p.declared}, which holds`\n : `declares wave ${p.declared}, which does not hold (${breachReasons(p).join('; ')})`;\n findings.push({\n rule: 'wave-schedule',\n severity: valid ? 'note' : change,\n message: `${was}; the schedule puts it in wave ${p.proposed}: ${reasons(p).join('; ')}`,\n file: p.brief.file,\n line: lineOfField(p.brief, 'wave') + 1,\n brief: p.brief.id ?? undefined,\n hint: valid\n ? `keep wave ${p.declared as number}, or run \"spec-brief schedule --write\" for wave ${p.proposed}`\n : `run \"spec-brief schedule --write\", or set \"wave: ${p.proposed}\"`,\n });\n }\n }\n const unscoped = configuredSeverity(corpus, 'unscoped');\n if (unscoped !== null && s.placements.length > 1) {\n for (const p of s.placements.filter((x) => x.unscoped)) {\n findings.push(unscopedFinding(unscoped, p.brief, `the ${s.placements.length - 1} other brief(s) the schedule places; it runs alone in wave ${p.proposed}`));\n }\n }\n const undecided = configuredSeverity(corpus, 'collision-undecided');\n if (undecided !== null) {\n for (const p of s.placements) {\n for (const passed of p.passed) {\n if (passed.reason !== 'undecided') continue;\n const theirsFirst = passed.patterns.map(([own, theirs]) => [theirs, own] as const);\n findings.push(undecidedFinding(undecided, passed.brief, p.brief, theirsFirst, passed.wave));\n }\n }\n }\n return findings;\n}\n\nexport interface WavePlan {\n /** A write of each brief whose wave changes: its front matter's `wave`, and every other line as it was. */\n readonly ops: readonly FileOp[];\n /** Briefs whose wave cannot be written, which refuse the whole write. */\n readonly refused: readonly Finding[];\n}\n\n/** What `--write` writes. */\nexport function planWaves(s: Schedule): WavePlan {\n const ops: FileOp[] = [];\n const refused: Finding[] = [];\n for (const p of moves(s)) {\n const { brief } = p;\n if (brief.frontMatter !== null && !editable(brief.frontMatter)) {\n const open = brief.frontMatter.close === -1;\n refused.push({\n rule: 'front-matter',\n severity: 'error',\n message: `the front matter is ${open ? 'never closed' : 'TOML'}, so wave ${p.proposed} cannot be written into it`,\n file: brief.file,\n line: 1,\n brief: brief.id ?? undefined,\n hint: open ? 'close the front matter with a \"---\" line, and schedule again' : 'write the front matter as YAML between \"---\" lines, and schedule again',\n });\n continue;\n }\n const lines = setEntryKeepingComment(brief.lines, brief.frontMatter, 'wave', String(p.proposed));\n ops.push({ kind: 'write', path: brief.file, content: encodeLike(brief.source, lines), before: brief.source });\n }\n return { ops, refused };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schedule.js","sourceRoot":"","sources":["../src/schedule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAc,WAAW,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAe,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrH,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,IAAI,EAA4B,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAqEvC,SAAS,KAAK,CAAC,KAAY;IACzB,OAAO,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC;AAChC,CAAC;AAED,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,2FAA2F;AAC3F,SAAS,KAAK,CAAC,GAAU,EAAE,IAAY,EAAE,IAAsB,EAAE,MAAc,EAAE,KAA+B;IAC9G,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;QACzB,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,C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,WAAW,CAAC,EAAE,CAAC;YAC/D,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,cAAc;gBACpB,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,uBAAuB,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,CAAC,QAAQ,4BAA4B;gBACjH,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,IAAI,EAAE,CAAC;gBACP,KAAK,EAAE,KAAK,CAAC,EAAE,IAAI,SAAS;gBAC5B,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,8DAA8D,CAAC,CAAC,CAAC,wEAAwE;aACvJ,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QACD,MAAM,KAAK,GAAG,sBAAsB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QACjG,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAChH,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AAC1B,CAAC","sourcesContent":["/**\n * Waves, computed: which live briefs can run side by side, so that no two in\n * one wave can write the same file and every brief runs after the briefs it\n * depends on.\n *\n * Deciding what the rounds of a goal are is prose, and an agent's work. Given\n * the rounds, placing them is not: it is precedence-constrained colouring, and\n * a tool answers it the same way every time (ADR-0011). Briefs are taken in\n * dependency order, ties broken by id, and each goes into the lowest wave that\n * is after every live dependency's and holds nothing it collides with. A brief\n * with no scope cannot be proved apart from anything, so it shares its wave\n * with nobody. The greedy answer is not always the fewest waves - no fast\n * method promises that - but it is always a valid one, and the same one.\n *\n * Nothing is written here. `planWaves` says what `--write` would write, and\n * the engine writes it as the archive writes, as one transaction.\n */\n\nimport type { FileOp } from './archive.js';\nimport { type Brief, lineOfField } from './brief.js';\nimport { undecidedFinding, unscopedFinding } from './collisions.js';\nimport { byId, type Corpus, cycleSubject, dependencyCycles, liveDependencies, waitingOnDeferred } from './corpus.js';\nimport { editable, setEntryKeepingComment } from './frontmatter.js';\nimport { readingIn, WITNESS_BUDGET } from './glob.js';\nimport { configuredSeverity } from './lint.js';\nimport { meet, type Overlap, type Scope, scopeOf, witnessText } from './scope.js';\nimport { encodeLike } from './text.js';\nimport type { Finding } from './types.js';\n\nexport interface ScheduleOptions {\n /** The files the tree holds, which say whether a literal path is a file or a directory. */\n readonly repoFiles?: readonly string[] | null;\n /** How many states one witness search may visit before it answers `undecided`. */\n readonly budget?: number;\n}\n\n/** A wave a brief could not join, and the brief already there that kept it out. */\nexport type Passed =\n | { readonly wave: number; readonly reason: 'collision'; readonly brief: Brief; readonly overlaps: readonly Overlap[] }\n | { readonly wave: number; readonly reason: 'undecided'; readonly brief: Brief; readonly patterns: readonly (readonly [string, string])[] }\n /** One of the two declares no affectedFiles, and an unscoped brief runs alone. */\n | { readonly wave: number; readonly reason: 'unscoped'; readonly brief: Brief };\n\n/**\n * Why a declared wave does not hold: what `matrix` or `lint` would report as\n * an error if the brief ran there.\n */\nexport type Breach =\n /** A brief the matrix compares, declaring the same wave, whose scope meets this one's. Overlaps name this brief's pattern first. */\n | { readonly reason: 'collision'; readonly brief: Brief; readonly overlaps: readonly Overlap[] }\n /** A live dependency declaring the same wave or a later one. */\n | { readonly reason: 'dependency'; readonly brief: Brief; readonly wave: number }\n /** A live brief depending on this one, declaring the same wave or an earlier one. */\n | { readonly reason: 'dependent'; readonly brief: Brief; readonly wave: number };\n\nexport interface Placement {\n readonly brief: Brief;\n /** The wave its front matter declares; `null` when it declares none it can read. */\n readonly declared: number | null;\n readonly proposed: number;\n /** The live dependency in the latest wave, which sets the earliest wave this one may run in. */\n readonly after: { readonly brief: Brief; readonly wave: number } | null;\n /** Every wave from that earliest one that it could not join, in order. Overlaps and patterns name its own pattern first. */\n readonly passed: readonly Passed[];\n /** Declares no affectedFiles, so it shares its wave with nobody. */\n readonly unscoped: boolean;\n /**\n * Why the declared wave does not hold, when it is not the proposed one. Empty\n * when it holds - a person moved the brief, and `lint` and `matrix` accept\n * the wave - and when there is no declared wave to judge.\n */\n readonly breaches: readonly Breach[];\n}\n\n/** A live brief that can be placed in no wave, and the dependency that holds it. */\nexport interface Unplaced {\n readonly brief: Brief;\n readonly waitsOn: Brief;\n /** The dependency is deferred, is in a dependency cycle, or is itself unplaced. */\n readonly because: 'deferred' | 'cycle' | 'unplaced';\n}\n\nexport interface Schedule {\n /** The first wave: the lowest any scheduled brief declares, or 1 when none declares one. */\n readonly first: number;\n /** In the order they were placed: dependency order, ties by id. */\n readonly placements: readonly Placement[];\n /** By id. */\n readonly unplaced: readonly Unplaced[];\n /** Dependency cycles among the scheduled briefs, each as a path back to its start. */\n readonly cycles: readonly (readonly Brief[])[];\n /** Deferred briefs, which wait for their trigger and run in no wave. By id. */\n readonly deferred: readonly Brief[];\n}\n\nfunction label(brief: Brief): string {\n return brief.id ?? brief.name;\n}\n\nexport { byId } from './corpus.js';\n\n/** The first brief in a wave this one cannot share it with, or `null` when it can join. */\nfunction clash(own: Scope, wave: number, here: readonly Scope[], budget: number, files: readonly string[] | null): Passed | null {\n for (const other of here) {\n if (own.affected.length === 0 || other.affected.length === 0) return { wave, reason: 'unscoped', brief: other.brief };\n const meeting = meet(own, other, budget, files);\n if (meeting.overlaps.length > 0) return { wave, reason: 'collision', brief: other.brief, overlaps: meeting.overlaps };\n if (meeting.undecided.length > 0) return { wave, reason: 'undecided', brief: other.brief, patterns: meeting.undecided };\n }\n return null;\n}\n\n/** What a declared wave is judged against. */\ninterface Judge {\n /** The briefs the matrix compares: none deferred, none waiting on deferred work. */\n readonly compared: readonly Brief[];\n /** Every live brief's live dependencies, the briefs in the order of their ids. */\n readonly dependencies: ReadonlyMap<Brief, readonly Brief[]>;\n /** The scope of every brief the schedule places or compares. */\n readonly scopes: ReadonlyMap<Brief, Scope>;\n readonly budget: number;\n readonly files: readonly string[] | null;\n}\n\n/**\n * Why a brief's declared wave does not hold, judged as `lint` and `matrix`\n * judge it: against the waves the other briefs declare, not the ones proposed.\n * Collisions are with the briefs the matrix compares; the dependency order is\n * wave-order's, both ways, over every live brief.\n */\nfunction breachesOf(brief: Brief, wave: number, judge: Judge): Breach[] {\n const out: Breach[] = [];\n for (const dependency of judge.dependencies.get(brief) as Brief[]) {\n if (dependency.wave !== null && dependency.wave >= wave) out.push({ reason: 'dependency', brief: dependency, wave: dependency.wave });\n }\n for (const [other, needs] of judge.dependencies) {\n if (other.wave !== null && other.wave <= wave && needs.includes(brief)) out.push({ reason: 'dependent', brief: other, wave: other.wave });\n }\n for (const other of judge.compared) {\n if (other === brief || other.wave !== wave) continue;\n const overlaps = meet(judge.scopes.get(brief) as Scope, judge.scopes.get(other) as Scope, judge.budget, judge.files).overlaps;\n if (overlaps.length > 0) out.push({ reason: 'collision', brief: other, overlaps });\n }\n return out;\n}\n\nexport function schedule(corpus: Corpus, options: ScheduleOptions = {}): Schedule {\n const files = options.repoFiles ?? null;\n const reading = readingIn(files);\n const budget = options.budget ?? WITNESS_BUDGET;\n const deferred = corpus.live.filter((b) => b.status === 'deferred').sort(byId);\n const briefs = corpus.live.filter((b) => b.status !== 'deferred').sort(byId);\n // Of deferred briefs too: lint's wave-order reads every live brief's wave.\n // In the order of the ids, which is the order a brief's dependents are named in.\n const dependencies = new Map([...corpus.live].sort(byId).map((b) => [b, liveDependencies(corpus, b)]));\n const declared = briefs.flatMap((b) => (b.wave === null ? [] : [b.wave]));\n const first = declared.length === 0 ? 1 : Math.min(...declared);\n const scopes = new Map(briefs.map((b) => [b, scopeOf(b, reading)]));\n const waiting = new Set(waitingOnDeferred(corpus).map((w) => w.brief));\n const judge: Judge = { compared: briefs.filter((b) => !waiting.has(b)), dependencies, scopes, budget, files };\n\n const waveOf = new Map<Brief, number>();\n const occupants = new Map<number, Scope[]>();\n const placements: Placement[] = [];\n const pending = [...briefs];\n // Kahn's order, taking the least id whose dependencies are all placed. A\n // brief waiting on a deferred one, or on a cycle, is never taken.\n for (;;) {\n const next = pending.find((b) => (dependencies.get(b) as Brief[]).every((d) => waveOf.has(d)));\n if (next === undefined) break;\n pending.splice(pending.indexOf(next), 1);\n let after: Placement['after'] = null;\n for (const dependency of dependencies.get(next) as Brief[]) {\n const wave = waveOf.get(dependency) as number;\n if (after === null || wave > after.wave) after = { brief: dependency, wave };\n }\n const own = scopes.get(next) as Scope;\n const passed: Passed[] = [];\n let wave = after === null ? first : after.wave + 1;\n // Ends by construction: a wave past every occupied one is empty, and an empty wave takes anyone.\n for (;;) {\n const found = clash(own, wave, occupants.get(wave) ?? [], budget, files);\n if (found === null) break;\n passed.push(found);\n wave += 1;\n }\n waveOf.set(next, wave);\n occupants.set(wave, [...(occupants.get(wave) ?? []), own]);\n const breaches = next.wave === null || next.wave === wave ? [] : breachesOf(next, next.wave, judge);\n placements.push({ brief: next, declared: next.wave, proposed: wave, after, passed, unscoped: own.affected.length === 0, breaches });\n }\n\n const cycles = dependencyCycles(corpus).filter((cycle) => cycle.every((b) => b.status !== 'deferred'));\n const inCycle = new Set(cycles.flat());\n const unplaced = pending.map((brief): Unplaced => {\n const waitsOn = (dependencies.get(brief) as Brief[]).find((d) => !waveOf.has(d))!;\n const because = waitsOn.status === 'deferred' ? 'deferred' : inCycle.has(waitsOn) ? 'cycle' : 'unplaced';\n return { brief, waitsOn, because };\n });\n return { first, placements, unplaced, cycles, deferred };\n}\n\n/** The briefs whose declared wave the schedule would change. */\nexport function moves(s: Schedule): Placement[] {\n return s.placements.filter((p) => p.proposed !== p.declared);\n}\n\n/**\n * Whether a brief's declared wave holds: it is the proposed one, or one a\n * person chose that `lint` and `matrix` accept. The schedule is one valid\n * answer, not the only one (ADR-0011, amended).\n */\nexport function holds(p: Placement): boolean {\n return p.declared !== null && p.breaches.length === 0;\n}\n\n/** Why a declared wave does not hold, a clause each. */\nexport function breachReasons(p: Placement): string[] {\n return p.breaches.map((b) => {\n if (b.reason === 'collision') return `${label(b.brief)} there also writes ${witnessText(b.overlaps[0] as Overlap)}`;\n if (b.reason === 'dependency') return `it depends on ${label(b.brief)}, in wave ${b.wave}`;\n return `${label(b.brief)} depends on it, in wave ${b.wave}`;\n });\n}\n\n/** Why a brief is in its wave and not an earlier one, a clause each. */\nexport function reasons(p: Placement): string[] {\n const out: string[] = [];\n if (p.after !== null) out.push(`after ${label(p.after.brief)}, in wave ${p.after.wave}`);\n if (p.unscoped && p.passed.length > 0) out.push('it declares no affectedFiles, so it runs in a wave of its own');\n for (const passed of p.passed) {\n const there = `not wave ${passed.wave}, where ${label(passed.brief)}`;\n if (passed.reason === 'collision') {\n const [overlap] = passed.overlaps as [Overlap];\n out.push(`${there} also writes ${witnessText(overlap)} (\"${overlap.patterns[0]}\" and \"${overlap.patterns[1]}\")`);\n } else if (passed.reason === 'undecided') {\n out.push(`${there} may write the same files: the search could not decide within its budget`);\n } else if (!p.unscoped) {\n out.push(`${there} declares no affectedFiles and runs alone`);\n }\n }\n if (out.length === 0) out.push('nothing holds it later');\n return out;\n}\n\n/** The schedule as findings: cycles, briefs whose waves would move, briefs that run alone, and pairs it could not decide. */\nexport function scheduleFindings(corpus: Corpus, s: Schedule): Finding[] {\n const findings: Finding[] = [];\n const cycle = configuredSeverity(corpus, 'dependency-cycle');\n if (cycle !== null) {\n for (const members of s.cycles) {\n const start = members[0] as Brief;\n findings.push({\n rule: 'dependency-cycle',\n severity: cycle,\n message: `dependencies form a cycle, so no wave can hold them: ${members.map(label).join(' -> ')}`,\n file: start.file,\n line: lineOfField(start, 'dependsOn') + 1,\n brief: start.id ?? undefined,\n hint: 'a cycle can never become ready; remove the dependency that is not real',\n subject: cycleSubject(members),\n });\n }\n }\n const change = configuredSeverity(corpus, 'wave-schedule');\n if (change !== null) {\n // A wave a person chose that lint and matrix accept is theirs to keep: a\n // note, so that CI passes it. One missing, or one that does not hold, is\n // the rule's finding at its configured severity.\n for (const p of moves(s)) {\n const valid = holds(p);\n const was =\n p.declared === null\n ? 'declares no wave'\n : valid\n ? `declares wave ${p.declared}, which holds`\n : `declares wave ${p.declared}, which does not hold (${breachReasons(p).join('; ')})`;\n findings.push({\n rule: 'wave-schedule',\n severity: valid ? 'note' : change,\n message: `${was}; the schedule puts it in wave ${p.proposed}: ${reasons(p).join('; ')}`,\n file: p.brief.file,\n line: lineOfField(p.brief, 'wave') + 1,\n brief: p.brief.id ?? undefined,\n hint: valid\n ? `keep wave ${p.declared as number}, or run \"spec-brief schedule --write\" for wave ${p.proposed}`\n : `run \"spec-brief schedule --write\", or set \"wave: ${p.proposed}\"`,\n });\n }\n }\n const unscoped = configuredSeverity(corpus, 'unscoped');\n if (unscoped !== null && s.placements.length > 1) {\n for (const p of s.placements.filter((x) => x.unscoped)) {\n findings.push(unscopedFinding(unscoped, p.brief, `the ${s.placements.length - 1} other brief(s) the schedule places; it runs alone in wave ${p.proposed}`));\n }\n }\n const undecided = configuredSeverity(corpus, 'collision-undecided');\n if (undecided !== null) {\n for (const p of s.placements) {\n for (const passed of p.passed) {\n if (passed.reason !== 'undecided') continue;\n const theirsFirst = passed.patterns.map(([own, theirs]): readonly [string, string] => [theirs, own]);\n findings.push(undecidedFinding(undecided, passed.brief, p.brief, theirsFirst, passed.wave));\n }\n }\n }\n return findings;\n}\n\nexport interface WavePlan {\n /** A write of each brief whose wave changes: its front matter's `wave`, and every other line as it was. */\n readonly ops: readonly FileOp[];\n /** Briefs whose wave cannot be written, which refuse the whole write. */\n readonly refused: readonly Finding[];\n}\n\n/** What `--write` writes. */\nexport function planWaves(s: Schedule): WavePlan {\n const ops: FileOp[] = [];\n const refused: Finding[] = [];\n for (const p of moves(s)) {\n const { brief } = p;\n if (brief.frontMatter !== null && !editable(brief.frontMatter)) {\n const open = brief.frontMatter.close === -1;\n refused.push({\n rule: 'front-matter',\n severity: 'error',\n message: `the front matter is ${open ? 'never closed' : 'TOML'}, so wave ${p.proposed} cannot be written into it`,\n file: brief.file,\n line: 1,\n brief: brief.id ?? undefined,\n hint: open ? 'close the front matter with a \"---\" line, and schedule again' : 'write the front matter as YAML between \"---\" lines, and schedule again',\n });\n continue;\n }\n const lines = setEntryKeepingComment(brief.lines, brief.frontMatter, 'wave', String(p.proposed));\n ops.push({ kind: 'write', path: brief.file, content: encodeLike(brief.source, lines), before: brief.source });\n }\n return { ops, refused };\n}\n"]}
|
package/dist/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA2BH,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IACzC,QAAQ,OAAO,KAAK,EAAE,CAAC;QACrB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB;YACE,OAAO,QAAQ,CAAC;IACpB,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAAC,MAAc,EAAE,IAAU;IACzC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,QAAQ;YACX,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;QAC5E,KAAK,SAAS;YACZ,OAAO,IAAI,KAAK,SAAS,CAAC;QAC5B,KAAK,SAAS;YACZ,OAAO,IAAI,K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O,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QAChE,KAAK,KAAK;YACR,OAAO,SAAS,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;AACH,CAAC","sourcesContent":["/**\n * A small schema language: one description that both validates a value and\n * renders as JSON Schema, so the published `schema.json` and the checks the\n * loader runs cannot disagree about what a configuration may say.\n */\n\ninterface Described {\n readonly description?: string;\n}\n\nexport type Schema =\n | (Described & {\n readonly type: 'string';\n readonly enum?: readonly string[];\n readonly nullable?: boolean;\n readonly minLength?: number;\n })\n | (Described & { readonly type: 'boolean' })\n | (Described & { readonly type: 'integer'; readonly minimum?: number; readonly maximum?: number })\n | (Described & { readonly type: 'array'; readonly items: Schema })\n | (Described & {\n readonly type: 'object';\n readonly properties: Readonly<Record<string, Schema>>;\n readonly required?: readonly string[];\n })\n | (Described & { readonly type: 'map'; readonly values: Schema })\n | (Described & { readonly type: 'anyOf'; readonly options: readonly Schema[] })\n | (Described & { readonly type: 'any' });\n\ntype Kind = 'null' | 'string' | 'boolean' | 'number' | 'array' | 'object';\n\nfunction kindOf(value: unknown): Kind {\n if (value === null) return 'null';\n if (Array.isArray(value)) return 'array';\n switch (typeof value) {\n case 'string':\n return 'string';\n case 'boolean':\n return 'boolean';\n case 'number':\n return 'number';\n default:\n return 'object';\n }\n}\n\nfunction accepts(schema: Schema, kind: Kind): boolean {\n switch (schema.type) {\n case 'string':\n return kind === 'string' || (kind === 'null' && schema.nullable === true);\n case 'boolean':\n return kind === 'boolean';\n case 'integer':\n return kind === 'number';\n case 'array':\n return kind === 'array';\n case 'object':\n case 'map':\n return kind === 'object';\n case 'anyOf':\n return schema.options.some((option) => accepts(option, kind));\n case 'any':\n return true;\n }\n}\n\nfunction noun(schema: Schema): string {\n switch (schema.type) {\n case 'string':\n return schema.nullable === true ? 'a string or null' : 'a string';\n case 'boolean':\n return 'true or false';\n case 'integer':\n return 'an integer';\n case 'array':\n return 'a list';\n case 'object':\n case 'map':\n return 'an object';\n case 'anyOf':\n return schema.options.map(noun).join(' or ');\n /* v8 ignore next 2 -- \"any\" accepts every value, so no message ever names it. */\n case 'any':\n return 'anything';\n }\n}\n\nfunction at(path: string, key: string): string {\n return path === '' ? key : `${path}.${key}`;\n}\n\n/** The problems with `value`, each naming the path to it. Empty when it conforms. */\nexport function validate(schema: Schema, value: unknown, path = ''): string[] {\n const where = path === '' ? 'the configuration' : `\"${path}\"`;\n if (!accepts(schema, kindOf(value))) return [`${where} must be ${noun(schema)}`];\n switch (schema.type) {\n case 'string': {\n if (typeof value !== 'string') return [];\n if (schema.enum !== undefined && !schema.enum.includes(value)) {\n return [`${where} must be one of ${schema.enum.map((e) => `\"${e}\"`).join(', ')}, not \"${value}\"`];\n }\n if (value.length < (schema.minLength ?? 0)) return [`${where} must not be empty`];\n return [];\n }\n case 'integer': {\n const number = value as number;\n if (!Number.isInteger(number)) return [`${where} must be an integer`];\n if (number < (schema.minimum ?? -Infinity)) return [`${where} must be at least ${schema.minimum}`];\n if (number > (schema.maximum ?? Infinity)) return [`${where} must be at most ${schema.maximum}`];\n return [];\n }\n case 'array':\n return (value as unknown[]).flatMap((item, i) => validate(schema.items, item, `${path}[${i}]`));\n case 'object': {\n const record = value as Record<string, unknown>;\n const known = Object.keys(schema.properties);\n const problems: string[] = [];\n for (const key of Object.keys(record)) {\n // Its own keys only: `constructor` is on every object, and is no key of a configuration.\n const property = Object.hasOwn(schema.properties, key) ? schema.properties[key] : undefined;\n if (property === undefined) {\n const guess = closest(key, known);\n problems.push(`\"${at(path, key)}\" is not a known key${guess === undefined ? '' : `; did you mean \"${guess}\"?`}`);\n continue;\n }\n problems.push(...validate(property, record[key], at(path, key)));\n }\n for (const key of schema.required ?? []) {\n if (!(key in record)) problems.push(`\"${at(path, key)}\" is required`);\n }\n return problems;\n }\n case 'map':\n return Object.entries(value as Record<string, unknown>).flatMap(([key, item]) =>\n validate(schema.values, item, at(path, key)),\n );\n case 'anyOf': {\n // Some option accepts the value's kind, or the check above would have answered: there is a first.\n const kind = kindOf(value);\n const problems = schema.options.filter((option) => accepts(option, kind)).map((option) => validate(option, value, path));\n return problems.some((found) => found.length === 0) ? [] : (problems[0] as string[]);\n }\n case 'boolean':\n case 'any':\n return [];\n }\n}\n\n/**\n * The known key nearest to a misspelling, when one is near enough to be what\n * was meant. One that keeps no character of the word is no misspelling of it,\n * however short both are: `狀態` is two edits from `id`.\n */\nexport function closest(word: string, options: readonly string[]): string | undefined {\n let best: string | undefined;\n let bestDistance = Math.max(2, Math.floor(word.length / 3)) + 1;\n for (const option of options) {\n const d = distance(word.toLowerCase(), option.toLowerCase());\n if (d < bestDistance && d < Math.max(word.length, option.length)) {\n best = option;\n bestDistance = d;\n }\n }\n return best;\n}\n\nfunction distance(a: string, b: string): number {\n let previous = Array.from({ length: b.length + 1 }, (_, j) => j);\n for (let i = 1; i <= a.length; i += 1) {\n const row = [i];\n for (let j = 1; j <= b.length; j += 1) {\n const cost = a.charAt(i - 1) === b.charAt(j - 1) ? 0 : 1;\n row.push(Math.min((previous[j] as number) + 1, (row[j - 1] as number) + 1, (previous[j - 1] as number) + cost));\n }\n previous = row;\n }\n return previous[b.length] as number;\n}\n\ntype Json = null | boolean | number | string | Json[] | { [key: string]: Json };\n\n/** Renders a schema as JSON Schema (draft 2020-12). */\nexport function toJsonSchema(schema: Schema): { [key: string]: Json } {\n const described = (body: { [key: string]: Json }): { [key: string]: Json } =>\n schema.description === undefined ? body : { description: schema.description, ...body };\n switch (schema.type) {\n case 'string': {\n const body: { [key: string]: Json } = { type: schema.nullable === true ? ['string', 'null'] : 'string' };\n if (schema.enum !== undefined) body['enum'] = [...schema.enum, ...(schema.nullable === true ? [null] : [])];\n if (schema.minLength !== undefined) body['minLength'] = schema.minLength;\n return described(body);\n }\n case 'boolean':\n return described({ type: 'boolean' });\n case 'integer': {\n const body: { [key: string]: Json } = { type: 'integer' };\n if (schema.minimum !== undefined) body['minimum'] = schema.minimum;\n if (schema.maximum !== undefined) body['maximum'] = schema.maximum;\n return described(body);\n }\n case 'array':\n return described({ type: 'array', items: toJsonSchema(schema.items) });\n case 'object': {\n const properties: { [key: string]: Json } = {};\n for (const [key, value] of Object.entries(schema.properties)) properties[key] = toJsonSchema(value);\n const body: { [key: string]: Json } = { type: 'object', properties, additionalProperties: false };\n if (schema.required !== undefined && schema.required.length > 0) body['required'] = [...schema.required];\n return described(body);\n }\n case 'map':\n return described({ type: 'object', additionalProperties: toJsonSchema(schema.values) });\n case 'anyOf':\n return described({ anyOf: schema.options.map(toJsonSchema) });\n case 'any':\n return described({});\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA2BH,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IACzC,QAAQ,OAAO,KAAK,EAAE,CAAC;QACrB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB;YACE,OAAO,QAAQ,CAAC;IACpB,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAAC,MAAc,EAAE,IAAU;IACzC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,QAAQ;YACX,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;QAC5E,KAAK,SAAS;YACZ,OAAO,IAAI,KAAK,SAAS,CAAC;QAC5B,KAAK,SAAS;YACZ,OAAO,IAAI,KAAK,QAAQ,CAAC;QAC3B,KAAK,OAAO;YACV,OAAO,IAAI,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AC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QAChE,KAAK,KAAK;YACR,OAAO,SAAS,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;AACH,CAAC","sourcesContent":["/**\n * A small schema language: one description that both validates a value and\n * renders as JSON Schema, so the published `schema.json` and the checks the\n * loader runs cannot disagree about what a configuration may say.\n */\n\ninterface Described {\n readonly description?: string;\n}\n\nexport type Schema =\n | (Described & {\n readonly type: 'string';\n readonly enum?: readonly string[];\n readonly nullable?: boolean;\n readonly minLength?: number;\n })\n | (Described & { readonly type: 'boolean' })\n | (Described & { readonly type: 'integer'; readonly minimum?: number; readonly maximum?: number })\n | (Described & { readonly type: 'array'; readonly items: Schema })\n | (Described & {\n readonly type: 'object';\n readonly properties: Readonly<Record<string, Schema>>;\n readonly required?: readonly string[];\n })\n | (Described & { readonly type: 'map'; readonly values: Schema })\n | (Described & { readonly type: 'anyOf'; readonly options: readonly Schema[] })\n | (Described & { readonly type: 'any' });\n\ntype Kind = 'null' | 'string' | 'boolean' | 'number' | 'array' | 'object';\n\nfunction kindOf(value: unknown): Kind {\n if (value === null) return 'null';\n if (Array.isArray(value)) return 'array';\n switch (typeof value) {\n case 'string':\n return 'string';\n case 'boolean':\n return 'boolean';\n case 'number':\n return 'number';\n default:\n return 'object';\n }\n}\n\nfunction accepts(schema: Schema, kind: Kind): boolean {\n switch (schema.type) {\n case 'string':\n return kind === 'string' || (kind === 'null' && schema.nullable === true);\n case 'boolean':\n return kind === 'boolean';\n case 'integer':\n return kind === 'number';\n case 'array':\n return kind === 'array';\n case 'object':\n case 'map':\n return kind === 'object';\n case 'anyOf':\n return schema.options.some((option) => accepts(option, kind));\n case 'any':\n return true;\n }\n}\n\nfunction noun(schema: Schema): string {\n switch (schema.type) {\n case 'string':\n return schema.nullable === true ? 'a string or null' : 'a string';\n case 'boolean':\n return 'true or false';\n case 'integer':\n return 'an integer';\n case 'array':\n return 'a list';\n case 'object':\n case 'map':\n return 'an object';\n case 'anyOf':\n return schema.options.map(noun).join(' or ');\n /* v8 ignore next 2 -- \"any\" accepts every value, so no message ever names it. */\n case 'any':\n return 'anything';\n }\n}\n\nfunction at(path: string, key: string): string {\n return path === '' ? key : `${path}.${key}`;\n}\n\n/** The problems with `value`, each naming the path to it. Empty when it conforms. */\nexport function validate(schema: Schema, value: unknown, path = ''): string[] {\n const where = path === '' ? 'the configuration' : `\"${path}\"`;\n if (!accepts(schema, kindOf(value))) return [`${where} must be ${noun(schema)}`];\n switch (schema.type) {\n case 'string': {\n if (typeof value !== 'string') return [];\n if (schema.enum !== undefined && !schema.enum.includes(value)) {\n return [`${where} must be one of ${schema.enum.map((e) => `\"${e}\"`).join(', ')}, not \"${value}\"`];\n }\n if (value.length < (schema.minLength ?? 0)) return [`${where} must not be empty`];\n return [];\n }\n case 'integer': {\n const number = value as number;\n if (!Number.isInteger(number)) return [`${where} must be an integer`];\n if (number < (schema.minimum ?? -Infinity)) return [`${where} must be at least ${schema.minimum}`];\n if (number > (schema.maximum ?? Infinity)) return [`${where} must be at most ${schema.maximum}`];\n return [];\n }\n case 'array':\n return (value as unknown[]).flatMap((item, i) => validate(schema.items, item, `${path}[${i}]`));\n case 'object': {\n const record = value as Record<string, unknown>;\n const known = Object.keys(schema.properties);\n const problems: string[] = [];\n for (const key of Object.keys(record)) {\n // Its own keys only: `constructor` is on every object, and is no key of a configuration.\n const property = Object.hasOwn(schema.properties, key) ? schema.properties[key] : undefined;\n if (property === undefined) {\n const guess = closest(key, known);\n problems.push(`\"${at(path, key)}\" is not a known key${guess === undefined ? '' : `; did you mean \"${guess}\"?`}`);\n continue;\n }\n problems.push(...validate(property, record[key], at(path, key)));\n }\n for (const key of schema.required ?? []) {\n if (!(key in record)) problems.push(`\"${at(path, key)}\" is required`);\n }\n return problems;\n }\n case 'map':\n return Object.entries(value as Record<string, unknown>).flatMap(([key, item]) =>\n validate(schema.values, item, at(path, key)),\n );\n case 'anyOf': {\n // Some option accepts the value's kind, or the check above would have answered: there is a first.\n const kind = kindOf(value);\n const problems = schema.options.filter((option) => accepts(option, kind)).map((option) => validate(option, value, path));\n return problems.some((found) => found.length === 0) ? [] : (problems[0] as string[]);\n }\n case 'boolean':\n case 'any':\n return [];\n }\n}\n\n/**\n * The known key nearest to a misspelling, when one is near enough to be what\n * was meant. One that keeps no character of the word is no misspelling of it,\n * however short both are: `狀態` is two edits from `id`.\n */\nexport function closest(word: string, options: readonly string[]): string | undefined {\n let best: string | undefined;\n let bestDistance = Math.max(2, Math.floor(word.length / 3)) + 1;\n for (const option of options) {\n const d = distance(word.toLowerCase(), option.toLowerCase());\n if (d < bestDistance && d < Math.max(word.length, option.length)) {\n best = option;\n bestDistance = d;\n }\n }\n return best;\n}\n\nfunction distance(a: string, b: string): number {\n let previous = Array.from({ length: b.length + 1 }, (_, j) => j);\n for (let i = 1; i <= a.length; i += 1) {\n const row = [i];\n for (let j = 1; j <= b.length; j += 1) {\n const cost = a.charAt(i - 1) === b.charAt(j - 1) ? 0 : 1;\n row.push(Math.min((previous[j] as number) + 1, row[j - 1]! + 1, previous[j - 1]! + cost));\n }\n previous = row;\n }\n return previous[b.length] as number;\n}\n\ntype Json = null | boolean | number | string | Json[] | { [key: string]: Json };\n\n/** Renders a schema as JSON Schema (draft 2020-12). */\nexport function toJsonSchema(schema: Schema): { [key: string]: Json } {\n const described = (body: { [key: string]: Json }): { [key: string]: Json } =>\n schema.description === undefined ? body : { description: schema.description, ...body };\n switch (schema.type) {\n case 'string': {\n const body: { [key: string]: Json } = { type: schema.nullable === true ? ['string', 'null'] : 'string' };\n if (schema.enum !== undefined) body['enum'] = [...schema.enum, ...(schema.nullable === true ? [null] : [])];\n if (schema.minLength !== undefined) body['minLength'] = schema.minLength;\n return described(body);\n }\n case 'boolean':\n return described({ type: 'boolean' });\n case 'integer': {\n const body: { [key: string]: Json } = { type: 'integer' };\n if (schema.minimum !== undefined) body['minimum'] = schema.minimum;\n if (schema.maximum !== undefined) body['maximum'] = schema.maximum;\n return described(body);\n }\n case 'array':\n return described({ type: 'array', items: toJsonSchema(schema.items) });\n case 'object': {\n const properties: { [key: string]: Json } = {};\n for (const [key, value] of Object.entries(schema.properties)) properties[key] = toJsonSchema(value);\n const body: { [key: string]: Json } = { type: 'object', properties, additionalProperties: false };\n if (schema.required !== undefined && schema.required.length > 0) body['required'] = [...schema.required];\n return described(body);\n }\n case 'map':\n return described({ type: 'object', additionalProperties: toJsonSchema(schema.values) });\n case 'anyOf':\n return described({ anyOf: schema.options.map(toJsonSchema) });\n case 'any':\n return described({});\n }\n}\n"]}
|
package/dist/scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,aAAa,EAAa,UAAU,EAAE,WAAW,EAAuB,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAiBzI,kDAAkD;AAClD,MAAM,UAAU,UAAU,CAAC,QAA2B,EAAE,OAAgB;IACtE,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAClC,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QACxD,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAY,EAAE,OAAgB;IACpD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,KAAK,CAAC,aAAa,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC,cAAc,EAAE,OAAO,CAAC,EAAE,CAAC;AAC7H,CAAC;AAqBD,M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;IACD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACjC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,OAAO,OAAO,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,8BAA8B,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;AACvG,CAAC;AASD,sEAAsE;AACtE,MAAM,UAAU,cAAc,CAAC,KAAY,EAAE,MAAM,GAAW,cAAc;IAC1E,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACjD,KAAK,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC/C,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC/C,IAAI,MAAM,KAAK,IAAI;YAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACtC,IAAI,MAAM,KAAK,WAAW;YAAE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC","sourcesContent":["/**\n * A brief's scope, and whether two briefs can write the same file.\n *\n * What a brief may write is its `affectedFiles` less its `protectedFiles`:\n * protection wins, so \"all of `src/` but the schema\" is written\n * `affectedFiles: [src/**]` with `protectedFiles: [src/db/schema.ts]`. Two\n * briefs meet when some file lies in both writable scopes - in a pattern of\n * each, and in neither brief's protections - and the witness is such a file\n * the tree holds, or else the shortest such path the search builds, as an\n * example (ADR-0005).\n */\n\nimport type { Brief } from './brief.js';\nimport { filesMatching, type Glob, globCovers, globWitness, type LiteralReading, matchGlob, parseGlob, WITNESS_BUDGET } from './glob.js';\n\n/** How a literal path is read, as {@link readingIn} answers for a tree. */\nexport type Reading = (path: string) => LiteralReading;\n\nexport interface ScopePattern {\n readonly pattern: string;\n readonly glob: Glob;\n}\n\nexport interface Scope {\n readonly brief: Brief;\n /** The `affectedFiles` that parse. One that does not is the `glob` rule's finding, and scopes nothing. */\n readonly affected: readonly ScopePattern[];\n readonly protected: readonly ScopePattern[];\n}\n\n/** Patterns that parse, read with one reading. */\nexport function patternsOf(patterns: readonly string[], reading: Reading): ScopePattern[] {\n return patterns.flatMap((pattern) => {\n const parsed = parseGlob(pattern, { literal: reading });\n return parsed.ok ? [{ pattern, glob: parsed.glob }] : [];\n });\n}\n\nexport function scopeOf(brief: Brief, reading: Reading): Scope {\n return { brief, affected: patternsOf(brief.affectedFiles, reading), protected: patternsOf(brief.protectedFiles, reading) };\n}\n\n/** A pattern from each scope, and a file both may write. */\nexport interface Overlap {\n readonly patterns: readonly [string, string];\n readonly witness: string;\n /**\n * `true` when the witness is a file the tree holds; `false` when the tree\n * holds none both patterns match outside the protections, and the witness\n * is an example the search built; `null` when no tree was given.\n */\n readonly inTree: boolean | null;\n}\n\nexport interface Meeting {\n /** Every pair of patterns that meets outside both protections, the first scope's pattern first. */\n readonly overlaps: readonly Overlap[];\n /** Pairs of patterns the search could not decide within its budget, and no file of the tree decides. */\n readonly undecided: readonly (readonly [string, string])[];\n}\n\nconst matched = new WeakMap<readonly string[], WeakMap<Glob, ReadonlySet<string>>>();\n\n/**\n * The files of a tree a pattern matches, in the tree's order. Found once per\n * pattern and tree, which every pair a brief is in shares; kept or not, the\n * answer is the same, and only the time differs.\n */\nfunction matching(files: readonly string[], glob: Glob): ReadonlySet<string> {\n let byGlob = matched.get(files);\n if (byGlob === undefined) {\n byGlob = new WeakMap();\n matched.set(files, byGlob);\n }\n let found = byGlob.get(glob);\n if (found === undefined) {\n found = new Set(filesMatching(glob, files));\n byGlob.set(glob, found);\n }\n return found;\n}\n\n/**\n * The first file of the tree, in its order, that both patterns match and no\n * protection does. The engine's list is sorted, so the file named is the same\n * on every run.\n */\nfunction heldInBoth(files: readonly string[], x: Glob, y: Glob, avoid: readonly Glob[]): string | undefined {\n const other = matching(files, y);\n for (const file of matching(files, x)) {\n if (other.has(file) && !avoid.some((glob) => matchGlob(glob, file))) return file;\n }\n return undefined;\n}\n\n/**\n * Where two writable scopes meet. Each pair of affected patterns is searched\n * for a file both cover that neither brief protects: a file one brief protects\n * is one that brief will not write, so it is no collision.\n *\n * The search names the shortest such path, which the tree need not hold:\n * `src/Shop/OrderService.cs` where the tree has `src/Shop/Orders/OrderService.cs`.\n * So where the search finds a meeting, or cannot decide one, the tree's files\n * are read, and the first both patterns match outside the protections is the\n * witness (ADR-0005, amended 2026-09-30). A file that exists and both briefs\n * may write settles a pair the search could not: it is a collision, proved by\n * the file, not a guess. Where the tree holds none, the search's path stands,\n * as an example. A pair the search proves apart has no such file, and the tree\n * is not read for it.\n */\nexport function meet(a: Scope, b: Scope, budget: number = WITNESS_BUDGET, files: readonly string[] | null = null): Meeting {\n const avoid = [...a.protected, ...b.protected].map((p) => p.glob);\n const overlaps: Overlap[] = [];\n const undecided: (readonly [string, string])[] = [];\n for (const x of a.affected) {\n for (const y of b.affected) {\n const witness = globWitness([x.glob, y.glob], avoid, budget);\n if (witness.kind === 'none') continue;\n const patterns = [x.pattern, y.pattern] as const;\n const held = files === null ? undefined : heldInBoth(files, x.glob, y.glob, avoid);\n if (held !== undefined) overlaps.push({ patterns, witness: held, inTree: true });\n else if (witness.kind === 'found') overlaps.push({ patterns, witness: witness.path, inTree: files === null ? null : false });\n else undecided.push(patterns);\n }\n }\n return { overlaps, undecided };\n}\n\n/**\n * A witness as a reader is told it: a file of the tree by its path, and a path\n * the search built with a word that it is an example.\n */\nexport function witnessText(overlap: Overlap): string {\n return overlap.inTree === false ? `${overlap.witness}, an example not in the tree` : overlap.witness;\n}\n\nexport interface Contradiction {\n /** Affected patterns every file of which is protected: nothing of them is writable. */\n readonly covered: readonly string[];\n /** Affected patterns for which the search could not decide within its budget. */\n readonly undecided: readonly string[];\n}\n\n/** The affected patterns a brief's own protections cover entirely. */\nexport function contradictions(scope: Scope, budget: number = WITNESS_BUDGET): Contradiction {\n const covered: string[] = [];\n const undecided: string[] = [];\n const outer = scope.protected.map((p) => p.glob);\n for (const { pattern, glob } of scope.affected) {\n const answer = globCovers(outer, glob, budget);\n if (answer === true) covered.push(pattern);\n else if (answer === 'undecided') undecided.push(pattern);\n }\n return { covered, undecided };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,aAAa,EAAa,UAAU,EAAE,WAAW,EAAuB,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAiBzI,kDAAkD;AAClD,MAAM,UAAU,UAAU,CAAC,QAA2B,EAAE,OAAgB;IACtE,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAClC,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QACxD,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAY,EAAE,OAAgB;IACpD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,KAAK,CAAC,aAAa,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC,cAAc,EAAE,OAAO,CAAC,EAAE,CAAC;AAC7H,CAAC;AAqBD,MAAM,OAAO,GAAG,IAAI,OAAO,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AE,SAAS,EAAE,CAAC;AACjC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,OAAO,OAAO,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,8BAA8B,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;AACvG,CAAC;AASD,sEAAsE;AACtE,MAAM,UAAU,cAAc,CAAC,KAAY,EAAE,MAAM,GAAW,cAAc;IAC1E,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACjD,KAAK,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC/C,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC/C,IAAI,MAAM,KAAK,IAAI;YAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACtC,IAAI,MAAM,KAAK,WAAW;YAAE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC","sourcesContent":["/**\n * A brief's scope, and whether two briefs can write the same file.\n *\n * What a brief may write is its `affectedFiles` less its `protectedFiles`:\n * protection wins, so \"all of `src/` but the schema\" is written\n * `affectedFiles: [src/**]` with `protectedFiles: [src/db/schema.ts]`. Two\n * briefs meet when some file lies in both writable scopes - in a pattern of\n * each, and in neither brief's protections - and the witness is such a file\n * the tree holds, or else the shortest such path the search builds, as an\n * example (ADR-0005).\n */\n\nimport type { Brief } from './brief.js';\nimport { filesMatching, type Glob, globCovers, globWitness, type LiteralReading, matchGlob, parseGlob, WITNESS_BUDGET } from './glob.js';\n\n/** How a literal path is read, as {@link readingIn} answers for a tree. */\nexport type Reading = (path: string) => LiteralReading;\n\nexport interface ScopePattern {\n readonly pattern: string;\n readonly glob: Glob;\n}\n\nexport interface Scope {\n readonly brief: Brief;\n /** The `affectedFiles` that parse. One that does not is the `glob` rule's finding, and scopes nothing. */\n readonly affected: readonly ScopePattern[];\n readonly protected: readonly ScopePattern[];\n}\n\n/** Patterns that parse, read with one reading. */\nexport function patternsOf(patterns: readonly string[], reading: Reading): ScopePattern[] {\n return patterns.flatMap((pattern) => {\n const parsed = parseGlob(pattern, { literal: reading });\n return parsed.ok ? [{ pattern, glob: parsed.glob }] : [];\n });\n}\n\nexport function scopeOf(brief: Brief, reading: Reading): Scope {\n return { brief, affected: patternsOf(brief.affectedFiles, reading), protected: patternsOf(brief.protectedFiles, reading) };\n}\n\n/** A pattern from each scope, and a file both may write. */\nexport interface Overlap {\n readonly patterns: readonly [string, string];\n readonly witness: string;\n /**\n * `true` when the witness is a file the tree holds; `false` when the tree\n * holds none both patterns match outside the protections, and the witness\n * is an example the search built; `null` when no tree was given.\n */\n readonly inTree: boolean | null;\n}\n\nexport interface Meeting {\n /** Every pair of patterns that meets outside both protections, the first scope's pattern first. */\n readonly overlaps: readonly Overlap[];\n /** Pairs of patterns the search could not decide within its budget, and no file of the tree decides. */\n readonly undecided: readonly (readonly [string, string])[];\n}\n\nconst matched = new WeakMap<readonly string[], WeakMap<Glob, ReadonlySet<string>>>();\n\n/**\n * The files of a tree a pattern matches, in the tree's order. Found once per\n * pattern and tree, which every pair a brief is in shares; kept or not, the\n * answer is the same, and only the time differs.\n */\nfunction matching(files: readonly string[], glob: Glob): ReadonlySet<string> {\n let byGlob = matched.get(files);\n if (byGlob === undefined) {\n byGlob = new WeakMap();\n matched.set(files, byGlob);\n }\n let found = byGlob.get(glob);\n if (found === undefined) {\n found = new Set(filesMatching(glob, files));\n byGlob.set(glob, found);\n }\n return found;\n}\n\n/**\n * The first file of the tree, in its order, that both patterns match and no\n * protection does. The engine's list is sorted, so the file named is the same\n * on every run.\n */\nfunction heldInBoth(files: readonly string[], x: Glob, y: Glob, avoid: readonly Glob[]): string | undefined {\n const other = matching(files, y);\n for (const file of matching(files, x)) {\n if (other.has(file) && !avoid.some((glob) => matchGlob(glob, file))) return file;\n }\n return undefined;\n}\n\n/**\n * Where two writable scopes meet. Each pair of affected patterns is searched\n * for a file both cover that neither brief protects: a file one brief protects\n * is one that brief will not write, so it is no collision.\n *\n * The search names the shortest such path, which the tree need not hold:\n * `src/Shop/OrderService.cs` where the tree has `src/Shop/Orders/OrderService.cs`.\n * So where the search finds a meeting, or cannot decide one, the tree's files\n * are read, and the first both patterns match outside the protections is the\n * witness (ADR-0005, amended 2026-09-30). A file that exists and both briefs\n * may write settles a pair the search could not: it is a collision, proved by\n * the file, not a guess. Where the tree holds none, the search's path stands,\n * as an example. A pair the search proves apart has no such file, and the tree\n * is not read for it.\n */\nexport function meet(a: Scope, b: Scope, budget: number = WITNESS_BUDGET, files: readonly string[] | null = null): Meeting {\n const avoid = [...a.protected, ...b.protected].map((p) => p.glob);\n const overlaps: Overlap[] = [];\n const undecided: (readonly [string, string])[] = [];\n for (const x of a.affected) {\n for (const y of b.affected) {\n const witness = globWitness([x.glob, y.glob], avoid, budget);\n if (witness.kind === 'none') continue;\n const patterns: readonly [string, string] = [x.pattern, y.pattern];\n const held = files === null ? undefined : heldInBoth(files, x.glob, y.glob, avoid);\n if (held !== undefined) overlaps.push({ patterns, witness: held, inTree: true });\n else if (witness.kind === 'found') overlaps.push({ patterns, witness: witness.path, inTree: files === null ? null : false });\n else undecided.push(patterns);\n }\n }\n return { overlaps, undecided };\n}\n\n/**\n * A witness as a reader is told it: a file of the tree by its path, and a path\n * the search built with a word that it is an example.\n */\nexport function witnessText(overlap: Overlap): string {\n return overlap.inTree === false ? `${overlap.witness}, an example not in the tree` : overlap.witness;\n}\n\nexport interface Contradiction {\n /** Affected patterns every file of which is protected: nothing of them is writable. */\n readonly covered: readonly string[];\n /** Affected patterns for which the search could not decide within its budget. */\n readonly undecided: readonly string[];\n}\n\n/** The affected patterns a brief's own protections cover entirely. */\nexport function contradictions(scope: Scope, budget: number = WITNESS_BUDGET): Contradiction {\n const covered: string[] = [];\n const undecided: string[] = [];\n const outer = scope.protected.map((p) => p.glob);\n for (const { pattern, glob } of scope.affected) {\n const answer = globCovers(outer, glob, budget);\n if (answer === true) covered.push(pattern);\n else if (answer === 'undecided') undecided.push(pattern);\n }\n return { covered, undecided };\n}\n"]}
|
package/dist/text.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,sFAAsF;AACtF,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE;QAAE,KAAK,CAAC,GAAG,EAAE,CAAC;IACpE,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,KAAwB;IAClD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,SAAS,CAAC,KAAwB,EAAE,GAAkB;IACpE,OAAO,KAAK,CAAC,MA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CAAC,QAAgB;IAC5C,OAAO,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAW,CAAC,CAAC;AACvF,CAAC","sourcesContent":["/**\n * Line handling and the normalisations every other module agrees on.\n */\n\n/** Splits text into lines without their terminators. A final newline adds no line. */\nexport function splitLines(text: string): string[] {\n const lines = text.split(/\\r?\\n/);\n if (lines.length > 1 && lines[lines.length - 1] === '') lines.pop();\n return lines;\n}\n\n/**\n * A brief's lines as one text, for spec-core's readers.\n *\n * A brief's lines end at LF or CRLF, and a sealed brief's hash is taken over\n * them. spec-core ends a line at a lone CR as well, as CommonMark does, so a\n * lone CR is handed to it as a space: every line and column it reports is\n * then one of the brief's own.\n */\nexport function textOfLines(lines: readonly string[]): string {\n return lines.join('\\n').replace(/\\r/g, ' ');\n}\n\n/**\n * The line ending a file already uses, so a rewrite does not flip it. Decided by\n * the first terminator; a file with none is written with LF.\n */\nexport function lineEnding(text: string): '\\n' | '\\r\\n' {\n return text.charAt(text.indexOf('\\n') - 1) === '\\r' ? '\\r\\n' : '\\n';\n}\n\n/** Joins lines with the given ending and a final newline. */\nexport function joinLines(lines: readonly string[], eol: '\\n' | '\\r\\n'): string {\n return lines.length === 0 ? '' : `${lines.join(eol)}${eol}`;\n}\n\n/** Lines written back with the source's byte-order mark, line ending and final newline, or lack of one. */\nexport function encodeLike(source: string, lines: readonly string[]): string {\n const bom = source.charCodeAt(0) === 0xfeff ? '\\uFEFF' : '';\n const eol = lineEnding(source);\n const text = joinLines(lines, eol);\n const finalNewline = source === '' || source.endsWith('\\n');\n return `${bom}${finalNewline ? text : text.slice(0, text.length - eol.length)}`;\n}\n\nexport function stripBom(text: string): string {\n return text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;\n}\n\n/** CRLF and a byte-order mark are storage details, not content. */\nexport function canonicalText(text: string): string {\n return stripBom(text).replace(/\\r\\n/g, '\\n');\n}\n\n/**\n * The form in which two section names are compared.\n *\n * Headings are typed by people and pasted from documents, so the comparison\n * forgives what does not change meaning: typographic apostrophes and quotes,\n * emphasis and code markers, a leading number, a trailing colon, case and runs\n * of whitespace. `## 2. Commander’s Intent:` and `Commander's Intent` compare\n * equal. Nothing else is folded: a different word is a different section.\n */\nexport function normaliseLabel(label: string): string {\n return label\n .normalize('NFKC')\n .replace(/[\\u2018\\u2019\\u201b\\u2032\\u00b4]/g, \"'\")\n .replace(/[\\u201c\\u201d\\u201f\\u2033]/g, '\"')\n .replace(/[*_`]/g, '')\n .replace(/^\\s*\\d+(?:\\.\\d+)*[.)]?\\s/, '')\n .replace(/\\s*:\\s*$/, '')\n .replace(/\\s+/g, ' ')\n .trim()\n .toLowerCase();\n}\n\n/**\n * Whether a heading names a section: equal after normalisation, or the section\n * name followed by a separator and a qualifier, as in `Invariants (must hold)`\n * or `Deliverables — round two`.\n */\nexport function labelMatches(heading: string, name: string): boolean {\n const h = normaliseLabel(heading);\n const n = normaliseLabel(name);\n if (n.length === 0) return false;\n if (h === n) return true;\n if (!h.startsWith(n)) return false;\n // Normalised, so whitespace is single spaces.\n const rest = h.slice(n.length);\n return /^(?:\\s*[:(\\u2014\\u2013]|\\s-\\s)/.test(rest);\n}\n\n/**\n * A file-name slug: lower case, ASCII letters and digits, single hyphens.\n * Letters with diacritics lose them; anything else becomes a separator.\n */\nexport function slugify(title: string, maxLength = 80): string {\n const slug = title\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-|-$/g, '');\n if (slug.length <= maxLength) return slug;\n const cut = slug.slice(0, maxLength);\n // A cut that lands on a break keeps its last word whole.\n if (slug.charAt(maxLength) === '-') return cut;\n const lastBreak = cut.lastIndexOf('-');\n return lastBreak === -1 ? cut : cut.slice(0, lastBreak);\n}\n\n/** `a`, `a and b`, `a, b and c`. */\nexport function inWords(items: readonly string[]): string {\n return items.length < 2 ? (items[0] ?? '') : `${items.slice(0, -1).join(', ')} and ${items[items.length - 1]!}`;\n}\n\n/**\n * Fills `{name}` holes. An unknown name is left as written, and a name every\n * object answers to, `{constructor}`, is unknown unless it was given.\n */\nexport function fillTemplate(template: string, values: Readonly<Record<string, string>>): string {\n return template.replace(/\\{([A-Za-z]+)\\}/g, (hole, name: string) => (Object.hasOwn(values, name) ? (values[name] as string) : hole));\n}\n\n/** The `{name}` holes a template line refers to. */\nexport function templateHoles(template: string): string[] {\n return [...template.matchAll(/\\{([A-Za-z]+)\\}/g)].map((match) => match[1] as string);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/markdown/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AA0DxC,MAAM,SAAS,GAAG,aAAa,CAAC;AAChC,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAC5C,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAEpC,4FAA4F;AAC5F,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;QAAE,OAAO,MAAM,CAAC;IAC7C,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACpD,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,IAAqB;IACnE,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChE,CAAC;A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,GAAG,KAAK,CAAC,CAAC;IAC3C,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["/**\n * A reader and editor for the front matter the spec-* tools use: a flat bag\n * of YAML scalars and lists, and optionally one level of nested mapping.\n *\n * Supported: `key: value` lines; plain, single-quoted and double-quoted\n * scalars; inline `[a, b]` sequences; block `- item` sequences; `#` comments.\n * Plain scalars follow the YAML 1.2 core schema, so `yes` is a word and `035`\n * keeps its leading zero for whoever reads it as text. With `nested`, a key\n * whose value is an indented block of keys is read as `parent.child` entries.\n *\n * Anything richer - deeper nesting, block scalars, anchors, tags, a value\n * continued onto the next line - is recognised and reported as unsupported\n * rather than guessed at. A YAML library would parse more, but it would not\n * give back the line and the offset of every value, and a report has to point\n * at the value it is about, and an edit has to leave every other line of the\n * file as it was.\n */\n\nimport { lineStarts, splitLines, stripBom } from '../text/index.js';\nimport { leadIndex } from './syntax.js';\nimport type { FrontMatterKind } from './types.js';\n\nexport interface YamlScalar {\n readonly text: string;\n readonly quoted: boolean;\n}\n\nexport type YamlValue =\n | { readonly kind: 'scalar'; readonly scalar: YamlScalar }\n | { readonly kind: 'list'; readonly items: readonly YamlScalar[] }\n | { readonly kind: 'unsupported'; readonly reason: string };\n\nexport interface FrontMatterEntry {\n /** The key as written; a nested key is its parent's and its own, joined by a dot. */\n readonly key: string;\n /** The key compared: {@link keyName} of `key`, so `depends-on` is `dependsOn`. */\n readonly name: string;\n /** The parent key as written, for a nested key; `null` at the top level. */\n readonly parent: string | null;\n /** 0-based line of the key. */\n readonly line: number;\n /** 0-based line after the entry's last line. */\n readonly end: number;\n /** Offset of the key in the text read. */\n readonly keyStart: number;\n /**\n * Offsets of the value as written: a quoted scalar with its quotes, an\n * inline list with its brackets, a block list from its first item's text to\n * its last item's. An empty value is the empty range just past the colon.\n */\n readonly valueStart: number;\n readonly valueEnd: number;\n readonly value: YamlValue;\n}\n\nexport interface FrontMatterProblem {\n /** 0-based line. */\n readonly line: number;\n readonly message: string;\n}\n\nexport interface FrontMatter {\n readonly kind: FrontMatterKind;\n /** 0-based line of the closing delimiter, or -1 when the block is never closed. */\n readonly close: number;\n readonly entries: readonly FrontMatterEntry[];\n readonly problems: readonly FrontMatterProblem[];\n}\n\nexport interface ReadOptions {\n /**\n * Read one level of nested mapping as `parent.child` entries, instead of\n * reporting the parent's value as unsupported.\n */\n readonly nested?: boolean;\n}\n\nconst YAML_OPEN = /^---[ \\t]*$/;\nconst YAML_CLOSE = /^(?:---|\\.\\.\\.)[ \\t]*$/;\nconst TOML_FENCE = /^\\+\\+\\+[ \\t]*$/;\n\n/** The kind of front matter a document's first line opens, or `null` when it opens none. */\nexport function frontMatterKind(firstLine: string): FrontMatterKind | null {\n if (YAML_OPEN.test(firstLine)) return 'yaml';\n return TOML_FENCE.test(firstLine) ? 'toml' : null;\n}\n\n/** Whether a line closes front matter of a kind: `---` or `...` for YAML, `+++` for TOML. */\nexport function frontMatterCloses(line: string, kind: FrontMatterKind): boolean {\n return (kind === 'yaml' ? YAML_CLOSE : TOML_FENCE).test(line);\n}\n\n/**\n * A key and what follows its colon. A key is a word of any script, as a YAML\n * plain key may be: a letter or `_` first, then letters, marks, digits and\n * `_.-`, so `狀態` and `状态` are keys as `status` is. Nothing else is one: a\n * digit or a mark first, a space, punctuation, and a full-width colon, which\n * YAML does not read as one.\n */\nconst KEY = /^([\\p{L}_][\\p{L}\\p{M}\\p{N}_.-]*)[ \\t]*:(?:[ \\t]+(.*))?$/u;\nconst SEQUENCE_ITEM = /^([ \\t]*)-(?:[ \\t]+(.*))?$/;\nconst BLANK_OR_COMMENT = /^[ \\t]*(?:#.*)?$/;\n\nexport function keyName(key: string): string {\n return key.toLowerCase().replace(/[-_]/g, '');\n}\n\n/**\n * Reads the front matter at the top of a text, or `null` when there is none.\n *\n * A leading byte-order mark is not part of the text read: offsets count from\n * the character after it, as a scan's do.\n */\nexport function readFrontMatter(source: string, options: ReadOptions = {}): FrontMatter | null {\n const text = stripBom(source);\n const lines = splitLines(text);\n const kind = frontMatterKind(lines[0] as string);\n if (kind === null) return null;\n const close = lines.findIndex((line, i) => i > 0 && frontMatterCloses(line, kind));\n if (close === -1) {\n return { kind, close, entries: [], problems: [{ line: 0, message: 'the front matter opened on line 1 is never closed' }] };\n }\n if (kind === 'toml') {\n return { kind, close, entries: [], problems: [{ line: 0, message: 'TOML front matter is not read; write YAML between \"---\" lines' }] };\n }\n\n const reader: Reader = {\n lines,\n starts: lineStarts(text),\n nested: options.nested === true,\n entries: [],\n problems: [],\n seen: new Map(),\n };\n let i = 1;\n while (i < close) {\n const line = lines[i] as string;\n if (BLANK_OR_COMMENT.test(line)) {\n i += 1;\n continue;\n }\n const match = KEY.exec(line);\n if (match === null) {\n reader.problems.push({\n line: i,\n message: /^\\s/.test(line) ? 'an indented line belongs to no key' : 'not a \"key: value\" line',\n });\n i += 1;\n continue;\n }\n // The closing delimiter belongs to no value, so the block stops there.\n let end = i + 1;\n while (belongsToBlock(lines[end] as string)) end += 1;\n end = trimBlock(lines, end);\n readEntry(reader, { key: match[1] as string, parent: null, line: i, column: 0, inline: match[2] ?? '', end });\n i = end;\n }\n return { kind, close, entries: reader.entries, problems: reader.problems };\n}\n\ninterface Reader {\n readonly lines: readonly string[];\n readonly starts: readonly number[];\n readonly nested: boolean;\n readonly entries: FrontMatterEntry[];\n readonly problems: FrontMatterProblem[];\n readonly seen: Map<string, number>;\n}\n\ninterface KeyLine {\n /** The key as written on its line, without a parent. */\n readonly key: string;\n readonly parent: string | null;\n readonly line: number;\n /** Column of the key. */\n readonly column: number;\n /** What follows the colon and its whitespace, as written. */\n readonly inline: string;\n /** 0-based line after the key's value. */\n readonly end: number;\n}\n\n/** A line under a top-level key is part of its value when it is indented or starts a sequence item. */\nfunction belongsToBlock(line: string): boolean {\n return /^[ \\t]/.test(line) || /^-(?:[ \\t]|$)/.test(line) || line.trim() === '';\n}\n\n/**\n * Takes trailing blank and comment lines off a value's block: they belong to\n * no key. The key's own line is neither, so the walk stops there at the latest.\n */\nfunction trimBlock(lines: readonly string[], end: number): number {\n let at = end;\n while (BLANK_OR_COMMENT.test(lines[at - 1] as string)) at -= 1;\n return at;\n}\n\nfunction note(reader: Reader, key: string, line: number): string {\n const name = keyName(key);\n const previous = reader.seen.get(name);\n if (previous === undefined) reader.seen.set(name, line);\n else reader.problems.push({ line, message: `\"${key}\" is declared twice (first on line ${previous + 1})` });\n return name;\n}\n\nfunction readEntry(reader: Reader, at: KeyLine): void {\n const { lines, starts } = reader;\n const text = lines[at.line] as string;\n const lineStart = starts[at.line] as number;\n const key = at.parent === null ? at.key : `${at.parent}.${at.key}`;\n // A key holds no colon and nothing before it does, so the first is its own.\n const colon = lineStart + text.indexOf(':') + 1;\n // What follows the colon starts after its whitespace; what ends it is\n // trimmed by whichever reader takes it.\n const inline = stripLeadingComment(at.inline);\n\n let read: Read;\n if (inline.length > 0) {\n const valueStart = lineStart + text.length - at.inline.length;\n const continued = contentLines(lines, at.line + 1, at.end).length > 0;\n const parsed = continued\n ? rough(unsupported('the value continues on the next line; keep it on one line, or quote it'), inline)\n : readInline(inline);\n read = { value: parsed.value, valueStart, valueEnd: valueStart + parsed.length };\n } else {\n const content = contentLines(lines, at.line + 1, at.end);\n const first = content[0];\n if (first !== undefined && at.parent === null && reader.nested && KEY.test((lines[first] as string).trim())) {\n note(reader, at.key, at.line);\n readChildren(reader, at.key, at.line + 1, at.end);\n return;\n }\n read = readBlock(reader, content, colon, at.parent === null);\n }\n\n reader.entries.push({\n key,\n name: note(reader, key, at.line),\n parent: at.parent,\n line: at.line,\n end: at.end,\n keyStart: lineStart + at.column,\n ...read,\n });\n}\n\n/** One level of keys under a parent, all at the indentation of the first. */\nfunction readChildren(reader: Reader, parent: string, from: number, end: number): void {\n const { lines } = reader;\n const first = lines[contentLines(lines, from, end)[0] as number] as string;\n const lead = first.slice(0, leadIndex(first));\n let i = from;\n while (i < end) {\n const line = lines[i] as string;\n if (BLANK_OR_COMMENT.test(line)) {\n i += 1;\n continue;\n }\n // A line deeper than the keys is always taken by the key above it, so only\n // one at their indentation or shallower reaches here.\n const match = line.startsWith(lead) ? KEY.exec(line.slice(lead.length)) : null;\n if (match === null) {\n reader.problems.push({ line: i, message: 'not a \"key: value\" line at the indentation of the keys before it' });\n i += 1;\n continue;\n }\n // Past the parent's value, a line belongs to a child only when it is blank\n // or a comment, and those are trimmed off again.\n let childEnd = i + 1;\n while (belongsToChild(lines[childEnd] as string, lead)) childEnd += 1;\n childEnd = trimBlock(lines, childEnd);\n readEntry(reader, { key: match[1] as string, parent, line: i, column: lead.length, inline: match[2] ?? '', end: childEnd });\n i = childEnd;\n }\n}\n\n/** A line under a nested key is part of its value when it is deeper, or a sequence item at the key's indentation. */\nfunction belongsToChild(line: string, lead: string): boolean {\n if (line.trim() === '') return true;\n if (!line.startsWith(lead)) return false;\n return /^(?:[ \\t]|-(?:[ \\t]|$))/.test(line.slice(lead.length));\n}\n\ninterface Read {\n readonly value: YamlValue;\n readonly valueStart: number;\n readonly valueEnd: number;\n}\n\n/** Indices of the lines in a range that are neither blank nor a comment. */\nfunction contentLines(lines: readonly string[], from: number, end: number): number[] {\n const out: number[] = [];\n for (let i = from; i < end; i += 1) if (!BLANK_OR_COMMENT.test(lines[i] as string)) out.push(i);\n return out;\n}\n\n/** A value written on the lines under its key. */\nfunction readBlock(reader: Reader, content: readonly number[], colon: number, topLevel: boolean): Read {\n const { lines, starts } = reader;\n const first = content[0];\n if (first === undefined) return { value: { kind: 'scalar', scalar: { text: '', quoted: false } }, valueStart: colon, valueEnd: colon };\n\n // An unsupported block is reported over all of its content lines.\n const firstText = lines[first] as string;\n const last = content[content.length - 1] as number;\n const whole = (value: YamlValue): Read => ({\n value,\n valueStart: (starts[first] as number) + leadIndex(firstText),\n valueEnd: (starts[last] as number) + (lines[last] as string).trimEnd().length,\n });\n\n const head = SEQUENCE_ITEM.exec(firstText);\n if (head === null) {\n // Quoting a list would make it a string, so a list gets its own advice.\n if (firstText.trim().startsWith('[')) return whole(unsupported('an inline list starts on the line after its key; write it after the colon'));\n if (!KEY.test(firstText.trim())) return whole(unsupported('the value continues on the next line; keep it on one line, or quote it'));\n return whole(\n unsupported(topLevel ? 'nested mappings are not supported; flatten the key' : 'only one level of nesting is read; flatten the key'),\n );\n }\n const indent = (head[1] as string).length;\n const items: YamlScalar[] = [];\n const spans: [number, number][] = [];\n for (const index of content) {\n const line = lines[index] as string;\n const item = SEQUENCE_ITEM.exec(line);\n if (item === null || (item[1] as string).length !== indent) {\n return whole(unsupported('a list item is continued or nested; keep each item on one line'));\n }\n // The item's text starts after its whitespace, as a key's value does.\n const written = item[2] ?? '';\n const text = stripLeadingComment(written);\n if (text.length === 0) return whole(unsupported('a list item is empty'));\n const parsed = readInline(text);\n if (parsed.value.kind !== 'scalar') {\n return whole(parsed.value.kind === 'list' ? unsupported('nested lists are not supported') : parsed.value);\n }\n const start = (starts[index] as number) + line.length - written.length;\n spans.push([start, start + parsed.length]);\n items.push(parsed.value.scalar);\n }\n return { value: { kind: 'list', items }, valueStart: (spans[0] as [number, number])[0], valueEnd: (spans[spans.length - 1] as [number, number])[1] };\n}\n\nfunction stripLeadingComment(text: string): string {\n return text.startsWith('#') ? '' : text;\n}\n\nfunction unsupported(reason: string): YamlValue {\n return { kind: 'unsupported', reason };\n}\n\ninterface Parsed {\n readonly value: YamlValue;\n /** Characters of the text the value spans. */\n readonly length: number;\n}\n\n/** An unsupported value spans its text up to any comment. */\nfunction rough(value: YamlValue, text: string): Parsed {\n return { value, length: stripTrailingComment(text).length };\n}\n\n/** Parses a value written on the key's own line. `text` is trimmed and non-empty. */\nexport function parseInline(text: string): YamlValue {\n return readInline(text).value;\n}\n\n/** `text` starts with the value; whitespace after it is allowed. */\nfunction readInline(text: string): Parsed {\n const head = text.charAt(0);\n if (head === '\"' || head === \"'\") {\n const quoted = head === '\"' ? readDoubleQuoted(text) : readSingleQuoted(text);\n if (typeof quoted === 'string') return rough(unsupported(quoted), text);\n return trailingIsComment(text.slice(quoted.next))\n ? { value: { kind: 'scalar', scalar: { text: quoted.text, quoted: true } }, length: quoted.next }\n : rough(unsupported('text follows a closing quote'), text);\n }\n if (head === '[') return parseFlowSequence(text);\n if (head === '{') return rough(unsupported('inline mappings are not supported'), text);\n if (head === '|' || head === '>') return rough(unsupported('block scalars are not supported; keep the value on one line'), text);\n if (head === '&' || head === '*' || head === '!') return rough(unsupported('anchors, aliases and tags are not supported'), text);\n if (head === '@' || head === '`') return rough(unsupported(`a plain value cannot start with \"${head}\"; quote it`), text);\n const plain = stripTrailingComment(text);\n if (/:(?:\\s|$)/.test(plain)) return rough(unsupported('a plain value cannot contain \": \"; quote it'), text);\n if (/^-(?:\\s|$)/.test(plain)) return rough(unsupported('a list must start on the line after its key'), text);\n return { value: { kind: 'scalar', scalar: { text: plain, quoted: false } }, length: plain.length };\n}\n\n/** A comment starts at a `#` after whitespace; a `#` inside a word is text. */\nfunction stripTrailingComment(text: string): string {\n return (text.split(/\\s#/, 1)[0] as string).trim();\n}\n\n/** Nothing after a closing quote or bracket, or whitespace and then a comment. */\nfunction trailingIsComment(rest: string): boolean {\n return /^(?:\\s+(?:#.*)?)?$/.test(rest);\n}\n\ninterface Quoted {\n readonly text: string;\n /** Index just past the closing quote. */\n readonly next: number;\n}\n\nconst ESCAPES: Readonly<Record<string, string>> = {\n '\"': '\"',\n '\\\\': '\\\\',\n '/': '/',\n '0': '\\u0000',\n b: '\\b',\n f: '\\f',\n n: '\\n',\n r: '\\r',\n t: '\\t',\n};\n\nconst HEX_ESCAPE_LENGTH: Readonly<Record<string, number>> = { x: 2, u: 4, U: 8 };\n\n/** Reads a double-quoted scalar starting at index 0, or returns why it cannot. */\nfunction readDoubleQuoted(text: string): Quoted | string {\n let out = '';\n for (let i = 1; ; i += 1) {\n const ch = text.charAt(i);\n if (ch === '') return 'a double-quoted value is never closed';\n if (ch === '\"') return { text: out, next: i + 1 };\n if (ch !== '\\\\') {\n out += ch;\n continue;\n }\n const code = text.charAt(i + 1);\n const simple = ESCAPES[code];\n if (simple !== undefined) {\n out += simple;\n i += 1;\n continue;\n }\n // An escape this reader does not know has no digits to read, and no\n // digits are not a number.\n const width = HEX_ESCAPE_LENGTH[code] ?? 0;\n const hex = text.slice(i + 2, i + 2 + width);\n if (hex.length !== width || !/^[0-9A-Fa-f]+$/.test(hex)) return `\"\\\\${code}\" is not an escape this reader knows`;\n const point = Number.parseInt(hex, 16);\n if (point > 0x10ffff) return `\"\\\\${code}${hex}\" is not a character`;\n out += String.fromCodePoint(point);\n i += 1 + width;\n }\n}\n\nfunction readSingleQuoted(text: string): Quoted | string {\n let out = '';\n for (let i = 1; ; i += 1) {\n const ch = text.charAt(i);\n if (ch === '') return 'a single-quoted value is never closed';\n if (ch !== \"'\") {\n out += ch;\n continue;\n }\n if (text.charAt(i + 1) !== \"'\") return { text: out, next: i + 1 };\n out += \"'\";\n i += 1;\n }\n}\n\n/** The first index at or after `from` that is not whitespace. */\nfunction skipSpace(text: string, from: number): number {\n let i = from;\n while (/\\s/.test(text.charAt(i))) i += 1;\n return i;\n}\n\nfunction parseFlowSequence(text: string): Parsed {\n const items: YamlScalar[] = [];\n const fail = (reason: string): Parsed => rough(unsupported(reason), text);\n let i = 1;\n for (;;) {\n i = skipSpace(text, i);\n const ch = text.charAt(i);\n if (ch === '') return fail('an inline list is never closed; keep it on one line');\n if (ch === ']') {\n return trailingIsComment(text.slice(i + 1))\n ? { value: { kind: 'list', items }, length: i + 1 }\n : fail('text follows the end of an inline list');\n }\n if (ch === '[' || ch === '{') return fail('nested lists and mappings are not supported');\n if (ch === ',') return fail('an inline list has an empty item');\n if (ch === '\"' || ch === \"'\") {\n const rest = text.slice(i);\n const quoted = ch === '\"' ? readDoubleQuoted(rest) : readSingleQuoted(rest);\n if (typeof quoted === 'string') return fail(quoted);\n items.push({ text: quoted.text, quoted: true });\n i += quoted.next;\n } else {\n let j = i;\n // One step past the end reads nothing and slices nothing more, so the\n // bound could be one further and still stop the walk.\n while (j < text.length && text.charAt(j) !== ',' && text.charAt(j) !== ']') j += 1;\n const plain = text.slice(i, j).trim();\n if (/[[{]/.test(plain) || /:(?:\\s|$)/.test(plain) || plain.includes(' #')) {\n return fail(`\"${plain}\" needs quoting inside an inline list`);\n }\n items.push({ text: plain, quoted: false });\n i = j;\n }\n i = skipSpace(text, i);\n // After a comma the next pass reads an item or, legally in YAML, the\n // bracket; at the end of the text it says the list is never closed.\n const next = text.charAt(i);\n if (next === ',') i += 1;\n else if (next !== ']' && next !== '') return fail('inline list items must be separated by commas');\n }\n}\n\n/** Null in the YAML 1.2 core schema: empty, `~` or `null` in any of its three spellings. */\nexport function isNull(scalar: YamlScalar): boolean {\n return !scalar.quoted && ['', '~', 'null', 'Null', 'NULL'].includes(scalar.text);\n}\n\n/**\n * Renders a string as a scalar that reads back as the same string.\n *\n * Plain only as a YAML plain scalar that reads back as itself: a letter\n * first, of any script, then letters, marks, digits, spaces and `._/+-` - so\n * a status of `封存` or `已接受` is written as it is typed - with no space at\n * the end, and none of `true`, `false`, `null`, `yes`, `no`, `on`, `off` or\n * `~` in any case, which YAML 1.2 or 1.1 reads as a boolean or a null.\n * Anything else is quoted: an indicator, `: ` or ` #`, a number, a space at\n * either end, a full-width space or punctuation.\n */\nexport function renderScalar(value: string): string {\n const reserved = /^(?:true|false|null|yes|no|on|off|~)$/i.test(value);\n const plain = /^\\p{L}[\\p{L}\\p{M}\\p{N} ._/+-]*$/u.test(value) && !value.endsWith(' ');\n return plain && !reserved ? value : JSON.stringify(value);\n}\n\nexport function findEntry(frontMatter: FrontMatter | null, key: string): FrontMatterEntry | undefined {\n const name = keyName(key);\n return frontMatter?.entries.find((entry) => entry.name === name);\n}\n\n/**\n * Sets one key, leaving every other line as it was.\n *\n * `lines` are the lines of the text the front matter was read from, as\n * `splitLines` gives them. An existing entry keeps the spelling and the\n * indentation of its key; a new one goes last, at the top level. A text with\n * no front matter gains a block.\n */\nexport function setEntry(lines: readonly string[], frontMatter: FrontMatter | null, key: string, rendered: string): string[] {\n if (frontMatter === null) return ['---', `${key}: ${rendered}`, '---', ...lines];\n if (frontMatter.close === -1) throw new Error('cannot edit front matter that is never closed');\n if (frontMatter.kind === 'toml') throw new Error('cannot edit TOML front matter');\n const entry = findEntry(frontMatter, key);\n if (entry === undefined) {\n return [...lines.slice(0, frontMatter.close), `${key}: ${rendered}`, ...lines.slice(frontMatter.close)];\n }\n const written =\n entry.parent === null\n ? `${entry.key}: ${rendered}`\n : `${(lines[entry.line] as string).slice(0, leadIndex(lines[entry.line] as string))}${entry.key.slice(entry.parent.length + 1)}: ${rendered}`;\n return [...lines.slice(0, entry.line), written, ...lines.slice(entry.end)];\n}\n\n/** Removes one key and its value lines; a key that is absent changes nothing. */\nexport function removeEntry(lines: readonly string[], frontMatter: FrontMatter | null, key: string): string[] {\n const entry = findEntry(frontMatter, key);\n if (entry === undefined) return [...lines];\n return [...lines.slice(0, entry.line), ...lines.slice(entry.end)];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/markdown/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AA0DxC,MAAM,SAAS,GAAG,aAAa,CAAC;AAChC,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAC5C,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAEpC,4FAA4F;AAC5F,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;QAAE,OAAO,MAAM,CAAC;IAC7C,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,C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AG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,WAAW,CAAC,KAAwB,EAAE,WAA+B,EAAE,GAAW;IAChG,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IAC1C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IAC3C,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["/**\n * A reader and editor for the front matter the spec-* tools use: a flat bag\n * of YAML scalars and lists, and optionally one level of nested mapping.\n *\n * Supported: `key: value` lines; plain, single-quoted and double-quoted\n * scalars; inline `[a, b]` sequences; block `- item` sequences; `#` comments.\n * Plain scalars follow the YAML 1.2 core schema, so `yes` is a word and `035`\n * keeps its leading zero for whoever reads it as text. With `nested`, a key\n * whose value is an indented block of keys is read as `parent.child` entries.\n *\n * Anything richer - deeper nesting, block scalars, anchors, tags, a value\n * continued onto the next line - is recognised and reported as unsupported\n * rather than guessed at. A YAML library would parse more, but it would not\n * give back the line and the offset of every value, and a report has to point\n * at the value it is about, and an edit has to leave every other line of the\n * file as it was.\n */\n\nimport { lineStarts, splitLines, stripBom } from '../text/index.js';\nimport { leadIndex } from './syntax.js';\nimport type { FrontMatterKind } from './types.js';\n\nexport interface YamlScalar {\n readonly text: string;\n readonly quoted: boolean;\n}\n\nexport type YamlValue =\n | { readonly kind: 'scalar'; readonly scalar: YamlScalar }\n | { readonly kind: 'list'; readonly items: readonly YamlScalar[] }\n | { readonly kind: 'unsupported'; readonly reason: string };\n\nexport interface FrontMatterEntry {\n /** The key as written; a nested key is its parent's and its own, joined by a dot. */\n readonly key: string;\n /** The key compared: {@link keyName} of `key`, so `depends-on` is `dependsOn`. */\n readonly name: string;\n /** The parent key as written, for a nested key; `null` at the top level. */\n readonly parent: string | null;\n /** 0-based line of the key. */\n readonly line: number;\n /** 0-based line after the entry's last line. */\n readonly end: number;\n /** Offset of the key in the text read. */\n readonly keyStart: number;\n /**\n * Offsets of the value as written: a quoted scalar with its quotes, an\n * inline list with its brackets, a block list from its first item's text to\n * its last item's. An empty value is the empty range just past the colon.\n */\n readonly valueStart: number;\n readonly valueEnd: number;\n readonly value: YamlValue;\n}\n\nexport interface FrontMatterProblem {\n /** 0-based line. */\n readonly line: number;\n readonly message: string;\n}\n\nexport interface FrontMatter {\n readonly kind: FrontMatterKind;\n /** 0-based line of the closing delimiter, or -1 when the block is never closed. */\n readonly close: number;\n readonly entries: readonly FrontMatterEntry[];\n readonly problems: readonly FrontMatterProblem[];\n}\n\nexport interface ReadOptions {\n /**\n * Read one level of nested mapping as `parent.child` entries, instead of\n * reporting the parent's value as unsupported.\n */\n readonly nested?: boolean;\n}\n\nconst YAML_OPEN = /^---[ \\t]*$/;\nconst YAML_CLOSE = /^(?:---|\\.\\.\\.)[ \\t]*$/;\nconst TOML_FENCE = /^\\+\\+\\+[ \\t]*$/;\n\n/** The kind of front matter a document's first line opens, or `null` when it opens none. */\nexport function frontMatterKind(firstLine: string): FrontMatterKind | null {\n if (YAML_OPEN.test(firstLine)) return 'yaml';\n return TOML_FENCE.test(firstLine) ? 'toml' : null;\n}\n\n/** Whether a line closes front matter of a kind: `---` or `...` for YAML, `+++` for TOML. */\nexport function frontMatterCloses(line: string, kind: FrontMatterKind): boolean {\n return (kind === 'yaml' ? YAML_CLOSE : TOML_FENCE).test(line);\n}\n\n/**\n * A key and what follows its colon. A key is a word of any script, as a YAML\n * plain key may be: a letter or `_` first, then letters, marks, digits and\n * `_.-`, so `狀態` and `状态` are keys as `status` is. Nothing else is one: a\n * digit or a mark first, a space, punctuation, and a full-width colon, which\n * YAML does not read as one.\n */\nconst KEY = /^([\\p{L}_][\\p{L}\\p{M}\\p{N}_.-]*)[ \\t]*:(?:[ \\t]+(.*))?$/u;\nconst SEQUENCE_ITEM = /^([ \\t]*)-(?:[ \\t]+(.*))?$/;\nconst BLANK_OR_COMMENT = /^[ \\t]*(?:#.*)?$/;\n\nexport function keyName(key: string): string {\n return key.toLowerCase().replace(/[-_]/g, '');\n}\n\n/**\n * Reads the front matter at the top of a text, or `null` when there is none.\n *\n * A leading byte-order mark is not part of the text read: offsets count from\n * the character after it, as a scan's do.\n */\nexport function readFrontMatter(source: string, options: ReadOptions = {}): FrontMatter | null {\n const text = stripBom(source);\n const lines = splitLines(text);\n const kind = frontMatterKind(lines[0] as string);\n if (kind === null) return null;\n const close = lines.findIndex((line, i) => i > 0 && frontMatterCloses(line, kind));\n if (close === -1) {\n return { kind, close, entries: [], problems: [{ line: 0, message: 'the front matter opened on line 1 is never closed' }] };\n }\n if (kind === 'toml') {\n return { kind, close, entries: [], problems: [{ line: 0, message: 'TOML front matter is not read; write YAML between \"---\" lines' }] };\n }\n\n const reader: Reader = {\n lines,\n starts: lineStarts(text),\n nested: options.nested === true,\n entries: [],\n problems: [],\n seen: new Map(),\n };\n let i = 1;\n while (i < close) {\n const line = lines[i] as string;\n if (BLANK_OR_COMMENT.test(line)) {\n i += 1;\n continue;\n }\n const match = KEY.exec(line);\n if (match === null) {\n reader.problems.push({\n line: i,\n message: /^\\s/.test(line) ? 'an indented line belongs to no key' : 'not a \"key: value\" line',\n });\n i += 1;\n continue;\n }\n // The closing delimiter belongs to no value, so the block stops there.\n let end = i + 1;\n while (belongsToBlock(lines[end] as string)) end += 1;\n end = trimBlock(lines, end);\n readEntry(reader, { key: match[1] as string, parent: null, line: i, column: 0, inline: match[2] ?? '', end });\n i = end;\n }\n return { kind, close, entries: reader.entries, problems: reader.problems };\n}\n\ninterface Reader {\n readonly lines: readonly string[];\n readonly starts: readonly number[];\n readonly nested: boolean;\n readonly entries: FrontMatterEntry[];\n readonly problems: FrontMatterProblem[];\n readonly seen: Map<string, number>;\n}\n\ninterface KeyLine {\n /** The key as written on its line, without a parent. */\n readonly key: string;\n readonly parent: string | null;\n readonly line: number;\n /** Column of the key. */\n readonly column: number;\n /** What follows the colon and its whitespace, as written. */\n readonly inline: string;\n /** 0-based line after the key's value. */\n readonly end: number;\n}\n\n/** A line under a top-level key is part of its value when it is indented or starts a sequence item. */\nfunction belongsToBlock(line: string): boolean {\n return /^[ \\t]/.test(line) || /^-(?:[ \\t]|$)/.test(line) || line.trim() === '';\n}\n\n/**\n * Takes trailing blank and comment lines off a value's block: they belong to\n * no key. The key's own line is neither, so the walk stops there at the latest.\n */\nfunction trimBlock(lines: readonly string[], end: number): number {\n let at = end;\n while (BLANK_OR_COMMENT.test(lines[at - 1]!)) at -= 1;\n return at;\n}\n\nfunction note(reader: Reader, key: string, line: number): string {\n const name = keyName(key);\n const previous = reader.seen.get(name);\n if (previous === undefined) reader.seen.set(name, line);\n else reader.problems.push({ line, message: `\"${key}\" is declared twice (first on line ${previous + 1})` });\n return name;\n}\n\nfunction readEntry(reader: Reader, at: KeyLine): void {\n const { lines, starts } = reader;\n const text = lines[at.line] as string;\n const lineStart = starts[at.line] as number;\n const key = at.parent === null ? at.key : `${at.parent}.${at.key}`;\n // A key holds no colon and nothing before it does, so the first is its own.\n const colon = lineStart + text.indexOf(':') + 1;\n // What follows the colon starts after its whitespace; what ends it is\n // trimmed by whichever reader takes it.\n const inline = stripLeadingComment(at.inline);\n\n let read: Read;\n if (inline.length > 0) {\n const valueStart = lineStart + text.length - at.inline.length;\n const continued = contentLines(lines, at.line + 1, at.end).length > 0;\n const parsed = continued\n ? rough(unsupported('the value continues on the next line; keep it on one line, or quote it'), inline)\n : readInline(inline);\n read = { value: parsed.value, valueStart, valueEnd: valueStart + parsed.length };\n } else {\n const content = contentLines(lines, at.line + 1, at.end);\n const first = content[0];\n if (first !== undefined && at.parent === null && reader.nested && KEY.test((lines[first] as string).trim())) {\n note(reader, at.key, at.line);\n readChildren(reader, at.key, at.line + 1, at.end);\n return;\n }\n read = readBlock(reader, content, colon, at.parent === null);\n }\n\n reader.entries.push({\n key,\n name: note(reader, key, at.line),\n parent: at.parent,\n line: at.line,\n end: at.end,\n keyStart: lineStart + at.column,\n ...read,\n });\n}\n\n/** One level of keys under a parent, all at the indentation of the first. */\nfunction readChildren(reader: Reader, parent: string, from: number, end: number): void {\n const { lines } = reader;\n const first = lines[contentLines(lines, from, end)[0] as number] as string;\n const lead = first.slice(0, leadIndex(first));\n let i = from;\n while (i < end) {\n const line = lines[i] as string;\n if (BLANK_OR_COMMENT.test(line)) {\n i += 1;\n continue;\n }\n // A line deeper than the keys is always taken by the key above it, so only\n // one at their indentation or shallower reaches here.\n const match = line.startsWith(lead) ? KEY.exec(line.slice(lead.length)) : null;\n if (match === null) {\n reader.problems.push({ line: i, message: 'not a \"key: value\" line at the indentation of the keys before it' });\n i += 1;\n continue;\n }\n // Past the parent's value, a line belongs to a child only when it is blank\n // or a comment, and those are trimmed off again.\n let childEnd = i + 1;\n while (belongsToChild(lines[childEnd] as string, lead)) childEnd += 1;\n childEnd = trimBlock(lines, childEnd);\n readEntry(reader, { key: match[1] as string, parent, line: i, column: lead.length, inline: match[2] ?? '', end: childEnd });\n i = childEnd;\n }\n}\n\n/** A line under a nested key is part of its value when it is deeper, or a sequence item at the key's indentation. */\nfunction belongsToChild(line: string, lead: string): boolean {\n if (line.trim() === '') return true;\n if (!line.startsWith(lead)) return false;\n return /^(?:[ \\t]|-(?:[ \\t]|$))/.test(line.slice(lead.length));\n}\n\ninterface Read {\n readonly value: YamlValue;\n readonly valueStart: number;\n readonly valueEnd: number;\n}\n\n/** Indices of the lines in a range that are neither blank nor a comment. */\nfunction contentLines(lines: readonly string[], from: number, end: number): number[] {\n const out: number[] = [];\n for (let i = from; i < end; i += 1) if (!BLANK_OR_COMMENT.test(lines[i] as string)) out.push(i);\n return out;\n}\n\n/** A value written on the lines under its key. */\nfunction readBlock(reader: Reader, content: readonly number[], colon: number, topLevel: boolean): Read {\n const { lines, starts } = reader;\n const first = content[0];\n if (first === undefined) return { value: { kind: 'scalar', scalar: { text: '', quoted: false } }, valueStart: colon, valueEnd: colon };\n\n // An unsupported block is reported over all of its content lines.\n const firstText = lines[first] as string;\n const last = content[content.length - 1]!;\n const whole = (value: YamlValue): Read => ({\n value,\n valueStart: (starts[first] as number) + leadIndex(firstText),\n valueEnd: (starts[last] as number) + (lines[last] as string).trimEnd().length,\n });\n\n const head = SEQUENCE_ITEM.exec(firstText);\n if (head === null) {\n // Quoting a list would make it a string, so a list gets its own advice.\n if (firstText.trim().startsWith('[')) return whole(unsupported('an inline list starts on the line after its key; write it after the colon'));\n if (!KEY.test(firstText.trim())) return whole(unsupported('the value continues on the next line; keep it on one line, or quote it'));\n return whole(\n unsupported(topLevel ? 'nested mappings are not supported; flatten the key' : 'only one level of nesting is read; flatten the key'),\n );\n }\n const indent = (head[1] as string).length;\n const items: YamlScalar[] = [];\n const spans: [number, number][] = [];\n for (const index of content) {\n const line = lines[index] as string;\n const item = SEQUENCE_ITEM.exec(line);\n if (item === null || (item[1] as string).length !== indent) {\n return whole(unsupported('a list item is continued or nested; keep each item on one line'));\n }\n // The item's text starts after its whitespace, as a key's value does.\n const written = item[2] ?? '';\n const text = stripLeadingComment(written);\n if (text.length === 0) return whole(unsupported('a list item is empty'));\n const parsed = readInline(text);\n if (parsed.value.kind !== 'scalar') {\n return whole(parsed.value.kind === 'list' ? unsupported('nested lists are not supported') : parsed.value);\n }\n const start = (starts[index] as number) + line.length - written.length;\n spans.push([start, start + parsed.length]);\n items.push(parsed.value.scalar);\n }\n return { value: { kind: 'list', items }, valueStart: (spans[0] as [number, number])[0], valueEnd: spans[spans.length - 1]![1] };\n}\n\nfunction stripLeadingComment(text: string): string {\n return text.startsWith('#') ? '' : text;\n}\n\nfunction unsupported(reason: string): YamlValue {\n return { kind: 'unsupported', reason };\n}\n\ninterface Parsed {\n readonly value: YamlValue;\n /** Characters of the text the value spans. */\n readonly length: number;\n}\n\n/** An unsupported value spans its text up to any comment. */\nfunction rough(value: YamlValue, text: string): Parsed {\n return { value, length: stripTrailingComment(text).length };\n}\n\n/** Parses a value written on the key's own line. `text` is trimmed and non-empty. */\nexport function parseInline(text: string): YamlValue {\n return readInline(text).value;\n}\n\n/** `text` starts with the value; whitespace after it is allowed. */\nfunction readInline(text: string): Parsed {\n const head = text.charAt(0);\n if (head === '\"' || head === \"'\") {\n const quoted = head === '\"' ? readDoubleQuoted(text) : readSingleQuoted(text);\n if (typeof quoted === 'string') return rough(unsupported(quoted), text);\n return trailingIsComment(text.slice(quoted.next))\n ? { value: { kind: 'scalar', scalar: { text: quoted.text, quoted: true } }, length: quoted.next }\n : rough(unsupported('text follows a closing quote'), text);\n }\n if (head === '[') return parseFlowSequence(text);\n if (head === '{') return rough(unsupported('inline mappings are not supported'), text);\n if (head === '|' || head === '>') return rough(unsupported('block scalars are not supported; keep the value on one line'), text);\n if (head === '&' || head === '*' || head === '!') return rough(unsupported('anchors, aliases and tags are not supported'), text);\n if (head === '@' || head === '`') return rough(unsupported(`a plain value cannot start with \"${head}\"; quote it`), text);\n const plain = stripTrailingComment(text);\n if (/:(?:\\s|$)/.test(plain)) return rough(unsupported('a plain value cannot contain \": \"; quote it'), text);\n if (/^-(?:\\s|$)/.test(plain)) return rough(unsupported('a list must start on the line after its key'), text);\n return { value: { kind: 'scalar', scalar: { text: plain, quoted: false } }, length: plain.length };\n}\n\n/** A comment starts at a `#` after whitespace; a `#` inside a word is text. */\nfunction stripTrailingComment(text: string): string {\n return text.split(/\\s#/, 1)[0]!.trim();\n}\n\n/** Nothing after a closing quote or bracket, or whitespace and then a comment. */\nfunction trailingIsComment(rest: string): boolean {\n return /^(?:\\s+(?:#.*)?)?$/.test(rest);\n}\n\ninterface Quoted {\n readonly text: string;\n /** Index just past the closing quote. */\n readonly next: number;\n}\n\nconst ESCAPES: Readonly<Record<string, string>> = {\n '\"': '\"',\n '\\\\': '\\\\',\n '/': '/',\n '0': '\\u0000',\n b: '\\b',\n f: '\\f',\n n: '\\n',\n r: '\\r',\n t: '\\t',\n};\n\nconst HEX_ESCAPE_LENGTH: Readonly<Record<string, number>> = { x: 2, u: 4, U: 8 };\n\n/** Reads a double-quoted scalar starting at index 0, or returns why it cannot. */\nfunction readDoubleQuoted(text: string): Quoted | string {\n let out = '';\n for (let i = 1; ; i += 1) {\n const ch = text.charAt(i);\n if (ch === '') return 'a double-quoted value is never closed';\n if (ch === '\"') return { text: out, next: i + 1 };\n if (ch !== '\\\\') {\n out += ch;\n continue;\n }\n const code = text.charAt(i + 1);\n const simple = ESCAPES[code];\n if (simple !== undefined) {\n out += simple;\n i += 1;\n continue;\n }\n // An escape this reader does not know has no digits to read, and no\n // digits are not a number.\n const width = HEX_ESCAPE_LENGTH[code] ?? 0;\n const hex = text.slice(i + 2, i + 2 + width);\n if (hex.length !== width || !/^[0-9A-Fa-f]+$/.test(hex)) return `\"\\\\${code}\" is not an escape this reader knows`;\n const point = Number.parseInt(hex, 16);\n if (point > 0x10ffff) return `\"\\\\${code}${hex}\" is not a character`;\n out += String.fromCodePoint(point);\n i += 1 + width;\n }\n}\n\nfunction readSingleQuoted(text: string): Quoted | string {\n let out = '';\n for (let i = 1; ; i += 1) {\n const ch = text.charAt(i);\n if (ch === '') return 'a single-quoted value is never closed';\n if (ch !== \"'\") {\n out += ch;\n continue;\n }\n if (text.charAt(i + 1) !== \"'\") return { text: out, next: i + 1 };\n out += \"'\";\n i += 1;\n }\n}\n\n/** The first index at or after `from` that is not whitespace. */\nfunction skipSpace(text: string, from: number): number {\n let i = from;\n while (/\\s/.test(text.charAt(i))) i += 1;\n return i;\n}\n\nfunction parseFlowSequence(text: string): Parsed {\n const items: YamlScalar[] = [];\n const fail = (reason: string): Parsed => rough(unsupported(reason), text);\n let i = 1;\n for (;;) {\n i = skipSpace(text, i);\n const ch = text.charAt(i);\n if (ch === '') return fail('an inline list is never closed; keep it on one line');\n if (ch === ']') {\n return trailingIsComment(text.slice(i + 1))\n ? { value: { kind: 'list', items }, length: i + 1 }\n : fail('text follows the end of an inline list');\n }\n if (ch === '[' || ch === '{') return fail('nested lists and mappings are not supported');\n if (ch === ',') return fail('an inline list has an empty item');\n if (ch === '\"' || ch === \"'\") {\n const rest = text.slice(i);\n const quoted = ch === '\"' ? readDoubleQuoted(rest) : readSingleQuoted(rest);\n if (typeof quoted === 'string') return fail(quoted);\n items.push({ text: quoted.text, quoted: true });\n i += quoted.next;\n } else {\n let j = i;\n // One step past the end reads nothing and slices nothing more, so the\n // bound could be one further and still stop the walk.\n while (j < text.length && text.charAt(j) !== ',' && text.charAt(j) !== ']') j += 1;\n const plain = text.slice(i, j).trim();\n if (/[[{]/.test(plain) || /:(?:\\s|$)/.test(plain) || plain.includes(' #')) {\n return fail(`\"${plain}\" needs quoting inside an inline list`);\n }\n items.push({ text: plain, quoted: false });\n i = j;\n }\n i = skipSpace(text, i);\n // After a comma the next pass reads an item or, legally in YAML, the\n // bracket; at the end of the text it says the list is never closed.\n const next = text.charAt(i);\n if (next === ',') i += 1;\n else if (next !== ']' && next !== '') return fail('inline list items must be separated by commas');\n }\n}\n\n/** Null in the YAML 1.2 core schema: empty, `~` or `null` in any of its three spellings. */\nexport function isNull(scalar: YamlScalar): boolean {\n return !scalar.quoted && ['', '~', 'null', 'Null', 'NULL'].includes(scalar.text);\n}\n\n/**\n * Renders a string as a scalar that reads back as the same string.\n *\n * Plain only as a YAML plain scalar that reads back as itself: a letter\n * first, of any script, then letters, marks, digits, spaces and `._/+-` - so\n * a status of `封存` or `已接受` is written as it is typed - with no space at\n * the end, and none of `true`, `false`, `null`, `yes`, `no`, `on`, `off` or\n * `~` in any case, which YAML 1.2 or 1.1 reads as a boolean or a null.\n * Anything else is quoted: an indicator, `: ` or ` #`, a number, a space at\n * either end, a full-width space or punctuation.\n */\nexport function renderScalar(value: string): string {\n const reserved = /^(?:true|false|null|yes|no|on|off|~)$/i.test(value);\n const plain = /^\\p{L}[\\p{L}\\p{M}\\p{N} ._/+-]*$/u.test(value) && !value.endsWith(' ');\n return plain && !reserved ? value : JSON.stringify(value);\n}\n\nexport function findEntry(frontMatter: FrontMatter | null, key: string): FrontMatterEntry | undefined {\n const name = keyName(key);\n return frontMatter?.entries.find((entry) => entry.name === name);\n}\n\n/**\n * Sets one key, leaving every other line as it was.\n *\n * `lines` are the lines of the text the front matter was read from, as\n * `splitLines` gives them. An existing entry keeps the spelling and the\n * indentation of its key; a new one goes last, at the top level. A text with\n * no front matter gains a block.\n */\nexport function setEntry(lines: readonly string[], frontMatter: FrontMatter | null, key: string, rendered: string): string[] {\n if (frontMatter === null) return ['---', `${key}: ${rendered}`, '---', ...lines];\n if (frontMatter.close === -1) throw new Error('cannot edit front matter that is never closed');\n if (frontMatter.kind === 'toml') throw new Error('cannot edit TOML front matter');\n const entry = findEntry(frontMatter, key);\n if (entry === undefined) {\n return [...lines.slice(0, frontMatter.close), `${key}: ${rendered}`, ...lines.slice(frontMatter.close)];\n }\n const written =\n entry.parent === null\n ? `${entry.key}: ${rendered}`\n : `${(lines[entry.line] as string).slice(0, leadIndex(lines[entry.line] as string))}${entry.key.slice(entry.parent.length + 1)}: ${rendered}`;\n return [...lines.slice(0, entry.line), written, ...lines.slice(entry.end)];\n}\n\n/** Removes one key and its value lines; a key that is absent changes nothing. */\nexport function removeEntry(lines: readonly string[], frontMatter: FrontMatter | null, key: string): string[] {\n const entry = findEntry(frontMatter, key);\n if (entry === undefined) return [...lines];\n return [...lines.slice(0, entry.line), ...lines.slice(entry.end)];\n}\n"]}
|