smashspace 0.2.0 → 0.2.1
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/README.md +1 -0
- package/dist/smash.mjs +41 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -89,6 +89,7 @@ smash scan --list "やること" # cards as JSON (id/title/list only)
|
|
|
89
89
|
smash scan --list "やること" --full # + description/agentMeta/labels — pick up work in ONE request
|
|
90
90
|
smash create "Fix signup bug" # add a card (to the first list, or --list; --desc for a body)
|
|
91
91
|
smash move <cardId> "レビュー" # move a card to a list by name
|
|
92
|
+
smash attachment add <cardId> ./out.png # upload a local file (agent-generated images, etc.)
|
|
92
93
|
smash archive <cardId> # archive (soft-delete) a card
|
|
93
94
|
smash --help # full command list (board/list/card/…)
|
|
94
95
|
```
|
package/dist/smash.mjs
CHANGED
|
@@ -3395,7 +3395,7 @@ import { randomBytes } from "node:crypto";
|
|
|
3395
3395
|
import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
3396
3396
|
import { platform as platform2 } from "node:os";
|
|
3397
3397
|
import { createInterface } from "node:readline/promises";
|
|
3398
|
-
import { relative, join as join3, dirname as dirname3 } from "node:path";
|
|
3398
|
+
import { relative, join as join3, dirname as dirname3, basename } from "node:path";
|
|
3399
3399
|
import { stdin, stdout } from "node:process";
|
|
3400
3400
|
|
|
3401
3401
|
// ../../shared/board-registry.ts
|
|
@@ -4343,7 +4343,47 @@ artifactCmd.command("delete <cardId> <artifactId>").description("Delete an artif
|
|
|
4343
4343
|
await api(`/api/cards/${cardId}/artifacts/${artifactId}`, { method: "DELETE" });
|
|
4344
4344
|
console.log(`\u2713 artifact ${artifactId} deleted`);
|
|
4345
4345
|
});
|
|
4346
|
+
var ATTACH_EXT_MIME = {
|
|
4347
|
+
png: "image/png",
|
|
4348
|
+
jpg: "image/jpeg",
|
|
4349
|
+
jpeg: "image/jpeg",
|
|
4350
|
+
gif: "image/gif",
|
|
4351
|
+
webp: "image/webp",
|
|
4352
|
+
svg: "image/svg+xml",
|
|
4353
|
+
bmp: "image/bmp",
|
|
4354
|
+
ico: "image/x-icon",
|
|
4355
|
+
pdf: "application/pdf",
|
|
4356
|
+
txt: "text/plain",
|
|
4357
|
+
md: "text/markdown",
|
|
4358
|
+
csv: "text/csv",
|
|
4359
|
+
json: "application/json",
|
|
4360
|
+
zip: "application/zip"
|
|
4361
|
+
};
|
|
4362
|
+
function guessMime(name) {
|
|
4363
|
+
const ext = name.split(".").pop()?.toLowerCase() ?? "";
|
|
4364
|
+
return ATTACH_EXT_MIME[ext] ?? "application/octet-stream";
|
|
4365
|
+
}
|
|
4346
4366
|
var attachmentCmd = program2.command("attachment").description("Card attachments");
|
|
4367
|
+
attachmentCmd.command("add <cardId> <file>").alias("upload").description("Upload a local file as a card attachment (\u2264100 MB)").action(async (cardId, filePath) => {
|
|
4368
|
+
const buf = await readFile2(filePath);
|
|
4369
|
+
const name = basename(filePath);
|
|
4370
|
+
const type = guessMime(name);
|
|
4371
|
+
const fd = new FormData();
|
|
4372
|
+
fd.append("file", new Blob([buf], { type }), name);
|
|
4373
|
+
const baseUrl = resolveBaseUrl();
|
|
4374
|
+
const token = await resolveToken(baseUrl);
|
|
4375
|
+
const res = await fetch(new URL(`/api/cards/${cardId}/attachments`, baseUrl), {
|
|
4376
|
+
method: "POST",
|
|
4377
|
+
headers: token ? { Authorization: `Bearer ${token}` } : {},
|
|
4378
|
+
body: fd
|
|
4379
|
+
});
|
|
4380
|
+
if (!res.ok) {
|
|
4381
|
+
const text = await res.text().catch(() => "");
|
|
4382
|
+
throw new Error(`API ${res.status} /api/cards/${cardId}/attachments: ${text || res.statusText}`);
|
|
4383
|
+
}
|
|
4384
|
+
const att = await res.json();
|
|
4385
|
+
show(att, [`\u2713 attached "${att.filename ?? name}" to ${cardId} (${att.id ?? "?"})`]);
|
|
4386
|
+
});
|
|
4347
4387
|
attachmentCmd.command("list <cardId>").description("List attachments on a card").action(async (cardId) => {
|
|
4348
4388
|
const items = await api(`/api/cards/${cardId}/attachments`);
|
|
4349
4389
|
show(items, [`\u2713 ${items.length} attachment(s)`]);
|