@descent-vtt/spec-harness 0.5.0 → 0.7.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.
Files changed (84) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +148 -0
  4. package/README.md +273 -24
  5. package/dist/audit.d.ts +71 -1
  6. package/dist/audit.js +140 -17
  7. package/dist/audit.js.map +1 -1
  8. package/dist/branch.d.ts +13 -0
  9. package/dist/branch.js +19 -0
  10. package/dist/branch.js.map +1 -1
  11. package/dist/cli.d.ts +1 -1
  12. package/dist/cli.js +51 -13
  13. package/dist/cli.js.map +1 -1
  14. package/dist/commands.js +13 -4
  15. package/dist/commands.js.map +1 -1
  16. package/dist/config.js +3 -1
  17. package/dist/config.js.map +1 -1
  18. package/dist/configure.d.ts +50 -3
  19. package/dist/configure.js +78 -5
  20. package/dist/configure.js.map +1 -1
  21. package/dist/context.d.ts +21 -7
  22. package/dist/context.js +104 -31
  23. package/dist/context.js.map +1 -1
  24. package/dist/document.d.ts +2 -1
  25. package/dist/document.js.map +1 -1
  26. package/dist/formats.d.ts +31 -0
  27. package/dist/formats.js +127 -0
  28. package/dist/formats.js.map +1 -0
  29. package/dist/git.d.ts +6 -0
  30. package/dist/git.js +8 -0
  31. package/dist/git.js.map +1 -1
  32. package/dist/guard.d.ts +8 -0
  33. package/dist/guard.js +19 -1
  34. package/dist/guard.js.map +1 -1
  35. package/dist/host.d.ts +14 -0
  36. package/dist/host.js +50 -0
  37. package/dist/host.js.map +1 -0
  38. package/dist/index.d.ts +5 -3
  39. package/dist/index.js +2 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/manifests.d.ts +8 -1
  42. package/dist/manifests.js +16 -6
  43. package/dist/manifests.js.map +1 -1
  44. package/dist/premises.d.ts +3 -0
  45. package/dist/premises.js +43 -13
  46. package/dist/premises.js.map +1 -1
  47. package/dist/reader.js +10 -2
  48. package/dist/reader.js.map +1 -1
  49. package/dist/round.d.ts +8 -0
  50. package/dist/round.js +73 -22
  51. package/dist/round.js.map +1 -1
  52. package/dist/server.js +11 -3
  53. package/dist/server.js.map +1 -1
  54. package/dist/setup.d.ts +10 -0
  55. package/dist/setup.js +68 -32
  56. package/dist/setup.js.map +1 -1
  57. package/dist/signers.d.ts +43 -0
  58. package/dist/signers.js +105 -0
  59. package/dist/signers.js.map +1 -0
  60. package/dist/types.d.ts +7 -0
  61. package/dist/types.js.map +1 -1
  62. package/dist/vendor/spec-core/markdown/frontmatter.d.ts +11 -1
  63. package/dist/vendor/spec-core/markdown/frontmatter.js +20 -3
  64. package/dist/vendor/spec-core/markdown/frontmatter.js.map +1 -1
  65. package/dist/vendor/spec-core/pattern/glob.d.ts +88 -2
  66. package/dist/vendor/spec-core/pattern/glob.js +234 -32
  67. package/dist/vendor/spec-core/pattern/glob.js.map +1 -1
  68. package/dist/vendor/spec-core/pattern/index.d.ts +2 -2
  69. package/dist/vendor/spec-core/pattern/index.js +1 -1
  70. package/dist/vendor/spec-core/pattern/index.js.map +1 -1
  71. package/dist/vendor/spec-core/text/index.d.ts +1 -0
  72. package/dist/vendor/spec-core/text/index.js +1 -0
  73. package/dist/vendor/spec-core/text/index.js.map +1 -1
  74. package/dist/vendor/spec-core/text/width.d.ts +30 -0
  75. package/dist/vendor/spec-core/text/width.js +113 -0
  76. package/dist/vendor/spec-core/text/width.js.map +1 -0
  77. package/dist/versions.d.ts +27 -1
  78. package/dist/versions.js +23 -1
  79. package/dist/versions.js.map +1 -1
  80. package/dist/workspace.d.ts +6 -1
  81. package/dist/workspace.js +17 -6
  82. package/dist/workspace.js.map +1 -1
  83. package/package.json +1 -1
  84. package/skills/close-round/SKILL.md +4 -1
