Versions 17 to 318
Lines 1–57 at 318 (were 1–22 at 17)
1−// Where abso keeps its state (the rename from avcs). A new folder keeps it in .abso/ and the user's in ~/.abso/.
2−// Folders and machines from before keep working on .avcs/ and ~/.avcs/, untouched: a folder is never half-moved,
3−// so an older client or installed mod still finds it. A later `abso migrate` moves a folder once its mods are updated.
4−// No imports from the rest of the client, so any module can use this.
1+// Where abso keeps its state (the rename from avcs). Reading takes .abso/ first, then .avcs/, so a folder in
2+// either works. A new folder is made with .abso/ unless an edit mod installed here is from before the rename:
3+// such a mod looks only for .avcs/config.json, and would stop recording a .abso/ folder's edits without a word.
4+// So a new folder gets .avcs/ while any installed mod is older than MOD_KNOWS_ABSO, and .abso/ otherwise.
5+// The user's files are written to ~/.abso/ (an older client that can't find them says so: it isn't silent).
57
6−import { existsSync } from "node:fs";
811
1215
13−/** A folder's state folder: whichever has a config.json (.abso first), else whichever exists, else .abso for a folder not made yet. */
16+/** A folder's state folder: whichever has a config.json (.abso first), else whichever exists, else the new folder's name (newFolderDir). */
1518 for (const name of STATE_DIRS) if (existsSync(join(root, name, "config.json"))) return join(root, name);
17− return join(root, STATE_DIR);
1922
23+/** The first mod version whose hooks look for .abso/config.json as well as .avcs/config.json. */
25+
28+
37+
38+/** What a new folder is made with: .abso, unless an installed mod is older than the rename (see the top). */
39+export function newFolderDir(env: Readonly<Record<string, string | undefined>> = process.env): string {
45+ version = (JSON.parse(readFileSync(join(skills, name, ".avcs-install.json"), "utf8")) as { version?: unknown })
50+ if (typeof version !== "string" || !versionAtLeast(version, MOD_KNOWS_ABSO)) return OLD_STATE_DIR;
54+
2055/** A file under the user's home to read: ~/.abso/<parts>, else the old ~/.avcs/<parts> when only that exists, else the new place. */
- MCP
- compare on this site's /mcp
- CLI
- abso diff 17 318 client/src/state-dir.ts --json
- JSON
- /christopher/abso-core/compare/17..318?file=client%2Fsrc%2Fstate-dir.ts&format=json