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
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
* The read driver: open the client, stamp the envelope meta, and emit either
|
|
3
|
-
* the `--json` envelope or human lines (with the TTY-only title preamble,
|
|
4
|
-
* normalized-form echo, and truncation hint). Plus the shared `--limit`/`--all`
|
|
5
|
-
* cap parsing and the invocation-echo helpers every read command reuses. No
|
|
6
|
-
* commander dependency — command registration lives in the command modules.
|
|
7
|
-
*/
|
|
8
|
-
import { type ThingsClient } from "../client.ts";
|
|
9
|
-
import { type GroupedPagination, type Pagination } from "../contracts.ts";
|
|
1
|
+
import { type GroupedTruncation, type ThingsClient, type Truncation } from "../index.ts";
|
|
10
2
|
export interface GlobalReadOpts {
|
|
11
3
|
json?: boolean;
|
|
12
4
|
db?: string;
|
|
13
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* The single usage-error emitter every command surface routes flag/argument
|
|
8
|
+
* errors through, so `--json` is honored uniformly: under `--json` a
|
|
9
|
+
* `{ok:false, error:{code:"usage", …}}` envelope goes to STDOUT (machine
|
|
10
|
+
* consumers read one stream); otherwise the prose `error:` line goes to
|
|
11
|
+
* STDERR. `details` carries the same machine-readable `candidates`/`suggestions`
|
|
12
|
+
* shape the resolver errors use. Always sets the Usage exit code.
|
|
13
|
+
*/
|
|
14
|
+
export declare function usageError(opts: {
|
|
15
|
+
json?: boolean;
|
|
16
|
+
}, message: string, details?: {
|
|
17
|
+
candidates?: unknown[];
|
|
18
|
+
suggestions?: string[];
|
|
19
|
+
}): void;
|
|
14
20
|
export interface PagedResult<T> {
|
|
15
21
|
data: T;
|
|
16
22
|
/** Flat-view truncation — carried into meta and the appended hint. */
|
|
17
|
-
|
|
23
|
+
truncation?: Truncation;
|
|
18
24
|
/** Grouped-view (anytime/someday) per-block truncation — carried into meta. */
|
|
19
|
-
grouped?:
|
|
25
|
+
grouped?: GroupedTruncation;
|
|
20
26
|
/**
|
|
21
27
|
* Precomputed human lines. Grouped views render inside `fn` (where the full
|
|
22
28
|
* per-block totals live) and hand the finished lines back here; when absent,
|
|
@@ -26,7 +32,7 @@ export interface PagedResult<T> {
|
|
|
26
32
|
}
|
|
27
33
|
/**
|
|
28
34
|
* The shared read driver: open the client, stamp the envelope meta (including
|
|
29
|
-
* fingerprint + optional
|
|
35
|
+
* fingerprint + optional truncation), and either emit the `--json` envelope or
|
|
30
36
|
* render human lines. When `hintBase` is given and the result was truncated,
|
|
31
37
|
* the muted "N more items" hint (reconstructing the user's own invocation) is
|
|
32
38
|
* appended to the human output — never to `--json`. When `header` names a view,
|
|
@@ -55,22 +61,23 @@ export type LimitResolution = {
|
|
|
55
61
|
export declare function parseLimit(opts: {
|
|
56
62
|
limit?: string;
|
|
57
63
|
all?: boolean;
|
|
64
|
+
json?: boolean;
|
|
58
65
|
}): LimitResolution;
|
|
59
66
|
/**
|
|
60
67
|
* Resolve one cap flag (`--limit`, `--area-limit`, `--project-limit`) against
|
|
61
68
|
* `--all`: positive integer required, `--all` conflicts with an explicit
|
|
62
|
-
* value and otherwise lifts the cap (null).
|
|
63
|
-
* the
|
|
64
|
-
*
|
|
69
|
+
* value and otherwise lifts the cap (null). This surface owns the string→integer
|
|
70
|
+
* validation and the usage-error emission; the client re-applies the same
|
|
71
|
+
* conflict/default semantics on the resolved value it receives.
|
|
65
72
|
*/
|
|
66
|
-
export declare function parseCap(flag: string, value: string | undefined, defaultLimit: number, all: boolean): LimitResolution;
|
|
73
|
+
export declare function parseCap(flag: string, value: string | undefined, defaultLimit: number, all: boolean, json?: boolean): LimitResolution;
|
|
67
74
|
export { shellQuote } from "./shell-quote.ts";
|
|
68
75
|
/** Reconstruct `things <name> <flags…>`, dropping falsy/empty parts. */
|
|
69
76
|
export declare function invocation(name: string, parts: Array<string | false | undefined>): string;
|
|
70
77
|
/**
|
|
71
|
-
* The unified truncation hint: a muted `── N more items — see more: … ·
|
|
72
|
-
*
|
|
78
|
+
* The unified truncation hint: a muted `── N more items — see more: … · … ──`
|
|
79
|
+
* line whose commands echo the user's actual invocation, so a bigger
|
|
73
80
|
* `--limit` or `--all` is one copy-paste away. Returns null when nothing was
|
|
74
81
|
* dropped or the caller already asked for every row.
|
|
75
82
|
*/
|
|
76
|
-
export declare function truncationHint(base: string,
|
|
83
|
+
export declare function truncationHint(base: string, truncation: Truncation): string | null;
|
package/dist/cli/read-driver.js
CHANGED
|
@@ -5,19 +5,32 @@
|
|
|
5
5
|
* cap parsing and the invocation-echo helpers every read command reuses. No
|
|
6
6
|
* commander dependency — command registration lives in the command modules.
|
|
7
7
|
*/
|
|
8
|
-
import { openThings } from "../client.js";
|
|
9
|
-
import { ThingsDbNotFoundError } from "../db/locate.js";
|
|
10
|
-
import { ThingsDbOpenError } from "../db/connection.js";
|
|
11
8
|
import { getInvocation } from "./resolve-invocation.js";
|
|
12
9
|
import { dim } from "./style.js";
|
|
13
10
|
import { viewHeaderLines } from "./render.js";
|
|
14
11
|
import { candidatesJson, DidYouMeanError, renderDidYouMean } from "./did-you-mean.js";
|
|
15
|
-
import { errorEnvelope, ExitCode, okEnvelope, } from "../
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
import { ClockError, DEFAULT_LIST_LIMIT, errorEnvelope, ExitCode, okEnvelope, omitEmpty, openThings, ReferenceResolutionError, schemaWarnings, ThingsDbNotFoundError, ThingsDbOpenError, } from "../index.js";
|
|
13
|
+
/**
|
|
14
|
+
* The single usage-error emitter every command surface routes flag/argument
|
|
15
|
+
* errors through, so `--json` is honored uniformly: under `--json` a
|
|
16
|
+
* `{ok:false, error:{code:"usage", …}}` envelope goes to STDOUT (machine
|
|
17
|
+
* consumers read one stream); otherwise the prose `error:` line goes to
|
|
18
|
+
* STDERR. `details` carries the same machine-readable `candidates`/`suggestions`
|
|
19
|
+
* shape the resolver errors use. Always sets the Usage exit code.
|
|
20
|
+
*/
|
|
21
|
+
export function usageError(opts, message, details) {
|
|
22
|
+
if (opts.json === true) {
|
|
23
|
+
const meta = { dbVersion: null, fingerprint: "unknown", elapsedMs: 0 };
|
|
24
|
+
process.stdout.write(`${JSON.stringify(errorEnvelope({ code: "usage", message, ...(details !== undefined && { details }) }, meta))}\n`);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
process.stderr.write(`error: ${message}\n`);
|
|
28
|
+
}
|
|
29
|
+
process.exitCode = ExitCode.Usage;
|
|
30
|
+
}
|
|
18
31
|
/**
|
|
19
32
|
* The shared read driver: open the client, stamp the envelope meta (including
|
|
20
|
-
* fingerprint + optional
|
|
33
|
+
* fingerprint + optional truncation), and either emit the `--json` envelope or
|
|
21
34
|
* render human lines. When `hintBase` is given and the result was truncated,
|
|
22
35
|
* the muted "N more items" hint (reconstructing the user's own invocation) is
|
|
23
36
|
* appended to the human output — never to `--json`. When `header` names a view,
|
|
@@ -28,37 +41,50 @@ export function runRead(opts, kind, fn, render, hintBase, header) {
|
|
|
28
41
|
// An empty --db would silently fall through to the default database path —
|
|
29
42
|
// reject it loudly instead of reading somewhere the caller did not name.
|
|
30
43
|
if (opts.db !== undefined && opts.db.trim() === "") {
|
|
31
|
-
|
|
32
|
-
process.exitCode = ExitCode.Usage;
|
|
44
|
+
usageError(opts, "--db requires a non-empty path");
|
|
33
45
|
return;
|
|
34
46
|
}
|
|
35
47
|
let client = null;
|
|
36
48
|
try {
|
|
37
49
|
client = openThings(opts.db ? { dbPath: opts.db } : {});
|
|
38
50
|
const fp = client.fingerprint();
|
|
39
|
-
|
|
51
|
+
// Reads never block on a schema change — they warn (design decision). The
|
|
52
|
+
// note reuses the same cached fingerprint the write path gates on.
|
|
53
|
+
const warnings = schemaWarnings(client.schemaStatus());
|
|
54
|
+
const { data, truncation, grouped, lines: precomputed } = fn(client);
|
|
40
55
|
// The canonical command a sugar invocation normalized to — known now that
|
|
41
56
|
// `fn` has resolved any reference. Present only for the routing sugars
|
|
42
57
|
// (bare noun, keyword-in-show, uuid/share-link routing); null otherwise.
|
|
43
58
|
const resolvedCommand = getInvocation()?.canonical ?? null;
|
|
59
|
+
// The clock honesty field: present only when a consumer zone / pinned now
|
|
60
|
+
// is in effect (absent = host clock, so the wire shape is unchanged).
|
|
61
|
+
const clock = client.clockMeta();
|
|
44
62
|
const meta = {
|
|
45
63
|
dbVersion: fp.observation.databaseVersion,
|
|
46
64
|
fingerprint: fp.kind === "ok" ? "ok" : fp.kind === "drift" ? "drift" : "unknown",
|
|
47
65
|
elapsedMs: Date.now() - started,
|
|
48
|
-
...(
|
|
66
|
+
...(truncation !== undefined && { truncation }),
|
|
49
67
|
...(grouped !== undefined && { grouped }),
|
|
50
68
|
...(resolvedCommand !== null && { resolvedCommand }),
|
|
69
|
+
...(warnings.length > 0 && { warnings }),
|
|
70
|
+
...(clock !== undefined && { clock }),
|
|
51
71
|
};
|
|
52
|
-
|
|
53
|
-
|
|
72
|
+
// Human output gets the note once on STDERR (never mixed into the piped
|
|
73
|
+
// stdout rows); the --json envelope carries it in meta.warnings instead.
|
|
74
|
+
if (!opts.json) {
|
|
75
|
+
for (const warning of warnings)
|
|
76
|
+
process.stderr.write(`warning: ${warning}\n`);
|
|
54
77
|
}
|
|
55
78
|
if (opts.json) {
|
|
56
|
-
|
|
79
|
+
// Omit-empty applies to the entity/data payload only (contracts.md); the
|
|
80
|
+
// envelope meta/truncation is untouched, and the human render below keeps
|
|
81
|
+
// the full, unpruned `data`.
|
|
82
|
+
process.stdout.write(`${JSON.stringify(okEnvelope(kind, omitEmpty(data), meta))}\n`);
|
|
57
83
|
}
|
|
58
84
|
else {
|
|
59
85
|
const lines = precomputed ?? render(data);
|
|
60
|
-
if (
|
|
61
|
-
const hint = truncationHint(hintBase,
|
|
86
|
+
if (truncation !== undefined && hintBase !== undefined) {
|
|
87
|
+
const hint = truncationHint(hintBase, truncation);
|
|
62
88
|
if (hint !== null)
|
|
63
89
|
lines.push("", hint);
|
|
64
90
|
}
|
|
@@ -101,6 +127,24 @@ export function runRead(opts, kind, fn, render, hintBase, header) {
|
|
|
101
127
|
process.exitCode = ExitCode.Usage;
|
|
102
128
|
return;
|
|
103
129
|
}
|
|
130
|
+
// An unresolved uuid/partial-uuid/name (ambiguous or not-found) is a
|
|
131
|
+
// usage-class failure carrying machine-readable candidates.
|
|
132
|
+
if (err instanceof ReferenceResolutionError) {
|
|
133
|
+
if (opts.json) {
|
|
134
|
+
process.stdout.write(`${JSON.stringify(errorEnvelope({ code: err.code, message: err.message, details: { candidates: err.candidates } }, meta))}\n`);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
process.stderr.write(`error: ${err.message}\n`);
|
|
138
|
+
}
|
|
139
|
+
process.exitCode = ExitCode.Usage;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
// A malformed THINGS_TZ / THINGS_NOW (or per-read zone) fails closed as a
|
|
143
|
+
// usage error naming the expected form — never a silent host fallback.
|
|
144
|
+
if (err instanceof ClockError) {
|
|
145
|
+
usageError(opts, err.message);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
104
148
|
const isEnv = err instanceof ThingsDbNotFoundError || err instanceof ThingsDbOpenError;
|
|
105
149
|
const message = err instanceof Error ? err.message : String(err);
|
|
106
150
|
if (opts.json) {
|
|
@@ -130,28 +174,28 @@ export function withClient(opts, kind, fn, render) {
|
|
|
130
174
|
* with `--all`.
|
|
131
175
|
*/
|
|
132
176
|
export function parseLimit(opts) {
|
|
133
|
-
return parseCap("--limit", opts.limit, DEFAULT_LIST_LIMIT, opts.all === true);
|
|
177
|
+
return parseCap("--limit", opts.limit, DEFAULT_LIST_LIMIT, opts.all === true, opts.json === true);
|
|
134
178
|
}
|
|
135
179
|
/**
|
|
136
180
|
* Resolve one cap flag (`--limit`, `--area-limit`, `--project-limit`) against
|
|
137
181
|
* `--all`: positive integer required, `--all` conflicts with an explicit
|
|
138
|
-
* value and otherwise lifts the cap (null).
|
|
139
|
-
* the
|
|
140
|
-
*
|
|
182
|
+
* value and otherwise lifts the cap (null). This surface owns the string→integer
|
|
183
|
+
* validation and the usage-error emission; the client re-applies the same
|
|
184
|
+
* conflict/default semantics on the resolved value it receives.
|
|
141
185
|
*/
|
|
142
|
-
export function parseCap(flag, value, defaultLimit, all) {
|
|
186
|
+
export function parseCap(flag, value, defaultLimit, all, json = false) {
|
|
143
187
|
const n = value === undefined ? undefined : Number(value);
|
|
144
|
-
|
|
188
|
+
// Resolve --all/value into a cap: an explicit value beside --all is a
|
|
189
|
+
// conflict; --all alone lifts the cap (null); otherwise the value or default.
|
|
190
|
+
const decision = all && n !== undefined ? "conflict" : all ? null : (n ?? defaultLimit);
|
|
145
191
|
// Conflict takes precedence over value validation (an explicit value beside
|
|
146
192
|
// --all is rejected before we scrutinize the value itself).
|
|
147
193
|
if (decision === "conflict") {
|
|
148
|
-
|
|
149
|
-
process.exitCode = ExitCode.Usage;
|
|
194
|
+
usageError({ json }, `${flag} and --all are mutually exclusive`);
|
|
150
195
|
return { ok: false };
|
|
151
196
|
}
|
|
152
197
|
if (n !== undefined && (!Number.isInteger(n) || n < 1)) {
|
|
153
|
-
|
|
154
|
-
process.exitCode = ExitCode.Usage;
|
|
198
|
+
usageError({ json }, `${flag} must be a positive integer`);
|
|
155
199
|
return { ok: false };
|
|
156
200
|
}
|
|
157
201
|
return { ok: true, limit: decision };
|
|
@@ -166,16 +210,16 @@ export function invocation(name, parts) {
|
|
|
166
210
|
].join(" ");
|
|
167
211
|
}
|
|
168
212
|
/**
|
|
169
|
-
* The unified truncation hint: a muted `── N more items — see more: … ·
|
|
170
|
-
*
|
|
213
|
+
* The unified truncation hint: a muted `── N more items — see more: … · … ──`
|
|
214
|
+
* line whose commands echo the user's actual invocation, so a bigger
|
|
171
215
|
* `--limit` or `--all` is one copy-paste away. Returns null when nothing was
|
|
172
216
|
* dropped or the caller already asked for every row.
|
|
173
217
|
*/
|
|
174
|
-
export function truncationHint(base,
|
|
175
|
-
if (!
|
|
218
|
+
export function truncationHint(base, truncation) {
|
|
219
|
+
if (!truncation.truncated || truncation.limit === null)
|
|
176
220
|
return null;
|
|
177
|
-
const more =
|
|
178
|
-
const bigger =
|
|
179
|
-
return dim(`── ${more} more item${more === 1 ? "" : "s"} — see more: \`${base} --limit ${bigger}\` ·
|
|
221
|
+
const more = truncation.total - truncation.shown;
|
|
222
|
+
const bigger = truncation.limit * 2;
|
|
223
|
+
return dim(`── ${more} more item${more === 1 ? "" : "s"} — see more: \`${base} --limit ${bigger}\` · \`${base} --all\` ──`);
|
|
180
224
|
}
|
|
181
225
|
//# sourceMappingURL=read-driver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-driver.js","sourceRoot":"","sources":["../../src/cli/read-driver.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"read-driver.js","sourceRoot":"","sources":["../../src/cli/read-driver.ts"],"names":[],"mappings":"AAAA;;;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AG,CACR,MAAM,IAAI,aAAa,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,kBAAkB,IAAI,YAAY,MAAM,UAAU,IAAI,aAAa,CAChH,CAAC;AACJ,CAAC"}
|
package/dist/cli/render.d.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* (agents and humans both need stable references); colors engage on a TTY only
|
|
8
8
|
* (../cli/style.ts).
|
|
9
9
|
*/
|
|
10
|
-
import { type ListItem, type SidebarSection, type TodayView } from "../
|
|
11
|
-
import {
|
|
10
|
+
import { type GroupedLimits, type GroupedTruncation, type ListItem, type SectionCount, type SidebarSection, type TodayView } from "../index.ts";
|
|
11
|
+
import { stripSgr } from "./width.ts";
|
|
12
12
|
/**
|
|
13
13
|
* A view's TTY-only title preamble: bold view name + its dim Things deep link,
|
|
14
14
|
* then a blank line — e.g. `Anytime (things:///show?id=anytime)`. The id is the
|
|
@@ -17,7 +17,8 @@ import { type GroupedLimits } from "../read/pagination.ts";
|
|
|
17
17
|
* of `--json`; the caller gates on both.
|
|
18
18
|
*/
|
|
19
19
|
export declare function viewHeaderLines(view: string): string[];
|
|
20
|
-
export
|
|
20
|
+
/** Re-export the canonical ANSI-stripper (impl in ./width.ts) — the legend and `--json` legend path use it. */
|
|
21
|
+
export declare const stripAnsi: typeof stripSgr;
|
|
21
22
|
/**
|
|
22
23
|
* The `things legend` layout: the visual language grouped into sections
|
|
23
24
|
* (`── To-dos ──`, …), each row the glyph as it actually renders (color on a
|
|
@@ -27,8 +28,12 @@ export declare const stripAnsi: (s: string) => string;
|
|
|
27
28
|
export declare function renderLegend(): string[];
|
|
28
29
|
export interface FormatOpts {
|
|
29
30
|
/**
|
|
30
|
-
* Render
|
|
31
|
-
*
|
|
31
|
+
* Render this project as a group HEADING: underline the title (its heading
|
|
32
|
+
* ROLE — the project heads the to-do group beneath it, anytime/someday).
|
|
33
|
+
* Bold is UNIVERSAL for project titles (projectTitleAccent, the render-
|
|
34
|
+
* language delta-1 law), so this adds ONLY the underline; the circle glyph
|
|
35
|
+
* and count chip still apply. A plain project ROW (e.g. area-detail's top
|
|
36
|
+
* projects, the projects sidebar) omits this — bold without underline.
|
|
32
37
|
*/
|
|
33
38
|
projectTitle?: boolean;
|
|
34
39
|
/** Container uuids already implied by surrounding output — their context suffix is dropped. */
|
|
@@ -38,20 +43,29 @@ export interface FormatOpts {
|
|
|
38
43
|
now?: Date;
|
|
39
44
|
/** Pre-styled Today/Evening mark (★/⏾), rendered right after the box — GUI position. */
|
|
40
45
|
mark?: string | null;
|
|
41
|
-
/** Dim status word after the box (the GUI's waiting/paused/ended chips on repeating templates). */
|
|
42
|
-
statusWord?: string;
|
|
43
46
|
/** Suppress the ‹date› chip (rows under a day header already carry the date). */
|
|
44
47
|
hideDateChip?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* The container's normal IS the resolved state (the Logbook): completed rows
|
|
50
|
+
* render plain and canceled rows keep their strikethrough but drop the dim —
|
|
51
|
+
* a row marks only its DEVIATIONS from the container. Mixed contexts
|
|
52
|
+
* (project/area show, search --logged/--trashed) omit this, so a resolved row
|
|
53
|
+
* among open ones stays dim/dim-strike. Never changes the status GLYPHS.
|
|
54
|
+
*/
|
|
55
|
+
resolvedNormal?: boolean;
|
|
45
56
|
}
|
|
46
57
|
/**
|
|
47
58
|
* One item line:
|
|
48
59
|
* `<uuid-prefix> <box> [★|⏾] [logged-date] [‹chip›] <title> [‹n›] [⍾] [≡] [≔] (container) #tags [⚑ deadline]`.
|
|
49
60
|
* Repeating templates seat ↻ INSIDE the box (`[↻]`/`(↻)`) rather than as a
|
|
50
|
-
* separate mark; open project
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
61
|
+
* separate mark; open project circles render blue, and project TITLES render
|
|
62
|
+
* bold + default-colored in every state (projectTitleAccent — the render-
|
|
63
|
+
* language law). The box is the glyph-language state carrier (../glyphs.ts):
|
|
64
|
+
* `[ ]`-family for to-dos, `( )`-family for projects — state survives with
|
|
65
|
+
* color stripped. Completed titles dim; canceled titles dim+strike (the `[×]`
|
|
66
|
+
* mark keeps the state when strike/ANSI is unavailable) — except where a view
|
|
67
|
+
* declares resolved its norm (Logbook, `resolvedNormal`), where completed is
|
|
68
|
+
* plain and canceled keeps only its strike. Human output shows
|
|
55
69
|
* a SHORTENED uuid prefix (every command accepts unique prefixes >= 6
|
|
56
70
|
* chars); `uuidWidth` is the display length from uuidDisplayWidth — never
|
|
57
71
|
* below 8 so a copied prefix stays unique across the whole database, not
|
|
@@ -68,6 +82,12 @@ export declare function formatItem(item: ListItem, uuidWidth?: number, opts?: Fo
|
|
|
68
82
|
* startDate is exactly today — the UI's daily expiry), null otherwise.
|
|
69
83
|
*/
|
|
70
84
|
export declare function todayMark(item: ListItem, now?: Date): string | null;
|
|
85
|
+
/** Minimum displayed-prefix length: shorter prefixes collide across the DB. */
|
|
86
|
+
export declare const UUID_DISPLAY_MIN = 8;
|
|
87
|
+
/** The full-form TTY row floor — worst-case furniture + full deadline. See {@link computeFitFloors}. */
|
|
88
|
+
export declare const FULL_FIT_FLOOR: number;
|
|
89
|
+
/** The compact-form TTY row floor — worst-case furniture + compact deadline. See {@link computeFitFloors}. */
|
|
90
|
+
export declare const COMPACT_FIT_FLOOR: number;
|
|
71
91
|
/**
|
|
72
92
|
* Display width for a list's uuid column: the shortest prefix that is
|
|
73
93
|
* unique WITHIN the list, floored at UUID_DISPLAY_MIN (list-local
|
|
@@ -92,15 +112,24 @@ export declare function renderList(items: ListItem[]): string[];
|
|
|
92
112
|
* the per-row ★/⏾, where the marker still carries information.
|
|
93
113
|
*
|
|
94
114
|
* This Evening mirrors the GUI: it renders ONLY when evening items exist —
|
|
95
|
-
* a truly-empty evening has no header at all. `
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
115
|
+
* a truly-empty evening has no header at all. `view` is the rows that survived
|
|
116
|
+
* the global `--limit`; `sections` is the metadata's pre-cap per-section counts
|
|
117
|
+
* ({@link SectionCount}) — the Today/This-Evening totals the hint math needs, so
|
|
118
|
+
* the section stays honest under truncation without a pre-cap copy of the view.
|
|
119
|
+
* When the cap hid some or all evening rows, an honest muted hint counts the
|
|
120
|
+
* hidden ones and points at the isolated `--evening` view — never the misleading
|
|
121
|
+
* `(empty)` a truncated evening used to show. (In `--evening` mode that pointer
|
|
122
|
+
* is redundant, so the hint keeps the `--limit`/`--all` levers instead.) `base`
|
|
123
|
+
* is the user's own invocation (flags echoed). The global footer (row driver)
|
|
124
|
+
* still reports the whole-view remainder separately.
|
|
125
|
+
*
|
|
126
|
+
* `options.eveningOnly` (the `--evening` section filter) renders ONLY the This
|
|
127
|
+
* Evening block — the Today header and its `(empty)` placeholder are suppressed
|
|
128
|
+
* because that section is deliberately filtered out, not merely empty.
|
|
102
129
|
*/
|
|
103
|
-
export declare function renderToday(
|
|
130
|
+
export declare function renderToday(view: TodayView, sections: SectionCount[] | undefined, base: string, options?: {
|
|
131
|
+
eveningOnly?: boolean;
|
|
132
|
+
}): string[];
|
|
104
133
|
/**
|
|
105
134
|
* Search rows: a standard list row, plus — for a project surfaced by a HEADING
|
|
106
135
|
* title match — a muted `(via heading "…")` suffix crediting the heading whose
|
|
@@ -136,6 +165,12 @@ export declare function renderProjectsSidebar(items: ListItem[], hints?: LaterHi
|
|
|
136
165
|
* absent), with the trailing Repeating To-Dos section: templates with no
|
|
137
166
|
* set next occurrence, carrying their waiting/paused/ended status word and
|
|
138
167
|
* the bare ⚑ when the rule will assign a deadline per occurrence.
|
|
168
|
+
*
|
|
169
|
+
* Deadline-forecast rows (UPC1) keep startDate=null but carry a real future
|
|
170
|
+
* deadline; they group under their DEADLINE date via COALESCE(startDate,
|
|
171
|
+
* deadline) — no when-date pill (the header carries the date; formatItem's
|
|
172
|
+
* chip keys on startDate, so a null-startDate row shows only the ⚑ deadline
|
|
173
|
+
* flag, mirroring the GUI's bare-flag anatomy).
|
|
139
174
|
*/
|
|
140
175
|
export declare function renderUpcoming(items: ListItem[], now?: Date): string[];
|
|
141
176
|
/**
|
|
@@ -143,6 +178,9 @@ export declare function renderUpcoming(items: ListItem[], now?: Date): string[];
|
|
|
143
178
|
* — `── July ──` within the current year, `── March 2025 ──` beyond (finer
|
|
144
179
|
* than the GUI's bare per-year buckets, deliberately). Truncation past the
|
|
145
180
|
* row limit is reported by the shared hint the command appends, not here.
|
|
181
|
+
* Resolved is the Logbook's NORM, so rows pass `resolvedNormal`: completed
|
|
182
|
+
* titles render plain and canceled titles keep their strikethrough but drop
|
|
183
|
+
* the dim (the blue `[✓]`/`[×]` marks and logged date are unchanged).
|
|
146
184
|
*/
|
|
147
185
|
export declare function renderLogbook(items: ListItem[], now?: Date): string[];
|
|
148
186
|
/**
|
|
@@ -157,16 +195,42 @@ export declare function renderLogbook(items: ListItem[], now?: Date): string[];
|
|
|
157
195
|
* with the Today-membership mark (★, or ⏾ for This-Evening members).
|
|
158
196
|
*/
|
|
159
197
|
export declare function renderSections(sections: SidebarSection[], star?: boolean): string[];
|
|
198
|
+
/** Single-quote a title for a copy-pasteable drill-down command. */
|
|
199
|
+
export declare function quoteTitle(title: string): string;
|
|
200
|
+
/**
|
|
201
|
+
* The one disclosure-hint grammar (docs/design/render-language.md § Disclosure
|
|
202
|
+
* hints): a muted `… <count> <noun> — [label:] `command` [· [label:] `command`]`.
|
|
203
|
+
* Every muted hint that discloses more content routes through here so the
|
|
204
|
+
* grammar lives in ONE place (the same one-law pattern as projectTitleAccent).
|
|
205
|
+
*
|
|
206
|
+
* `count` pluralizes `noun` (pass a `{ one, many }` pair when the plural is not
|
|
207
|
+
* a trailing `s`); each action is a FULL command echoing the user's own
|
|
208
|
+
* invocation, and a `label` prefixes an action only where it adds semantics the
|
|
209
|
+
* command text doesn't carry (e.g. `recent:` before a capped `--show-logged`).
|
|
210
|
+
* `indent` marks a TRUNCATION FOOTER — two spaces under its partially-shown
|
|
211
|
+
* section — whereas a HIDDEN-SECTION placeholder stays flush at the position
|
|
212
|
+
* its unrendered section would occupy.
|
|
213
|
+
*/
|
|
214
|
+
export declare function disclosureHint(count: number, noun: string | {
|
|
215
|
+
one: string;
|
|
216
|
+
many: string;
|
|
217
|
+
}, actions: Array<{
|
|
218
|
+
label?: string;
|
|
219
|
+
command: string;
|
|
220
|
+
}>, opts?: {
|
|
221
|
+
indent?: boolean;
|
|
222
|
+
}): string;
|
|
160
223
|
/**
|
|
161
224
|
* The anytime preview: the FULL block skeleton — every area header and every
|
|
162
|
-
* project row — always renders; `
|
|
163
|
-
*
|
|
164
|
-
* block trails a muted `… N more — \`things (project|area) show
|
|
165
|
-
* drill-down (the loose block has no container, so it shows only the
|
|
166
|
-
* and the view ends with one line escalating the caps that hit
|
|
167
|
-
*
|
|
225
|
+
* project row — always renders; the `sections` are the already-bounded view
|
|
226
|
+
* and `grouped` the per-block metadata that carries each block's pre-cap total,
|
|
227
|
+
* so a truncated block trails a muted `… N more — \`things (project|area) show
|
|
228
|
+
* '…'\`` drill-down (the loose block has no container, so it shows only the
|
|
229
|
+
* count), and the view ends with one line escalating the caps that hit
|
|
230
|
+
* (`limits` supplies the doubling). Today members are starred. Mirrors
|
|
231
|
+
* renderSections' layout exactly.
|
|
168
232
|
*/
|
|
169
|
-
export declare function renderAnytimePreview(sections: SidebarSection[], limits: GroupedLimits, base: string): string[];
|
|
233
|
+
export declare function renderAnytimePreview(sections: SidebarSection[], grouped: GroupedTruncation, limits: GroupedLimits, base: string): string[];
|
|
170
234
|
/**
|
|
171
235
|
* The someday preview, mirroring the GUI (side-by-side, 2026-07-12): inside
|
|
172
236
|
* each group the project rows render as PLAIN items — `(~)` circle, count
|
|
@@ -179,4 +243,4 @@ export declare function renderAnytimePreview(sections: SidebarSection[], limits:
|
|
|
179
243
|
* When the toggle is off and such items exist, a muted bottom hint counts
|
|
180
244
|
* them and names the flag.
|
|
181
245
|
*/
|
|
182
|
-
export declare function renderSomedayPreview(sections: SidebarSection[], limits: GroupedLimits, base: string, showActive: boolean, hiddenActiveItems: number): string[];
|
|
246
|
+
export declare function renderSomedayPreview(sections: SidebarSection[], grouped: GroupedTruncation, limits: GroupedLimits, base: string, showActive: boolean, hiddenActiveItems: number): string[];
|