things-api 0.9.0 → 0.10.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 (214) hide show
  1. package/README.md +30 -11
  2. package/dist/audit/log.js +56 -2
  3. package/dist/audit/log.js.map +1 -1
  4. package/dist/audit/schema.d.ts +26 -8
  5. package/dist/audit/schema.js +42 -1
  6. package/dist/audit/schema.js.map +1 -1
  7. package/dist/cli/commands/area.d.ts +26 -3
  8. package/dist/cli/commands/area.js +125 -70
  9. package/dist/cli/commands/area.js.map +1 -1
  10. package/dist/cli/commands/doctor.d.ts +1 -1
  11. package/dist/cli/commands/doctor.js +44 -5
  12. package/dist/cli/commands/doctor.js.map +1 -1
  13. package/dist/cli/commands/mcp.js +23 -4
  14. package/dist/cli/commands/mcp.js.map +1 -1
  15. package/dist/cli/commands/project.d.ts +18 -1
  16. package/dist/cli/commands/project.js +69 -31
  17. package/dist/cli/commands/project.js.map +1 -1
  18. package/dist/cli/commands/reads.js +423 -157
  19. package/dist/cli/commands/reads.js.map +1 -1
  20. package/dist/cli/commands/repeat-flags.d.ts +20 -0
  21. package/dist/cli/commands/repeat-flags.js +76 -0
  22. package/dist/cli/commands/repeat-flags.js.map +1 -0
  23. package/dist/cli/commands/setup.js +2 -3
  24. package/dist/cli/commands/setup.js.map +1 -1
  25. package/dist/cli/commands/show.js +47 -24
  26. package/dist/cli/commands/show.js.map +1 -1
  27. package/dist/cli/commands/todo.d.ts +1 -1
  28. package/dist/cli/commands/todo.js +7 -6
  29. package/dist/cli/commands/todo.js.map +1 -1
  30. package/dist/cli/commands/writes.js +378 -148
  31. package/dist/cli/commands/writes.js.map +1 -1
  32. package/dist/cli/did-you-mean.d.ts +1 -1
  33. package/dist/cli/excess-args.d.ts +15 -0
  34. package/dist/cli/excess-args.js +51 -0
  35. package/dist/cli/excess-args.js.map +1 -0
  36. package/dist/cli/glyphs.d.ts +39 -2
  37. package/dist/cli/glyphs.js +91 -21
  38. package/dist/cli/glyphs.js.map +1 -1
  39. package/dist/cli/help.d.ts +54 -0
  40. package/dist/cli/help.js +355 -0
  41. package/dist/cli/help.js.map +1 -0
  42. package/dist/cli/main.js +32 -25
  43. package/dist/cli/main.js.map +1 -1
  44. package/dist/cli/period.d.ts +7 -0
  45. package/dist/cli/period.js +12 -0
  46. package/dist/cli/period.js.map +1 -1
  47. package/dist/cli/read-driver.d.ts +26 -19
  48. package/dist/cli/read-driver.js +67 -33
  49. package/dist/cli/read-driver.js.map +1 -1
  50. package/dist/cli/render.d.ts +92 -28
  51. package/dist/cli/render.js +318 -97
  52. package/dist/cli/render.js.map +1 -1
  53. package/dist/cli/resolve-invocation.d.ts +42 -4
  54. package/dist/cli/resolve-invocation.js +97 -14
  55. package/dist/cli/resolve-invocation.js.map +1 -1
  56. package/dist/cli/tag-filters.d.ts +59 -0
  57. package/dist/cli/tag-filters.js +57 -0
  58. package/dist/cli/tag-filters.js.map +1 -0
  59. package/dist/cli/verb-hint.d.ts +25 -0
  60. package/dist/cli/verb-hint.js +138 -0
  61. package/dist/cli/verb-hint.js.map +1 -0
  62. package/dist/cli/width.d.ts +135 -0
  63. package/dist/cli/width.js +313 -0
  64. package/dist/cli/width.js.map +1 -0
  65. package/dist/client.d.ts +137 -24
  66. package/dist/client.js +105 -16
  67. package/dist/client.js.map +1 -1
  68. package/dist/config.d.ts +11 -0
  69. package/dist/config.js +3 -0
  70. package/dist/config.js.map +1 -1
  71. package/dist/contracts.d.ts +87 -17
  72. package/dist/contracts.js +44 -1
  73. package/dist/contracts.js.map +1 -1
  74. package/dist/db/fingerprint.d.ts +12 -0
  75. package/dist/db/fingerprint.js +15 -1
  76. package/dist/db/fingerprint.js.map +1 -1
  77. package/dist/db/locate.js +1 -1
  78. package/dist/db/locate.js.map +1 -1
  79. package/dist/diagnose.d.ts +63 -0
  80. package/dist/diagnose.js +38 -1
  81. package/dist/diagnose.js.map +1 -1
  82. package/dist/index.d.ts +30 -4
  83. package/dist/index.js +35 -2
  84. package/dist/index.js.map +1 -1
  85. package/dist/mcp/server.d.ts +9 -1
  86. package/dist/mcp/server.js +691 -133
  87. package/dist/mcp/server.js.map +1 -1
  88. package/dist/model/entities.d.ts +31 -7
  89. package/dist/model/entities.js.map +1 -1
  90. package/dist/model/mappers.d.ts +7 -0
  91. package/dist/model/mappers.js +7 -2
  92. package/dist/model/mappers.js.map +1 -1
  93. package/dist/model/serialize.d.ts +28 -0
  94. package/dist/model/serialize.js +80 -0
  95. package/dist/model/serialize.js.map +1 -0
  96. package/dist/model/when-sugar.d.ts +47 -0
  97. package/dist/model/when-sugar.js +45 -0
  98. package/dist/model/when-sugar.js.map +1 -0
  99. package/dist/read/area-view.d.ts +8 -1
  100. package/dist/read/area-view.js +49 -13
  101. package/dist/read/area-view.js.map +1 -1
  102. package/dist/read/filter-contract.d.ts +117 -0
  103. package/dist/read/filter-contract.js +78 -0
  104. package/dist/read/filter-contract.js.map +1 -0
  105. package/dist/read/predicates.d.ts +30 -0
  106. package/dist/read/predicates.js +30 -0
  107. package/dist/read/predicates.js.map +1 -1
  108. package/dist/read/project-view.d.ts +12 -1
  109. package/dist/read/project-view.js +39 -8
  110. package/dist/read/project-view.js.map +1 -1
  111. package/dist/read/queries.d.ts +149 -6
  112. package/dist/read/queries.js +250 -31
  113. package/dist/read/queries.js.map +1 -1
  114. package/dist/read/sections.d.ts +51 -0
  115. package/dist/read/sections.js +37 -0
  116. package/dist/read/sections.js.map +1 -0
  117. package/dist/read/sidebar-order.js +2 -1
  118. package/dist/read/sidebar-order.js.map +1 -1
  119. package/dist/read/tags.d.ts +27 -3
  120. package/dist/read/tags.js +83 -12
  121. package/dist/read/tags.js.map +1 -1
  122. package/dist/read/truncation.d.ts +71 -0
  123. package/dist/read/{pagination.js → truncation.js} +103 -94
  124. package/dist/read/truncation.js.map +1 -0
  125. package/dist/read/views.d.ts +140 -16
  126. package/dist/read/views.js +264 -67
  127. package/dist/read/views.js.map +1 -1
  128. package/dist/surface-copy.d.ts +19 -0
  129. package/dist/surface-copy.js +32 -0
  130. package/dist/surface-copy.js.map +1 -1
  131. package/dist/sync-health.d.ts +78 -0
  132. package/dist/sync-health.js +312 -0
  133. package/dist/sync-health.js.map +1 -0
  134. package/dist/write/accessibility-probe.d.ts +12 -0
  135. package/dist/write/accessibility-probe.js +63 -0
  136. package/dist/write/accessibility-probe.js.map +1 -0
  137. package/dist/write/automation-probe.d.ts +7 -0
  138. package/dist/write/automation-probe.js +8 -1
  139. package/dist/write/automation-probe.js.map +1 -1
  140. package/dist/write/batch.js +4 -2
  141. package/dist/write/batch.js.map +1 -1
  142. package/dist/write/capabilities.d.ts +8 -0
  143. package/dist/write/capabilities.js +13 -6
  144. package/dist/write/capabilities.js.map +1 -1
  145. package/dist/write/commands.d.ts +2 -0
  146. package/dist/write/commands.js +562 -48
  147. package/dist/write/commands.js.map +1 -1
  148. package/dist/write/edit-checklist.js +3 -2
  149. package/dist/write/edit-checklist.js.map +1 -1
  150. package/dist/write/guards.d.ts +2 -7
  151. package/dist/write/guards.js +64 -6
  152. package/dist/write/guards.js.map +1 -1
  153. package/dist/write/heading.js +2 -0
  154. package/dist/write/heading.js.map +1 -1
  155. package/dist/write/lock.d.ts +40 -2
  156. package/dist/write/lock.js +91 -14
  157. package/dist/write/lock.js.map +1 -1
  158. package/dist/write/make-repeating-project.d.ts +4 -0
  159. package/dist/write/make-repeating-project.js +253 -0
  160. package/dist/write/make-repeating-project.js.map +1 -0
  161. package/dist/write/operations.d.ts +145 -1
  162. package/dist/write/operations.js +48 -0
  163. package/dist/write/operations.js.map +1 -1
  164. package/dist/write/pipeline.d.ts +19 -0
  165. package/dist/write/pipeline.js +109 -26
  166. package/dist/write/pipeline.js.map +1 -1
  167. package/dist/write/pre-state.d.ts +68 -3
  168. package/dist/write/pre-state.js +102 -3
  169. package/dist/write/pre-state.js.map +1 -1
  170. package/dist/write/reopen.js +3 -2
  171. package/dist/write/reopen.js.map +1 -1
  172. package/dist/write/reorder.js +27 -17
  173. package/dist/write/reorder.js.map +1 -1
  174. package/dist/write/repeat-rule.d.ts +22 -0
  175. package/dist/write/repeat-rule.js +258 -0
  176. package/dist/write/repeat-rule.js.map +1 -0
  177. package/dist/write/reversibility.js +49 -0
  178. package/dist/write/reversibility.js.map +1 -1
  179. package/dist/write/tag-refs.d.ts +47 -0
  180. package/dist/write/tag-refs.js +126 -0
  181. package/dist/write/tag-refs.js.map +1 -0
  182. package/dist/write/undo.d.ts +74 -5
  183. package/dist/write/undo.js +493 -80
  184. package/dist/write/undo.js.map +1 -1
  185. package/dist/write/vectors/registry.d.ts +17 -1
  186. package/dist/write/vectors/registry.js +18 -2
  187. package/dist/write/vectors/registry.js.map +1 -1
  188. package/dist/write/vectors/types.d.ts +119 -3
  189. package/dist/write/vectors/ui-certification.d.ts +48 -0
  190. package/dist/write/vectors/ui-certification.js +46 -0
  191. package/dist/write/vectors/ui-certification.js.map +1 -0
  192. package/dist/write/vectors/ui-drag.d.ts +188 -0
  193. package/dist/write/vectors/ui-drag.js +1095 -0
  194. package/dist/write/vectors/ui-drag.js.map +1 -0
  195. package/dist/write/vectors/ui-recipes.d.ts +70 -0
  196. package/dist/write/vectors/ui-recipes.js +558 -0
  197. package/dist/write/vectors/ui-recipes.js.map +1 -0
  198. package/dist/write/vectors/ui.d.ts +137 -0
  199. package/dist/write/vectors/ui.js +656 -0
  200. package/dist/write/vectors/ui.js.map +1 -0
  201. package/dist/write/verify/delta.d.ts +31 -3
  202. package/dist/write/verify/delta.js +22 -6
  203. package/dist/write/verify/delta.js.map +1 -1
  204. package/dist/write/verify/poller.js +1 -0
  205. package/dist/write/verify/poller.js.map +1 -1
  206. package/package.json +1 -1
  207. package/dist/cli/exit-codes.d.ts +0 -26
  208. package/dist/cli/exit-codes.js +0 -26
  209. package/dist/cli/exit-codes.js.map +0 -1
  210. package/dist/cli/output.d.ts +0 -42
  211. package/dist/cli/output.js +0 -16
  212. package/dist/cli/output.js.map +0 -1
  213. package/dist/read/pagination.d.ts +0 -104
  214. package/dist/read/pagination.js.map +0 -1
