{"draft":null,"from":16,"to":17,"files":[{"path":"client/src/config.ts","added":18,"removed":18,"diff":"--- a/client/src/config.ts\n+++ b/client/src/config.ts\n@@ -6,9 +6,10 @@\n \n import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\n import { homedir } from \"node:os\";\n-import { dirname, join, resolve } from \"node:path\";\n+import { basename, dirname, join, resolve } from \"node:path\";\n import { UsageError } from \"./args.ts\";\n import { type MachineServers, machineServers, TOKEN_SERVERS, tokenGoesTo, trustedList } from \"./core.ts\";\n+import { homeFile, stateDir } from \"./state-dir.ts\";\n \n /** What .avcs/config.json holds. */\n export interface Settings {\n@@ -25,13 +26,11 @@\n \treadonly token?: string;\n }\n \n-export const AVCS_DIR = \".avcs\";\n-\n export function configPath(root: string): string {\n-\treturn join(root, AVCS_DIR, \"config.json\");\n+\treturn join(stateDir(root), \"config.json\");\n }\n \n-/** The nearest folder at or above `start` that has .avcs/config.json, or undefined. */\n+/** The nearest folder at or above `start` that has .abso/config.json (or .avcs/config.json, from before the rename), or undefined. */\n export function findRoot(start: string): string | undefined {\n \tlet dir = resolve(start);\n \tfor (;;) {\n@@ -92,7 +91,7 @@\n }\n \n function keyPath(root: string): string {\n-\treturn join(root, AVCS_DIR, \"key\");\n+\treturn join(stateDir(root), \"key\");\n }\n \n function originOf(server: string): string {\n@@ -126,7 +125,7 @@\n \tif (configured && serverFlag && originOf(configured) !== originOf(serverFlag))\n \t\tthrow new UsageError(`this folder's server is ${configured}, not ${serverFlag}`);\n \tconst server = configured ?? serverFlag;\n-\tif (!server) throw new UsageError(\"this folder has no .avcs/config.json yet: give --server <url>\");\n+\tif (!server) throw new UsageError(\"this folder has no .abso/config.json yet: give --server <url>\");\n \tlet parsed: { key?: unknown; id?: unknown };\n \ttry {\n \t\tparsed = JSON.parse(stdin) as { key?: unknown; id?: unknown };\n@@ -140,7 +139,7 @@\n \t\t!/^k_[0-9a-f]{8}$/.test(parsed.id)\n \t)\n \t\tthrow new UsageError(\"stdin needs {key, id} from the staging issue route\");\n-\tmkdirSync(join(root, AVCS_DIR), { recursive: true });\n+\tmkdirSync(stateDir(root), { recursive: true });\n \twriteFileSync(keyPath(root), `${JSON.stringify({ server, key: parsed.key, id: parsed.id })}\\n`, { mode: 0o600 });\n \ttry {\n \t\tchmodSync(keyPath(root), 0o600);\n@@ -167,16 +166,16 @@\n \tconst trusted = trustedServers(env);\n \tif (token === undefined || tokenGoesTo(server, trusted)) return token;\n \tthrow new UsageError(\n-\t\t`this folder's server is ${server}, and abso sends your token only to ${[...TOKEN_SERVERS, \"this machine\"].join(\", \")}, and the servers ~/.avcs/servers.json or AVCS_TRUSTED_SERVERS name. ` +\n-\t\t\t`If ${server} is yours, name it in ~/.avcs/servers.json or AVCS_TRUSTED_SERVERS (comma-separated); if you didn't set it, someone else wrote .avcs/config.json.`,\n+\t\t`this folder's server is ${server}, and abso sends your token only to ${[...TOKEN_SERVERS, \"this machine\"].join(\", \")}, and the servers ~/.abso/servers.json or AVCS_TRUSTED_SERVERS name. ` +\n+\t\t\t`If ${server} is yours, name it in ~/.abso/servers.json or AVCS_TRUSTED_SERVERS (comma-separated); if you didn't set it, someone else wrote .abso/config.json.`,\n \t);\n }\n \n let machine: MachineServers | undefined;\n-/** This machine's servers (core.ts machineServers), from ~/.avcs/servers.json, read once. AVCS_SERVERS_FILE names another file (tests). */\n+/** This machine's servers (core.ts machineServers), from ~/.abso/servers.json (or ~/.abso/servers.json), read once. AVCS_SERVERS_FILE names another file (tests). */\n export function readMachineServers(env: Readonly<Record<string, string | undefined>> = process.env): MachineServers {\n \tif (env.AVCS_SERVERS_FILE !== undefined) return machineServers(readOr(env.AVCS_SERVERS_FILE));\n-\tmachine ??= machineServers(readOr(join(homedir(), AVCS_DIR, \"servers.json\")));\n+\tmachine ??= machineServers(readOr(homeFile(homedir(), \"servers.json\")));\n \treturn machine;\n }\n const readOr = (path: string): string | undefined => {\n@@ -192,18 +191,18 @@\n \treturn trustedList(env.AVCS_TRUSTED_SERVERS, readMachineServers(env));\n }\n \n-/** AVCS_TOKEN if set, else ~/.avcs/token, else none. */\n+/** AVCS_TOKEN if set, else ~/.abso/token, else ~/.avcs/token, else none. */\n export function readToken(env: Readonly<Record<string, string | undefined>> = process.env): string | undefined {\n \tif (env.AVCS_TOKEN) return env.AVCS_TOKEN.trim();\n \ttry {\n-\t\treturn readFileSync(join(homedir(), AVCS_DIR, \"token\"), \"utf8\").trim() || undefined;\n+\t\treturn readFileSync(homeFile(homedir(), \"token\"), \"utf8\").trim() || undefined;\n \t} catch {\n \t\treturn undefined;\n \t}\n }\n \n export function writeConfig(root: string, settings: Settings): void {\n-\tmkdirSync(join(root, AVCS_DIR), { recursive: true });\n+\tmkdirSync(stateDir(root), { recursive: true });\n \tconst { server, project, agent, follow, reader } = settings;\n \twriteFileSync(\n \t\tconfigPath(root),\n@@ -212,13 +211,14 @@\n \texcludeFromGit(root);\n }\n \n-/** If the folder is a git repo, keep .avcs/ out of it (in .git/info/exclude, so .gitignore isn't changed). */\n+/** If the folder is a git repo, keep its state folder (.abso/, or .avcs/ in an older folder) out of it (in .git/info/exclude, so .gitignore isn't changed). */\n function excludeFromGit(root: string): void {\n \tconst git = join(root, \".git\");\n \tif (!existsSync(join(git, \"HEAD\"))) return;\n \tconst exclude = join(git, \"info\", \"exclude\");\n \tconst text = existsSync(exclude) ? readFileSync(exclude, \"utf8\") : \"\";\n-\tif (text.split(/\\r?\\n/).some((line) => line.trim() === \".avcs/\" || line.trim() === \"/.avcs/\")) return;\n+\tconst name = `${basename(stateDir(root))}/`;\n+\tif (text.split(/\\r?\\n/).some((line) => line.trim() === name || line.trim() === `/${name}`)) return;\n \tmkdirSync(dirname(exclude), { recursive: true });\n-\twriteFileSync(exclude, `${text}${text === \"\" || text.endsWith(\"\\n\") ? \"\" : \"\\n\"}/.avcs/\\n`);\n+\twriteFileSync(exclude, `${text}${text === \"\" || text.endsWith(\"\\n\") ? \"\" : \"\\n\"}/${name}\\n`);\n }"}],"unmatched":[]}