listspace 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,12 +2,18 @@
2
2
 
3
3
  One version runs through the CLI, the skill and the Claude Code plugin, so each entry covers all three.
4
4
 
5
+ ## 0.8.0
6
+
7
+ - `listspace attach <item> <file> --new-version`: the file becomes the newest version of the current file on the item with the same name, and the old one is kept as an older version (the same as **Upload a new version** in the app). With no current file of that name the file is added as a new file and the output says so; with more than one the command stops before sending anything and lists their ids. `--version-of <attachment id>` picks the file to replace (one file per command). The output says `as version 2`. Large files carry it too. Nothing changed on the server: it already took `replaces_attachment_id`, so this works against the current deploy.
8
+ - The skill's CLI and file pages describe both flags.
9
+
5
10
  ## 0.7.0
6
11
 
7
12
  - Upload links for several files in one call: `get_upload_link` takes `files`, up to 25 entries each with `item_id`, `filename` and `size_bytes`, and the REST API has `POST /v1/upload-links` for the same. `listspace attach` uses it when it sends two or more files over 8 MB: it asks for the links of a few files at a time, right before sending them: a file joins a chunk only while the bytes queued ahead of it stay under about 500 MB, since a link for a large file holds room in storage and its upload must start within 15 minutes. A link that has run out or runs out within a minute is replaced by a fresh one before its upload. The CLI sends the files that got a link, names the ones that did not, and goes back to one link a file on a server that does not have the route yet. Publish this CLI after the server (the functions) is deployed.
8
13
  - The upload limit counts files and bytes, not calls: 200 upload links or 10 GB an hour per account. A refusal says when to come back (`Try again after 14:32 UTC (in 12 minutes)`), with `retry_after_seconds` and `retry_at` in the error, and the CLI passes it on.
9
14
  - The answer to an upload says in `attachment.is_cover` whether the file became the item's cover.
10
15
  - The skill's file pages tell agents to send a batch in one call and to wait for the time the error names.
16
+ - The skill's file pages and tool table cover `copy_attachment` (a file of another item of the same board, copied on the server, no upload) and pictures inside an item's text (`![alt](attachment:ITEM_ID/ATTACHMENT_ID)` in `update_item`, read back as `![alt](picture:NAME)`). Publish this after the server is deployed.
11
17
 
12
18
  ## 0.6.0
13
19
 
package/README.md CHANGED
@@ -60,7 +60,7 @@ Write (the board's agent access level decides what is made and what waits in the
60
60
  comment <item> <text> Add a comment (markdown) to an item.
61
61
  move <item> <list>
62
62
  done <item> Move to the board's done list.
63
- list add <board> <title> [--kind info|capture|backlog|todo|doing|done]
63
+ list add <board> <title> [--kind info|capture|backlog|todo|doing|review|done]
64
64
  list rename <list> <title> Here <list> is a list id.
65
65
  undo <request_id> Take back one of your own calls.
66
66
  Writes take --inbox --reason "<why>" to suggest instead of change.
@@ -71,7 +71,8 @@ Every MCP tool (the same tools, levels and results as the MCP server)
71
71
  call <tool> ['<json>'] Run a tool with its arguments as one JSON object.
72
72
 
73
73
  Files from this computer (needs level 4, Act)
74
- attach <item> <file> [<file>...] Up to the plan's size of one file, at most 4 GB.
74
+ attach <item> <file> [<file>...] [--new-version | --version-of <attachment id>]
75
+ Up to the plan's size of one file, at most 4 GB.
75
76
 
76
77
  Work on your own (needs level 4, Act)
77
78
  next <board> [--kinds todo,backlog] [--label <id>] [--no-move] [--ttl <minutes>]
@@ -117,6 +118,14 @@ npx listspace attach 2b6f0c1e-... ./contract.pdf ./screenshots/footer.png
117
118
 
118
119
  The type comes from the extension: images (jpg, png, gif, webp, svg), PDF, Word, Excel and PowerPoint files, text, Markdown, CSV, JSON, archives (zip, rar, 7z), audio and video. Each file can be as large as the plan of the board's owner allows (Free 25 MB, Pro 2 GB, a team's boards 5 GB), at most 4 GB from the CLI. A file over 8 MB goes straight to Listspace's file storage, sent from disk, and is put on the item when it has arrived. Every file is checked before the first one is sent. Attaching needs level 4 (Act) on the board: a file cannot wait in the Inbox.
