{"file":"client/src/versions.ts","version":318,"total":180,"from":1,"to":180,"lines":[{"n":1,"text":"// abso drop, pluck, amend, label, labels and follow: changing which published","atom":"a0","author":"init","version":0},{"n":2,"text":"// versions shared holds, naming versions, and following a named one (#10, #27).","atom":"a0","author":"init","version":0},{"n":3,"text":"","atom":"a0","author":"init","version":0},{"n":4,"text":"import type { VersionRef } from \"./api.ts\";","atom":"a0","author":"init","version":0},{"n":5,"text":"import { bool, type Parsed, str, UsageError } from \"./args.ts\";","atom":"a0","author":"init","version":0},{"n":6,"text":"import {","atom":"a2760","author":"pinch","version":280},{"n":7,"text":"\tapplyAnswer,","atom":"a2760","author":"pinch","version":280},{"n":8,"text":"\tcollisionText,","atom":"a2760","author":"pinch","version":280},{"n":9,"text":"\ttype Env,","atom":"a2760","author":"pinch","version":280},{"n":10,"text":"\tEXIT,","atom":"a2760","author":"pinch","version":280},{"n":11,"text":"\ttype Output,","atom":"a2760","author":"pinch","version":280},{"n":12,"text":"\topen,","atom":"a2760","author":"pinch","version":280},{"n":13,"text":"\tplural,","atom":"a2760","author":"pinch","version":280},{"n":14,"text":"\tpullAnswer,","atom":"a2760","author":"pinch","version":280},{"n":15,"text":"\tpullWritten,","atom":"a2760","author":"pinch","version":280},{"n":16,"text":"\trecordFolder,","atom":"a2760","author":"pinch","version":280},{"n":17,"text":"} from \"./commands.ts\";","atom":"a2760","author":"pinch","version":280},{"n":18,"text":"import { writeConfig } from \"./config.ts\";","atom":"a0","author":"init","version":0},{"n":19,"text":"import { refusedText } from \"./safety.ts\";","atom":"a0","author":"init","version":0},{"n":20,"text":"","atom":"a0","author":"init","version":0},{"n":21,"text":"function versionList(words: readonly string[], what: string): number[] {","atom":"a0","author":"init","version":0},{"n":22,"text":"\tif (words.length === 0) throw new UsageError(`name the ${what} by number`);","atom":"a0","author":"init","version":0},{"n":23,"text":"\treturn words.map((w) => {","atom":"a0","author":"init","version":0},{"n":24,"text":"\t\tif (!/^\\d+$/.test(w)) throw new UsageError(`${what} are version numbers (got ${JSON.stringify(w)})`);","atom":"a0","author":"init","version":0},{"n":25,"text":"\t\treturn Number(w);","atom":"a0","author":"init","version":0},{"n":26,"text":"\t});","atom":"a0","author":"init","version":0},{"n":27,"text":"}","atom":"a0","author":"init","version":0},{"n":28,"text":"","atom":"a0","author":"init","version":0},{"n":29,"text":"function ref(v: VersionRef): string {","atom":"a0","author":"init","version":0},{"n":30,"text":"\treturn `  version ${v.version} by ${v.agent}: ${v.message}`;","atom":"a0","author":"init","version":0},{"n":31,"text":"}","atom":"a0","author":"init","version":0},{"n":32,"text":"","atom":"a0","author":"init","version":0},{"n":33,"text":"function labelName(raw: string | undefined): string {","atom":"a0","author":"init","version":0},{"n":34,"text":"\tif (!raw || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(raw))","atom":"a0","author":"init","version":0},{"n":35,"text":"\t\tthrow new UsageError(","atom":"a0","author":"init","version":0},{"n":36,"text":"\t\t\t`label names are letters, digits, dot, dash and underscore (got ${JSON.stringify(raw ?? \"\")})`,","atom":"a0","author":"init","version":0},{"n":37,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":38,"text":"\treturn raw;","atom":"a0","author":"init","version":0},{"n":39,"text":"}","atom":"a0","author":"init","version":0},{"n":40,"text":"","atom":"a0","author":"init","version":0},{"n":41,"text":"export async function runDrop(args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":42,"text":"\tconst versions = versionList(args.positionals, \"versions to drop\");","atom":"a0","author":"init","version":0},{"n":43,"text":"\tconst message = str(args, \"message\");","atom":"a0","author":"init","version":0},{"n":44,"text":"\tif (!message) throw new UsageError('say why with -m \"<message>\"');","atom":"a0","author":"init","version":0},{"n":45,"text":"\tconst { api } = open(env);","atom":"a0","author":"init","version":0},{"n":46,"text":"\tconst answer = await api.drop(versions, message, bool(args, \"with-dependents\"));","atom":"a0","author":"init","version":0},{"n":47,"text":"\tif (answer.ok) {","atom":"a0","author":"init","version":0},{"n":48,"text":"\t\treturn {","atom":"a0","author":"init","version":0},{"n":49,"text":"\t\t\ttext: [","atom":"a0","author":"init","version":0},{"n":50,"text":"\t\t\t\t`Dropped from shared, as version ${answer.version}:`,","atom":"a0","author":"init","version":0},{"n":51,"text":"\t\t\t\t...answer.dropped.map(ref),","atom":"a0","author":"init","version":0},{"n":52,"text":"\t\t\t\t\"Other agents hear it as news; their next pull takes it out of their folders. History keeps it: abso log shows the drop.\",","atom":"a852","author":"rename","version":100},{"n":53,"text":"\t\t\t].join(\"\\n\"),","atom":"a0","author":"init","version":0},{"n":54,"text":"\t\t\tjson: { ...answer },","atom":"a0","author":"init","version":0},{"n":55,"text":"\t\t};","atom":"a0","author":"init","version":0},{"n":56,"text":"\t}","atom":"a0","author":"init","version":0},{"n":57,"text":"\tconst lines = [\"Not dropped.\"];","atom":"a0","author":"init","version":0},{"n":58,"text":"\tif (answer.dependents && answer.dependents.length > 0) {","atom":"a0","author":"init","version":0},{"n":59,"text":"\t\tlines.push(","atom":"a0","author":"init","version":0},{"n":60,"text":"\t\t\t`Later pushed versions build on ${versions.length === 1 ? \"it\" : \"them\"}:`,","atom":"a852","author":"rename","version":100},{"n":61,"text":"\t\t\t...answer.dependents.map(ref),","atom":"a0","author":"init","version":0},{"n":62,"text":"\t\t\t\"Pass --with-dependents to drop those too.\",","atom":"a0","author":"init","version":0},{"n":63,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":64,"text":"\t}","atom":"a0","author":"init","version":0},{"n":65,"text":"\tif (answer.blocked && answer.blocked.length > 0) {","atom":"a0","author":"init","version":0},{"n":66,"text":"\t\tlines.push(","atom":"a0","author":"init","version":0},{"n":67,"text":"\t\t\t\"Unpushed work builds on it, and a drop never touches unpushed work:\",","atom":"a852","author":"rename","version":100},{"n":68,"text":"\t\t\t...answer.blocked.map(","atom":"a0","author":"init","version":0},{"n":69,"text":"\t\t\t\t(b) => `  ${b.agent !== undefined ? `agent ${b.agent}` : `draft ${b.draft}`}: ${b.files.join(\", \")}`,","atom":"a0","author":"init","version":0},{"n":70,"text":"\t\t\t),","atom":"a0","author":"init","version":0},{"n":71,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":72,"text":"\t}","atom":"a0","author":"init","version":0},{"n":73,"text":"\treturn { exit: EXIT.refused, text: lines.join(\"\\n\"), json: { ...answer } };","atom":"a0","author":"init","version":0},{"n":74,"text":"}","atom":"a0","author":"init","version":0},{"n":75,"text":"","atom":"a0","author":"init","version":0},{"n":76,"text":"export async function runPluck(args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":77,"text":"\tconst [draft, ...rest] = args.positionals;","atom":"a0","author":"init","version":0},{"n":78,"text":"\tif (draft === undefined)","atom":"a0","author":"init","version":0},{"n":79,"text":"\t\tthrow new UsageError('pluck takes a draft and its versions: abso pluck <draft> <version...> -m \"why\"');","atom":"a0","author":"init","version":0},{"n":80,"text":"\tconst versions = versionList(rest, `versions of draft ${draft} to pluck`);","atom":"a0","author":"init","version":0},{"n":81,"text":"\tconst message = str(args, \"message\");","atom":"a0","author":"init","version":0},{"n":82,"text":"\tif (!message) throw new UsageError('say why with -m \"<message>\"');","atom":"a0","author":"init","version":0},{"n":83,"text":"\tconst { api } = open(env);","atom":"a0","author":"init","version":0},{"n":84,"text":"\tconst answer = await api.pluck(draft, versions, message, bool(args, \"with-dependencies\"));","atom":"a0","author":"init","version":0},{"n":85,"text":"\tif (answer.ok) {","atom":"a0","author":"init","version":0},{"n":86,"text":"\t\treturn {","atom":"a0","author":"init","version":0},{"n":87,"text":"\t\t\ttext: `Plucked ${plural(versions.length, \"version\")} of draft ${draft} into shared as version ${answer.version} (${plural(answer.changes, \"change\")}). The draft stays as it is; landing it later brings in only the rest.`,","atom":"a0","author":"init","version":0},{"n":88,"text":"\t\t\tjson: { ...answer },","atom":"a0","author":"init","version":0},{"n":89,"text":"\t\t};","atom":"a0","author":"init","version":0},{"n":90,"text":"\t}","atom":"a0","author":"init","version":0},{"n":91,"text":"\tconst lines = [\"Not plucked.\"];","atom":"a0","author":"init","version":0},{"n":92,"text":"\tif (answer.needs && answer.needs.length > 0)","atom":"a0","author":"init","version":0},{"n":93,"text":"\t\tlines.push(","atom":"a0","author":"init","version":0},{"n":94,"text":"\t\t\t\"They build on these versions of the draft:\",","atom":"a0","author":"init","version":0},{"n":95,"text":"\t\t\t...answer.needs.map(ref),","atom":"a0","author":"init","version":0},{"n":96,"text":"\t\t\t\"Pass --with-dependencies to take those too.\",","atom":"a0","author":"init","version":0},{"n":97,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":98,"text":"\tif (answer.collisions && answer.collisions.length > 0)","atom":"a0","author":"init","version":0},{"n":99,"text":"\t\tlines.push(","atom":"a0","author":"init","version":0},{"n":100,"text":"\t\t\t`${plural(answer.collisions.length, \"collision\")} with work in shared:`,","atom":"a0","author":"init","version":0},{"n":101,"text":"\t\t\t...answer.collisions.map(collisionText),","atom":"a0","author":"init","version":0},{"n":102,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":103,"text":"\treturn { exit: EXIT.refused, text: lines.join(\"\\n\"), json: { ...answer } };","atom":"a0","author":"init","version":0},{"n":104,"text":"}","atom":"a0","author":"init","version":0},{"n":105,"text":"","atom":"a0","author":"init","version":0},{"n":106,"text":"export async function runAmend(args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":107,"text":"\tconst message = str(args, \"message\");","atom":"a0","author":"init","version":0},{"n":108,"text":"\tif (!message) throw new UsageError('give the new message with -m \"<message>\"');","atom":"a0","author":"init","version":0},{"n":109,"text":"\tconst { api } = open(env);","atom":"a0","author":"init","version":0},{"n":110,"text":"\tconst a = await api.amend(message);","atom":"a0","author":"init","version":0},{"n":111,"text":"\tconst where = a.draft === null ? \"shared\" : `draft ${a.draft}`;","atom":"a0","author":"init","version":0},{"n":112,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":113,"text":"\t\ttext: `Version ${a.version} of ${where} now says: ${a.message}\\n(It said: ${a.was}.) Only the message changed; to change what it did, push again or abso drop it.`,","atom":"a852","author":"rename","version":100},{"n":114,"text":"\t\tjson: { ...a },","atom":"a0","author":"init","version":0},{"n":115,"text":"\t};","atom":"a0","author":"init","version":0},{"n":116,"text":"}","atom":"a0","author":"init","version":0},{"n":117,"text":"","atom":"a0","author":"init","version":0},{"n":118,"text":"export async function runLabel(args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":119,"text":"\tif (args.positionals.length !== 1)","atom":"a0","author":"init","version":0},{"n":120,"text":"\t\tthrow new UsageError(\"label takes one name: abso label <name> [--version <n>] [--remove]\");","atom":"a0","author":"init","version":0},{"n":121,"text":"\tconst name = labelName(args.positionals[0]);","atom":"a0","author":"init","version":0},{"n":122,"text":"\tconst raw = str(args, \"version\");","atom":"a0","author":"init","version":0},{"n":123,"text":"\tif (raw !== undefined && !/^\\d+$/.test(raw))","atom":"a0","author":"init","version":0},{"n":124,"text":"\t\tthrow new UsageError(`--version is a version number (got ${JSON.stringify(raw)})`);","atom":"a0","author":"init","version":0},{"n":125,"text":"\tconst remove = bool(args, \"remove\");","atom":"a0","author":"init","version":0},{"n":126,"text":"\tconst { api } = open(env);","atom":"a0","author":"init","version":0},{"n":127,"text":"\tconst a = await api.label(name, raw === undefined ? undefined : Number(raw), remove);","atom":"a0","author":"init","version":0},{"n":128,"text":"\tconst now =","atom":"a0","author":"init","version":0},{"n":129,"text":"\t\ta.versions.length === 0 ? \"no version now\" : `${plural(a.versions.length, \"version\")}: ${a.versions.join(\", \")}`;","atom":"a0","author":"init","version":0},{"n":130,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":131,"text":"\t\ttext: `${remove ? \"Took\" : \"Put\"} label ${a.name} ${remove ? \"off\" : \"on\"} version ${a.version}. It marks ${now}.`,","atom":"a0","author":"init","version":0},{"n":132,"text":"\t\tjson: { ...a },","atom":"a0","author":"init","version":0},{"n":133,"text":"\t};","atom":"a0","author":"init","version":0},{"n":134,"text":"}","atom":"a0","author":"init","version":0},{"n":135,"text":"","atom":"a0","author":"init","version":0},{"n":136,"text":"export async function runLabels(_args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":137,"text":"\tconst { config, api } = open(env);","atom":"a0","author":"init","version":0},{"n":138,"text":"\tconst { labels } = await api.labels();","atom":"a0","author":"init","version":0},{"n":139,"text":"\tconst names = Object.keys(labels).sort();","atom":"a0","author":"init","version":0},{"n":140,"text":"\tconst lines =","atom":"a0","author":"init","version":0},{"n":141,"text":"\t\tnames.length === 0","atom":"a0","author":"init","version":0},{"n":142,"text":"\t\t\t? [\"No labels yet. abso label <name> puts one on shared's newest version.\"]","atom":"a0","author":"init","version":0},{"n":143,"text":"\t\t\t: names.map((n) => `  ${n}: ${labels[n]!.join(\", \")}${config.follow === n ? \"   (this folder follows it)\" : \"\"}`);","atom":"a0","author":"init","version":0},{"n":144,"text":"\treturn { text: lines.join(\"\\n\"), json: { labels, follow: config.follow ?? null } };","atom":"a0","author":"init","version":0},{"n":145,"text":"}","atom":"a0","author":"init","version":0},{"n":146,"text":"","atom":"a0","author":"init","version":0},{"n":147,"text":"export async function runFollow(args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":148,"text":"\tconst none = bool(args, \"none\");","atom":"a0","author":"init","version":0},{"n":149,"text":"\tif (none === (args.positionals.length === 1) || args.positionals.length > 1)","atom":"a0","author":"init","version":0},{"n":150,"text":"\t\tthrow new UsageError(\"follow takes one label, or --none: abso follow <label> | abso follow --none\");","atom":"a0","author":"init","version":0},{"n":151,"text":"\tconst follow = none ? undefined : labelName(args.positionals[0]);","atom":"a0","author":"init","version":0},{"n":152,"text":"\tconst { root, config } = open(env);","atom":"a0","author":"init","version":0},{"n":153,"text":"\tconst { token: _token, follow: _old, ...settings } = config;","atom":"a0","author":"init","version":0},{"n":154,"text":"\twriteConfig(root, { ...settings, ...(follow ? { follow } : {}) });","atom":"a0","author":"init","version":0},{"n":155,"text":"\t// Sync now (recording first, as sync does), so the folder is where it now says it is.","atom":"a0","author":"init","version":0},{"n":156,"text":"\tconst { api } = open(env);","atom":"a0","author":"init","version":0},{"n":157,"text":"\tawait recordFolder(root, api);","atom":"a0","author":"init","version":0},{"n":158,"text":"\tconst s = await applyAnswer(root, api, await pullAnswer(root, api));","atom":"a2760","author":"pinch","version":280},{"n":159,"text":"\tpullWritten(root);","atom":"a2760","author":"pinch","version":280},{"n":160,"text":"\tconst changes = s.written.length + s.deleted.length;","atom":"a0","author":"init","version":0},{"n":161,"text":"\tconst head = follow","atom":"a0","author":"init","version":0},{"n":162,"text":"\t\t? `This folder now follows label ${follow}: every pull takes it to the newest version with that label. It is on version ${s.version}.`","atom":"a852","author":"rename","version":100},{"n":163,"text":"\t\t: `This folder follows no label now: pulls take it to shared's newest version, ${s.version}.`;","atom":"a852","author":"rename","version":100},{"n":164,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":165,"text":"\t\ttext: [","atom":"a0","author":"init","version":0},{"n":166,"text":"\t\t\thead,","atom":"a0","author":"init","version":0},{"n":167,"text":"\t\t\tchanges === 0 ? \"No files changed.\" : `${plural(s.written.length, \"file\")} updated, ${s.deleted.length} deleted.`,","atom":"a0","author":"init","version":0},{"n":168,"text":"\t\t\t...refusedText(s.refused),","atom":"a0","author":"init","version":0},{"n":169,"text":"\t\t\t...(s.kept.length > 0 ? [`Left alone because they have unrecorded changes: ${s.kept.join(\", \")}`] : []),","atom":"a0","author":"init","version":0},{"n":170,"text":"\t\t].join(\"\\n\"),","atom":"a0","author":"init","version":0},{"n":171,"text":"\t\tjson: {","atom":"a0","author":"init","version":0},{"n":172,"text":"\t\t\tfollow: follow ?? null,","atom":"a0","author":"init","version":0},{"n":173,"text":"\t\t\tversion: s.version,","atom":"a0","author":"init","version":0},{"n":174,"text":"\t\t\twritten: s.written,","atom":"a0","author":"init","version":0},{"n":175,"text":"\t\t\tdeleted: s.deleted,","atom":"a0","author":"init","version":0},{"n":176,"text":"\t\t\tkept: s.kept,","atom":"a0","author":"init","version":0},{"n":177,"text":"\t\t\trefused: s.refused,","atom":"a0","author":"init","version":0},{"n":178,"text":"\t\t},","atom":"a0","author":"init","version":0},{"n":179,"text":"\t};","atom":"a0","author":"init","version":0},{"n":180,"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":"a852","author":"rename","message":"","time":1791659799126,"timeIso":"2026-10-10T19:16:39.126Z","publish":{"draft":null,"version":100,"agent":"rename","message":"abso publish is now abso push, abso sync is now abso pull (abso 427)\n\nCommands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; \"shared\" stays the noun (\"Pushed version N\"). No aliases, no notices. A queued push that was \"pulled\" is now \"turned back\", so pull means one thing.\n\npush -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch.\n\nKept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.","time":1791659833853,"timeIso":"2026-10-10T19:17:13.853Z"}},{"atom":"a2760","author":"pinch","message":"","time":1792113682010,"timeIso":"2026-10-16T01:21:22.010Z","publish":{"draft":null,"version":280,"agent":"pinch","message":"A pull whose answer never arrives no longer leaves the folder behind\n\nThe server moves the agent's base when it answers a pull, and later pulls send only what changed since that base. When the answer was lost (a timeout on a slow server), the files it carried were never written, and every later pull, status, restore and export agreed the folder was current.\n\nNow the client notes a pull in .abso/pulling.json before asking, and takes the note away once the answer is written. While the note is there, abso status says a pull didn't finish, and the next pull asks for every file in the view (as pull --full does) and writes the ones that differ, keeping work done in the folder meanwhile, as every pull does. follow, draft switching and draft-pull pull the same way. A server without full pulls gets a plain pull.\n\nTests: client/test/lost-pull.test.ts (a fake server that carries out a pull and drops its answer), plus held-push, join-signed-out and record-batches: 19 pass. tsc and Biome clean.","time":1792113718029,"timeIso":"2026-10-16T01:21:58.029Z"}}]}