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
blame on this site's /mcp
CLI
abso blame client/src/check-ignore.ts --json
JSON
/christopher/abso-core/blame/client/src/check-ignore.ts?format=json
85 linesFirst import 96% · review 4%Last change review in version 27,

85 lines from 3 changes in 3 versions.

init0Start the project1// `abso check-ignore`: whether abso leaves a path out, and which line of
2// which ignore file decided. The same rules record, publish, sync, run and the
3// hook use (core.ts).
4
5import { existsSync, statSync } from "node:fs";
6import { dirname, join, resolve } from "node:path";
7import { type Parsed, UsageError } from "./args.ts";
8import type { Env, Output } from "./commands.ts";
9import { findRoot } from "./config.ts";
10import type { IgnoreMatch } from "./core.ts";
11import { gitHome, loadIgnore, relativeTo } from "./folder.ts";
review27Client: ABSO_ environment names (AVCS_ still read), .absoignore (.avcsignore still read), .abso-export.json, shot files; READMEs say abso (abso 224)Compare13/** Starting .absoignore for `abso init`, when the folder has none. */
14export const STARTING_ABSOIGNORE = `# Files abso leaves out, on top of .gitignore. Same rules as .gitignore; this
init0Start the project15# file wins over .gitignore in the same folder. \`abso check-ignore <path>\`
review17New folders keep their state in .abso/, and the machine's sign-in, servers and admin token are read from ~/.abso/ first, then ~/.avcs/. A folder made before, with only .avcs/, is untouched: it keeps working, is never half-moved, and no older client or mod loses it. stateDir(root) and homeFile/homeWritePath are in the new client/src/state-dir.ts and replace the old AVCS_DIR constant everywhere. abso login writes only to ~/.abso/ and leaves ~/.avcs/ alone; logout removes both copies. The edit mod and the view mod read either folder. .abso is skipped like .avcs (including its odd spellings), the git exclude names whichever folder is in use, and the messages name .abso. Not changed: avcs.json (the server reads that name, so abso.json needs the server to learn it first), .avcsignore, env var names and wire headers. Tests: 709 run, 708 pass (one is skipped), including new ones for the folder choice, the home-file order and box sign-in; biome ci has no errors.Compare16# says which line decided. .git, .abso, .avcs, .claude and node_modules are always
init0Start the project17# left out.
19# Each session's own Claude Code state
20.claude/
22# Operating system files
23.DS_Store
24._*
25.Spotlight-V100/
26.Trashes/
27Thumbs.db
28ehthumbs.db
29desktop.ini
30$RECYCLE.BIN/
31`;
33/** The abso folder around cwd, else the git repository around it, else cwd. */
34function rootFor(cwd: string): string {
35 const avcs = findRoot(cwd);
36 if (avcs !== undefined) return avcs;
37 for (let dir = resolve(cwd); ; dir = dirname(dir)) {
38 if (existsSync(join(dir, ".git"))) return dir;
39 if (dirname(dir) === dir) return resolve(cwd);
40 }
43function rule(m: IgnoreMatch): string {
44 return m.rule ? `${m.rule.source}:${m.rule.line} "${m.rule.pattern}"` : "";
47function describe(rel: string, m: IgnoreMatch): string {
48 if (m.alwaysSkipped !== undefined) return `${rel}: ignored: abso always leaves out ${m.alwaysSkipped}`;
49 if (m.folder !== undefined)
50 return `${rel}: ignored, because its folder ${m.folder} is ignored by ${rule(m)}. Nothing inside an ignored folder can be brought back with "!"; un-ignore the folder first.`;
51 if (m.rule === undefined) return `${rel}: not ignored (no rule matches)`;
52 return m.ignored ? `${rel}: ignored by ${rule(m)}` : `${rel}: not ignored: ${rule(m)} brings it back`;
55export async function runCheckIgnore(args: Parsed, env: Env): Promise<Output> {
56 if (args.positionals.length === 0) throw new UsageError("give at least one path: abso check-ignore <path...>");
57 const root = rootFor(env.cwd);
58 const ignore = loadIgnore(root, gitHome(env.env));
59 const results = args.positionals.map((arg) => {
60 const full = resolve(env.cwd, arg);
61 const rel = relativeTo(root, full);
62 if (rel === undefined) throw new UsageError(`${arg} is not inside ${root}`);
63 let isDir = /[\\/]$/.test(arg);
64 try {
65 isDir = statSync(full).isDirectory();
66 } catch {
67 // A path that doesn't exist yet: a trailing slash means a folder.
68 }
69 return { rel, isDir, match: ignore.why(rel, isDir) };
70 });
71 return {
72 text: results.map(({ rel, match }) => describe(rel, match)).join("\n"),
73 json: {
74 root,
75 paths: results.map(({ rel, isDir, match: m }) => ({
76 path: rel,
77 folder: isDir,
78 ignored: m.ignored,
79 ...(m.rule ? { source: m.rule.source, line: m.rule.line, pattern: m.rule.pattern } : {}),
80 ...(m.folder !== undefined ? { because: m.folder } : {}),
81 ...(m.alwaysSkipped !== undefined ? { alwaysSkipped: m.alwaysSkipped } : {}),
82 })),
83 },
84 };