119
120
 
121
+ Uploading a file again adds a second file by default. To make it the next version of the file already on the item, add `--new-version`:
122
+
123
+ ```bash
124
+ npx listspace attach 2b6f0c1e-... ./contract.pdf --new-version
125
+ ```
126
+
127
+ The current file with the same name becomes version 2 and the old one is kept as an older version, with its comments. If the item has no current file with that name, the file is added as a new file and the output says so. If two current files share the name, nothing is sent: the command lists them, and `--version-of <attachment id>` picks one (one file per command; the ids are in `npx listspace call list_attachments --json '{"item_id": "..."}'`). It follows the same rules as **Upload a new version** in the app, including storage, the virus check and the bin.
128
+
120
129
  ## Output for agents and scripts
121
130
 
122
131
  Every command takes `--json` and then prints the API's JSON instead of text:
@@ -73,7 +73,8 @@ function union(pick, a, b) {
73
73
  }
74
74
 
75
75
  // src/schema.ts
76
- var LIST_KINDS = ["info", "capture", "backlog", "todo", "doing", "done"];
76
+ var LIST_KINDS = ["info", "capture", "backlog", "todo", "doing", "review", "done"];
77
+ var NEXT_KINDS = LIST_KINDS.filter((kind) => kind !== "review");
77
78
  var listKind = nullable(literal(...LIST_KINDS));
78
79
  var level = object({
79
80
  effective: literal(1, 2, 3, 4, 5),
@@ -226,7 +227,9 @@ var attached = object({
226
227
  filename: string,
227
228
  mime_type: nullable(string),
228
229
  size_bytes: nullable(number),
229
- url: string
230
+ url: string,
231
+ /** 1 for a file never replaced, 2 and up for a newer version; null from a server that does not say. */
232
+ version: withDefault(nullable(number), null)
230
233
  })
231
234
  });