@@ -1 +1 @@
1
- {"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/pattern/glob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Globs, in the three dialects the spec-* tools speak, compiled to one kind of\n * automaton.\n *\n * The syntax is the part people type: `*`, `**`, `?`, `[abc]`, `[!a-z]`,\n * `{a,b}`, and `\\` to escape. What differs between the tools is not the\n * syntax but what a pattern is matched against, and those differences are\n * deliberate, so each has a name (docs/adr/0003-glob-dialects.md):\n *\n * - `path` - the whole repository-relative path, anchored at the root. A\n * pattern with no glob syntax names a file, a directory, or either, as the\n * caller says; `src/auth` may cover `src/auth/login.ts`.\n * - `ripgrep` - as ripgrep's `-g`: a pattern with no `/` is matched against\n * the last segment at any depth, so `*.ts` matches `src/deep/a.ts`; one with\n * a `/` is matched against the whole path.\n * - `gitignore` - as an exclusion list reads: a pattern matches a path or any\n * directory above it, so `tests` excludes everything under any `tests`; one\n * with a `/` other than a trailing one is anchored at the root, and a\n * leading `/` only anchors.\n *\n * Shared by all three:\n *\n * - `**` is a globstar only as a whole segment. `a/**\\/b` matches `a/b` and\n * `a/x/y/b`; a trailing `/**` matches everything inside a directory and not\n * the directory itself. Two stars inside a name, `**.md`, are refused: the\n * tools read it three ways, and the quiet reading narrowed their scope. The\n * refusal writes the two patterns it may have meant from the one written.\n * - `*`, `?` and classes never match `/`, and `*` matches a leading dot.\n * - Braces expand first, and each alternative reads as it would written on\n * its own: `{src/,lib}` is `src/` or `lib`, and a trailing `/` means the\n * directory's contents - in an exclusion, the directory and its contents.\n * One that names no path, `{./,lib}` or `{,lib}`, is refused, as `./` and\n * the empty pattern are.\n * - Case is the caller's decision, stated every time. A result must not\n * depend on the host it ran on.\n * - A malformed pattern is an error, never a literal. An unclosed `[` or `{`,\n * an extended glob, a `..` - each is refused with a reason, because a typo\n * read as a literal is a scope that silently matches nothing. An extended\n * glob is a group holding a `|`, `+(a|b)`: without one, `C++(notes).md` is\n * a name with parentheses in it, as ripgrep and `.gitignore` read it.\n */\n\nimport {\n AutomatonTooLarge,\n Builder,\n findWitness,\n Matcher,\n WITNESS_BUDGET,\n type Automaton,\n type Fragment,\n type Witness,\n} from './automaton.js';\nimport { ANY, classSet, literalSet, SEPARATOR, type CodeRange } from './charset.js';\n\nexport type GlobDialect = 'path' | 'ripgrep' | 'gitignore';\n\n/** How a `path` pattern with no glob syntax is read. */\nexport type LiteralReading = 'file' | 'directory' | 'either';\n\nexport interface GlobOptions {\n readonly dialect: GlobDialect;\n /** Whether `A` and `a` differ. No default: the caller decides, every time. */\n readonly caseSensitive: boolean;\n /**\n * `path` dialect only: how a pattern with no glob syntax is read - as a\n * file, as a directory and everything beneath it, or as either. A function\n * is asked per literal path, for a caller that knows the tree. `either` when\n * unset. A trailing `/`, on the pattern or on one of its brace alternatives,\n * always means a directory's contents, and is never asked about.\n */\n readonly literal?: LiteralReading | ((path: string) => LiteralReading) | undefined;\n /**\n * `escape` (the default): `\\` escapes the next character, and a `\\` before a\n * letter or digit is refused as a Windows separator typed by mistake.\n * `separator`: every `\\` is a `/`, for patterns typed on a Windows shell.\n */\n readonly backslash?: 'escape' | 'separator' | undefined;\n}\n\nexport interface Glob {\n readonly source: string;\n readonly dialect: GlobDialect;\n readonly caseSensitive: boolean;\n /**\n * The directories a walk must enter to find every match: one per\n * alternative, the leading literal segments. `''` for an alternative that\n * can match at any depth.\n */\n readonly bases: readonly string[];\n readonly automaton: Automaton;\n /** Whether a canonical path - POSIX, no `.`, no empty or trailing segment - matches. */\n match(path: string): boolean;\n}\n\nexport type GlobParse = { readonly ok: true; readonly glob: Glob } | { readonly ok: false; readonly error: string };\n\nexport class GlobError extends Error {\n readonly source: string;\n constructor(source: string, reason: string) {\n super(`invalid glob \"${source}\": ${reason}`);\n this.name = 'GlobError';\n this.source = source;\n }\n}\n\n/** More alternatives than this is a pattern nobody meant. */\nexport const MAX_ALTERNATIVES = 256;\n\ntype Token =\n | { readonly kind: 'literal'; readonly point: number }\n | { readonly kind: 'any' }\n | { readonly kind: 'star' }\n | { readonly kind: 'class'; readonly negated: boolean; readonly ranges: readonly CodeRange[] };\n\ntype Segment = { readonly kind: 'globstar' } | { readonly kind: 'name'; readonly tokens: readonly Token[] };\n\ninterface Alternative {\n readonly segments: readonly Segment[];\n /** Written with a `/` somewhere other than at its end. */\n readonly slashed: boolean;\n}\n\n/** Whether a string uses glob syntax at all. */\nexport function isGlobSyntax(source: string): boolean {\n return /[*?[\\]{}]/.test(source);\n}\n\n/**\n * Parses and compiles a glob, or says why it cannot: malformed, or too large\n * to compile, past {@link MAX_ALTERNATIVES} alternatives or `MAX_STATES`\n * states. It throws only what a `literal` function throws.\n */\nexport function parseGlob(source: string, options: GlobOptions): GlobParse {\n const result = build(source, options);\n return typeof result === 'string' ? { ok: false, error: result } : { ok: true, glob: result };\n}\n\n/**\n * Parses and compiles a glob, throwing {@link GlobError} for every reason\n * {@link parseGlob} gives, and what a `literal` function throws.\n */\nexport function compileGlob(source: string, options: GlobOptions): Glob {\n const result = build(source, options);\n if (typeof result === 'string') throw new GlobError(source, result);\n return result;\n}\n\nfunction build(source: string, options: GlobOptions): Glob | string {\n const escapes = options.backslash !== 'separator';\n let pattern = source.trim();\n if (!escapes) pattern = pattern.replace(/\\\\/g, '/');\n const written = pattern;\n if (pattern.length === 0) return 'the pattern is empty';\n if (pattern.startsWith('!')) return 'a negated pattern is a list entry, not a glob; narrow the positive pattern';\n if (/(?:^|[^\\\\])[?*+@!]\\([^)]*\\|/.test(pattern)) return EXTGLOB;\n while (pattern.startsWith('./')) pattern = pattern.slice(2);\n\n // A leading slash roots a pattern at the filesystem's root in the path and\n // ripgrep dialects, and only anchors it at the repository root in gitignore.\n let rooted = false;\n let anchored = false;\n if (pattern.startsWith('/')) {\n if (options.dialect === 'gitignore') anchored = true;\n else rooted = true;\n pattern = pattern.replace(/^\\/+/, '');\n }\n if (pattern.length === 0) return 'the pattern names the root itself, not a path under it';\n\n const expanded = expandBraces(pattern, escapes);\n if (typeof expanded === 'string') return expanded;\n\n const alternatives: Alternative[] = [];\n for (const text of expanded) {\n // Refused before its trailing slash is read, which would make `./` the\n // contents of `.`, every path: `{./,a}` is refused as `./` alone is.\n // Each text the braces give is shorter than the pattern, so only a\n // pattern without braces is its own text.\n if (namesNoPath(text)) return text === pattern ? 'the pattern names no path' : bracesNamingNoPath(text);\n const parsed = parseAlternative(trailingSlash(text, options.dialect), escapes);\n if (parsed === GLOBSTAR_IN_NAME) return `${GLOBSTAR_IN_NAME}: ${globstarAdvice(written)}`;\n if (typeof parsed === 'string') return parsed;\n alternatives.push(parsed);\n }\n\n const builder = new Builder();\n const fragments: Fragment[] = [];\n const bases: string[] = [];\n let automaton: Automaton;\n try {\n for (const alternative of alternatives) {\n const compiled = compileAlternative(builder, alternative, options, rooted, anchored);\n fragments.push(compiled.fragment);\n bases.push(compiled.base);\n }\n automaton = builder.finish(builder.either(fragments), options.caseSensitive);\n } catch (error) {\n // A pattern too large to compile is refused with a reason, as a malformed\n // one is. Anything else - a caller's literal reading that throws - is the\n // caller's failure, not the pattern's, and goes on up.\n if (error instanceof AutomatonTooLarge) return error.message;\n throw error;\n }\n let matcher: Matcher | null = null;\n return {\n source,\n dialect: options.dialect,\n caseSensitive: options.caseSensitive,\n bases: [...new Set(bases)],\n automaton,\n match(path: string): boolean {\n matcher ??= new Matcher(automaton);\n return matcher.test(path);\n },\n };\n}\n\n/* ------------------------------------------------------------------ braces */\n\n/**\n * Expands `{a,b}` groups into the patterns they stand for, or says why the\n * pattern is malformed.\n *\n * Classes and escapes are skipped while looking for braces and commas, so\n * `{[,]x,y}` is two alternatives, `[,]x` and `y`. A lone `}` is a literal: it\n * cannot be read as anything else. An unclosed `{` is an error.\n *\n * Here and in the two functions after it, a loop that reads one step past\n * the end reads `''`, which none of them acts on, and `classEnd` answers -1\n * or an index past the `[`, so `close > 0` and `close >= 0` read the same.\n * `open` is set by the `{` that any `}` read here closes, so its first value\n * is never read.\n */\nfunction expandBraces(pattern: string, escapes: boolean): string[] | string {\n let depth = 0;\n let open = -1;\n for (let i = 0; i < pattern.length; i += 1) {\n const ch = pattern.charAt(i);\n if (ch === '\\\\' && escapes) {\n i += 1;\n continue;\n }\n if (ch === '[') {\n const close = classEnd(pattern, i, escapes);\n if (close > 0) i = close;\n continue;\n }\n if (ch === '{') {\n if (depth === 0) open = i;\n depth += 1;\n continue;\n }\n if (ch !== '}' || depth === 0) continue;\n depth -= 1;\n if (depth > 0) continue;\n const prefix = pattern.slice(0, open);\n const suffix = pattern.slice(i + 1);\n const results: string[] = [];\n for (const option of splitOptions(pattern.slice(open + 1, i), escapes)) {\n const expanded = expandBraces(`${prefix}${option}${suffix}`, escapes);\n if (typeof expanded === 'string') return expanded;\n results.push(...expanded);\n if (results.length > MAX_ALTERNATIVES) return `the braces expand to more than ${MAX_ALTERNATIVES} patterns`;\n }\n return results;\n }\n if (depth > 0) return 'a \"{\" is never closed';\n return [pattern];\n}\n\n/** Splits a brace body on its top-level commas. */\nfunction splitOptions(body: string, escapes: boolean): string[] {\n const parts: string[] = [];\n let depth = 0;\n let start = 0;\n for (let i = 0; i < body.length; i += 1) {\n const ch = body.charAt(i);\n if (ch === '\\\\' && escapes) {\n i += 1;\n } else if (ch === '[') {\n const close = classEnd(body, i, escapes);\n if (close > 0) i = close;\n } else if (ch === '{') {\n depth += 1;\n } else if (ch === '}') {\n depth -= 1;\n } else if (ch === ',' && depth === 0) {\n parts.push(body.slice(start, i));\n start = i + 1;\n }\n }\n parts.push(body.slice(start));\n return parts;\n}\n\n/** The index of the `]` closing a class opened at `open`, or -1 when none does within the segment. */\nfunction classEnd(pattern: string, open: number, escapes: boolean): number {\n let i = open + 1;\n if (pattern.charAt(i) === '!' || pattern.charAt(i) === '^') i += 1;\n // The first member is always a member, even `]`.\n if (pattern.charAt(i) === ']') i += 1;\n for (; i < pattern.length; i += 1) {\n const ch = pattern.charAt(i);\n if (ch === '\\\\' && escapes) {\n i += 1;\n continue;\n }\n if (ch === '/') return -1;\n if (ch === ']') return i;\n }\n return -1;\n}\n\n/* ---------------------------------------------------------------- segments */\n\n/** Whether a pattern's text names no path: nothing in it but `/` and `.` segments. */\nfunction namesNoPath(text: string): boolean {\n return text.split('/').every((part) => part === '' || part === '.');\n}\n\n/**\n * The refusal of an alternative the braces give that names no path, naming\n * it as it was expanded, so that `.{/,a}` is told `./`, the text refused.\n */\nfunction bracesNamingNoPath(text: string): string {\n return text === '' ? 'the braces expand to an empty pattern' : `the braces expand to \"${text}\", which names no path`;\n}\n\n/**\n * What a trailing slash means, read on each alternative the braces give, so\n * that `{src/,lib}` reads `src/` as `src/` alone reads: the directory's\n * contents, `src/**`, and not a literal that may be the directory itself.\n *\n * In an exclusion `build/` excludes what `build` does. Git's rule is that a\n * trailing slash matches only a directory, and a directory is excluded with\n * everything in it; a matcher that sees only a path cannot tell a directory\n * from a file, so the slash is dropped, and it anchors nothing.\n *\n * Only ever given a text that names a path, so a name is left. The whole run\n * of slashes is taken, but one slash would read the same, since\n * `parseAlternative` drops the empty segments the rest leave; and taken\n * lazily it is the whole run all the same, since it ends the text.\n */\nfunction trailingSlash(text: string, dialect: GlobDialect): string {\n const name = text.replace(/\\/+$/, '');\n return name === text || dialect === 'gitignore' ? name : `${name}/**`;\n}\n\n/**\n * The segments of a text that names a path - `build` refuses one that does\n * not - so at least one segment is left.\n */\nfunction parseAlternative(text: string, escapes: boolean): Alternative | string {\n const segments: Segment[] = [];\n const raw = text.split('/');\n for (const part of raw) {\n if (part === '' || part === '.') continue;\n if (part === '..') return 'a pattern cannot climb out of its root with \"..\"';\n if (part === '**') {\n if (segments[segments.length - 1]?.kind !== 'globstar') segments.push({ kind: 'globstar' });\n continue;\n }\n const tokens = tokenize(part, escapes);\n if (typeof tokens === 'string') return tokens;\n segments.push({ kind: 'name', tokens });\n }\n return { segments, slashed: raw.filter((part) => part !== '' && part !== '.').length > 1 };\n}\n\nconst EXTGLOB = 'extended globs such as \"+(a|b)\" are not supported: write alternatives as \"{a,b}\", and a literal parenthesis as \"[(]\"';\nconst GLOBSTAR_IN_NAME = '\"**\" means any number of directories only as a whole segment';\n\n/**\n * The two patterns a writer of `**` inside a name may have meant, built from\n * what they wrote. Each run of stars that is not a whole segment becomes, for\n * any depth, a globstar segment with a star kept on each side where a name\n * went on - `docs/**.md` to `docs/**\\/*.md`, `src/a**` to `src/a*\\/**`,\n * `a**b` to `a*\\/**\\/*b` - and for one level a single star. Everything else\n * stays as written, braces and classes included, and a globstar that was a\n * whole segment stays one.\n *\n * Only `/` is taken for a boundary. A run beside a brace, `{**.md,x}`, is\n * given a star on that side too, which keeps the advice a pattern that\n * compiles whatever the braces expand to.\n *\n * `written` holds a `\\` only where it escapes: in the `separator` reading\n * each one is already a `/`.\n */\nfunction globstarAdvice(written: string): string {\n let deep = '';\n let flat = '';\n let at = 0;\n // One step past the end reads `''` and appends nothing, so the bound could\n // be one further and give the same advice.\n while (at < written.length) {\n const ch = written.charAt(at);\n let next = at + 1;\n if (ch === '\\\\') {\n next = at + 2;\n } else if (ch === '[') {\n // A class is copied as written. `classEnd` answers an index past the\n // `[`, or -1 for one never closed, so `close >= 0` reads the same; and\n // stopping one short of the `]` copies the class all the same, since\n // its last member and the `]` after it are never a run of stars.\n const close = classEnd(written, at, true);\n if (close > 0) next = close + 1;\n } else if (ch === '*') {\n while (written.charAt(next) === '*') next += 1;\n const before = at > 0 && written.charAt(at - 1) !== '/';\n const after = next < written.length && written.charAt(next) !== '/';\n if (next - at > 2 || (next - at === 2 && (before || after))) {\n deep += `${before ? '*/' : ''}**${after ? '/*' : ''}`;\n flat += '*';\n at = next;\n continue;\n }\n }\n deep += written.slice(at, next);\n flat += written.slice(at, next);\n at = next;\n }\n return `write \"${deep}\" for any depth, or \"${flat}\" for one level`;\n}\n\nfunction tokenize(segment: string, escapes: boolean): Token[] | string {\n const tokens: Token[] = [];\n const chars = Array.from(segment);\n for (let i = 0; i < chars.length; i += 1) {\n const ch = chars[i] as string;\n if (ch === '\\\\' && escapes) {\n const next = chars[i + 1];\n if (next === undefined || /[A-Za-z0-9]/.test(next)) {\n return '\"\\\\\" escapes glob syntax; separate directories with \"/\"';\n }\n tokens.push({ kind: 'literal', point: next.codePointAt(0) as number });\n i += 1;\n } else if (ch === '*') {\n // Two stars inside a name are refused rather than read as one. The\n // tools this replaces read `docs/**.md` three ways - recursive, one\n // level, and as ripgrep does - and reading it as one level silently\n // dropped every nested document from a run that used to include them.\n if (chars[i + 1] === '*') return GLOBSTAR_IN_NAME;\n tokens.push({ kind: 'star' });\n } else if (ch === '?') {\n tokens.push({ kind: 'any' });\n } else if (ch === '[') {\n const parsed = readClass(chars, i, escapes);\n if (typeof parsed === 'string') return parsed;\n tokens.push(parsed.token);\n i = parsed.end;\n } else {\n tokens.push({ kind: 'literal', point: ch.codePointAt(0) as number });\n }\n }\n return tokens;\n}\n\nfunction readClass(chars: readonly string[], open: number, escapes: boolean): { token: Token; end: number } | string {\n let i = open + 1;\n let negated = false;\n if (chars[i] === '!' || chars[i] === '^') {\n negated = true;\n i += 1;\n }\n const ranges: CodeRange[] = [];\n let first = true;\n for (; i < chars.length; i += 1) {\n const ch = chars[i] as string;\n if (ch === ']' && !first) return { token: { kind: 'class', negated, ranges }, end: i };\n first = false;\n let low = ch;\n if (ch === '\\\\' && escapes && chars[i + 1] !== undefined) {\n i += 1;\n low = chars[i] as string;\n }\n let high = low;\n if (chars[i + 1] === '-' && chars[i + 2] !== undefined && chars[i + 2] !== ']') {\n i += 2;\n high = chars[i] as string;\n if (high === '\\\\' && escapes && chars[i + 1] !== undefined) {\n i += 1;\n high = chars[i] as string;\n }\n }\n const from = low.codePointAt(0) as number;\n const to = high.codePointAt(0) as number;\n if (to < from) return `the range \"${low}-${high}\" runs backwards`;\n ranges.push([from, to]);\n }\n return 'a \"[\" is never closed';\n}\n\n/* --------------------------------------------------------------- compiling */\n\nfunction literalText(segments: readonly Segment[]): string | null {\n const names: string[] = [];\n for (const segment of segments) {\n if (segment.kind !== 'name') return null;\n let name = '';\n for (const token of segment.tokens) {\n if (token.kind !== 'literal') return null;\n name += String.fromCodePoint(token.point);\n }\n names.push(name);\n }\n return names.join('/');\n}\n\n/** One segment name: at least one character, none of them `/`. */\nfunction name(b: Builder): Fragment {\n return b.plus(b.char(ANY));\n}\n\n/** Zero or more whole directories: `(name/)*`. */\nfunction anyDirectories(b: Builder): Fragment {\n return b.star(b.sequence([name(b), b.char(SEPARATOR)]));\n}\n\n/** One or more whole segments below a path: `/name(/name)*`. */\nfunction beneath(b: Builder): Fragment {\n return b.sequence([b.char(SEPARATOR), name(b), b.star(b.sequence([b.char(SEPARATOR), name(b)]))]);\n}\n\nfunction tokens(b: Builder, list: readonly Token[]): Fragment {\n return b.sequence(\n list.map((token) => {\n switch (token.kind) {\n case 'literal':\n return b.char(literalSet(token.point));\n case 'any':\n return b.char(ANY);\n case 'star':\n return b.star(b.char(ANY));\n case 'class':\n return b.char(classSet(token.ranges, token.negated));\n }\n }),\n );\n}\n\nfunction segmentsFragment(b: Builder, segments: readonly Segment[]): Fragment {\n const parts: Fragment[] = [];\n segments.forEach((segment, i) => {\n const last = i === segments.length - 1;\n if (segment.kind === 'globstar') {\n // Inside a path a globstar is any number of whole directories, the\n // separator after them included; at its end, at least one segment.\n parts.push(last ? b.sequence([name(b), b.star(b.sequence([b.char(SEPARATOR), name(b)]))]) : anyDirectories(b));\n return;\n }\n parts.push(tokens(b, segment.tokens));\n if (!last) parts.push(b.char(SEPARATOR));\n });\n return b.sequence(parts);\n}\n\nfunction compileAlternative(\n b: Builder,\n alternative: Alternative,\n options: GlobOptions,\n rooted: boolean,\n anchored: boolean,\n): { fragment: Fragment; base: string } {\n const { segments } = alternative;\n const body = segmentsFragment(b, segments);\n const root = rooted ? '/' : '';\n const literal = literalText(segments);\n const leading = leadingLiteral(segments);\n\n if (options.dialect === 'gitignore') {\n const floating = !anchored && !alternative.slashed;\n const parts = [body, b.optional(beneath(b))];\n if (floating) parts.unshift(anyDirectories(b));\n const base = literal !== null ? leading.slice(0, -1) : leading;\n return { fragment: b.sequence(parts), base: floating ? '' : base.join('/') };\n }\n\n if (options.dialect === 'ripgrep' && !rooted && !alternative.slashed) {\n return { fragment: b.sequence([anyDirectories(b), body]), base: '' };\n }\n\n const parts = rooted ? [b.char(SEPARATOR), body] : [body];\n if (options.dialect === 'path' && literal !== null) {\n const reading = typeof options.literal === 'function' ? options.literal(root + literal) : options.literal ?? 'either';\n if (reading === 'directory') {\n parts.push(beneath(b));\n return { fragment: b.sequence(parts), base: root + literal };\n }\n if (reading === 'either') parts.push(b.optional(beneath(b)));\n }\n // A literal path may be a file, whose base is the directory holding it.\n const base = literal !== null ? leading.slice(0, -1) : leading;\n return { fragment: b.sequence(parts), base: root + base.join('/') };\n}\n\nfunction leadingLiteral(segments: readonly Segment[]): string[] {\n const out: string[] = [];\n for (const segment of segments) {\n const text = literalText([segment]);\n if (text === null) break;\n out.push(text);\n }\n return out;\n}\n\n/* ---------------------------------------------------------------- questions */\n\nfunction assertComparable(globs: readonly Glob[]): void {\n for (const glob of globs) {\n if (!glob.caseSensitive) throw new Error(`\"${glob.source}\" ignores case; scopes are compared case-sensitively`);\n }\n}\n\n/**\n * A shortest path every glob in `include` matches and no glob in `exclude`\n * does: the file two scopes would both write, less what either protects.\n * `none` is a proof that there is no such path. Case-sensitive globs only.\n */\nexport function globWitness(\n include: readonly Glob[],\n exclude: readonly Glob[] = [],\n budget: number = WITNESS_BUDGET,\n): Witness {\n assertComparable([...include, ...exclude]);\n return findWitness(\n include.map((glob) => glob.automaton),\n exclude.map((glob) => glob.automaton),\n budget,\n );\n}\n\n/**\n * Whether every path `inner` matches is matched by one of `outer`: `true`,\n * `false`, or `undecided` when the search met its budget.\n */\nexport function globCovers(\n outer: readonly Glob[],\n inner: Glob,\n budget: number = WITNESS_BUDGET,\n): boolean | 'undecided' {\n const witness = globWitness([inner], outer, budget);\n return witness.kind === 'undecided' ? 'undecided' : witness.kind === 'none';\n}\n\n/* -------------------------------------------------------------------- lists */\n\nexport interface GlobList {\n /** Whether a path is in: the last entry that matches it decides, and a `!` entry takes it out. */\n match(path: string): boolean;\n readonly entries: readonly { readonly negated: boolean; readonly glob: Glob }[];\n}\n\nexport type GlobListParse = { readonly ok: true; readonly list: GlobList } | { readonly ok: false; readonly error: string };\n\n/**\n * A list of patterns read the way a `.gitignore` reads: in order, each entry\n * deciding the paths it matches, a leading `!` taking them back out.\n */\nexport function parseGlobList(patterns: readonly string[], options: GlobOptions): GlobListParse {\n const entries: { negated: boolean; glob: Glob }[] = [];\n for (const pattern of patterns) {\n const trimmed = pattern.trim();\n const negated = trimmed.startsWith('!');\n const parsed = parseGlob(negated ? trimmed.slice(1) : trimmed, options);\n if (!parsed.ok) return { ok: false, error: `\"${pattern}\": ${parsed.error}` };\n entries.push({ negated, glob: parsed.glob });\n }\n return {\n ok: true,\n list: {\n entries,\n match(path: string): boolean {\n let included = false;\n for (const entry of entries) if (entry.glob.match(path)) included = !entry.negated;\n return included;\n },\n },\n };\n}\n"]}
1
+ {"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/pattern/glob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EACL,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,OAAO,EACP,cAAc,GAIf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAkB,MAAM,cAAc,CAAC;AA4CpF,MAAM,OAAO,SAAU,SAAQ,KAAK;IACzB,MAAM,CAAS;IACxB,YAAY,MAAc,EAAE,MAAc;QACxC,KAAK,CAAC,iBAAiB,MAAM,MAAM,MAAM,EAAE,CAAC,CAAC;QAC7C,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,6DAA6D;AAC7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAsBpC,gDAAgD;AAChD,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,O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AE,EAAE,KAAK,EAAE,KAAK,EAAE,4DAA4D,KAAK,wBAAwB,EAAE,CAAC;IACzH,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;AACnE,CAAC;AASD,kHAAkH;AAClH,SAAS,KAAK,CAAC,IAAY,EAAE,WAA8B;IACzD,IAAI,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC;IAC9B,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;IAC/B,OAAO,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/C,IAAI,IAAI,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAC5B,IAAI,IAAI,CAAC,CAAC;QACV,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACtC,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;AAC3D,CAAC;AAED;;;;GAIG;AACH,SAAS,KAAK,CAAC,KAAc;IAC3B,OAAO,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;AAC3G,CAAC","sourcesContent":["/**\n * Globs, in the three dialects the spec-* tools speak, compiled to one kind of\n * automaton.\n *\n * The syntax is the part people type: `*`, `**`, `?`, `[abc]`, `[!a-z]`,\n * `{a,b}`, and `\\` to escape. What differs between the tools is not the\n * syntax but what a pattern is matched against, and those differences are\n * deliberate, so each has a name (docs/adr/0003-glob-dialects.md):\n *\n * - `path` - the whole repository-relative path, anchored at the root. A\n * pattern with no glob syntax names a file, a directory, or either, as the\n * caller says; `src/auth` may cover `src/auth/login.ts`.\n * - `ripgrep` - as ripgrep's `-g`: a pattern with no `/` is matched against\n * the last segment at any depth, so `*.ts` matches `src/deep/a.ts`; one with\n * a `/` is matched against the whole path.\n * - `gitignore` - as an exclusion list reads: a pattern matches a path or any\n * directory above it, so `tests` excludes everything under any `tests`; one\n * with a `/` other than a trailing one is anchored at the root, and a\n * leading `/` only anchors.\n *\n * Shared by all three:\n *\n * - `**` is a globstar only as a whole segment. `a/**\\/b` matches `a/b` and\n * `a/x/y/b`; a trailing `/**` matches everything inside a directory and not\n * the directory itself. Two stars inside a name, `**.md`, are refused: the\n * tools read it three ways, and the quiet reading narrowed their scope. The\n * refusal writes the two patterns it may have meant from the one written.\n * - `*`, `?` and classes never match `/`, and `*` matches a leading dot.\n * - Braces expand first, and each alternative reads as it would written on\n * its own: `{src/,lib}` is `src/` or `lib`, and a trailing `/` means the\n * directory's contents - in an exclusion, the directory and its contents.\n * `{/docs,lib}` is `/docs` or `lib`, the leading `/` rooting or anchoring\n * that alternative as it would the pattern. One that names no path,\n * `{./,lib}` or `{,lib}`, is refused, as `./` and the empty pattern are.\n * - A leading `./` is the current directory, and goes with the slashes after\n * it, as POSIX reads them: `.//docs` is `docs`, and never `/docs`.\n * - Case is the caller's decision, stated every time. A result must not\n * depend on the host it ran on.\n * - A malformed pattern is an error, never a literal. An unclosed `[` or `{`,\n * an extended glob, a `..` - each is refused with a reason, because a typo\n * read as a literal is a scope that silently matches nothing. An extended\n * glob is a group holding a `|`, `+(a|b)`: without one, `C++(notes).md` is\n * a name with parentheses in it, as ripgrep and `.gitignore` read it.\n */\n\nimport {\n AutomatonTooLarge,\n Builder,\n findWitness,\n Matcher,\n WITNESS_BUDGET,\n type Automaton,\n type Fragment,\n type Witness,\n} from './automaton.js';\nimport { ANY, classSet, literalSet, SEPARATOR, type CodeRange } from './charset.js';\n\nexport type GlobDialect = 'path' | 'ripgrep' | 'gitignore';\n\n/** How a `path` pattern with no glob syntax is read. */\nexport type LiteralReading = 'file' | 'directory' | 'either';\n\nexport interface GlobOptions {\n readonly dialect: GlobDialect;\n /** Whether `A` and `a` differ. No default: the caller decides, every time. */\n readonly caseSensitive: boolean;\n /**\n * `path` dialect only: how a pattern with no glob syntax is read - as a\n * file, as a directory and everything beneath it, or as either. A function\n * is asked per literal path, for a caller that knows the tree. `either` when\n * unset. A trailing `/`, on the pattern or on one of its brace alternatives,\n * always means a directory's contents, and is never asked about.\n */\n readonly literal?: LiteralReading | ((path: string) => LiteralReading) | undefined;\n /**\n * `escape` (the default): `\\` escapes the next character, and a `\\` before a\n * letter or digit is refused as a Windows separator typed by mistake.\n * `separator`: every `\\` is a `/`, for patterns typed on a Windows shell.\n */\n readonly backslash?: 'escape' | 'separator' | undefined;\n}\n\nexport interface Glob {\n readonly source: string;\n readonly dialect: GlobDialect;\n readonly caseSensitive: boolean;\n /**\n * The directories a walk must enter to find every match: one per\n * alternative, the leading literal segments. `''` for an alternative that\n * can match at any depth.\n */\n readonly bases: readonly string[];\n readonly automaton: Automaton;\n /** Whether a canonical path - POSIX, no `.`, no empty or trailing segment - matches. */\n match(path: string): boolean;\n}\n\nexport type GlobParse = { readonly ok: true; readonly glob: Glob } | { readonly ok: false; readonly error: string };\n\nexport class GlobError extends Error {\n readonly source: string;\n constructor(source: string, reason: string) {\n super(`invalid glob \"${source}\": ${reason}`);\n this.name = 'GlobError';\n this.source = source;\n }\n}\n\n/** More alternatives than this is a pattern nobody meant. */\nexport const MAX_ALTERNATIVES = 256;\n\ntype Token =\n | { readonly kind: 'literal'; readonly point: number }\n | { readonly kind: 'any' }\n | { readonly kind: 'star' }\n | { readonly kind: 'class'; readonly negated: boolean; readonly ranges: readonly CodeRange[] };\n\ntype Segment = { readonly kind: 'globstar' } | { readonly kind: 'name'; readonly tokens: readonly Token[] };\n\ninterface Alternative {\n readonly segments: readonly Segment[];\n /** Written with a `/` somewhere other than at its end. */\n readonly slashed: boolean;\n /**\n * Written with a leading `/`, on the pattern or on the alternative: rooted\n * at the filesystem's root in the `path` and `ripgrep` dialects, and only\n * anchored at the repository root in `gitignore`.\n */\n readonly rooted: boolean;\n}\n\n/** Whether a string uses glob syntax at all. */\nexport function isGlobSyntax(source: string): boolean {\n return /[*?[\\]{}]/.test(source);\n}\n\n/**\n * Parses and compiles a glob, or says why it cannot: malformed, or too large\n * to compile, past {@link MAX_ALTERNATIVES} alternatives or `MAX_STATES`\n * states. It throws only what a `literal` function throws.\n */\nexport function parseGlob(source: string, options: GlobOptions): GlobParse {\n const result = build(source, options);\n return typeof result === 'string' ? { ok: false, error: result } : { ok: true, glob: result };\n}\n\n/**\n * Parses and compiles a glob, throwing {@link GlobError} for every reason\n * {@link parseGlob} gives, and what a `literal` function throws.\n */\nexport function compileGlob(source: string, options: GlobOptions): Glob {\n const result = build(source, options);\n if (typeof result === 'string') throw new GlobError(source, result);\n return result;\n}\n\n/**\n * A pattern as every dialect takes it - trimmed, and each `\\` a separator\n * when the caller asks - or the reason it is refused before anything in it is\n * read.\n */\nfunction prepare(source: string, escapes: boolean): { readonly pattern: string } | string {\n const trimmed = source.trim();\n const pattern = escapes ? trimmed : trimmed.replace(/\\\\/g, '/');\n if (pattern.length === 0) return 'the pattern is empty';\n if (pattern.startsWith('!')) return 'a negated pattern is a list entry, not a glob; narrow the positive pattern';\n if (/(?:^|[^\\\\])[?*+@!]\\([^)]*\\|/.test(pattern)) return EXTGLOB;\n return { pattern };\n}\n\nfunction build(source: string, options: GlobOptions): Glob | string {\n const escapes = options.backslash !== 'separator';\n const prepared = prepare(source, escapes);\n if (typeof prepared === 'string') return prepared;\n const { pattern } = prepared;\n\n // The pattern's own leading slash is taken off before the braces expand, so\n // that the root itself, and a text the braces give, are refused in the\n // words they always were: `/{./,a}` is told `./`.\n const whole = unrooted(pattern);\n if (whole.text.length === 0) return 'the pattern names the root itself, not a path under it';\n\n const expanded = expandBraces(whole.text, escapes);\n if (typeof expanded === 'string') return expanded;\n\n const alternatives: Alternative[] = [];\n for (const text of expanded) {\n // Refused before its trailing slash is read, which would make `./` the\n // contents of `.`, every path: `{./,a}` is refused as `./` alone is.\n // Each text the braces give is shorter than the pattern, so only a\n // pattern without braces is its own text.\n if (namesNoPath(text)) return text === whole.text ? 'the pattern names no path' : bracesNamingNoPath(text);\n // Its leading slash is read as the pattern's is, since braces expand\n // before anything else is decided: `{/docs,x}` is `/docs` or `x`. Left to\n // `parseAlternative`, the slash would be an empty segment, dropped, and\n // `/docs` would read as `docs`. A slash after a segment, as in\n // `a/{/b,c}`, starts no text, and is the empty segment of `a//b`; one\n // after the pattern's `./` roots nothing either.\n const alone = unrooted(text);\n const parsed = parseAlternative(trailingSlash(alone.text, options.dialect), escapes);\n if (parsed === GLOBSTAR_IN_NAME) return `${GLOBSTAR_IN_NAME}: ${globstarAdvice(pattern)}`;\n if (typeof parsed === 'string') return parsed;\n alternatives.push({ ...parsed, rooted: rootedIn(whole, alone) });\n }\n\n const builder = new Builder();\n const fragments: Fragment[] = [];\n const bases: string[] = [];\n let automaton: Automaton;\n try {\n for (const alternative of alternatives) {\n const compiled = compileAlternative(builder, alternative, options);\n fragments.push(compiled.fragment);\n bases.push(compiled.base);\n }\n automaton = builder.finish(builder.either(fragments), options.caseSensitive);\n } catch (error) {\n // A pattern too large to compile is refused with a reason, as a malformed\n // one is. Anything else - a caller's literal reading that throws - is the\n // caller's failure, not the pattern's, and goes on up.\n if (error instanceof AutomatonTooLarge) return error.message;\n throw error;\n }\n let matcher: Matcher | null = null;\n return {\n source,\n dialect: options.dialect,\n caseSensitive: options.caseSensitive,\n bases: [...new Set(bases)],\n automaton,\n match(path: string): boolean {\n matcher ??= new Matcher(automaton);\n return matcher.test(path);\n },\n };\n}\n\n/* ------------------------------------------------------------------ braces */\n\n/**\n * Expands `{a,b}` groups into the patterns they stand for, or says why the\n * pattern is malformed.\n *\n * Classes and escapes are skipped while looking for braces and commas, so\n * `{[,]x,y}` is two alternatives, `[,]x` and `y`. A lone `}` is a literal: it\n * cannot be read as anything else. An unclosed `{` is an error.\n *\n * Here and in the two functions after it, a loop that reads one step past\n * the end reads `''`, which none of them acts on, and `classEnd` answers -1\n * or an index past the `[`, so `close > 0` and `close >= 0` read the same.\n * `open` is set by the `{` that any `}` read here closes, so its first value\n * is never read.\n */\nfunction expandBraces(pattern: string, escapes: boolean): string[] | string {\n let depth = 0;\n let open = -1;\n for (let i = 0; i < pattern.length; i += 1) {\n const ch = pattern.charAt(i);\n if (ch === '\\\\' && escapes) {\n i += 1;\n continue;\n }\n if (ch === '[') {\n const close = classEnd(pattern, i, escapes);\n if (close > 0) i = close;\n continue;\n }\n if (ch === '{') {\n if (depth === 0) open = i;\n depth += 1;\n continue;\n }\n if (ch !== '}' || depth === 0) continue;\n depth -= 1;\n if (depth > 0) continue;\n const prefix = pattern.slice(0, open);\n const suffix = pattern.slice(i + 1);\n const results: string[] = [];\n for (const option of splitOptions(pattern.slice(open + 1, i), escapes)) {\n const expanded = expandBraces(`${prefix}${option}${suffix}`, escapes);\n if (typeof expanded === 'string') return expanded;\n results.push(...expanded);\n if (results.length > MAX_ALTERNATIVES) return `the braces expand to more than ${MAX_ALTERNATIVES} patterns`;\n }\n return results;\n }\n if (depth > 0) return 'a \"{\" is never closed';\n return [pattern];\n}\n\n/** Splits a brace body on its top-level commas. */\nfunction splitOptions(body: string, escapes: boolean): string[] {\n const parts: string[] = [];\n let depth = 0;\n let start = 0;\n for (let i = 0; i < body.length; i += 1) {\n const ch = body.charAt(i);\n if (ch === '\\\\' && escapes) {\n i += 1;\n } else if (ch === '[') {\n const close = classEnd(body, i, escapes);\n if (close > 0) i = close;\n } else if (ch === '{') {\n depth += 1;\n } else if (ch === '}') {\n depth -= 1;\n } else if (ch === ',' && depth === 0) {\n parts.push(body.slice(start, i));\n start = i + 1;\n }\n }\n parts.push(body.slice(start));\n return parts;\n}\n\n/** The index of the `]` closing a class opened at `open`, or -1 when none does within the segment. */\nfunction classEnd(pattern: string, open: number, escapes: boolean): number {\n let i = open + 1;\n if (pattern.charAt(i) === '!' || pattern.charAt(i) === '^') i += 1;\n // The first member is always a member, even `]`.\n if (pattern.charAt(i) === ']') i += 1;\n for (; i < pattern.length; i += 1) {\n const ch = pattern.charAt(i);\n if (ch === '\\\\' && escapes) {\n i += 1;\n continue;\n }\n if (ch === '/') return -1;\n if (ch === ']') return i;\n }\n return -1;\n}\n\n/* ---------------------------------------------------------------- segments */\n\n/**\n * A pattern, or a text its braces give, without the `./` and the slashes it\n * starts with; whether a slash led it, which roots it; and whether a `./`\n * did, which leaves every slash after it rootless. What a leading slash means\n * is the dialect's: it roots a pattern at the filesystem's root in `path` and\n * `ripgrep`, and only anchors it at the repository root in `gitignore`, as\n * git reads one.\n *\n * The slashes after a `./` go with it, as POSIX reads `.//docs` as `./docs`:\n * the current directory, then `docs`. Left behind, they would lead what is\n * left and root it, and `.//docs` would be `/docs`. A slash the braces give\n * after a pattern's `./` is one of them, so `./{/docs,x}`, which is\n * `.//docs` or `./x`, roots neither.\n */\nfunction unrooted(text: string): Lead {\n let rest = text;\n while (rest.startsWith('./')) rest = rest.slice(2).replace(/^\\/+/, '');\n return { text: rest.replace(/^\\/+/, ''), rooted: rest.startsWith('/'), dotted: rest !== text };\n}\n\ninterface Lead {\n readonly text: string;\n readonly rooted: boolean;\n readonly dotted: boolean;\n}\n\n/**\n * Whether a text the braces give is rooted: by the pattern's own leading\n * slash, or by its own when the pattern's `./` does not stand before it.\n */\nfunction rootedIn(whole: Lead, alone: Lead): boolean {\n return whole.rooted || (alone.rooted && !whole.dotted);\n}\n\n/** Whether a pattern's text names no path: nothing in it but `/` and `.` segments. */\nfunction namesNoPath(text: string): boolean {\n return text.split('/').every((part) => part === '' || part === '.');\n}\n\n/**\n * The refusal of an alternative the braces give that names no path, naming\n * it as it was expanded, so that `.{/,a}` is told `./`, the text refused.\n */\nfunction bracesNamingNoPath(text: string): string {\n return text === '' ? 'the braces expand to an empty pattern' : `the braces expand to \"${text}\", which names no path`;\n}\n\n/**\n * What a trailing slash means, read on each alternative the braces give, so\n * that `{src/,lib}` reads `src/` as `src/` alone reads: the directory's\n * contents, `src/**`, and not a literal that may be the directory itself.\n *\n * In an exclusion `build/` excludes what `build` does. Git's rule is that a\n * trailing slash matches only a directory, and a directory is excluded with\n * everything in it; a matcher that sees only a path cannot tell a directory\n * from a file, so the slash is dropped, and it anchors nothing.\n *\n * Only ever given a text that names a path, so a name is left. The whole run\n * of slashes is taken, but one slash would read the same, since\n * `parseAlternative` drops the empty segments the rest leave; and taken\n * lazily it is the whole run all the same, since it ends the text.\n */\nfunction trailingSlash(text: string, dialect: GlobDialect): string {\n const name = text.replace(/\\/+$/, '');\n return name === text || dialect === 'gitignore' ? name : `${name}/**`;\n}\n\n/**\n * The segments of a text that names a path - `build` refuses one that does\n * not - so at least one segment is left.\n */\nfunction parseAlternative(text: string, escapes: boolean): Omit<Alternative, 'rooted'> | string {\n const segments: Segment[] = [];\n const raw = text.split('/');\n for (const part of raw) {\n if (part === '' || part === '.') continue;\n if (part === '..') return CLIMBS_OUT;\n if (part === '**') {\n if (segments[segments.length - 1]?.kind !== 'globstar') segments.push({ kind: 'globstar' });\n continue;\n }\n const tokens = tokenize(part, escapes);\n if (typeof tokens === 'string') return tokens;\n segments.push({ kind: 'name', tokens });\n }\n return { segments, slashed: raw.filter((part) => part !== '' && part !== '.').length > 1 };\n}\n\nconst CLIMBS_OUT = 'a pattern cannot climb out of its root with \"..\"';\nconst EXTGLOB = 'extended globs such as \"+(a|b)\" are not supported: write alternatives as \"{a,b}\", and a literal parenthesis as \"[(]\"';\nconst GLOBSTAR_IN_NAME = '\"**\" means any number of directories only as a whole segment';\n\n/**\n * The two patterns a writer of `**` inside a name may have meant, built from\n * what they wrote. Each run of stars that is not a whole segment becomes, for\n * any depth, a globstar segment with a star kept on each side where a name\n * went on - `docs/**.md` to `docs/**\\/*.md`, `src/a**` to `src/a*\\/**`,\n * `a**b` to `a*\\/**\\/*b` - and for one level a single star. Everything else\n * stays as written, braces and classes included, and a globstar that was a\n * whole segment stays one.\n *\n * Only `/` is taken for a boundary. A run beside a brace, `{**.md,x}`, is\n * given a star on that side too, which keeps the advice a pattern that\n * compiles whatever the braces expand to.\n *\n * `written` holds a `\\` only where it escapes: in the `separator` reading\n * each one is already a `/`.\n */\nfunction globstarAdvice(written: string): string {\n let deep = '';\n let flat = '';\n let at = 0;\n // One step past the end reads `''` and appends nothing, so the bound could\n // be one further and give the same advice.\n while (at < written.length) {\n const ch = written.charAt(at);\n let next = at + 1;\n if (ch === '\\\\') {\n next = at + 2;\n } else if (ch === '[') {\n // A class is copied as written. `classEnd` answers an index past the\n // `[`, or -1 for one never closed, so `close >= 0` reads the same; and\n // stopping one short of the `]` copies the class all the same, since\n // its last member and the `]` after it are never a run of stars.\n const close = classEnd(written, at, true);\n if (close > 0) next = close + 1;\n } else if (ch === '*') {\n while (written.charAt(next) === '*') next += 1;\n const before = at > 0 && written.charAt(at - 1) !== '/';\n const after = next < written.length && written.charAt(next) !== '/';\n if (next - at > 2 || (next - at === 2 && (before || after))) {\n deep += `${before ? '*/' : ''}**${after ? '/*' : ''}`;\n flat += '*';\n at = next;\n continue;\n }\n }\n deep += written.slice(at, next);\n flat += written.slice(at, next);\n at = next;\n }\n return `write \"${deep}\" for any depth, or \"${flat}\" for one level`;\n}\n\nfunction tokenize(segment: string, escapes: boolean): Token[] | string {\n const tokens: Token[] = [];\n const chars = Array.from(segment);\n for (let i = 0; i < chars.length; i += 1) {\n const ch = chars[i] as string;\n if (ch === '\\\\' && escapes) {\n const next = chars[i + 1];\n if (next === undefined || /[A-Za-z0-9]/.test(next)) {\n return '\"\\\\\" escapes glob syntax; separate directories with \"/\"';\n }\n tokens.push({ kind: 'literal', point: next.codePointAt(0) as number });\n i += 1;\n } else if (ch === '*') {\n // Two stars inside a name are refused rather than read as one. The\n // tools this replaces read `docs/**.md` three ways - recursive, one\n // level, and as ripgrep does - and reading it as one level silently\n // dropped every nested document from a run that used to include them.\n if (chars[i + 1] === '*') return GLOBSTAR_IN_NAME;\n tokens.push({ kind: 'star' });\n } else if (ch === '?') {\n tokens.push({ kind: 'any' });\n } else if (ch === '[') {\n const parsed = readClass(chars, i, escapes);\n if (typeof parsed === 'string') return parsed;\n tokens.push(parsed.token);\n i = parsed.end;\n } else {\n tokens.push({ kind: 'literal', point: ch.codePointAt(0) as number });\n }\n }\n return tokens;\n}\n\nfunction readClass(chars: readonly string[], open: number, escapes: boolean): { token: Token; end: number } | string {\n let i = open + 1;\n let negated = false;\n if (chars[i] === '!' || chars[i] === '^') {\n negated = true;\n i += 1;\n }\n const ranges: CodeRange[] = [];\n let first = true;\n for (; i < chars.length; i += 1) {\n const ch = chars[i] as string;\n if (ch === ']' && !first) return { token: { kind: 'class', negated, ranges }, end: i };\n first = false;\n let low = ch;\n if (ch === '\\\\' && escapes && chars[i + 1] !== undefined) {\n i += 1;\n low = chars[i] as string;\n }\n let high = low;\n if (chars[i + 1] === '-' && chars[i + 2] !== undefined && chars[i + 2] !== ']') {\n i += 2;\n high = chars[i] as string;\n if (high === '\\\\' && escapes && chars[i + 1] !== undefined) {\n i += 1;\n high = chars[i] as string;\n }\n }\n const from = low.codePointAt(0) as number;\n const to = high.codePointAt(0) as number;\n if (to < from) return `the range \"${low}-${high}\" runs backwards`;\n ranges.push([from, to]);\n }\n return 'a \"[\" is never closed';\n}\n\n/* --------------------------------------------------------------- compiling */\n\nfunction literalText(segments: readonly Segment[]): string | null {\n const names: string[] = [];\n for (const segment of segments) {\n if (segment.kind !== 'name') return null;\n let name = '';\n for (const token of segment.tokens) {\n if (token.kind !== 'literal') return null;\n name += String.fromCodePoint(token.point);\n }\n names.push(name);\n }\n return names.join('/');\n}\n\n/** One segment name: at least one character, none of them `/`. */\nfunction name(b: Builder): Fragment {\n return b.plus(b.char(ANY));\n}\n\n/** Zero or more whole directories: `(name/)*`. */\nfunction anyDirectories(b: Builder): Fragment {\n return b.star(b.sequence([name(b), b.char(SEPARATOR)]));\n}\n\n/** One or more whole segments below a path: `/name(/name)*`. */\nfunction beneath(b: Builder): Fragment {\n return b.sequence([b.char(SEPARATOR), name(b), b.star(b.sequence([b.char(SEPARATOR), name(b)]))]);\n}\n\nfunction tokens(b: Builder, list: readonly Token[]): Fragment {\n return b.sequence(\n list.map((token) => {\n switch (token.kind) {\n case 'literal':\n return b.char(literalSet(token.point));\n case 'any':\n return b.char(ANY);\n case 'star':\n return b.star(b.char(ANY));\n case 'class':\n return b.char(classSet(token.ranges, token.negated));\n }\n }),\n );\n}\n\nfunction segmentsFragment(b: Builder, segments: readonly Segment[]): Fragment {\n const parts: Fragment[] = [];\n segments.forEach((segment, i) => {\n const last = i === segments.length - 1;\n if (segment.kind === 'globstar') {\n // Inside a path a globstar is any number of whole directories, the\n // separator after them included; at its end, at least one segment.\n parts.push(last ? b.sequence([name(b), b.star(b.sequence([b.char(SEPARATOR), name(b)]))]) : anyDirectories(b));\n return;\n }\n parts.push(tokens(b, segment.tokens));\n if (!last) parts.push(b.char(SEPARATOR));\n });\n return b.sequence(parts);\n}\n\nfunction compileAlternative(b: Builder, alternative: Alternative, options: GlobOptions): { fragment: Fragment; base: string } {\n const { segments, rooted } = alternative;\n const body = segmentsFragment(b, segments);\n const root = rooted ? '/' : '';\n const literal = literalText(segments);\n const leading = leadingLiteral(segments);\n\n if (options.dialect === 'gitignore') {\n const floating = !rooted && !alternative.slashed;\n const parts = [body, b.optional(beneath(b))];\n if (floating) parts.unshift(anyDirectories(b));\n const base = literal !== null ? leading.slice(0, -1) : leading;\n return { fragment: b.sequence(parts), base: floating ? '' : base.join('/') };\n }\n\n if (options.dialect === 'ripgrep' && !rooted && !alternative.slashed) {\n return { fragment: b.sequence([anyDirectories(b), body]), base: '' };\n }\n\n const parts = rooted ? [b.char(SEPARATOR), body] : [body];\n if (options.dialect === 'path' && literal !== null) {\n const reading = typeof options.literal === 'function' ? options.literal(root + literal) : options.literal ?? 'either';\n if (reading === 'directory') {\n parts.push(beneath(b));\n return { fragment: b.sequence(parts), base: root + literal };\n }\n if (reading === 'either') parts.push(b.optional(beneath(b)));\n }\n // A literal path may be a file, whose base is the directory holding it.\n const base = literal !== null ? leading.slice(0, -1) : leading;\n return { fragment: b.sequence(parts), base: root + base.join('/') };\n}\n\nfunction leadingLiteral(segments: readonly Segment[]): string[] {\n const out: string[] = [];\n for (const segment of segments) {\n const text = literalText([segment]);\n if (text === null) break;\n out.push(text);\n }\n return out;\n}\n\n/* ---------------------------------------------------------------- questions */\n\nfunction assertComparable(globs: readonly Glob[]): void {\n for (const glob of globs) {\n if (!glob.caseSensitive) throw new Error(`\"${glob.source}\" ignores case; scopes are compared case-sensitively`);\n }\n}\n\n/**\n * A shortest path every glob in `include` matches and no glob in `exclude`\n * does: the file two scopes would both write, less what either protects.\n * `none` is a proof that there is no such path. Case-sensitive globs only.\n */\nexport function globWitness(\n include: readonly Glob[],\n exclude: readonly Glob[] = [],\n budget: number = WITNESS_BUDGET,\n): Witness {\n assertComparable([...include, ...exclude]);\n return findWitness(\n include.map((glob) => glob.automaton),\n exclude.map((glob) => glob.automaton),\n budget,\n );\n}\n\n/**\n * Whether every path `inner` matches is matched by one of `outer`: `true`,\n * `false`, or `undecided` when the search met its budget.\n */\nexport function globCovers(\n outer: readonly Glob[],\n inner: Glob,\n budget: number = WITNESS_BUDGET,\n): boolean | 'undecided' {\n const witness = globWitness([inner], outer, budget);\n return witness.kind === 'undecided' ? 'undecided' : witness.kind === 'none';\n}\n\n/* -------------------------------------------------------------------- lists */\n\nexport interface GlobList {\n /** Whether a path is in: the last entry that matches it decides, and a `!` entry takes it out. */\n match(path: string): boolean;\n readonly entries: readonly { readonly negated: boolean; readonly glob: Glob }[];\n}\n\nexport type GlobListParse = { readonly ok: true; readonly list: GlobList } | { readonly ok: false; readonly error: string };\n\n/**\n * A list of patterns read the way a `.gitignore` reads: in order, each entry\n * deciding the paths it matches, a leading `!` taking them back out.\n */\nexport function parseGlobList(patterns: readonly string[], options: GlobOptions): GlobListParse {\n const entries: { negated: boolean; glob: Glob }[] = [];\n for (const pattern of patterns) {\n const trimmed = pattern.trim();\n const negated = trimmed.startsWith('!');\n const parsed = parseGlob(negated ? trimmed.slice(1) : trimmed, options);\n if (!parsed.ok) return { ok: false, error: `\"${pattern}\": ${parsed.error}` };\n entries.push({ negated, glob: parsed.glob });\n }\n return {\n ok: true,\n list: {\n entries,\n match(path: string): boolean {\n let included = false;\n for (const entry of entries) if (entry.glob.match(path)) included = !entry.negated;\n return included;\n },\n },\n };\n}\n\n/* ------------------------------------------------------------- alternatives */\n\n/** One text a pattern's braces give, as every dialect reads its start. */\nexport interface GlobAlternative {\n /**\n * Led by a `/`, the pattern's or its own with no `./` of the pattern's\n * before it: rooted at the filesystem's root in the `path` and `ripgrep`\n * dialects, and anchored at the repository root in `gitignore`.\n */\n readonly rooted: boolean;\n /**\n * The text without the `./` and the slashes it starts with, the pattern's\n * included, and with each `}` and `,` no group took written as a class of\n * that one character, so that it reads the same inside braces again. Alone,\n * it reads the same behind a `/` when rooted and behind a `./` when not,\n * which keeps a `!` it starts with a character. A trailing `/` stays: what\n * it means is the dialect's.\n */\n readonly text: string;\n}\n\nexport type GlobAlternatives =\n | {\n readonly ok: true;\n /** Led by a `/` of its own, before any `./`, which roots every alternative. */\n readonly rooted: boolean;\n /** In the order the braces give them. */\n readonly alternatives: readonly GlobAlternative[];\n }\n | { readonly ok: false; readonly error: string };\n\n/**\n * The alternatives a pattern's braces give, each read at its start as\n * {@link parseGlob} reads it, for a tool that reads a pattern's alternatives\n * one by one - to anchor a rooted one, to hand each to another engine - and\n * would otherwise expand braces and read a leading `./` and `/` again itself.\n *\n * Braces expand first, and an alternative is rooted by a leading `/` on the\n * pattern, or on the text the braces give when no `./` of the pattern's stands\n * before it: `{/docs,x}` is `docs` rooted and `x`; `./{/docs,x}` and\n * `{.//docs,x}` are `docs` and `x`, neither rooted; `a/{/b,c}` is `a//b` and\n * `a/c`. A `!` after a `./` is a character, as it is to `parseGlob`: `./!a` is\n * the name `!a`.\n *\n * A reading, not a verdict: refused are only what `parseGlob` refuses before\n * it reads an alternative, in its words, and braces that do not expand. An\n * alternative `parseGlob` refuses - `{/,x}` gives `/` - is given as read.\n */\nexport function globAlternatives(source: string, options: Pick<GlobOptions, 'backslash'> = {}): GlobAlternatives {\n const escapes = options.backslash !== 'separator';\n const prepared = prepare(source, escapes);\n if (typeof prepared === 'string') return { ok: false, error: prepared };\n const whole = unrooted(prepared.pattern);\n const texts = expandBraces(whole.text, escapes);\n if (typeof texts === 'string') return { ok: false, error: texts };\n return {\n ok: true,\n rooted: whole.rooted,\n alternatives: texts.map((text) => {\n const alone = unrooted(text);\n // Past its root, a text may start with a `./` of its own, as `/./docs`\n // does, and names the same without it.\n return { rooted: rootedIn(whole, alone), text: asCharacters(unrooted(alone.text).text) };\n }),\n };\n}\n\n/**\n * A text the braces gave, with each `}` and `,` no group took written as the\n * class of that one character: once the braces have expanded, that is every\n * one outside a class and not escaped. Escapes and classes are copied as\n * written. A `\\` is always an escape here, since one read as a separator was\n * a `/` before the braces expanded. A step past the end reads `''`, which\n * adds nothing, so the bound could be one further.\n */\nfunction asCharacters(text: string): string {\n let out = '';\n for (let i = 0; i < text.length; i += 1) {\n const ch = text.charAt(i);\n let next = i + 1;\n if (ch === '\\\\') next = i + 2;\n else if (ch === '[') next = Math.max(next, classEnd(text, i, true) + 1);\n out += ch === '}' || ch === ',' ? `[${ch}]` : text.slice(i, next);\n i = next - 1;\n }\n return out;\n}\n\n/* ----------------------------------------------------------------- rebasing */\n\nexport type GlobRebase = { readonly ok: true; readonly pattern: string } | { readonly ok: false; readonly error: string };\n\n/**\n * A list entry typed in a directory below the root, rewritten to read from\n * the root as the `path` dialect reads it: for a tool run in a subdirectory\n * that matches whole paths from the root, where what is typed means what it\n * names from where it was typed.\n *\n * `directory` is where the entry was typed, a path under the root; at the\n * root itself, `''`, there is nothing to rewrite. The entry is read as\n * {@link parseGlobList} reads one: a leading `!` stays in front, and what\n * follows is the pattern. Braces expand first, and each alternative is\n * rebased as that text written alone would be:\n *\n * - one with a leading `/` is rooted at the filesystem's root, which no\n * directory moves, and is kept: `/docs` is `/docs` typed anywhere;\n * - any other gets the directory in front, a leading `..` climbing out of\n * it: `docs/*.md` typed in `sub` is `sub/docs/*.md`, and `../*.md` typed in\n * `docs/deep` is `docs/*.md`.\n *\n * When every alternative is rebased alike, the braces stay as written, `{a,b}`\n * typed in `sub` being `sub/{a,b}`; when they are not, each is written out:\n * `{/docs,x}` is `{/docs,sub/x}`.\n *\n * Refused, with the reason: what {@link parseGlob} refuses before it reads an\n * alternative, in its words; braces that do not expand; a `..` that climbs\n * above the root; a directory no pattern can name; and alternatives written\n * out that hold a `,` or a `}`, which would read as braces. Anything else a\n * rebased pattern holds is for `parseGlob` to refuse, as it would the same\n * pattern typed at the root.\n */\nexport function rebaseGlob(entry: string, directory: string, options: Pick<GlobOptions, 'backslash'> = {}): GlobRebase {\n if (directory === '') return { ok: true, pattern: entry };\n const directories = directory.split('/');\n if (directories.some((name) => name === '' || name === '.' || name === '..')) {\n throw new Error(`\"${directory}\" is not a directory under the root`);\n }\n const escapes = options.backslash !== 'separator';\n const trimmed = entry.trim();\n const negation = trimmed.startsWith('!') ? '!' : '';\n const prepared = prepare(trimmed.slice(negation.length), escapes);\n if (typeof prepared === 'string') return { ok: false, error: prepared };\n const { pattern } = prepared;\n const whole = unrooted(pattern);\n if (whole.rooted) return { ok: true, pattern: negation + pattern };\n const texts = expandBraces(whole.text, escapes);\n if (typeof texts === 'string') return { ok: false, error: texts };\n\n const pieces: string[] = [];\n const depths = new Set<number>();\n let rooted = false;\n for (const text of texts) {\n // Rooted as `build` roots it, the pattern's own slash having been read.\n if (rootedIn(whole, unrooted(text))) {\n rooted = true;\n pieces.push(text);\n continue;\n }\n const moved = climb(text, directories);\n if (moved === null) return { ok: false, error: CLIMBS_OUT };\n depths.add(moved.directories.length);\n pieces.push(spell(moved));\n }\n if (depths.size === 0) return { ok: true, pattern: negation + pattern };\n if (/^[!\\s]|[*?[{\\\\]/.test(directory)) {\n return {\n ok: false,\n error: `the directory \"${directory}\" cannot be named in a pattern: a \"*\", \"?\", \"[\", \"{\" or \"\\\\\" in it, or a \"!\" or a space it starts with, would be read as syntax`,\n };\n }\n // Every text the braces give starts with the pattern's own leading `..`\n // segments, and one of them has just climbed without leaving the root.\n const lead = climb(whole.text, directories) as Climbed;\n if (!rooted && depths.size === 1 && depths.has(lead.directories.length)) return { ok: true, pattern: negation + spell(lead) };\n const split = pieces.find((piece) => /[,}]/.test(piece));\n if (split !== undefined) {\n return { ok: false, error: `the braces cannot be rebased one alternative at a time: \"${split}\" holds a \",\" or a \"}\"` };\n }\n return { ok: true, pattern: `${negation}{${pieces.join(',')}}` };\n}\n\ninterface Climbed {\n /** The directories left once the text's leading `..` segments have climbed out. */\n readonly directories: readonly string[];\n /** The text after them, without a leading `./` or slash. */\n readonly rest: string;\n}\n\n/** A relative text's leading `..` segments taken off the directories it was typed in, or `null` past the root. */\nfunction climb(text: string, directories: readonly string[]): Climbed | null {\n let kept = directories.length;\n let rest = unrooted(text).text;\n while (rest === '..' || rest.startsWith('../')) {\n if (kept === 0) return null;\n kept -= 1;\n rest = unrooted(rest.slice(3)).text;\n }\n return { directories: directories.slice(0, kept), rest };\n}\n\n/**\n * A rebased relative text. At the root itself it is read from there behind a\n * `./`, which keeps a slash the braces give after it from rooting it, and\n * leaves the root refused as `./` is.\n */\nfunction spell(moved: Climbed): string {\n return moved.directories.length > 0 ? `${moved.directories.join('/')}/${moved.rest}` : `./${moved.rest}`;\n}\n"]}
@@ -1,5 +1,5 @@
1
- export { compileGlob, globCovers, globWitness, isGlobSyntax, parseGlob, parseGlobList, GlobError, MAX_ALTERNATIVES } from './glob.js';
2
- export type { Glob, GlobDialect, GlobList, GlobListParse, GlobOptions, GlobParse, LiteralReading } from './glob.js';
1
+ export { compileGlob, globAlternatives, globCovers, globWitness, isGlobSyntax, parseGlob, parseGlobList, rebaseGlob, GlobError, MAX_ALTERNATIVES, } from './glob.js';
2
+ export type { Glob, GlobAlternative, GlobAlternatives, GlobDialect, GlobList, GlobListParse, GlobOptions, GlobParse, GlobRebase, LiteralReading, } from './glob.js';
3
3
  export { AutomatonTooLarge, MAX_STATES, WITNESS_BUDGET } from './automaton.js';
