smashspace 0.4.0 → 0.5.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/dist/smash.mjs CHANGED
@@ -3398,6 +3398,40 @@ import { createInterface } from "node:readline/promises";
3398
3398
  import { relative, join as join3, dirname as dirname3, basename } from "node:path";
3399
3399
  import { stdin, stdout } from "node:process";
3400
3400
 
3401
+ // ../../shared/assignee-id.ts
3402
+ function normalizeAssigneeName(name) {
3403
+ return name.trim().toLowerCase();
3404
+ }
3405
+ function findAssigneeByName(known, name) {
3406
+ const needle = normalizeAssigneeName(name);
3407
+ return known.find((a) => normalizeAssigneeName(a.display_name) === needle);
3408
+ }
3409
+ function hash32(input) {
3410
+ let h = 2166136261;
3411
+ for (let i = 0; i < input.length; i += 1) {
3412
+ h ^= input.charCodeAt(i);
3413
+ h = Math.imul(h, 16777619) >>> 0;
3414
+ }
3415
+ return h >>> 0;
3416
+ }
3417
+ function stableAssigneeId(kind, name) {
3418
+ const normalized = normalizeAssigneeName(name);
3419
+ const ascii = normalized.replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 32);
3420
+ const suffix = ascii.length >= 2 ? ascii : hash32(normalized).toString(36).padStart(7, "0");
3421
+ return `${kind}_${suffix}`;
3422
+ }
3423
+ function resolveAssignee(known, input) {
3424
+ const existing = input.explicitId ? known.find((a) => a.id === input.explicitId) : findAssigneeByName(known, input.name);
3425
+ const id = input.explicitId ?? existing?.id ?? stableAssigneeId(input.kind, input.name);
3426
+ const emoji = input.emoji ?? existing?.avatar_emoji;
3427
+ return {
3428
+ kind: input.kind,
3429
+ id,
3430
+ display_name: input.name.trim(),
3431
+ ...emoji ? { avatar_emoji: emoji } : {}
3432
+ };
3433
+ }
3434
+
3401
3435
  // ../../shared/board-registry.ts
3402
3436
  var BOARD_ID_PATTERN = /^(?:board_|b_|s_)[a-z0-9]+$/i;
3403
3437
  var URL_BOARD_PATTERN = /^(https?:\/\/[^/]+)\/(?:board|space)\/((?:board_|b_|s_)[a-z0-9]+)/i;
@@ -4135,7 +4169,7 @@ cardCmd.command("move <cardId>").description("Move a card to a list (and optiona
4135
4169
  );
4136
4170
  cardCmd.command("delete <cardId>").description("Delete a card").action(async (cardId) => {
4137
4171
  await api(`/api/cards/${cardId}`, { method: "DELETE" });
4138
- console.log(`\u2713 card ${cardId} deleted`);
4172
+ console.log(`\u2713 card ${cardId} archived (restore with: smash archive restore ${cardId})`);
4139
4173
  });