@@ -0,0 +1,137 @@
1
+ import type { ThingsApiConfig } from "../../config.ts";
2
+ import { type UiDriveAux } from "./ui-drag.ts";
3
+ import type { UiPrimitive, UiStep, WriteVector } from "./types.ts";
4
+ /**
5
+ * Command-level primitives. Extends the recipe `UiPrimitive` set with the
6
+ * INTERNAL sub-steps composite recipe steps decompose into: a `click-element`
7
+ * step becomes read-the-frame (`resolve-frame`) + click-at-center
8
+ * (`click-point`); a `drag-reorder` step becomes snapshot/scroll/drag cycles
9
+ * (`sidebar-snapshot`, `sidebar-scroll`, `sidebar-drag` — ui-drag.ts). Keeping
10
+ * every subprocess call behind the injectable `run` seam makes the
11
+ * orchestration unit-testable without a GUI.
12
+ */
13
+ export type UiCommandPrimitive = UiPrimitive | "resolve-frame" | "click-point" | "sidebar-snapshot" | "sidebar-scroll" | "sidebar-drag" | "sidebar-held-drag";
14
+ /** A single primitive dispatch — one stable shape per primitive. */
15
+ export interface UiCommand {
16
+ primitive: UiCommandPrimitive;
17
+ label: string;
18
+ /** osascript source (AX primitives); absent for reveal. */
19
+ script?: string;
20
+ /** reveal only: the things:/// URL opened to select the target. */
21
+ url?: string;
22
+ /** `script` language for the osascript hop; defaults to AppleScript. */
23
+ lang?: "applescript" | "javascript";
24
+ /** Structured command parameters (test-inspectable; never dispatched). */
25
+ meta?: Record<string, unknown>;
26
+ }
27
+ export interface UiRunResult {
28
+ ok: boolean;
29
+ stdout: string;
30
+ stderr: string;
31
+ timedOut?: boolean;
32
+ }
33
+ /**
34
+ * Low-level dispatch seam. Injectable so the driver's recipe orchestration,
35
+ * canary, and abort logic are unit-testable WITHOUT ever touching a real GUI
36
+ * (CLAUDE.md safety rails — the production app is never a valid target).
37
+ */
38
+ export type UiRunner = (command: UiCommand, timeoutMs: number) => Promise<UiRunResult>;
39
+ /** resolve-element: does the element exist right now? Returns "true"/"false". */
40
+ export declare function axResolveScript(path: string): string;
41
+ /** press: AXPress the element. */
42
+ export declare function axPressScript(path: string): string;
43
+ /**
44
+ * set-field-value: enter a value into the dialog's numeric text field (interval,
45
+ * ends-count, start-days-earlier). It FOCUSES the field, selects all, TYPES the
46
+ * value, and Tabs to commit — because `set value of <field>` writes the field's
47
+ * displayed text WITHOUT firing the edit, so the app's binding keeps the old
48
+ * number (the field shows "5" but the rule stays interval 1 — a silent no-op
49
+ * exactly like `set value` on a pop-up, UIC6; it went unnoticed while every base
50
+ * case used the default interval 1). Real keystrokes fire the change the binding
51
+ * needs; Tab (not Return, which would fire the default OK button) commits and
52
+ * moves focus. Foreground-bound (keystrokes reach the frontmost app) — the
53
+ * reveal/activate preamble puts Things there. One stable command shape.
54
+ */
55
+ export declare function axSetValueScript(path: string, value: string): string;
56
+ /**
57
+ * select-popup: choose an item in a pop-up button by NAME. Setting `value` on a
58
+ * Things pop-up button is a silent no-op (UIC1 / UI2-i) — the control must be
59
+ * opened and the menu item clicked. The open-click is POLLED until the menu
60
+ * actually renders: in the full-vocabulary dialog a preceding pop-up's menu is
61
+ * still animating closed when the next select fires, and that first open-click
62
+ * is ABSORBED (the pop-up stays closed, so `menu 1` is an invalid index and the
63
+ * item click errors -1719, UIC6). Re-clicking only while the menu is absent
64
+ * (never once it is open) opens it reliably without toggling it back shut. One
65
+ * stable command shape per primitive.
66
+ */
67
+ export declare function axSelectPopupScript(path: string, value: string): string;
68
+ /**
69
+ * select-row: select a PROJECT row by title, purely via AX (UIC4-a). Walks the
70
+ * content table's rows, issues the row `select` action on each (which REPLACES
71
+ * the table selection — single-select, UIC5), and reads back Things' `name of
72
+ * selected to dos`; the first row whose readback equals the target title is LEFT
73
+ * selected and the script returns "OK". Non-selectable rows (the area/Someday
74
+ * header, the blank spacer) select nothing (readback count 0) and are skipped.
75
+ * Returns "NOMATCH" if no row selects to the title — the readback is the
76
+ * selection-landed verification, so a match guarantees the intended row is
77
+ * selected. One stable command shape per primitive.
78
+ *
79
+ * UIC5 correction: the shipped form set the TABLE's `AXSelectedRows` attribute
80
+ * to a one-row list, which is a SILENT NO-OP on Things' content table via System
81
+ * Events (no error, selection never lands). The row `select` action is the
82
+ * working pure-System-Events route and stays background-capable with no focus
83
+ * steal (UIC5-e). (UIC4-a proved settability with the ObjC-bridge NSArray set —
84
+ * a different API than the System Events attribute set the driver shells out to.)
85
+ */
86
+ export declare function axSelectRowScript(tablePath: string, title: string): string;
87
+ /** activate: foreground Things (the fallback preamble step). */
88
+ export declare function axActivateScript(): string;
89
+ /** key: a space-separated keystroke spec (e.g. "down down return"). */
90
+ export declare function axKeyScript(keys: string): string;
91
+ /** The abort keystroke sent to dismiss a half-open sheet/popover on failure. */
92
+ export declare function axAbortScript(): string;
93
+ /**
94
+ * resolve-frame: read the element's on-screen frame (top-left origin, points)
95
+ * from the live AX tree and print "x y w h". Used by `click-element` to target
96
+ * the frame CENTER — the position comes from AX (`position`/`size`), never a
97
+ * guessed pixel, so a missing element errors (fail-closed) instead of clicking
98
+ * a stale coordinate. Points map 1:1 to CGEvent coordinates (NATIVE1-b).
99
+ */
100
+ export declare function axFrameScript(path: string): string;
101
+ /**
102
+ * click-point: synthesize a single left mouse click at (x, y) via the global
103
+ * HID event tap (the NATIVE1 JXA ObjC-bridge path — `CGEventPostToPid` is inert
104
+ * for Things' hit-testing; only `CGEventPost(kCGHIDEventTap)` lands). The HID
105
+ * tap posts to the FOREGROUND surface, so the recipe must have activated Things
106
+ * first. Event types are the stable CGEventType values (5 = mouse-moved,
107
+ * 1 = left-down, 2 = left-up).
108
+ */
109
+ export declare function jxaClickScript(x: number, y: number): string;
110
+ /**
111
+ * set-datetime: set the Repeat dialog's `AXDateTimeArea` (reminder time / "ends
112
+ * on date" bound) via the ObjC AX bridge. Things' date/time control holds an
113
+ * NSDate, and System Events cannot write it (`set value … to <date>` → -10000,
114
+ * UIC6), so — like the mouse-synthesis primitive — this runs in JXA and calls
115
+ * `AXUIElementSetAttributeValue(…, AXValue, <NSDate>)` directly. The control is
116
+ * found by ROLE within Things' front dialog (there is exactly one during a
117
+ * reminder/end-date step; the matrix never sets both at once), polled briefly
118
+ * so it is caught right after the checkbox/pop-up that reveals it, and the
119
+ * script THROWS when absent so the driver fails closed. `spec` is
120
+ * `time:HH:mm` (keep the control's date, overwrite the time-of-day) or
121
+ * `date:YYYY-MM-DD` (overwrite the date at midnight). One stable JXA shape.
122
+ */
123
+ export declare function axSetDateTimeScript(spec: string): string;
124
+ /** Parse a resolve-frame "x y w h" line into the frame's center point. */
125
+ export declare function parseFrameCenter(stdout: string): {
126
+ x: number;
127
+ y: number;
128
+ } | null;
129
+ /** Compile one recipe step into its primitive command (no dispatch). */
130
+ export declare function commandForStep(step: UiStep, targetUuid: string): UiCommand;
131
+ /**
132
+ * The ui vector. Config-gated: when `ui.enabled` is false the matrix reports
133
+ * every op unsupported (with a remediation naming the config key + setup doc),
134
+ * so the operation is never dispatched. When enabled, `execute` runs the
135
+ * compiled recipe fail-closed.
136
+ */
137
+ export declare function createUiVector(config: ThingsApiConfig, run?: UiRunner, aux?: UiDriveAux): WriteVector;