- MCP
- blame on this site's /mcp
- CLI
- abso blame client/src/versions.ts --version 261 --json
- JSON
- /christopher/abso-core/blame/client/src/versions.ts?version=261&format=json
168 linesFirst import 96% · rename 4%Last change rename in version 100,
168 lines from 2 changes in 2 versions.
init0Start the project1// abso drop, pluck, amend, label, labels and follow: changing which published
2// versions shared holds, naming versions, and following a named one (#10, #27).
4import type { VersionRef } from "./api.ts";
5import { bool, type Parsed, str, UsageError } from "./args.ts";
6import { applyAnswer, collisionText, type Env, EXIT, type Output, open, plural, recordFolder } from "./commands.ts";
7import { writeConfig } from "./config.ts";
8import { refusedText } from "./safety.ts";
10function versionList(words: readonly string[], what: string): number[] {
11 if (words.length === 0) throw new UsageError(`name the ${what} by number`);
12 return words.map((w) => {
13 if (!/^\d+$/.test(w)) throw new UsageError(`${what} are version numbers (got ${JSON.stringify(w)})`);
14 return Number(w);
15 });
16}
18function ref(v: VersionRef): string {
19 return ` version ${v.version} by ${v.agent}: ${v.message}`;
20}
22function labelName(raw: string | undefined): string {
23 if (!raw || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(raw))
24 throw new UsageError(
25 `label names are letters, digits, dot, dash and underscore (got ${JSON.stringify(raw ?? "")})`,
26 );
27 return raw;
28}
30export async function runDrop(args: Parsed, env: Env): Promise<Output> {
31 const versions = versionList(args.positionals, "versions to drop");
32 const message = str(args, "message");
33 if (!message) throw new UsageError('say why with -m "<message>"');
34 const { api } = open(env);
35 const answer = await api.drop(versions, message, bool(args, "with-dependents"));
36 if (answer.ok) {
37 return {
38 text: [
39 `Dropped from shared, as version ${answer.version}:`,
40 ...answer.dropped.map(ref),
rename100abso publish is now abso push, abso sync is now abso pull (abso 427)
Commands, 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.
push -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.
Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare41 "Other agents hear it as news; their next pull takes it out of their folders. History keeps it: abso log shows the drop.",
43 json: { ...answer },
44 };
45 }
46 const lines = ["Not dropped."];
47 if (answer.dependents && answer.dependents.length > 0) {
48 lines.push(
rename100abso publish is now abso push, abso sync is now abso pull (abso 427)
Commands, 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.
push -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.
Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare49 `Later pushed versions build on ${versions.length === 1 ? "it" : "them"}:`,
51 "Pass --with-dependents to drop those too.",
52 );
53 }
54 if (answer.blocked && answer.blocked.length > 0) {
55 lines.push(
rename100abso publish is now abso push, abso sync is now abso pull (abso 427)
Commands, 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.
push -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.
Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare56 "Unpushed work builds on it, and a drop never touches unpushed work:",
58 (b) => ` ${b.agent !== undefined ? `agent ${b.agent}` : `draft ${b.draft}`}: ${b.files.join(", ")}`,
59 ),
60 );
61 }
62 return { exit: EXIT.refused, text: lines.join("\n"), json: { ...answer } };
63}
65export async function runPluck(args: Parsed, env: Env): Promise<Output> {
66 const [draft, ...rest] = args.positionals;
67 if (draft === undefined)
68 throw new UsageError('pluck takes a draft and its versions: abso pluck <draft> <version...> -m "why"');
69 const versions = versionList(rest, `versions of draft ${draft} to pluck`);
70 const message = str(args, "message");
71 if (!message) throw new UsageError('say why with -m "<message>"');
72 const { api } = open(env);
73 const answer = await api.pluck(draft, versions, message, bool(args, "with-dependencies"));
74 if (answer.ok) {
75 return {
76 text: `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.`,
77 json: { ...answer },
78 };
79 }
80 const lines = ["Not plucked."];
81 if (answer.needs && answer.needs.length > 0)
82 lines.push(
83 "They build on these versions of the draft:",
84 ...answer.needs.map(ref),
85 "Pass --with-dependencies to take those too.",
86 );
87 if (answer.collisions && answer.collisions.length > 0)
88 lines.push(
89 `${plural(answer.collisions.length, "collision")} with work in shared:`,
90 ...answer.collisions.map(collisionText),
91 );
92 return { exit: EXIT.refused, text: lines.join("\n"), json: { ...answer } };
93}
95export async function runAmend(args: Parsed, env: Env): Promise<Output> {
96 const message = str(args, "message");
97 if (!message) throw new UsageError('give the new message with -m "<message>"');
98 const { api } = open(env);
99 const a = await api.amend(message);
100 const where = a.draft === null ? "shared" : `draft ${a.draft}`;
101 return {
rename100abso publish is now abso push, abso sync is now abso pull (abso 427)
Commands, 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.
push -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.
Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare102 text: `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.`,
104 };
105}
107export async function runLabel(args: Parsed, env: Env): Promise<Output> {
108 if (args.positionals.length !== 1)
109 throw new UsageError("label takes one name: abso label <name> [--version <n>] [--remove]");
110 const name = labelName(args.positionals[0]);
111 const raw = str(args, "version");
112 if (raw !== undefined && !/^\d+$/.test(raw))
113 throw new UsageError(`--version is a version number (got ${JSON.stringify(raw)})`);
114 const remove = bool(args, "remove");
115 const { api } = open(env);
116 const a = await api.label(name, raw === undefined ? undefined : Number(raw), remove);
117 const now =
118 a.versions.length === 0 ? "no version now" : `${plural(a.versions.length, "version")}: ${a.versions.join(", ")}`;
119 return {
120 text: `${remove ? "Took" : "Put"} label ${a.name} ${remove ? "off" : "on"} version ${a.version}. It marks ${now}.`,
121 json: { ...a },
122 };
123}
125export async function runLabels(_args: Parsed, env: Env): Promise<Output> {
126 const { config, api } = open(env);
127 const { labels } = await api.labels();
128 const names = Object.keys(labels).sort();
129 const lines =
130 names.length === 0
131 ? ["No labels yet. abso label <name> puts one on shared's newest version."]
132 : names.map((n) => ` ${n}: ${labels[n]!.join(", ")}${config.follow === n ? " (this folder follows it)" : ""}`);
133 return { text: lines.join("\n"), json: { labels, follow: config.follow ?? null } };
134}
136export async function runFollow(args: Parsed, env: Env): Promise<Output> {
137 const none = bool(args, "none");
138 if (none === (args.positionals.length === 1) || args.positionals.length > 1)
139 throw new UsageError("follow takes one label, or --none: abso follow <label> | abso follow --none");
140 const follow = none ? undefined : labelName(args.positionals[0]);
141 const { root, config } = open(env);
142 const { token: _token, follow: _old, ...settings } = config;
143 writeConfig(root, { ...settings, ...(follow ? { follow } : {}) });
144 // Sync now (recording first, as sync does), so the folder is where it now says it is.
145 const { api } = open(env);
146 await recordFolder(root, api);
147 const s = await applyAnswer(root, api, await api.sync());
148 const changes = s.written.length + s.deleted.length;
149 const head = follow
rename100abso publish is now abso push, abso sync is now abso pull (abso 427)
Commands, 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.
push -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.
Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare150 ? `This folder now follows label ${follow}: every pull takes it to the newest version with that label. It is on version ${s.version}.`
151 : `This folder follows no label now: pulls take it to shared's newest version, ${s.version}.`;
153 text: [
154 head,
155 changes === 0 ? "No files changed." : `${plural(s.written.length, "file")} updated, ${s.deleted.length} deleted.`,
156 ...refusedText(s.refused),
157 ...(s.kept.length > 0 ? [`Left alone because they have unrecorded changes: ${s.kept.join(", ")}`] : []),
158 ].join("\n"),
159 json: {
160 follow: follow ?? null,
161 version: s.version,
162 written: s.written,
163 deleted: s.deleted,
164 kept: s.kept,
165 refused: s.refused,
166 },
167 };
168}