4
4
  export type { Witness } from './automaton.js';
5
5
  export { compileRegex, RegexError } from './regex.js';
@@ -1,4 +1,4 @@
1
- export { compileGlob, globCovers, globWitness, isGlobSyntax, parseGlob, parseGlobList, GlobError, MAX_ALTERNATIVES } from './glob.js';
1
+ export { compileGlob, globAlternatives, globCovers, globWitness, isGlobSyntax, parseGlob, parseGlobList, rebaseGlob, GlobError, MAX_ALTERNATIVES, } from './glob.js';
2
2
  export { AutomatonTooLarge, MAX_STATES, WITNESS_BUDGET } from './automaton.js';
3
3
  export { compileRegex, RegexError } from './regex.js';
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/pattern/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEtI,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export { compileGlob, globCovers, globWitness, isGlobSyntax, parseGlob, parseGlobList, GlobError, MAX_ALTERNATIVES } from './glob.js';\nexport type { Glob, GlobDialect, GlobList, GlobListParse, GlobOptions, GlobParse, LiteralReading } from './glob.js';\nexport { AutomatonTooLarge, MAX_STATES, WITNESS_BUDGET } from './automaton.js';\nexport type { Witness } from './automaton.js';\nexport { compileRegex, RegexError } from './regex.js';\nexport type { RegexMatcher, RegexOptions } from './regex.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/pattern/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,SAAS,EACT,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAanB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export {\n compileGlob,\n globAlternatives,\n globCovers,\n globWitness,\n isGlobSyntax,\n parseGlob,\n parseGlobList,\n rebaseGlob,\n GlobError,\n MAX_ALTERNATIVES,\n} from './glob.js';\nexport type {\n Glob,\n GlobAlternative,\n GlobAlternatives,\n GlobDialect,\n GlobList,\n GlobListParse,\n GlobOptions,\n GlobParse,\n GlobRebase,\n LiteralReading,\n} from './glob.js';\nexport { AutomatonTooLarge, MAX_STATES, WITNESS_BUDGET } from './automaton.js';\nexport type { Witness } from './automaton.js';\nexport { compileRegex, RegexError } from './regex.js';\nexport type { RegexMatcher, RegexOptions } from './regex.js';\n"]}
@@ -1,2 +1,3 @@
1
1
  export { createLineIndex, inRanges, lineEnding, lineStarts, locate, maskRanges, mergeRanges, splitLines, stripBom, } from './lines.js';
