things-api 0.15.0 → 0.16.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/README.md +4 -4
- package/dist/audit/schema.d.ts +8 -0
- package/dist/audit/schema.js.map +1 -1
- package/dist/cli/commands/install-skill.js +9 -2
- package/dist/cli/commands/install-skill.js.map +1 -1
- package/dist/cli/commands/repeat-flags.d.ts +11 -1
- package/dist/cli/commands/repeat-flags.js +23 -0
- package/dist/cli/commands/repeat-flags.js.map +1 -1
- package/dist/cli/commands/todo.js +49 -2
- package/dist/cli/commands/todo.js.map +1 -1
- package/dist/cli/commands/writes.js +182 -61
- package/dist/cli/commands/writes.js.map +1 -1
- package/dist/cli/help.js +14 -11
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/read-driver.d.ts +2 -2
- package/dist/cli/skill.d.ts +24 -0
- package/dist/cli/skill.js +40 -0
- package/dist/cli/skill.js.map +1 -1
- package/dist/client.d.ts +53 -12
- package/dist/client.js +6 -1
- package/dist/client.js.map +1 -1
- package/dist/contracts.d.ts +1 -1
- package/dist/contracts.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +132 -31
- package/dist/mcp/server.js.map +1 -1
- package/dist/model/entities.d.ts +35 -0
- package/dist/model/entities.js.map +1 -1
- package/dist/read/detail.js +49 -1
- package/dist/read/detail.js.map +1 -1
- package/dist/read/queries.d.ts +12 -0
- package/dist/read/queries.js +14 -0
- package/dist/read/queries.js.map +1 -1
- package/dist/read/shape.d.ts +25 -22
- package/dist/read/shape.js +81 -55
- package/dist/read/shape.js.map +1 -1
- package/dist/read/stage.d.ts +5 -5
- package/dist/read/stage.js +2 -2
- package/dist/read/views.d.ts +1 -1
- package/dist/read/views.js +4 -4
- package/dist/surface-copy.d.ts +2 -2
- package/dist/surface-copy.js +2 -2
- package/dist/write/batch.d.ts +28 -3
- package/dist/write/batch.js +162 -46
- package/dist/write/batch.js.map +1 -1
- package/dist/write/clone.d.ts +4 -0
- package/dist/write/clone.js +531 -0
- package/dist/write/clone.js.map +1 -0
- package/dist/write/commands.js +90 -4
- package/dist/write/commands.js.map +1 -1
- package/dist/write/guards.d.ts +1 -1
- package/dist/write/guards.js +33 -5
- package/dist/write/guards.js.map +1 -1
- package/dist/write/make-repeating-project.d.ts +2 -3
- package/dist/write/make-repeating-project.js +2 -73
- package/dist/write/make-repeating-project.js.map +1 -1
- package/dist/write/move.js +8 -1
- package/dist/write/move.js.map +1 -1
- package/dist/write/operations.d.ts +131 -9
- package/dist/write/operations.js +4 -1
- package/dist/write/operations.js.map +1 -1
- package/dist/write/pipeline.d.ts +38 -0
- package/dist/write/pipeline.js +68 -3
- package/dist/write/pipeline.js.map +1 -1
- package/dist/write/pre-state.js +7 -1
- package/dist/write/pre-state.js.map +1 -1
- package/dist/write/preserve-modified.d.ts +55 -0
- package/dist/write/preserve-modified.js +106 -0
- package/dist/write/preserve-modified.js.map +1 -0
- package/dist/write/promote-clone.d.ts +32 -0
- package/dist/write/promote-clone.js +620 -0
- package/dist/write/promote-clone.js.map +1 -0
- package/dist/write/resolution-timestamps.js +22 -0
- package/dist/write/resolution-timestamps.js.map +1 -1
- package/dist/write/reversibility.js +27 -14
- package/dist/write/reversibility.js.map +1 -1
- package/dist/write/undo.d.ts +11 -1
- package/dist/write/undo.js +126 -10
- package/dist/write/undo.js.map +1 -1
- package/dist/write/vectors/simulator.js +32 -1
- package/dist/write/vectors/simulator.js.map +1 -1
- package/dist/write/vectors/ui-certification.d.ts +1 -1
- package/dist/write/vectors/ui-certification.js +10 -3
- package/dist/write/vectors/ui-certification.js.map +1 -1
- package/package.json +1 -1
- package/skills/things-cli/SKILL.md +3 -2
- package/skills/things-cli/references/banner.md +1 -1
- package/skills/things-cli/references/contracts.md +17 -9
- package/skills/things-cli/references/data-model.md +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
|
-
import { addRepeatRuleFlags, repeatRuleFlagsFromOpts } from "./repeat-flags.js";
|
|
2
|
+
import { addRepeatCalendarFlags, addRepeatingRuleFieldsFromOpts, addRepeatRuleFlags, repeatRuleFlagsFromOpts, } from "./repeat-flags.js";
|
|
3
3
|
import { aggregateExitCode, blockedCode, capabilitiesTable, ClockError, describeConfig, errorEnvelope, ExitCode, getConfigKey, mutationWireData, okEnvelope, openThings, OP_ID_RE, outcomeFailed, ReferenceResolutionError, saveConfigKey, splitWhenSugar, ThingsDbNotFoundError, ThingsDbOpenError, verifyFailedCode, } from "../../index.js";
|
|
4
4
|
import { usageError } from "../read-driver.js";
|
|
5
5
|
import { dim } from "../style.js";
|
|
@@ -8,6 +8,12 @@ function addWriteFlags(cmd) {
|
|
|
8
8
|
.option("--json", "emit versioned JSON envelope on stdout")
|
|
9
9
|
.option("--db <path>", "explicit database path")
|
|
10
10
|
.option("--dry-run", "preview the planned change and its expected effect; nothing executes")
|
|
11
|
+
.option("--preserve-modified", "keep this change off the modification-date timeline: capture each pre-existing edited " +
|
|
12
|
+
"item's modification date and restore it (to the whole second) after the change, so a " +
|
|
13
|
+
"changes/watch query keyed on it does not surface the edit. A no-op on a pure create. " +
|
|
14
|
+
"Safe with Things Cloud: the restored date syncs to your other devices and stays put, so " +
|
|
15
|
+
"the item stays off the timeline everywhere — unless another device edits the same item " +
|
|
16
|
+
"at nearly the same time, which re-dates it.")
|
|
11
17
|
.option("--vector <id>", "force how the change is delivered: url-scheme | applescript | shortcuts | ui")
|
|
12
18
|
.option("--allow-disruptive", "permit changes that briefly steal window focus")
|
|
13
19
|
.option("--allow-very-disruptive", "permit changes that visibly drive the Things UI")
|
|
@@ -88,6 +94,7 @@ function writeOptionsFrom(opts, extra = {}) {
|
|
|
88
94
|
...(opts.actor !== undefined && { actor: opts.actor }),
|
|
89
95
|
...(opts.dangerouslyDriveGui === true && { dangerouslyDriveGui: true }),
|
|
90
96
|
...(opts.opId !== undefined && { opId: opts.opId }),
|
|
97
|
+
...(opts.preserveModified === true && { preserveModified: true }),
|
|
91
98
|
...extra,
|
|
92
99
|
};
|
|
93
100
|
}
|
|
@@ -234,6 +241,23 @@ async function runWrite(opts, fn, emitFn = emitResult) {
|
|
|
234
241
|
client?.close();
|
|
235
242
|
}
|
|
236
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* TTY disclosure for `--preserve-modified` on a verified ok result: a dim line
|
|
246
|
+
* naming how many pre-existing rows' modification date was restored (kept off
|
|
247
|
+
* the `changes`/watch timeline), plus a stderr warning per row the best-effort
|
|
248
|
+
* restore could not neutralize. Silent when the flag did no work (the field is
|
|
249
|
+
* absent — a pure create, or an already-silent op).
|
|
250
|
+
*/
|
|
251
|
+
function emitPreserveNote(result) {
|
|
252
|
+
if (result.preservedModified === undefined)
|
|
253
|
+
return;
|
|
254
|
+
const failed = result.preserveFailures ?? [];
|
|
255
|
+
const tail = failed.length > 0 ? `; ${failed.length} could not be restored (see warnings)` : "";
|
|
256
|
+
process.stdout.write(dim(` preserved modification date on ${result.preservedModified} item(s) — kept off the changes timeline${tail}\n`));
|
|
257
|
+
for (const f of failed) {
|
|
258
|
+
process.stderr.write(`warning: preserve-modified: ${f.uuid}: ${f.detail}\n`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
237
261
|
function emitResult(result, opts, meta) {
|
|
238
262
|
switch (result.kind) {
|
|
239
263
|
case "bounce-aborted": {
|
|
@@ -265,6 +289,7 @@ function emitResult(result, opts, meta) {
|
|
|
265
289
|
? "already applied — matched op-id in the change history, not re-run"
|
|
266
290
|
: `vector=${result.vector}, tier=${result.tier}, verified`;
|
|
267
291
|
process.stdout.write(`ok ${result.op}${uuid} (${status})\n`);
|
|
292
|
+
emitPreserveNote(result);
|
|
268
293
|
}
|
|
269
294
|
process.exitCode = ExitCode.Ok;
|
|
270
295
|
return;
|
|
@@ -680,6 +705,11 @@ function group(program, name, description) {
|
|
|
680
705
|
return program.command(name).description(description);
|
|
681
706
|
}
|
|
682
707
|
const containerRef = (value) => value === undefined ? undefined : { uuid: value, title: value };
|
|
708
|
+
/** The clone-specific args (`--title` / `--preserve-created`) for todo/project clone. */
|
|
709
|
+
const cloneArgs = (opts) => ({
|
|
710
|
+
...(opts["title"] !== undefined && { title: opts["title"] }),
|
|
711
|
+
...(opts["preserveCreated"] === true && { preserveCreated: true }),
|
|
712
|
+
});
|
|
683
713
|
export function registerWriteCommands(program) {
|
|
684
714
|
const todo = group(program, "todo", "To-do–scoped operations");
|
|
685
715
|
addCreateTagsFlag(addWriteFlags(todo
|
|
@@ -921,6 +951,21 @@ export function registerWriteCommands(program) {
|
|
|
921
951
|
"available for repeating to-dos.")).action(async (uuid, opts) => {
|
|
922
952
|
await runWrite(opts, (c) => c.write.duplicateTodo(uuid, writeOptionsFrom(opts)));
|
|
923
953
|
});
|
|
954
|
+
addDriveGuiFlag(addWriteFlags(todo
|
|
955
|
+
.command("clone <uuid>")
|
|
956
|
+
.description("Clone a to-do — a faithful content copy (title, notes, tags, when, reminder, deadline, " +
|
|
957
|
+
"checklist items and their checked state, container, and completed/canceled state with " +
|
|
958
|
+
"the exact original timestamp). The clone is a new capture: a new uuid, created now, at " +
|
|
959
|
+
"its container's usual position; the clone's uuid is printed on success. Refuses a " +
|
|
960
|
+
"trashed source (restore it first). A repeating template is cloned as a NEW repeating " +
|
|
961
|
+
"series (its content plus the source's rule, minted fresh — no instances copied); this " +
|
|
962
|
+
"drives the app (requires --dangerously-drive-gui) and refuses a rule the Repeat dialog " +
|
|
963
|
+
"cannot express. Undo trashes the clone (a template clone trashes the new series).")
|
|
964
|
+
.option("--title <text>", "give the clone a different title (default: the source's title)")
|
|
965
|
+
.option("--preserve-created", "copy the source's creation date onto the clone (minute resolution) instead of now"))).action(async (uuid, opts) => {
|
|
966
|
+
const clone = cloneArgs(opts);
|
|
967
|
+
await runWrite(opts, (c) => c.write.cloneTodo(uuid, clone, writeOptionsFrom(opts)));
|
|
968
|
+
});
|
|
924
969
|
addCreateTagsFlag(addWriteFlags(todo
|
|
925
970
|
.command("tags <uuid>")
|
|
926
971
|
.description("Set or extend a to-do's tags. --set REPLACES the full tag set (an empty value " +
|
|
@@ -1042,36 +1087,39 @@ export function registerWriteCommands(program) {
|
|
|
1042
1087
|
// --- ui vector: GUI-driven transforms (two-key gated) --------------------
|
|
1043
1088
|
const REPEAT_FREQ_HELP = "daily | weekly | monthly | yearly";
|
|
1044
1089
|
const REPEAT_INTERVAL_HELP = "every N units (1–99)";
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1090
|
+
// make-repeating is promote-via-clone: a disposable copy is promoted and the
|
|
1091
|
+
// ORIGINAL moves to the Trash, so `things undo` reverses it (removes the new
|
|
1092
|
+
// series and restores the original).
|
|
1093
|
+
addDriveGuiFlag(addRepeatRuleFlags(addWriteFlags(todo
|
|
1094
|
+
.command("make-repeating <uuid>")
|
|
1095
|
+
.description("Turn a plain to-do into a repeating one. A disposable copy is promoted and the " +
|
|
1096
|
+
"ORIGINAL is moved to the Trash — so `things undo` reverses it (it removes the new " +
|
|
1097
|
+
"series and restores the original). The new template's uuid is printed. Set the rule " +
|
|
1098
|
+
"with the flags below; see `things help repeating`.")
|
|
1099
|
+
.requiredOption("--frequency <freq>", REPEAT_FREQ_HELP)
|
|
1100
|
+
.requiredOption("--interval <n>", REPEAT_INTERVAL_HELP)))).action(async (uuid, opts) => {
|
|
1101
|
+
const frequency = opts["frequency"];
|
|
1102
|
+
await runWrite(opts, (c) => c.write.makeRepeatingTodo(uuid, {
|
|
1103
|
+
frequency,
|
|
1104
|
+
interval: Number(opts["interval"]),
|
|
1105
|
+
...repeatRuleFlagsFromOpts(opts, frequency),
|
|
1106
|
+
}, writeOptionsFrom(opts)));
|
|
1107
|
+
});
|
|
1108
|
+
addDriveGuiFlag(addRepeatRuleFlags(addWriteFlags(todo
|
|
1109
|
+
.command("reschedule-repeat <uuid>")
|
|
1110
|
+
.description("Change an existing repeating to-do's rule in place (the item keeps its identity). Set " +
|
|
1111
|
+
"the new rule with the flags below; see `things help repeating`. `things undo` " +
|
|
1112
|
+
"restores the previous rule.")
|
|
1113
|
+
.requiredOption("--frequency <freq>", REPEAT_FREQ_HELP)
|
|
1114
|
+
.requiredOption("--interval <n>", REPEAT_INTERVAL_HELP)))).action(async (uuid, opts) => {
|
|
1115
|
+
const frequency = opts["frequency"];
|
|
1116
|
+
await runWrite(opts, (c) => c.write.run("todo.reschedule-repeat", {
|
|
1117
|
+
uuid,
|
|
1118
|
+
frequency,
|
|
1119
|
+
interval: Number(opts["interval"]),
|
|
1120
|
+
...repeatRuleFlagsFromOpts(opts, frequency),
|
|
1121
|
+
}, writeOptionsFrom(opts)));
|
|
1122
|
+
});
|
|
1075
1123
|
for (const [verb, op, desc] of [
|
|
1076
1124
|
[
|
|
1077
1125
|
"pause-repeat",
|
|
@@ -1205,7 +1253,7 @@ export function registerWriteCommands(program) {
|
|
|
1205
1253
|
return c.write.moveHeading({ uuid: proj.uuid }, headings, placement, writeOptionsFrom(opts));
|
|
1206
1254
|
});
|
|
1207
1255
|
});
|
|
1208
|
-
addWriteFlags(project
|
|
1256
|
+
addDriveGuiFlag(addWriteFlags(project
|
|
1209
1257
|
.command("move-heading-to-project <project> <heading>")
|
|
1210
1258
|
.requiredOption("--to <project>", "destination project (uuid or unique title)")
|
|
1211
1259
|
.description("Move a heading — WITH its to-dos — to a DIFFERENT project. This is the cross-project " +
|
|
@@ -1215,14 +1263,14 @@ export function registerWriteCommands(program) {
|
|
|
1215
1263
|
"once with `things config set ui.enabled true` and pass --dangerously-drive-gui. Fails " +
|
|
1216
1264
|
"closed when the heading title is shared by another heading in the project, or the " +
|
|
1217
1265
|
"destination title by another project (the drive addresses both by title). No undo — " +
|
|
1218
|
-
"move it back to reverse.")).action(async (projectRef, sel, opts) => {
|
|
1266
|
+
"move it back to reverse."))).action(async (projectRef, sel, opts) => {
|
|
1219
1267
|
await runWrite(opts, (c) => {
|
|
1220
1268
|
const proj = c.resolve.project(projectRef);
|
|
1221
1269
|
const dest = c.resolve.project(String(opts["to"]));
|
|
1222
1270
|
return c.write.moveHeadingToProject({ uuid: proj.uuid }, sel, { uuid: dest.uuid }, writeOptionsFrom(opts));
|
|
1223
1271
|
});
|
|
1224
1272
|
});
|
|
1225
|
-
addWriteFlags(project
|
|
1273
|
+
addDriveGuiFlag(addWriteFlags(project
|
|
1226
1274
|
.command("dissolve-heading <project> <heading>")
|
|
1227
1275
|
.description("Dissolve a heading — remove it but KEEP its to-dos, which become direct children of the " +
|
|
1228
1276
|
"project (in the same order), NOT trashed. This is the opposite of deleting: nothing is " +
|
|
@@ -1230,7 +1278,7 @@ export function registerWriteCommands(program) {
|
|
|
1230
1278
|
"Shortcuts heading-delete cascade, which TRASH the children. GUI-ONLY (drives the " +
|
|
1231
1279
|
"heading row's ellipsis Delete): enable it once with `things config set ui.enabled true` " +
|
|
1232
1280
|
"and pass --dangerously-drive-gui. Fails closed when the heading title is shared by " +
|
|
1233
|
-
"another heading in the project. No undo — re-create the heading and move the to-dos back.")).action(async (projectRef, sel, opts) => {
|
|
1281
|
+
"another heading in the project. No undo — re-create the heading and move the to-dos back."))).action(async (projectRef, sel, opts) => {
|
|
1234
1282
|
await runWrite(opts, (c) => {
|
|
1235
1283
|
const proj = c.resolve.project(projectRef);
|
|
1236
1284
|
const h = c.resolve.heading(proj.uuid, sel);
|
|
@@ -1272,11 +1320,11 @@ export function registerWriteCommands(program) {
|
|
|
1272
1320
|
}
|
|
1273
1321
|
addDriveGuiFlag(addRepeatRuleFlags(addWriteFlags(project
|
|
1274
1322
|
.command("make-repeating <ref>")
|
|
1275
|
-
.description("Turn a project into a repeating one.
|
|
1276
|
-
"
|
|
1277
|
-
"
|
|
1278
|
-
"
|
|
1279
|
-
"flags below; see `things help repeating`.")
|
|
1323
|
+
.description("Turn a project into a repeating one. A disposable copy is promoted and the ORIGINAL is " +
|
|
1324
|
+
"moved to the Trash — so `things undo` reverses it (it removes the new series and " +
|
|
1325
|
+
"restores the original). Refuses a project that holds a nested repeating template. An " +
|
|
1326
|
+
"Anytime project with no area is moved to Someday first (a cleanup-free intermediate " +
|
|
1327
|
+
"step, shown in --dry-run). Set the rule with the flags below; see `things help repeating`.")
|
|
1280
1328
|
.requiredOption("--frequency <freq>", REPEAT_FREQ_HELP)
|
|
1281
1329
|
.requiredOption("--interval <n>", REPEAT_INTERVAL_HELP)))).action(async (uuid, opts) => {
|
|
1282
1330
|
const frequency = opts["frequency"];
|
|
@@ -1288,30 +1336,73 @@ export function registerWriteCommands(program) {
|
|
|
1288
1336
|
...repeatRuleFlagsFromOpts(opts, frequency),
|
|
1289
1337
|
}, writeOptionsFrom(opts)));
|
|
1290
1338
|
});
|
|
1291
|
-
addDriveGuiFlag(addWriteFlags(project
|
|
1339
|
+
addDriveGuiFlag(addRepeatCalendarFlags(addWriteFlags(project
|
|
1292
1340
|
.command("add-repeating <title>")
|
|
1293
|
-
.description("Create a project and turn it into a repeating series in ONE call. Two
|
|
1294
|
-
"
|
|
1295
|
-
"is promoted (which drives the GUI). Give --area to place it, or omit
|
|
1296
|
-
"Someday. The new repeating project's uuid is printed
|
|
1341
|
+
.description("Create a project and turn it into a repeating series in ONE call. Two legs: the project " +
|
|
1342
|
+
"is created (notes/area/when/deadline/child to-dos) and PERSISTS even if the promote " +
|
|
1343
|
+
"refuses; then it is promoted (which drives the GUI). Give --area to place it, or omit " +
|
|
1344
|
+
"it to create in Someday. The new repeating project's uuid is printed; `things undo` " +
|
|
1345
|
+
"removes the created series (trash-both).")
|
|
1297
1346
|
.option("--notes <text>", "notes body")
|
|
1298
1347
|
.option("--area <ref>", "destination area (uuid or unique name)")
|
|
1348
|
+
.option("--when <value>", "today | evening | anytime | someday | YYYY-MM-DD")
|
|
1299
1349
|
.option("--deadline <date>", "YYYY-MM-DD")
|
|
1300
1350
|
.option("--todo <title>", "initial child to-do (repeatable)", collect, [])
|
|
1301
1351
|
.requiredOption("--frequency <freq>", REPEAT_FREQ_HELP)
|
|
1302
|
-
.requiredOption("--interval <n>", REPEAT_INTERVAL_HELP))).action(async (title, opts) => {
|
|
1352
|
+
.requiredOption("--interval <n>", REPEAT_INTERVAL_HELP)))).action(async (title, opts) => {
|
|
1303
1353
|
const todos = opts["todo"];
|
|
1304
1354
|
const area = containerRef(opts["area"]);
|
|
1355
|
+
const frequency = opts["frequency"];
|
|
1305
1356
|
if (opIdCompoundRefused(opts, "project add-repeating"))
|
|
1306
1357
|
return;
|
|
1307
1358
|
await runWrite(opts, (c) => c.write.addRepeatingProject({
|
|
1308
1359
|
title,
|
|
1309
1360
|
...(opts["notes"] !== undefined && { notes: opts["notes"] }),
|
|
1310
1361
|
...(area !== undefined && { area }),
|
|
1362
|
+
...(opts["when"] !== undefined && { when: opts["when"] }),
|
|
1311
1363
|
...(opts["deadline"] !== undefined && { deadline: opts["deadline"] }),
|
|
1312
1364
|
...(todos.length > 0 && { todos }),
|
|
1313
|
-
frequency
|
|
1314
|
-
|
|
1365
|
+
...addRepeatingRuleFieldsFromOpts(opts, frequency, Number(opts["interval"])),
|
|
1366
|
+
}, writeOptionsFrom(opts)));
|
|
1367
|
+
});
|
|
1368
|
+
addDriveGuiFlag(addRepeatCalendarFlags(addWriteFlags(todo
|
|
1369
|
+
.command("add-repeating <title>")
|
|
1370
|
+
.description("Create a to-do and turn it into a repeating series in ONE call. Two legs: the to-do is " +
|
|
1371
|
+
"created (notes/tags/when/deadline/reminder/checklist/--created-at) and PERSISTS even " +
|
|
1372
|
+
"if the promote refuses; then it is promoted (which drives the GUI). The new repeating " +
|
|
1373
|
+
"template's uuid is printed; `things undo` removes the created series (trash-both).")
|
|
1374
|
+
.option("--notes <text>", "notes body")
|
|
1375
|
+
.option("--when <value>", "today | evening | anytime | someday | YYYY-MM-DD")
|
|
1376
|
+
.option("--reminder <time>", "HH:mm reminder (needs a schedulable --when)")
|
|
1377
|
+
.option("--deadline <date>", "YYYY-MM-DD")
|
|
1378
|
+
.option("--tag <name>", "tag to attach (repeatable)", collect, [])
|
|
1379
|
+
.option("--checklist-item <title>", "checklist item (repeatable)", collect, [])
|
|
1380
|
+
.option("--project <ref>", "destination project (uuid or unique name)")
|
|
1381
|
+
.option("--area <ref>", "destination area (uuid or unique name)")
|
|
1382
|
+
.option("--heading <title>", "existing heading inside the target project")
|
|
1383
|
+
.option("--created-at <iso>", "born with this creation timestamp (ISO date or datetime; a date is noon in the effective zone)")
|
|
1384
|
+
.requiredOption("--frequency <freq>", REPEAT_FREQ_HELP)
|
|
1385
|
+
.requiredOption("--interval <n>", REPEAT_INTERVAL_HELP)))).action(async (title, opts) => {
|
|
1386
|
+
const tags = opts["tag"];
|
|
1387
|
+
const checklistItems = opts["checklistItem"];
|
|
1388
|
+
const projectRef = containerRef(opts["project"]);
|
|
1389
|
+
const area = containerRef(opts["area"]);
|
|
1390
|
+
const frequency = opts["frequency"];
|
|
1391
|
+
if (opIdCompoundRefused(opts, "todo add-repeating"))
|
|
1392
|
+
return;
|
|
1393
|
+
await runWrite(opts, (c) => c.write.addRepeatingTodo({
|
|
1394
|
+
title,
|
|
1395
|
+
...(opts["notes"] !== undefined && { notes: opts["notes"] }),
|
|
1396
|
+
...(opts["when"] !== undefined && { when: opts["when"] }),
|
|
1397
|
+
...(opts["reminder"] !== undefined && { reminder: opts["reminder"] }),
|
|
1398
|
+
...(opts["deadline"] !== undefined && { deadline: opts["deadline"] }),
|
|
1399
|
+
...(tags.length > 0 && { tags }),
|
|
1400
|
+
...(checklistItems.length > 0 && { checklistItems }),
|
|
1401
|
+
...(projectRef !== undefined && { project: projectRef }),
|
|
1402
|
+
...(area !== undefined && { area }),
|
|
1403
|
+
...(opts["heading"] !== undefined && { heading: opts["heading"] }),
|
|
1404
|
+
...(opts["createdAt"] !== undefined && { createdAt: opts["createdAt"] }),
|
|
1405
|
+
...addRepeatingRuleFieldsFromOpts(opts, frequency, Number(opts["interval"])),
|
|
1315
1406
|
}, writeOptionsFrom(opts)));
|
|
1316
1407
|
});
|
|
1317
1408
|
addWriteFlags(project
|
|
@@ -1514,6 +1605,23 @@ export function registerWriteCommands(program) {
|
|
|
1514
1605
|
"copy's uuid is printed on success. Not available for repeating projects.")).action(async (uuid, opts) => {
|
|
1515
1606
|
await runWrite(opts, (c) => c.write.duplicateProject(uuid, writeOptionsFrom(opts)));
|
|
1516
1607
|
});
|
|
1608
|
+
addDriveGuiFlag(addWriteFlags(project
|
|
1609
|
+
.command("clone <ref>")
|
|
1610
|
+
.description("Clone a project (target by uuid or unique name) — a faithful content copy: area, " +
|
|
1611
|
+
"headings, headed and root children (one import), notes and deadline, plus " +
|
|
1612
|
+
"logged/canceled children and the project's own completed/canceled state with the " +
|
|
1613
|
+
"exact original timestamps. The clone is a new capture (new uuid, created now); its " +
|
|
1614
|
+
"uuid is printed on success. Refuses a trashed source and a project holding a nested " +
|
|
1615
|
+
"repeating template (named in the refusal). A repeating-template project is cloned as " +
|
|
1616
|
+
"a NEW repeating series (its content plus the source's rule, minted fresh — no " +
|
|
1617
|
+
"instances copied); this drives the app (requires --dangerously-drive-gui) and refuses " +
|
|
1618
|
+
"a rule the Repeat dialog cannot express. Undo trashes the clone and every child it " +
|
|
1619
|
+
"minted (a template clone trashes the new series).")
|
|
1620
|
+
.option("--title <text>", "give the clone a different title (default: the source's title)")
|
|
1621
|
+
.option("--preserve-created", "copy the source's creation date onto the clone (minute resolution) instead of now"))).action(async (uuid, opts) => {
|
|
1622
|
+
const clone = cloneArgs(opts);
|
|
1623
|
+
await runWrite(opts, (c) => c.write.cloneProject(uuid, clone, writeOptionsFrom(opts)));
|
|
1624
|
+
});
|
|
1517
1625
|
addWriteFlags(project
|
|
1518
1626
|
.command("complete <ref>")
|
|
1519
1627
|
.description("Complete a project (target by uuid or unique name). Completing also completes its " +
|
|
@@ -1701,23 +1809,27 @@ export function registerWriteCommands(program) {
|
|
|
1701
1809
|
.description("Run MANY mutations from JSONL (file, or stdin when omitted/'-'): one op per line, " +
|
|
1702
1810
|
'{"op": "<kind>", "params": {...}, "options": {...}} — see `things capabilities` for ' +
|
|
1703
1811
|
"op kinds and params. Ops run sequentially and independently — NO transactions; a " +
|
|
1704
|
-
"failure does not roll back earlier ops.
|
|
1812
|
+
"failure does not roll back earlier ops. A statically-invalid line (bad shape, unknown " +
|
|
1813
|
+
"op, a $ref to an undeclared/forward tempId, a duplicate tempId) refuses the WHOLE " +
|
|
1814
|
+
"batch before anything runs, naming every bad line. Otherwise ops run and per-op " +
|
|
1815
|
+
"results stream as JSONL. Per-op " +
|
|
1705
1816
|
"options carry the confirmation flags (acknowledgeChecklistReset, " +
|
|
1706
1817
|
"acknowledgeProjectReopen, dangerouslyPermanent, acknowledgeTagSubtree). " +
|
|
1707
1818
|
"CHAINING: an op that creates something may carry a `tempId` (a handle like " +
|
|
1708
1819
|
'"proj1"); a LATER op references that new uuid as "$proj1" in any id/container ' +
|
|
1709
1820
|
'param (dotted "$proj1.instance"/"$proj1.replaced" reach a repeating op\'s spawned ' +
|
|
1710
1821
|
"instance / replaced source). A tempId is valid only on a creating op (not tag.add — " +
|
|
1711
|
-
"reference a tag by title) and unique per batch
|
|
1712
|
-
"
|
|
1713
|
-
"
|
|
1714
|
-
"`tempIdMapping` (handle → uuid) and
|
|
1715
|
-
"`things undo --txn <undoToken>`. " +
|
|
1716
|
-
"
|
|
1717
|
-
"
|
|
1718
|
-
"
|
|
1822
|
+
"reference a tag by title) and unique per batch. IDEMPOTENCY: a line's `opId` makes " +
|
|
1823
|
+
"resubmission safe — a matching earlier success is reported already-applied, not " +
|
|
1824
|
+
"re-created (put an opId on EVERY line so a stopped batch can be resubmitted verbatim " +
|
|
1825
|
+
"to resume). The trailing summary line adds `tempIdMapping` (handle → uuid) and " +
|
|
1826
|
+
"`undoToken` — undo the WHOLE batch with `things undo --txn <undoToken>`. " +
|
|
1827
|
+
"By DEFAULT a runtime failure STOPS the batch (later lines reported not-run, with resume " +
|
|
1828
|
+
"guidance in the summary); --continue-on-error runs past failures. --dry-run plans " +
|
|
1829
|
+
"everything without executing. Exit (worst failure wins): 0 all ok · 3 any " +
|
|
1830
|
+
"verify-failed/invalid · 4 any blocked · 5 any drift-blocked · 6 any unsupported.")
|
|
1719
1831
|
.option("--dry-run", "plan every op; execute nothing")
|
|
1720
|
-
.option("--
|
|
1832
|
+
.option("--continue-on-error", "run past a failed op instead of stopping (default: stop)")
|
|
1721
1833
|
.option("--json", "JSONL results + summary on stdout (also the default)")
|
|
1722
1834
|
.option("--db <path>", "explicit database path")
|
|
1723
1835
|
.option("--actor <name>", "author name recorded for the whole batch")
|
|
@@ -1758,7 +1870,7 @@ export function registerWriteCommands(program) {
|
|
|
1758
1870
|
client = openThings(opts.db ? { dbPath: opts.db } : {});
|
|
1759
1871
|
const batchResult = await client.write.batch(ops, {
|
|
1760
1872
|
...(opts.dryRun !== undefined && { dryRun: opts.dryRun }),
|
|
1761
|
-
...(opts["
|
|
1873
|
+
...(opts["continueOnError"] === true && { continueOnError: true }),
|
|
1762
1874
|
...(opts.actor !== undefined && { actor: opts.actor }),
|
|
1763
1875
|
}, (r) => {
|
|
1764
1876
|
const pre = preInvalid.find((p) => p.index === r.index);
|
|
@@ -1777,6 +1889,10 @@ export function registerWriteCommands(program) {
|
|
|
1777
1889
|
// (undo the whole submission with `things undo --txn <token>`).
|
|
1778
1890
|
...(hasMapping && { tempIdMapping: batchResult.tempIdMapping }),
|
|
1779
1891
|
...(batchResult.undoToken !== undefined && { undoToken: batchResult.undoToken }),
|
|
1892
|
+
// ADDITIVE: resume guidance when a runtime failure stopped the batch
|
|
1893
|
+
// (Change 2) — how many lines did not run and whether a verbatim
|
|
1894
|
+
// resubmission is safe.
|
|
1895
|
+
...(batchResult.resumption !== undefined && { resumption: batchResult.resumption }),
|
|
1780
1896
|
},
|
|
1781
1897
|
};
|
|
1782
1898
|
process.stdout.write(`${JSON.stringify(summary)}\n`);
|
|
@@ -1797,8 +1913,13 @@ export function registerWriteCommands(program) {
|
|
|
1797
1913
|
"author's changes (e.g. `--by mcp` to clean up after an agent), or --txn <token> " +
|
|
1798
1914
|
"to undo one exact change by the `undoToken` its result returned (immune to any " +
|
|
1799
1915
|
"changes made in between). Changes made directly in the Things app cannot be " +
|
|
1800
|
-
"undone here.
|
|
1801
|
-
"
|
|
1916
|
+
"undone here. --last/--by select the N newest NOT-YET-undone changes: a change already " +
|
|
1917
|
+
"undone is SKIPPED, so repeating `undo --last N` walks progressively deeper into " +
|
|
1918
|
+
"history rather than re-selecting the same changes. An IRREVERSIBLE change is NOT " +
|
|
1919
|
+
"skipped — it still counts toward N and is reported every pass (so you always see it " +
|
|
1920
|
+
"rather than silently reaching past it). IRREVERSIBLE changes are reported, not " +
|
|
1921
|
+
"guessed: permanent deletes and changes whose prior state is unknown. Partial " +
|
|
1922
|
+
"restores carry notes (e.g. a " +
|
|
1802
1923
|
"delete-undo lands in the Inbox de-scheduled). --dry-run shows every inverse plan " +
|
|
1803
1924
|
"without executing. Undoing a CREATED area/tag deletes it permanently — requires " +
|
|
1804
1925
|
"--dangerously-permanent. An undo is refused when the item changed outside things-api " +
|