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.
Files changed (90) hide show
  1. package/README.md +4 -4
  2. package/dist/audit/schema.d.ts +8 -0
  3. package/dist/audit/schema.js.map +1 -1
  4. package/dist/cli/commands/install-skill.js +9 -2
  5. package/dist/cli/commands/install-skill.js.map +1 -1
  6. package/dist/cli/commands/repeat-flags.d.ts +11 -1
  7. package/dist/cli/commands/repeat-flags.js +23 -0
  8. package/dist/cli/commands/repeat-flags.js.map +1 -1
  9. package/dist/cli/commands/todo.js +49 -2
  10. package/dist/cli/commands/todo.js.map +1 -1
  11. package/dist/cli/commands/writes.js +182 -61
  12. package/dist/cli/commands/writes.js.map +1 -1
  13. package/dist/cli/help.js +14 -11
  14. package/dist/cli/help.js.map +1 -1
  15. package/dist/cli/read-driver.d.ts +2 -2
  16. package/dist/cli/skill.d.ts +24 -0
  17. package/dist/cli/skill.js +40 -0
  18. package/dist/cli/skill.js.map +1 -1
  19. package/dist/client.d.ts +53 -12
  20. package/dist/client.js +6 -1
  21. package/dist/client.js.map +1 -1
  22. package/dist/contracts.d.ts +1 -1
  23. package/dist/contracts.js +1 -1
  24. package/dist/index.d.ts +2 -2
  25. package/dist/index.js.map +1 -1
  26. package/dist/mcp/server.js +132 -31
  27. package/dist/mcp/server.js.map +1 -1
  28. package/dist/model/entities.d.ts +35 -0
  29. package/dist/model/entities.js.map +1 -1
  30. package/dist/read/detail.js +49 -1
  31. package/dist/read/detail.js.map +1 -1
  32. package/dist/read/queries.d.ts +12 -0
  33. package/dist/read/queries.js +14 -0
  34. package/dist/read/queries.js.map +1 -1
  35. package/dist/read/shape.d.ts +25 -22
  36. package/dist/read/shape.js +81 -55
  37. package/dist/read/shape.js.map +1 -1
  38. package/dist/read/stage.d.ts +5 -5
  39. package/dist/read/stage.js +2 -2
  40. package/dist/read/views.d.ts +1 -1
  41. package/dist/read/views.js +4 -4
  42. package/dist/surface-copy.d.ts +2 -2
  43. package/dist/surface-copy.js +2 -2
  44. package/dist/write/batch.d.ts +28 -3
  45. package/dist/write/batch.js +162 -46
  46. package/dist/write/batch.js.map +1 -1
  47. package/dist/write/clone.d.ts +4 -0
  48. package/dist/write/clone.js +531 -0
  49. package/dist/write/clone.js.map +1 -0
  50. package/dist/write/commands.js +90 -4
  51. package/dist/write/commands.js.map +1 -1
  52. package/dist/write/guards.d.ts +1 -1
  53. package/dist/write/guards.js +33 -5
  54. package/dist/write/guards.js.map +1 -1
  55. package/dist/write/make-repeating-project.d.ts +2 -3
  56. package/dist/write/make-repeating-project.js +2 -73
  57. package/dist/write/make-repeating-project.js.map +1 -1
  58. package/dist/write/move.js +8 -1
  59. package/dist/write/move.js.map +1 -1
  60. package/dist/write/operations.d.ts +131 -9
  61. package/dist/write/operations.js +4 -1
  62. package/dist/write/operations.js.map +1 -1
  63. package/dist/write/pipeline.d.ts +38 -0
  64. package/dist/write/pipeline.js +68 -3
  65. package/dist/write/pipeline.js.map +1 -1
  66. package/dist/write/pre-state.js +7 -1
  67. package/dist/write/pre-state.js.map +1 -1
  68. package/dist/write/preserve-modified.d.ts +55 -0
  69. package/dist/write/preserve-modified.js +106 -0
  70. package/dist/write/preserve-modified.js.map +1 -0
  71. package/dist/write/promote-clone.d.ts +32 -0
  72. package/dist/write/promote-clone.js +620 -0
  73. package/dist/write/promote-clone.js.map +1 -0
  74. package/dist/write/resolution-timestamps.js +22 -0
  75. package/dist/write/resolution-timestamps.js.map +1 -1
  76. package/dist/write/reversibility.js +27 -14
  77. package/dist/write/reversibility.js.map +1 -1
  78. package/dist/write/undo.d.ts +11 -1
  79. package/dist/write/undo.js +126 -10
  80. package/dist/write/undo.js.map +1 -1
  81. package/dist/write/vectors/simulator.js +32 -1
  82. package/dist/write/vectors/simulator.js.map +1 -1
  83. package/dist/write/vectors/ui-certification.d.ts +1 -1
  84. package/dist/write/vectors/ui-certification.js +10 -3
  85. package/dist/write/vectors/ui-certification.js.map +1 -1
  86. package/package.json +1 -1
  87. package/skills/things-cli/SKILL.md +3 -2
  88. package/skills/things-cli/references/banner.md +1 -1
  89. package/skills/things-cli/references/contracts.md +17 -9
  90. package/skills/things-cli/references/data-model.md +2 -1
