{"file":"client/test/install.test.ts","version":318,"total":525,"from":1,"to":525,"lines":[{"n":1,"text":"// Installing a mod (src/install.ts, #29): a staged copy that passed its check","atom":"a0","author":"init","version":0},{"n":2,"text":"// goes in file by file with renames, plugin.json last; what it replaces is","atom":"a0","author":"init","version":0},{"n":3,"text":"// kept for a rollback; a failed check or a failed rename leaves the mod as it","atom":"a0","author":"init","version":0},{"n":4,"text":"// was. Every install here goes into a scratch folder. And which client this","atom":"a0","author":"init","version":0},{"n":5,"text":"// is (src/version.ts): the commit, read from .git the way git reads it.","atom":"a0","author":"init","version":0},{"n":6,"text":"","atom":"a0","author":"init","version":0},{"n":7,"text":"import assert from \"node:assert/strict\";","atom":"a0","author":"init","version":0},{"n":8,"text":"import { spawnSync } from \"node:child_process\";","atom":"a0","author":"init","version":0},{"n":9,"text":"import {","atom":"a0","author":"init","version":0},{"n":10,"text":"\tcopyFileSync,","atom":"a0","author":"init","version":0},{"n":11,"text":"\texistsSync,","atom":"a0","author":"init","version":0},{"n":12,"text":"\tmkdirSync,","atom":"a0","author":"init","version":0},{"n":13,"text":"\tmkdtempSync,","atom":"a0","author":"init","version":0},{"n":14,"text":"\treaddirSync,","atom":"a0","author":"init","version":0},{"n":15,"text":"\treadFileSync,","atom":"a0","author":"init","version":0},{"n":16,"text":"\trenameSync,","atom":"a0","author":"init","version":0},{"n":17,"text":"\trmSync,","atom":"a0","author":"init","version":0},{"n":18,"text":"\tstatSync,","atom":"a0","author":"init","version":0},{"n":19,"text":"\tutimesSync,","atom":"a0","author":"init","version":0},{"n":20,"text":"\twriteFileSync,","atom":"a0","author":"init","version":0},{"n":21,"text":"} from \"node:fs\";","atom":"a0","author":"init","version":0},{"n":22,"text":"import { tmpdir } from \"node:os\";","atom":"a0","author":"init","version":0},{"n":23,"text":"import { dirname, join, relative } from \"node:path\";","atom":"a0","author":"init","version":0},{"n":24,"text":"import { after, describe, it } from \"node:test\";","atom":"a0","author":"init","version":0},{"n":25,"text":"import { Api } from \"../src/api.ts\";","atom":"a0","author":"init","version":0},{"n":26,"text":"import { clientVersion, headCommit } from \"../src/client-version.ts\";","atom":"a0","author":"init","version":0},{"n":27,"text":"import {","atom":"a402","author":"review","version":40},{"n":28,"text":"\tAVCS_MOD,","atom":"a402","author":"review","version":40},{"n":29,"text":"\thookCommand,","atom":"a2871","author":"pinch","version":293},{"n":30,"text":"\tinstallerCommand,","atom":"a2774","author":"pinch","version":281},{"n":31,"text":"\tinstallMod,","atom":"a402","author":"review","version":40},{"n":32,"text":"\tkeptModCommit,","atom":"a421","author":"speed","version":43},{"n":33,"text":"\ttype ModSpec,","atom":"a402","author":"review","version":40},{"n":34,"text":"\tmodsBehindText,","atom":"a402","author":"review","version":40},{"n":35,"text":"\tretireOldMod,","atom":"a402","author":"review","version":40},{"n":36,"text":"\trollbackMod,","atom":"a402","author":"review","version":40},{"n":37,"text":"\tversionFor,","atom":"a402","author":"review","version":40},{"n":38,"text":"\tversionReport,","atom":"a402","author":"review","version":40},{"n":39,"text":"} from \"../src/install.ts\";","atom":"a402","author":"review","version":40},{"n":40,"text":"import { main } from \"../src/main.ts\";","atom":"a0","author":"init","version":0},{"n":41,"text":"","atom":"a0","author":"init","version":0},{"n":42,"text":"const hasGit = spawnSync(\"git\", [\"--version\"]).status === 0;","atom":"a0","author":"init","version":0},{"n":43,"text":"const dirs: string[] = [];","atom":"a0","author":"init","version":0},{"n":44,"text":"after(() => {","atom":"a0","author":"init","version":0},{"n":45,"text":"\tfor (const d of dirs) rmSync(d, { recursive: true, force: true, maxRetries: 5 });","atom":"a0","author":"init","version":0},{"n":46,"text":"});","atom":"a0","author":"init","version":0},{"n":47,"text":"","atom":"a0","author":"init","version":0},{"n":48,"text":"function temp(): string {","atom":"a0","author":"init","version":0},{"n":49,"text":"\tconst d = mkdtempSync(join(tmpdir(), \"avcs-install-test-\"));","atom":"a0","author":"init","version":0},{"n":50,"text":"\tdirs.push(d);","atom":"a0","author":"init","version":0},{"n":51,"text":"\treturn d;","atom":"a0","author":"init","version":0},{"n":52,"text":"}","atom":"a0","author":"init","version":0},{"n":53,"text":"","atom":"a0","author":"init","version":0},{"n":54,"text":"const FILES = [\"src/core.ts\", \"hooks/stamp.ts\", \"hooks/register.ts\", \"hooks/hooks.json\", \".claude-plugin/plugin.json\"];","atom":"a0","author":"init","version":0},{"n":55,"text":"const pass = () => undefined;","atom":"a0","author":"init","version":0},{"n":56,"text":"const at = (dir: string, rel: string) => join(dir, ...rel.split(\"/\"));","atom":"a0","author":"init","version":0},{"n":57,"text":"const read = (dir: string, rel: string) => readFileSync(at(dir, rel), \"utf8\");","atom":"a0","author":"init","version":0},{"n":58,"text":"const write = (dir: string, rel: string, text: string) => {","atom":"a0","author":"init","version":0},{"n":59,"text":"\tmkdirSync(dirname(at(dir, rel)), { recursive: true });","atom":"a0","author":"init","version":0},{"n":60,"text":"\twriteFileSync(at(dir, rel), text);","atom":"a0","author":"init","version":0},{"n":61,"text":"};","atom":"a0","author":"init","version":0},{"n":62,"text":"","atom":"a0","author":"init","version":0},{"n":63,"text":"/** A mod's source folder: a small mod shaped like avcs, with these texts in place of the defaults. */","atom":"a0","author":"init","version":0},{"n":64,"text":"function source(texts: Record<string, string> = {}): ModSpec {","atom":"a0","author":"init","version":0},{"n":65,"text":"\tconst from = temp();","atom":"a0","author":"init","version":0},{"n":66,"text":"\tconst all: Record<string, string> = {","atom":"a0","author":"init","version":0},{"n":67,"text":"\t\t\"src/core.ts\": \"export const core = 1\\n\",","atom":"a0","author":"init","version":0},{"n":68,"text":"\t\t\"hooks/stamp.ts\": \"// Which mod this is.\\nexport const STAMP: string | undefined = undefined\\n\",","atom":"a0","author":"init","version":0},{"n":69,"text":"\t\t\"hooks/register.ts\": \"import { core } from '../src/core.ts'\\n\",","atom":"a0","author":"init","version":0},{"n":70,"text":"\t\t\"hooks/hooks.json\": '{ \"modules\": [\"./register.ts\"] }\\n',","atom":"a0","author":"init","version":0},{"n":71,"text":"\t\t\".claude-plugin/plugin.json\": '{ \"name\": \"avcs\", \"version\": \"0.1.0\", \"description\": \"a mod\" }\\n',","atom":"a0","author":"init","version":0},{"n":72,"text":"\t\t...texts,","atom":"a0","author":"init","version":0},{"n":73,"text":"\t};","atom":"a0","author":"init","version":0},{"n":74,"text":"\tfor (const [rel, text] of Object.entries(all)) write(from, rel, text);","atom":"a0","author":"init","version":0},{"n":75,"text":"\treturn { name: \"avcs\", from, files: FILES };","atom":"a0","author":"init","version":0},{"n":76,"text":"}","atom":"a0","author":"init","version":0},{"n":77,"text":"","atom":"a0","author":"init","version":0},{"n":78,"text":"/** Every file under dir, relative and sorted. */","atom":"a0","author":"init","version":0},{"n":79,"text":"function tree(dir: string): string[] {","atom":"a0","author":"init","version":0},{"n":80,"text":"\treturn readdirSync(dir, { recursive: true, withFileTypes: true })","atom":"a0","author":"init","version":0},{"n":81,"text":"\t\t.filter((e) => e.isFile())","atom":"a0","author":"init","version":0},{"n":82,"text":"\t\t.map((e) => relative(dir, join(e.parentPath, e.name)).replace(/\\\\/g, \"/\"))","atom":"a0","author":"init","version":0},{"n":83,"text":"\t\t.sort();","atom":"a0","author":"init","version":0},{"n":84,"text":"}","atom":"a0","author":"init","version":0},{"n":85,"text":"","atom":"a0","author":"init","version":0},{"n":86,"text":"const contents = (dir: string) => Object.fromEntries(tree(dir).map((rel) => [rel, read(dir, rel)]));","atom":"a0","author":"init","version":0},{"n":87,"text":"const record = (dir: string) =>","atom":"a0","author":"init","version":0},{"n":88,"text":"\tJSON.parse(read(dir, \".avcs-install.json\")) as {","atom":"a0","author":"init","version":0},{"n":89,"text":"\t\tversion: string;","atom":"a0","author":"init","version":0},{"n":90,"text":"\t\tfiles: string[];","atom":"a0","author":"init","version":0},{"n":91,"text":"\t\tprev?: { version: string; files: string[] };","atom":"a0","author":"init","version":0},{"n":92,"text":"\t\tmoving?: string;","atom":"a0","author":"init","version":0},{"n":93,"text":"\t};","atom":"a0","author":"init","version":0},{"n":94,"text":"","atom":"a0","author":"init","version":0},{"n":95,"text":"describe(\"installing a mod\", () => {","atom":"a0","author":"init","version":0},{"n":96,"text":"\tit(\"stamps the version into plugin.json and stamp.ts, and leaves nothing staged behind\", () => {","atom":"a0","author":"init","version":0},{"n":97,"text":"\t\tconst spec = source();","atom":"a0","author":"init","version":0},{"n":98,"text":"\t\tconst target = join(temp(), \"avcs\");","atom":"a0","author":"init","version":0},{"n":99,"text":"\t\tconst r = installMod(spec, { target, check: pass, commit: \"702c616\" });","atom":"a0","author":"init","version":0},{"n":100,"text":"\t\tassert.deepEqual(r, { changed: true, version: \"0.1.0+702c616\", previous: undefined, files: 5 });","atom":"a0","author":"init","version":0},{"n":101,"text":"\t\tassert.deepEqual(JSON.parse(read(target, \".claude-plugin/plugin.json\")), {","atom":"a0","author":"init","version":0},{"n":102,"text":"\t\t\tname: \"avcs\",","atom":"a0","author":"init","version":0},{"n":103,"text":"\t\t\tversion: \"0.1.0+702c616\",","atom":"a0","author":"init","version":0},{"n":104,"text":"\t\t\tdescription: \"a mod\",","atom":"a0","author":"init","version":0},{"n":105,"text":"\t\t});","atom":"a0","author":"init","version":0},{"n":106,"text":"\t\tassert.equal(","atom":"a0","author":"init","version":0},{"n":107,"text":"\t\t\tread(target, \"hooks/stamp.ts\"),","atom":"a0","author":"init","version":0},{"n":108,"text":"\t\t\t\"// Which mod this is.\\nexport const STAMP: string | undefined = '0.1.0+702c616'\\n\",","atom":"a0","author":"init","version":0},{"n":109,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":110,"text":"\t\tassert.equal(read(target, \"src/core.ts\"), \"export const core = 1\\n\");","atom":"a0","author":"init","version":0},{"n":111,"text":"\t\tassert.deepEqual(tree(target), [\".avcs-install.json\", ...FILES].sort());","atom":"a0","author":"init","version":0},{"n":112,"text":"\t\tassert.deepEqual(","atom":"a0","author":"init","version":0},{"n":113,"text":"\t\t\t{ ...record(target), at: undefined, from: undefined },","atom":"a0","author":"init","version":0},{"n":114,"text":"\t\t\t{ mod: \"avcs\", version: \"0.1.0+702c616\", files: FILES, at: undefined, from: undefined },","atom":"a0","author":"init","version":0},{"n":115,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":116,"text":"\t});","atom":"a0","author":"init","version":0},{"n":117,"text":"","atom":"a0","author":"init","version":0},{"n":118,"text":"\tit(\"stamps the command that runs this client's abso hook, where stamp.ts has a HOOK_COMMAND line\", () => {","atom":"a2860","author":"pinch","version":293},{"n":119,"text":"\t\tconst spec = source({","atom":"a2860","author":"pinch","version":293},{"n":120,"text":"\t\t\t\"hooks/stamp.ts\":","atom":"a2860","author":"pinch","version":293},{"n":121,"text":"\t\t\t\t\"export const STAMP: string | undefined = undefined\\nexport const HOOK_COMMAND: readonly string[] | undefined = undefined\\n\",","atom":"a2860","author":"pinch","version":293},{"n":122,"text":"\t\t});","atom":"a2860","author":"pinch","version":293},{"n":123,"text":"\t\tconst target = join(temp(), \"avcs\");","atom":"a2860","author":"pinch","version":293},{"n":124,"text":"\t\tinstallMod(spec, {","atom":"a2871","author":"pinch","version":293},{"n":125,"text":"\t\t\ttarget,","atom":"a2871","author":"pinch","version":293},{"n":126,"text":"\t\t\tcheck: pass,","atom":"a2871","author":"pinch","version":293},{"n":127,"text":"\t\t\tcommit: \"702c616\",","atom":"a2871","author":"pinch","version":293},{"n":128,"text":"\t\t\thookCommand: [\"C:\\\\node.exe\", \"C:\\\\abso\\\\client\\\\abso.ts\", \"hook\"],","atom":"a2871","author":"pinch","version":293},{"n":129,"text":"\t\t});","atom":"a2871","author":"pinch","version":293},{"n":130,"text":"\t\tassert.equal(","atom":"a2860","author":"pinch","version":293},{"n":131,"text":"\t\t\tread(target, \"hooks/stamp.ts\"),","atom":"a2860","author":"pinch","version":293},{"n":132,"text":"\t\t\t\"export const STAMP: string | undefined = '0.1.0+702c616'\\n\" +","atom":"a2860","author":"pinch","version":293},{"n":133,"text":"\t\t\t\t'export const HOOK_COMMAND: readonly string[] | undefined = [\"C:\\\\\\\\node.exe\",\"C:\\\\\\\\abso\\\\\\\\client\\\\\\\\abso.ts\",\"hook\"]\\n',","atom":"a2860","author":"pinch","version":293},{"n":134,"text":"\t\t);","atom":"a2860","author":"pinch","version":293},{"n":135,"text":"\t\t// By default, this checkout's own: the node running it and client/abso.ts.","atom":"a2860","author":"pinch","version":293},{"n":136,"text":"\t\tassert.deepEqual(hookCommand().slice(0, 1), [process.execPath]);","atom":"a2860","author":"pinch","version":293},{"n":137,"text":"\t\tassert.match(hookCommand()[1]!, /client[\\\\/]abso\\.ts$/);","atom":"a2860","author":"pinch","version":293},{"n":138,"text":"\t});","atom":"a2860","author":"pinch","version":293},{"n":139,"text":"","atom":"a2860","author":"pinch","version":293},{"n":140,"text":"\tit(\"moves the files in by rename, what the hook imports first and plugin.json last\", () => {","atom":"a0","author":"init","version":0},{"n":141,"text":"\t\tconst spec = source();","atom":"a0","author":"init","version":0},{"n":142,"text":"\t\tconst target = join(temp(), \"avcs\");","atom":"a0","author":"init","version":0},{"n":143,"text":"\t\tinstallMod(spec, { target, check: pass, commit: \"aaaaaaa\" });","atom":"a0","author":"init","version":0},{"n":144,"text":"\t\twrite(spec.from, \"src/core.ts\", \"export const core = 2\\n\");","atom":"a0","author":"init","version":0},{"n":145,"text":"\t\tconst order: string[] = [];","atom":"a0","author":"init","version":0},{"n":146,"text":"\t\tinstallMod(spec, {","atom":"a0","author":"init","version":0},{"n":147,"text":"\t\t\ttarget,","atom":"a0","author":"init","version":0},{"n":148,"text":"\t\t\tcheck: pass,","atom":"a0","author":"init","version":0},{"n":149,"text":"\t\t\tcommit: \"bbbbbbb\",","atom":"a0","author":"init","version":0},{"n":150,"text":"\t\t\trename: (from, to) => {","atom":"a0","author":"init","version":0},{"n":151,"text":"\t\t\t\tassert.ok(from.endsWith(\".next\"));","atom":"a0","author":"init","version":0},{"n":152,"text":"\t\t\t\torder.push(relative(target, to).replace(/\\\\/g, \"/\"));","atom":"a0","author":"init","version":0},{"n":153,"text":"\t\t\t\trenameSync(from, to);","atom":"a0","author":"init","version":0},{"n":154,"text":"\t\t\t},","atom":"a0","author":"init","version":0},{"n":155,"text":"\t\t});","atom":"a0","author":"init","version":0},{"n":156,"text":"\t\tassert.deepEqual(order, FILES);","atom":"a0","author":"init","version":0},{"n":157,"text":"\t});","atom":"a0","author":"init","version":0},{"n":158,"text":"","atom":"a0","author":"init","version":0},{"n":159,"text":"\tit(\"checks the staged copy, stamped, and when the check fails changes nothing\", () => {","atom":"a0","author":"init","version":0},{"n":160,"text":"\t\tconst spec = source();","atom":"a0","author":"init","version":0},{"n":161,"text":"\t\tconst target = join(temp(), \"avcs\");","atom":"a0","author":"init","version":0},{"n":162,"text":"\t\tinstallMod(spec, { target, check: pass, commit: \"aaaaaaa\" });","atom":"a0","author":"init","version":0},{"n":163,"text":"\t\tconst before = contents(target);","atom":"a0","author":"init","version":0},{"n":164,"text":"\t\twrite(spec.from, \"src/core.ts\", \"export const core = 2\\n\");","atom":"a0","author":"init","version":0},{"n":165,"text":"\t\tlet staged = \"\";","atom":"a0","author":"init","version":0},{"n":166,"text":"\t\tconst failing = (dir: string) => {","atom":"a0","author":"init","version":0},{"n":167,"text":"\t\t\tstaged = read(dir, \"hooks/stamp.ts\") + read(dir, \"src/core.ts\");","atom":"a0","author":"init","version":0},{"n":168,"text":"\t\t\treturn \"2 tests failed\";","atom":"a0","author":"init","version":0},{"n":169,"text":"\t\t};","atom":"a0","author":"init","version":0},{"n":170,"text":"\t\tassert.throws(","atom":"a0","author":"init","version":0},{"n":171,"text":"\t\t\t() => installMod(spec, { target, check: failing, commit: \"bbbbbbb\" }),","atom":"a0","author":"init","version":0},{"n":172,"text":"\t\t\t/failed its check, so nothing was changed:\\n2 tests failed/,","atom":"a0","author":"init","version":0},{"n":173,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":174,"text":"\t\tassert.match(staged, /'0\\.1\\.0\\+bbbbbbb'[\\s\\S]*core = 2/);","atom":"a0","author":"init","version":0},{"n":175,"text":"\t\tassert.deepEqual(contents(target), before);","atom":"a0","author":"init","version":0},{"n":176,"text":"\t});","atom":"a0","author":"init","version":0},{"n":177,"text":"","atom":"a0","author":"init","version":0},{"n":178,"text":"\tit(\"leaves no folder behind when a first install fails its check\", () => {","atom":"a0","author":"init","version":0},{"n":179,"text":"\t\tconst target = join(temp(), \"avcs\");","atom":"a0","author":"init","version":0},{"n":180,"text":"\t\tassert.throws(() => installMod(source(), { target, check: () => \"no\", commit: \"aaaaaaa\" }), /nothing was changed/);","atom":"a0","author":"init","version":0},{"n":181,"text":"\t\tassert.equal(existsSync(target), false);","atom":"a0","author":"init","version":0},{"n":182,"text":"\t});","atom":"a0","author":"init","version":0},{"n":183,"text":"","atom":"a0","author":"init","version":0},{"n":184,"text":"\tit(\"changes nothing, and checks nothing, when the same files are installed again\", () => {","atom":"a0","author":"init","version":0},{"n":185,"text":"\t\tconst spec = source();","atom":"a0","author":"init","version":0},{"n":186,"text":"\t\tconst target = join(temp(), \"avcs\");","atom":"a0","author":"init","version":0},{"n":187,"text":"\t\tinstallMod(spec, { target, check: pass, commit: \"aaaaaaa\" });","atom":"a0","author":"init","version":0},{"n":188,"text":"\t\tconst mtime = statSync(at(target, \"hooks/register.ts\")).mtimeMs;","atom":"a0","author":"init","version":0},{"n":189,"text":"\t\tlet checked = false;","atom":"a0","author":"init","version":0},{"n":190,"text":"\t\tconst again = installMod(spec, { target, check: () => ((checked = true), undefined), commit: \"aaaaaaa\" });","atom":"a0","author":"init","version":0},{"n":191,"text":"\t\tassert.equal(again.changed, false);","atom":"a0","author":"init","version":0},{"n":192,"text":"\t\tassert.equal(checked, false);","atom":"a0","author":"init","version":0},{"n":193,"text":"\t\tassert.equal(statSync(at(target, \"hooks/register.ts\")).mtimeMs, mtime);","atom":"a0","author":"init","version":0},{"n":194,"text":"\t});","atom":"a0","author":"init","version":0},{"n":195,"text":"","atom":"a0","author":"init","version":0},{"n":196,"text":"\tit(\"keeps what it replaces; a rollback puts it back, and a second rollback undoes the first\", () => {","atom":"a0","author":"init","version":0},{"n":197,"text":"\t\tconst spec = source();","atom":"a0","author":"init","version":0},{"n":198,"text":"\t\tconst target = join(temp(), \"avcs\");","atom":"a0","author":"init","version":0},{"n":199,"text":"\t\tinstallMod(spec, { target, check: pass, commit: \"aaaaaaa\" });","atom":"a0","author":"init","version":0},{"n":200,"text":"\t\twrite(spec.from, \"src/core.ts\", \"export const core = 2\\n\");","atom":"a0","author":"init","version":0},{"n":201,"text":"\t\tconst r = installMod(spec, { target, check: pass, commit: \"bbbbbbb\" });","atom":"a0","author":"init","version":0},{"n":202,"text":"\t\tassert.equal(r.previous, \"0.1.0+aaaaaaa\");","atom":"a0","author":"init","version":0},{"n":203,"text":"\t\tassert.equal(read(target, \"src/core.ts.prev\"), \"export const core = 1\\n\");","atom":"a0","author":"init","version":0},{"n":204,"text":"","atom":"a0","author":"init","version":0},{"n":205,"text":"\t\tconst back = rollbackMod(spec, { target });","atom":"a0","author":"init","version":0},{"n":206,"text":"\t\tassert.deepEqual(back, { changed: true, version: \"0.1.0+aaaaaaa\", previous: \"0.1.0+bbbbbbb\", files: 5 });","atom":"a0","author":"init","version":0},{"n":207,"text":"\t\tassert.equal(read(target, \"src/core.ts\"), \"export const core = 1\\n\");","atom":"a0","author":"init","version":0},{"n":208,"text":"\t\tassert.equal(JSON.parse(read(target, \".claude-plugin/plugin.json\")).version, \"0.1.0+aaaaaaa\");","atom":"a0","author":"init","version":0},{"n":209,"text":"\t\tassert.match(read(target, \"hooks/stamp.ts\"), /'0\\.1\\.0\\+aaaaaaa'/);","atom":"a0","author":"init","version":0},{"n":210,"text":"","atom":"a0","author":"init","version":0},{"n":211,"text":"\t\tconst forward = rollbackMod(spec, { target });","atom":"a0","author":"init","version":0},{"n":212,"text":"\t\tassert.equal(forward.version, \"0.1.0+bbbbbbb\");","atom":"a0","author":"init","version":0},{"n":213,"text":"\t\tassert.equal(read(target, \"src/core.ts\"), \"export const core = 2\\n\");","atom":"a0","author":"init","version":0},{"n":214,"text":"\t\tassert.equal(record(target).prev?.version, \"0.1.0+aaaaaaa\");","atom":"a0","author":"init","version":0},{"n":215,"text":"\t});","atom":"a0","author":"init","version":0},{"n":216,"text":"","atom":"a0","author":"init","version":0},{"n":217,"text":"\tit(\"puts back the files already moved when a rename fails midway\", () => {","atom":"a0","author":"init","version":0},{"n":218,"text":"\t\tconst spec = source();","atom":"a0","author":"init","version":0},{"n":219,"text":"\t\tconst target = join(temp(), \"avcs\");","atom":"a0","author":"init","version":0},{"n":220,"text":"\t\tinstallMod(spec, { target, check: pass, commit: \"aaaaaaa\" });","atom":"a0","author":"init","version":0},{"n":221,"text":"\t\tconst before = Object.fromEntries(FILES.map((rel) => [rel, read(target, rel)]));","atom":"a0","author":"init","version":0},{"n":222,"text":"\t\twrite(spec.from, \"src/core.ts\", \"export const core = 2\\n\");","atom":"a0","author":"init","version":0},{"n":223,"text":"\t\twrite(spec.from, \"hooks/register.ts\", \"import { core } from '../src/core.ts'\\nexport const two = core\\n\");","atom":"a0","author":"init","version":0},{"n":224,"text":"\t\tlet n = 0;","atom":"a0","author":"init","version":0},{"n":225,"text":"\t\tconst flaky = (from: string, to: string) => {","atom":"a0","author":"init","version":0},{"n":226,"text":"\t\t\tif (++n === 3) throw Object.assign(new Error(\"EPERM: operation not permitted, rename\"), { code: \"EPERM\" });","atom":"a0","author":"init","version":0},{"n":227,"text":"\t\t\trenameSync(from, to);","atom":"a0","author":"init","version":0},{"n":228,"text":"\t\t};","atom":"a0","author":"init","version":0},{"n":229,"text":"\t\tassert.throws(() => installMod(spec, { target, check: pass, commit: \"bbbbbbb\", rename: flaky }), /EPERM/);","atom":"a0","author":"init","version":0},{"n":230,"text":"\t\tassert.deepEqual(Object.fromEntries(FILES.map((rel) => [rel, read(target, rel)])), before);","atom":"a0","author":"init","version":0},{"n":231,"text":"\t\tassert.deepEqual(","atom":"a0","author":"init","version":0},{"n":232,"text":"\t\t\ttree(target).filter((f) => f.endsWith(\".next\")),","atom":"a0","author":"init","version":0},{"n":233,"text":"\t\t\t[],","atom":"a0","author":"init","version":0},{"n":234,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":235,"text":"\t\tassert.equal(record(target).version, \"0.1.0+aaaaaaa\");","atom":"a0","author":"init","version":0},{"n":236,"text":"\t\tassert.equal(record(target).moving, undefined);","atom":"a0","author":"init","version":0},{"n":237,"text":"\t});","atom":"a0","author":"init","version":0},{"n":238,"text":"","atom":"a0","author":"init","version":0},{"n":239,"text":"\tit(\"keeps a mod installed before .avcs-install.json for a rollback\", () => {","atom":"a0","author":"init","version":0},{"n":240,"text":"\t\tconst spec = source();","atom":"a0","author":"init","version":0},{"n":241,"text":"\t\tconst target = join(temp(), \"avcs\");","atom":"a0","author":"init","version":0},{"n":242,"text":"\t\t// The old installer copied four files and wrote nothing else.","atom":"a0","author":"init","version":0},{"n":243,"text":"\t\tfor (const rel of FILES.filter((f) => f !== \"hooks/stamp.ts\")) {","atom":"a0","author":"init","version":0},{"n":244,"text":"\t\t\tmkdirSync(dirname(at(target, rel)), { recursive: true });","atom":"a0","author":"init","version":0},{"n":245,"text":"\t\t\tcopyFileSync(at(spec.from, rel), at(target, rel));","atom":"a0","author":"init","version":0},{"n":246,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":247,"text":"\t\tconst r = installMod(spec, { target, check: pass, commit: \"bbbbbbb\" });","atom":"a0","author":"init","version":0},{"n":248,"text":"\t\tassert.equal(r.previous, \"0.1.0\");","atom":"a0","author":"init","version":0},{"n":249,"text":"\t\tconst back = rollbackMod(spec, { target });","atom":"a0","author":"init","version":0},{"n":250,"text":"\t\tassert.equal(back.version, \"0.1.0\");","atom":"a0","author":"init","version":0},{"n":251,"text":"\t\tassert.equal(JSON.parse(read(target, \".claude-plugin/plugin.json\")).version, \"0.1.0\");","atom":"a0","author":"init","version":0},{"n":252,"text":"\t\tassert.equal(existsSync(at(target, \"hooks/stamp.ts\")), false);","atom":"a0","author":"init","version":0},{"n":253,"text":"\t});","atom":"a0","author":"init","version":0},{"n":254,"text":"","atom":"a0","author":"init","version":0},{"n":255,"text":"\tit(\"after an install that stopped midway, keeps the last whole install for a rollback\", () => {","atom":"a0","author":"init","version":0},{"n":256,"text":"\t\tconst spec = source();","atom":"a0","author":"init","version":0},{"n":257,"text":"\t\tconst target = join(temp(), \"avcs\");","atom":"a0","author":"init","version":0},{"n":258,"text":"\t\tinstallMod(spec, { target, check: pass, commit: \"aaaaaaa\" });","atom":"a0","author":"init","version":0},{"n":259,"text":"\t\twrite(spec.from, \"src/core.ts\", \"export const core = 2\\n\");","atom":"a0","author":"init","version":0},{"n":260,"text":"\t\tinstallMod(spec, { target, check: pass, commit: \"bbbbbbb\" });","atom":"a0","author":"init","version":0},{"n":261,"text":"\t\t// An install of ccccccc that died after its first rename: core.ts is new, the rest is bbbbbbb.","atom":"a0","author":"init","version":0},{"n":262,"text":"\t\tfor (const rel of FILES) copyFileSync(at(target, rel), at(target, `${rel}.prev`));","atom":"a0","author":"init","version":0},{"n":263,"text":"\t\twriteFileSync(","atom":"a0","author":"init","version":0},{"n":264,"text":"\t\t\tat(target, \".avcs-install.json\"),","atom":"a0","author":"init","version":0},{"n":265,"text":"\t\t\tJSON.stringify({ ...record(target), prev: { ...record(target), prev: undefined }, moving: \"0.1.0+ccccccc\" }),","atom":"a0","author":"init","version":0},{"n":266,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":267,"text":"\t\twrite(target, \"src/core.ts\", \"export const core = 3\\n\");","atom":"a0","author":"init","version":0},{"n":268,"text":"","atom":"a0","author":"init","version":0},{"n":269,"text":"\t\twrite(spec.from, \"src/core.ts\", \"export const core = 4\\n\");","atom":"a0","author":"init","version":0},{"n":270,"text":"\t\tconst r = installMod(spec, { target, check: pass, commit: \"ddddddd\" });","atom":"a0","author":"init","version":0},{"n":271,"text":"\t\tassert.equal(r.previous, \"0.1.0+bbbbbbb\");","atom":"a0","author":"init","version":0},{"n":272,"text":"\t\tassert.equal(read(target, \"src/core.ts.prev\"), \"export const core = 2\\n\");","atom":"a0","author":"init","version":0},{"n":273,"text":"\t\trollbackMod(spec, { target });","atom":"a0","author":"init","version":0},{"n":274,"text":"\t\tassert.equal(read(target, \"src/core.ts\"), \"export const core = 2\\n\");","atom":"a0","author":"init","version":0},{"n":275,"text":"\t});","atom":"a0","author":"init","version":0},{"n":276,"text":"","atom":"a0","author":"init","version":0},{"n":277,"text":"\tit(\"refuses while another install holds the lock, and takes over a lock left by one that died\", () => {","atom":"a0","author":"init","version":0},{"n":278,"text":"\t\tconst spec = source();","atom":"a0","author":"init","version":0},{"n":279,"text":"\t\tconst target = join(temp(), \"avcs\");","atom":"a0","author":"init","version":0},{"n":280,"text":"\t\tinstallMod(spec, { target, check: pass, commit: \"aaaaaaa\" });","atom":"a0","author":"init","version":0},{"n":281,"text":"\t\twrite(spec.from, \"src/core.ts\", \"export const core = 2\\n\");","atom":"a0","author":"init","version":0},{"n":282,"text":"\t\tconst lock = at(target, \".avcs-install.lock\");","atom":"a0","author":"init","version":0},{"n":283,"text":"\t\twriteFileSync(lock, \"\");","atom":"a0","author":"init","version":0},{"n":284,"text":"\t\tassert.throws(() => installMod(spec, { target, check: pass, commit: \"bbbbbbb\" }), /another install is running/);","atom":"a0","author":"init","version":0},{"n":285,"text":"\t\tassert.throws(() => rollbackMod(spec, { target }), /another install is running/);","atom":"a0","author":"init","version":0},{"n":286,"text":"\t\tconst old = new Date(Date.now() - 11 * 60_000);","atom":"a0","author":"init","version":0},{"n":287,"text":"\t\tutimesSync(lock, old, old);","atom":"a0","author":"init","version":0},{"n":288,"text":"\t\tassert.equal(installMod(spec, { target, check: pass, commit: \"bbbbbbb\" }).changed, true);","atom":"a0","author":"init","version":0},{"n":289,"text":"\t\tassert.equal(existsSync(lock), false);","atom":"a0","author":"init","version":0},{"n":290,"text":"\t});","atom":"a0","author":"init","version":0},{"n":291,"text":"","atom":"a0","author":"init","version":0},{"n":292,"text":"\tit(\"says so when there is nothing to roll back to\", () => {","atom":"a0","author":"init","version":0},{"n":293,"text":"\t\tconst spec = source();","atom":"a0","author":"init","version":0},{"n":294,"text":"\t\tconst target = join(temp(), \"avcs\");","atom":"a0","author":"init","version":0},{"n":295,"text":"\t\tassert.throws(() => rollbackMod(spec, { target }), /nothing is installed/);","atom":"a0","author":"init","version":0},{"n":296,"text":"\t\tinstallMod(spec, { target, check: pass, commit: \"aaaaaaa\" });","atom":"a0","author":"init","version":0},{"n":297,"text":"\t\tassert.throws(() => rollbackMod(spec, { target }), /no earlier install is kept/);","atom":"a0","author":"init","version":0},{"n":298,"text":"\t});","atom":"a0","author":"init","version":0},{"n":299,"text":"","atom":"a0","author":"init","version":0},{"n":300,"text":"\tit(\"stamps plugin.json's version plus the last commit that changed the mod's files, and .dirty when they differ from it\", {","atom":"a0","author":"init","version":0},{"n":301,"text":"\t\tskip: !hasGit,","atom":"a0","author":"init","version":0},{"n":302,"text":"\t}, () => {","atom":"a0","author":"init","version":0},{"n":303,"text":"\t\tconst spec = source();","atom":"a0","author":"init","version":0},{"n":304,"text":"\t\tconst git = (...args: string[]) =>","atom":"a0","author":"init","version":0},{"n":305,"text":"\t\t\tspawnSync(\"git\", [\"-c\", \"user.name=t\", \"-c\", \"user.email=t@t\", \"-C\", spec.from, ...args], {","atom":"a0","author":"init","version":0},{"n":306,"text":"\t\t\t\tencoding: \"utf8\",","atom":"a0","author":"init","version":0},{"n":307,"text":"\t\t\t}).stdout.trim();","atom":"a0","author":"init","version":0},{"n":308,"text":"\t\tgit(\"init\", \"-q\");","atom":"a0","author":"init","version":0},{"n":309,"text":"\t\tgit(\"add\", \".\");","atom":"a0","author":"init","version":0},{"n":310,"text":"\t\tgit(\"commit\", \"-q\", \"-m\", \"mod\");","atom":"a0","author":"init","version":0},{"n":311,"text":"\t\tconst mod = git(\"rev-parse\", \"--short=7\", \"HEAD\");","atom":"a0","author":"init","version":0},{"n":312,"text":"\t\tassert.equal(versionFor(spec), `0.1.0+${mod}`);","atom":"a0","author":"init","version":0},{"n":313,"text":"\t\t// A commit that changes none of the mod's files leaves the stamp, so a reinstall changes nothing.","atom":"a0","author":"init","version":0},{"n":314,"text":"\t\twrite(spec.from, \"README.md\", \"not part of the mod\\n\");","atom":"a0","author":"init","version":0},{"n":315,"text":"\t\tassert.equal(versionFor(spec), `0.1.0+${mod}`);","atom":"a0","author":"init","version":0},{"n":316,"text":"\t\tgit(\"add\", \".\");","atom":"a0","author":"init","version":0},{"n":317,"text":"\t\tgit(\"commit\", \"-q\", \"-m\", \"docs\");","atom":"a0","author":"init","version":0},{"n":318,"text":"\t\tassert.equal(versionFor(spec), `0.1.0+${mod}`);","atom":"a0","author":"init","version":0},{"n":319,"text":"\t\tconst target = join(temp(), \"avcs\");","atom":"a0","author":"init","version":0},{"n":320,"text":"\t\tinstallMod(spec, { target, check: pass });","atom":"a0","author":"init","version":0},{"n":321,"text":"\t\tassert.equal(installMod(spec, { target, check: pass }).changed, false);","atom":"a0","author":"init","version":0},{"n":322,"text":"\t\twrite(spec.from, \"src/core.ts\", \"export const core = 2\\n\");","atom":"a0","author":"init","version":0},{"n":323,"text":"\t\tassert.equal(versionFor(spec), `0.1.0+${mod}.dirty`);","atom":"a0","author":"init","version":0},{"n":324,"text":"\t\tgit(\"commit\", \"-q\", \"-am\", \"core\");","atom":"a0","author":"init","version":0},{"n":325,"text":"\t\tassert.equal(versionFor(spec), `0.1.0+${git(\"rev-parse\", \"--short=7\", \"HEAD\")}`);","atom":"a0","author":"init","version":0},{"n":326,"text":"\t\t// Outside a git checkout there is no commit to add.","atom":"a0","author":"init","version":0},{"n":327,"text":"\t\tassert.equal(versionFor(spec, null), \"0.1.0\");","atom":"a0","author":"init","version":0},{"n":328,"text":"\t});","atom":"a0","author":"init","version":0},{"n":329,"text":"","atom":"a422","author":"speed","version":43},{"n":330,"text":"\tit(\"keeps the mod's commit between runs, and asks git again when the checkout or a file moves, or a file is too new to trust\", {","atom":"a422","author":"speed","version":43},{"n":331,"text":"\t\tskip: !hasGit,","atom":"a422","author":"speed","version":43},{"n":332,"text":"\t}, () => {","atom":"a422","author":"speed","version":43},{"n":333,"text":"\t\tconst spec = source();","atom":"a422","author":"speed","version":43},{"n":334,"text":"\t\tconst home = temp();","atom":"a422","author":"speed","version":43},{"n":335,"text":"\t\tconst kept = join(home, \".abso\", \"mod-commits.json\");","atom":"a422","author":"speed","version":43},{"n":336,"text":"\t\tconst git = (...args: string[]) =>","atom":"a422","author":"speed","version":43},{"n":337,"text":"\t\t\tspawnSync(\"git\", [\"-c\", \"user.name=t\", \"-c\", \"user.email=t@t\", \"-C\", spec.from, ...args], {","atom":"a422","author":"speed","version":43},{"n":338,"text":"\t\t\t\tencoding: \"utf8\",","atom":"a422","author":"speed","version":43},{"n":339,"text":"\t\t\t}).stdout.trim();","atom":"a422","author":"speed","version":43},{"n":340,"text":"\t\t// Every mod file minutes old, so a kept answer can be trusted. Each call sets a whole minute earlier","atom":"a443","author":"speed","version":45},{"n":341,"text":"\t\t// than the last: git's own index compares times by the second, and a same-size edit given the time","atom":"a443","author":"speed","version":45},{"n":342,"text":"\t\t// git last saw would look unchanged to git itself.","atom":"a443","author":"speed","version":45},{"n":343,"text":"\t\tlet minutes = 0;","atom":"a443","author":"speed","version":45},{"n":344,"text":"\t\tconst age = () => {","atom":"a422","author":"speed","version":43},{"n":345,"text":"\t\t\tminutes += 1;","atom":"a443","author":"speed","version":45},{"n":346,"text":"\t\t\tconst old = new Date(Date.now() - minutes * 60_000);","atom":"a443","author":"speed","version":45},{"n":347,"text":"\t\t\tfor (const rel of FILES) utimesSync(at(spec.from, rel), old, old);","atom":"a422","author":"speed","version":43},{"n":348,"text":"\t\t};","atom":"a422","author":"speed","version":43},{"n":349,"text":"\t\t// Swaps every kept answer for a made-up one: what comes back says whether git ran.","atom":"a422","author":"speed","version":43},{"n":350,"text":"\t\tconst plant = () => {","atom":"a422","author":"speed","version":43},{"n":351,"text":"\t\t\tconst file = JSON.parse(readFileSync(kept, \"utf8\"));","atom":"a422","author":"speed","version":43},{"n":352,"text":"\t\t\tfor (const k of Object.keys(file.mods)) file.mods[k].commit = \"fffffff\";","atom":"a422","author":"speed","version":43},{"n":353,"text":"\t\t\twriteFileSync(kept, JSON.stringify(file));","atom":"a422","author":"speed","version":43},{"n":354,"text":"\t\t};","atom":"a422","author":"speed","version":43},{"n":355,"text":"\t\t// Not a git checkout yet: no commit, and nothing kept.","atom":"a425","author":"speed","version":43},{"n":356,"text":"\t\tassert.equal(keptModCommit(spec, home), null);","atom":"a425","author":"speed","version":43},{"n":357,"text":"\t\tassert.equal(existsSync(kept), false);","atom":"a425","author":"speed","version":43},{"n":358,"text":"\t\tgit(\"init\", \"-q\");","atom":"a422","author":"speed","version":43},{"n":359,"text":"\t\tgit(\"add\", \".\");","atom":"a422","author":"speed","version":43},{"n":360,"text":"\t\tgit(\"commit\", \"-q\", \"-m\", \"mod\");","atom":"a422","author":"speed","version":43},{"n":361,"text":"\t\tconst mod = git(\"rev-parse\", \"--short=7\", \"HEAD\");","atom":"a422","author":"speed","version":43},{"n":362,"text":"\t\tage();","atom":"a422","author":"speed","version":43},{"n":363,"text":"\t\tassert.equal(keptModCommit(spec, home), mod);","atom":"a422","author":"speed","version":43},{"n":364,"text":"\t\tplant();","atom":"a422","author":"speed","version":43},{"n":365,"text":"\t\tassert.equal(keptModCommit(spec, home), \"fffffff\", \"a kept answer is used while nothing moved\");","atom":"a422","author":"speed","version":43},{"n":366,"text":"","atom":"a422","author":"speed","version":43},{"n":367,"text":"\t\t// A file changed in the same moment the answer was kept is never trusted, even when its size and time match.","atom":"a422","author":"speed","version":43},{"n":368,"text":"\t\t// A time a minute ahead stays too new however long the run takes.","atom":"a435","author":"speed","version":44},{"n":369,"text":"\t\twrite(spec.from, \"src/core.ts\", \"export const core = 2\\n\");","atom":"a422","author":"speed","version":43},{"n":370,"text":"\t\tconst soon = new Date(Date.now() + 60_000);","atom":"a435","author":"speed","version":44},{"n":371,"text":"\t\tutimesSync(at(spec.from, \"src/core.ts\"), soon, soon);","atom":"a435","author":"speed","version":44},{"n":372,"text":"\t\tassert.equal(keptModCommit(spec, home), `${mod}.dirty`);","atom":"a422","author":"speed","version":43},{"n":373,"text":"\t\tplant();","atom":"a422","author":"speed","version":43},{"n":374,"text":"\t\tassert.equal(keptModCommit(spec, home), `${mod}.dirty`, \"too new to trust: git runs again\");","atom":"a422","author":"speed","version":43},{"n":375,"text":"","atom":"a422","author":"speed","version":43},{"n":376,"text":"\t\t// An edit that keeps the size, with its time set back a minute, still isn't the time that was kept.","atom":"a423","author":"speed","version":43},{"n":377,"text":"\t\tage();","atom":"a422","author":"speed","version":43},{"n":378,"text":"\t\tassert.equal(keptModCommit(spec, home), `${mod}.dirty`);","atom":"a422","author":"speed","version":43},{"n":379,"text":"\t\tplant();","atom":"a422","author":"speed","version":43},{"n":380,"text":"\t\twrite(spec.from, \"src/core.ts\", \"export const core = 3\\n\");","atom":"a422","author":"speed","version":43},{"n":381,"text":"\t\tage();","atom":"a422","author":"speed","version":43},{"n":382,"text":"\t\tassert.equal(keptModCommit(spec, home), `${mod}.dirty`);","atom":"a422","author":"speed","version":43},{"n":383,"text":"","atom":"a422","author":"speed","version":43},{"n":384,"text":"\t\t// A commit moves the checkout.","atom":"a422","author":"speed","version":43},{"n":385,"text":"\t\tgit(\"commit\", \"-q\", \"-am\", \"core\");","atom":"a422","author":"speed","version":43},{"n":386,"text":"\t\tage();","atom":"a422","author":"speed","version":43},{"n":387,"text":"\t\tconst next = git(\"rev-parse\", \"--short=7\", \"HEAD\");","atom":"a422","author":"speed","version":43},{"n":388,"text":"\t\tassert.equal(keptModCommit(spec, home), next);","atom":"a422","author":"speed","version":43},{"n":389,"text":"\t\tplant();","atom":"a422","author":"speed","version":43},{"n":390,"text":"\t\tgit(\"commit\", \"-q\", \"--allow-empty\", \"-m\", \"empty\");","atom":"a422","author":"speed","version":43},{"n":391,"text":"\t\tassert.equal(keptModCommit(spec, home), next, \"a new commit asks git again\");","atom":"a422","author":"speed","version":43},{"n":392,"text":"","atom":"a422","author":"speed","version":43},{"n":393,"text":"\t\t// A file it can't read, or doesn't know the format of, is the same as none.","atom":"a422","author":"speed","version":43},{"n":394,"text":"\t\tplant();","atom":"a422","author":"speed","version":43},{"n":395,"text":"\t\twriteFileSync(kept, JSON.stringify({ format: 2, mods: JSON.parse(readFileSync(kept, \"utf8\")).mods }));","atom":"a422","author":"speed","version":43},{"n":396,"text":"\t\tassert.equal(keptModCommit(spec, home), next);","atom":"a422","author":"speed","version":43},{"n":397,"text":"\t\twriteFileSync(kept, \"not json\");","atom":"a422","author":"speed","version":43},{"n":398,"text":"\t\tassert.equal(keptModCommit(spec, home), next);","atom":"a422","author":"speed","version":43},{"n":399,"text":"\t});","atom":"a422","author":"speed","version":43},{"n":400,"text":"});","atom":"a0","author":"init","version":0},{"n":401,"text":"","atom":"a0","author":"init","version":0},{"n":402,"text":"describe(\"which client this is\", () => {","atom":"a0","author":"init","version":0},{"n":403,"text":"\tconst git = (cwd: string, ...args: string[]) =>","atom":"a0","author":"init","version":0},{"n":404,"text":"\t\tspawnSync(","atom":"a0","author":"init","version":0},{"n":405,"text":"\t\t\t\"git\",","atom":"a0","author":"init","version":0},{"n":406,"text":"\t\t\t[\"-c\", \"user.name=t\", \"-c\", \"user.email=t@t\", \"-c\", \"init.defaultBranch=main\", \"-C\", cwd, ...args],","atom":"a0","author":"init","version":0},{"n":407,"text":"\t\t\t{ encoding: \"utf8\" },","atom":"a0","author":"init","version":0},{"n":408,"text":"\t\t).stdout.trim();","atom":"a0","author":"init","version":0},{"n":409,"text":"","atom":"a0","author":"init","version":0},{"n":410,"text":"\tit(\"reads the commit from .git as git does: a branch, a packed branch, a detached head, a worktree\", {","atom":"a0","author":"init","version":0},{"n":411,"text":"\t\tskip: !hasGit,","atom":"a0","author":"init","version":0},{"n":412,"text":"\t}, () => {","atom":"a0","author":"init","version":0},{"n":413,"text":"\t\tconst repo = temp();","atom":"a0","author":"init","version":0},{"n":414,"text":"\t\tgit(repo, \"init\", \"-q\");","atom":"a0","author":"init","version":0},{"n":415,"text":"\t\twrite(repo, \"a/b/file.txt\", \"one\\n\");","atom":"a0","author":"init","version":0},{"n":416,"text":"\t\tgit(repo, \"add\", \".\");","atom":"a0","author":"init","version":0},{"n":417,"text":"\t\tgit(repo, \"commit\", \"-q\", \"-m\", \"one\");","atom":"a0","author":"init","version":0},{"n":418,"text":"\t\tassert.equal(headCommit(join(repo, \"a\", \"b\")), git(repo, \"rev-parse\", \"--short=7\", \"HEAD\"));","atom":"a0","author":"init","version":0},{"n":419,"text":"\t\twrite(repo, \"a/b/file.txt\", \"two\\n\");","atom":"a0","author":"init","version":0},{"n":420,"text":"\t\tgit(repo, \"commit\", \"-q\", \"-am\", \"two\");","atom":"a0","author":"init","version":0},{"n":421,"text":"\t\tgit(repo, \"pack-refs\", \"--all\");","atom":"a0","author":"init","version":0},{"n":422,"text":"\t\tassert.equal(existsSync(join(repo, \".git\", \"refs\", \"heads\", \"main\")), false);","atom":"a0","author":"init","version":0},{"n":423,"text":"\t\tassert.equal(headCommit(repo), git(repo, \"rev-parse\", \"--short=7\", \"HEAD\"));","atom":"a0","author":"init","version":0},{"n":424,"text":"\t\tconst first = git(repo, \"rev-parse\", \"--short=7\", \"HEAD~1\");","atom":"a0","author":"init","version":0},{"n":425,"text":"\t\tgit(repo, \"checkout\", \"-q\", \"--detach\", \"HEAD~1\");","atom":"a0","author":"init","version":0},{"n":426,"text":"\t\tassert.equal(headCommit(repo), first);","atom":"a0","author":"init","version":0},{"n":427,"text":"\t\tconst wt = join(temp(), \"wt\");","atom":"a0","author":"init","version":0},{"n":428,"text":"\t\tgit(repo, \"worktree\", \"add\", \"-q\", \"-b\", \"side\", wt, \"main\");","atom":"a0","author":"init","version":0},{"n":429,"text":"\t\twrite(wt, \"a/b/file.txt\", \"three\\n\");","atom":"a0","author":"init","version":0},{"n":430,"text":"\t\tgit(wt, \"commit\", \"-q\", \"-am\", \"three\");","atom":"a0","author":"init","version":0},{"n":431,"text":"\t\tassert.equal(headCommit(join(wt, \"a\")), git(wt, \"rev-parse\", \"--short=7\", \"HEAD\"));","atom":"a0","author":"init","version":0},{"n":432,"text":"\t\tassert.notEqual(headCommit(wt), headCommit(repo));","atom":"a0","author":"init","version":0},{"n":433,"text":"\t});","atom":"a0","author":"init","version":0},{"n":434,"text":"","atom":"a0","author":"init","version":0},{"n":435,"text":"\tit(\"has no commit outside a repository\", () => {","atom":"a0","author":"init","version":0},{"n":436,"text":"\t\tassert.equal(headCommit(temp()), undefined);","atom":"a0","author":"init","version":0},{"n":437,"text":"\t});","atom":"a0","author":"init","version":0},{"n":438,"text":"","atom":"a0","author":"init","version":0},{"n":439,"text":"\tit(\"avcs --version names this client's version and the mods installed, and which are from another commit\", async () => {","atom":"a0","author":"init","version":0},{"n":440,"text":"\t\tconst config = temp();","atom":"a0","author":"init","version":0},{"n":441,"text":"\t\tconst spec = source();","atom":"a0","author":"init","version":0},{"n":442,"text":"\t\tinstallMod(spec, {","atom":"a0","author":"init","version":0},{"n":443,"text":"\t\t\ttarget: join(config, \"skills\", \"abso-hooks\"),","atom":"a402","author":"review","version":40},{"n":444,"text":"\t\t\tcheck: pass,","atom":"a0","author":"init","version":0},{"n":445,"text":"\t\t\tcommit: \"aaaaaaa\",","atom":"a0","author":"init","version":0},{"n":446,"text":"\t\t\tnow: new Date(\"2026-10-05T04:30:00Z\"),","atom":"a0","author":"init","version":0},{"n":447,"text":"\t\t});","atom":"a0","author":"init","version":0},{"n":448,"text":"\t\tconst out = await main([\"--version\"], { cwd: config, env: { CLAUDE_CONFIG_DIR: config }, write: () => {} });","atom":"a0","author":"init","version":0},{"n":449,"text":"\t\tconst [client, mod, view] = out.stdout.trimEnd().split(\"\\n\");","atom":"a0","author":"init","version":0},{"n":450,"text":"\t\tassert.equal(out.exit, 0);","atom":"a0","author":"init","version":0},{"n":451,"text":"\t\tassert.equal(client, `abso ${clientVersion()} (${dirname(import.meta.dirname)})`);","atom":"a0","author":"init","version":0},{"n":452,"text":"\t\tassert.match(","atom":"a0","author":"init","version":0},{"n":453,"text":"\t\t\tmod!,","atom":"a0","author":"init","version":0},{"n":454,"text":"\t\t\t/^the abso-hooks mod: 0\\.1\\.0\\+aaaaaaa in .*skills[\\\\/]abso-hooks, installed 2026-10-05 04:30 UTC; this client has 0.2.0(\\+[0-9a-f]{7}(\\.dirty)?)?: /,","atom":"a2780","author":"pinch","version":281},{"n":455,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":456,"text":"\t\tassert.ok(mod!.endsWith(`: ${installerCommand(\"install-mod.ts\")} installs it`), mod);","atom":"a2780","author":"pinch","version":281},{"n":457,"text":"\t\tassert.equal(view, `the abso-view mod: not installed (${installerCommand(\"install-view.ts\")})`);","atom":"a2780","author":"pinch","version":281},{"n":458,"text":"\t\tconst json = JSON.parse(","atom":"a0","author":"init","version":0},{"n":459,"text":"\t\t\t(await main([\"--version\", \"--json\"], { cwd: config, env: { CLAUDE_CONFIG_DIR: config }, write: () => {} }))","atom":"a0","author":"init","version":0},{"n":460,"text":"\t\t\t\t.stdout,","atom":"a0","author":"init","version":0},{"n":461,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":462,"text":"\t\tassert.equal(json.client, clientVersion());","atom":"a0","author":"init","version":0},{"n":463,"text":"\t\tassert.equal(json.mods[0].version, \"0.1.0+aaaaaaa\");","atom":"a0","author":"init","version":0},{"n":464,"text":"\t});","atom":"a0","author":"init","version":0},{"n":465,"text":"","atom":"a0","author":"init","version":0},{"n":466,"text":"\tit(\"moves the old avcs mod folder out of the skills folder, not deleting it, once abso-hooks is in\", () => {","atom":"a402","author":"review","version":40},{"n":467,"text":"\t\tconst config = temp();","atom":"a402","author":"review","version":40},{"n":468,"text":"\t\tconst old = join(config, \"skills\", \"avcs\");","atom":"a402","author":"review","version":40},{"n":469,"text":"\t\twrite(old, \".claude-plugin/plugin.json\", '{\"name\":\"avcs\",\"version\":\"0.1.0\"}');","atom":"a402","author":"review","version":40},{"n":470,"text":"\t\tconst home = temp();","atom":"a402","author":"review","version":40},{"n":471,"text":"\t\tconst was = process.env.USERPROFILE;","atom":"a402","author":"review","version":40},{"n":472,"text":"\t\tconst was2 = process.env.HOME;","atom":"a402","author":"review","version":40},{"n":473,"text":"\t\tprocess.env.USERPROFILE = home;","atom":"a402","author":"review","version":40},{"n":474,"text":"\t\tprocess.env.HOME = home;","atom":"a402","author":"review","version":40},{"n":475,"text":"\t\ttry {","atom":"a402","author":"review","version":40},{"n":476,"text":"\t\t\tconst to = retireOldMod(AVCS_MOD, { CLAUDE_CONFIG_DIR: config });","atom":"a402","author":"review","version":40},{"n":477,"text":"\t\t\tassert.ok(to?.startsWith(join(home, \".abso\", \"retired-mods\")));","atom":"a402","author":"review","version":40},{"n":478,"text":"\t\t\tassert.equal(existsSync(old), false);","atom":"a402","author":"review","version":40},{"n":479,"text":"\t\t\tassert.equal(existsSync(join(to!, \".claude-plugin\", \"plugin.json\")), true);","atom":"a402","author":"review","version":40},{"n":480,"text":"\t\t\tassert.equal(retireOldMod(AVCS_MOD, { CLAUDE_CONFIG_DIR: config }), undefined);","atom":"a402","author":"review","version":40},{"n":481,"text":"\t\t} finally {","atom":"a402","author":"review","version":40},{"n":482,"text":"\t\t\tif (was === undefined) delete process.env.USERPROFILE;","atom":"a402","author":"review","version":40},{"n":483,"text":"\t\t\telse process.env.USERPROFILE = was;","atom":"a402","author":"review","version":40},{"n":484,"text":"\t\t\tif (was2 === undefined) delete process.env.HOME;","atom":"a402","author":"review","version":40},{"n":485,"text":"\t\t\telse process.env.HOME = was2;","atom":"a402","author":"review","version":40},{"n":486,"text":"\t\t}","atom":"a402","author":"review","version":40},{"n":487,"text":"\t});","atom":"a402","author":"review","version":40},{"n":488,"text":"","atom":"a402","author":"review","version":40},{"n":489,"text":"\tit(\"status says when an installed mod is behind this client, where the client knows its commit (abso issue 41)\", () => {","atom":"a0","author":"init","version":0},{"n":490,"text":"\t\tconst config = temp();","atom":"a0","author":"init","version":0},{"n":491,"text":"\t\tconst env = { CLAUDE_CONFIG_DIR: config };","atom":"a0","author":"init","version":0},{"n":492,"text":"\t\tassert.deepEqual(modsBehindText(env), [], \"nothing installed, nothing to say\");","atom":"a0","author":"init","version":0},{"n":493,"text":"\t\tinstallMod(source(), {","atom":"a0","author":"init","version":0},{"n":494,"text":"\t\t\ttarget: join(config, \"skills\", \"abso-hooks\"),","atom":"a402","author":"review","version":40},{"n":495,"text":"\t\t\tcheck: pass,","atom":"a0","author":"init","version":0},{"n":496,"text":"\t\t\tcommit: \"aaaaaaa\",","atom":"a0","author":"init","version":0},{"n":497,"text":"\t\t\tnow: new Date(\"2026-10-05T04:30:00Z\"),","atom":"a0","author":"init","version":0},{"n":498,"text":"\t\t});","atom":"a0","author":"init","version":0},{"n":499,"text":"\t\tconst current = (versionReport(env).json.mods as { current: string }[])[0]!.current;","atom":"a0","author":"init","version":0},{"n":500,"text":"\t\tif (/\\+[0-9a-f]{7}$/.test(current))","atom":"a0","author":"init","version":0},{"n":501,"text":"\t\t\tassert.deepEqual(modsBehindText(env), [","atom":"a0","author":"init","version":0},{"n":502,"text":"\t\t\t\t`The ${AVCS_MOD.name} mod installed on this machine is 0.1.0+aaaaaaa, and this client has ${current}: ${installerCommand(\"install-mod.ts\")} installs it (new chats load it).`,","atom":"a2774","author":"pinch","version":281},{"n":503,"text":"\t\t\t]);","atom":"a0","author":"init","version":0},{"n":504,"text":"\t\t// A client outside git (an abso folder, a box) can't tell, so it says nothing.","atom":"a0","author":"init","version":0},{"n":505,"text":"\t\telse assert.deepEqual(modsBehindText(env), []);","atom":"a0","author":"init","version":0},{"n":506,"text":"\t});","atom":"a0","author":"init","version":0},{"n":507,"text":"","atom":"a0","author":"init","version":0},{"n":508,"text":"\tit(\"the command-line client says which client it is with every call\", () => {","atom":"a0","author":"init","version":0},{"n":509,"text":"\t\tconst headers = new Api({","atom":"a0","author":"init","version":0},{"n":510,"text":"\t\t\tserver: \"https://avcs.test\",","atom":"a0","author":"init","version":0},{"n":511,"text":"\t\t\tproject: \"p\",","atom":"a0","author":"init","version":0},{"n":512,"text":"\t\t\tagent: \"a\",","atom":"a0","author":"init","version":0},{"n":513,"text":"\t\t\ttoken: \"t\",","atom":"a0","author":"init","version":0},{"n":514,"text":"\t\t} as ConstructorParameters<typeof Api>[0]).headers(\"application/json\");","atom":"a0","author":"init","version":0},{"n":515,"text":"\t\tassert.equal(headers[\"x-abso-client\"], `abso-cli/${clientVersion()}`);","atom":"a499","author":"pinch","version":54},{"n":516,"text":"\t\tassert.match(clientVersion(), /^\\d+\\.\\d+\\.\\d+(\\+[0-9a-f]{7})?$/);","atom":"a0","author":"init","version":0},{"n":517,"text":"\t});","atom":"a0","author":"init","version":0},{"n":518,"text":"","atom":"a604","author":"pinch","version":59},{"n":519,"text":"\tit(\"the npm package's client gives the package's version\", () => {","atom":"a604","author":"pinch","version":59},{"n":520,"text":"\t\tconst url = new URL(\"../src/client-version.ts\", import.meta.url).href;","atom":"a604","author":"pinch","version":59},{"n":521,"text":"\t\tconst script = `globalThis.__ABSO_PACKAGE_VERSION__ = \"0.58.0\"; const m = await import(${JSON.stringify(url)}); console.log(m.clientVersion());`;","atom":"a604","author":"pinch","version":59},{"n":522,"text":"\t\tconst r = spawnSync(process.execPath, [\"--input-type=module\", \"-e\", script], { encoding: \"utf8\" });","atom":"a604","author":"pinch","version":59},{"n":523,"text":"\t\tassert.equal(r.stdout.trim(), \"0.58.0\", r.stderr);","atom":"a604","author":"pinch","version":59},{"n":524,"text":"\t});","atom":"a604","author":"pinch","version":59},{"n":525,"text":"});","atom":"a0","author":"init","version":0}],"atoms":[{"atom":"a0","author":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z","publish":{"draft":null,"version":0,"agent":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z"}},{"atom":"a402","author":"review","message":"","time":1791549456768,"timeIso":"2026-10-09T12:37:36.768Z","publish":{"draft":null,"version":40,"agent":"review","message":"Mods: the hooks mod is abso-hooks and the view mod abso-view; an install moves the old skills/avcs and skills/avcs-view folders to ~/.abso/retired-mods (moved, not deleted); the hook stands down for either name; status checks either. Tests cover the move.","time":1791549457128,"timeIso":"2026-10-09T12:37:37.128Z"}},{"atom":"a421","author":"speed","message":"","time":1791555907250,"timeIso":"2026-10-09T14:25:07.250Z","publish":{"draft":null,"version":43,"agent":"speed","message":"status: keep each mod's commit between runs (~/.abso/mod-commits.json), keyed on the checkout's commit read from .git and each mod file's size, time and inode, so status runs no git while nothing moved; files changed too recently to trust are asked again; outside a git checkout git isn't run","time":1791556436079,"timeIso":"2026-10-09T14:33:56.079Z"}},{"atom":"a422","author":"speed","message":"","time":1791555908270,"timeIso":"2026-10-09T14:25:08.270Z","publish":{"draft":null,"version":43,"agent":"speed","message":"status: keep each mod's commit between runs (~/.abso/mod-commits.json), keyed on the checkout's commit read from .git and each mod file's size, time and inode, so status runs no git while nothing moved; files changed too recently to trust are asked again; outside a git checkout git isn't run","time":1791556436079,"timeIso":"2026-10-09T14:33:56.079Z"}},{"atom":"a423","author":"speed","message":"","time":1791555929160,"timeIso":"2026-10-09T14:25:29.160Z","publish":{"draft":null,"version":43,"agent":"speed","message":"status: keep each mod's commit between runs (~/.abso/mod-commits.json), keyed on the checkout's commit read from .git and each mod file's size, time and inode, so status runs no git while nothing moved; files changed too recently to trust are asked again; outside a git checkout git isn't run","time":1791556436079,"timeIso":"2026-10-09T14:33:56.079Z"}},{"atom":"a425","author":"speed","message":"","time":1791556106553,"timeIso":"2026-10-09T14:28:26.553Z","publish":{"draft":null,"version":43,"agent":"speed","message":"status: keep each mod's commit between runs (~/.abso/mod-commits.json), keyed on the checkout's commit read from .git and each mod file's size, time and inode, so status runs no git while nothing moved; files changed too recently to trust are asked again; outside a git checkout git isn't run","time":1791556436079,"timeIso":"2026-10-09T14:33:56.079Z"}},{"atom":"a435","author":"speed","message":"","time":1791557280520,"timeIso":"2026-10-09T14:48:00.520Z","publish":{"draft":null,"version":44,"agent":"speed","message":"status: skip reading files found unchanged before. A record in the folder's state dir (clean.json) keeps, per file, the size, time and inode of the file and its known copy, taken before reading; only status's unrecorded and line-ending checks use it, record always reads every file. Files changed too recently to trust are read; an unknown format or client version reads everything. The state dir is found once per walk. The mod-commit test no longer depends on how long it takes.","time":1791558026769,"timeIso":"2026-10-09T15:00:26.769Z"}},{"atom":"a443","author":"speed","message":"","time":1791558056116,"timeIso":"2026-10-09T15:00:56.116Z","publish":{"draft":null,"version":45,"agent":"speed","message":"Test fix: the mod-commit test set the same 'a minute ago' time twice within a second, which git's index (compared by the second) took as unchanged on Linux; each step now sets its own earlier minute","time":1791558088922,"timeIso":"2026-10-09T15:01:28.922Z"}},{"atom":"a499","author":"pinch","message":"","time":1791586659806,"timeIso":"2026-10-09T22:57:39.806Z","publish":{"draft":null,"version":54,"agent":"pinch","message":"The client and the edit mods send and read X-Abso-* headers only (Client, Name, Run-Key, Kind, Admin; Run, Box, Prep from answers). Servers have read X-Abso-* beside the old names for a while and answer under both, so this works with any current server.","time":1791586669845,"timeIso":"2026-10-09T22:57:49.845Z"}},{"atom":"a604","author":"pinch","message":"","time":1791600222905,"timeIso":"2026-10-10T02:43:42.905Z","publish":{"draft":null,"version":59,"agent":"pinch","message":"The client reports an npm package's version: a build that sets __ABSO_PACKAGE_VERSION__ gets it from abso --version and in its client header, and a built copy (the npm package or a downloaded abso.mjs) reports the installed mods without pointing at install scripts it doesn't have","time":1791600223045,"timeIso":"2026-10-10T02:43:43.045Z"}},{"atom":"a2774","author":"pinch","message":"","time":1792114303447,"timeIso":"2026-10-16T01:31:43.447Z","publish":{"draft":null,"version":281,"agent":"pinch","message":"Client fixes from the judge dry run: help with today's names, a mod installer hint that runs, a failed init or join takes back what it wrote, a refused 401 names the credential that went, and reply --file\n\n- help: abso.json, ABSO_ADMIN_TOKEN, ABSO_ADMIN_SERVERS, ABSO_BOX and .abso/shots/ in place of the old names, and the missing full stop. abso shot saves under .abso/shots/ as help says.\n- --version, init, join and status name the mod installer by its full path, and on a Node that can't run .ts files say it needs Node 22.18 or later. A built copy, which has no installer, says abso record sends the edits.\n- A failed init removes the .absoignore and abso.json it wrote. A failed join removes its .abso/ folder; a key already there, or one made for this join, stays.\n- A 401 names what was sent (this folder's key, ABSO_TOKEN, a pipeline run's key, the token file) instead of always a folder key.\n- reply takes --file <path> or --file - (stdin), like ask and answer.\n- The mod-behind tests no longer depend on which mods the machine has.\n\nTests: install, body-files, failed-start (new), doctor, help, lost-pull pass; tsc clean.","time":1792114518416,"timeIso":"2026-10-16T01:35:18.416Z"}},{"atom":"a2780","author":"pinch","message":"","time":1792114458583,"timeIso":"2026-10-16T01:34:18.583Z","publish":{"draft":null,"version":281,"agent":"pinch","message":"Client fixes from the judge dry run: help with today's names, a mod installer hint that runs, a failed init or join takes back what it wrote, a refused 401 names the credential that went, and reply --file\n\n- help: abso.json, ABSO_ADMIN_TOKEN, ABSO_ADMIN_SERVERS, ABSO_BOX and .abso/shots/ in place of the old names, and the missing full stop. abso shot saves under .abso/shots/ as help says.\n- --version, init, join and status name the mod installer by its full path, and on a Node that can't run .ts files say it needs Node 22.18 or later. A built copy, which has no installer, says abso record sends the edits.\n- A failed init removes the .absoignore and abso.json it wrote. A failed join removes its .abso/ folder; a key already there, or one made for this join, stays.\n- A 401 names what was sent (this folder's key, ABSO_TOKEN, a pipeline run's key, the token file) instead of always a folder key.\n- reply takes --file <path> or --file - (stdin), like ask and answer.\n- The mod-behind tests no longer depend on which mods the machine has.\n\nTests: install, body-files, failed-start (new), doctor, help, lost-pull pass; tsc clean.","time":1792114518416,"timeIso":"2026-10-16T01:35:18.416Z"}},{"atom":"a2860","author":"pinch","message":"","time":1792121214987,"timeIso":"2026-10-16T03:26:54.987Z","publish":{"draft":null,"version":293,"agent":"pinch","message":"Local projects: the abso mod hands their edits to abso hook. The installer stamps the mod with the command that runs its checkout's abso hook (node, client/abso.ts); in a local project's folder the mod runs it with the edit, as Claude Code's command hook would, and passes its news to the chat. A mod installed before this one still skips local folders, and init says so.","time":1792121340185,"timeIso":"2026-10-16T03:29:00.185Z"}},{"atom":"a2871","author":"pinch","message":"","time":1792121339859,"timeIso":"2026-10-16T03:28:59.859Z","publish":{"draft":null,"version":293,"agent":"pinch","message":"Local projects: the abso mod hands their edits to abso hook. The installer stamps the mod with the command that runs its checkout's abso hook (node, client/abso.ts); in a local project's folder the mod runs it with the edit, as Claude Code's command hook would, and passes its news to the chat. A mod installed before this one still skips local folders, and init says so.","time":1792121340185,"timeIso":"2026-10-16T03:29:00.185Z"}}]}