232
235
  var largeUploadLink = object({
@@ -239,9 +242,12 @@ var largeUploadLinks = object({
239
242
  links: array(object({ index: number, upload_url: string, finish_url: nullable(string), expires_at: withDefault(nullable(string), null) })),
240
243
  refused: array(object({ index: number, filename: string, message: string }))
241
244
  });
245
+ var currentFiles = object({
246
+ attachments: array(object({ id: string, filename: string, version: withDefault(number, 1) }))
247
+ });
242
248
 
243
249
  // src/version.ts
244
- var VERSION = "0.7.0";
250
+ var VERSION = "0.8.0";
245
251
 
246
252
  // src/api.ts
247
253
  var DEFAULT_API_URL = "https://api.listspace.app/v1";
@@ -714,7 +720,8 @@ function formatRelease(result) {
714
720
  function formatAttached(results) {
715
721
  return results.map(({ attachment, level: level2 }) => {
716
722
  const size = attachment.size_bytes === null ? "" : ` (${formatSize(attachment.size_bytes)})`;
717
- return `Attached "${attachment.filename}"${size} to ${attachment.item_id} ${attachment.id} (${levelText(level2)}).`;
723
+ const version = attachment.version !== null && attachment.version > 1 ? ` as version ${attachment.version}` : "";
724
+ return `Attached "${attachment.filename}"${size}${version} to ${attachment.item_id} ${attachment.id} (${levelText(level2)}).`;
718
725
  }).join("\n");
719
726
  }
720
727
 
@@ -876,6 +883,45 @@ async function releaseCommand(client, input) {
876
883
  const answer = await client.data("DELETE", `/items/${path(input.item)}/claim`, releaseResult);
877
884
  return { raw: answer.raw, text: formatRelease(answer.value) };
878
885
  }
886
+ var replacesField = (file) => file.replaces === void 0 ? {} : { replaces_attachment_id: file.replaces };
887
+ async function resolveVersions(client, item2, files, version) {
888
+ switch (version.kind) {
889
+ case "new_file":
890
+ return { files: [...files], notes: [] };
891
+ case "of": {
892
+ if (!UUID.test(version.attachmentId)) return fail({ kind: "usage", message: `"${version.attachmentId}" is not an attachment id. Attachment ids come from \`listspace call list_attachments --json '{"item_id": "${item2}"}'\`.` });
893
+ if (files.length !== 1) return fail({ kind: "usage", message: "--version-of replaces one file, so give it exactly one file." });
894
+ return { files: files.map((file) => ({ ...file, replaces: version.attachmentId })), notes: [] };
895
+ }
896
+ case "same_name": {
897
+ const names = files.map((file) => file.fileName);
898
+ const twice = names.find((name, index) => names.indexOf(name) !== index);
899
+ if (twice !== void 0) return fail({ kind: "usage", message: `${twice} is given twice, and --new-version would make the second one replace the first. Send one at a time.` });
900
+ const current = (await client.data("GET", `/items/${path(item2)}/attachments`, currentFiles)).value.attachments;
901
+ const out = [];
902
+ const notes = [];
903
+ for (const file of files) {
904
+ const same = current.filter((entry) => entry.filename === file.fileName);
905
+ const [only, ...others] = same;
906
+ if (only === void 0) {
907
+ out.push(file);
908
+ notes.push(`No current file named "${file.fileName}" on this item, so it was added as a new file.`);
909
+ } else if (others.length > 0) {
910
+ const lines = same.map((entry) => ` ${entry.id} ${entry.filename} (version ${entry.version})`).join("\n");
911
+ return fail({ kind: "usage", message: `${same.length} current files on this item are named "${file.fileName}". Nothing was sent. Pick one with --version-of <attachment id>:
912
+ ${lines}` });
913
+ } else {
914
+ out.push({ ...file, replaces: only.id });
915
+ }
916
+ }
917
+ return { files: out, notes };
918
+ }
919
+ default: {
920
+ const exhaustive = version;
921
+ return exhaustive;
922
+ }
923
+ }
924
+ }
879
925
  async function prepareFiles(paths, read) {
880
926
  const out = [];
881
927
  for (const filePath of paths) {
@@ -915,16 +961,18 @@ var CHUNK_FILES = 10;
915
961
  var STALE_MS = 6e4;
916
962
  async function attachCommand(client, input) {
917
963
  if (!UUID.test(input.item)) return fail({ kind: "usage", message: `"${input.item}" is not an item id. Item ids come from \`listspace board <board>\`.` });
964
+ const resolved = await resolveVersions(client, input.item, input.files, input.version ?? { kind: "new_file" });
965
+ const files = resolved.files;
918
966
  const results = [];
919
967
  const raw = [];
920
968
  const skipped = [];
921
969
  const links = /* @__PURE__ */ new Map();
922
970
  let batches = true;
923
- for (const [position, file] of input.files.entries()) {
971
+ for (const [position, file] of files.entries()) {
924
972
  try {
925
973
  let made;
926
974
  if (file.content.kind === "blob") {
927
- if (batches && !links.has(file)) batches = await askForLinks(client, input.item, input.files.slice(position), links);
975
+ if (batches && !links.has(file)) batches = await askForLinks(client, input.item, files.slice(position), links);
928
976
  const got = links.get(file);
929
977
  if (got !== void 0 && "refused" in got) {
930
978
  skipped.push({ name: file.fileName, reason: got.refused });
@@ -950,7 +998,7 @@ async function attachCommand(client, input) {
950
998
  message: `Attached ${done === "" ? "nothing" : done}; not attached: ${skipped.map((s) => `${s.name} (${s.reason})`).join("; ")}`
951
999
  });
952
1000
  }
953
- return { raw: { data: raw }, text: formatAttached(results) };
1001
+ return { raw: { data: raw }, text: [formatAttached(results), ...resolved.notes].join("\n") };
954
1002
  }
955
1003
  async function askForLinks(client, item2, rest, links) {
956
1004
  const next = rest.filter((file) => file.content.kind === "blob" && !links.has(file));
@@ -962,7 +1010,7 @@ async function askForLinks(client, item2, rest, links) {
962
1010
  chunk.push(file);
963
1011
  queued += file.content.kind === "blob" ? file.content.sizeBytes : 0;
964
1012
  }
965
- const body = { files: chunk.map((file) => ({ item_id: item2, filename: file.fileName, size_bytes: file.content.kind === "blob" ? file.content.sizeBytes : 0 })) };
1013
+ const body = { files: chunk.map((file) => ({ item_id: item2, filename: file.fileName, size_bytes: file.content.kind === "blob" ? file.content.sizeBytes : 0, ...replacesField(file) })) };
966
1014
  let answer;
967
1015
  try {
968
1016
  answer = (await client.data("POST", "/upload-links", largeUploadLinks, { body })).value;
@@ -983,12 +1031,12 @@ async function askForLinks(client, item2, rest, links) {
983
1031
  async function attachOne(client, item2, file, made) {
984
1032
  switch (file.content.kind) {
985
1033
  case "bytes": {
986
- const body = { filename: file.fileName, mime_type: file.mimeType, content_base64: Buffer.from(file.content.bytes).toString("base64") };
1034
+ const body = { filename: file.fileName, mime_type: file.mimeType, content_base64: Buffer.from(file.content.bytes).toString("base64"), ...replacesField(file) };
987
1035
  return client.data("POST", `/items/${path(item2)}/attachments`, attached, { body });
988
1036
  }
989
1037
  case "blob": {
990
1038
  const stale = made !== void 0 && made.expires_at !== null && Date.parse(made.expires_at) - Date.now() < STALE_MS;
991
- const link = made === void 0 || stale ? (await client.data("POST", `/items/${path(item2)}/upload-links`, largeUploadLink, { body: { filename: file.fileName, size_bytes: file.content.sizeBytes } })).value : made;
1039
+ const link = made === void 0 || stale ? (await client.data("POST", `/items/${path(item2)}/upload-links`, largeUploadLink, { body: { filename: file.fileName, size_bytes: file.content.sizeBytes, ...replacesField(file) } })).value : made;
992
1040
  if (link.finish_url === null) return fail({ kind: "unexpected", message: "Listspace answered without a link to finish a large upload. Update the CLI, or the server is older than it." });
993
1041
  await client.putToStorage(link.upload_url, file.content.blob);
994
1042
  return client.finishUpload(link.finish_url, attached);
@@ -1196,7 +1244,7 @@ Write (the board's agent access level decides what is made and what waits in the
1196
1244
  comment <item> <text> Add a comment (markdown) to an item.
1197
1245
  move <item> <list>
1198
1246
  done <item> Move to the board's done list.
1199
- list add <board> <title> [--kind info|capture|backlog|todo|doing|done]
1247
+ list add <board> <title> [--kind info|capture|backlog|todo|doing|review|done]
1200
1248
  list rename <list> <title> Here <list> is a list id.
1201
1249
  undo <request_id> Take back one of your own calls.
1202
1250
  Writes take --inbox --reason "<why>" to suggest instead of change.
@@ -1210,13 +1258,22 @@ Every MCP tool (the same tools, levels and results as the MCP server)
1210
1258
  idempotency_key, so a retry never makes it twice.
1211
1259
 
1212
1260
  Files from this computer (needs level 4, Act; a file cannot wait in the Inbox)
1213
- attach <item> <file> [<file>...]
1261
+ attach <item> <file> [<file>...] [--new-version | --version-of <attachment id>]
1214
1262
  Upload files to an item: images, PDF, Office
1215
1263
  files, text, Markdown, CSV, JSON, archives, audio
1216
1264
  and video. Up to the plan's size of one file
1217
1265
  (Free 25 MB, Pro 2 GB, a team's boards 5 GB), at
1218
1266
  most 4 GB from here; over 8 MB the file goes
1219
1267
  straight to file storage.
1268
+ --new-version: a file with the name of a current
1269
+ file on the item becomes its newest version (the
1270
+ old one is kept as an older version). No file of
1271
+ that name: it is added as a new file, and the
1272
+ output says so. Several files of that name: it
1273
+ stops and lists them.
1274
+ --version-of: the attachment id of the current
1275
+ file to replace (one file; ids come from
1276
+ call list_attachments).
1220
1277
 
1221
1278
  Work on your own (needs level 4, Act; other agents leave a claimed item alone)
1222
1279
  next <board> [--kinds todo,backlog] [--label <id>] [--no-move] [--ttl <minutes>]
@@ -1231,7 +1288,7 @@ Work on your own (needs level 4, Act; other agents leave a claimed item alone)
1231
1288
  the item renews it.
1232
1289
 
1233
1290
  <board> is an id or a title, <list> an id, a title or a kind (todo, doing, done,
1234
- info, capture, backlog), <item> an item id.
1291
+ info, capture, backlog, review), <item> an item id.
1235
1292
 
1236
1293
  Options
1237
1294
  --json Print the server's JSON (for agents and scripts).
@@ -1270,7 +1327,9 @@ var OPTIONS = {
1270
1327
  kinds: { type: "string" },
1271
1328
  label: { type: "string", multiple: true },
1272
1329
  "no-move": { type: "boolean" },
1273
- ttl: { type: "string" }
1330
+ ttl: { type: "string" },
1331
+ "new-version": { type: "boolean" },
1332
+ "version-of": { type: "string" }
1274
1333
  };
1275
1334
  var usage = (message) => fail({ kind: "usage", message: `${message} Run \`listspace --help\`.` });
1276
1335
  function positionals(command, given, names) {
@@ -1295,13 +1354,20 @@ function ttlFrom(flags) {
1295
1354
  if (minutes === null) return usage("--ttl is a whole number of minutes from 5 to 1440.");
1296
1355
  return minutes;
1297
1356
  }
1357
+ function versionFrom(flags) {
1358
+ const sameName = flags["new-version"] === true;
1359
+ const picked = flags["version-of"];
1360
+ if (sameName && picked !== void 0) return usage("Give --new-version or --version-of <attachment id>, not both.");
1361
+ if (picked !== void 0) return { kind: "of", attachmentId: picked.trim() };
1362
+ return sameName ? { kind: "same_name" } : { kind: "new_file" };
1363
+ }
1298
1364
  function kindsFrom(flags) {
1299
1365
  if (flags.kinds === void 0) return [];
1300
1366
  const kinds = [];
1301
1367
  for (const part of flags.kinds.split(",")) {
1302
1368
  const wanted = part.trim().toLowerCase();
1303
- const kind = LIST_KINDS.find((candidate) => candidate === wanted);
1304
- if (kind === void 0) return usage(`--kinds takes a comma list of ${LIST_KINDS.join(", ")}; "${part.trim()}" is not one.`);
1369
+ const kind = NEXT_KINDS.find((candidate) => candidate === wanted);
1370
+ if (kind === void 0) return usage(`--kinds takes a comma list of ${NEXT_KINDS.join(", ")}; "${part.trim()}" is not one.`);
1305
1371
  if (!kinds.includes(kind)) kinds.push(kind);
1306
1372
  }
1307
1373
  return kinds;
@@ -1467,8 +1533,9 @@ async function dispatch(command, args, flags, io, dir) {
1467
1533
  const [item2, ...paths] = args;
1468
1534
  if (item2 === void 0 || paths.length === 0) return usage("`attach` takes <item> and one or more files.");
1469
1535
  if (flags.inbox === true) return usage("A file cannot wait in the Inbox: attaching needs level 4 (Act) on the board.");
1536
+ const version = versionFrom(flags);
1470
1537
  const files = await prepareFiles(paths, io.readFile);
1471
- return attachCommand(await clientFor(io, dir), { item: item2, files });
1538
+ return attachCommand(await clientFor(io, dir), { item: item2, files, version });
1472
1539
  }
1473
1540
  case "undo": {
1474
1541
  const [requestId] = positionals(command, args, ["request_id"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listspace",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Listspace from the command line: the agentic project memory, for people and coding agents.",
5
5
  "keywords": [
6
6
  "listspace",
@@ -41,7 +41,7 @@
41
41
  "scripts": {
42
42
  "build": "esbuild src/main.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/listspace.mjs --banner:js=\"#!/usr/bin/env node\"",
43
43
  "typecheck": "tsc --noEmit",
44
- "test": "tsc -p tsconfig.test.json && node --test build/test/api.test.js build/test/cli.test.js build/test/config.test.js build/test/commands.test.js build/test/attach.test.js build/test/tools.test.js",
44
+ "test": "tsc -p tsconfig.test.json && node --test build/test/api.test.js build/test/cli.test.js build/test/config.test.js build/test/commands.test.js build/test/attach.test.js build/test/attachVersion.test.js build/test/tools.test.js",
45
45
  "prepublishOnly": "npm run typecheck && npm test && npm run build"
46
46
  },
47
47
  "devDependencies": {