4140
4174
  cardCmd.command("search <query>").description(
4141
4175
  "Search cards by case-insensitive substring match (title + description). Use --board to search one board, or set SMASH_BOARDS env var to search all registered boards."
@@ -4225,6 +4259,43 @@ cardCmd.command("comment <cardId> <body>").description("Add a comment to a card"
4225
4259
  function collectRepeated(value, previous) {
4226
4260
  return [...previous, value];
4227
4261
  }
4262
+ program2.command("cards").description(
4263
+ "List cards on the resolved board \u2014 light by default (no description). Filter by list/assignee, pick columns with --fields."
4264
+ ).option("-b, --board <label>", "board label from config").option("--board-id <id>", "explicit board id (bypass config)").option("-l, --list <name>", "only cards in this list (name or id)").option("--assignee <idOrName>", "only cards assigned to this id or display name").option(
4265
+ "--fields <list>",
4266
+ "comma-separated columns (default: id,title,listId,listTitle,updatedAt). Add description only when you need bodies."
4267
+ ).option("--limit <n>", "max cards per page (default 100, max 500)").option("--cursor <cursor>", "continue from a previous response's cursor").action(async (opts) => {
4268
+ const ctx = resolveContext(opts);
4269
+ const params = new URLSearchParams();
4270
+ if (opts.list)
4271
+ params.set("list", opts.list);
4272
+ if (opts.assignee)
4273
+ params.set("assignee", opts.assignee);
4274
+ if (opts.fields)
4275
+ params.set("fields", opts.fields);
4276
+ if (opts.limit)
4277
+ params.set("limit", opts.limit);
4278
+ if (opts.cursor)
4279
+ params.set("cursor", opts.cursor);
4280
+ const qs = params.toString();
4281
+ const result = await api(
4282
+ `/api/boards/${ctx.boardId}/cards${qs ? `?${qs}` : ""}`,
4283
+ void 0,
4284
+ ctx.baseUrl
4285
+ );
4286
+ if (getOpts().json) {
4287
+ console.log(JSON.stringify(result, null, 2));
4288
+ return;
4289
+ }
4290
+ for (const card of result.cards) {
4291
+ const listTitle = typeof card.listTitle === "string" ? `[${card.listTitle}] ` : "";
4292
+ console.log(`${listTitle}${String(card.title ?? "")} (${String(card.id ?? "")})`);
4293
+ }
4294
+ console.log(
4295
+ `
4296
+ ${result.cards.length} of ${result.total}${result.cursor ? ` next: --cursor ${result.cursor}` : ""}`
4297
+ );
4298
+ });
4228
4299
  program2.command("inbox").description(
4229
4300
  `New comments across the resolved board (${CONFIG_FILENAME}). Poll with --since <cursor> to read only what you have not seen.`
4230
4301
  ).option("-b, --board <label>", "board label from config").option("--board-id <id>", "explicit board id (bypass config)").option("--since <iso>", "only comments created after this ISO timestamp (exclusive)").option("--to <id>", "only comments addressed to this assignee id").option("--limit <n>", "max comments to read (default 100, max 500)").action(async (opts) => {
@@ -4698,23 +4769,31 @@ assigneesCmd.command("add <cardId>").description("Append a single assignee (read
4698
4769
  console.error("--name must not be empty");
4699
4770
  process.exit(1);
4700
4771
  }
4701
- const id = opts.id ?? `${opts.kind}_${Math.random().toString(36).slice(2, 10)}`;
4702
4772
  const detail = await api(`/api/cards/${cardId}`);
4703
4773
  const current = detail.card.assignees ?? [];
4704
- const next = [
4774
+ const board = await api(
4775
+ `/api/boards/${detail.card.boardId}/cards?fields=assignees&limit=500`
4776
+ );
4777
+ const known = [
4705
4778
  ...current,
4706
- {
4707
- kind: opts.kind,
4708
- id,
4709
- display_name: opts.name,
4710
- ...opts.emoji ? { avatar_emoji: opts.emoji } : {}
4711
- }
4779
+ ...board.cards.flatMap(
4780
+ (c) => Array.isArray(c.assignees) ? c.assignees : []
4781
+ )
4712
4782
  ];
4783
+ const entry = resolveAssignee(known, {
4784
+ kind: opts.kind,
4785
+ name: opts.name,
4786
+ explicitId: opts.id,
4787
+ emoji: opts.emoji
4788
+ });
4789
+ const next = [...current, entry];
4713
4790
  const card = await api(`/api/cards/${cardId}`, {
4714
4791
  method: "PATCH",
4715
4792
  body: JSON.stringify({ assignees: next })
4716
4793
  });
4717
- show(card, [`\u2713 card ${card.id} assignees now has ${next.length} entries`]);
4794
+ show(card, [
4795
+ `\u2713 card ${card.id} assignees now has ${next.length} entries (${entry.display_name} \u2192 ${entry.id})`
4796
+ ]);
4718
4797
  });
4719
4798
  assigneesCmd.command("update <cardId> <assigneeId>").description("Change an assignee's icon (emoji) and/or display name").option("--emoji <emoji>", "New avatar_emoji").option("--no-emoji", "Remove the avatar_emoji (fall back to the default icon)").option("--name <name>", "New display_name").action(async (cardId, assigneeId, opts) => {
4720
4799
  if (opts.emoji === void 0 && opts.name === void 0) {
@@ -15509,7 +15509,7 @@ var tools = [
15509
15509
  },
15510
15510
  {
15511
15511
  name: "smash_get_board",
15512
- description: "Get full board detail including lists, cards (with labelIds), and labels.",
15512
+ description: "Get full board detail including lists, cards (with labelIds), and labels. This returns every card's full description and can run to six figures of characters on a busy board \u2014 prefer smash_list_cards when you only need to find cards, and come back here for the whole structure.",
15513
15513
  inputSchema: {
15514
15514
  type: "object",
15515
15515
  properties: {
@@ -15653,7 +15653,7 @@ var tools = [
15653
15653
  },
15654
15654
  {
15655
15655
  name: "smash_set_agent_meta",
15656
- description: "Set or clear a card's agent_meta (structured field for external agents like Claude Code). Pass agentMeta=null to clear. Common shape: {primary_agent, status: 'idle'|'working'|'waiting_review'|'blocked'|'done', turn: 'human'|'agent'|'blocked', started_at, updated_at, progress (0..1), current_step}. avatar_emoji is shown on the board's cards, so give each agent a distinct emoji (and reuse the same id) to make ownership visible at a glance. Extra keys are accepted for forward-compat.",
15656
+ description: "Set or clear a card's agent_meta (structured field for external agents like Claude Code). Pass agentMeta=null to clear. Common shape: {primary_agent, status: 'idle'|'working'|'waiting_review'|'blocked'|'done', turn: 'human'|'agent'|'blocked', started_at, updated_at, progress (0..1), current_step}. REUSE THE SAME id for the same role across cards (e.g. always 'platform', not a fresh random id): ids are how anyone filters cards later, and a role that gets a new id per card cannot be filtered at all. Check smash_list_cards with fields=['assignees'] to see which ids the board already uses. avatar_emoji is shown on the board's cards, so give each agent a distinct emoji (and reuse the same id) to make ownership visible at a glance. Extra keys are accepted for forward-compat.",
15657
15657
  inputSchema: {
15658
15658
  type: "object",
15659
15659
  properties: {
@@ -15701,6 +15701,41 @@ var tools = [
15701
15701
  body: JSON.stringify({ externalRefs: args.externalRefs ?? null })
15702
15702
  })
15703
15703
  },
15704
+ {
15705
+ name: "smash_list_cards",
15706
+ description: "List a board's cards WITHOUT their descriptions \u2014 use this instead of smash_get_board when you only need to find cards. smash_get_board returns every card body and can exceed a tool-output limit on a busy board. Filter with `list` and `assignee` (matches an assignee id or display name), and pick columns with `fields` (default: id, title, listId, listTitle, updatedAt). Pass fields including 'description' only when you truly need bodies; otherwise fetch one card with smash_get_card. Paginate with the returned `cursor`.",
15707
+ inputSchema: {
15708
+ type: "object",
15709
+ properties: {
15710
+ boardId: { type: "string" },
15711
+ list: { type: "string", description: "List name (case-insensitive) or list id" },
15712
+ assignee: { type: "string", description: "Assignee id or display name" },
15713
+ fields: {
15714
+ type: "array",
15715
+ items: { type: "string" },
15716
+ description: "Columns to return: id, boardId, title, description, listId, listTitle, position, dueAt, labelIds, checklistTitle, agentMeta, externalRefs, assignees, customData, createdAt, updatedAt"
15717
+ },
15718
+ limit: { type: "number", description: "Max cards per page (default 100, max 500)" },
15719
+ cursor: { type: "string", description: "Cursor from a previous response" }
15720
+ },
15721
+ required: ["boardId"]
15722
+ },
15723
+ handler: async (args) => {
15724
+ const params = new URLSearchParams();
15725
+ if (typeof args.list === "string" && args.list)
15726
+ params.set("list", args.list);
15727
+ if (typeof args.assignee === "string" && args.assignee)
15728
+ params.set("assignee", args.assignee);
15729
+ if (Array.isArray(args.fields) && args.fields.length > 0)
15730
+ params.set("fields", args.fields.join(","));
15731
+ if (typeof args.limit === "number")
15732
+ params.set("limit", String(args.limit));
15733
+ if (typeof args.cursor === "string" && args.cursor)
15734
+ params.set("cursor", args.cursor);
15735
+ const qs = params.toString();
15736
+ return api(`/api/boards/${args.boardId}/cards${qs ? `?${qs}` : ""}`);
15737
+ }
15738
+ },
15704
15739
  {
15705
15740
  name: "smash_set_assignees",
15706
15741
  description: "Set or clear a card's assignees (humans + external agents listed together). Pass assignees=null to clear. Each entry: {kind: 'human'|'agent', id: string, display_name: string, avatar_emoji?: string}. Extra keys are accepted for forward-compat.",
@@ -15753,7 +15788,7 @@ var tools = [
15753
15788
  },
15754
15789
  {
15755
15790
  name: "smash_delete_card",
15756
- description: "Soft-delete a card.",
15791
+ description: "Archive a card (soft delete). It leaves the board but is kept: it shows up in the space's archived column and smash_restore_card puts it back. Nothing is destroyed here \u2014 smash_permanently_delete_card is the irreversible one.",
15757
15792
  inputSchema: {
15758
15793
  type: "object",
15759
15794
  properties: { cardId: { type: "string" } },
@@ -15761,7 +15796,11 @@ var tools = [
15761
15796
  },
15762
15797
  handler: async (args) => {
15763
15798
  await api(`/api/cards/${args.cardId}`, { method: "DELETE" });
15764
- return { ok: true };
15799
+ return {
15800
+ ok: true,
15801
+ archived: true,
15802
+ note: `Archived, not destroyed. Restore with smash_restore_card({cardId: "${args.cardId}"}), or find it in the space's \u5B8C\u4E86\u6E08\u307F / Archive column.`
15803
+ };
15765
15804
  }
15766
15805
  },
15767
15806
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smashspace",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "SmashSpace CLI + MCP — operate SmashSpace boards from your terminal, Claude Code, Cursor, and Codex.",
5
5
  "type": "module",
6
6
  "bin": {