Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
code on this site's /mcp
CLI
none: the JSON below is the answer
JSON
/christopher/abso-core/files/worker/project/globs.ts?version=315&format=json
61 linesFirst import 98% · infra-split 2%Last change infra-split in version 37, 2 versions changed it

You're reading version 315. The newest is 318, and no version since then changed this file. Go to the newestCompare with 318

1// File patterns for starting notes (#37): a note may name files
2// by glob ("tools/*.mjs"), or only in its text ("Add --mute-audio to every
3// Chromium launch in tools/*.mjs"). Overlap news matches both.
4
5const GLOB = /[*?]/;
6
7/**
8 * Whether `path` matches `pattern`: `*` is any run within one folder, `**`
9 * any run across folders, `?` one character. A pattern with no `/` and no
10 * glob ("main.ts") matches that file name in any folder.
11 */
12export function matchesPattern(pattern: string, path: string): boolean {
13 if (!GLOB.test(pattern))
14 return pattern.includes("/") ? pattern === path : pattern === path || path.endsWith(`/${pattern}`);
15 let re = "";
16 for (let i = 0; i < pattern.length; i++) {
17 const c = pattern[i]!;
18 if (c === "*" && pattern[i + 1] === "*") {
19 // "**/" also matches no folder at all.
20 if (pattern[i + 2] === "/") {
21 re += "(?:.*/)?";
22 i += 2;
23 } else {
24 re += ".*";
25 i += 1;
26 }
27 } else if (c === "*") re += "[^/]*";
28 else if (c === "?") re += "[^/]";
29 else re += c.replace(/[.+^${}()|[\]\\]/g, "\\$&");
30 }
31 const full = new RegExp(`^${re}$`);
32 return full.test(path) || (!pattern.includes("/") && full.test(path.slice(path.lastIndexOf("/") + 1)));
35/** Whether two patterns can name the same file: the same text, or one matches the other as a path. */
36export function patternsMeet(a: string, b: string): boolean {
37 return a === b || (!GLOB.test(b) && matchesPattern(a, b)) || (!GLOB.test(a) && matchesPattern(b, a));
40/**
41 * Paths and globs written in a note's text: words with a folder in them
42 * ("src/render/keys.ts", "tools/*.mjs"), or a file name with a letter
43 * extension ("audio.ts"). Version numbers and "x1.3" are not file names.
44 */
45export function pathsInText(text: string): string[] {
46 const out = new Set<string>();
47 for (const raw of text.split(/[\s,;:()'"`]+/)) {
48 const word = raw.replace(/[.!?]+$/, "");
49 if (word === "" || word.startsWith("-") || /^[a-z]+:\/\//i.test(word)) continue;
50 if (
51 word.includes("/") &&
52 /^[\w.*?\-/]+$/.test(word) &&
53 /[A-Za-z*]/.test(word) &&
54 !word.startsWith("/") &&
55 !word.includes("..")
56 )
57 out.add(word);
58 else if (/^[A-Za-z_][\w-]*(\.[A-Za-z_][\w-]*)*\.[A-Za-z]{1,6}$/.test(word)) out.add(word);
59 }
60 return [...out].sort();