things-api 0.9.0 → 0.11.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 +57 -12
- package/dist/audit/log.js +56 -2
- package/dist/audit/log.js.map +1 -1
- package/dist/audit/schema.d.ts +26 -8
- package/dist/audit/schema.js +42 -1
- package/dist/audit/schema.js.map +1 -1
- package/dist/cli/clock.d.ts +8 -0
- package/dist/cli/clock.js +24 -0
- package/dist/cli/clock.js.map +1 -0
- package/dist/cli/commands/area.d.ts +26 -3
- package/dist/cli/commands/area.js +129 -75
- package/dist/cli/commands/area.js.map +1 -1
- package/dist/cli/commands/doctor.d.ts +1 -1
- package/dist/cli/commands/doctor.js +44 -5
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/install-skill.d.ts +45 -0
- package/dist/cli/commands/install-skill.js +207 -0
- package/dist/cli/commands/install-skill.js.map +1 -0
- package/dist/cli/commands/mcp.js +23 -4
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/project.d.ts +18 -1
- package/dist/cli/commands/project.js +74 -35
- package/dist/cli/commands/project.js.map +1 -1
- package/dist/cli/commands/reads.d.ts +15 -2
- package/dist/cli/commands/reads.js +459 -165
- package/dist/cli/commands/reads.js.map +1 -1
- package/dist/cli/commands/repeat-flags.d.ts +20 -0
- package/dist/cli/commands/repeat-flags.js +76 -0
- package/dist/cli/commands/repeat-flags.js.map +1 -0
- package/dist/cli/commands/setup.js +8 -4
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/cli/commands/show.js +53 -30
- package/dist/cli/commands/show.js.map +1 -1
- package/dist/cli/commands/todo.d.ts +1 -1
- package/dist/cli/commands/todo.js +20 -13
- package/dist/cli/commands/todo.js.map +1 -1
- package/dist/cli/commands/writes.js +388 -161
- package/dist/cli/commands/writes.js.map +1 -1
- package/dist/cli/did-you-mean.d.ts +1 -1
- package/dist/cli/excess-args.d.ts +15 -0
- package/dist/cli/excess-args.js +51 -0
- package/dist/cli/excess-args.js.map +1 -0
- package/dist/cli/glyphs.d.ts +55 -2
- package/dist/cli/glyphs.js +114 -21
- package/dist/cli/glyphs.js.map +1 -1
- package/dist/cli/help.d.ts +54 -0
- package/dist/cli/help.js +405 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/main.js +64 -26
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/move-hint.d.ts +45 -0
- package/dist/cli/move-hint.js +196 -0
- package/dist/cli/move-hint.js.map +1 -0
- package/dist/cli/period.d.ts +9 -8
- package/dist/cli/period.js +56 -30
- package/dist/cli/period.js.map +1 -1
- package/dist/cli/read-driver.d.ts +26 -19
- package/dist/cli/read-driver.js +77 -33
- package/dist/cli/read-driver.js.map +1 -1
- package/dist/cli/render.d.ts +92 -28
- package/dist/cli/render.js +333 -103
- package/dist/cli/render.js.map +1 -1
- package/dist/cli/resolve-invocation.d.ts +42 -4
- package/dist/cli/resolve-invocation.js +97 -14
- package/dist/cli/resolve-invocation.js.map +1 -1
- package/dist/cli/skill-check.d.ts +21 -0
- package/dist/cli/skill-check.js +82 -0
- package/dist/cli/skill-check.js.map +1 -0
- package/dist/cli/skill.d.ts +62 -0
- package/dist/cli/skill.js +142 -0
- package/dist/cli/skill.js.map +1 -0
- package/dist/cli/tag-filters.d.ts +63 -0
- package/dist/cli/tag-filters.js +59 -0
- package/dist/cli/tag-filters.js.map +1 -0
- package/dist/cli/verb-hint.d.ts +25 -0
- package/dist/cli/verb-hint.js +163 -0
- package/dist/cli/verb-hint.js.map +1 -0
- package/dist/cli/version.d.ts +4 -0
- package/dist/cli/version.js +18 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/cli/width.d.ts +135 -0
- package/dist/cli/width.js +313 -0
- package/dist/cli/width.js.map +1 -0
- package/dist/client.d.ts +160 -24
- package/dist/client.js +132 -19
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -1
- package/dist/contracts.d.ts +97 -17
- package/dist/contracts.js +44 -1
- package/dist/contracts.js.map +1 -1
- package/dist/db/fingerprint.d.ts +12 -0
- package/dist/db/fingerprint.js +15 -1
- package/dist/db/fingerprint.js.map +1 -1
- package/dist/db/locate.js +1 -1
- package/dist/db/locate.js.map +1 -1
- package/dist/diagnose.d.ts +63 -0
- package/dist/diagnose.js +38 -1
- package/dist/diagnose.js.map +1 -1
- package/dist/index.d.ts +36 -5
- package/dist/index.js +38 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.d.ts +9 -1
- package/dist/mcp/server.js +1038 -436
- package/dist/mcp/server.js.map +1 -1
- package/dist/model/clock.d.ts +61 -0
- package/dist/model/clock.js +71 -0
- package/dist/model/clock.js.map +1 -0
- package/dist/model/dates.d.ts +26 -3
- package/dist/model/dates.js +84 -3
- package/dist/model/dates.js.map +1 -1
- package/dist/model/entities.d.ts +48 -10
- package/dist/model/entities.js.map +1 -1
- package/dist/model/mappers.d.ts +9 -2
- package/dist/model/mappers.js +32 -9
- package/dist/model/mappers.js.map +1 -1
- package/dist/model/serialize.d.ts +28 -0
- package/dist/model/serialize.js +80 -0
- package/dist/model/serialize.js.map +1 -0
- package/dist/model/when-sugar.d.ts +47 -0
- package/dist/model/when-sugar.js +45 -0
- package/dist/model/when-sugar.js.map +1 -0
- package/dist/read/area-view.d.ts +8 -1
- package/dist/read/area-view.js +55 -17
- package/dist/read/area-view.js.map +1 -1
- package/dist/read/detail.d.ts +1 -1
- package/dist/read/detail.js +11 -4
- package/dist/read/detail.js.map +1 -1
- package/dist/read/filter-contract.d.ts +117 -0
- package/dist/read/filter-contract.js +78 -0
- package/dist/read/filter-contract.js.map +1 -0
- package/dist/read/log-boundary.d.ts +1 -1
- package/dist/read/log-boundary.js +13 -3
- package/dist/read/log-boundary.js.map +1 -1
- package/dist/read/predicates.d.ts +30 -0
- package/dist/read/predicates.js +30 -0
- package/dist/read/predicates.js.map +1 -1
- package/dist/read/project-view.d.ts +12 -1
- package/dist/read/project-view.js +45 -12
- package/dist/read/project-view.js.map +1 -1
- package/dist/read/queries.d.ts +152 -7
- package/dist/read/queries.js +277 -36
- package/dist/read/queries.js.map +1 -1
- package/dist/read/sections.d.ts +51 -0
- package/dist/read/sections.js +37 -0
- package/dist/read/sections.js.map +1 -0
- package/dist/read/sidebar-order.js +2 -1
- package/dist/read/sidebar-order.js.map +1 -1
- package/dist/read/snapshot.d.ts +1 -1
- package/dist/read/snapshot.js +9 -2
- package/dist/read/snapshot.js.map +1 -1
- package/dist/read/tags.d.ts +27 -3
- package/dist/read/tags.js +83 -12
- package/dist/read/tags.js.map +1 -1
- package/dist/read/truncation.d.ts +71 -0
- package/dist/read/{pagination.js → truncation.js} +103 -94
- package/dist/read/truncation.js.map +1 -0
- package/dist/read/views.d.ts +147 -22
- package/dist/read/views.js +282 -80
- package/dist/read/views.js.map +1 -1
- package/dist/surface-copy.d.ts +19 -0
- package/dist/surface-copy.js +32 -0
- package/dist/surface-copy.js.map +1 -1
- package/dist/sync-health.d.ts +78 -0
- package/dist/sync-health.js +312 -0
- package/dist/sync-health.js.map +1 -0
- package/dist/write/accessibility-probe.d.ts +12 -0
- package/dist/write/accessibility-probe.js +71 -0
- package/dist/write/accessibility-probe.js.map +1 -0
- package/dist/write/automation-probe.d.ts +8 -1
- package/dist/write/automation-probe.js +16 -1
- package/dist/write/automation-probe.js.map +1 -1
- package/dist/write/batch.js +5 -2
- package/dist/write/batch.js.map +1 -1
- package/dist/write/capabilities.d.ts +8 -0
- package/dist/write/capabilities.js +13 -6
- package/dist/write/capabilities.js.map +1 -1
- package/dist/write/commands.d.ts +3 -1
- package/dist/write/commands.js +602 -49
- package/dist/write/commands.js.map +1 -1
- package/dist/write/edit-checklist.js +3 -2
- package/dist/write/edit-checklist.js.map +1 -1
- package/dist/write/guards.d.ts +2 -7
- package/dist/write/guards.js +87 -6
- package/dist/write/guards.js.map +1 -1
- package/dist/write/heading.js +2 -0
- package/dist/write/heading.js.map +1 -1
- package/dist/write/lock.d.ts +40 -2
- package/dist/write/lock.js +91 -14
- package/dist/write/lock.js.map +1 -1
- package/dist/write/make-repeating-project.d.ts +4 -0
- package/dist/write/make-repeating-project.js +253 -0
- package/dist/write/make-repeating-project.js.map +1 -0
- package/dist/write/operations.d.ts +145 -1
- package/dist/write/operations.js +48 -0
- package/dist/write/operations.js.map +1 -1
- package/dist/write/pipeline.d.ts +73 -2
- package/dist/write/pipeline.js +218 -43
- package/dist/write/pipeline.js.map +1 -1
- package/dist/write/planner.js +8 -1
- package/dist/write/planner.js.map +1 -1
- package/dist/write/pre-state.d.ts +105 -3
- package/dist/write/pre-state.js +144 -3
- package/dist/write/pre-state.js.map +1 -1
- package/dist/write/recurrence-rule-blob.d.ts +65 -0
- package/dist/write/recurrence-rule-blob.js +150 -0
- package/dist/write/recurrence-rule-blob.js.map +1 -0
- package/dist/write/reopen.js +3 -2
- package/dist/write/reopen.js.map +1 -1
- package/dist/write/reorder.js +27 -17
- package/dist/write/reorder.js.map +1 -1
- package/dist/write/repeat-rule.d.ts +22 -0
- package/dist/write/repeat-rule.js +258 -0
- package/dist/write/repeat-rule.js.map +1 -0
- package/dist/write/reversibility.js +49 -0
- package/dist/write/reversibility.js.map +1 -1
- package/dist/write/tag-refs.d.ts +47 -0
- package/dist/write/tag-refs.js +126 -0
- package/dist/write/tag-refs.js.map +1 -0
- package/dist/write/undo.d.ts +74 -5
- package/dist/write/undo.js +493 -80
- package/dist/write/undo.js.map +1 -1
- package/dist/write/vectors/registry.d.ts +15 -1
- package/dist/write/vectors/registry.js +65 -2
- package/dist/write/vectors/registry.js.map +1 -1
- package/dist/write/vectors/simulator.d.ts +44 -0
- package/dist/write/vectors/simulator.js +1136 -0
- package/dist/write/vectors/simulator.js.map +1 -0
- package/dist/write/vectors/types.d.ts +154 -3
- package/dist/write/vectors/ui-certification.d.ts +54 -0
- package/dist/write/vectors/ui-certification.js +43 -0
- package/dist/write/vectors/ui-certification.js.map +1 -0
- package/dist/write/vectors/ui-drag.d.ts +188 -0
- package/dist/write/vectors/ui-drag.js +1095 -0
- package/dist/write/vectors/ui-drag.js.map +1 -0
- package/dist/write/vectors/ui-recipes.d.ts +83 -0
- package/dist/write/vectors/ui-recipes.js +610 -0
- package/dist/write/vectors/ui-recipes.js.map +1 -0
- package/dist/write/vectors/ui.d.ts +152 -0
- package/dist/write/vectors/ui.js +704 -0
- package/dist/write/vectors/ui.js.map +1 -0
- package/dist/write/verify/delta.d.ts +141 -4
- package/dist/write/verify/delta.js +199 -21
- package/dist/write/verify/delta.js.map +1 -1
- package/dist/write/verify/poller.d.ts +7 -1
- package/dist/write/verify/poller.js +21 -1
- package/dist/write/verify/poller.js.map +1 -1
- package/package.json +18 -3
- package/skills/things-cli/SKILL.md +53 -0
- package/skills/things-cli/references/contracts.md +41 -0
- package/skills/things-cli/references/gui.md +11 -0
- package/skills/things-cli/references/model.md +51 -0
- package/dist/cli/exit-codes.d.ts +0 -26
- package/dist/cli/exit-codes.js +0 -26
- package/dist/cli/exit-codes.js.map +0 -1
- package/dist/cli/output.d.ts +0 -42
- package/dist/cli/output.js +0 -16
- package/dist/cli/output.js.map +0 -1
- package/dist/read/pagination.d.ts +0 -104
- package/dist/read/pagination.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A typed TypeScript library + CLI (`things`) for programmatic interaction with [Things 3](https://culturedcode.com/things/) by Cultured Code.
|
|
4
4
|
|
|
5
|
-
**Status: read + write + MCP layers live and published to npm (v0.
|
|
5
|
+
**Status: read + write + MCP layers live and published to npm (v0.11.0 — see [CHANGELOG.md](CHANGELOG.md)).** Reads go straight to the local SQLite database (UI-exact Today ordering, sidebar-grouped Anytime/Someday with container-status cascade, decoded repeat rules, occurrence projections); writes run a verified pipeline over four write vectors — two lab-validated headless surfaces (the URL scheme + AppleScript) and two opt-in surfaces (Apple Shortcuts and an Accessibility-driven GUI vector) — with hazard guards, disruption-tier policy, a JSONL audit trail, batch mode, audit-replay undo (transactional across compound operations), full project lifecycle (complete/cancel/reopen/restore), heading rename/archive/unarchive with children policies, container detach, granular stateful checklists, tag hierarchy management incl. un-nesting, completion/creation backdating, Logbook imports, tiered fuzzy name resolution (uuid prefixes, `things:///show?id=` share links), and ordering across eight scopes (incl. a project's headings and the top-level sidebar projects). The Apple Shortcuts surface is wired for the two headless capabilities nothing else can do: creating a heading in an existing project (`things heading add`) and clearing a reminder from a date-scheduled item (`things todo clear-reminder`). Both run through bundled proxy shortcuts (`things setup shortcuts`) and are gated on their presence. The fourth vector — the Accessibility-driven GUI vector — is off by default and drives the local Things app to reach transforms that exist on no scriptable surface (repeat-rule editing on existing to-dos and projects, convert-to-project, sidebar area reorder); see [Accessibility GUI vector](#accessibility-gui-vector-optional-off-by-default) below. Single-item permanent delete stays interactive-only (its macOS consent has no always-allow) and is out of the headless pipeline. See [docs/design/](docs/design/) for the architecture and VM-lab design, [docs/lab/](docs/lab/harness.md) for the probe harness and campaign results the write layer is grounded in, and [docs/atlas/](docs/atlas/schema-v26.md) for the database↔UI map.
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
8
|
things today --json # read: your Today list, Evening split, UI order
|
|
@@ -15,7 +15,7 @@ things capabilities --op todo.delete # what's possible, per vector, with evide
|
|
|
15
15
|
|
|
16
16
|
## Requirements & first-run setup
|
|
17
17
|
|
|
18
|
-
Things 3 installed and launched once, Node ≥ 24, and a handful of one-time macOS consents / Things settings depending on what you use (file-access consent for reads; "Enable Things URLs" + Automation consents for writes). **See [docs/setup.md](docs/setup.md)** — including the dedicated-automation-Mac checklist. `things doctor` validates your setup and prints remediation for anything missing.
|
|
18
|
+
Things 3 installed and launched once, Node ≥ 24, and a handful of one-time macOS consents / Things settings depending on what you use (file-access consent for reads; "Enable Things URLs" + Automation consents for writes; an Accessibility grant for the optional GUI vector). **See [docs/setup.md](docs/setup.md)** — including the dedicated-automation-Mac checklist. `things doctor` validates your setup and prints remediation for anything missing.
|
|
19
19
|
|
|
20
20
|
### Shortcuts setup (optional)
|
|
21
21
|
|
|
@@ -27,7 +27,15 @@ things setup shortcuts # opens an install sheet per missing shortcut — click
|
|
|
27
27
|
|
|
28
28
|
On each shortcut's first run macOS asks for permission — choose **Always Allow** so later runs are unattended (the two delete shortcuts re-ask on every run by design; Apple offers no always-allow for deletion). `things setup shortcuts --check` and `things doctor` report installation state.
|
|
29
29
|
|
|
30
|
-
Once installed, these Shortcuts-only operations become available as ordinary commands: `things heading add <project> <title>` (create a heading in an existing project) and `things todo clear-reminder <uuid>` (clear a date-scheduled to-do's reminder while keeping its date). Both are also exposed over MCP (`
|
|
30
|
+
Once installed, these Shortcuts-only operations become available as ordinary commands: `things heading add <project> <title>` (create a heading in an existing project) and `things todo clear-reminder <uuid>` (clear a date-scheduled to-do's reminder while keeping its date). Both are also exposed over MCP (the `heading` tool's create action, and `clear_reminder`). If a required shortcut is missing, the command is blocked up front with a pointer back to `things setup shortcuts` — nothing is dispatched.
|
|
31
|
+
|
|
32
|
+
### Accessibility GUI vector (optional, off by default)
|
|
33
|
+
|
|
34
|
+
A handful of transforms exist on **no scriptable surface at all** — the URL scheme, AppleScript, and Shortcuts cannot express them. The fourth write vector (the "ui" vector) reaches them by driving the local Things app's real interface through macOS Accessibility. It unlocks: making an existing to-do or project repeat and rescheduling/pausing/resuming its rule; converting a to-do into a project; and moving an area to a new position in the global area order (the sidebar). See [docs/design/ui-vector.md](docs/design/ui-vector.md) for the full model.
|
|
35
|
+
|
|
36
|
+
Because it drives the live GUI it is **fail-closed and two-key gated**: enable it once with `things config set ui-enabled true`, then acknowledge each individual call with `--dangerously-drive-gui` (`dangerously_drive_gui` over MCP). It carries the `H-UI-DRIVE` hazard, sits at the top disruption tier (3), and is intended for a dedicated, always-on Mac pinned to the English app language (a non-English UI fails the vector closed). Its recipes are **fragile** — an app-layout change can break them — so each op carries a per-op certification status (`uncertified` → `lab-certified` → on-device `certified`) recorded in the manifest at [src/write/vectors/ui-certification.ts](src/write/vectors/ui-certification.ts) and surfaced by `things capabilities` and the `things doctor` ui-vector section; a successful drive of a not-yet-`certified` op returns a note saying so.
|
|
37
|
+
|
|
38
|
+
Setup — granting Accessibility to the driving process and verifying it with `things doctor --probe-accessibility` — is in [docs/setup.md](docs/setup.md).
|
|
31
39
|
|
|
32
40
|
### Development install
|
|
33
41
|
|
|
@@ -42,23 +50,24 @@ Edits under `src/` take effect immediately. The bin launcher ([bin/things.js](bi
|
|
|
42
50
|
|
|
43
51
|
## Core principles
|
|
44
52
|
|
|
45
|
-
- **Reads** go directly to Things' local SQLite database (read-only, WAL-aware). **Writes** go exclusively through official app surfaces — URL scheme, AppleScript, Shortcuts — never direct DB writes (sync corruption).
|
|
53
|
+
- **Reads** go directly to Things' local SQLite database (read-only, WAL-aware). **Writes** go exclusively through official app surfaces — URL scheme, AppleScript, Shortcuts, and (opt-in) the Accessibility-driven GUI — never direct DB writes (sync corruption).
|
|
46
54
|
- **Every mutation is verified**: pre-read → hazard guards → execute → poll re-read until the expected delta appears. Silent no-ops are failures.
|
|
47
55
|
- **Every mutation is audited**: JSONL trail (`~/.local/state/things-api/audit/`) with requested vs. observed deltas; auth tokens structurally redacted.
|
|
48
|
-
- **Schema drift is detected**: table/column fingerprints keyed by Things' database version; writes hard-block on mismatch ([drift runbook](docs/lab/drift-runbook.md)).
|
|
49
|
-
- **Disruption is explicit**: every operation×vector combination carries a disruption tier (0 = invisible → 3 =
|
|
56
|
+
- **Schema drift is detected**: table/column fingerprints keyed by Things' database version; writes hard-block on mismatch, and reads surface a non-blocking `meta.warnings` note rather than failing ([drift runbook](docs/lab/drift-runbook.md)).
|
|
57
|
+
- **Disruption is explicit**: every operation×vector combination carries a disruption tier (0 = invisible → 3 = drives the live UI); disruptive operations require explicit opt-in flags.
|
|
50
58
|
- **Nothing is developed against production data**: probing and integration tests run in disposable Tart macOS VMs.
|
|
51
59
|
|
|
52
60
|
## For agents
|
|
53
61
|
|
|
54
62
|
The CLI is designed to be driven by coding agents with no out-of-band knowledge. The contract:
|
|
55
63
|
|
|
56
|
-
1. **Discovery**: `things --help` (
|
|
57
|
-
2. **Structured output**: every command takes `--json` → versioned envelope `{ apiVersion, ok, kind, data|error, meta }` on stdout; human chatter goes to stderr only. List views are **bounded by default**: the flat/chronological views (`inbox`, `today`, `upcoming`, `logbook`, `trash`, `search`, `changes`) return at most 50 items — raise with `--limit <n>` or lift with `--all` — and carry exact truncation counts in `meta.
|
|
58
|
-
3. **Stable exit codes**: `0` ok · `2` usage · `3` verify-failed (mutation executed, expected delta never appeared) · `4` blocked (hazard guard or disruption policy; error carries `remediation`) · `5` drift-blocked · `6` unsupported · `7` environment.
|
|
64
|
+
1. **Discovery**: `things --help` (a grouped one-line-per-command index; orientation detail lives behind `things help <topic>` — `agent`, `filters`, `ids`, `output`, `writes`), per-command `things <command> --help` (behavior, side effects, and the exact acknowledgement flag names a write needs — regression-tested as API; by design it does **not** carry vector/tier/hazard vocabulary, which is banned from help text by [docs/design/surface-copy.md](docs/design/surface-copy.md) — that classification lives in `capabilities`), and `things capabilities [--op <op>] --json` (the lab-validated operation × vector support matrix with disruption tiers, hazards, per-op certification status, and probe-evidence ids). Command invocation follows one grammar (`things <view>` · `things <type> <verb> <subject>` · loose `things <verb> <subject>` · bare `things <subject>`) with a single precedence chain — registered command/alias → view keyword → reference resolution — specified in [docs/design/cli-grammar.md](docs/design/cli-grammar.md).
|
|
65
|
+
2. **Structured output**: every command takes `--json` → versioned envelope `{ apiVersion, ok, kind, data|error, meta }` on stdout; human chatter goes to stderr only. List views are **bounded by default**: the flat/chronological views (`inbox`, `today`, `upcoming`, `logbook`, `trash`, `search`, `changes`) return at most 50 items — raise with `--limit <n>` or lift with `--all` — and carry exact truncation counts in `meta.truncation { shown, total, limit, truncated }` (the split `today` view also breaks the counts down per render section under `sections`). The grouped catalogues (`anytime`, `someday`) always show every area and project row and cap per block instead (no `--limit`): `--area-limit <n>` (default 30) per area block on both, `--project-limit <n>` (default 3) per project block on anytime, `--show-active-project-items [n]` for someday's trailing active-projects section — reporting `meta.grouped { truncated, blocks[] }`, where each block is identity-carrying (`kind`, `ref`, `title`, `shown`, `total`) and project blocks nest inside their area block under `children`. A read whose database schema no longer matches this build's validated fingerprint carries a non-blocking `meta.warnings` note (the read still returns best-effort; the same drift hard-blocks writes). Same defaults and metadata apply over MCP.
|
|
66
|
+
3. **Stable exit codes**: `0` ok · `2` usage · `3` verify-failed (mutation executed, expected delta never appeared) · `4` blocked (hazard guard or disruption policy; error carries `remediation`) · `5` drift-blocked · `6` unsupported (op has no supported vector — `things batch` also aggregates to 6 when its only failures are unsupported ops) · `7` environment.
|
|
59
67
|
4. **Plan before executing**: every write supports `--dry-run` — compiled invocation (token-redacted), chosen vector, tier, hazards checked, expected delta. Nothing runs, nothing is audited.
|
|
60
|
-
5. **No prompts, ever**: risky semantics are explicit flags — `--children require-resolved|auto-complete` (project completion cascades), `--acknowledge-checklist-reset` (checklist replacement destroys per-item state), `--acknowledge-project-reopen` (open child reopens a resolved project), `--dangerously-permanent` (area/tag delete and empty-trash skip the Trash).
|
|
61
|
-
6. **Experimental surfaces are opt-in**: `things reorder` (ordering within Today, the Inbox, Someday, a project's to-dos, a project's headings, or an area) rides an undocumented AppleScript command that any Things update may remove. It requires `things config set allow-experimental true` and re-checks the app's sdef declaration before every dispatch; `things doctor` reports both gates. Two scopes never touch it: This Evening and the top-level sidebar projects use verified `when=` round-trips (the "bounce", ≤10 items) instead.
|
|
68
|
+
5. **No prompts, ever**: risky semantics are explicit flags — `--children require-resolved|auto-complete` (project completion cascades), `--acknowledge-checklist-reset` (checklist replacement destroys per-item state), `--acknowledge-project-reopen` (open child reopens a resolved project), `--dangerously-permanent` (area/tag delete and empty-trash skip the Trash), `--dangerously-drive-gui` (each Accessibility GUI-vector call).
|
|
69
|
+
6. **Experimental surfaces are opt-in**: `things reorder` (ordering within Today, the Inbox, Someday, a project's to-dos, a project's headings, or an area) rides an undocumented AppleScript command that any Things update may remove. It requires `things config set allow-experimental true` and re-checks the app's sdef declaration before every dispatch; `things doctor` reports both gates. Two scopes never touch it: This Evening and the top-level sidebar projects use verified `when=` round-trips (the "bounce", ≤10 items) instead. Reordering the areas themselves (the sidebar order) is a separate operation on the Accessibility GUI vector (`things area reorder`, MCP `reorder` with `scope=areas`).
|
|
70
|
+
7. **Consumer timezone (optional)**: date boundaries (today / evening / upcoming / logbook sweep / overdue / since-until) evaluate in the host's zone by default. Set `THINGS_TZ` (an IANA zone) so they render for another calendar — e.g. an always-on Mac queried three zones away; over MCP the date-sensitive read tools and the `when`-bearing write tools also take a per-call `tz` that overrides it. `THINGS_NOW` (an ISO instant) pins "now" for determinism. When either is in effect a response carries `meta.clock { timezone, today }` (absent on the host clock); invalid values fail closed (exit 2). Writing `when` = today resolves to that zone's date before dispatch; `when` = evening is refused when the consumer's day differs from the app machine's (This Evening exists only for the app machine's current day). Reminder times are wall-clock and never shifted. For a dedicated single-consumer host, aligning the system timezone (`sudo systemsetup -settimezone <zone>`) is the simpler path — see [docs/design/contracts.md](docs/design/contracts.md#deployment-note--host-timezone-alignment).
|
|
62
71
|
|
|
63
72
|
A typical mutation flow:
|
|
64
73
|
|
|
@@ -75,6 +84,28 @@ things undo # execute it — verified like an
|
|
|
75
84
|
|
|
76
85
|
Failure modes are first-class: a `verify-failed:silent-noop` means the app accepted the command and did nothing (a real Things behavior the guards mostly prevent — see [docs/things-app-oddities.md](docs/things-app-oddities.md)); `blocked:*` responses include machine-readable remediation.
|
|
77
86
|
|
|
87
|
+
## Agent skill
|
|
88
|
+
|
|
89
|
+
An [agent skill](skills/things-cli/SKILL.md) ships in the package: a compact orientation an agent loads once — the data model, how to refer to items, and the stable machine contracts — pointing at `things --help` and `things help <topic>` for the fast-moving mechanics. **Install the skill and the rest self-maintains:** CLI access is via whatever `things` (or `npx`) resolves, mechanics come from that binary's own help, and version nudges flow both ways.
|
|
90
|
+
|
|
91
|
+
Install (or update) it with one command:
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
things install-skill # global: covers every agent harness the skills CLI detects
|
|
95
|
+
things install-skill --project # into the current project's .agents instead
|
|
96
|
+
things install-skill --check # compare installed vs bundled version, write nothing
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Under the hood it hands the bundled skill to the [`skills` CLI](https://github.com/vercel-labs/skills) (`npx -y skills add …`), which keeps one canonical copy under `~/.agents/skills/` and materializes it into each detected agent's directory (`~/.claude/skills/`, `~/.codex/skills/`, …). When that tool or the network is unavailable it falls back to a plain copy into `~/.agents` and `~/.claude`. **Re-running `things install-skill` IS the update** — it replaces the skill wholesale — so prefer it over a generic `skills update` for this skill (a single, unambiguous update path).
|
|
100
|
+
|
|
101
|
+
Three entry angles, all converging on the same working setup:
|
|
102
|
+
|
|
103
|
+
- **CLI installed** (`npm i -g things-api`) → `things --help` suggests `things install-skill`.
|
|
104
|
+
- **No install** → `npx things-api install-skill` places the skill; the skill itself falls back to `npx -y things-api@latest` for every command, so it works with no global binary on PATH.
|
|
105
|
+
- **Skill first, zero npm knowledge** → `npx skills add mikegreiling/things-api` pulls the skill straight from GitHub (whatever `skills/things-cli/` currently holds).
|
|
106
|
+
|
|
107
|
+
To keep the two sides from drifting, the `things` binary carries a version-stamped copy of the skill and (on human/`--help` output only, never `--json`) notes when the installed skill is well behind it. That notice reads the well-known skill directories under `~/.agents` and `~/.claude`; disable it with `THINGS_API_NO_SKILL_CHECK=1`.
|
|
108
|
+
|
|
78
109
|
## Architecture: one library, thin surfaces
|
|
79
110
|
|
|
80
111
|
The TypeScript library (`import { openThings } from "things-api"`) is the product; the CLI and the MCP server are thin presentation layers over the same `ThingsClient` — every read view and every verified mutation is a client method first. Shared machine contracts (JSON envelope, exit codes) live in the core (`contracts.ts`), and `diagnose()` / `capabilitiesTable()` are library functions the surfaces merely render.
|
|
@@ -87,4 +118,18 @@ The TypeScript library (`import { openThings } from "things-api"`) is the produc
|
|
|
87
118
|
{ "mcpServers": { "things": { "command": "things", "args": ["mcp"] } } }
|
|
88
119
|
```
|
|
89
120
|
|
|
90
|
-
The server instructions carry the user's live inventory (areas, tag hierarchy, open projects — read at server start) plus the reference/scheduling vocabulary, so models can name real destinations without a discovery round-trip. Tools mirror the client surface
|
|
121
|
+
The server instructions carry the user's live inventory (areas, tag hierarchy, open projects — read at server start) plus the reference/scheduling vocabulary, so models can name real destinations without a discovery round-trip. Tools mirror the client surface, grouped by area:
|
|
122
|
+
|
|
123
|
+
The catalog is consolidated around a few verb-parameterized tools (a discriminator — `kind`, `scope`, or `action` — selects the variant, with per-variant requirements validated at call time). This keeps every capability reachable while shrinking the static tool surface a model must load.
|
|
124
|
+
|
|
125
|
+
- **Reads**: `read_view` (today / inbox / anytime / upcoming with occurrence horizon / someday / logbook / trash), `search`, `changes_since`, `get_item`, `get_project`, `get_area`, `list_collections`.
|
|
126
|
+
- **Editing**: `update` (`kind` todo / project / area / tag), `set_status` (`scope` todo / project — completed / canceled / open, with the project children policy), `delete` (`kind` item / area / tag — Trash for items, guarded permanent delete for areas/tags incl. tag subtrees).
|
|
127
|
+
- **To-do writes**: `add_todo`, `move_todo`, `set_tags`, `edit_checklist`, plus completion/creation backdating (`backdate_todo`) and Logbook import (`add_logged_todo`).
|
|
128
|
+
- **Project writes**: `add_project`, `move_project`.
|
|
129
|
+
- **To-dos and projects alike**: `restore_item`, `duplicate_item`.
|
|
130
|
+
- **Create**: `add_area`, `add_tag`.
|
|
131
|
+
- **Headings & reminders** (Shortcuts-backed where headless-impossible): `heading` (`action` create / rename / archive / unarchive / convert_to_project), `clear_reminder`.
|
|
132
|
+
- **Recurrence via the Accessibility GUI ("ui") vector** (two-key gated — `ui-enabled` config + `dangerously_drive_gui` per call): `repeat` (`scope` todo / project; `action` start / reschedule / pause / resume / create). The `heading` convert_to_project action and the `reorder` areas scope ride the same gated GUI surface.
|
|
133
|
+
- **Generic & discovery**: `run_operation` (the full 49-op catalog), `batch`, `reorder` (item ordering across scopes, plus `scope=areas` for the sidebar area order), `undo`, `capabilities`, `doctor`.
|
|
134
|
+
|
|
135
|
+
Every write tool takes `dry_run`; the GUI-driven variants additionally require `dangerously_drive_gui`; tools carry read-only/destructive annotations; hazard blocks come back as structured tool errors carrying the same remediation text the CLI prints. Tool descriptions follow the consumer-voice contract in [docs/design/surface-copy.md](docs/design/surface-copy.md).
|
package/dist/audit/log.js
CHANGED
|
@@ -2,9 +2,63 @@
|
|
|
2
2
|
* JSONL audit writer: monthly files, never auto-deleted, structural token
|
|
3
3
|
* redaction — the serializer refuses to emit any string containing the
|
|
4
4
|
* loaded auth token.
|
|
5
|
+
*
|
|
6
|
+
* DURABILITY + TEAR-RESISTANCE (M5). Audit appends happen from processes that
|
|
7
|
+
* do NOT hold the mutation lock (e.g. a drift-gate or lock-contention block is
|
|
8
|
+
* recorded before/without ever acquiring it), so two things-api invocations can
|
|
9
|
+
* append to the same monthly file concurrently. The append path is therefore:
|
|
10
|
+
*
|
|
11
|
+
* open(path, O_APPEND) → ONE writeSync(fd, completeLineBuffer) → fsyncSync → close
|
|
12
|
+
*
|
|
13
|
+
* Two properties make this safe for our use in practice, on regular files:
|
|
14
|
+
* - ATOMIC APPEND. With O_APPEND the kernel positions the write at end-of-file
|
|
15
|
+
* and performs the append under the inode lock, so a SINGLE write() call
|
|
16
|
+
* cannot interleave with a concurrent write() from another fd — no torn or
|
|
17
|
+
* spliced line. We hand writeSync the COMPLETE `${line}\n` buffer so exactly
|
|
18
|
+
* one write() syscall carries the whole record. (The old appendFileSync path
|
|
19
|
+
* gave neither a single-write guarantee nor a flush.)
|
|
20
|
+
* - DURABILITY. fsyncSync flushes the record to disk before we return, so a
|
|
21
|
+
* crash immediately after the append cannot lose an already-acknowledged
|
|
22
|
+
* record — the pairing invariant the M3 intent record relies on holds.
|
|
23
|
+
*
|
|
24
|
+
* No lockfile is used, deliberately: for regular local files a single
|
|
25
|
+
* O_APPEND write() is already interleave-safe, our records are small and writes
|
|
26
|
+
* infrequent, and a lockfile would add a failure mode (stale locks, contention)
|
|
27
|
+
* into a path that must NEVER throw into the mutation result. A short write from
|
|
28
|
+
* write() only occurs on signals/full disks/pipes — not local regular-file
|
|
29
|
+
* appends of records this size — so the "one writeSync = one record" assumption
|
|
30
|
+
* holds; the >1MB round-trip test exercises the large-buffer case.
|
|
31
|
+
*
|
|
32
|
+
* NEVER THROWS INTO THE MUTATION PATH. If the durable path fails for any reason
|
|
33
|
+
* (fsync unsupported on an exotic FS, transient open error, …) we fall back to a
|
|
34
|
+
* best-effort plain append, and if THAT throws we swallow it: a mutation's
|
|
35
|
+
* result must never break because auditing hit an I/O error.
|
|
5
36
|
*/
|
|
6
|
-
import { appendFileSync, mkdirSync } from "node:fs";
|
|
37
|
+
import { appendFileSync, closeSync, fsyncSync, mkdirSync, openSync, writeSync } from "node:fs";
|
|
7
38
|
import { join } from "node:path";
|
|
39
|
+
/** Durable single-write append (O_APPEND + fsync), best-effort fallback on failure. */
|
|
40
|
+
function durableAppend(path, buf) {
|
|
41
|
+
try {
|
|
42
|
+
const fd = openSync(path, "a"); // "a" → O_APPEND
|
|
43
|
+
try {
|
|
44
|
+
writeSync(fd, buf); // one write() with the complete line — atomic append
|
|
45
|
+
fsyncSync(fd); // flush to disk before returning
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
closeSync(fd);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// Best-effort fallback: try a plain append, then give up silently. An audit
|
|
53
|
+
// write must never throw into the mutation path that called it.
|
|
54
|
+
try {
|
|
55
|
+
appendFileSync(path, buf);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
/* swallow — a mutation result must never break because auditing failed */
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
8
62
|
export function createAuditWriter(options) {
|
|
9
63
|
const secrets = options.secrets.filter((s) => s.length > 0);
|
|
10
64
|
return {
|
|
@@ -24,7 +78,7 @@ export function createAuditWriter(options) {
|
|
|
24
78
|
}
|
|
25
79
|
return value;
|
|
26
80
|
});
|
|
27
|
-
|
|
81
|
+
durableAppend(join(options.dir, `${month}.jsonl`), Buffer.from(`${line}\n`, "utf8"));
|
|
28
82
|
},
|
|
29
83
|
};
|
|
30
84
|
}
|
package/dist/audit/log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/audit/log.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/audit/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/F,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAQjC,uFAAuF;AACvF,SAAS,aAAa,CAAC,IAAY,EAAE,GAAW;IAC9C,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,iBAAiB;QACjD,IAAI,CAAC;YACH,SAAS,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,qDAAqD;YACzE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,iCAAiC;QAClD,CAAC;gBAAS,CAAC;YACT,SAAS,CAAC,EAAE,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,4EAA4E;QAC5E,gEAAgE;QAChE,IAAI,CAAC;YACH,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,0EAA0E;QAC5E,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAKjC;IACC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC5D,OAAO;QACL,MAAM,CAAC,MAAmB;YACxB,IAAI,CAAC,OAAO,CAAC,OAAO;gBAAE,OAAO;YAC7B,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU;YAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;gBAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;oBAC9B,IAAI,GAAG,GAAG,KAAK,CAAC;oBAChB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;wBAC7B,OAAO,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;4BAAE,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;oBACrE,CAAC;oBACD,OAAO,GAAG,CAAC;gBACb,CAAC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC,CAAC,CAAC;YACH,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,KAAK,QAAQ,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QACvF,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/audit/schema.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Audit record v1 — one JSON object per line in
|
|
3
|
-
* ~/.local/state/things-api/audit/YYYY-MM.jsonl (see design §5).
|
|
4
|
-
*
|
|
5
|
-
* Every mutation ATTEMPT is recorded: successes, verification failures, and
|
|
6
|
-
* blocked decisions (with invocation null — the app was never touched).
|
|
7
|
-
*/
|
|
8
1
|
export interface AuditRecord {
|
|
9
2
|
v: 1;
|
|
10
3
|
ts: string;
|
|
@@ -26,13 +19,20 @@ export interface AuditRecord {
|
|
|
26
19
|
id: string;
|
|
27
20
|
role: "leg" | "summary";
|
|
28
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Undo back-reference (ADDITIVE): the undo token of the ORIGINAL mutation
|
|
24
|
+
* this record inverts. Set only on inverse mutations (`undo:<actor>` records)
|
|
25
|
+
* so a later `things undo --txn <token>` can tell an already-undone mutation
|
|
26
|
+
* apart from a nonexistent one. Absent on ordinary (non-undo) mutations.
|
|
27
|
+
*/
|
|
28
|
+
undoOf?: string;
|
|
29
29
|
/** Normalized requested delta (params as given, post-normalization). */
|
|
30
30
|
requested: Record<string, unknown>;
|
|
31
31
|
/** Asserted-field subset of the pre-state (null when target didn't exist). */
|
|
32
32
|
pre: Record<string, unknown> | null;
|
|
33
33
|
/** Post-verify observation (best-effort on failure). */
|
|
34
34
|
observed: Record<string, unknown> | null;
|
|
35
|
-
result: "ok" | "verify-failed:timeout" | "verify-failed:mismatch" | "verify-failed:silent-noop" | `blocked:${string}` | "unsupported";
|
|
35
|
+
result: "intent" | "ok" | "verify-failed:timeout" | "verify-failed:mismatch" | "verify-failed:silent-noop" | `blocked:${string}` | "unsupported";
|
|
36
36
|
verify: {
|
|
37
37
|
attempts: number;
|
|
38
38
|
elapsedMs: number;
|
|
@@ -44,3 +44,21 @@ export interface AuditRecord {
|
|
|
44
44
|
fingerprint: "ok" | "drift" | "user-accepted" | "unknown";
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* The stable UNDO TOKEN for a mutation — the value a caller passes to
|
|
49
|
+
* `things undo --txn <token>` (MCP `txn`) to invert exactly THIS record,
|
|
50
|
+
* immune to interleaving. Two cases:
|
|
51
|
+
*
|
|
52
|
+
* - A compound operation's SUMMARY record already carries a real transaction
|
|
53
|
+
* id shared by its legs — that id IS the token (undoing it replays the
|
|
54
|
+
* whole sequence as one unit).
|
|
55
|
+
* - A single-op record has no such id, so we derive a content-addressed one
|
|
56
|
+
* from the fields that identify the record on disk (start timestamp + op +
|
|
57
|
+
* actor + host + target uuid). The mutation lock serializes writes, so those
|
|
58
|
+
* fields are unique per record in practice; the token is deterministic, so
|
|
59
|
+
* the write path (which returns it in the result) and the undo path (which
|
|
60
|
+
* recomputes it while scanning the trail) always agree.
|
|
61
|
+
*
|
|
62
|
+
* Purely additive: it is DERIVED from persisted fields, never stored.
|
|
63
|
+
*/
|
|
64
|
+
export declare function undoToken(record: Pick<AuditRecord, "ts" | "op" | "actor" | "host" | "uuid" | "txn">): string;
|
package/dist/audit/schema.js
CHANGED
|
@@ -4,6 +4,47 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Every mutation ATTEMPT is recorded: successes, verification failures, and
|
|
6
6
|
* blocked decisions (with invocation null — the app was never touched).
|
|
7
|
+
*
|
|
8
|
+
* A successful mutation writes TWO records: an `intent` marker immediately
|
|
9
|
+
* before the app is touched (M3 durability — so a crash between the app-side
|
|
10
|
+
* mutation and the final record leaves evidence the change may have landed),
|
|
11
|
+
* then the final `ok`/`verify-failed:*` record after read-after-write. The two
|
|
12
|
+
* share ts+op+actor+host (both derive from the same startedAt); an intent with
|
|
13
|
+
* no later final sibling is the signature of a crashed write. Intent records
|
|
14
|
+
* are NEVER undo targets — every undo reader filters `result === "ok"`, which
|
|
15
|
+
* an intent (result `"intent"`) is not, so it is excluded uniformly.
|
|
16
|
+
*/
|
|
17
|
+
import { createHash } from "node:crypto";
|
|
18
|
+
/**
|
|
19
|
+
* The stable UNDO TOKEN for a mutation — the value a caller passes to
|
|
20
|
+
* `things undo --txn <token>` (MCP `txn`) to invert exactly THIS record,
|
|
21
|
+
* immune to interleaving. Two cases:
|
|
22
|
+
*
|
|
23
|
+
* - A compound operation's SUMMARY record already carries a real transaction
|
|
24
|
+
* id shared by its legs — that id IS the token (undoing it replays the
|
|
25
|
+
* whole sequence as one unit).
|
|
26
|
+
* - A single-op record has no such id, so we derive a content-addressed one
|
|
27
|
+
* from the fields that identify the record on disk (start timestamp + op +
|
|
28
|
+
* actor + host + target uuid). The mutation lock serializes writes, so those
|
|
29
|
+
* fields are unique per record in practice; the token is deterministic, so
|
|
30
|
+
* the write path (which returns it in the result) and the undo path (which
|
|
31
|
+
* recomputes it while scanning the trail) always agree.
|
|
32
|
+
*
|
|
33
|
+
* Purely additive: it is DERIVED from persisted fields, never stored.
|
|
7
34
|
*/
|
|
8
|
-
export {
|
|
35
|
+
export function undoToken(record) {
|
|
36
|
+
if (record.txn?.role === "summary")
|
|
37
|
+
return record.txn.id;
|
|
38
|
+
// JSON-encode the identity tuple so field boundaries are unambiguous (no
|
|
39
|
+
// separator an actor/host string could forge) while staying plain text.
|
|
40
|
+
const identity = JSON.stringify([
|
|
41
|
+
record.ts,
|
|
42
|
+
record.op,
|
|
43
|
+
record.actor,
|
|
44
|
+
record.host,
|
|
45
|
+
record.uuid ?? "",
|
|
46
|
+
]);
|
|
47
|
+
const digest = createHash("sha256").update(identity).digest("hex").slice(0, 12);
|
|
48
|
+
return `m-${digest}`;
|
|
49
|
+
}
|
|
9
50
|
//# sourceMappingURL=schema.js.map
|
package/dist/audit/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/audit/schema.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/audit/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAkDzC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,SAAS,CACvB,MAA0E;IAE1E,IAAI,MAAM,CAAC,GAAG,EAAE,IAAI,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IACzD,yEAAyE;IACzE,wEAAwE;IACxE,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAC9B,MAAM,CAAC,EAAE;QACT,MAAM,CAAC,EAAE;QACT,MAAM,CAAC,KAAK;QACZ,MAAM,CAAC,IAAI;QACX,MAAM,CAAC,IAAI,IAAI,EAAE;KAClB,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChF,OAAO,KAAK,MAAM,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function setRenderClock(clock: {
|
|
2
|
+
now: () => Date;
|
|
3
|
+
zone: string | undefined;
|
|
4
|
+
}): void;
|
|
5
|
+
/** The render clock's instant (pinned THINGS_NOW when set, else real time); host time when unset. */
|
|
6
|
+
export declare function renderNow(): Date;
|
|
7
|
+
/** The render clock's consumer zone, or undefined for the host zone. */
|
|
8
|
+
export declare function renderZone(): string | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's process-wide render clock, resolved once in `runCli` from the
|
|
3
|
+
* environment (THINGS_TZ / THINGS_NOW) and read by the pure renderers and the
|
|
4
|
+
* period parsers — the same module-state pattern the width fit uses
|
|
5
|
+
* (./width.ts). It carries the consumer's `now` source and IANA zone so every
|
|
6
|
+
* human date token (Today marker, ‹date› chips, period bounds) matches the
|
|
7
|
+
* `meta.clock` the library reports. Unset (the default, and in unit tests that
|
|
8
|
+
* import the renderers directly) it is the host clock — byte-identical output.
|
|
9
|
+
*/
|
|
10
|
+
let clockNow = null;
|
|
11
|
+
let clockZone;
|
|
12
|
+
export function setRenderClock(clock) {
|
|
13
|
+
clockNow = clock.now;
|
|
14
|
+
clockZone = clock.zone;
|
|
15
|
+
}
|
|
16
|
+
/** The render clock's instant (pinned THINGS_NOW when set, else real time); host time when unset. */
|
|
17
|
+
export function renderNow() {
|
|
18
|
+
return clockNow === null ? new Date() : clockNow();
|
|
19
|
+
}
|
|
20
|
+
/** The render clock's consumer zone, or undefined for the host zone. */
|
|
21
|
+
export function renderZone() {
|
|
22
|
+
return clockZone;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=clock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../../src/cli/clock.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,IAAI,QAAQ,GAAwB,IAAI,CAAC;AACzC,IAAI,SAA6B,CAAC;AAElC,MAAM,UAAU,cAAc,CAAC,KAAoD;IACjF,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC;IACrB,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC;AACzB,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,SAAS;IACvB,OAAO,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;AACrD,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,UAAU;IACxB,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* under `things area` are registered by writes.ts on the same group).
|
|
4
4
|
*/
|
|
5
5
|
import type { Command } from "commander";
|
|
6
|
-
import type
|
|
7
|
-
import { type
|
|
6
|
+
import { type AreaView, type GroupedLimits, type GroupedTruncation } from "../../index.ts";
|
|
7
|
+
import { type TagFlags } from "../tag-filters.ts";
|
|
8
8
|
export interface AreaShowOpts {
|
|
9
9
|
showLater?: boolean;
|
|
10
10
|
/** Commander optional-value flag: true when bare, the raw string when given a count. */
|
|
@@ -24,6 +24,29 @@ export interface AreaShowOpts {
|
|
|
24
24
|
* (future-scheduled projects, to-dos, and repeating templates intermixed in
|
|
25
25
|
* date order) and Someday (someday projects as a leading block, then
|
|
26
26
|
* someday to-dos). `--show-logged` reveals the full logbook.
|
|
27
|
+
*
|
|
28
|
+
* `view` is the already-bounded card (its ACTIVE project rows and direct to-dos
|
|
29
|
+
* capped; scheduled/someday project rows and the later/logged/trashed sections
|
|
30
|
+
* intact) and `grouped` the per-block metadata carrying each capped section's
|
|
31
|
+
* pre-cap total — so the "… N more" footers derive from metadata, never a
|
|
32
|
+
* pre-cap copy of the view.
|
|
27
33
|
*/
|
|
28
|
-
export declare function renderAreaView(view: AreaView, opts: AreaShowOpts): string[];
|
|
34
|
+
export declare function renderAreaView(view: AreaView, grouped: GroupedTruncation, opts: AreaShowOpts): string[];
|
|
35
|
+
/** Options accepted by the area-show code path (shared by `area show` and `areas <ref>`). */
|
|
36
|
+
export type AreaShowActionOpts = AreaShowOpts & TagFlags & {
|
|
37
|
+
json?: boolean;
|
|
38
|
+
db?: string;
|
|
39
|
+
limit?: string;
|
|
40
|
+
areaLimit?: string;
|
|
41
|
+
projectLimit?: string;
|
|
42
|
+
all?: boolean;
|
|
43
|
+
/** Content scope: keep only rows (loose to-dos + child projects) with an overdue own deadline. */
|
|
44
|
+
overdue?: boolean;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The `area show <ref>` action body, factored out so the pluralized
|
|
48
|
+
* `things areas <ref>` can delegate to the identical code path (a true synonym,
|
|
49
|
+
* not a reimplementation). Both echo the canonical `things area show …` hint.
|
|
50
|
+
*/
|
|
51
|
+
export declare function runAreaShow(ref: string, opts: AreaShowActionOpts): void;
|
|
29
52
|
export declare function registerAreaCommands(program: Command): void;
|