Skip to content

Commit 940d10b

Browse files
mayoalexanderclaude
andcommitted
feat(bloqs): delete-list and rename-list — creating structure with no way to correct it (#180584)
There was create-list and nothing else. A typo or a duplicate list was permanent from the CLI, while ITEMS had both delete-item and restore-item. The asymmetry was the bug: a command that creates structure with no command to correct it means every mistake is forever. Both endpoints existed the whole time — BloqListController::update and ::destroy, routed as PATCH /user/{userId}/bloqs/list/{listId} and DELETE /user/bloqs/list/{listId}. Only the surface was missing, so this is a CLI addition and nothing else. Hit for real today: `iris bloqs create` silently seeds Ideas/Todo/In Progress/Completed/Daily Diary and its output says only {success, id, name}, so setting up a client project (anomalyco#601, GTC MediGuide) produced TWO Todo lists, two In Progress and two Completed — on a board whose first reader would reasonably ask which one is real. Now cleaned up with the new command. delete-list is deliberately NOT a mirror of create-list. Creating a list costs nothing; deleting one takes ITS ITEMS WITH IT. So it: - counts the items first when --bloq-id is given, and REFUSES a non-empty list without --force, naming the count — a number is what turns "delete list 1964" from a guess into a decision - WARNS when it could not count, rather than proceeding quietly. A silently skipped safety check reads exactly like a check that passed, which is the failure mode this codebase keeps finding. Verified against the live board rather than asserted: delete-list 1964 --bloq-id 601 -> success, items_removed 0 delete-list 1974 --bloq-id 601 -> REFUSED: "has 6 item(s)" delete-list 9999999 (no bloq-id) -> warns the count was NOT checked Still open in #180584: `bloqs create` should report the lists it seeds, or take --no-default-lists. Printing them would have prevented the duplication entirely. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011wLxn8v7hD3rud1G17YjNk
1 parent ba9af7b commit 940d10b

2 files changed

Lines changed: 164 additions & 3 deletions

File tree

‎packages/opencode/capabilities.json‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"generated_note": "GENERATED by script/build-capabilities.ts — do not edit by hand. Run `bun run capabilities` to refresh.",
33
"counts": {
4-
"command": 1197,
4+
"command": 1199,
55
"how-to": 37,
66
"playbook": 41,
77
"skill": 42,
8-
"total": 1317
8+
"total": 1319
99
},
1010
"terms": {
1111
"bespoke": [
@@ -1482,7 +1482,7 @@
14821482
"atlas"
14831483
],
14841484
"run": "iris bloqs",
1485-
"haystack": "bloqs kb knowledge memory projects atlas manage knowledge bases (bloqs) — start with: iris search <query> list get export open invite links revoke-link create update ingest add-item delete-item restore-item delete publish make-public make-private create-list move-item reorder-item compose rename search attach-lead detach-lead attach-playbook detach-playbook playbooks update-item contributors items publish-pages relate unrelate relations board kanban list project workspace notes"
1485+
"haystack": "bloqs kb knowledge memory projects atlas manage knowledge bases (bloqs) — start with: iris search <query> list get export open invite links revoke-link create update ingest add-item delete-item restore-item delete publish make-public make-private create-list rename-list delete-list move-item reorder-item compose rename search attach-lead detach-lead attach-playbook detach-playbook playbooks update-item contributors items publish-pages relate unrelate relations board kanban list project workspace notes"
14861486
},
14871487
{
14881488
"kind": "command",
@@ -1556,6 +1556,14 @@
15561556
"run": "iris bloqs delete-item <item-id>",
15571557
"haystack": "bloqs delete-item rm-item remove-item delete an item from a bloq list (soft delete — restore with: iris bloqs restore-item <id>)"
15581558
},
1559+
{
1560+
"kind": "command",
1561+
"name": "bloqs delete-list",
1562+
"describe": "delete a list from a bloq (refuses a non-empty list without --force)",
1563+
"aliases": [],
1564+
"run": "iris bloqs delete-list <list-id>",
1565+
"haystack": "bloqs delete-list rm-list remove-list delete a list from a bloq (refuses a non-empty list without --force)"
1566+
},
15591567
{
15601568
"kind": "command",
15611569
"name": "bloqs detach-lead",
@@ -1708,6 +1716,14 @@
17081716
"run": "iris bloqs rename <type> <id> [name]",
17091717
"haystack": "bloqs rename mv rename a bloq, list, or item"
17101718
},
1719+
{
1720+
"kind": "command",
1721+
"name": "bloqs rename-list",
1722+
"describe": "rename a list on a bloq",
1723+
"aliases": [],
1724+
"run": "iris bloqs rename-list <list-id> <name>",
1725+
"haystack": "bloqs rename-list update-list rename a list on a bloq"
1726+
},
17111727
{
17121728
"kind": "command",
17131729
"name": "bloqs reorder-item",

‎packages/opencode/src/cli/cmd/platform-bloqs.ts‎

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,149 @@ const BloqsCreateListCommand = cmd({
14521452
},
14531453
})
14541454

1455+
/**
1456+
* Rename a list (#180584).
1457+
*
1458+
* There was create-list and nothing else, so a typo or a duplicate was permanent from the CLI —
1459+
* while ITEMS had delete-item and restore-item. The endpoints existed the whole time; only the
1460+
* surface was missing.
1461+
*/
1462+
const BloqsRenameListCommand = cmd({
1463+
command: "rename-list <list-id> <name>",
1464+
aliases: ["update-list"],
1465+
describe: "rename a list on a bloq",
1466+
builder: (yargs) =>
1467+
yargs
1468+
.positional("list-id", { describe: "list ID", type: "number", demandOption: true })
1469+
.positional("name", { describe: "new list name", type: "string", demandOption: true })
1470+
.option("json", { describe: "JSON output", type: "boolean", default: false })
1471+
.option("user-id", { describe: "user ID (or IRIS_USER_ID env)", type: "number" }),
1472+
async handler(args) {
1473+
if (!args.json) { UI.empty(); prompts.intro(`◈ Rename List #${args["list-id"]}`) }
1474+
1475+
const token = await requireAuth()
1476+
if (!token) { if (!args.json) prompts.outro("Done"); return }
1477+
1478+
const userId = await requireUserId(args["user-id"])
1479+
if (!userId) { if (!args.json) prompts.outro("Done"); return }
1480+
1481+
const spinner = args.json ? null : prompts.spinner()
1482+
spinner?.start("Renaming…")
1483+
1484+
try {
1485+
const res = await irisFetch(`/api/v1/user/${userId}/bloqs/list/${args["list-id"]}`, {
1486+
method: "PATCH",
1487+
body: JSON.stringify({ name: args.name, title: args.name }),
1488+
})
1489+
if (!res.ok) {
1490+
spinner?.stop("Failed", 1)
1491+
if (args.json) { console.log(JSON.stringify({ success: false, error: `HTTP ${res.status}` })); return }
1492+
await handleApiError(res, "Rename list")
1493+
prompts.outro("Done")
1494+
return
1495+
}
1496+
1497+
if (args.json) { console.log(JSON.stringify({ success: true, id: args["list-id"], name: args.name })); return }
1498+
spinner?.stop(`${success("✓")} Renamed to ${bold(args.name)}`)
1499+
prompts.outro("Done")
1500+
} catch (err) {
1501+
spinner?.stop("Error", 1)
1502+
if (args.json) { console.log(JSON.stringify({ success: false, error: err instanceof Error ? err.message : String(err) })); return }
1503+
prompts.log.error(err instanceof Error ? err.message : String(err))
1504+
prompts.outro("Done")
1505+
}
1506+
},
1507+
})
1508+
1509+
/**
1510+
* Delete a list (#180584).
1511+
*
1512+
* Deliberately more careful than create-list, because the two are not mirror images: creating a
1513+
* list costs nothing, and deleting one takes ITS ITEMS WITH IT. So this refuses a non-empty list
1514+
* unless --force, and says how many items it would take — a count is the one thing that turns
1515+
* "delete list 1964" from a guess into a decision.
1516+
*/
1517+
const BloqsDeleteListCommand = cmd({
1518+
command: "delete-list <list-id>",
1519+
aliases: ["rm-list", "remove-list"],
1520+
describe: "delete a list from a bloq (refuses a non-empty list without --force)",
1521+
builder: (yargs) =>
1522+
yargs
1523+
.positional("list-id", { describe: "list ID", type: "number", demandOption: true })
1524+
.option("bloq-id", { describe: "bloq ID — enables the item-count safety check", type: "number" })
1525+
.option("force", { describe: "delete even if the list has items", type: "boolean", default: false })
1526+
.option("json", { describe: "JSON output", type: "boolean", default: false })
1527+
.option("user-id", { describe: "user ID (or IRIS_USER_ID env)", type: "number" }),
1528+
async handler(args) {
1529+
if (!args.json) { UI.empty(); prompts.intro(`◈ Delete List #${args["list-id"]}`) }
1530+
1531+
const token = await requireAuth()
1532+
if (!token) { if (!args.json) prompts.outro("Done"); return }
1533+
1534+
const userId = await requireUserId(args["user-id"])
1535+
if (!userId) { if (!args.json) prompts.outro("Done"); return }
1536+
1537+
// Count first, when we can. Without a bloq id there is no cheap way to enumerate the list,
1538+
// so say that rather than implying the check passed — a silent skip of a safety check reads
1539+
// exactly like the check succeeding.
1540+
let itemCount: number | null = null
1541+
if (args["bloq-id"]) {
1542+
try {
1543+
const listsRes = await irisFetch(`/api/v1/user/${userId}/bloqs/${args["bloq-id"]}/lists`)
1544+
if (listsRes.ok) {
1545+
const body = (await listsRes.json()) as any
1546+
const lists = body?.data?.data ?? body?.data ?? body ?? []
1547+
const match = (Array.isArray(lists) ? lists : []).find(
1548+
(l: any) => Number(l.id) === Number(args["list-id"]),
1549+
)
1550+
if (match) itemCount = (match.items?.length ?? match.items_count ?? 0) as number
1551+
}
1552+
} catch {
1553+
// Leave itemCount null — reported as unknown below, never as zero.
1554+
}
1555+
}
1556+
1557+
if (itemCount !== null && itemCount > 0 && !args.force) {
1558+
const msg = `List #${args["list-id"]} has ${itemCount} item(s). Re-run with --force to delete it and them.`
1559+
if (args.json) { console.log(JSON.stringify({ success: false, error: msg, items: itemCount })); return }
1560+
prompts.log.error(msg)
1561+
prompts.outro("Done")
1562+
return
1563+
}
1564+
1565+
if (!args.json && itemCount === null) {
1566+
prompts.log.warn(
1567+
args["bloq-id"]
1568+
? "Could not read the item count — deleting without that check."
1569+
: "No --bloq-id given, so the item count was NOT checked. Items in this list go with it.",
1570+
)
1571+
}
1572+
1573+
const spinner = args.json ? null : prompts.spinner()
1574+
spinner?.start("Deleting…")
1575+
1576+
try {
1577+
const res = await irisFetch(`/api/v1/user/bloqs/list/${args["list-id"]}`, { method: "DELETE" })
1578+
if (!res.ok) {
1579+
spinner?.stop("Failed", 1)
1580+
if (args.json) { console.log(JSON.stringify({ success: false, error: `HTTP ${res.status}` })); return }
1581+
await handleApiError(res, "Delete list")
1582+
prompts.outro("Done")
1583+
return
1584+
}
1585+
1586+
if (args.json) { console.log(JSON.stringify({ success: true, id: args["list-id"], items_removed: itemCount })); return }
1587+
spinner?.stop(`${success("✓")} List #${args["list-id"]} deleted`)
1588+
prompts.outro("Done")
1589+
} catch (err) {
1590+
spinner?.stop("Error", 1)
1591+
if (args.json) { console.log(JSON.stringify({ success: false, error: err instanceof Error ? err.message : String(err) })); return }
1592+
prompts.log.error(err instanceof Error ? err.message : String(err))
1593+
prompts.outro("Done")
1594+
}
1595+
},
1596+
})
1597+
14551598
const BloqsMoveItemCommand = cmd({
14561599
command: "move-item <item-id> <target-list-id>",
14571600
describe: "move an item to a different list",
@@ -3198,6 +3341,8 @@ export const PlatformBloqsCommand = cmd({
31983341
.command(BloqsMakePublicCommand)
31993342
.command(BloqsMakePrivateCommand)
32003343
.command(BloqsCreateListCommand)
3344+
.command(BloqsRenameListCommand)
3345+
.command(BloqsDeleteListCommand)
32013346
.command(BloqsMoveItemCommand)
32023347
.command(BloqsReorderItemCommand)
32033348
.command(BloqsComposeCommand)

0 commit comments

Comments
 (0)