Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
show on this site's /mcp
CLI
abso show 23 --json
JSON
/christopher/abso-core/versions/23?format=json

abso issue <N> --copy-to <project>: copy an issue into another project, with its comments, answered asks and labels, each keeping its author and time. The Issues server reads the source issue itself; the client sends only which issue, and any cleaned texts.

of shared·pinch··Not checked

  • --dry-run shows what the copy would make (title, how many comments and asks, which were edited, labels) and what's left behind. It writes nothing.
  • --clean <file> gives cleaned texts by source id, as JSON: {title, description, comments: [{id, text}], asks: [{id, question, answer}]}. A comment left out of a given list isn't copied.
  • --copy-to goes alone, so a copy is never half an edit. Copying into the project the issue is already in is refused before any call.
  • When a live server refuses the copy (copying out of a project there takes an owner of it), the message says --dry-run still works.
  • The MCP issue tool's clean input is a file too, so it's confined to the server's start folder like attach.

Tests: client/test/issues.test.ts, against a stand-in Issues server. The run --parallel test that sometimes times out under a full run passed when rerun.

Version 22 · Files at version 23

6 files, 259 lines added, 12 removed.

--- a/client/src/api.ts
+++ b/client/src/api.ts
@@ -97,6 +97,32 @@
9797 return (typeof news === "string" ? [news] : [...news]).filter((s) => typeof s === "string" && s.trim() !== "");
9898}
9999
100+/** An issue copy's request: the source, and any texts given cleaned, by their source ids. */
101+export interface CopyBody {
102+ from: string;
103+ issue: number;
104+ title?: string;
105+ description?: string;
106+ comments?: { id: number; text?: string }[];
107+ asks?: { id: number; question?: string; answer?: string }[];
108+}
110+/** What a copy writes, as a dry run answers it. */
111+export interface CopyPlan {
112+ from: { project: string; issue: number };
113+ title: string;
114+ edited: ("title" | "description")[];
115+ labels: string[];
116+ closed: { how: "done" | "dropped" } | null;
117+ comments: { edited: boolean }[];
118+ asks: { edited: boolean }[];
119+ skipped: { comments: number[]; asks: number[] };
120+}
122+export type CopyAnswer =
123+ | { dryRun: true; plan: CopyPlan }
124+ | { ok: true; id: number; from: { project: string; issue: number }; skipped: { comments: number[]; asks: number[] } };
100126export class Api {
101127 readonly config: Config;
102128 readonly timeoutMs: number;
@@ -452,6 +478,17 @@
452478 return JSON.parse(text) as Attachment;
453479 }
454480
481+ /**
482+ * Copies issue `body.issue` of this project into project `to`, keeping
483+ * authors and times: the Issues server reads the source itself, and only
484+ * texts may be given cleaned. A dry run answers the plan and writes nothing.
485+ */
486+ issueCopy(to: string, body: CopyBody & { dryRun?: boolean }): Promise<CopyAnswer> {
487+ const there = new Api({ ...this.config, project: to }, this.timeoutMs);
488+ there.issuesServer = this.issuesServer;
489+ return there.#issues("POST", there.agentPath("copy"), body);
490+ }
455492 /** Where an attachment is served. */
456493 attachmentUrl(id: string): string {
457494 return this.url(`/attachments/${id}`, this.issuesServer);
--- a/client/src/issues.ts
+++ b/client/src/issues.ts
@@ -7,7 +7,19 @@
77
88import { readFileSync, statSync } from "node:fs";
99import { basename, resolve } from "node:path";
10−import type { Api, Ask, Attachment, Draft, DraftBody, IssuePage, IssueRow, IssueSearchHit } from "./api.ts";
10+import {
11+ type Api,
12+ ApiError,
13+ type Ask,
14+ type Attachment,
15+ type CopyAnswer,
16+ type CopyBody,
17+ type Draft,
18+ type DraftBody,
19+ type IssuePage,
20+ type IssueRow,
21+ type IssueSearchHit,
22+} from "./api.ts";
1123import { bool, type Parsed, str, UsageError } from "./args.ts";
1224import { type Env, type Output, open, plural } from "./commands.ts";
1325import { type Config, readMachineServers, trustedServers } from "./config.ts";
@@ -325,6 +337,76 @@
325337 };
326338}
327339
340+/** The flags --copy-to goes with: anything else on the same command is refused, so a copy is never half an edit. */
341+const COPY_FLAGS = new Set(["copy-to", "clean", "dry-run"]);
343+/** abso issue <N> --copy-to <project>: the server reads the issue and writes the copy. */
344+async function runCopy(api: Api, id: number, to: string, args: Parsed, env: Env): Promise<Output> {
345+ const other = [...args.flags.keys()].filter((f) => !COPY_FLAGS.has(f) && f !== "json");
346+ if (other.length > 0)
347+ throw new UsageError(`--copy-to goes alone (with --clean and --dry-run), not with --${other[0]}`);
348+ if (to === api.config.project)
349+ throw new UsageError(`issue ${id} is already in ${to}; --copy-to names another project`);
350+ const clean = str(args, "clean");
351+ const texts = clean === undefined ? {} : readClean(resolve(env.cwd, clean), clean);
352+ const dryRun = bool(args, "dry-run");
353+ const from = api.config.project;
354+ let answer: CopyAnswer;
355+ try {
356+ answer = await api.issueCopy(to, { ...texts, from, issue: id, ...(dryRun ? { dryRun: true } : {}) });
357+ } catch (e) {
358+ if (e instanceof ApiError && e.status === 403 && !dryRun)
359+ throw new ApiError(`${e.message}. --dry-run still shows what would go.`, e.status);
360+ throw e;
361+ }
362+ if ("dryRun" in answer) {
363+ const p = answer.plan;
364+ const edited = (list: { edited: boolean }[]) => list.filter((x) => x.edited).length;
365+ const lines = [
366+ `A dry run: nothing was written. Copying ${from} issue ${id} into ${to} would make:`,
367+ ` ${q(p.title)}${p.closed ? `, ${p.closed.how}` : ""}${p.edited.length > 0 ? ` (${p.edited.join(" and ")} edited when copied)` : ""}`,
368+ ` ${plural(p.comments.length, "comment")}${edited(p.comments) > 0 ? ` (${edited(p.comments)} edited)` : ""}, ${plural(p.asks.length, "answered ask")}${edited(p.asks) > 0 ? ` (${edited(p.asks)} edited)` : ""}${p.labels.length > 0 ? `, labelled ${p.labels.join(", ")}` : ""}`,
369+ ...skippedLines(p.skipped),
370+ `Run it again without --dry-run to copy it.`,
371+ ];
372+ return { text: lines.join("\n"), json: answer };
373+ }
374+ return {
375+ text: [
376+ `Copied ${from} issue ${id} to ${to} issue ${answer.id}. Its comments and asks keep their authors and times, and issue ${id} has a comment saying where it went.`,
377+ ...skippedLines(answer.skipped),
378+ ].join("\n"),
379+ json: answer,
380+ };
381+}
383+function skippedLines(skipped: { comments: number[]; asks: number[] }): string[] {
384+ const parts = [
385+ ...(skipped.comments.length > 0 ? [`comments ${skipped.comments.join(", ")}`] : []),
386+ ...(skipped.asks.length > 0 ? [`asks ${skipped.asks.join(", ")}`] : []),
387+ ];
388+ return parts.length > 0 ? [` not copied: ${parts.join("; ")} (open asks, and what --clean left out)`] : [];
389+}
391+/** --clean's file: cleaned texts by source id. The server checks each id against the issue it reads. */
392+function readClean(path: string, given: string): Omit<CopyBody, "from" | "issue"> {
393+ let raw: unknown;
394+ try {
395+ raw = JSON.parse(readFileSync(path, "utf8"));
396+ } catch (e) {
397+ throw new UsageError(
398+ `--clean ${given}: ${(e as NodeJS.ErrnoException).code === "ENOENT" ? "no such file" : "not JSON"}`,
399+ );
400+ }
401+ if (typeof raw !== "object" || raw === null || Array.isArray(raw))
402+ throw new UsageError(`--clean ${given}: a JSON object with title, description, comments or asks`);
403+ const known = new Set(["title", "description", "comments", "asks"]);
404+ const unknown = Object.keys(raw).filter((k) => !known.has(k));
405+ if (unknown.length > 0)
406+ throw new UsageError(`--clean ${given}: ${unknown[0]} isn't one of title, description, comments, asks`);
407+ return raw as Omit<CopyBody, "from" | "issue">;
408+}
328410export async function runIssue(args: Parsed, env: Env): Promise<Output> {
329411 const [first, ...rest] = args.positionals;
330412 const { api } = openIssues(env);
@@ -347,6 +429,10 @@
347429 'abso issue <N> [--comment "..." | --object "..." | --drop | --reopen | --done [--done-by <version>] | an edit], or abso issue new "<title>"',
348430 );
349431 const id = issueNumber(first);
432+ const copyTo = str(args, "copy-to");
433+ if (copyTo !== undefined) return runCopy(api, id, copyTo, args, env);
434+ if (str(args, "clean") !== undefined || bool(args, "dry-run"))
435+ throw new UsageError("--clean and --dry-run go with --copy-to <project>");
350436 const comment = str(args, "comment");
351437 const object = str(args, "object");
352438 const doneBy = str(args, "done-by");
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -387,11 +387,14 @@
387387 open: "boolean",
388388 delete: "boolean",
389389 attach: "string",
390+ "copy-to": "string",
391+ clean: "string",
392+ "dry-run": "boolean",
390393 },
391394 usage:
392− 'abso issue <N> [--comment "..." [--attach <file,file>] | --object "..." | --drop | --reopen | --done [--done-by <version>]] | abso issue <N> [--title "..."] [--description "..."] [--parent <N|none>] [--agent <agent|none>] [--blocked-by <N,N|none>] [--label <l,l>] [--unlabel <l,l>] [--notify <who,who> | --quiet] | abso issue new "<title>" [--description "..."] [--parent <N>] [--lines <file>:<from>-<to>@<version>] [--agent <agent>] [--blocked-by <N,N>] [--notify <who,who>] [--label <l,l>] [--attach <file,file>]',
395+ 'abso issue <N> --copy-to <project> [--clean <file>] [--dry-run] | abso issue <N> [--comment "..." [--attach <file,file>] | --object "..." | --drop | --reopen | --done [--done-by <version>]] | abso issue <N> [--title "..."] [--description "..."] [--parent <N|none>] [--agent <agent|none>] [--blocked-by <N,N|none>] [--label <l,l>] [--unlabel <l,l>] [--notify <who,who> | --quiet] | abso issue new "<title>" [--description "..."] [--parent <N>] [--lines <file>:<from>-<to>@<version>] [--agent <agent>] [--blocked-by <N,N>] [--notify <who,who>] [--label <l,l>] [--attach <file,file>]',
393396 about:
394− "One issue: its description, Agent, Blocked by, labels, asks, comments, edits, sub-issues and watchers. --comment comments on it and --object objects; its agents hear either. --drop drops it. --reopen opens a dropped issue again. --done marks it done by hand, and --done-by <version> names the published version that did it. publish --done still marks it done too. --title, --description, --parent, --agent and --blocked-by edit it, and the edit tells its watchers (who opened it, its Agent and agents, its Reviewer, whoever was named in Notify, and whoever commented); --notify tells more people, --quiet tells nobody. --label adds labels and --unlabel takes them off (friction, area:client: lower-case letters, digits and - _ . :); a label-only edit tells nobody unless --notify names people. An issue is Blocked until each issue it's blocked by is Done. abso issue new opens one; --lines ties it to lines at a version of shared, --agent says who it's for, --notify tells people now, and --label labels it. --attach shot.png,after.png puts images on a new issue or a comment (png, jpeg, gif or webp, 10 MB each; the server checks the type by the bytes and takes out metadata such as where a photo was taken), and prints each one's id for the text to point at; the issue's page lists them with a link. abso issue draft \"<title>\" [the same fields] saves a draft instead: yours alone, with no number and no news; abso issue draft <D> [fields] changes it, --open opens it as an issue, --delete deletes it.",
397+ "One issue: its description, Agent, Blocked by, labels, asks, comments, edits, sub-issues and watchers. --comment comments on it and --object objects; its agents hear either. --drop drops it. --reopen opens a dropped issue again. --done marks it done by hand, and --done-by <version> names the published version that did it. publish --done still marks it done too. --title, --description, --parent, --agent and --blocked-by edit it, and the edit tells its watchers (who opened it, its Agent and agents, its Reviewer, whoever was named in Notify, and whoever commented); --notify tells more people, --quiet tells nobody. --label adds labels and --unlabel takes them off (friction, area:client: lower-case letters, digits and - _ . :); a label-only edit tells nobody unless --notify names people. An issue is Blocked until each issue it's blocked by is Done. abso issue new opens one; --lines ties it to lines at a version of shared, --agent says who it's for, --notify tells people now, and --label labels it. --attach shot.png,after.png puts images on a new issue or a comment (png, jpeg, gif or webp, 10 MB each; the server checks the type by the bytes and takes out metadata such as where a photo was taken), and prints each one's id for the text to point at; the issue's page lists them with a link. --copy-to <project> copies the issue into another project, with its comments, answered asks and labels, each keeping its author and time; --dry-run shows what would go and writes nothing, and --clean <file> gives cleaned texts by source id as JSON ({title, description, comments: [{id, text}], asks: [{id, question, answer}]}; a comment left out of a given list isn't copied). Copying out of a project on a live server takes an owner of that project. abso issue draft \"<title>\" [the same fields] saves a draft instead: yours alone, with no number and no news; abso issue draft <D> [fields] changes it, --open opens it as an issue, --delete deletes it.",
395398 run: runIssue,
396399 },
397400 ask: {
--- a/client/src/mcp.ts
+++ b/client/src/mcp.ts
@@ -120,12 +120,15 @@
120120 return rel === "" || (rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));
121121}
122122
123+/** The tool inputs that name files on this machine to read, comma-separated: each is confined like the folder. */
124+export const FILE_INPUTS = ["attach", "clean"] as const;
123126/**
124127 * Where a tool call runs, and what it may read: its folder and
125− * every --attach file stay inside the folder the server started in. A relative
126− * path that climbs out (..), an absolute one elsewhere, or a link out is
127− * refused, so no tool reads a file outside the project. Answers the folder, or
128− * why the call is refused.
128+ * every file a FILE_INPUTS input names stay inside the folder the server
129+ * started in. A relative path that climbs out (..), an absolute one elsewhere,
130+ * or a link out is refused, so no tool reads a file outside the project.
131+ * Answers the folder, or why the call is refused.
129132 */
130133export function confineCall(
131134 start: string,
@@ -137,15 +140,18 @@
137140 return {
138141 refused: `folder ${JSON.stringify(named)} is outside ${start}, the folder this server started in; tools run there or below`,
139142 };
140− if (typeof input.attach === "string")
141− for (const p of input.attach
143+ for (const flag of FILE_INPUTS) {
144+ const value = input[flag];
145+ if (typeof value !== "string") continue;
146+ for (const p of value
142147 .split(",")
143148 .map((x) => x.trim())
144149 .filter((x) => x !== ""))
145150 if (!inside(start, resolve(folder, p)))
146151 return {
147− refused: `--attach ${p} is outside ${start}, the folder this server started in; a tool attaches files from there or below`,
152+ refused: `--${flag} ${p} is outside ${start}, the folder this server started in; a tool reads files from there or below`,
148153 };
154+ }
149155 return { folder };
150156}
151157
--- a/client/test/client.test.ts
+++ b/client/test/client.test.ts
@@ -2657,6 +2657,8 @@
26572657 assert.match(refused({ attach: "a.txt,../x.png" }), /^--attach \.\.\/x\.png is outside/);
26582658 assert.match(refused({ attach: join(tmpdir(), "x.png") }), /is outside/);
26592659 assert.match(refused({ folder: "sub", attach: "../../x.png" }), /is outside/);
2660+ assert.match(refused({ clean: "../clean.json" }), /^--clean \.\.\/clean\.json is outside/);
2661+ assert.deepEqual(confineCall(start, { clean: "clean.json" }), { folder: start });
26602662 assert.deepEqual(confineCall(start, { folder: "sub", attach: "../a.txt" }), { folder: join(start, "sub") });
26612663 const server = mcp(start);
26622664 try {
--- a/client/test/issues.test.ts
+++ b/client/test/issues.test.ts
@@ -12,7 +12,7 @@
1212import { tmpdir } from "node:os";
1313import { join } from "node:path";
1414import { after, before, describe, it } from "node:test";
15−import { readMachineServers } from "../src/config.ts";
15+import { readConfig, readMachineServers } from "../src/config.ts";
1616import { issuesServerFor, tokenGoesTo } from "../src/core.ts";
1717import { searchLines } from "../src/issues.ts";
1818import { main } from "../src/main.ts";
@@ -26,13 +26,45 @@
2626let issuesUrl: string;
2727/** Every call the stand-in Issues server took. */
2828const seen: string[] = [];
29+/** The bodies of the copy requests it took. */
30+const copies: Record<string, unknown>[] = [];
2931const dirs: string[] = [];
3032
3133before(async () => {
3234 fake = await startFake(0, TOKEN);
3335 issues = createServer((req, res) => {
3436 seen.push(`${req.method} ${req.url}`);
35− res.writeHead(500, { "content-type": "application/json" }).end(JSON.stringify({ error: "a stand-in" }));
37+ const send = (status: number, body: unknown) =>
38+ res.writeHead(status, { "content-type": "application/json" }).end(JSON.stringify(body));
39+ if (req.method === "POST" && /\/copy$/.test(req.url ?? "")) {
40+ let raw = "";
41+ req.on("data", (c: Buffer) => (raw += c.toString("utf8")));
42+ req.on("end", () => {
43+ const body = JSON.parse(raw) as Record<string, unknown>;
44+ copies.push(body);
45+ // Issue 403 stands for a live server refusing an agent's copy.
46+ if (body.issue === 403 && body.dryRun !== true)
47+ return send(403, { error: "copying an issue out of its project takes an owner of that project" });
48+ const skipped = { comments: [4], asks: [2] };
49+ if (body.dryRun === true)
50+ return send(200, {
51+ dryRun: true,
52+ plan: {
53+ from: { project: body.from, issue: body.issue },
54+ title: "Sync is slow",
55+ edited: ["description"],
56+ labels: ["client"],
57+ closed: { how: "done" },
58+ comments: [{ edited: false }, { edited: true }],
59+ asks: [{ edited: false }],
60+ skipped,
61+ },
62+ });
63+ send(200, { ok: true, id: 31, from: { project: body.from, issue: body.issue }, skipped });
64+ });
65+ return;
66+ }
67+ send(500, { error: "a stand-in" });
3668 });
3769 await new Promise<void>((ok) => issues.listen(0, "127.0.0.1", ok));
3870 issuesUrl = `http://127.0.0.1:${(issues.address() as AddressInfo).port}`;
@@ -166,3 +198,84 @@
166198 assert.match(posts[0]!, /^POST \/p\/issues\d+\/a\/erin\/withdraw\/3$/);
167199 });
168200});
202+describe("abso issue <N> --copy-to <project>", () => {
203+ const text = async (cwd: string, argv: string[]) => {
204+ const r = await main(argv, { cwd, env: ENV(), write: () => {} });
205+ return { exit: r.exit, out: r.stdout + r.stderr };
206+ };
208+ it("a dry run asks the other project's copy route for the plan, and says nothing was written", async () => {
209+ const gil = await folder("gil");
210+ const before = seen.length;
211+ const r = await text(gil, ["issue", "12", "--copy-to", "core", "--dry-run"]);
212+ assert.equal(r.exit, 0, r.out);
213+ assert.deepEqual(seen.slice(before), ["POST /p/core/a/gil/copy"]);
214+ const from = (copies.at(-1) as { from: string }).from;
215+ assert.match(from, /^issues\d+$/);
216+ assert.deepEqual(copies.at(-1), { from, issue: 12, dryRun: true });
217+ assert.equal(
218+ r.out.trimEnd(),
219+ [
220+ `A dry run: nothing was written. Copying ${from} issue 12 into core would make:`,
221+ ` "Sync is slow", done (description edited when copied)`,
222+ " 2 comments (1 edited), 1 answered ask, labelled client",
223+ " not copied: comments 4; asks 2 (open asks, and what --clean left out)",
224+ "Run it again without --dry-run to copy it.",
225+ ].join("\n"),
226+ );
227+ });
229+ it("copies with the cleaned texts --clean gives, by source id", async () => {
230+ const gil = await folder("gil");
231+ writeFileSync(
232+ join(gil, "clean.json"),
233+ JSON.stringify({ description: "Cleaned.", comments: [{ id: 1 }, { id: 3, text: "Cleaned too." }] }),
234+ );
235+ const r = await text(gil, ["issue", "12", "--copy-to", "core", "--clean", "clean.json"]);
236+ assert.equal(r.exit, 0, r.out);
237+ const from = (copies.at(-1) as { from: string }).from;
238+ assert.deepEqual(copies.at(-1), {
239+ description: "Cleaned.",
240+ comments: [{ id: 1 }, { id: 3, text: "Cleaned too." }],
241+ from,
242+ issue: 12,
243+ });
244+ assert.match(
245+ r.out,
246+ new RegExp(`^Copied ${from} issue 12 to core issue 31\\. Its comments and asks keep their authors`),
247+ );
248+ });
250+ it("says a dry run still works when the server refuses the copy", async () => {
251+ const gil = await folder("gil");
252+ const r = await text(gil, ["issue", "403", "--copy-to", "core"]);
253+ assert.equal(r.exit, 1, r.out);
254+ assert.match(r.out, /takes an owner of that project\. --dry-run still shows what would go\./);
255+ });
257+ it("refuses mistakes before any call", async () => {
258+ const gil = await folder("gil");
259+ writeFileSync(join(gil, "bad.json"), JSON.stringify({ from: "elsewhere" }));
260+ const before = seen.length;
261+ for (const [argv, why] of [
262+ [["issue", "12", "--copy-to", "core", "--comment", "x"], /--copy-to goes alone .* not with --comment/],
263+ [["issue", "12", "--dry-run"], /--clean and --dry-run go with --copy-to <project>/],
264+ [["issue", "12", "--copy-to", "core", "--clean", "nope.json"], /--clean nope\.json: no such file/],
265+ [
266+ ["issue", "12", "--copy-to", "core", "--clean", "bad.json"],
267+ /from isn't one of title, description, comments, asks/,
268+ ],
269+ ] as const) {
270+ const r = await text(gil, [...argv]);
271+ assert.notEqual(r.exit, 0, argv.join(" "));
272+ assert.match(r.out, why);
273+ }
274+ const { project } = readConfig(gil);
275+ assert.match(
276+ (await text(gil, ["issue", "12", "--copy-to", project])).out,
277+ /issue 12 is already in issues\d+; --copy-to names another project/,
278+ );
279+ assert.equal(seen.length, before, "nothing reached the Issues server");
280+ });
281+});