2
2
  export type { LineIndex, Position, Range } from './lines.js';
3
+ export { displayWidth } from './width.js';
@@ -1,2 +1,3 @@
1
1
  export { createLineIndex, inRanges, lineEnding, lineStarts, locate, maskRanges, mergeRanges, splitLines, stripBom, } from './lines.js';
2
+ export { displayWidth } from './width.js';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,QAAQ,EACR,UAAU,EACV,UAAU,EACV,MAAM,EACN,UAAU,EACV,WAAW,EACX,UAAU,EACV,QAAQ,GACT,MAAM,YAAY,CAAC","sourcesContent":["export {\n createLineIndex,\n inRanges,\n lineEnding,\n lineStarts,\n locate,\n maskRanges,\n mergeRanges,\n splitLines,\n stripBom,\n} from './lines.js';\nexport type { LineIndex, Position, Range } from './lines.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,QAAQ,EACR,UAAU,EACV,UAAU,EACV,MAAM,EACN,UAAU,EACV,WAAW,EACX,UAAU,EACV,QAAQ,GACT,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export {\n createLineIndex,\n inRanges,\n lineEnding,\n lineStarts,\n locate,\n maskRanges,\n mergeRanges,\n splitLines,\n stripBom,\n} from './lines.js';\nexport type { LineIndex, Position, Range } from './lines.js';\nexport { displayWidth } from './width.js';\n"]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * How many columns of a terminal a text takes, for a tool that lines up the
3
+ * columns of a table it prints: `.padEnd` counts UTF-16 units, and `已接受`
4
+ * is three of them and six columns.
5
+ *
6
+ * Counted per grapheme cluster, as a terminal draws one: a cluster takes the
7
+ * width of the first character in it that shows, and what follows that
8
+ * character - a combining mark, a variation selector, a joiner and what it
9
+ * joins - adds nothing.
10
+ *
11
+ * - An East Asian Wide or Fullwidth character takes two: Han, kana and
12
+ * hangul, full-width forms, and most emoji.
13
+ * - So does an emoji sequence, whatever its first character's own width: an
14
+ * emoji and the presentation selector U+FE0F (`❤` with it, and a keycap),
15
+ * a modifier base and a skin tone (`☝` with one), and a flag, two
16
+ * regional indicators.
17
+ * - A cluster of nothing that shows takes none: combining marks, format
18
+ * characters - the zero-width space and joiners, the byte-order mark, the
19
+ * bidirectional controls - and control characters. A soft hyphen shows, as
20
+ * terminals draw one.
21
+ * - Everything else takes one, East Asian Ambiguous included, as a terminal
22
+ * draws it outside a legacy East Asian mode.
23
+ *
24
+ * The widths are the table below, fixed. Grapheme clusters and general
25
+ * categories are the runtime's, and a runtime knows the characters of its
26
+ * own Unicode version: only a character assigned after the older of two
27
+ * hosts' versions can be counted differently on them.
28
+ */
29
+ /** The columns a text takes in a terminal. */
30
+ export declare function displayWidth(text: string): number;
@@ -0,0 +1,113 @@
1
+ /**
2
+ * How many columns of a terminal a text takes, for a tool that lines up the
3
+ * columns of a table it prints: `.padEnd` counts UTF-16 units, and `已接受`
4
+ * is three of them and six columns.
5
+ *
6
+ * Counted per grapheme cluster, as a terminal draws one: a cluster takes the
7
+ * width of the first character in it that shows, and what follows that
8
+ * character - a combining mark, a variation selector, a joiner and what it
9
+ * joins - adds nothing.
10
+ *
11
+ * - An East Asian Wide or Fullwidth character takes two: Han, kana and
12
+ * hangul, full-width forms, and most emoji.
13
+ * - So does an emoji sequence, whatever its first character's own width: an
14
+ * emoji and the presentation selector U+FE0F (`❤` with it, and a keycap),
15
+ * a modifier base and a skin tone (`☝` with one), and a flag, two
16
+ * regional indicators.
17
+ * - A cluster of nothing that shows takes none: combining marks, format
18
+ * characters - the zero-width space and joiners, the byte-order mark, the
19
+ * bidirectional controls - and control characters. A soft hyphen shows, as
20
+ * terminals draw one.
21
+ * - Everything else takes one, East Asian Ambiguous included, as a terminal
22
+ * draws it outside a legacy East Asian mode.
23
+ *
24
+ * The widths are the table below, fixed. Grapheme clusters and general
25
+ * categories are the runtime's, and a runtime knows the characters of its
26
+ * own Unicode version: only a character assigned after the older of two
27
+ * hosts' versions can be counted differently on them.
28
+ */
29
+ /**
30
+ * The East Asian Wide and Fullwidth code points of Unicode 16.0.0
31
+ * (EastAsianWidth-16.0.0.txt), the unassigned ones its `@missing` lines
32
+ * make Wide included, as the first and last of each run, in order.
33
+ *
34
+ * 16.0 is the version both supported lines have: Node 22.16.0 reports
35
+ * `process.versions.unicode` 16.0, and Node 24.18.1 17.0, which Node 22 does
36
+ * not ship. A character is counted as the older line knows it; one 17.0
37
+ * added counts one, as it does on a host that cannot name it.
38
+ */
39
+ const WIDE = [
40
+ 0x1100, 0x115f, 0x231a, 0x231b, 0x2329, 0x232a, 0x23e9, 0x23ec, 0x23f0, 0x23f0, 0x23f3, 0x23f3,
41
+ 0x25fd, 0x25fe, 0x2614, 0x2615, 0x2630, 0x2637, 0x2648, 0x2653, 0x267f, 0x267f, 0x268a, 0x268f,
42
+ 0x2693, 0x2693, 0x26a1, 0x26a1, 0x26aa, 0x26ab, 0x26bd, 0x26be, 0x26c4, 0x26c5, 0x26ce, 0x26ce,
43
+ 0x26d4, 0x26d4, 0x26ea, 0x26ea, 0x26f2, 0x26f3, 0x26f5, 0x26f5, 0x26fa, 0x26fa, 0x26fd, 0x26fd,
44
+ 0x2705, 0x2705, 0x270a, 0x270b, 0x2728, 0x2728, 0x274c, 0x274c, 0x274e, 0x274e, 0x2753, 0x2755,
45
+ 0x2757, 0x2757, 0x2795, 0x2797, 0x27b0, 0x27b0, 0x27bf, 0x27bf, 0x2b1b, 0x2b1c, 0x2b50, 0x2b50,
46
+ 0x2b55, 0x2b55, 0x2e80, 0x2e99, 0x2e9b, 0x2ef3, 0x2f00, 0x2fd5, 0x2ff0, 0x303e, 0x3041, 0x3096,
47
+ 0x3099, 0x30ff, 0x3105, 0x312f, 0x3131, 0x318e, 0x3190, 0x31e5, 0x31ef, 0x321e, 0x3220, 0x3247,
48
+ 0x3250, 0xa48c, 0xa490, 0xa4c6, 0xa960, 0xa97c, 0xac00, 0xd7a3, 0xf900, 0xfaff, 0xfe10, 0xfe19,
49
+ 0xfe30, 0xfe52, 0xfe54, 0xfe66, 0xfe68, 0xfe6b, 0xff01, 0xff60, 0xffe0, 0xffe6, 0x16fe0, 0x16fe4,
50
+ 0x16ff0, 0x16ff1, 0x17000, 0x187f7, 0x18800, 0x18cd5, 0x18cff, 0x18d08, 0x1aff0, 0x1aff3,
51
+ 0x1aff5, 0x1affb, 0x1affd, 0x1affe, 0x1b000, 0x1b122, 0x1b132, 0x1b132, 0x1b150, 0x1b152,
52
+ 0x1b155, 0x1b155, 0x1b164, 0x1b167, 0x1b170, 0x1b2fb, 0x1d300, 0x1d356, 0x1d360, 0x1d376,
53
+ 0x1f004, 0x1f004, 0x1f0cf, 0x1f0cf, 0x1f18e, 0x1f18e, 0x1f191, 0x1f19a, 0x1f200, 0x1f202,
54
+ 0x1f210, 0x1f23b, 0x1f240, 0x1f248, 0x1f250, 0x1f251, 0x1f260, 0x1f265, 0x1f300, 0x1f320,
55
+ 0x1f32d, 0x1f335, 0x1f337, 0x1f37c, 0x1f37e, 0x1f393, 0x1f3a0, 0x1f3ca, 0x1f3cf, 0x1f3d3,
56
+ 0x1f3e0, 0x1f3f0, 0x1f3f4, 0x1f3f4, 0x1f3f8, 0x1f43e, 0x1f440, 0x1f440, 0x1f442, 0x1f4fc,
57
+ 0x1f4ff, 0x1f53d, 0x1f54b, 0x1f54e, 0x1f550, 0x1f567, 0x1f57a, 0x1f57a, 0x1f595, 0x1f596,
58
+ 0x1f5a4, 0x1f5a4, 0x1f5fb, 0x1f64f, 0x1f680, 0x1f6c5, 0x1f6cc, 0x1f6cc, 0x1f6d0, 0x1f6d2,
59
+ 0x1f6d5, 0x1f6d7, 0x1f6dc, 0x1f6df, 0x1f6eb, 0x1f6ec, 0x1f6f4, 0x1f6fc, 0x1f7e0, 0x1f7eb,
60
+ 0x1f7f0, 0x1f7f0, 0x1f90c, 0x1f93a, 0x1f93c, 0x1f945, 0x1f947, 0x1f9ff, 0x1fa70, 0x1fa7c,
61
+ 0x1fa80, 0x1fa89, 0x1fa8f, 0x1fac6, 0x1face, 0x1fadc, 0x1fadf, 0x1fae9, 0x1faf0, 0x1faf8,
62
+ 0x20000, 0x2fffd, 0x30000, 0x3fffd,
63
+ ];
64
+ /** A character that shows: anything but a control, a format character or a mark, and the soft hyphen. */
65
+ const SHOWN = /[^\p{Cc}\p{Cf}\p{Mn}\p{Me}]|\u00ad/u;
66
+ /**
67
+ * The start of an emoji sequence a terminal draws as one wide picture: an
68
+ * emoji and the presentation selector, a modifier base and its modifier, or
69
+ * two regional indicators, a flag.
70
+ */
71
+ const EMOJI_SEQUENCE = /^(?:\p{Emoji}\ufe0f|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}|\p{Regional_Indicator}{2})/u;
72
+ // Made the first time a width is asked for: loading the segmentation rules
73
+ // costs milliseconds that a tool which never measures a string - every one
74
+ // that copies this module for its line tables - would pay on each start.
75
+ let graphemes;
76
+ /** The columns a text takes in a terminal. */
77
+ export function displayWidth(text) {
78
+ // A named locale, so the host's default is never read; clusters are the
79
+ // same in every locale, and they are what a segmenter gives unless told
80
+ // otherwise.
81
+ graphemes ??= new Intl.Segmenter('en');
82
+ let width = 0;
83
+ for (const { segment } of graphemes.segment(text))
84
+ width += clusterWidth(segment);
85
+ return width;
86
+ }
87
+ function clusterWidth(cluster) {
88
+ const at = cluster.search(SHOWN);
89
+ if (at < 0)
90
+ return 0;
91
+ const shown = cluster.slice(at);
92
+ return isWide(shown.codePointAt(0)) || EMOJI_SEQUENCE.test(shown) ? 2 : 1;
93
+ }
94
+ /**
95
+ * Whether a code point is in {@link WIDE}, by bisection over its runs. The
96
+ * search is half-open, as `inRanges`'s is: `high` is one past the last run
97
+ * still in question.
98
+ */
99
+ function isWide(point) {
100
+ let low = 0;
101
+ let high = WIDE.length / 2;
102
+ while (low < high) {
103
+ const mid = (low + high) >> 1;
104
+ if (point < WIDE[2 * mid])
105
+ high = mid;
106
+ else if (point > WIDE[2 * mid + 1])
107
+ low = mid + 1;
108
+ else
109
+ return true;
110
+ }
111
+ return false;
112
+ }
113
+ //# sourceMappingURL=width.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"width.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/text/width.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;;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G,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAW,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtF,CAAC;AAED;;;;GAIG;AACH,SAAS,MAAM,CAAC,KAAa;IAC3B,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3B,OAAO,GAAG,GAAG,IAAI,EAAE,CAAC;QAClB,MAAM,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,KAAK,GAAI,IAAI,CAAC,CAAC,GAAG,GAAG,CAAY;YAAE,IAAI,GAAG,GAAG,CAAC;aAC7C,IAAI,KAAK,GAAI,IAAI,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAY;YAAE,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;;YACzD,OAAO,IAAI,CAAC;IACnB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * How many columns of a terminal a text takes, for a tool that lines up the\n * columns of a table it prints: `.padEnd` counts UTF-16 units, and `已接受`\n * is three of them and six columns.\n *\n * Counted per grapheme cluster, as a terminal draws one: a cluster takes the\n * width of the first character in it that shows, and what follows that\n * character - a combining mark, a variation selector, a joiner and what it\n * joins - adds nothing.\n *\n * - An East Asian Wide or Fullwidth character takes two: Han, kana and\n * hangul, full-width forms, and most emoji.\n * - So does an emoji sequence, whatever its first character's own width: an\n * emoji and the presentation selector U+FE0F (`❤` with it, and a keycap),\n * a modifier base and a skin tone (`☝` with one), and a flag, two\n * regional indicators.\n * - A cluster of nothing that shows takes none: combining marks, format\n * characters - the zero-width space and joiners, the byte-order mark, the\n * bidirectional controls - and control characters. A soft hyphen shows, as\n * terminals draw one.\n * - Everything else takes one, East Asian Ambiguous included, as a terminal\n * draws it outside a legacy East Asian mode.\n *\n * The widths are the table below, fixed. Grapheme clusters and general\n * categories are the runtime's, and a runtime knows the characters of its\n * own Unicode version: only a character assigned after the older of two\n * hosts' versions can be counted differently on them.\n */\n\n/**\n * The East Asian Wide and Fullwidth code points of Unicode 16.0.0\n * (EastAsianWidth-16.0.0.txt), the unassigned ones its `@missing` lines\n * make Wide included, as the first and last of each run, in order.\n *\n * 16.0 is the version both supported lines have: Node 22.16.0 reports\n * `process.versions.unicode` 16.0, and Node 24.18.1 17.0, which Node 22 does\n * not ship. A character is counted as the older line knows it; one 17.0\n * added counts one, as it does on a host that cannot name it.\n */\nconst WIDE: readonly number[] = [\n 0x1100, 0x115f, 0x231a, 0x231b, 0x2329, 0x232a, 0x23e9, 0x23ec, 0x23f0, 0x23f0, 0x23f3, 0x23f3,\n 0x25fd, 0x25fe, 0x2614, 0x2615, 0x2630, 0x2637, 0x2648, 0x2653, 0x267f, 0x267f, 0x268a, 0x268f,\n 0x2693, 0x2693, 0x26a1, 0x26a1, 0x26aa, 0x26ab, 0x26bd, 0x26be, 0x26c4, 0x26c5, 0x26ce, 0x26ce,\n 0x26d4, 0x26d4, 0x26ea, 0x26ea, 0x26f2, 0x26f3, 0x26f5, 0x26f5, 0x26fa, 0x26fa, 0x26fd, 0x26fd,\n 0x2705, 0x2705, 0x270a, 0x270b, 0x2728, 0x2728, 0x274c, 0x274c, 0x274e, 0x274e, 0x2753, 0x2755,\n 0x2757, 0x2757, 0x2795, 0x2797, 0x27b0, 0x27b0, 0x27bf, 0x27bf, 0x2b1b, 0x2b1c, 0x2b50, 0x2b50,\n 0x2b55, 0x2b55, 0x2e80, 0x2e99, 0x2e9b, 0x2ef3, 0x2f00, 0x2fd5, 0x2ff0, 0x303e, 0x3041, 0x3096,\n 0x3099, 0x30ff, 0x3105, 0x312f, 0x3131, 0x318e, 0x3190, 0x31e5, 0x31ef, 0x321e, 0x3220, 0x3247,\n 0x3250, 0xa48c, 0xa490, 0xa4c6, 0xa960, 0xa97c, 0xac00, 0xd7a3, 0xf900, 0xfaff, 0xfe10, 0xfe19,\n 0xfe30, 0xfe52, 0xfe54, 0xfe66, 0xfe68, 0xfe6b, 0xff01, 0xff60, 0xffe0, 0xffe6, 0x16fe0, 0x16fe4,\n 0x16ff0, 0x16ff1, 0x17000, 0x187f7, 0x18800, 0x18cd5, 0x18cff, 0x18d08, 0x1aff0, 0x1aff3,\n 0x1aff5, 0x1affb, 0x1affd, 0x1affe, 0x1b000, 0x1b122, 0x1b132, 0x1b132, 0x1b150, 0x1b152,\n 0x1b155, 0x1b155, 0x1b164, 0x1b167, 0x1b170, 0x1b2fb, 0x1d300, 0x1d356, 0x1d360, 0x1d376,\n 0x1f004, 0x1f004, 0x1f0cf, 0x1f0cf, 0x1f18e, 0x1f18e, 0x1f191, 0x1f19a, 0x1f200, 0x1f202,\n 0x1f210, 0x1f23b, 0x1f240, 0x1f248, 0x1f250, 0x1f251, 0x1f260, 0x1f265, 0x1f300, 0x1f320,\n 0x1f32d, 0x1f335, 0x1f337, 0x1f37c, 0x1f37e, 0x1f393, 0x1f3a0, 0x1f3ca, 0x1f3cf, 0x1f3d3,\n 0x1f3e0, 0x1f3f0, 0x1f3f4, 0x1f3f4, 0x1f3f8, 0x1f43e, 0x1f440, 0x1f440, 0x1f442, 0x1f4fc,\n 0x1f4ff, 0x1f53d, 0x1f54b, 0x1f54e, 0x1f550, 0x1f567, 0x1f57a, 0x1f57a, 0x1f595, 0x1f596,\n 0x1f5a4, 0x1f5a4, 0x1f5fb, 0x1f64f, 0x1f680, 0x1f6c5, 0x1f6cc, 0x1f6cc, 0x1f6d0, 0x1f6d2,\n 0x1f6d5, 0x1f6d7, 0x1f6dc, 0x1f6df, 0x1f6eb, 0x1f6ec, 0x1f6f4, 0x1f6fc, 0x1f7e0, 0x1f7eb,\n 0x1f7f0, 0x1f7f0, 0x1f90c, 0x1f93a, 0x1f93c, 0x1f945, 0x1f947, 0x1f9ff, 0x1fa70, 0x1fa7c,\n 0x1fa80, 0x1fa89, 0x1fa8f, 0x1fac6, 0x1face, 0x1fadc, 0x1fadf, 0x1fae9, 0x1faf0, 0x1faf8,\n 0x20000, 0x2fffd, 0x30000, 0x3fffd,\n];\n\n/** A character that shows: anything but a control, a format character or a mark, and the soft hyphen. */\nconst SHOWN = /[^\\p{Cc}\\p{Cf}\\p{Mn}\\p{Me}]|\\u00ad/u;\n\n/**\n * The start of an emoji sequence a terminal draws as one wide picture: an\n * emoji and the presentation selector, a modifier base and its modifier, or\n * two regional indicators, a flag.\n */\nconst EMOJI_SEQUENCE = /^(?:\\p{Emoji}\\ufe0f|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}|\\p{Regional_Indicator}{2})/u;\n\n// Made the first time a width is asked for: loading the segmentation rules\n// costs milliseconds that a tool which never measures a string - every one\n// that copies this module for its line tables - would pay on each start.\nlet graphemes: Intl.Segmenter | undefined;\n\n/** The columns a text takes in a terminal. */\nexport function displayWidth(text: string): number {\n // A named locale, so the host's default is never read; clusters are the\n // same in every locale, and they are what a segmenter gives unless told\n // otherwise.\n graphemes ??= new Intl.Segmenter('en');\n let width = 0;\n for (const { segment } of graphemes.segment(text)) width += clusterWidth(segment);\n return width;\n}\n\nfunction clusterWidth(cluster: string): number {\n const at = cluster.search(SHOWN);\n if (at < 0) return 0;\n const shown = cluster.slice(at);\n return isWide(shown.codePointAt(0) as number) || EMOJI_SEQUENCE.test(shown) ? 2 : 1;\n}\n\n/**\n * Whether a code point is in {@link WIDE}, by bisection over its runs. The\n * search is half-open, as `inRanges`'s is: `high` is one past the last run\n * still in question.\n */\nfunction isWide(point: number): boolean {\n let low = 0;\n let high = WIDE.length / 2;\n while (low < high) {\n const mid = (low + high) >> 1;\n if (point < (WIDE[2 * mid] as number)) high = mid;\n else if (point > (WIDE[2 * mid + 1] as number)) low = mid + 1;\n else return true;\n }\n return false;\n}\n"]}
@@ -8,7 +8,8 @@
8
8
  * the minimum instead, as a missing sibling is reported (ADR-0002, ADR-0011).
