@robbeverhelst/do 1.89.0 → 1.90.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.
Files changed (2) hide show
  1. package/dist/do.js +89 -17
  2. package/package.json +1 -1
package/dist/do.js CHANGED
@@ -25,7 +25,8 @@ var GLOBAL_BOOLEAN_FLAGS = [
25
25
  "verbose",
26
26
  "help",
27
27
  "version",
28
- "allow-destructive"
28
+ "allow-destructive",
29
+ "dry-run"
29
30
  ];
30
31
  var SHORT_ALIASES = {
31
32
  h: "help",
@@ -4341,7 +4342,6 @@ var projects = pgTable("projects", {
4341
4342
  tenantId: text("tenant_id").notNull().references(() => tenants.id),
4342
4343
  status: projectStatus("status").notNull().default("planning"),
4343
4344
  progress: integer("progress").notNull().default(0),
4344
- notes: text("notes"),
4345
4345
  startAt: timestamp("start_at", { withTimezone: true }),
4346
4346
  dueAt: timestamp("due_at", { withTimezone: true }),
4347
4347
  areaId: text("area_id").references(() => areas.id)
@@ -4399,7 +4399,6 @@ var occurrenceStatus = pgEnum("occurrence_status", [
4399
4399
  var tasks = pgTable("tasks", {
4400
4400
  id: text("id").primaryKey().references(() => nodes.id),
4401
4401
  tenantId: text("tenant_id").notNull().references(() => tenants.id),
4402
- notes: text("notes"),
4403
4402
  status: taskStatus("status").notNull().default("todo"),
4404
4403
  starred: boolean("starred").notNull().default(false),
4405
4404
  allDay: boolean("all_day").notNull().default(true),
@@ -19802,7 +19801,8 @@ var taskViewSchema = taskSchema.extend({
19802
19801
  parentId: ulidSchema.nullable(),
19803
19802
  createdAt: exports_external.coerce.date(),
19804
19803
  updatedAt: exports_external.coerce.date(),
19805
- deletedAt: exports_external.coerce.date().nullable()
19804
+ deletedAt: exports_external.coerce.date().nullable(),
19805
+ notes: exports_external.string().nullable()
19806
19806
  });
19807
19807
  var taskProjectIdSchema = ulidSchema.nullish();
19808
19808
  var taskAreaIdSchema = ulidSchema.nullish();
@@ -19818,7 +19818,8 @@ var createTaskInputSchema = createInsertSchema(tasks, {
19818
19818
  }).omit({ tenantId: true, recurrenceRuleId: true, startAt: true }).extend({
19819
19819
  title: exports_external.string().min(1),
19820
19820
  parentId: ulidSchema.nullish(),
19821
- areaName: taskAreaNameSchema
19821
+ areaName: taskAreaNameSchema,
19822
+ notes: exports_external.string().nullish()
19822
19823
  });
19823
19824
  var updateTaskInputSchema = createUpdateSchema(tasks, {
19824
19825
  scheduledAt: exports_external.coerce.date().nullish(),
@@ -19829,7 +19830,8 @@ var updateTaskInputSchema = createUpdateSchema(tasks, {
19829
19830
  areaId: taskAreaIdSchema
19830
19831
  }).omit({ id: true, tenantId: true, recurrenceRuleId: true, startAt: true }).extend({
19831
19832
  title: exports_external.string().min(1).optional(),
19832
- parentId: ulidSchema.nullish()
19833
+ parentId: ulidSchema.nullish(),
19834
+ notes: exports_external.string().nullish()
19833
19835
  }).strict();
19834
19836
  var taskListFilterSchema = exports_external.enum(["all", "unsorted", "starred"]);
19835
19837
  // ../../packages/schema/src/contracts/habits.ts
@@ -20084,7 +20086,8 @@ var createProjectInputSchema = createInsertSchema(projects, {
20084
20086
  }).omit({ tenantId: true }).extend({
20085
20087
  title: exports_external.string().min(1),
20086
20088
  parentId: ulidSchema.nullish(),
20087
- milestones: exports_external.array(projectMilestoneInputSchema).optional()
20089
+ milestones: exports_external.array(projectMilestoneInputSchema).optional(),
20090
+ notes: exports_external.string().nullish()
20088
20091
  });
20089
20092
  var updateProjectInputSchema = createUpdateSchema(projects, {
20090
20093
  progress: exports_external.number().int().min(0).max(100).optional(),
@@ -20094,7 +20097,8 @@ var updateProjectInputSchema = createUpdateSchema(projects, {
20094
20097
  }).omit({ id: true, tenantId: true }).extend({
20095
20098
  title: exports_external.string().min(1).optional(),
20096
20099
  parentId: ulidSchema.nullish(),
20097
- milestones: exports_external.array(projectMilestoneInputSchema).optional()
20100
+ milestones: exports_external.array(projectMilestoneInputSchema).optional(),
20101
+ notes: exports_external.string().nullish()
20098
20102
  }).strict();
20099
20103
  var projectViewSchema = projectSchema.extend({
20100
20104
  title: exports_external.string(),
@@ -20102,6 +20106,7 @@ var projectViewSchema = projectSchema.extend({
20102
20106
  createdAt: exports_external.coerce.date(),
20103
20107
  updatedAt: exports_external.coerce.date(),
20104
20108
  deletedAt: exports_external.coerce.date().nullable(),
20109
+ notes: exports_external.string().nullable(),
20105
20110
  milestoneCount: exports_external.number().int().min(0),
20106
20111
  completedMilestoneCount: exports_external.number().int().min(0),
20107
20112
  taskCount: exports_external.number().int().min(0),
@@ -24132,7 +24137,7 @@ function parseCapture2(input, now) {
24132
24137
 
24133
24138
  // src/meta.ts
24134
24139
  var CLI_NAME = "do";
24135
- var VERSION = "1.89.0";
24140
+ var VERSION = "1.90.1";
24136
24141
  var API_PREFIX = "/api/v1";
24137
24142
  var DEFAULT_API_URL = "http://localhost:3001";
24138
24143
 
@@ -24547,7 +24552,7 @@ function entityOperations(e) {
24547
24552
  if (e.write?.updateSchema)
24548
24553
  ops.push("update");
24549
24554
  if (e.write?.canDelete)
24550
- ops.push("delete");
24555
+ ops.push("delete", "archive");
24551
24556
  return ops;
24552
24557
  }
24553
24558
 
@@ -24585,6 +24590,11 @@ var GLOBAL_FLAGS = [
24585
24590
  name: "allow-destructive",
24586
24591
  type: "boolean",
24587
24592
  description: "Permit a destructive verb (delete/revoke/remove-member). Off by default \u2014 a guardrail for autonomous agents."
24593
+ },
24594
+ {
24595
+ name: "dry-run",
24596
+ type: "boolean",
24597
+ description: "Preview a create/update/delete/archive (prints before/after) without writing \u2014 for agent-driven cleanup."
24588
24598
  }
24589
24599
  ];
24590
24600
  var COMMAND_SPECS = [
@@ -25363,6 +25373,19 @@ function shortDate(iso) {
25363
25373
 
25364
25374
  // src/today.ts
25365
25375
  var OPEN_STATUSES = new Set(["todo", "in_progress"]);
25376
+ function isTaskLike(value) {
25377
+ return typeof value === "object" && value !== null && typeof value.id === "string";
25378
+ }
25379
+ function normalizeTasks(response) {
25380
+ if (Array.isArray(response))
25381
+ return response.filter(isTaskLike);
25382
+ if (response && typeof response === "object") {
25383
+ const data = response.data;
25384
+ if (Array.isArray(data))
25385
+ return data.filter(isTaskLike);
25386
+ }
25387
+ return [];
25388
+ }
25366
25389
  function toDate(value) {
25367
25390
  if (value == null)
25368
25391
  return null;
@@ -25379,7 +25402,7 @@ var pad = (n) => String(n).padStart(2, "0");
25379
25402
  function selectToday(tasks3, now) {
25380
25403
  const { start, end, label } = localDayBounds(now);
25381
25404
  const items = [];
25382
- for (const task of tasks3) {
25405
+ for (const task of normalizeTasks(tasks3)) {
25383
25406
  if (!OPEN_STATUSES.has(task.status))
25384
25407
  continue;
25385
25408
  const scheduled = toDate(task.scheduledAt);
@@ -25478,11 +25501,18 @@ async function dispatchEntity(entity, rest, flags, requireClient) {
25478
25501
  const id = requireArg(args, 0, "id");
25479
25502
  return { data: await client.get(`${entity.path}/${id}`), render: renderRecord };
25480
25503
  }
25504
+ const dryRun = flagBool(flags, "dry-run");
25481
25505
  if (op === "create") {
25482
25506
  const write = requireWrite(entity, "create");
25483
25507
  if (!write.createSchema)
25484
25508
  throw usageError(`\`${entity.name}\` cannot be created`);
25485
25509
  const body = parseInput(write.createSchema, { id: ulid3(), ...readDataFlag(flags) });
25510
+ if (dryRun) {
25511
+ return {
25512
+ data: { dryRun: true, op: "create", entity: entity.name, after: body },
25513
+ render: renderRecord
25514
+ };
25515
+ }
25486
25516
  return { data: await client.post(entity.path, body), render: renderRecord };
25487
25517
  }
25488
25518
  if (op === "update") {
@@ -25491,16 +25521,42 @@ async function dispatchEntity(entity, rest, flags, requireClient) {
25491
25521
  throw usageError(`\`${entity.name}\` cannot be updated`);
25492
25522
  const id = requireArg(args, 0, "id");
25493
25523
  const body = parseInput(write.updateSchema, readDataFlag(flags));
25524
+ if (dryRun) {
25525
+ const before = entity.canGet ? await client.get(`${entity.path}/${id}`) : null;
25526
+ return {
25527
+ data: {
25528
+ dryRun: true,
25529
+ op: "update",
25530
+ entity: entity.name,
25531
+ id,
25532
+ before,
25533
+ after: mergePreview(before, body),
25534
+ changes: body
25535
+ },
25536
+ render: renderRecord
25537
+ };
25538
+ }
25494
25539
  return { data: await client.patch(`${entity.path}/${id}`, body), render: renderRecord };
25495
25540
  }
25496
- if (op === "delete") {
25497
- const write = requireWrite(entity, "delete");
25541
+ if (op === "delete" || op === "archive") {
25542
+ const write = requireWrite(entity, op);
25498
25543
  if (!write.canDelete)
25499
- throw usageError(`\`${entity.name}\` cannot be deleted`);
25544
+ throw usageError(`\`${entity.name}\` cannot be ${op}d`);
25500
25545
  const id = requireArg(args, 0, "id");
25501
- assertDestructiveAllowed(flags, `delete ${entity.name} ${id}`);
25546
+ if (dryRun) {
25547
+ const before = entity.canGet ? await client.get(`${entity.path}/${id}`) : null;
25548
+ return {
25549
+ data: { dryRun: true, op, entity: entity.name, id, before, softDelete: true },
25550
+ render: renderRecord
25551
+ };
25552
+ }
25553
+ if (op === "delete")
25554
+ assertDestructiveAllowed(flags, `delete ${entity.name} ${id}`);
25502
25555
  await client.delete(`${entity.path}/${id}`);
25503
- return { data: { ok: true, deleted: id }, render: renderRecord };
25556
+ return {
25557
+ data: op === "archive" ? { ok: true, archived: id, softDelete: true } : { ok: true, deleted: id, softDelete: true },
25558
+ render: renderRecord
25559
+ };
25504
25560
  }
25505
25561
  throw usageError(`unknown operation for ${entity.name}: \`${op ?? ""}\` (use ${entityOperations(entity).join(", ")})`);
25506
25562
  }
@@ -25538,7 +25594,16 @@ var HANDLERS = {
25538
25594
  return { data: task, render: renderTask };
25539
25595
  },
25540
25596
  today: async ({ io, requireClient }) => {
25541
- const tasks3 = await requireClient().get("/tasks", { query: { filter: "all" } });
25597
+ const client = requireClient();
25598
+ const tasks3 = [];
25599
+ let cursor;
25600
+ do {
25601
+ const page = await client.getPage("/tasks", {
25602
+ query: { filter: "all", cursor }
25603
+ });
25604
+ tasks3.push(...page.data);
25605
+ cursor = page.nextCursor ?? undefined;
25606
+ } while (cursor);
25542
25607
  return {
25543
25608
  data: selectToday(tasks3, io.now()),
25544
25609
  render: renderToday
@@ -25945,6 +26010,13 @@ function requireWrite(entity, op) {
25945
26010
  }
25946
26011
  return entity.write;
25947
26012
  }
26013
+ function mergePreview(before, changes) {
26014
+ const patch = changes && typeof changes === "object" && !Array.isArray(changes) ? changes : {};
26015
+ if (before && typeof before === "object" && !Array.isArray(before)) {
26016
+ return { ...before, ...patch };
26017
+ }
26018
+ return changes;
26019
+ }
25948
26020
  function readDataFlag(flags) {
25949
26021
  const raw = flagString(flags, "data");
25950
26022
  if (raw === undefined)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robbeverhelst/do",
3
- "version": "1.89.0",
3
+ "version": "1.90.1",
4
4
  "private": false,
5
5
  "description": "do — the agent-drivable CLI over the public /api/v1 surface",
6
6
  "type": "module",