@@ -0,0 +1,620 @@
1
+ import { undoToken } from "../audit/schema.js";
2
+ import { byUuid } from "../read/detail.js";
3
+ import { resolveProjectWriteTarget, resolveTaskUuidPrefix } from "../read/queries.js";
4
+ import { runCloneProject, runCloneTodo } from "./clone.js";
5
+ import { promoteProjectViaGui } from "./make-repeating-project.js";
6
+ import { fingerprintLabel, runMutation, } from "./pipeline.js";
7
+ import { assertRepeatRule, ruleToInverseParams } from "./repeat-rule.js";
8
+ import { createDbReader } from "./verify/delta.js";
9
+ const PLACEMENT_NOTE = "the series' current instance lands at its container's default position — its prior slot was " +
10
+ "not automatically restored (best-effort placement is not yet wired for this container); " +
11
+ "reposition it with `things reorder` if the order matters";
12
+ // --------------------------------------------------------------- small helpers
13
+ function newTxnId(now) {
14
+ return `txn-${now.getTime().toString(36)}-${process.pid.toString(36)}`;
15
+ }
16
+ /**
17
+ * Forward the caller's audit/timeout/GUI knobs onto a delegated leg. `extra`
18
+ * carries per-leg additions — `preserveModified` is threaded ONLY onto the legs
19
+ * that touch a PRE-EXISTING row (the trash-X leg); the clone/promote legs mint
20
+ * fresh rows, where the flag would be a no-op.
21
+ */
22
+ function legOptions(base, txnId, vector, extra) {
23
+ const out = { txn: { id: txnId, role: "leg" } };
24
+ if (vector !== undefined)
25
+ out.vector = vector;
26
+ if (base.actor !== undefined)
27
+ out.actor = base.actor;
28
+ if (base.verifyTimeoutMs !== undefined)
29
+ out.verifyTimeoutMs = base.verifyTimeoutMs;
30
+ if (base.dangerouslyDriveGui !== undefined)
31
+ out.dangerouslyDriveGui = base.dangerouslyDriveGui;
32
+ if (base.maxDisruption !== undefined)
33
+ out.maxDisruption = base.maxDisruption;
34
+ if (base.zone !== undefined)
35
+ out.zone = base.zone;
36
+ if (extra?.preserveModified === true)
37
+ out.preserveModified = true;
38
+ return out;
39
+ }
40
+ /** The two-key GUI-drive block (mirrors H-UI-DRIVE) — the promote leg drives the app. */
41
+ function blockedUiDrive(op) {
42
+ return {
43
+ kind: "blocked",
44
+ op,
45
+ reason: "hazard",
46
+ hazard: "H-UI-DRIVE",
47
+ detail: "this operation promotes an item to a repeating series by driving the local Things app " +
48
+ "through the Accessibility API (the Repeat… dialog) — it may briefly interact with the UI",
49
+ remediation: "pass dangerouslyDriveGui (--dangerously-drive-gui) to proceed; the vector also requires " +
50
+ "`things config set ui-enabled true` and Accessibility granted to this process (see docs/setup.md)",
51
+ };
52
+ }
53
+ /** Pick the rule fields (frequency/interval + calendar anchors) as a RepeatRuleParams. */
54
+ function ruleParamsFor(uuid, rule) {
55
+ return {
56
+ uuid,
57
+ frequency: rule.frequency,
58
+ interval: rule.interval,
59
+ ...(rule.afterCompletion !== undefined && { afterCompletion: rule.afterCompletion }),
60
+ ...(rule.weekdays !== undefined && { weekdays: rule.weekdays }),
61
+ ...(rule.monthly !== undefined && { monthly: rule.monthly }),
62
+ ...(rule.yearly !== undefined && { yearly: rule.yearly }),
63
+ ...(rule.ends !== undefined && { ends: rule.ends }),
64
+ };
65
+ }
66
+ /** The discovered template/instance from a promote leg's result. */
67
+ function discoveryOf(promote) {
68
+ const rep = promote.repeating;
69
+ return {
70
+ templateUuid: rep?.templateUuid ?? promote.uuid ?? "",
71
+ instanceUuid: rep?.instanceUuid ?? null,
72
+ };
73
+ }
74
+ // -------------------------------------------------------------- audit summary
75
+ function appendPromoteSummary(deps, args) {
76
+ const fp = deps.fingerprint();
77
+ const observed = {
78
+ templateUuid: args.templateUuid,
79
+ instanceUuid: args.instanceUuid,
80
+ ...(args.originalUuid !== undefined && { originalUuid: args.originalUuid }),
81
+ };
82
+ const record = {
83
+ v: 1,
84
+ ts: args.startedAt.toISOString(),
85
+ actor: deps.config.actor,
86
+ host: deps.config.host,
87
+ op: args.op,
88
+ uuid: args.templateUuid,
89
+ vector: "ui",
90
+ disruption: 3,
91
+ invocation: args.invocation,
92
+ requested: args.requested,
93
+ txn: { id: args.txnId, role: "summary" },
94
+ pre: null,
95
+ observed,
96
+ result: "ok",
97
+ ...(args.preModDates !== undefined && { preModDates: args.preModDates }),
98
+ verify: null,
99
+ durationMs: (deps.now?.() ?? new Date()).getTime() - args.startedAt.getTime(),
100
+ env: {
101
+ pkg: deps.pkgVersion ?? "0.0.1",
102
+ dbVersion: fp.observation.databaseVersion,
103
+ fingerprint: fingerprintLabel(fp, deps.config),
104
+ },
105
+ };
106
+ deps.audit.append(record);
107
+ }
108
+ /** Build the ok result for a promote (make/add-repeating). */
109
+ function promoteOk(args) {
110
+ const repeating = {
111
+ templateUuid: args.templateUuid,
112
+ instanceUuid: args.instanceUuid,
113
+ replacedUuid: args.replacedUuid,
114
+ };
115
+ return {
116
+ kind: "ok",
117
+ op: args.op,
118
+ uuid: args.templateUuid,
119
+ title: args.title,
120
+ observed: { templateUuid: args.templateUuid, instanceUuid: args.instanceUuid },
121
+ vector: "ui",
122
+ tier: 3,
123
+ undoToken: undoToken({
124
+ ts: "",
125
+ op: args.op,
126
+ actor: "",
127
+ host: "",
128
+ uuid: args.templateUuid,
129
+ txn: { id: args.txnId, role: "summary" },
130
+ }),
131
+ repeating,
132
+ ...(args.warnings.length > 0 && { warnings: args.warnings }),
133
+ };
134
+ }
135
+ // ============================================================ make-repeating
136
+ /**
137
+ * Shared clone → native-promote → trash(X) for `todo.make-repeating` /
138
+ * `project.make-repeating`. `promoteLeg` runs the native promote on the clone.
139
+ */
140
+ async function makeRepeatingViaClone(deps, kind, params, options) {
141
+ const op = kind === "project" ? "project.make-repeating" : "todo.make-repeating";
142
+ // Validate the rule BEFORE anything (a bad rule must never mint a clone).
143
+ assertRepeatRule(params);
144
+ const now = deps.now?.() ?? new Date();
145
+ const srcUuid = kind === "project"
146
+ ? resolveProjectWriteTarget(deps.db, params.uuid)
147
+ : resolveTaskUuidPrefix(deps.db, params.uuid, "to-do");
148
+ const src = byUuid(deps.db, srcUuid, now, deps.zone);
149
+ const expectedType = kind === "project" ? "project" : "to-do";
150
+ if (src === null || src.type !== expectedType) {
151
+ return {
152
+ kind: "blocked",
153
+ op,
154
+ reason: "hazard",
155
+ hazard: "H-UNKNOWN-DESTINATION",
156
+ detail: `the target is not a ${expectedType} (make-repeating needs an existing ${expectedType})`,
157
+ remediation: kind === "project"
158
+ ? "verify the uuid with `things projects`, or use `things todo make-repeating` for a to-do"
159
+ : "verify the uuid with `things show <uuid>`, or use `things project make-repeating` for a project",
160
+ };
161
+ }
162
+ // The promote leg drives the GUI — block before minting a clone if the ack is missing.
163
+ if (options.dangerouslyDriveGui !== true && options.dryRun !== true) {
164
+ return blockedUiDrive(op);
165
+ }
166
+ if (options.dryRun === true) {
167
+ return {
168
+ kind: "dry-run",
169
+ op,
170
+ plan: {
171
+ op,
172
+ vector: "ui",
173
+ tier: 3,
174
+ invocation: `clone ${srcUuid} (--preserve-created) → make-repeating the clone (Repeat… → ` +
175
+ `frequency=${params.frequency}, interval=${params.interval}) → trash the original ${srcUuid}`,
176
+ expectedDelta: {
177
+ mode: "create",
178
+ probe: { title: src.title, type: expectedType, sinceEpoch: 0 },
179
+ assert: [{ field: "repeating.isTemplate", equals: true }],
180
+ },
181
+ hazardsChecked: ["H-UNKNOWN-DESTINATION", "H-CLONE-SOURCE", "H-UI-DRIVE"],
182
+ },
183
+ };
184
+ }
185
+ const startedAt = now;
186
+ const txnId = newTxnId(startedAt);
187
+ // 1. Clone the source as a disposable, embedded leg (--preserve-created). The
188
+ // clone has captured X's full content by the time it returns.
189
+ const clone = kind === "project"
190
+ ? await runCloneProject(deps, { uuid: srcUuid, preserveCreated: true }, legOptions(options, txnId))
191
+ : await runCloneTodo(deps, { uuid: srcUuid, preserveCreated: true }, legOptions(options, txnId));
192
+ if (clone.kind !== "ok" || clone.uuid === null) {
193
+ // A clone refusal (nested repeating template, H-CLONE-SOURCE) surfaces
194
+ // coherently here — re-label it to the make-repeating op for the caller.
195
+ return clone.kind === "ok"
196
+ ? {
197
+ kind: "verify-failed",
198
+ op,
199
+ reason: "mismatch",
200
+ expected: {
201
+ mode: "create",
202
+ probe: { title: src.title, type: expectedType, sinceEpoch: 0 },
203
+ assert: [],
204
+ },
205
+ observed: null,
206
+ detail: "the disposable clone was created but its uuid was not discovered — nothing was promoted or trashed",
207
+ }
208
+ : { ...clone, op };
209
+ }
210
+ const cloneUuid = clone.uuid;
211
+ // --preserve-modified: X is the ONLY pre-existing row the compound touches (the
212
+ // clone/promote legs mint fresh rows). Capture its pre-write umd BEFORE the
213
+ // trash bumps it — the trash leg restores it forward, and the value rides the
214
+ // summary record's preModDates so the symmetric undo restore fires on the
215
+ // revived X (undo.ts, 2026-08-13 ruling). The clone leg above reads X but never
216
+ // writes it, so its umd is still pristine here.
217
+ const preserveModified = options.preserveModified === true;
218
+ const preUmd = preserveModified
219
+ ? createDbReader(deps.db, now, deps.zone).modDateOf(srcUuid)
220
+ : null;
221
+ // 2. Trash the original BEFORE promoting — the clone already holds X's content,
222
+ // and a live same-titled X would make the promote's project row-selection
223
+ // ambiguous (H-PROJECT-REPEAT). X survives in the Trash (the recoverable half).
224
+ const trash = await runMutation(deps, `${kind}.delete`, { uuid: srcUuid }, legOptions(options, txnId, undefined, preserveModified ? { preserveModified: true } : undefined));
225
+ if (trash.kind !== "ok") {
226
+ return {
227
+ ...trash,
228
+ op,
229
+ ...("detail" in trash
230
+ ? {
231
+ detail: `${trash.detail} — the disposable clone (uuid ${cloneUuid}) was created but the ` +
232
+ `original ${srcUuid} could not be moved to the Trash, so it was NOT promoted; trash ` +
233
+ "the clone and retry",
234
+ }
235
+ : {}),
236
+ };
237
+ }
238
+ // 3. Native-promote the clone.
239
+ const rule = ruleParamsFor(cloneUuid, params);
240
+ const promote = kind === "project"
241
+ ? await promoteProjectViaGui(deps, rule, legOptions(options, txnId, "ui"))
242
+ : await runMutation(deps, "todo.make-repeating", rule, legOptions(options, txnId, "ui"));
243
+ if (promote.kind !== "ok") {
244
+ // The clone persists but was not promoted; best-effort ROLL BACK the trash so
245
+ // the original is not stranded in the Trash.
246
+ const restoreOp = kind === "project" ? "project.restore" : "todo.restore";
247
+ const rolledBack = await runMutation(deps, restoreOp, { uuid: srcUuid }, legOptions(options, txnId));
248
+ const rollNote = rolledBack.kind === "ok"
249
+ ? `the original ${srcUuid} was restored from the Trash`
250
+ : `the original ${srcUuid} could NOT be restored from the Trash — restore it in the app`;
251
+ return {
252
+ ...promote,
253
+ op,
254
+ ...("detail" in promote
255
+ ? {
256
+ detail: `${promote.detail} — the disposable clone (uuid ${cloneUuid}) was created but the ` +
257
+ `promote did not land; ${rollNote}. Trash the clone and retry`,
258
+ }
259
+ : {}),
260
+ };
261
+ }
262
+ const { templateUuid, instanceUuid } = discoveryOf(promote);
263
+ const warnings = [
264
+ `the original ${expectedType} (uuid ${srcUuid}) was moved to the Trash; \`things undo\` ` +
265
+ "removes the new series (trash-both) and restores it",
266
+ PLACEMENT_NOTE,
267
+ ];
268
+ if (promote.warnings !== undefined)
269
+ warnings.push(...promote.warnings);
270
+ appendPromoteSummary(deps, {
271
+ startedAt,
272
+ op,
273
+ txnId,
274
+ templateUuid,
275
+ instanceUuid,
276
+ originalUuid: srcUuid,
277
+ invocation: `${op}: clone ${srcUuid} → trash ${srcUuid} → promote ${cloneUuid} → template ${templateUuid}`,
278
+ requested: params,
279
+ ...(preserveModified && preUmd !== null && { preModDates: { [srcUuid]: preUmd } }),
280
+ });
281
+ return promoteOk({
282
+ op,
283
+ templateUuid,
284
+ instanceUuid,
285
+ replacedUuid: cloneUuid,
286
+ title: src.title,
287
+ txnId,
288
+ warnings,
289
+ });
290
+ }
291
+ export function runMakeRepeatingTodo(deps, params, options = {}) {
292
+ return makeRepeatingViaClone(deps, "todo", params, options);
293
+ }
294
+ export function runMakeRepeatingProject(deps, params, options = {}) {
295
+ return makeRepeatingViaClone(deps, "project", params, options);
296
+ }
297
+ // ============================================================== add-repeating
298
+ /**
299
+ * Shared add(full vocabulary) → native-promote for `todo.add-repeating` /
300
+ * `project.add-repeating`. No trash leg — there is no original. The two legs are
301
+ * NOT atomic: the created item persists even if the promote refuses.
302
+ */
303
+ async function addRepeatingViaCreate(deps, kind, addParams, rule, title, options) {
304
+ const op = kind === "project" ? "project.add-repeating" : "todo.add-repeating";
305
+ assertRepeatRule(rule);
306
+ // The promote leg drives the GUI — block before creating anything if the ack is missing.
307
+ if (options.dangerouslyDriveGui !== true && options.dryRun !== true) {
308
+ return blockedUiDrive(op);
309
+ }
310
+ const expectedType = kind === "project" ? "project" : "to-do";
311
+ if (options.dryRun === true) {
312
+ return {
313
+ kind: "dry-run",
314
+ op,
315
+ plan: {
316
+ op,
317
+ vector: "ui",
318
+ tier: 3,
319
+ invocation: `create ${expectedType} "${title}" (persists on its own) → then make-repeating ` +
320
+ `(Repeat… → frequency=${rule.frequency}, interval=${rule.interval})`,
321
+ expectedDelta: {
322
+ mode: "create",
323
+ probe: { title, type: expectedType, sinceEpoch: 0 },
324
+ assert: [{ field: "repeating.isTemplate", equals: true }],
325
+ },
326
+ hazardsChecked: ["H-UI-DRIVE"],
327
+ },
328
+ };
329
+ }
330
+ const startedAt = deps.now?.() ?? new Date();
331
+ const txnId = newTxnId(startedAt);
332
+ // 1. Create the item (full add vocabulary) as an embedded leg.
333
+ const addOp = kind === "project" ? "project.add" : "todo.add";
334
+ const add = await runMutation(deps, addOp, addParams, legOptions(options, txnId, "url-scheme"));
335
+ if (add.kind !== "ok" || add.uuid === null) {
336
+ return add.kind === "ok"
337
+ ? {
338
+ kind: "verify-failed",
339
+ op,
340
+ reason: "mismatch",
341
+ expected: {
342
+ mode: "create",
343
+ probe: { title, type: expectedType, sinceEpoch: 0 },
344
+ assert: [],
345
+ },
346
+ observed: null,
347
+ detail: `the ${expectedType} was created but its uuid was not discovered — it cannot be promoted to repeating`,
348
+ }
349
+ : { ...add, op };
350
+ }
351
+ const createdUuid = add.uuid;
352
+ // 2. Native-promote the fresh row.
353
+ const ruleParams = ruleParamsFor(createdUuid, rule);
354
+ const promote = kind === "project"
355
+ ? await promoteProjectViaGui(deps, ruleParams, legOptions(options, txnId, "ui"))
356
+ : await runMutation(deps, "todo.make-repeating", ruleParams, legOptions(options, txnId, "ui"));
357
+ if (promote.kind !== "ok") {
358
+ // Honest: the item was created (and persists) but the promote did not land.
359
+ return { ...promote, op };
360
+ }
361
+ const { templateUuid, instanceUuid } = discoveryOf(promote);
362
+ const warnings = [PLACEMENT_NOTE];
363
+ if (promote.warnings !== undefined)
364
+ warnings.push(...promote.warnings);
365
+ appendPromoteSummary(deps, {
366
+ startedAt,
367
+ op,
368
+ txnId,
369
+ templateUuid,
370
+ instanceUuid,
371
+ invocation: `${op}: add "${title}" ${createdUuid} → template ${templateUuid}`,
372
+ requested: { title, ...rule },
373
+ });
374
+ return promoteOk({
375
+ op,
376
+ templateUuid,
377
+ instanceUuid,
378
+ replacedUuid: createdUuid,
379
+ title,
380
+ txnId,
381
+ warnings,
382
+ });
383
+ }
384
+ export function runAddRepeatingTodo(deps, params, options = {}) {
385
+ const { frequency, interval, afterCompletion, weekdays, monthly, yearly, ends, ...add } = params;
386
+ const rule = {
387
+ frequency,
388
+ interval,
389
+ ...(afterCompletion !== undefined && { afterCompletion }),
390
+ ...(weekdays !== undefined && { weekdays }),
391
+ ...(monthly !== undefined && { monthly }),
392
+ ...(yearly !== undefined && { yearly }),
393
+ ...(ends !== undefined && { ends }),
394
+ };
395
+ const addParams = {
396
+ title: add.title,
397
+ ...(add.notes !== undefined && { notes: add.notes }),
398
+ ...(add.when !== undefined && { when: add.when }),
399
+ ...(add.reminder !== undefined && { reminder: add.reminder }),
400
+ ...(add.deadline !== undefined && { deadline: add.deadline }),
401
+ ...(add.tags !== undefined && { tags: add.tags }),
402
+ ...(add.checklistItems !== undefined && { checklistItems: add.checklistItems }),
403
+ ...(add.project !== undefined && { project: add.project }),
404
+ ...(add.area !== undefined && { area: add.area }),
405
+ ...(add.heading !== undefined && { heading: add.heading }),
406
+ ...(add.createdAt !== undefined && { createdAt: add.createdAt }),
407
+ };
408
+ return addRepeatingViaCreate(deps, "todo", addParams, rule, add.title, options);
409
+ }
410
+ export function runAddRepeatingProject(deps, params, options = {}) {
411
+ const { frequency, interval, afterCompletion, weekdays, monthly, yearly, ends, ...add } = params;
412
+ const rule = {
413
+ frequency,
414
+ interval,
415
+ ...(afterCompletion !== undefined && { afterCompletion }),
416
+ ...(weekdays !== undefined && { weekdays }),
417
+ ...(monthly !== undefined && { monthly }),
418
+ ...(yearly !== undefined && { yearly }),
419
+ ...(ends !== undefined && { ends }),
420
+ };
421
+ // Seed a pure-AX taxonomy: an area lands a selectable AREA-view row; otherwise
422
+ // create in Someday (UIC4-f) so the promote skips the anytime-header problem.
423
+ const seedWhen = add.when ?? (add.area === undefined ? "someday" : undefined);
424
+ const addParams = {
425
+ title: add.title,
426
+ ...(add.notes !== undefined && { notes: add.notes }),
427
+ ...(add.area !== undefined && { area: add.area }),
428
+ ...(seedWhen !== undefined && { when: seedWhen }),
429
+ ...(add.deadline !== undefined && { deadline: add.deadline }),
430
+ ...(add.todos !== undefined && { todos: add.todos }),
431
+ ...(add.items !== undefined && { items: add.items }),
432
+ ...(add.createdAt !== undefined && { createdAt: add.createdAt }),
433
+ };
434
+ return addRepeatingViaCreate(deps, "project", addParams, rule, add.title, options);
435
+ }
436
+ // ====================================================== template-direct clone
437
+ /**
438
+ * The new-series-identity disclosure: a template clone is NOT linked to the
439
+ * source — it is a fresh series with its own uuid, and references to the source
440
+ * (its instances, its uuid) do not transfer.
441
+ */
442
+ const NEW_SERIES_NOTE = "cloning a repeating template mints a NEW repeating series with its own identity — it is not " +
443
+ "linked to the source template, and references to the source (its instances, its uuid) do not " +
444
+ "transfer to the clone";
445
+ /** A fail-closed H-CLONE-SOURCE refusal for a template that cannot be cloned. */
446
+ function blockedCloneSource(op, detail, remediation) {
447
+ return { kind: "blocked", op, reason: "hazard", hazard: "H-CLONE-SOURCE", detail, remediation };
448
+ }
449
+ /**
450
+ * Name the specific feature that puts a decoded rule OUTSIDE the promote
451
+ * vocabulary (used only when {@link ruleToInverseParams} returns null — the SAME
452
+ * boundary the reschedule undo rides). Two shapes the Repeat dialog cannot
453
+ * produce: two simultaneous end bounds, and a multi-anchor month/year rule.
454
+ */
455
+ function inexpressibleReason(rule) {
456
+ if (rule.endDate !== null && rule.remainingCount !== null) {
457
+ return ("the source rule ends on BOTH a date and an occurrence count, which the repeat vocabulary " +
458
+ "cannot express (its Ends bound is a single choice)");
459
+ }
460
+ const anchors = rule.offsets.filter((o) => o.day !== undefined || o.weekday !== undefined || o.month !== undefined);
461
+ if ((rule.unit === "monthly" || rule.unit === "yearly") && anchors.length > 1) {
462
+ return (`the source ${rule.unit} rule fires on multiple calendar anchors, which the repeat ` +
463
+ `vocabulary cannot express (it sets exactly one ${rule.unit} anchor)`);
464
+ }
465
+ return "the source recurrence rule uses a shape the repeat vocabulary cannot express";
466
+ }
467
+ /**
468
+ * TEMPLATE-DIRECT clone (ruling 2026-08-13(d)): cloning a repeating TEMPLATE =
469
+ * clone its content as a PLAIN item, then native-promote the clone with the
470
+ * SOURCE's decoded rule — a NEW series identity, NO instances cloned, one instance
471
+ * spawns immediately per the create law (identical to a from-scratch
472
+ * add-repeating). Delegated to from `runCloneTodo`/`runCloneProject`'s
473
+ * template-source branch (clone.ts).
474
+ *
475
+ * The compound:
476
+ * 1. decode the source's rule (`repeating.rule`) — undecodable ⇒ refuse;
477
+ * 2. map it onto the promote vocabulary (`ruleToInverseParams` + the template's
478
+ * deadline flag) — inexpressible (two end bounds / multi-anchor month-year) ⇒
479
+ * refuse, naming the feature (the SAME boundary the reschedule undo rides);
480
+ * 3. gate on the GUI-drive ack (the promote leg drives the app) BEFORE minting;
481
+ * 4. mint the plain clone (embedded leg, recurrence stripped — `cloneTemplateAsPlain`);
482
+ * 5. native-promote the clone with the FULL decoded rule (incl. deadline/start-earlier).
483
+ *
484
+ * Result = the add-repeating contract (template uuid + `repeating{templateUuid,
485
+ * instanceUuid|null}`); undo = trash-both (no original to restore). A PAUSED
486
+ * source mints the new series UNPAUSED (pause is not part of the rule vocabulary),
487
+ * disclosed. `--title`/`--preserve-created` behave as in ordinary clone (a
488
+ * delete-fate promote may replace the clone row, so preserve-created is
489
+ * best-effort on the surviving series — disclosed).
490
+ */
491
+ export async function cloneTemplateViaRepromote(deps, kind, src, srcUuid, params, options) {
492
+ const op = kind === "project" ? "project.add-repeating" : "todo.add-repeating";
493
+ const expectedType = kind === "project" ? "project" : "to-do";
494
+ const title = params.title ?? src.title;
495
+ // 1. Decode the source template's rule (detail reads populate repeating.rule;
496
+ // an undecodable rule — a future Things schema — is omitted).
497
+ const rule = src.repeating.rule;
498
+ if (rule === undefined) {
499
+ return blockedCloneSource(op, `the source ${expectedType} is a repeating template whose recurrence rule could not be ` +
500
+ "decoded (an unrecognized rule format), so the series cannot be reproduced", "re-create the repeat in the Things app on a fresh " + expectedType);
501
+ }
502
+ // 2. Map the decoded rule onto the promote vocabulary — refuse fail-closed when
503
+ // it falls outside what the Repeat dialog can express (name the feature).
504
+ const inverse = ruleToInverseParams(rule, src.repeating.deadlined === true);
505
+ if (inverse === null) {
506
+ return blockedCloneSource(op, `${inexpressibleReason(rule)} — so this template cannot be cloned faithfully`, "re-create the repeat in the Things app on a fresh " + expectedType);
507
+ }
508
+ // 3. The promote leg drives the GUI — block before minting a clone if the ack
509
+ // is missing (nothing created). An expressibility refusal above takes
510
+ // precedence (more informative than the drive block).
511
+ if (options.dangerouslyDriveGui !== true && options.dryRun !== true) {
512
+ return blockedUiDrive(op);
513
+ }
514
+ if (options.dryRun === true) {
515
+ return {
516
+ kind: "dry-run",
517
+ op,
518
+ plan: {
519
+ op,
520
+ vector: "ui",
521
+ tier: 3,
522
+ invocation: `clone the template ${srcUuid} as a plain ${expectedType} (content only, recurrence ` +
523
+ `stripped) → make-repeating the clone with the source's rule (Repeat… → ` +
524
+ `frequency=${inverse.frequency}, interval=${inverse.interval})`,
525
+ expectedDelta: {
526
+ mode: "create",
527
+ probe: { title, type: expectedType, sinceEpoch: 0 },
528
+ assert: [{ field: "repeating.isTemplate", equals: true }],
529
+ },
530
+ hazardsChecked: ["H-CLONE-SOURCE", "H-UI-DRIVE"],
531
+ },
532
+ };
533
+ }
534
+ const startedAt = deps.now?.() ?? new Date();
535
+ const txnId = newTxnId(startedAt);
536
+ // 4. Mint the plain clone as an embedded leg — cloneTemplateAsPlain reaches the
537
+ // clone orchestrator's plain-content path (recurrence + schedule stripped);
538
+ // --title/--preserve-created ride through the CloneParams.
539
+ const cloneParams = {
540
+ uuid: srcUuid,
541
+ ...(params.title !== undefined && { title: params.title }),
542
+ ...(params.preserveCreated === true && { preserveCreated: true }),
543
+ };
544
+ const cloneOptions = { ...legOptions(options, txnId), cloneTemplateAsPlain: true };
545
+ const clone = kind === "project"
546
+ ? await runCloneProject(deps, cloneParams, cloneOptions)
547
+ : await runCloneTodo(deps, cloneParams, cloneOptions);
548
+ if (clone.kind !== "ok" || clone.uuid === null) {
549
+ // A nested-repeater refusal (a template CONTAINING a nested repeater) or any
550
+ // clone failure surfaces coherently here — re-label it to the compound op.
551
+ return clone.kind === "ok"
552
+ ? {
553
+ kind: "verify-failed",
554
+ op,
555
+ reason: "mismatch",
556
+ expected: {
557
+ mode: "create",
558
+ probe: { title, type: expectedType, sinceEpoch: 0 },
559
+ assert: [],
560
+ },
561
+ observed: null,
562
+ detail: "the plain clone was created but its uuid was not discovered — nothing was promoted",
563
+ }
564
+ : { ...clone, op };
565
+ }
566
+ const cloneUuid = clone.uuid;
567
+ // 5. Native-promote the clone with the FULL decoded rule (ruleToInverseParams
568
+ // carries deadline/start-earlier + the calendar anchors + ends).
569
+ const ruleParams = { uuid: cloneUuid, ...inverse };
570
+ const promote = kind === "project"
571
+ ? await promoteProjectViaGui(deps, ruleParams, legOptions(options, txnId, "ui"))
572
+ : await runMutation(deps, "todo.make-repeating", ruleParams, legOptions(options, txnId, "ui"));
573
+ if (promote.kind !== "ok") {
574
+ // The plain clone persists but was not promoted — honest report (no original
575
+ // to roll back; the clone is a fresh row the caller can trash and retry).
576
+ return {
577
+ ...promote,
578
+ op,
579
+ ...("detail" in promote
580
+ ? {
581
+ detail: `${promote.detail} — the plain clone (uuid ${cloneUuid}) was created but the promote ` +
582
+ `did not land; trash the clone with \`things ${kind} delete ${cloneUuid}\` and retry`,
583
+ }
584
+ : {}),
585
+ };
586
+ }
587
+ const { templateUuid, instanceUuid } = discoveryOf(promote);
588
+ const warnings = [NEW_SERIES_NOTE, PLACEMENT_NOTE];
589
+ if (params.preserveCreated === true) {
590
+ warnings.push("--preserve-created is best-effort on a template clone: the promote may replace the clone " +
591
+ "row with the new template, whose creation date is the conversion time");
592
+ }
593
+ if (src.repeating.paused === true) {
594
+ warnings.push(`the source template was PAUSED; the new series is created UNPAUSED and begins spawning — ` +
595
+ `pause it with \`things ${kind} pause-repeat\` if you want it suspended`);
596
+ }
597
+ if (promote.warnings !== undefined)
598
+ warnings.push(...promote.warnings);
599
+ // Summary WITHOUT originalUuid → undo is the add-repeating trash-both (remove
600
+ // the minted series; there is no original to restore).
601
+ appendPromoteSummary(deps, {
602
+ startedAt,
603
+ op,
604
+ txnId,
605
+ templateUuid,
606
+ instanceUuid,
607
+ invocation: `${kind}.clone (template) ${srcUuid}: clone → promote ${cloneUuid} → template ${templateUuid}`,
608
+ requested: { source: srcUuid, title, ...inverse },
609
+ });
610
+ return promoteOk({
611
+ op,
612
+ templateUuid,
613
+ instanceUuid,
614
+ replacedUuid: cloneUuid,
615
+ title,
616
+ txnId,
617
+ warnings,
618
+ });
619
+ }
620
+ //# sourceMappingURL=promote-clone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promote-clone.js","sourceRoot":"","sources":["../../src/write/promote-clone.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EA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