9
9
  *
10
10
  * package.json says the same minimums to npm as `peerDependencies`; a test
11
- * holds the two together.
11
+ * holds the two together. So is the oldest Claude Code that runs the hooks,
12
+ * which doctor measures the one on `PATH` against.
12
13
  */
13
14
  import type { SiblingName } from './config.js';
14
15
  export declare const MINIMUM_VERSIONS: Readonly<Record<SiblingName, string>>;
@@ -40,3 +41,28 @@ export type VersionCheck = {
40
41
  * refused as an old one is.
41
42
  */
42
43
  export declare function checkVersion(name: SiblingName, declared: unknown): VersionCheck;
44
+ /**
45
+ * The oldest Claude Code that runs the guard hooks (ADR-0012). Its changelog
46
+ * adds hook `args` in 2.1.139. An older release runs the hook's bare
47
+ * `command`, `node`, which reads the hook's input as a script and fails, and
48
+ * a PreToolUse hook that fails with anything but exit 2 blocks nothing: every
49
+ * write passes unguarded.
50
+ */
51
+ export declare const CLAUDE_CODE_MINIMUM = "2.1.139";
52
+ /** What `claude --version` printed, or why nothing could be asked. */
53
+ export type ClaudeCodeAnswer = {
54
+ readonly output: string;
55
+ } | {
56
+ readonly missing: string;
57
+ };
58
+ export type ClaudeCodeCheck = {
59
+ readonly state: 'ok' | 'outdated';
60
+ readonly version: string;
61
+ }
62
+ /** Never read as fine: an older release lets every write through. */
63
+ | {
64
+ readonly state: 'unknown';
65
+ readonly reason: string;
66
+ };
67
+ /** The release `claude --version` names in its first word, `2.1.235 (Claude Code)`, against the minimum. */
68
+ export declare function checkClaudeCode(answer: ClaudeCodeAnswer): ClaudeCodeCheck;
package/dist/versions.js CHANGED
@@ -8,7 +8,8 @@
8
8
  * the minimum instead, as a missing sibling is reported (ADR-0002, ADR-0011).
9
9
  *
10
10
  * package.json says the same minimums to npm as `peerDependencies`; a test
11
- * holds the two together.
11
+ * holds the two together. So is the oldest Claude Code that runs the hooks,
12
+ * which doctor measures the one on `PATH` against.
12
13
  */
13
14
  export const MINIMUM_VERSIONS = {
14
15
  // The plugin `waive` hook, through which spec-brief's archive accepts a
@@ -54,4 +55,25 @@ export function checkVersion(name, declared) {
54
55
  return { ok: true, version: declared };
55
56
  return { ok: false, version: declared, reason: `${name} ${declared} is installed here; ${needs}` };
56
57
  }
58
+ /**
59
+ * The oldest Claude Code that runs the guard hooks (ADR-0012). Its changelog
60
+ * adds hook `args` in 2.1.139. An older release runs the hook's bare
61
+ * `command`, `node`, which reads the hook's input as a script and fails, and
62
+ * a PreToolUse hook that fails with anything but exit 2 blocks nothing: every
63
+ * write passes unguarded.
64
+ */
65
+ export const CLAUDE_CODE_MINIMUM = '2.1.139';
66
+ /** The release `claude --version` names in its first word, `2.1.235 (Claude Code)`, against the minimum. */
67
+ export function checkClaudeCode(answer) {
68
+ if ('missing' in answer)
69
+ return { state: 'unknown', reason: answer.missing };
70
+ const said = answer.output.trim().split('\n')[0]?.trim() ?? '';
71
+ if (said === '')
72
+ return { state: 'unknown', reason: 'claude --version printed nothing' };
73
+ const first = said.split(/\s+/)[0];
74
+ const parsed = parseVersion(first);
75
+ if (parsed === null)
76
+ return { state: 'unknown', reason: `claude --version printed "${said}", which is not a version` };
77
+ return { state: meets(parsed, parseVersion(CLAUDE_CODE_MINIMUM)) ? 'ok' : 'outdated', version: first };
78
+ }
57
79
  //# sourceMappingURL=versions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"versions.js","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,MAAM,CAAC,MAAM,gBAAgB,GAA0C;IACrE,wEAAwE;IACxE,8CAA8C;IAC9C,YAAY,EAAE,OAAO;IACrB,4EAA4E;IAC5E,yEAAyE;IACzE,YAAY,EAAE,OAAO;IACrB,2EAA2E;IAC3E,wDAAwD;IACxD,YAAY,EAAE,QAAQ;CACvB,CAAC;AASF,qGAAqG;AACrG,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,KAAK,GAAG,yHAAyH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnJ,IAAI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,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,IAAI,6BAA6B,QAAQ,8BAA8B,KAAK,EAAE,EAAE,CAAC;IAC5J,IAAI,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,OAAO,CAAY,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IAC5F,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,IAAI,QAAQ,uBAAuB,KAAK,EAAE,EAAE,CAAC;AACrG,CAAC","sourcesContent":["/**\n * The oldest release of each sibling this harness runs, and an installed\n * sibling measured against it.\n *\n * An older sibling is not run. It would answer, and the answer would lack what\n * this release relies on: spec-brief before 0.2.0 has no `waive` hook, so its\n * archive refuses a protected file a signed ruling allows. It is reported with\n * the minimum instead, as a missing sibling is reported (ADR-0002, ADR-0011).\n *\n * package.json says the same minimums to npm as `peerDependencies`; a test\n * holds the two together.\n */\n\nimport type { SiblingName } from './config.js';\n\nexport const MINIMUM_VERSIONS: Readonly<Record<SiblingName, string>> = {\n // The plugin `waive` hook, through which spec-brief's archive accepts a\n // protected file that a signed ruling allows.\n 'spec-brief': '0.2.0',\n // An archived brief read as a record, as init configures it, where an older\n // release reads it as retired and what depends on it as a stale premise.\n 'spec-graph': '0.9.0',\n // Scopes read with the spec-core globs the harness reads them with, and an\n // archived brief's assertions withheld rather than run.\n 'spec-guard': '0.12.0',\n};\n\nexport interface Version {\n readonly major: number;\n readonly minor: number;\n readonly patch: number;\n readonly prerelease: boolean;\n}\n\n/** A semver version, or `null`. Build metadata is accepted and ignored, as precedence ignores it. */\nexport function parseVersion(text: string): Version | null {\n const match = /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/.exec(text);\n if (match === null) return null;\n return { major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]), prerelease: match[4] !== undefined };\n}\n\n/**\n * Whether `installed` is `minimum` or later by semver precedence. A minimum is\n * a release, never a prerelease, so a prerelease of the minimum comes before\n * it and a prerelease of anything later comes after it.\n */\nexport function meets(installed: Version, minimum: Version): boolean {\n const order = [installed.major - minimum.major, installed.minor - minimum.minor, installed.patch - minimum.patch].find((difference) => difference !== 0) ?? 0;\n return order > 0 || (order === 0 && !installed.prerelease);\n}\n\nexport type VersionCheck =\n | { readonly ok: true; readonly version: string }\n | { readonly ok: false; readonly version: string | null; readonly reason: string };\n\n/**\n * The `version` an installed sibling's package.json declares, against the\n * minimum. A version that cannot be read cannot be shown to meet it, and is\n * refused as an old one is.\n */\nexport function checkVersion(name: SiblingName, declared: unknown): VersionCheck {\n const minimum = MINIMUM_VERSIONS[name];\n const needs = `spec-harness needs ${minimum} or later: npm install --save-dev @descent-vtt/${name}@latest`;\n if (typeof declared !== 'string') return { ok: false, version: null, reason: `the ${name} installed here declares no version; ${needs}` };\n const parsed = parseVersion(declared);\n if (parsed === null) return { ok: false, version: declared, reason: `the ${name} installed here declares \"${declared}\", which is not a version; ${needs}` };\n if (meets(parsed, parseVersion(minimum) as Version)) return { ok: true, version: declared };\n return { ok: false, version: declared, reason: `${name} ${declared} is installed here; ${needs}` };\n}\n"]}
1
+ {"version":3,"file":"versions.js","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,CAAC,MAAM,gBAAgB,GAA0C;IACrE,wEAAwE;IACxE,8CAA8C;IAC9C,YAAY,EAAE,OAAO;IACrB,4EAA4E;IAC5E,yEAAyE;IACzE,YAAY,EAAE,OAAO;IACrB,2EAA2E;IAC3E,wDAAwD;IACxD,YAAY,EAAE,QAAQ;CACvB,CAAC;AASF,qGAAqG;AACrG,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC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E,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,mBAAmB,CAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AACpH,CAAC","sourcesContent":["/**\n * The oldest release of each sibling this harness runs, and an installed\n * sibling measured against it.\n *\n * An older sibling is not run. It would answer, and the answer would lack what\n * this release relies on: spec-brief before 0.2.0 has no `waive` hook, so its\n * archive refuses a protected file a signed ruling allows. It is reported with\n * the minimum instead, as a missing sibling is reported (ADR-0002, ADR-0011).\n *\n * package.json says the same minimums to npm as `peerDependencies`; a test\n * holds the two together. So is the oldest Claude Code that runs the hooks,\n * which doctor measures the one on `PATH` against.\n */\n\nimport type { SiblingName } from './config.js';\n\nexport const MINIMUM_VERSIONS: Readonly<Record<SiblingName, string>> = {\n // The plugin `waive` hook, through which spec-brief's archive accepts a\n // protected file that a signed ruling allows.\n 'spec-brief': '0.2.0',\n // An archived brief read as a record, as init configures it, where an older\n // release reads it as retired and what depends on it as a stale premise.\n 'spec-graph': '0.9.0',\n // Scopes read with the spec-core globs the harness reads them with, and an\n // archived brief's assertions withheld rather than run.\n 'spec-guard': '0.12.0',\n};\n\nexport interface Version {\n readonly major: number;\n readonly minor: number;\n readonly patch: number;\n readonly prerelease: boolean;\n}\n\n/** A semver version, or `null`. Build metadata is accepted and ignored, as precedence ignores it. */\nexport function parseVersion(text: string): Version | null {\n const match = /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/.exec(text);\n if (match === null) return null;\n return { major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]), prerelease: match[4] !== undefined };\n}\n\n/**\n * Whether `installed` is `minimum` or later by semver precedence. A minimum is\n * a release, never a prerelease, so a prerelease of the minimum comes before\n * it and a prerelease of anything later comes after it.\n */\nexport function meets(installed: Version, minimum: Version): boolean {\n const order = [installed.major - minimum.major, installed.minor - minimum.minor, installed.patch - minimum.patch].find((difference) => difference !== 0) ?? 0;\n return order > 0 || (order === 0 && !installed.prerelease);\n}\n\nexport type VersionCheck =\n | { readonly ok: true; readonly version: string }\n | { readonly ok: false; readonly version: string | null; readonly reason: string };\n\n/**\n * The `version` an installed sibling's package.json declares, against the\n * minimum. A version that cannot be read cannot be shown to meet it, and is\n * refused as an old one is.\n */\nexport function checkVersion(name: SiblingName, declared: unknown): VersionCheck {\n const minimum = MINIMUM_VERSIONS[name];\n const needs = `spec-harness needs ${minimum} or later: npm install --save-dev @descent-vtt/${name}@latest`;\n if (typeof declared !== 'string') return { ok: false, version: null, reason: `the ${name} installed here declares no version; ${needs}` };\n const parsed = parseVersion(declared);\n if (parsed === null) return { ok: false, version: declared, reason: `the ${name} installed here declares \"${declared}\", which is not a version; ${needs}` };\n if (meets(parsed, parseVersion(minimum) as Version)) return { ok: true, version: declared };\n return { ok: false, version: declared, reason: `${name} ${declared} is installed here; ${needs}` };\n}\n\n/**\n * The oldest Claude Code that runs the guard hooks (ADR-0012). Its changelog\n * adds hook `args` in 2.1.139. An older release runs the hook's bare\n * `command`, `node`, which reads the hook's input as a script and fails, and\n * a PreToolUse hook that fails with anything but exit 2 blocks nothing: every\n * write passes unguarded.\n */\nexport const CLAUDE_CODE_MINIMUM = '2.1.139';\n\n/** What `claude --version` printed, or why nothing could be asked. */\nexport type ClaudeCodeAnswer = { readonly output: string } | { readonly missing: string };\n\nexport type ClaudeCodeCheck =\n | { readonly state: 'ok' | 'outdated'; readonly version: string }\n /** Never read as fine: an older release lets every write through. */\n | { readonly state: 'unknown'; readonly reason: string };\n\n/** The release `claude --version` names in its first word, `2.1.235 (Claude Code)`, against the minimum. */\nexport function checkClaudeCode(answer: ClaudeCodeAnswer): ClaudeCodeCheck {\n if ('missing' in answer) return { state: 'unknown', reason: answer.missing };\n const said = answer.output.trim().split('\\n')[0]?.trim() ?? '';\n if (said === '') return { state: 'unknown', reason: 'claude --version printed nothing' };\n const first = said.split(/\\s+/)[0] as string;\n const parsed = parseVersion(first);\n if (parsed === null) return { state: 'unknown', reason: `claude --version printed \"${said}\", which is not a version` };\n return { state: meets(parsed, parseVersion(CLAUDE_CODE_MINIMUM) as Version) ? 'ok' : 'outdated', version: first };\n}\n"]}