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/dist/cli/main.js
CHANGED
|
@@ -7,46 +7,37 @@
|
|
|
7
7
|
import { realpathSync } from "node:fs";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
9
|
import { Command } from "commander";
|
|
10
|
+
import { registerHelp } from "./help.js";
|
|
11
|
+
import { installExcessArgsHelp } from "./excess-args.js";
|
|
10
12
|
import { registerDoctor } from "./commands/doctor.js";
|
|
11
13
|
import { registerMcp } from "./commands/mcp.js";
|
|
12
14
|
import { registerAreaCommands } from "./commands/area.js";
|
|
13
15
|
import { registerProjectCommands } from "./commands/project.js";
|
|
14
16
|
import { registerReadCommands } from "./commands/reads.js";
|
|
15
17
|
import { registerSetup } from "./commands/setup.js";
|
|
18
|
+
import { registerInstallSkill } from "./commands/install-skill.js";
|
|
16
19
|
import { registerShowCommands } from "./commands/show.js";
|
|
17
20
|
import { registerSnapshot } from "./commands/snapshot.js";
|
|
18
21
|
import { registerTodoCommands } from "./commands/todo.js";
|
|
19
22
|
import { registerWriteCommands } from "./commands/writes.js";
|
|
20
23
|
import { resolveInvocation } from "./resolve-invocation.js";
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- A Things share link (Share > Copy Link, "things:///show?id=<uuid>") is
|
|
29
|
-
accepted anywhere a uuid or name is expected — it is stripped to the id.
|
|
30
|
-
- The word \`show\` may be omitted: \`things <ref>\` shows the referenced
|
|
31
|
-
item whenever <ref> is not a command name (command names always win).
|
|
32
|
-
- Exit codes are stable: 0 ok, 2 usage, 3 verify-failed, 4 blocked,
|
|
33
|
-
5 drift-blocked, 6 unsupported, 7 environment.
|
|
34
|
-
- No command ever prompts interactively; operations with cascading or
|
|
35
|
-
permanent effects require explicit flags documented in their --help.
|
|
36
|
-
- Discover the full operation catalog with: things capabilities --json
|
|
37
|
-
- Symbols & colors in list output: run \`things legend\` (add --json for the table).
|
|
38
|
-
- Every write supports --dry-run: preview the planned change and its
|
|
39
|
-
expected effect without executing anything.
|
|
40
|
-
- Failures are loud: a change that does not take effect exits 3; refused
|
|
41
|
-
changes exit 4 with machine-readable remediation.
|
|
42
|
-
`;
|
|
24
|
+
import { runVerbHint } from "./verb-hint.js";
|
|
25
|
+
import { detectMoveHint, runMoveHint } from "./move-hint.js";
|
|
26
|
+
import { setRenderClock } from "./clock.js";
|
|
27
|
+
import { maybeEmitSkillDriftNote } from "./skill-check.js";
|
|
28
|
+
import { resolveWidth, setFitWidth } from "./width.js";
|
|
29
|
+
import { CLI_VERSION } from "./version.js";
|
|
30
|
+
import { ExitCode, resolveClock } from "../index.js";
|
|
43
31
|
export function buildProgram() {
|
|
44
32
|
const program = new Command();
|
|
45
33
|
program
|
|
46
34
|
.name("things")
|
|
47
35
|
.description("Programmatic interface to Things 3 (Cultured Code)")
|
|
48
|
-
.version(
|
|
49
|
-
|
|
36
|
+
.version(CLI_VERSION)
|
|
37
|
+
// Unknown-command typos are answered with "did you mean …" (default on;
|
|
38
|
+
// stated for the record — most top-level typos route through the bare-noun
|
|
39
|
+
// did-you-mean instead, this covers the subcommand groups).
|
|
40
|
+
.showSuggestionAfterError(true);
|
|
50
41
|
registerDoctor(program);
|
|
51
42
|
registerReadCommands(program);
|
|
52
43
|
registerShowCommands(program);
|
|
@@ -55,11 +46,42 @@ export function buildProgram() {
|
|
|
55
46
|
registerTodoCommands(program);
|
|
56
47
|
registerWriteCommands(program);
|
|
57
48
|
registerSetup(program);
|
|
49
|
+
registerInstallSkill(program);
|
|
58
50
|
registerSnapshot(program);
|
|
59
51
|
registerMcp(program);
|
|
52
|
+
// The signpost index + `help [topic]` replace the multi-scroll epilog; the
|
|
53
|
+
// improved excess-argument message names the command and its usage line.
|
|
54
|
+
registerHelp(program);
|
|
55
|
+
installExcessArgsHelp(program);
|
|
60
56
|
return program;
|
|
61
57
|
}
|
|
62
58
|
export function runCli() {
|
|
59
|
+
// Resolve the width-aware row fit ONCE at startup (docs/design/width-aware-
|
|
60
|
+
// tty.md): THINGS_WIDTH override, else stdout.columns on a TTY, else null (no
|
|
61
|
+
// fitting — pipes/grep/--json byte-stable). Threaded to the renderers via the
|
|
62
|
+
// module-level fit width in ./width.ts, so every human list path inherits it
|
|
63
|
+
// and MCP/--json never touch it.
|
|
64
|
+
setFitWidth(resolveWidth({
|
|
65
|
+
env: process.env,
|
|
66
|
+
columns: process.stdout.columns,
|
|
67
|
+
isTTY: process.stdout.isTTY === true,
|
|
68
|
+
}));
|
|
69
|
+
// Resolve the consumer clock ONCE (THINGS_TZ / THINGS_NOW) so the human
|
|
70
|
+
// renderers and period parsers evaluate dates in the same zone the library
|
|
71
|
+
// does. A malformed value is NOT fatal here: the command's own client-open
|
|
72
|
+
// re-resolves it and surfaces the usage error with --json awareness — so
|
|
73
|
+
// leave the render clock on the host default if resolution throws.
|
|
74
|
+
try {
|
|
75
|
+
const clock = resolveClock({ env: process.env });
|
|
76
|
+
setRenderClock({ now: clock.now, zone: clock.zone });
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// handled by the command path (openThings → runRead/runWrite usage error)
|
|
80
|
+
}
|
|
81
|
+
// Passive skill-drift notice: one stderr line when the installed agent skill
|
|
82
|
+
// is well behind this binary's bundled copy (human paths only, never --json /
|
|
83
|
+
// mcp; kill switch THINGS_API_NO_SKILL_CHECK=1). Silent on any error/absence.
|
|
84
|
+
maybeEmitSkillDriftNote({ argv: process.argv.slice(2), env: process.env });
|
|
63
85
|
const program = buildProgram();
|
|
64
86
|
program.exitOverride((err) => {
|
|
65
87
|
process.exit(err.exitCode === 0 ? ExitCode.Ok : ExitCode.Usage);
|
|
@@ -67,8 +89,24 @@ export function runCli() {
|
|
|
67
89
|
// The single router (docs/design/cli-grammar.md): classify the invocation,
|
|
68
90
|
// then dispatch its normalized argv. Sugar forms (bare noun, keyword-in-show)
|
|
69
91
|
// normalize into the canonical grammar here.
|
|
70
|
-
const
|
|
71
|
-
|
|
92
|
+
const resolved = resolveInvocation(program, process.argv.slice(2));
|
|
93
|
+
// A bare top-level mutation verb (`things update <ref>`) never reaches
|
|
94
|
+
// commander: it is answered with a namespaced-write suggestion instead of the
|
|
95
|
+
// show-sugar's confusing usage error (docs/design/cli-grammar.md).
|
|
96
|
+
if (resolved.form === "verb-hint") {
|
|
97
|
+
runVerbHint(program, resolved.argv);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// A namespaced `move` carrying scheduling intent (`todo move X --when today`,
|
|
101
|
+
// `todo move X someday`) is answered with the command that actually schedules
|
|
102
|
+
// an item, instead of a bare unknown-option / excess-argument usage error
|
|
103
|
+
// (docs/design/cli-grammar.md). Never fires on a valid container move.
|
|
104
|
+
const moveHint = detectMoveHint(program, resolved.argv);
|
|
105
|
+
if (moveHint !== null) {
|
|
106
|
+
runMoveHint(moveHint);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
program.parse(resolved.argv, { from: "user" });
|
|
72
110
|
}
|
|
73
111
|
// Direct-run detection must survive the npm .bin symlink (argv[1] ends with
|
|
74
112
|
// "things", not "main.js") — resolve through realpath and compare to this
|
package/dist/cli/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AACA;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AACA;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,a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C;QACtB,OAAO;IACT,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AACjD,CAAC;AAED,4EAA4E;AAC5E,0EAA0E;AAC1E,wEAAwE;AACxE,4EAA4E;AAC5E,+BAA+B;AAC/B,MAAM,WAAW,GAAG,CAAC,GAAY,EAAE;IACjC,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChC,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,OAAO,CAAC,KAAK,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC,EAAE,CAAC;AACL,IAAI,WAAW,EAAE,CAAC;IAChB,MAAM,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The scheduling-intent hint for a namespaced `move` (docs/design/cli-grammar.md).
|
|
3
|
+
* `things todo move <ref>` and `things project move <ref>` take CONTAINER
|
|
4
|
+
* destinations only (--area/--project/--heading; todo also --inbox/--detach).
|
|
5
|
+
* An agent carrying scheduling intent ("move X to Someday") reaches for
|
|
6
|
+
* spellings `move` does not accept — `--to someday`, `--when today`,
|
|
7
|
+
* `--someday`, or a bare `someday` positional — and would otherwise land on a
|
|
8
|
+
* bare unknown-option / excess-argument usage error that never names the
|
|
9
|
+
* command which actually schedules an item.
|
|
10
|
+
*
|
|
11
|
+
* This runs BEFORE commander parses (like the bare-verb hint) and, when it
|
|
12
|
+
* recognizes scheduling vocabulary on a `move` invocation, answers with the
|
|
13
|
+
* concrete command that works:
|
|
14
|
+
*
|
|
15
|
+
* - a scheduling term (`someday`/`today`/`evening`/`anytime`/a date), as a
|
|
16
|
+
* flag value or a stray positional → `things <group> update <ref> --when <value>`.
|
|
17
|
+
* - a bare `inbox` positional on `todo move` → `things todo move <ref> --inbox`
|
|
18
|
+
* (the real Inbox-return; `--when inbox` is not a thing).
|
|
19
|
+
*
|
|
20
|
+
* It NEVER fires on a valid move: every trapped spelling is already a usage
|
|
21
|
+
* error, so the accepted grammar is unchanged. Exit class stays Usage (2);
|
|
22
|
+
* under `--json` the suggestion rides `error.details.suggestions`.
|
|
23
|
+
*/
|
|
24
|
+
import type { Command } from "commander";
|
|
25
|
+
/** The corrected command this hint points at. */
|
|
26
|
+
export interface MoveHint {
|
|
27
|
+
group: "todo" | "project";
|
|
28
|
+
/** Whether the caller asked for a --json envelope. */
|
|
29
|
+
json: boolean;
|
|
30
|
+
/** Inbox return vs. a schedule change — selects the wording. */
|
|
31
|
+
intent: "schedule" | "inbox";
|
|
32
|
+
/** The full, runnable suggestion (already shell-quoted). */
|
|
33
|
+
suggestion: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Classify a `<group> move` invocation for scheduling intent. Returns the
|
|
37
|
+
* corrected-command hint when a trapped spelling is present, else null (the
|
|
38
|
+
* invocation falls through to commander unchanged).
|
|
39
|
+
*/
|
|
40
|
+
export declare function detectMoveHint(program: Command, argv: string[]): MoveHint | null;
|
|
41
|
+
/**
|
|
42
|
+
* Emit the scheduling-intent hint and set the Usage exit code. Never opens the
|
|
43
|
+
* write pipeline — it only rewrites the failing invocation into a working one.
|
|
44
|
+
*/
|
|
45
|
+
export declare function runMoveHint(hint: MoveHint): void;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { errorEnvelope, ExitCode } from "../index.js";
|
|
2
|
+
import { indexPastLeadingFlags } from "./resolve-invocation.js";
|
|
3
|
+
import { shellQuote } from "./shell-quote.js";
|
|
4
|
+
/** The write groups whose `move` subcommand this hint guards. */
|
|
5
|
+
const MOVE_GROUPS = new Set(["todo", "project"]);
|
|
6
|
+
/**
|
|
7
|
+
* Flag spellings that signal scheduling intent on a `move` — none is a real
|
|
8
|
+
* `move` option, so their presence is always a usage error we can improve.
|
|
9
|
+
* `--inbox` is deliberately absent: it is a genuine `todo move` destination.
|
|
10
|
+
*/
|
|
11
|
+
const SCHEDULING_FLAGS = new Set([
|
|
12
|
+
"--to",
|
|
13
|
+
"--when",
|
|
14
|
+
"--someday",
|
|
15
|
+
"--today",
|
|
16
|
+
"--evening",
|
|
17
|
+
"--anytime",
|
|
18
|
+
"--date",
|
|
19
|
+
"--schedule",
|
|
20
|
+
]);
|
|
21
|
+
/** Scheduling flags that carry their term as the NEXT token (or `--flag=term`). */
|
|
22
|
+
const VALUE_SCHEDULING_FLAGS = new Set(["--to", "--when", "--date", "--schedule"]);
|
|
23
|
+
/** Boolean-style scheduling flags whose name IS the `--when` term. */
|
|
24
|
+
const FLAG_TERM = {
|
|
25
|
+
"--someday": "someday",
|
|
26
|
+
"--today": "today",
|
|
27
|
+
"--evening": "evening",
|
|
28
|
+
"--anytime": "anytime",
|
|
29
|
+
};
|
|
30
|
+
/** Recognized `--when` terms (a date is matched separately). */
|
|
31
|
+
const WHEN_TERMS = new Set(["today", "evening", "anytime", "someday"]);
|
|
32
|
+
/** Positional destinations that read as scheduling intent, not a container. */
|
|
33
|
+
const SCHEDULING_POSITIONALS = new Set(["someday", "today", "evening", "anytime", "inbox"]);
|
|
34
|
+
/** A bare `YYYY-MM-DD` — a valid `--when` value, never a container name. */
|
|
35
|
+
function isDate(token) {
|
|
36
|
+
return /^\d{4}-\d{2}-\d{2}$/.test(token);
|
|
37
|
+
}
|
|
38
|
+
/** Long/short flag names of `<group> move` that consume the following token. */
|
|
39
|
+
function valueFlagsFor(program, group) {
|
|
40
|
+
const names = new Set();
|
|
41
|
+
const groupCmd = program.commands.find((c) => c.name() === group);
|
|
42
|
+
const moveCmd = groupCmd?.commands.find((c) => c.name() === "move");
|
|
43
|
+
if (moveCmd === undefined)
|
|
44
|
+
return names;
|
|
45
|
+
for (const opt of moveCmd.options) {
|
|
46
|
+
// Commander marks value-taking options `<x>` (required) or `[x]` (optional).
|
|
47
|
+
if (opt.required === true || opt.optional === true) {
|
|
48
|
+
if (opt.long !== undefined)
|
|
49
|
+
names.add(opt.long);
|
|
50
|
+
if (opt.short !== undefined)
|
|
51
|
+
names.add(opt.short);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return names;
|
|
55
|
+
}
|
|
56
|
+
/** Map a raw scheduling term to a valid `--when` value (park by default). */
|
|
57
|
+
function whenValue(term) {
|
|
58
|
+
if (term !== null && (WHEN_TERMS.has(term.toLowerCase()) || isDate(term))) {
|
|
59
|
+
return term.toLowerCase() === term ? term : term.toLowerCase();
|
|
60
|
+
}
|
|
61
|
+
return "someday";
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Walk the tokens after `<group> move`, skipping global/known value flags so
|
|
65
|
+
* their values are never misread as a positional destination (`--heading
|
|
66
|
+
* someday` moves under a heading literally named "someday" — not a trap).
|
|
67
|
+
*/
|
|
68
|
+
function scan(tokens, valueFlags) {
|
|
69
|
+
const positionals = [];
|
|
70
|
+
let flagTerm = null;
|
|
71
|
+
let flagIntent = false;
|
|
72
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
73
|
+
const tok = tokens[i] ?? "";
|
|
74
|
+
if (tok.startsWith("-")) {
|
|
75
|
+
const eq = tok.indexOf("=");
|
|
76
|
+
const name = eq >= 0 ? tok.slice(0, eq) : tok;
|
|
77
|
+
const inline = eq >= 0 ? tok.slice(eq + 1) : undefined;
|
|
78
|
+
if (SCHEDULING_FLAGS.has(name)) {
|
|
79
|
+
if (!flagIntent) {
|
|
80
|
+
if (VALUE_SCHEDULING_FLAGS.has(name)) {
|
|
81
|
+
flagTerm = inline ?? tokens[i + 1] ?? null;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
flagTerm = FLAG_TERM[name] ?? null;
|
|
85
|
+
}
|
|
86
|
+
flagIntent = true;
|
|
87
|
+
}
|
|
88
|
+
if (VALUE_SCHEDULING_FLAGS.has(name) && inline === undefined)
|
|
89
|
+
i++; // consume its term
|
|
90
|
+
}
|
|
91
|
+
else if (valueFlags.has(name) && inline === undefined) {
|
|
92
|
+
i++; // a known value flag — skip its value, it is not a positional
|
|
93
|
+
}
|
|
94
|
+
// boolean / unknown flags carry no positional to protect
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
positionals.push(tok);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
ref: positionals[0] ?? null,
|
|
102
|
+
dest: positionals[1] ?? null,
|
|
103
|
+
flagTerm,
|
|
104
|
+
flagIntent,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Classify a `<group> move` invocation for scheduling intent. Returns the
|
|
109
|
+
* corrected-command hint when a trapped spelling is present, else null (the
|
|
110
|
+
* invocation falls through to commander unchanged).
|
|
111
|
+
*/
|
|
112
|
+
export function detectMoveHint(program, argv) {
|
|
113
|
+
const at = indexPastLeadingFlags(argv);
|
|
114
|
+
if (at === null)
|
|
115
|
+
return null;
|
|
116
|
+
const group = argv[at];
|
|
117
|
+
if (group === undefined || !MOVE_GROUPS.has(group))
|
|
118
|
+
return null;
|
|
119
|
+
if (argv[at + 1] !== "move")
|
|
120
|
+
return null;
|
|
121
|
+
const g = group;
|
|
122
|
+
const s = scan(argv.slice(at + 2), valueFlagsFor(program, group));
|
|
123
|
+
const json = argv.includes("--json");
|
|
124
|
+
const refEcho = s.ref !== null ? shellQuote(s.ref) : "<ref>";
|
|
125
|
+
// Precedence: an explicit scheduling FLAG wins over a positional read.
|
|
126
|
+
if (s.flagIntent) {
|
|
127
|
+
return {
|
|
128
|
+
group: g,
|
|
129
|
+
json,
|
|
130
|
+
intent: "schedule",
|
|
131
|
+
suggestion: `things ${g} update ${refEcho} --when ${whenValue(s.flagTerm)}`,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
// A stray positional destination that reads as scheduling vocabulary.
|
|
135
|
+
const dest = s.dest;
|
|
136
|
+
if (dest === null)
|
|
137
|
+
return null;
|
|
138
|
+
const lower = dest.toLowerCase();
|
|
139
|
+
if (lower === "inbox") {
|
|
140
|
+
// Only to-dos have an Inbox, and its return is a flag (`--when inbox` is not
|
|
141
|
+
// a thing). A project has no Inbox — leave that to commander.
|
|
142
|
+
if (g !== "todo")
|
|
143
|
+
return null;
|
|
144
|
+
return {
|
|
145
|
+
group: g,
|
|
146
|
+
json,
|
|
147
|
+
intent: "inbox",
|
|
148
|
+
suggestion: `things todo move ${refEcho} --inbox`,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (SCHEDULING_POSITIONALS.has(lower) || isDate(dest)) {
|
|
152
|
+
return {
|
|
153
|
+
group: g,
|
|
154
|
+
json,
|
|
155
|
+
intent: "schedule",
|
|
156
|
+
suggestion: `things ${g} update ${refEcho} --when ${whenValue(dest)}`,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
/** The lead line naming what `move` does — scheduling vs. Inbox framing. */
|
|
162
|
+
function leadLine(hint) {
|
|
163
|
+
return hint.intent === "inbox"
|
|
164
|
+
? `error: \`things ${hint.group} move\` takes a container flag, not a positional destination.`
|
|
165
|
+
: `error: \`things ${hint.group} move\` changes an item's container, not its schedule.`;
|
|
166
|
+
}
|
|
167
|
+
/** The action line inviting the corrected command. */
|
|
168
|
+
function actionLine(hint) {
|
|
169
|
+
return hint.intent === "inbox"
|
|
170
|
+
? `to send an item back to the Inbox use: ${hint.suggestion}`
|
|
171
|
+
: `to schedule or park an item use: ${hint.suggestion}`;
|
|
172
|
+
}
|
|
173
|
+
/** Human render: the framing line, the corrected command, the container reminder. */
|
|
174
|
+
function renderHuman(hint) {
|
|
175
|
+
return [
|
|
176
|
+
leadLine(hint),
|
|
177
|
+
actionLine(hint),
|
|
178
|
+
`move changes containers (--area/--project/--heading).`,
|
|
179
|
+
].join("\n");
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Emit the scheduling-intent hint and set the Usage exit code. Never opens the
|
|
183
|
+
* write pipeline — it only rewrites the failing invocation into a working one.
|
|
184
|
+
*/
|
|
185
|
+
export function runMoveHint(hint) {
|
|
186
|
+
if (hint.json) {
|
|
187
|
+
const meta = { dbVersion: null, fingerprint: "unknown", elapsedMs: 0 };
|
|
188
|
+
const message = `${leadLine(hint).replace(/^error: /, "")} ${actionLine(hint)}`;
|
|
189
|
+
process.stdout.write(`${JSON.stringify(errorEnvelope({ code: "usage", message, details: { suggestions: [hint.suggestion] } }, meta))}\n`);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
process.stderr.write(`${renderHuman(hint)}\n`);
|
|
193
|
+
}
|
|
194
|
+
process.exitCode = ExitCode.Usage;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=move-hint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-hint.js","sourceRoot":"","sources":["../../src/cli/move-hint.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,iEAAiE;AACjE,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAEjD;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,MAAM;IACN,QAAQ;IACR,WAAW;IACX,SAAS;IACT,WAAW;IACX,WAAW;IACX,QAAQ;IACR,YAAY;CACb,CAAC,CAAC;AAEH,mFAAmF;AACnF,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAA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;QAChF,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,GAAG,IAAI,CAAC,SAAS,CACf,aAAa,CACX,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,EACvE,IAAI,CACL,CACF,IAAI,CACN,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC;AACpC,CAAC"}
|
package/dist/cli/period.d.ts
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Period-and-calendar grammar shared by the read views: the `--since`/`--until`
|
|
3
|
-
* whole-period parsers, the relative-period (`3d`/`2w`/`1m`/`1y`) grammar, and
|
|
4
|
-
* the Upcoming date-bucket labeller. Fully pure — no CLI or app imports — so
|
|
5
|
-
* the renderers and command registrations can both draw on it.
|
|
6
|
-
*/
|
|
7
1
|
declare const FULL_MONTHS: readonly ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
8
2
|
export { FULL_MONTHS };
|
|
3
|
+
/**
|
|
4
|
+
* Double a relative period for a "wider window" suggestion: `1m`→`2m`,
|
|
5
|
+
* `2w`→`4w`, `1y`→`2y`. A non-relative input (an absolute calendar period
|
|
6
|
+
* like `2026-09`) comes back unchanged — there is nothing sensible to double.
|
|
7
|
+
* Deliberately dumb: it only scales the count of a `\d+[dwmy]` period.
|
|
8
|
+
*/
|
|
9
|
+
export declare function doublePeriod(period: string): string;
|
|
9
10
|
/**
|
|
10
11
|
* `--until` accepting whole periods: `2024` means through Dec 31 2024,
|
|
11
12
|
* `2024-03` through Mar 31, `2024-03-05` through end of that day; relative
|
|
12
13
|
* periods (`2w`, `1m`, `1y`) count FORWARD from now through the end of the
|
|
13
14
|
* landing day; anything else parses as an instant.
|
|
14
15
|
*/
|
|
15
|
-
export declare function parsePeriodEnd(s: string, now?: Date): Date;
|
|
16
|
+
export declare function parsePeriodEnd(s: string, now?: Date, zone?: string): Date;
|
|
16
17
|
/**
|
|
17
18
|
* `--since` accepting the same vocabulary at the period's START: `2024` =
|
|
18
19
|
* Jan 1 2024 00:00, `2024-03` = Mar 1, `2024-03-05` = that midnight;
|
|
19
20
|
* relative periods (`2w`, `1m`) count BACKWARD from now to the landing
|
|
20
21
|
* day's midnight; anything else parses as an instant.
|
|
21
22
|
*/
|
|
22
|
-
export declare function parsePeriodStart(s: string, now?: Date): Date;
|
|
23
|
+
export declare function parsePeriodStart(s: string, now?: Date, zone?: string): Date;
|
|
23
24
|
/**
|
|
24
25
|
* GUI-style Upcoming bucket for a date, granularity decaying with distance:
|
|
25
26
|
* individual days for the next week ("Wed Jul 15"), the remainder of the
|
package/dist/cli/period.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Period-and-calendar grammar shared by the read views: the `--since`/`--until`
|
|
3
3
|
* whole-period parsers, the relative-period (`3d`/`2w`/`1m`/`1y`) grammar, and
|
|
4
|
-
* the Upcoming date-bucket labeller.
|
|
5
|
-
* the
|
|
4
|
+
* the Upcoming date-bucket labeller. The only library dependency is the pair of
|
|
5
|
+
* zone-aware date helpers (through the single entry point) so a `--since 2w` is
|
|
6
|
+
* counted in the CONSUMER'S calendar, not the host's — byte-identical to the
|
|
7
|
+
* host math when no zone is in effect.
|
|
6
8
|
*/
|
|
9
|
+
import { dayBoundInstant, localToday } from "../index.js";
|
|
7
10
|
const FULL_MONTHS = [
|
|
8
11
|
"January",
|
|
9
12
|
"February",
|
|
@@ -40,19 +43,57 @@ export { FULL_MONTHS };
|
|
|
40
43
|
* bound (each command's natural direction; the flag name carries it).
|
|
41
44
|
*/
|
|
42
45
|
const RELATIVE_PERIOD = /^(\d+)([dwmy])$/i;
|
|
43
|
-
|
|
46
|
+
/** Format a UTC-anchored Date's date fields as `YYYY-MM-DD`. */
|
|
47
|
+
function isoFromUtc(dt) {
|
|
48
|
+
return `${String(dt.getUTCFullYear()).padStart(4, "0")}-${String(dt.getUTCMonth() + 1).padStart(2, "0")}-${String(dt.getUTCDate()).padStart(2, "0")}`;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The target CALENDAR date for a relative period, counted from a base ISO date
|
|
52
|
+
* (the consumer's today) — days/weeks add days, months/years use the JS Date
|
|
53
|
+
* overflow the host arithmetic always used (Jan 31 + 1m → Mar 3). Pure calendar
|
|
54
|
+
* math on the date fields (UTC-anchored so the host zone never intrudes), so it
|
|
55
|
+
* is zone-agnostic once the base date is chosen.
|
|
56
|
+
*/
|
|
57
|
+
function relativeTargetIso(m, baseIso, sign) {
|
|
58
|
+
const [y, mo, d] = baseIso.split("-").map(Number);
|
|
59
|
+
const dt = new Date(Date.UTC(y ?? 1970, (mo ?? 1) - 1, d ?? 1));
|
|
44
60
|
const n = sign * Number(m[1]);
|
|
45
61
|
const unit = (m[2] ?? "").toLowerCase();
|
|
46
|
-
const d = new Date(now);
|
|
47
62
|
if (unit === "d")
|
|
48
|
-
|
|
63
|
+
dt.setUTCDate(dt.getUTCDate() + n);
|
|
49
64
|
else if (unit === "w")
|
|
50
|
-
|
|
65
|
+
dt.setUTCDate(dt.getUTCDate() + 7 * n);
|
|
51
66
|
else if (unit === "m")
|
|
52
|
-
|
|
67
|
+
dt.setUTCMonth(dt.getUTCMonth() + n);
|
|
53
68
|
else
|
|
54
|
-
|
|
55
|
-
return
|
|
69
|
+
dt.setUTCFullYear(dt.getUTCFullYear() + n);
|
|
70
|
+
return isoFromUtc(dt);
|
|
71
|
+
}
|
|
72
|
+
/** The ISO date at a whole absolute period's START or END edge (`2024` → Jan 1 / Dec 31, etc.). */
|
|
73
|
+
function absolutePeriodIso(m, edge) {
|
|
74
|
+
const year = Number(m[1]);
|
|
75
|
+
if (m[2] === undefined)
|
|
76
|
+
return edge === "start" ? `${m[1]}-01-01` : `${m[1]}-12-31`;
|
|
77
|
+
const month = Number(m[2]) - 1;
|
|
78
|
+
if (m[3] === undefined) {
|
|
79
|
+
if (edge === "start")
|
|
80
|
+
return `${m[1]}-${m[2]}-01`;
|
|
81
|
+
const lastDay = new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
|
82
|
+
return `${m[1]}-${m[2]}-${String(lastDay).padStart(2, "0")}`;
|
|
83
|
+
}
|
|
84
|
+
return `${m[1]}-${m[2]}-${m[3]}`;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Double a relative period for a "wider window" suggestion: `1m`→`2m`,
|
|
88
|
+
* `2w`→`4w`, `1y`→`2y`. A non-relative input (an absolute calendar period
|
|
89
|
+
* like `2026-09`) comes back unchanged — there is nothing sensible to double.
|
|
90
|
+
* Deliberately dumb: it only scales the count of a `\d+[dwmy]` period.
|
|
91
|
+
*/
|
|
92
|
+
export function doublePeriod(period) {
|
|
93
|
+
const m = RELATIVE_PERIOD.exec(period.trim());
|
|
94
|
+
if (m === null)
|
|
95
|
+
return period;
|
|
96
|
+
return `${Number(m[1]) * 2}${(m[2] ?? "").toLowerCase()}`;
|
|
56
97
|
}
|
|
57
98
|
/**
|
|
58
99
|
* `--until` accepting whole periods: `2024` means through Dec 31 2024,
|
|
@@ -60,23 +101,15 @@ function relativePeriodDate(m, now, sign) {
|
|
|
60
101
|
* periods (`2w`, `1m`, `1y`) count FORWARD from now through the end of the
|
|
61
102
|
* landing day; anything else parses as an instant.
|
|
62
103
|
*/
|
|
63
|
-
export function parsePeriodEnd(s, now = new Date()) {
|
|
104
|
+
export function parsePeriodEnd(s, now = new Date(), zone) {
|
|
64
105
|
const rel = RELATIVE_PERIOD.exec(s.trim());
|
|
65
106
|
if (rel !== null) {
|
|
66
|
-
|
|
67
|
-
return new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59, 59, 999);
|
|
107
|
+
return dayBoundInstant(relativeTargetIso(rel, localToday(now, zone), 1), "end", zone);
|
|
68
108
|
}
|
|
69
109
|
const m = /^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?$/.exec(s.trim());
|
|
70
110
|
if (m === null)
|
|
71
111
|
return new Date(s);
|
|
72
|
-
|
|
73
|
-
// Day 0 of month n+1 = the last day of month n.
|
|
74
|
-
if (m[2] === undefined)
|
|
75
|
-
return new Date(year, 11, 31, 23, 59, 59, 999);
|
|
76
|
-
const month = Number(m[2]) - 1;
|
|
77
|
-
if (m[3] === undefined)
|
|
78
|
-
return new Date(year, month + 1, 0, 23, 59, 59, 999);
|
|
79
|
-
return new Date(year, month, Number(m[3]), 23, 59, 59, 999);
|
|
112
|
+
return dayBoundInstant(absolutePeriodIso(m, "end"), "end", zone);
|
|
80
113
|
}
|
|
81
114
|
/**
|
|
82
115
|
* `--since` accepting the same vocabulary at the period's START: `2024` =
|
|
@@ -84,22 +117,15 @@ export function parsePeriodEnd(s, now = new Date()) {
|
|
|
84
117
|
* relative periods (`2w`, `1m`) count BACKWARD from now to the landing
|
|
85
118
|
* day's midnight; anything else parses as an instant.
|
|
86
119
|
*/
|
|
87
|
-
export function parsePeriodStart(s, now = new Date()) {
|
|
120
|
+
export function parsePeriodStart(s, now = new Date(), zone) {
|
|
88
121
|
const rel = RELATIVE_PERIOD.exec(s.trim());
|
|
89
122
|
if (rel !== null) {
|
|
90
|
-
|
|
91
|
-
return new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
123
|
+
return dayBoundInstant(relativeTargetIso(rel, localToday(now, zone), -1), "start", zone);
|
|
92
124
|
}
|
|
93
125
|
const m = /^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?$/.exec(s.trim());
|
|
94
126
|
if (m === null)
|
|
95
127
|
return new Date(s);
|
|
96
|
-
|
|
97
|
-
if (m[2] === undefined)
|
|
98
|
-
return new Date(year, 0, 1);
|
|
99
|
-
const month = Number(m[2]) - 1;
|
|
100
|
-
if (m[3] === undefined)
|
|
101
|
-
return new Date(year, month, 1);
|
|
102
|
-
return new Date(year, month, Number(m[3]));
|
|
128
|
+
return dayBoundInstant(absolutePeriodIso(m, "start"), "start", zone);
|
|
103
129
|
}
|
|
104
130
|
/**
|
|
105
131
|
* GUI-style Upcoming bucket for a date, granularity decaying with distance:
|
package/dist/cli/period.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"period.js","sourceRoot":"","sources":["../../src/cli/period.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"period.js","sourceRoot":"","sources":["../../src/cli/period.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAgB,MAAM,aAAa,CAAC;AAExE,MAAM,WAAW,GAAG;IAClB,SAAS;IACT,UAAU;IACV,OAAO;IACP,OAAO;IACP,KAAK;IACL,MAAM;IACN,MAAM;IACN,QAAQ;IACR,WAAW;IACX,SAAS;IACT,UAAU;IACV,UAAU;CACF,CAAC;AAEX,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAU,CAAC;AAE5E,MAAM,YAAY,GAAG;IACnB,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;CACG,CAAC;AAEX,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB;;;;GAIG;AACH,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAE3C,gEAAgE;AAChE,SAAS,UAAU,CAAC,EAAQ;IAC1B,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CA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