@unbrained/pm-cli 2026.5.29 → 2026.5.31
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/CHANGELOG.md +54 -12
- package/dist/cli/bootstrap-args.d.ts +1 -1
- package/dist/cli/bootstrap-args.js +59 -9
- package/dist/cli/bootstrap-args.js.map +1 -1
- package/dist/cli/commands/activity.js +4 -4
- package/dist/cli/commands/activity.js.map +1 -1
- package/dist/cli/commands/calendar.js +83 -11
- package/dist/cli/commands/calendar.js.map +1 -1
- package/dist/cli/commands/close.js +4 -4
- package/dist/cli/commands/close.js.map +1 -1
- package/dist/cli/commands/completion.js +4 -4
- package/dist/cli/commands/completion.js.map +1 -1
- package/dist/cli/commands/create.js +50 -7
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/commands/deps.js +4 -4
- package/dist/cli/commands/deps.js.map +1 -1
- package/dist/cli/commands/extension/install-sources.d.ts +3 -0
- package/dist/cli/commands/extension/install-sources.js +29 -4
- package/dist/cli/commands/extension/install-sources.js.map +1 -1
- package/dist/cli/commands/extension.js +26 -5
- package/dist/cli/commands/extension.js.map +1 -1
- package/dist/cli/commands/get.js +6 -3
- package/dist/cli/commands/get.js.map +1 -1
- package/dist/cli/commands/list.js +25 -6
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/reindex.js +3 -3
- package/dist/cli/commands/reindex.js.map +1 -1
- package/dist/cli/commands/search.d.ts +17 -0
- package/dist/cli/commands/search.js +40 -10
- package/dist/cli/commands/search.js.map +1 -1
- package/dist/cli/commands/stats.js +4 -4
- package/dist/cli/commands/stats.js.map +1 -1
- package/dist/cli/commands/test-all.js +4 -4
- package/dist/cli/commands/test-all.js.map +1 -1
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +39 -11
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/register-list-query.js +10 -12
- package/dist/cli/register-list-query.js.map +1 -1
- package/dist/cli/register-mutation.js +20 -22
- package/dist/cli/register-mutation.js.map +1 -1
- package/dist/cli/register-operations.js +32 -25
- package/dist/cli/register-operations.js.map +1 -1
- package/dist/cli/register-setup.js +7 -9
- package/dist/cli/register-setup.js.map +1 -1
- package/dist/cli/registration-helpers.js +6 -3
- package/dist/cli/registration-helpers.js.map +1 -1
- package/dist/cli/search-refresh.d.ts +2 -0
- package/dist/cli/search-refresh.js +13 -0
- package/dist/cli/search-refresh.js.map +1 -0
- package/dist/cli-bundle/chunks/activity-OWYSUZOY.js +17 -0
- package/dist/cli-bundle/chunks/activity-OWYSUZOY.js.map +7 -0
- package/dist/cli-bundle/chunks/aggregate-ADUOSFRO.js +209 -0
- package/dist/cli-bundle/chunks/aggregate-ADUOSFRO.js.map +7 -0
- package/dist/cli-bundle/chunks/append-JD2DETU7.js +73 -0
- package/dist/cli-bundle/chunks/append-JD2DETU7.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-3HUE7XOF.js +27 -0
- package/dist/cli-bundle/chunks/chunk-3HUE7XOF.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-3M73P3G6.js +1636 -0
- package/dist/cli-bundle/chunks/chunk-3M73P3G6.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js +189 -0
- package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-5HSEP75M.js +330 -0
- package/dist/cli-bundle/chunks/chunk-5HSEP75M.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-6HT2F4TK.js +1770 -0
- package/dist/cli-bundle/chunks/chunk-6HT2F4TK.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-6YCV7WSL.js +552 -0
- package/dist/cli-bundle/chunks/chunk-6YCV7WSL.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-7Y53ZJIQ.js +202 -0
- package/dist/cli-bundle/chunks/chunk-7Y53ZJIQ.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-A7E7PUVX.js +157 -0
- package/dist/cli-bundle/chunks/chunk-A7E7PUVX.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-AKOOMO3T.js +90 -0
- package/dist/cli-bundle/chunks/chunk-AKOOMO3T.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-BUPWJ3IJ.js +950 -0
- package/dist/cli-bundle/chunks/chunk-BUPWJ3IJ.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-CEFIVZPG.js +79 -0
- package/dist/cli-bundle/chunks/chunk-CEFIVZPG.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-D7AOMPRH.js +349 -0
- package/dist/cli-bundle/chunks/chunk-D7AOMPRH.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-EAOG77HM.js +56 -0
- package/dist/cli-bundle/chunks/chunk-EAOG77HM.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js +47 -0
- package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-FM26RGSU.js +56 -0
- package/dist/cli-bundle/chunks/chunk-FM26RGSU.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-FQE6XZDB.js +435 -0
- package/dist/cli-bundle/chunks/chunk-FQE6XZDB.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-G57E5D7T.js +185 -0
- package/dist/cli-bundle/chunks/chunk-G57E5D7T.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-GN7IJPCD.js +3621 -0
- package/dist/cli-bundle/chunks/chunk-GN7IJPCD.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-JFWUHHS2.js +233 -0
- package/dist/cli-bundle/chunks/chunk-JFWUHHS2.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-JTWRXG4B.js +1861 -0
- package/dist/cli-bundle/chunks/chunk-JTWRXG4B.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-JULRTHJQ.js +648 -0
- package/dist/cli-bundle/chunks/chunk-JULRTHJQ.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-KBQY3YG5.js +122 -0
- package/dist/cli-bundle/chunks/chunk-KBQY3YG5.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-L2FXEKDB.js +185 -0
- package/dist/cli-bundle/chunks/chunk-L2FXEKDB.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-LRBOHPUE.js +189 -0
- package/dist/cli-bundle/chunks/chunk-LRBOHPUE.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-LSXGH6NE.js +5153 -0
- package/dist/cli-bundle/chunks/chunk-LSXGH6NE.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-MD7K4JYF.js +1345 -0
- package/dist/cli-bundle/chunks/chunk-MD7K4JYF.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-NGN7UV5K.js +341 -0
- package/dist/cli-bundle/chunks/chunk-NGN7UV5K.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-O7IWB35H.js +18 -0
- package/dist/cli-bundle/chunks/chunk-O7IWB35H.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-OGZEG5TT.js +2929 -0
- package/dist/cli-bundle/chunks/chunk-OGZEG5TT.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-P53TN6IA.js +674 -0
- package/dist/cli-bundle/chunks/chunk-P53TN6IA.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-PVNQLCIS.js +176 -0
- package/dist/cli-bundle/chunks/chunk-PVNQLCIS.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-PXUAZUUY.js +1680 -0
- package/dist/cli-bundle/chunks/chunk-PXUAZUUY.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-QAJBIGRA.js +20 -0
- package/dist/cli-bundle/chunks/chunk-QAJBIGRA.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-SEXQN4KL.js +60 -0
- package/dist/cli-bundle/chunks/chunk-SEXQN4KL.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-U7FMKRXH.js +362 -0
- package/dist/cli-bundle/chunks/chunk-U7FMKRXH.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-VGICHR7D.js +141 -0
- package/dist/cli-bundle/chunks/chunk-VGICHR7D.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-WDPXDQFG.js +632 -0
- package/dist/cli-bundle/chunks/chunk-WDPXDQFG.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-WJ2NAC37.js +252 -0
- package/dist/cli-bundle/chunks/chunk-WJ2NAC37.js.map +7 -0
- package/dist/cli-bundle/chunks/claim-EE4TKKCV.js +133 -0
- package/dist/cli-bundle/chunks/claim-EE4TKKCV.js.map +7 -0
- package/dist/cli-bundle/chunks/close-XY4CSAYF.js +14 -0
- package/dist/cli-bundle/chunks/close-XY4CSAYF.js.map +7 -0
- package/dist/cli-bundle/chunks/comments-AAKJQ6LW.js +104 -0
- package/dist/cli-bundle/chunks/comments-AAKJQ6LW.js.map +7 -0
- package/dist/cli-bundle/chunks/config-V3FZOKLI.js +1577 -0
- package/dist/cli-bundle/chunks/config-V3FZOKLI.js.map +7 -0
- package/dist/cli-bundle/chunks/context-RZ5QPNJB.js +1458 -0
- package/dist/cli-bundle/chunks/context-RZ5QPNJB.js.map +7 -0
- package/dist/cli-bundle/chunks/contracts-YLMH33VU.js +1245 -0
- package/dist/cli-bundle/chunks/contracts-YLMH33VU.js.map +7 -0
- package/dist/cli-bundle/chunks/create-PZVHRIZQ.js +28 -0
- package/dist/cli-bundle/chunks/create-PZVHRIZQ.js.map +7 -0
- package/dist/cli-bundle/chunks/delete-RHCTEORS.js +59 -0
- package/dist/cli-bundle/chunks/delete-RHCTEORS.js.map +7 -0
- package/dist/cli-bundle/chunks/deps-MZYCMLAO.js +229 -0
- package/dist/cli-bundle/chunks/deps-MZYCMLAO.js.map +7 -0
- package/dist/cli-bundle/chunks/docs-FXXUCZYU.js +35 -0
- package/dist/cli-bundle/chunks/docs-FXXUCZYU.js.map +7 -0
- package/dist/cli-bundle/chunks/extension-B4WL7BQU.js +25 -0
- package/dist/cli-bundle/chunks/extension-B4WL7BQU.js.map +7 -0
- package/dist/cli-bundle/chunks/files-WVOX67PE.js +286 -0
- package/dist/cli-bundle/chunks/files-WVOX67PE.js.map +7 -0
- package/dist/cli-bundle/chunks/gc-JWNF66EC.js +181 -0
- package/dist/cli-bundle/chunks/gc-JWNF66EC.js.map +7 -0
- package/dist/cli-bundle/chunks/get-LTK3HOCQ.js +198 -0
- package/dist/cli-bundle/chunks/get-LTK3HOCQ.js.map +7 -0
- package/dist/cli-bundle/chunks/health-TCWL55KM.js +1233 -0
- package/dist/cli-bundle/chunks/health-TCWL55KM.js.map +7 -0
- package/dist/cli-bundle/chunks/history-A2JUDXUE.js +21 -0
- package/dist/cli-bundle/chunks/history-A2JUDXUE.js.map +7 -0
- package/dist/cli-bundle/chunks/history-redact-ED6RFCPL.js +20 -0
- package/dist/cli-bundle/chunks/history-redact-ED6RFCPL.js.map +7 -0
- package/dist/cli-bundle/chunks/history-repair-ZWSTDRH2.js +198 -0
- package/dist/cli-bundle/chunks/history-repair-ZWSTDRH2.js.map +7 -0
- package/dist/cli-bundle/chunks/init-M2WUB4YH.js +16 -0
- package/dist/cli-bundle/chunks/init-M2WUB4YH.js.map +7 -0
- package/dist/cli-bundle/chunks/learnings-NXTWE3FR.js +48 -0
- package/dist/cli-bundle/chunks/learnings-NXTWE3FR.js.map +7 -0
- package/dist/cli-bundle/chunks/list-OGWQPC26.js +20 -0
- package/dist/cli-bundle/chunks/list-OGWQPC26.js.map +7 -0
- package/dist/cli-bundle/chunks/notes-DFS5ZGOO.js +48 -0
- package/dist/cli-bundle/chunks/notes-DFS5ZGOO.js.map +7 -0
- package/dist/cli-bundle/chunks/plan-67AB2PLM.js +1175 -0
- package/dist/cli-bundle/chunks/plan-67AB2PLM.js.map +7 -0
- package/dist/cli-bundle/chunks/register-list-query-UP3VRUFS.js +232 -0
- package/dist/cli-bundle/chunks/register-list-query-UP3VRUFS.js.map +7 -0
- package/dist/cli-bundle/chunks/register-mutation-YWSBF545.js +712 -0
- package/dist/cli-bundle/chunks/register-mutation-YWSBF545.js.map +7 -0
- package/dist/cli-bundle/chunks/register-operations-3BDTGSDH.js +374 -0
- package/dist/cli-bundle/chunks/register-operations-3BDTGSDH.js.map +7 -0
- package/dist/cli-bundle/chunks/register-setup-V56GDRUS.js +246 -0
- package/dist/cli-bundle/chunks/register-setup-V56GDRUS.js.map +7 -0
- package/dist/cli-bundle/chunks/restore-MB2ISME7.js +18 -0
- package/dist/cli-bundle/chunks/restore-MB2ISME7.js.map +7 -0
- package/dist/cli-bundle/chunks/schema-Q622KC46.js +119 -0
- package/dist/cli-bundle/chunks/schema-Q622KC46.js.map +7 -0
- package/dist/cli-bundle/chunks/search-HENBL456.js +1135 -0
- package/dist/cli-bundle/chunks/search-HENBL456.js.map +7 -0
- package/dist/cli-bundle/chunks/stats-N6H3YP2F.js +124 -0
- package/dist/cli-bundle/chunks/stats-N6H3YP2F.js.map +7 -0
- package/dist/cli-bundle/chunks/test-VNBDRJ4Z.js +32 -0
- package/dist/cli-bundle/chunks/test-VNBDRJ4Z.js.map +7 -0
- package/dist/cli-bundle/chunks/test-all-G2AZOHXI.js +332 -0
- package/dist/cli-bundle/chunks/test-all-G2AZOHXI.js.map +7 -0
- package/dist/cli-bundle/chunks/test-runs-GX5HTPSF.js +939 -0
- package/dist/cli-bundle/chunks/test-runs-GX5HTPSF.js.map +7 -0
- package/dist/cli-bundle/chunks/update-H6SCWNMA.js +22 -0
- package/dist/cli-bundle/chunks/update-H6SCWNMA.js.map +7 -0
- package/dist/cli-bundle/chunks/update-many-46HRSP2Q.js +676 -0
- package/dist/cli-bundle/chunks/update-many-46HRSP2Q.js.map +7 -0
- package/dist/cli-bundle/chunks/upgrade-H5HHM5UV.js +271 -0
- package/dist/cli-bundle/chunks/upgrade-H5HHM5UV.js.map +7 -0
- package/dist/cli-bundle/chunks/validate-TMCVKIGZ.js +1110 -0
- package/dist/cli-bundle/chunks/validate-TMCVKIGZ.js.map +7 -0
- package/dist/cli-bundle/main.js +6952 -0
- package/dist/cli-bundle/main.js.map +7 -0
- package/dist/cli.js +1 -1
- package/dist/core/config/nested-settings.d.ts +2 -0
- package/dist/core/config/nested-settings.js +17 -2
- package/dist/core/config/nested-settings.js.map +1 -1
- package/dist/core/item/item-type-definition.js +6 -2
- package/dist/core/item/item-type-definition.js.map +1 -1
- package/dist/core/item/type-registry.d.ts +4 -0
- package/dist/core/item/type-registry.js +10 -2
- package/dist/core/item/type-registry.js.map +1 -1
- package/dist/core/item/type-synonyms.d.ts +20 -0
- package/dist/core/item/type-synonyms.js +42 -0
- package/dist/core/item/type-synonyms.js.map +1 -0
- package/dist/core/search/background-refresh.d.ts +53 -0
- package/dist/core/search/background-refresh.js +286 -0
- package/dist/core/search/background-refresh.js.map +1 -0
- package/dist/core/search/cache.d.ts +20 -1
- package/dist/core/search/cache.js +76 -5
- package/dist/core/search/cache.js.map +1 -1
- package/dist/core/search/semantic-defaults.js +73 -32
- package/dist/core/search/semantic-defaults.js.map +1 -1
- package/dist/core/search/vector-stores.js +7 -3
- package/dist/core/search/vector-stores.js.map +1 -1
- package/dist/core/sentry/helpers.d.ts +1 -1
- package/dist/core/sentry/helpers.js +4 -4
- package/dist/core/sentry/helpers.js.map +1 -1
- package/dist/core/shared/constants.d.ts +2 -2
- package/dist/core/shared/constants.js +3 -3
- package/dist/core/shared/constants.js.map +1 -1
- package/dist/core/shared/html-entity-decode.d.ts +2 -1
- package/dist/core/shared/html-entity-decode.js +14 -9
- package/dist/core/shared/html-entity-decode.js.map +1 -1
- package/dist/core/shared/time.js +52 -2
- package/dist/core/shared/time.js.map +1 -1
- package/dist/core/store/front-matter-cache.d.ts +24 -0
- package/dist/core/store/front-matter-cache.js +119 -8
- package/dist/core/store/front-matter-cache.js.map +1 -1
- package/dist/core/store/item-format-migration.js +25 -15
- package/dist/core/store/item-format-migration.js.map +1 -1
- package/dist/core/store/item-store.d.ts +7 -0
- package/dist/core/store/item-store.js +13 -3
- package/dist/core/store/item-store.js.map +1 -1
- package/dist/core/store/settings-validator.d.ts +1 -0
- package/dist/core/store/settings-validator.js +7 -2
- package/dist/core/store/settings-validator.js.map +1 -1
- package/dist/core/store/settings.js +19 -3
- package/dist/core/store/settings.js.map +1 -1
- package/dist/core/telemetry/runtime.d.ts +10 -0
- package/dist/core/telemetry/runtime.js +86 -2
- package/dist/core/telemetry/runtime.js.map +1 -1
- package/dist/mcp/server.js +3 -3
- package/dist/mcp/server.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +4 -4
- package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
- package/dist/sdk/cli-contracts.js +29 -8
- package/dist/sdk/cli-contracts.js.map +1 -1
- package/dist/types.d.ts +9 -1
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/docs/CONFIGURATION.md +11 -0
- package/docs/RELEASING.md +1 -1
- package/package.json +7 -5
- package/packages/pm-calendar/extensions/calendar/index.js +27 -2
- package/packages/pm-calendar/extensions/calendar/index.ts +28 -2
- package/scripts/bundle-cli.mjs +39 -0
|
@@ -0,0 +1,1458 @@
|
|
|
1
|
+
import {
|
|
2
|
+
runActivity
|
|
3
|
+
} from "./chunk-L2FXEKDB.js";
|
|
4
|
+
import "./chunk-LRBOHPUE.js";
|
|
5
|
+
import "./chunk-JFWUHHS2.js";
|
|
6
|
+
import {
|
|
7
|
+
levenshteinDistanceWithinLimit
|
|
8
|
+
} from "./chunk-EAOG77HM.js";
|
|
9
|
+
import {
|
|
10
|
+
runList
|
|
11
|
+
} from "./chunk-FQE6XZDB.js";
|
|
12
|
+
import {
|
|
13
|
+
collectRuntimeFilterValues,
|
|
14
|
+
matchesRuntimeFilters
|
|
15
|
+
} from "./chunk-FM26RGSU.js";
|
|
16
|
+
import {
|
|
17
|
+
parseIntegerLimit,
|
|
18
|
+
parsePriority,
|
|
19
|
+
parseType
|
|
20
|
+
} from "./chunk-SEXQN4KL.js";
|
|
21
|
+
import {
|
|
22
|
+
listAllFrontMatterLight
|
|
23
|
+
} from "./chunk-BUPWJ3IJ.js";
|
|
24
|
+
import "./chunk-4AEZR5EJ.js";
|
|
25
|
+
import "./chunk-CEFIVZPG.js";
|
|
26
|
+
import {
|
|
27
|
+
isTerminalStatus,
|
|
28
|
+
normalizeStatusForRegistry,
|
|
29
|
+
normalizeStatusInput
|
|
30
|
+
} from "./chunk-MD7K4JYF.js";
|
|
31
|
+
import {
|
|
32
|
+
resolveItemTypeRegistry
|
|
33
|
+
} from "./chunk-WDPXDQFG.js";
|
|
34
|
+
import {
|
|
35
|
+
compareTimestampStrings,
|
|
36
|
+
nowIso,
|
|
37
|
+
resolveIsoOrRelative
|
|
38
|
+
} from "./chunk-PVNQLCIS.js";
|
|
39
|
+
import {
|
|
40
|
+
CONTEXT_DEPTH_VALUES,
|
|
41
|
+
CONTEXT_SECTION_VALUES,
|
|
42
|
+
EXIT_CODE,
|
|
43
|
+
PmCliError,
|
|
44
|
+
SETTINGS_DEFAULTS,
|
|
45
|
+
getActiveExtensionRegistrations,
|
|
46
|
+
getSettingsPath,
|
|
47
|
+
pathExists,
|
|
48
|
+
readSettings,
|
|
49
|
+
resolvePmRoot,
|
|
50
|
+
resolveRuntimeFieldRegistry,
|
|
51
|
+
resolveRuntimeStatusRegistry,
|
|
52
|
+
weekdayOrderIndex
|
|
53
|
+
} from "./chunk-LSXGH6NE.js";
|
|
54
|
+
|
|
55
|
+
// dist/cli/commands/calendar.js
|
|
56
|
+
import { encode as encodeToon } from "@toon-format/toon";
|
|
57
|
+
!(function() {
|
|
58
|
+
try {
|
|
59
|
+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
60
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "da600821-1762-55a5-9cf5-0ea9f8ac1781");
|
|
61
|
+
} catch (e2) {
|
|
62
|
+
}
|
|
63
|
+
})();
|
|
64
|
+
var CALENDAR_VIEW_VALUES = ["agenda", "day", "week", "month"];
|
|
65
|
+
var UTC_DAY_TO_WEEKDAY = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
|
66
|
+
var DEFAULT_RECURRENCE_LOOKAHEAD_DAYS = 365;
|
|
67
|
+
var DEFAULT_RECURRENCE_LOOKBACK_DAYS = 365;
|
|
68
|
+
var DEFAULT_EVENTS_ONLY_LOOKAHEAD_DAYS = 28;
|
|
69
|
+
var MAX_RECURRENCE_OCCURRENCES = 1e3;
|
|
70
|
+
function parseNonNegativeInteger(raw, label) {
|
|
71
|
+
if (raw === void 0)
|
|
72
|
+
return void 0;
|
|
73
|
+
const parsed = Number(raw);
|
|
74
|
+
if (!Number.isInteger(parsed) || parsed < 0) {
|
|
75
|
+
throw new PmCliError(`${label} must be a non-negative integer`, EXIT_CODE.USAGE);
|
|
76
|
+
}
|
|
77
|
+
return parsed;
|
|
78
|
+
}
|
|
79
|
+
function parseIncludeSources(raw) {
|
|
80
|
+
if (!raw) {
|
|
81
|
+
return /* @__PURE__ */ new Set(["deadlines", "reminders", "events"]);
|
|
82
|
+
}
|
|
83
|
+
const normalized = raw.trim().toLowerCase();
|
|
84
|
+
if (normalized === "all") {
|
|
85
|
+
return /* @__PURE__ */ new Set(["deadlines", "reminders", "events"]);
|
|
86
|
+
}
|
|
87
|
+
const values = normalized.split(/[\|,]/).map((value) => value.trim()).filter((value) => value.length > 0);
|
|
88
|
+
if (values.length === 0) {
|
|
89
|
+
throw new PmCliError("Calendar include filter must not be empty", EXIT_CODE.USAGE);
|
|
90
|
+
}
|
|
91
|
+
const include = /* @__PURE__ */ new Set();
|
|
92
|
+
for (const value of values) {
|
|
93
|
+
if (value === "deadlines" || value === "deadline") {
|
|
94
|
+
include.add("deadlines");
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (value === "reminders" || value === "reminder") {
|
|
98
|
+
include.add("reminders");
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (value === "events" || value === "event" || value === "scheduled") {
|
|
102
|
+
include.add("events");
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
throw new PmCliError("Calendar include filter must be deadlines|reminders|events|scheduled|all", EXIT_CODE.USAGE);
|
|
106
|
+
}
|
|
107
|
+
return include;
|
|
108
|
+
}
|
|
109
|
+
function suggestClosestChoice(value, choices) {
|
|
110
|
+
let best;
|
|
111
|
+
for (const choice of choices) {
|
|
112
|
+
const distance = levenshteinDistanceWithinLimit(value, choice, 2);
|
|
113
|
+
if (distance !== null && (best === void 0 || distance < best.distance)) {
|
|
114
|
+
best = { choice, distance };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return best?.choice;
|
|
118
|
+
}
|
|
119
|
+
function parseView(raw) {
|
|
120
|
+
if (!raw)
|
|
121
|
+
return "agenda";
|
|
122
|
+
const normalized = raw.trim().toLowerCase();
|
|
123
|
+
if (!CALENDAR_VIEW_VALUES.includes(normalized)) {
|
|
124
|
+
const suggestion = suggestClosestChoice(normalized, CALENDAR_VIEW_VALUES);
|
|
125
|
+
throw new PmCliError(`Calendar view must be one of ${CALENDAR_VIEW_VALUES.join("|")}${suggestion ? `. Did you mean "${suggestion}"?` : "."}`, EXIT_CODE.USAGE);
|
|
126
|
+
}
|
|
127
|
+
return normalized;
|
|
128
|
+
}
|
|
129
|
+
function parseStatus(raw, statusRegistry) {
|
|
130
|
+
if (raw === void 0)
|
|
131
|
+
return void 0;
|
|
132
|
+
const normalized = normalizeStatusInput(raw, statusRegistry);
|
|
133
|
+
if (!normalized) {
|
|
134
|
+
const allowedStatuses = statusRegistry.definitions.map((definition) => definition.id);
|
|
135
|
+
throw new PmCliError(`Calendar status filter must be one of ${allowedStatuses.join("|")}`, EXIT_CODE.USAGE);
|
|
136
|
+
}
|
|
137
|
+
return normalized;
|
|
138
|
+
}
|
|
139
|
+
function parseAssigneeFilter(raw) {
|
|
140
|
+
if (raw === void 0) {
|
|
141
|
+
return void 0;
|
|
142
|
+
}
|
|
143
|
+
const normalized = raw.trim().toLowerCase();
|
|
144
|
+
if (!normalized) {
|
|
145
|
+
throw new PmCliError("Calendar assignee filter must be one of assigned|unassigned", EXIT_CODE.USAGE);
|
|
146
|
+
}
|
|
147
|
+
if (normalized !== "assigned" && normalized !== "unassigned") {
|
|
148
|
+
throw new PmCliError(`Invalid calendar assignee filter "${raw}". Allowed: assigned|unassigned`, EXIT_CODE.USAGE);
|
|
149
|
+
}
|
|
150
|
+
return normalized;
|
|
151
|
+
}
|
|
152
|
+
function toUtcDayKey(timestamp) {
|
|
153
|
+
return new Date(timestamp).toISOString().slice(0, 10);
|
|
154
|
+
}
|
|
155
|
+
function toLocalDayKey(timestamp, timezone) {
|
|
156
|
+
if (!timezone || timezone === "UTC") {
|
|
157
|
+
return toUtcDayKey(timestamp);
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
const parts = new Intl.DateTimeFormat("en-CA", {
|
|
161
|
+
timeZone: timezone,
|
|
162
|
+
year: "numeric",
|
|
163
|
+
month: "2-digit",
|
|
164
|
+
day: "2-digit"
|
|
165
|
+
}).formatToParts(new Date(timestamp));
|
|
166
|
+
const year = parts.find((part) => part.type === "year")?.value;
|
|
167
|
+
const month = parts.find((part) => part.type === "month")?.value;
|
|
168
|
+
const day = parts.find((part) => part.type === "day")?.value;
|
|
169
|
+
if (year && month && day) {
|
|
170
|
+
return `${year}-${month}-${day}`;
|
|
171
|
+
}
|
|
172
|
+
} catch {
|
|
173
|
+
}
|
|
174
|
+
return toUtcDayKey(timestamp);
|
|
175
|
+
}
|
|
176
|
+
function startOfUtcDay(timestamp) {
|
|
177
|
+
const date = new Date(timestamp);
|
|
178
|
+
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0, 0)).toISOString();
|
|
179
|
+
}
|
|
180
|
+
function addUtcDays(timestamp, days) {
|
|
181
|
+
const date = new Date(timestamp);
|
|
182
|
+
return new Date(date.getTime() + days * 24 * 60 * 60 * 1e3).toISOString();
|
|
183
|
+
}
|
|
184
|
+
function startOfUtcWeekMonday(timestamp) {
|
|
185
|
+
const base = new Date(startOfUtcDay(timestamp));
|
|
186
|
+
const day = base.getUTCDay();
|
|
187
|
+
const delta = day === 0 ? -6 : 1 - day;
|
|
188
|
+
return addUtcDays(base.toISOString(), delta);
|
|
189
|
+
}
|
|
190
|
+
function startOfUtcMonth(timestamp) {
|
|
191
|
+
const date = new Date(timestamp);
|
|
192
|
+
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), 1, 0, 0, 0, 0)).toISOString();
|
|
193
|
+
}
|
|
194
|
+
function startOfNextUtcMonth(timestamp) {
|
|
195
|
+
const date = new Date(timestamp);
|
|
196
|
+
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + 1, 1, 0, 0, 0, 0)).toISOString();
|
|
197
|
+
}
|
|
198
|
+
function maxTimestamp(left, right) {
|
|
199
|
+
return compareTimestampStrings(left, right) >= 0 ? left : right;
|
|
200
|
+
}
|
|
201
|
+
function toSortedCountRecord(values) {
|
|
202
|
+
return Object.fromEntries([...values.entries()].sort(([left], [right]) => left.localeCompare(right)));
|
|
203
|
+
}
|
|
204
|
+
function incrementCount(values, key) {
|
|
205
|
+
values.set(key, (values.get(key) ?? 0) + 1);
|
|
206
|
+
}
|
|
207
|
+
function formatRecurrenceRuleForSummary(rule) {
|
|
208
|
+
if (!rule) {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
const parts = [`freq=${rule.freq}`];
|
|
212
|
+
if (rule.interval !== void 0) {
|
|
213
|
+
parts.push(`interval=${rule.interval}`);
|
|
214
|
+
}
|
|
215
|
+
if (rule.count !== void 0) {
|
|
216
|
+
parts.push(`count=${rule.count}`);
|
|
217
|
+
}
|
|
218
|
+
if (rule.until) {
|
|
219
|
+
parts.push(`until=${rule.until}`);
|
|
220
|
+
}
|
|
221
|
+
if (rule.by_weekday && rule.by_weekday.length > 0) {
|
|
222
|
+
const weekdays = [...rule.by_weekday].sort((left, right) => weekdayOrderIndex(left) - weekdayOrderIndex(right));
|
|
223
|
+
parts.push(`by_weekday=${weekdays.join("|")}`);
|
|
224
|
+
}
|
|
225
|
+
if (rule.by_month_day && rule.by_month_day.length > 0) {
|
|
226
|
+
const monthDays = [...rule.by_month_day].sort((left, right) => left - right);
|
|
227
|
+
parts.push(`by_month_day=${monthDays.join("|")}`);
|
|
228
|
+
}
|
|
229
|
+
if (rule.exdates && rule.exdates.length > 0) {
|
|
230
|
+
const exdates = [...rule.exdates].sort((left, right) => left.localeCompare(right));
|
|
231
|
+
parts.push(`exdates=${exdates.join("|")}`);
|
|
232
|
+
}
|
|
233
|
+
return parts.join(",");
|
|
234
|
+
}
|
|
235
|
+
function buildUtcTimestamp(year, month, day, timeSource) {
|
|
236
|
+
const candidate = new Date(Date.UTC(year, month, day, timeSource.getUTCHours(), timeSource.getUTCMinutes(), timeSource.getUTCSeconds(), timeSource.getUTCMilliseconds()));
|
|
237
|
+
if (candidate.getUTCFullYear() !== year || candidate.getUTCMonth() !== month || candidate.getUTCDate() !== day) {
|
|
238
|
+
return void 0;
|
|
239
|
+
}
|
|
240
|
+
return candidate.toISOString();
|
|
241
|
+
}
|
|
242
|
+
function weekdayToken(timestamp) {
|
|
243
|
+
return UTC_DAY_TO_WEEKDAY[new Date(timestamp).getUTCDay()];
|
|
244
|
+
}
|
|
245
|
+
function buildRecurringEventWindow(start, end, nowValue, lookbackDays, lookaheadDays) {
|
|
246
|
+
const windowStart = start ?? addUtcDays(nowValue, -(lookbackDays ?? DEFAULT_RECURRENCE_LOOKBACK_DAYS));
|
|
247
|
+
const windowEnd = end ?? addUtcDays(start ?? nowValue, lookaheadDays ?? DEFAULT_RECURRENCE_LOOKAHEAD_DAYS);
|
|
248
|
+
return {
|
|
249
|
+
start: windowStart,
|
|
250
|
+
end: compareTimestampStrings(windowEnd, windowStart) > 0 ? windowEnd : addUtcDays(windowStart, 1)
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function expandRecurringOccurrences(startAt, recurrence, window2, occurrenceLimit) {
|
|
254
|
+
const maxOccurrences = occurrenceLimit ?? MAX_RECURRENCE_OCCURRENCES;
|
|
255
|
+
const interval = recurrence.interval ?? 1;
|
|
256
|
+
const countLimit = recurrence.count ?? Number.POSITIVE_INFINITY;
|
|
257
|
+
const until = recurrence.until;
|
|
258
|
+
const excluded = new Set(recurrence.exdates ?? []);
|
|
259
|
+
const recurrenceWeekdays = recurrence.by_weekday && recurrence.by_weekday.length > 0 ? [...recurrence.by_weekday] : [weekdayToken(startAt)];
|
|
260
|
+
const recurrenceMonthDays = recurrence.by_month_day && recurrence.by_month_day.length > 0 ? [...recurrence.by_month_day] : [new Date(startAt).getUTCDate()];
|
|
261
|
+
const weekdayFilter = recurrence.by_weekday ? new Set(recurrence.by_weekday) : void 0;
|
|
262
|
+
const monthDayFilter = recurrence.by_month_day ? new Set(recurrence.by_month_day) : void 0;
|
|
263
|
+
const sortedWeekdays = [...new Set(recurrenceWeekdays)].sort((left, right) => weekdayOrderIndex(left) - weekdayOrderIndex(right));
|
|
264
|
+
const sortedMonthDays = [...new Set(recurrenceMonthDays)].sort((left, right) => left - right);
|
|
265
|
+
const occurrences = [];
|
|
266
|
+
let produced = 0;
|
|
267
|
+
const consumeCandidate = (candidateAt) => {
|
|
268
|
+
if (compareTimestampStrings(candidateAt, startAt) < 0) {
|
|
269
|
+
return "continue";
|
|
270
|
+
}
|
|
271
|
+
if (until && compareTimestampStrings(candidateAt, until) > 0) {
|
|
272
|
+
return "stop";
|
|
273
|
+
}
|
|
274
|
+
if (compareTimestampStrings(candidateAt, window2.end) >= 0) {
|
|
275
|
+
return "stop";
|
|
276
|
+
}
|
|
277
|
+
if (excluded.has(candidateAt)) {
|
|
278
|
+
return "continue";
|
|
279
|
+
}
|
|
280
|
+
produced += 1;
|
|
281
|
+
if (compareTimestampStrings(candidateAt, window2.start) >= 0) {
|
|
282
|
+
occurrences.push(candidateAt);
|
|
283
|
+
}
|
|
284
|
+
if (produced >= countLimit) {
|
|
285
|
+
return "stop";
|
|
286
|
+
}
|
|
287
|
+
return "continue";
|
|
288
|
+
};
|
|
289
|
+
const startDate = new Date(startAt);
|
|
290
|
+
if (recurrence.freq === "daily") {
|
|
291
|
+
let candidateAt = startAt;
|
|
292
|
+
for (let iteration = 0; iteration < maxOccurrences; iteration += 1) {
|
|
293
|
+
const candidateWeekday = weekdayToken(candidateAt);
|
|
294
|
+
const candidateMonthDay = new Date(candidateAt).getUTCDate();
|
|
295
|
+
const weekdayMatches = !weekdayFilter || weekdayFilter.has(candidateWeekday);
|
|
296
|
+
const monthDayMatches = !monthDayFilter || monthDayFilter.has(candidateMonthDay);
|
|
297
|
+
if (weekdayMatches && monthDayMatches && consumeCandidate(candidateAt) === "stop") {
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
candidateAt = addUtcDays(candidateAt, interval);
|
|
301
|
+
}
|
|
302
|
+
return occurrences;
|
|
303
|
+
}
|
|
304
|
+
if (recurrence.freq === "weekly") {
|
|
305
|
+
const weekStart = startOfUtcWeekMonday(startAt);
|
|
306
|
+
for (let step = 0; step < maxOccurrences; step += 1) {
|
|
307
|
+
const candidateWeekStart = addUtcDays(weekStart, step * interval * 7);
|
|
308
|
+
for (const weekday of sortedWeekdays) {
|
|
309
|
+
const dayOffset = weekdayOrderIndex(weekday);
|
|
310
|
+
const candidateDay = addUtcDays(candidateWeekStart, dayOffset);
|
|
311
|
+
const dayDate = new Date(candidateDay);
|
|
312
|
+
const candidateAt = new Date(Date.UTC(dayDate.getUTCFullYear(), dayDate.getUTCMonth(), dayDate.getUTCDate(), startDate.getUTCHours(), startDate.getUTCMinutes(), startDate.getUTCSeconds(), startDate.getUTCMilliseconds())).toISOString();
|
|
313
|
+
const candidateMonthDay = dayDate.getUTCDate();
|
|
314
|
+
if (monthDayFilter && !monthDayFilter.has(candidateMonthDay)) {
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
const consumed = consumeCandidate(candidateAt);
|
|
318
|
+
if (consumed === "stop") {
|
|
319
|
+
return occurrences;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return occurrences;
|
|
324
|
+
}
|
|
325
|
+
if (recurrence.freq === "monthly") {
|
|
326
|
+
const startYear = startDate.getUTCFullYear();
|
|
327
|
+
const startMonth = startDate.getUTCMonth();
|
|
328
|
+
for (let step = 0; step < maxOccurrences; step += 1) {
|
|
329
|
+
const monthAnchor = new Date(Date.UTC(startYear, startMonth + step * interval, 1, 0, 0, 0, 0));
|
|
330
|
+
const year2 = monthAnchor.getUTCFullYear();
|
|
331
|
+
const month2 = monthAnchor.getUTCMonth();
|
|
332
|
+
for (const monthDay of sortedMonthDays) {
|
|
333
|
+
const candidateAt = buildUtcTimestamp(year2, month2, monthDay, startDate);
|
|
334
|
+
if (!candidateAt) {
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
const candidateWeekday = weekdayToken(candidateAt);
|
|
338
|
+
if (weekdayFilter && !weekdayFilter.has(candidateWeekday)) {
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
const consumed = consumeCandidate(candidateAt);
|
|
342
|
+
if (consumed === "stop") {
|
|
343
|
+
return occurrences;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return occurrences;
|
|
348
|
+
}
|
|
349
|
+
const year = startDate.getUTCFullYear();
|
|
350
|
+
const month = startDate.getUTCMonth();
|
|
351
|
+
for (let step = 0; step < maxOccurrences; step += 1) {
|
|
352
|
+
const candidateYear = year + step * interval;
|
|
353
|
+
for (const monthDay of sortedMonthDays) {
|
|
354
|
+
const candidateAt = buildUtcTimestamp(candidateYear, month, monthDay, startDate);
|
|
355
|
+
if (!candidateAt) {
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
const candidateWeekday = weekdayToken(candidateAt);
|
|
359
|
+
if (weekdayFilter && !weekdayFilter.has(candidateWeekday)) {
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
const consumed = consumeCandidate(candidateAt);
|
|
363
|
+
if (consumed === "stop") {
|
|
364
|
+
return occurrences;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return occurrences;
|
|
369
|
+
}
|
|
370
|
+
function sortEvents(values) {
|
|
371
|
+
return [...values].sort((a, b) => {
|
|
372
|
+
const byAt = compareTimestampStrings(a.at, b.at);
|
|
373
|
+
if (byAt !== 0)
|
|
374
|
+
return byAt;
|
|
375
|
+
const byPriority = a.item_priority - b.item_priority;
|
|
376
|
+
if (byPriority !== 0)
|
|
377
|
+
return byPriority;
|
|
378
|
+
const byId = a.item_id.localeCompare(b.item_id);
|
|
379
|
+
if (byId !== 0)
|
|
380
|
+
return byId;
|
|
381
|
+
const byKind = a.kind.localeCompare(b.kind);
|
|
382
|
+
if (byKind !== 0)
|
|
383
|
+
return byKind;
|
|
384
|
+
const byEventTitle = String(a.event_title).localeCompare(String(b.event_title));
|
|
385
|
+
if (byEventTitle !== 0)
|
|
386
|
+
return byEventTitle;
|
|
387
|
+
return String(a.reminder_text).localeCompare(String(b.reminder_text));
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
function buildEventSeed(items, recurringWindow, includeSources, occurrenceLimit) {
|
|
391
|
+
const events = [];
|
|
392
|
+
for (const item of items) {
|
|
393
|
+
if (includeSources.has("deadlines") && item.deadline) {
|
|
394
|
+
events.push({
|
|
395
|
+
at: item.deadline,
|
|
396
|
+
date: toUtcDayKey(item.deadline),
|
|
397
|
+
kind: "deadline",
|
|
398
|
+
reminder_text: null,
|
|
399
|
+
event_title: null,
|
|
400
|
+
event_end: null,
|
|
401
|
+
event_location: null,
|
|
402
|
+
event_all_day: null,
|
|
403
|
+
event_timezone: null,
|
|
404
|
+
event_recurring: null,
|
|
405
|
+
event_recurrence_rule: null,
|
|
406
|
+
item_id: item.id,
|
|
407
|
+
item_title: item.title,
|
|
408
|
+
item_type: item.type,
|
|
409
|
+
item_status: item.status,
|
|
410
|
+
item_priority: item.priority,
|
|
411
|
+
item_assignee: item.assignee ?? null,
|
|
412
|
+
item_deadline: item.deadline,
|
|
413
|
+
item_tags: item.tags
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
for (const reminder of includeSources.has("reminders") ? item.reminders ?? [] : []) {
|
|
417
|
+
events.push({
|
|
418
|
+
at: reminder.at,
|
|
419
|
+
date: toUtcDayKey(reminder.at),
|
|
420
|
+
kind: "reminder",
|
|
421
|
+
reminder_text: reminder.text,
|
|
422
|
+
event_title: null,
|
|
423
|
+
event_end: null,
|
|
424
|
+
event_location: null,
|
|
425
|
+
event_all_day: null,
|
|
426
|
+
event_timezone: null,
|
|
427
|
+
event_recurring: null,
|
|
428
|
+
event_recurrence_rule: null,
|
|
429
|
+
item_id: item.id,
|
|
430
|
+
item_title: item.title,
|
|
431
|
+
item_type: item.type,
|
|
432
|
+
item_status: item.status,
|
|
433
|
+
item_priority: item.priority,
|
|
434
|
+
item_assignee: item.assignee ?? null,
|
|
435
|
+
item_deadline: item.deadline ?? null,
|
|
436
|
+
item_tags: item.tags
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
for (const event of includeSources.has("events") ? item.events ?? [] : []) {
|
|
440
|
+
const recurrenceRuleSummary = formatRecurrenceRuleForSummary(event.recurrence);
|
|
441
|
+
const recurringDurationMs = (() => {
|
|
442
|
+
if (!event.end_at) {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
const duration = Date.parse(event.end_at) - Date.parse(event.start_at);
|
|
446
|
+
return Number.isFinite(duration) && duration > 0 ? duration : null;
|
|
447
|
+
})();
|
|
448
|
+
const occurrences = event.recurrence ? expandRecurringOccurrences(event.start_at, event.recurrence, recurringWindow, occurrenceLimit) : [event.start_at];
|
|
449
|
+
for (const occurrenceAt of occurrences) {
|
|
450
|
+
const occurrenceEnd = event.recurrence && recurringDurationMs !== null ? new Date(new Date(occurrenceAt).getTime() + recurringDurationMs).toISOString() : event.end_at ?? null;
|
|
451
|
+
events.push({
|
|
452
|
+
at: occurrenceAt,
|
|
453
|
+
// All-day events are timezone-agnostic calendar dates: bucket by the
|
|
454
|
+
// literal start date. Timed events bucket by their local day in the
|
|
455
|
+
// event's timezone (defaults to UTC when unset).
|
|
456
|
+
date: event.all_day === true ? occurrenceAt.slice(0, 10) : toLocalDayKey(occurrenceAt, event.timezone),
|
|
457
|
+
kind: "event",
|
|
458
|
+
reminder_text: event.description ?? null,
|
|
459
|
+
event_title: event.title ?? item.title,
|
|
460
|
+
event_end: occurrenceEnd,
|
|
461
|
+
event_location: event.location ?? null,
|
|
462
|
+
event_all_day: event.all_day ?? null,
|
|
463
|
+
event_timezone: event.timezone ?? null,
|
|
464
|
+
event_recurring: event.recurrence ? true : false,
|
|
465
|
+
event_recurrence_rule: recurrenceRuleSummary,
|
|
466
|
+
item_id: item.id,
|
|
467
|
+
item_title: item.title,
|
|
468
|
+
item_type: item.type,
|
|
469
|
+
item_status: item.status,
|
|
470
|
+
item_priority: item.priority,
|
|
471
|
+
item_assignee: item.assignee ?? null,
|
|
472
|
+
item_deadline: item.deadline ?? null,
|
|
473
|
+
item_tags: item.tags
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return sortEvents(events);
|
|
479
|
+
}
|
|
480
|
+
function filterItems(items, options, typeRegistry, statusRegistry, runtimeFieldFilters) {
|
|
481
|
+
const typeFilter = parseType(options.type, typeRegistry);
|
|
482
|
+
const tagFilter = options.tag?.trim().toLowerCase();
|
|
483
|
+
const priorityFilter = parsePriority(options.priority);
|
|
484
|
+
const statusFilter = parseStatus(options.status, statusRegistry);
|
|
485
|
+
const assigneeFilter = options.assignee?.trim();
|
|
486
|
+
const assigneeModeFilter = parseAssigneeFilter(options.assigneeFilter);
|
|
487
|
+
const sprintFilter = options.sprint?.trim();
|
|
488
|
+
const releaseFilter = options.release?.trim();
|
|
489
|
+
if (assigneeFilter && (assigneeFilter.toLowerCase() === "none" || assigneeFilter.toLowerCase() === "null")) {
|
|
490
|
+
throw new PmCliError('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.', EXIT_CODE.USAGE);
|
|
491
|
+
}
|
|
492
|
+
if (assigneeFilter !== void 0 && assigneeModeFilter === "unassigned") {
|
|
493
|
+
throw new PmCliError("Cannot combine --assignee with --assignee-filter unassigned", EXIT_CODE.USAGE);
|
|
494
|
+
}
|
|
495
|
+
return items.filter((item) => {
|
|
496
|
+
if (typeFilter && item.type !== typeFilter)
|
|
497
|
+
return false;
|
|
498
|
+
if (tagFilter && !item.tags.some((tag) => tag.trim().toLowerCase() === tagFilter))
|
|
499
|
+
return false;
|
|
500
|
+
if (priorityFilter !== void 0 && item.priority !== priorityFilter)
|
|
501
|
+
return false;
|
|
502
|
+
if (statusFilter && item.status !== statusFilter)
|
|
503
|
+
return false;
|
|
504
|
+
if (assigneeModeFilter === "assigned" && !item.assignee)
|
|
505
|
+
return false;
|
|
506
|
+
if (assigneeModeFilter === "unassigned" && item.assignee)
|
|
507
|
+
return false;
|
|
508
|
+
if (assigneeFilter !== void 0 && item.assignee !== assigneeFilter) {
|
|
509
|
+
return false;
|
|
510
|
+
}
|
|
511
|
+
if (sprintFilter !== void 0 && item.sprint !== sprintFilter)
|
|
512
|
+
return false;
|
|
513
|
+
if (releaseFilter !== void 0 && item.release !== releaseFilter)
|
|
514
|
+
return false;
|
|
515
|
+
if (!matchesRuntimeFilters(item, runtimeFieldFilters))
|
|
516
|
+
return false;
|
|
517
|
+
return true;
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
function includeEventInWindow(event, start, end) {
|
|
521
|
+
if (start && compareTimestampStrings(event.at, start) < 0) {
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
if (end && compareTimestampStrings(event.at, end) >= 0) {
|
|
525
|
+
return false;
|
|
526
|
+
}
|
|
527
|
+
return true;
|
|
528
|
+
}
|
|
529
|
+
function resolveCalendarBoundaryInput(raw, nowValue, fieldLabel) {
|
|
530
|
+
if (raw.trim().toLowerCase() === "today") {
|
|
531
|
+
return startOfUtcDay(nowValue);
|
|
532
|
+
}
|
|
533
|
+
return resolveIsoOrRelative(raw, new Date(nowValue), fieldLabel);
|
|
534
|
+
}
|
|
535
|
+
function buildRange(view, options, nowValue) {
|
|
536
|
+
const anchor = options.date ? resolveCalendarBoundaryInput(options.date, nowValue, "--date") : nowValue;
|
|
537
|
+
const includePast = options.past === true;
|
|
538
|
+
const fullPeriodRequested = options.fullPeriod === true;
|
|
539
|
+
const from = options.from ? resolveCalendarBoundaryInput(options.from, nowValue, "--from") : void 0;
|
|
540
|
+
const to = options.to ? resolveCalendarBoundaryInput(options.to, nowValue, "--to") : void 0;
|
|
541
|
+
if (from && to && compareTimestampStrings(from, to) >= 0) {
|
|
542
|
+
throw new PmCliError("Calendar --from must be before --to", EXIT_CODE.USAGE);
|
|
543
|
+
}
|
|
544
|
+
if (view !== "agenda" && (options.from !== void 0 || options.to !== void 0)) {
|
|
545
|
+
throw new PmCliError("--from and --to are only supported for --view agenda", EXIT_CODE.USAGE);
|
|
546
|
+
}
|
|
547
|
+
if (view === "agenda") {
|
|
548
|
+
if (fullPeriodRequested) {
|
|
549
|
+
throw new PmCliError("--full-period is only supported for --view day|week|month. For agenda windows, use --from and --to.", EXIT_CODE.USAGE);
|
|
550
|
+
}
|
|
551
|
+
const start2 = from ?? (options.date ? anchor : includePast ? void 0 : nowValue);
|
|
552
|
+
return {
|
|
553
|
+
anchor,
|
|
554
|
+
start: start2,
|
|
555
|
+
end: to,
|
|
556
|
+
fullPeriod: false
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
if (view === "day") {
|
|
560
|
+
const dayStart = startOfUtcDay(anchor);
|
|
561
|
+
const fullPeriod2 = includePast || fullPeriodRequested;
|
|
562
|
+
const start2 = fullPeriod2 ? dayStart : maxTimestamp(dayStart, nowValue);
|
|
563
|
+
return {
|
|
564
|
+
anchor,
|
|
565
|
+
start: start2,
|
|
566
|
+
end: addUtcDays(dayStart, 1),
|
|
567
|
+
periodStart: dayStart,
|
|
568
|
+
periodEnd: addUtcDays(dayStart, 1),
|
|
569
|
+
fullPeriod: fullPeriod2
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
if (view === "week") {
|
|
573
|
+
const weekStart = startOfUtcWeekMonday(anchor);
|
|
574
|
+
const fullPeriod2 = includePast || fullPeriodRequested;
|
|
575
|
+
const start2 = fullPeriod2 ? weekStart : maxTimestamp(weekStart, nowValue);
|
|
576
|
+
return {
|
|
577
|
+
anchor,
|
|
578
|
+
start: start2,
|
|
579
|
+
end: addUtcDays(weekStart, 7),
|
|
580
|
+
periodStart: weekStart,
|
|
581
|
+
periodEnd: addUtcDays(weekStart, 7),
|
|
582
|
+
fullPeriod: fullPeriod2
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
const monthStart = startOfUtcMonth(anchor);
|
|
586
|
+
const monthEnd = startOfNextUtcMonth(anchor);
|
|
587
|
+
const fullPeriod = includePast || fullPeriodRequested;
|
|
588
|
+
const start = fullPeriod ? monthStart : maxTimestamp(monthStart, nowValue);
|
|
589
|
+
return {
|
|
590
|
+
anchor,
|
|
591
|
+
start,
|
|
592
|
+
end: monthEnd,
|
|
593
|
+
periodStart: monthStart,
|
|
594
|
+
periodEnd: monthEnd,
|
|
595
|
+
fullPeriod
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
function bucketEventsByDay(events) {
|
|
599
|
+
const dayMap = /* @__PURE__ */ new Map();
|
|
600
|
+
for (const event of events) {
|
|
601
|
+
const list = dayMap.get(event.date) ?? [];
|
|
602
|
+
list.push(event);
|
|
603
|
+
dayMap.set(event.date, list);
|
|
604
|
+
}
|
|
605
|
+
return [...dayMap.entries()].sort(([left], [right]) => left.localeCompare(right)).map(([date, dayEvents]) => ({
|
|
606
|
+
date,
|
|
607
|
+
count: dayEvents.length,
|
|
608
|
+
events: sortEvents(dayEvents)
|
|
609
|
+
}));
|
|
610
|
+
}
|
|
611
|
+
function summarize(events) {
|
|
612
|
+
const itemIds = /* @__PURE__ */ new Set();
|
|
613
|
+
const byType = /* @__PURE__ */ new Map();
|
|
614
|
+
const byStatus = /* @__PURE__ */ new Map();
|
|
615
|
+
let deadlines = 0;
|
|
616
|
+
let reminders = 0;
|
|
617
|
+
let scheduled = 0;
|
|
618
|
+
let recurringEvents = 0;
|
|
619
|
+
for (const event of events) {
|
|
620
|
+
itemIds.add(event.item_id);
|
|
621
|
+
incrementCount(byType, event.item_type);
|
|
622
|
+
incrementCount(byStatus, event.item_status);
|
|
623
|
+
if (event.kind === "deadline") {
|
|
624
|
+
deadlines += 1;
|
|
625
|
+
} else if (event.kind === "reminder") {
|
|
626
|
+
reminders += 1;
|
|
627
|
+
} else {
|
|
628
|
+
scheduled += 1;
|
|
629
|
+
if (event.event_recurring === true) {
|
|
630
|
+
recurringEvents += 1;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return {
|
|
635
|
+
events: events.length,
|
|
636
|
+
items: itemIds.size,
|
|
637
|
+
deadlines,
|
|
638
|
+
reminders,
|
|
639
|
+
scheduled,
|
|
640
|
+
by_kind: {
|
|
641
|
+
deadline: deadlines,
|
|
642
|
+
reminder: reminders,
|
|
643
|
+
event: scheduled
|
|
644
|
+
},
|
|
645
|
+
by_type: toSortedCountRecord(byType),
|
|
646
|
+
by_status: toSortedCountRecord(byStatus),
|
|
647
|
+
recurring_events: recurringEvents
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
async function runCalendar(options, global2) {
|
|
651
|
+
const pmRoot = resolvePmRoot(process.cwd(), global2.path);
|
|
652
|
+
if (!await pathExists(getSettingsPath(pmRoot))) {
|
|
653
|
+
throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
|
|
654
|
+
}
|
|
655
|
+
const nowValue = nowIso();
|
|
656
|
+
const view = parseView(options.view);
|
|
657
|
+
const rangeBounds = buildRange(view, options, nowValue);
|
|
658
|
+
const limit = parseIntegerLimit(options.limit);
|
|
659
|
+
const includeSources = parseIncludeSources(options.include);
|
|
660
|
+
const explicitLookahead = parseNonNegativeInteger(options.recurrenceLookaheadDays, "Calendar recurrence lookahead days");
|
|
661
|
+
const recurrenceLookbackDays = parseNonNegativeInteger(options.recurrenceLookbackDays, "Calendar recurrence lookback days");
|
|
662
|
+
const occurrenceLimit = parseNonNegativeInteger(options.occurrenceLimit, "Calendar occurrence limit");
|
|
663
|
+
if (occurrenceLimit !== void 0 && occurrenceLimit < 1) {
|
|
664
|
+
throw new PmCliError("Calendar occurrence limit must be >= 1", EXIT_CODE.USAGE);
|
|
665
|
+
}
|
|
666
|
+
const eventsOnly = includeSources.has("events") && !includeSources.has("deadlines") && !includeSources.has("reminders");
|
|
667
|
+
const hasExplicitBounds = options.to !== void 0 || explicitLookahead !== void 0 || occurrenceLimit !== void 0;
|
|
668
|
+
const eventsOnlyCapApplied = eventsOnly && !hasExplicitBounds;
|
|
669
|
+
const recurrenceLookaheadDays = eventsOnlyCapApplied ? DEFAULT_EVENTS_ONLY_LOOKAHEAD_DAYS : explicitLookahead;
|
|
670
|
+
const recurrenceLookbackWindowDays = eventsOnlyCapApplied && recurrenceLookbackDays === void 0 ? 0 : recurrenceLookbackDays;
|
|
671
|
+
const settings = await readSettings(pmRoot);
|
|
672
|
+
const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
|
|
673
|
+
const runtimeFieldRegistry = resolveRuntimeFieldRegistry(settings.schema);
|
|
674
|
+
const runtimeFieldFilters = collectRuntimeFilterValues(options, runtimeFieldRegistry, "calendar");
|
|
675
|
+
const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
|
|
676
|
+
const listWarnings = [];
|
|
677
|
+
if (eventsOnlyCapApplied) {
|
|
678
|
+
listWarnings.push(`recurring_events_default_cap_applied:lookback=0d,lookahead=${DEFAULT_EVENTS_ONLY_LOOKAHEAD_DAYS}d -- use --recurrence-lookback-days/--recurrence-lookahead-days or --to for wider range`);
|
|
679
|
+
}
|
|
680
|
+
const items = await listAllFrontMatterLight(pmRoot, settings.item_format, typeRegistry.type_to_folder, listWarnings, settings.schema);
|
|
681
|
+
const filteredItems = filterItems(items, options, typeRegistry, statusRegistry, runtimeFieldFilters);
|
|
682
|
+
const recurringWindow = buildRecurringEventWindow(rangeBounds.start, rangeBounds.end, nowValue, recurrenceLookbackWindowDays, recurrenceLookaheadDays);
|
|
683
|
+
const seededEvents = buildEventSeed(filteredItems, recurringWindow, includeSources, occurrenceLimit);
|
|
684
|
+
const rangedEvents = seededEvents.filter((event) => includeEventInWindow(event, rangeBounds.start, rangeBounds.end));
|
|
685
|
+
const limitedEvents = limit === void 0 ? rangedEvents : rangedEvents.slice(0, limit);
|
|
686
|
+
const days = bucketEventsByDay(limitedEvents);
|
|
687
|
+
const warnings = [...new Set(listWarnings)].sort((left, right) => left.localeCompare(right));
|
|
688
|
+
return {
|
|
689
|
+
view,
|
|
690
|
+
output_default: "markdown",
|
|
691
|
+
now: nowValue,
|
|
692
|
+
anchor: rangeBounds.anchor,
|
|
693
|
+
range: {
|
|
694
|
+
start: rangeBounds.start ?? null,
|
|
695
|
+
end: rangeBounds.end ?? null,
|
|
696
|
+
period_start: rangeBounds.periodStart ?? null,
|
|
697
|
+
period_end: rangeBounds.periodEnd ?? null,
|
|
698
|
+
full_period: rangeBounds.fullPeriod,
|
|
699
|
+
past: options.past === true,
|
|
700
|
+
from: options.from ?? null,
|
|
701
|
+
to: options.to ?? null
|
|
702
|
+
},
|
|
703
|
+
filters: {
|
|
704
|
+
type: options.type ?? null,
|
|
705
|
+
tag: options.tag ?? null,
|
|
706
|
+
priority: options.priority ?? null,
|
|
707
|
+
status: options.status ?? null,
|
|
708
|
+
assignee: options.assignee ?? null,
|
|
709
|
+
assignee_filter: options.assigneeFilter ?? null,
|
|
710
|
+
sprint: options.sprint ?? null,
|
|
711
|
+
release: options.release ?? null,
|
|
712
|
+
runtime_filters: runtimeFieldFilters,
|
|
713
|
+
limit: options.limit ?? null,
|
|
714
|
+
include: options.include ?? null,
|
|
715
|
+
full_period: options.fullPeriod === true ? "true" : null,
|
|
716
|
+
recurrence_lookahead_days: options.recurrenceLookaheadDays ?? null,
|
|
717
|
+
recurrence_lookback_days: options.recurrenceLookbackDays ?? null,
|
|
718
|
+
occurrence_limit: options.occurrenceLimit ?? null
|
|
719
|
+
},
|
|
720
|
+
summary: summarize(limitedEvents),
|
|
721
|
+
events: limitedEvents,
|
|
722
|
+
days,
|
|
723
|
+
...warnings.length > 0 ? { warnings } : {}
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// dist/cli/commands/context.js
|
|
728
|
+
!(function() {
|
|
729
|
+
try {
|
|
730
|
+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
731
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "d5f50a52-85aa-5e3d-b803-9c1500b4320c");
|
|
732
|
+
} catch (e2) {
|
|
733
|
+
}
|
|
734
|
+
})();
|
|
735
|
+
var CONTEXT_OUTPUT_VALUES = ["markdown", "toon", "json"];
|
|
736
|
+
var HIGH_LEVEL_TYPES = /* @__PURE__ */ new Set(["Epic", "Feature"]);
|
|
737
|
+
var DEFAULT_CONTEXT_LIMIT = 10;
|
|
738
|
+
var STANDARD_SECTIONS = ["hierarchy", "activity", "progress", "workload"];
|
|
739
|
+
var DEEP_SECTIONS = [
|
|
740
|
+
...STANDARD_SECTIONS,
|
|
741
|
+
"blockers",
|
|
742
|
+
"files",
|
|
743
|
+
"staleness",
|
|
744
|
+
"tests"
|
|
745
|
+
];
|
|
746
|
+
function parseOutputFormat(raw) {
|
|
747
|
+
if (!raw)
|
|
748
|
+
return void 0;
|
|
749
|
+
const normalized = raw.trim().toLowerCase();
|
|
750
|
+
if (!CONTEXT_OUTPUT_VALUES.includes(normalized)) {
|
|
751
|
+
throw new PmCliError("Context format must be one of markdown|toon|json", EXIT_CODE.USAGE);
|
|
752
|
+
}
|
|
753
|
+
return normalized;
|
|
754
|
+
}
|
|
755
|
+
function resolveContextOutputFormat(options, global2) {
|
|
756
|
+
const commandFormat = parseOutputFormat(options.format);
|
|
757
|
+
if (global2.json && commandFormat && commandFormat !== "json") {
|
|
758
|
+
throw new PmCliError("Cannot combine --json with --format markdown|toon", EXIT_CODE.USAGE);
|
|
759
|
+
}
|
|
760
|
+
if (global2.json) {
|
|
761
|
+
return "json";
|
|
762
|
+
}
|
|
763
|
+
return commandFormat ?? "toon";
|
|
764
|
+
}
|
|
765
|
+
function parseContextLimit(raw) {
|
|
766
|
+
return parseIntegerLimit(raw, "--limit") ?? DEFAULT_CONTEXT_LIMIT;
|
|
767
|
+
}
|
|
768
|
+
function parseContextDepth(raw, settings) {
|
|
769
|
+
if (!raw)
|
|
770
|
+
return settings.default_depth;
|
|
771
|
+
const normalized = raw.trim().toLowerCase();
|
|
772
|
+
if (!CONTEXT_DEPTH_VALUES.includes(normalized)) {
|
|
773
|
+
throw new PmCliError(`Context --depth must be one of ${CONTEXT_DEPTH_VALUES.join("|")}`, EXIT_CODE.USAGE);
|
|
774
|
+
}
|
|
775
|
+
return normalized;
|
|
776
|
+
}
|
|
777
|
+
function parseContextSections(raw, depth, settings) {
|
|
778
|
+
if (raw && raw.length > 0) {
|
|
779
|
+
const sections = [];
|
|
780
|
+
for (const value of raw) {
|
|
781
|
+
const normalized = value.trim().toLowerCase();
|
|
782
|
+
if (!CONTEXT_SECTION_VALUES.includes(normalized)) {
|
|
783
|
+
throw new PmCliError(`Context --section must be one of ${CONTEXT_SECTION_VALUES.join("|")}`, EXIT_CODE.USAGE);
|
|
784
|
+
}
|
|
785
|
+
if (!sections.includes(normalized)) {
|
|
786
|
+
sections.push(normalized);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
return sections;
|
|
790
|
+
}
|
|
791
|
+
if (depth === "brief")
|
|
792
|
+
return [];
|
|
793
|
+
const pool = depth === "deep" ? DEEP_SECTIONS : STANDARD_SECTIONS;
|
|
794
|
+
return pool.filter((section) => settings.sections[section]);
|
|
795
|
+
}
|
|
796
|
+
function parseActivityLimit(raw, settings) {
|
|
797
|
+
if (!raw)
|
|
798
|
+
return settings.activity_limit;
|
|
799
|
+
return parseIntegerLimit(raw, "--activity-limit") ?? settings.activity_limit;
|
|
800
|
+
}
|
|
801
|
+
function parseStaleThresholdDays(raw, settings) {
|
|
802
|
+
if (!raw)
|
|
803
|
+
return settings.stale_threshold_days;
|
|
804
|
+
const trimmed = raw.trim().toLowerCase();
|
|
805
|
+
const match = /^(\d+)d?$/.exec(trimmed);
|
|
806
|
+
if (!match) {
|
|
807
|
+
throw new PmCliError("--stale-threshold must be a number of days (e.g. 7 or 7d)", EXIT_CODE.USAGE);
|
|
808
|
+
}
|
|
809
|
+
const days = parseInt(match[1], 10);
|
|
810
|
+
if (days <= 0) {
|
|
811
|
+
throw new PmCliError("--stale-threshold must be positive", EXIT_CODE.USAGE);
|
|
812
|
+
}
|
|
813
|
+
return days;
|
|
814
|
+
}
|
|
815
|
+
function statusRank(status, statusRegistry) {
|
|
816
|
+
const normalizedStatus = normalizeStatusForRegistry(status, statusRegistry);
|
|
817
|
+
const inProgressStatus = normalizeStatusInput("in_progress", statusRegistry);
|
|
818
|
+
const openStatus = normalizeStatusInput("open", statusRegistry) ?? statusRegistry.open_status;
|
|
819
|
+
const blockedStatus = normalizeStatusInput("blocked", statusRegistry);
|
|
820
|
+
const draftStatus = normalizeStatusInput("draft", statusRegistry);
|
|
821
|
+
if (inProgressStatus && normalizedStatus === inProgressStatus)
|
|
822
|
+
return 0;
|
|
823
|
+
if (openStatus && normalizedStatus === openStatus)
|
|
824
|
+
return 1;
|
|
825
|
+
if (blockedStatus && normalizedStatus === blockedStatus)
|
|
826
|
+
return 2;
|
|
827
|
+
if (draftStatus && normalizedStatus === draftStatus)
|
|
828
|
+
return 3;
|
|
829
|
+
if (statusRegistry.active_statuses.has(normalizedStatus))
|
|
830
|
+
return 4;
|
|
831
|
+
if (statusRegistry.blocked_statuses.has(normalizedStatus))
|
|
832
|
+
return 5;
|
|
833
|
+
if (statusRegistry.terminal_statuses.has(normalizedStatus))
|
|
834
|
+
return 7;
|
|
835
|
+
return 6;
|
|
836
|
+
}
|
|
837
|
+
function isClosedStatus(status, statusRegistry) {
|
|
838
|
+
const closeStatus = normalizeStatusInput("closed", statusRegistry);
|
|
839
|
+
return closeStatus ? normalizeStatusForRegistry(status, statusRegistry) === closeStatus : false;
|
|
840
|
+
}
|
|
841
|
+
function isInProgressStatus(status, statusRegistry) {
|
|
842
|
+
const inProgressStatus = normalizeStatusInput("in_progress", statusRegistry);
|
|
843
|
+
return inProgressStatus ? normalizeStatusForRegistry(status, statusRegistry) === inProgressStatus : false;
|
|
844
|
+
}
|
|
845
|
+
function isOpenStatus(status, statusRegistry) {
|
|
846
|
+
const openStatus = normalizeStatusInput("open", statusRegistry) ?? statusRegistry.open_status;
|
|
847
|
+
return normalizeStatusForRegistry(status, statusRegistry) === openStatus;
|
|
848
|
+
}
|
|
849
|
+
function isBlockedStatus(status, statusRegistry) {
|
|
850
|
+
return statusRegistry.blocked_statuses.has(normalizeStatusForRegistry(status, statusRegistry));
|
|
851
|
+
}
|
|
852
|
+
var LIST_PROJECTION_FLAGS = ["compact", "brief", "fields", "includeBody", "include_body"];
|
|
853
|
+
function stripListProjectionFlags(options) {
|
|
854
|
+
const copy = { ...options };
|
|
855
|
+
for (const key of LIST_PROJECTION_FLAGS) {
|
|
856
|
+
delete copy[key];
|
|
857
|
+
}
|
|
858
|
+
return copy;
|
|
859
|
+
}
|
|
860
|
+
function compareOptionalOrder(left, right) {
|
|
861
|
+
const leftValue = left ?? null;
|
|
862
|
+
const rightValue = right ?? null;
|
|
863
|
+
if (leftValue === null && rightValue === null)
|
|
864
|
+
return 0;
|
|
865
|
+
if (leftValue === null)
|
|
866
|
+
return 1;
|
|
867
|
+
if (rightValue === null)
|
|
868
|
+
return -1;
|
|
869
|
+
return leftValue - rightValue;
|
|
870
|
+
}
|
|
871
|
+
function compareOptionalDeadline(left, right) {
|
|
872
|
+
const leftValue = left ?? null;
|
|
873
|
+
const rightValue = right ?? null;
|
|
874
|
+
if (leftValue === null && rightValue === null)
|
|
875
|
+
return 0;
|
|
876
|
+
if (leftValue === null)
|
|
877
|
+
return 1;
|
|
878
|
+
if (rightValue === null)
|
|
879
|
+
return -1;
|
|
880
|
+
return compareTimestampStrings(leftValue, rightValue);
|
|
881
|
+
}
|
|
882
|
+
function compareCriticalItems(left, right, statusRegistry) {
|
|
883
|
+
const byStatus = statusRank(left.status, statusRegistry) - statusRank(right.status, statusRegistry);
|
|
884
|
+
if (byStatus !== 0)
|
|
885
|
+
return byStatus;
|
|
886
|
+
const byPriority = left.priority - right.priority;
|
|
887
|
+
if (byPriority !== 0)
|
|
888
|
+
return byPriority;
|
|
889
|
+
const byOrder = compareOptionalOrder(left.order, right.order);
|
|
890
|
+
if (byOrder !== 0)
|
|
891
|
+
return byOrder;
|
|
892
|
+
const byDeadline = compareOptionalDeadline(left.deadline, right.deadline);
|
|
893
|
+
if (byDeadline !== 0)
|
|
894
|
+
return byDeadline;
|
|
895
|
+
const byUpdated = compareTimestampStrings(right.updated_at, left.updated_at);
|
|
896
|
+
const byId = left.id.localeCompare(right.id);
|
|
897
|
+
return byUpdated !== 0 ? byUpdated : byId;
|
|
898
|
+
}
|
|
899
|
+
function toContextFocusItem(item) {
|
|
900
|
+
return {
|
|
901
|
+
id: item.id,
|
|
902
|
+
title: item.title,
|
|
903
|
+
type: item.type,
|
|
904
|
+
status: item.status,
|
|
905
|
+
priority: item.priority,
|
|
906
|
+
order: item.order ?? null,
|
|
907
|
+
deadline: item.deadline ?? null,
|
|
908
|
+
assignee: item.assignee ?? null,
|
|
909
|
+
tags: Array.isArray(item.tags) ? [...item.tags] : [],
|
|
910
|
+
updated_at: item.updated_at
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
function summarizeAgenda(events) {
|
|
914
|
+
let deadlines = 0;
|
|
915
|
+
let reminders = 0;
|
|
916
|
+
let scheduled = 0;
|
|
917
|
+
const itemIds = /* @__PURE__ */ new Set();
|
|
918
|
+
for (const event of events) {
|
|
919
|
+
itemIds.add(event.item_id);
|
|
920
|
+
if (event.kind === "deadline") {
|
|
921
|
+
deadlines += 1;
|
|
922
|
+
continue;
|
|
923
|
+
}
|
|
924
|
+
if (event.kind === "reminder") {
|
|
925
|
+
reminders += 1;
|
|
926
|
+
continue;
|
|
927
|
+
}
|
|
928
|
+
scheduled += 1;
|
|
929
|
+
}
|
|
930
|
+
return {
|
|
931
|
+
events: events.length,
|
|
932
|
+
items: itemIds.size,
|
|
933
|
+
deadlines,
|
|
934
|
+
reminders,
|
|
935
|
+
scheduled
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
function filterTerminalCalendarEvents(events, statusRegistry) {
|
|
939
|
+
return events.filter((event) => !statusRegistry.terminal_statuses.has(normalizeStatusForRegistry(event.item_status, statusRegistry)));
|
|
940
|
+
}
|
|
941
|
+
function buildHierarchy(allItems, activeItems, statusRegistry, limit) {
|
|
942
|
+
const itemMap = /* @__PURE__ */ new Map();
|
|
943
|
+
for (const item of allItems) {
|
|
944
|
+
itemMap.set(item.id, item);
|
|
945
|
+
}
|
|
946
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
947
|
+
for (const item of allItems) {
|
|
948
|
+
if (!item.parent)
|
|
949
|
+
continue;
|
|
950
|
+
const children = childrenByParent.get(item.parent) ?? [];
|
|
951
|
+
children.push(item);
|
|
952
|
+
childrenByParent.set(item.parent, children);
|
|
953
|
+
}
|
|
954
|
+
const activeHighLevelIds = new Set(activeItems.filter((item) => HIGH_LEVEL_TYPES.has(item.type)).map((item) => item.id));
|
|
955
|
+
const nodes = [];
|
|
956
|
+
for (const parentId of activeHighLevelIds) {
|
|
957
|
+
const parent = itemMap.get(parentId);
|
|
958
|
+
if (!parent)
|
|
959
|
+
continue;
|
|
960
|
+
const allDescendants = collectDescendants(parentId, childrenByParent);
|
|
961
|
+
const childItems = childrenByParent.get(parentId) ?? [];
|
|
962
|
+
let closedCount = 0;
|
|
963
|
+
let openCount = 0;
|
|
964
|
+
let inProgressCount = 0;
|
|
965
|
+
let blockedCount = 0;
|
|
966
|
+
for (const desc of allDescendants) {
|
|
967
|
+
if (isClosedStatus(desc.status, statusRegistry))
|
|
968
|
+
closedCount++;
|
|
969
|
+
else if (isInProgressStatus(desc.status, statusRegistry))
|
|
970
|
+
inProgressCount++;
|
|
971
|
+
else if (isBlockedStatus(desc.status, statusRegistry))
|
|
972
|
+
blockedCount++;
|
|
973
|
+
else if (isOpenStatus(desc.status, statusRegistry))
|
|
974
|
+
openCount++;
|
|
975
|
+
}
|
|
976
|
+
const children = childItems.sort((a, b) => compareCriticalItems(a, b, statusRegistry)).slice(0, limit).map((child) => {
|
|
977
|
+
const grandchildren = collectDescendants(child.id, childrenByParent);
|
|
978
|
+
const gcClosed = grandchildren.filter((gc) => isClosedStatus(gc.status, statusRegistry)).length;
|
|
979
|
+
return {
|
|
980
|
+
id: child.id,
|
|
981
|
+
title: child.title,
|
|
982
|
+
type: child.type,
|
|
983
|
+
status: child.status,
|
|
984
|
+
children_total: grandchildren.length,
|
|
985
|
+
children_closed: gcClosed
|
|
986
|
+
};
|
|
987
|
+
});
|
|
988
|
+
nodes.push({
|
|
989
|
+
id: parent.id,
|
|
990
|
+
title: parent.title,
|
|
991
|
+
type: parent.type,
|
|
992
|
+
status: parent.status,
|
|
993
|
+
children_total: allDescendants.length,
|
|
994
|
+
children_closed: closedCount,
|
|
995
|
+
children_open: openCount,
|
|
996
|
+
children_in_progress: inProgressCount,
|
|
997
|
+
children_blocked: blockedCount,
|
|
998
|
+
children
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
return nodes.sort((a, b) => {
|
|
1002
|
+
const aParent = itemMap.get(a.id);
|
|
1003
|
+
const bParent = itemMap.get(b.id);
|
|
1004
|
+
return compareCriticalItems(aParent, bParent, statusRegistry);
|
|
1005
|
+
}).slice(0, limit);
|
|
1006
|
+
}
|
|
1007
|
+
function collectDescendants(parentId, childrenByParent) {
|
|
1008
|
+
const result = [];
|
|
1009
|
+
const stack = [parentId];
|
|
1010
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1011
|
+
while (stack.length > 0) {
|
|
1012
|
+
const current = stack.pop();
|
|
1013
|
+
if (visited.has(current))
|
|
1014
|
+
continue;
|
|
1015
|
+
visited.add(current);
|
|
1016
|
+
const children = childrenByParent.get(current) ?? [];
|
|
1017
|
+
for (const child of children) {
|
|
1018
|
+
result.push(child);
|
|
1019
|
+
stack.push(child.id);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
return result;
|
|
1023
|
+
}
|
|
1024
|
+
async function buildActivity(activityLimit, global2) {
|
|
1025
|
+
const result = await runActivity({ compact: true, limit: String(activityLimit) }, global2);
|
|
1026
|
+
return result.compact_activity ?? [];
|
|
1027
|
+
}
|
|
1028
|
+
function buildProgress(allItems, activeItems, statusRegistry, limit) {
|
|
1029
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
1030
|
+
for (const item of allItems) {
|
|
1031
|
+
if (!item.parent)
|
|
1032
|
+
continue;
|
|
1033
|
+
const children = childrenByParent.get(item.parent) ?? [];
|
|
1034
|
+
children.push(item);
|
|
1035
|
+
childrenByParent.set(item.parent, children);
|
|
1036
|
+
}
|
|
1037
|
+
const activeHighLevel = activeItems.filter((item) => HIGH_LEVEL_TYPES.has(item.type));
|
|
1038
|
+
const entries = [];
|
|
1039
|
+
for (const parent of activeHighLevel) {
|
|
1040
|
+
const descendants = collectDescendants(parent.id, childrenByParent);
|
|
1041
|
+
const total = descendants.length;
|
|
1042
|
+
if (total === 0)
|
|
1043
|
+
continue;
|
|
1044
|
+
let closed = 0;
|
|
1045
|
+
let open = 0;
|
|
1046
|
+
let inProgress = 0;
|
|
1047
|
+
let blocked = 0;
|
|
1048
|
+
for (const desc of descendants) {
|
|
1049
|
+
if (isClosedStatus(desc.status, statusRegistry))
|
|
1050
|
+
closed++;
|
|
1051
|
+
else if (isInProgressStatus(desc.status, statusRegistry))
|
|
1052
|
+
inProgress++;
|
|
1053
|
+
else if (isBlockedStatus(desc.status, statusRegistry))
|
|
1054
|
+
blocked++;
|
|
1055
|
+
else if (isOpenStatus(desc.status, statusRegistry))
|
|
1056
|
+
open++;
|
|
1057
|
+
}
|
|
1058
|
+
entries.push({
|
|
1059
|
+
id: parent.id,
|
|
1060
|
+
title: parent.title,
|
|
1061
|
+
type: parent.type,
|
|
1062
|
+
total,
|
|
1063
|
+
closed,
|
|
1064
|
+
open,
|
|
1065
|
+
in_progress: inProgress,
|
|
1066
|
+
blocked,
|
|
1067
|
+
completion_pct: total > 0 ? Math.round(closed / total * 100) : 0
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
return entries.sort((a, b) => a.completion_pct - b.completion_pct).slice(0, limit);
|
|
1071
|
+
}
|
|
1072
|
+
function buildBlockers(blockedItems, itemMap, limit) {
|
|
1073
|
+
return blockedItems.slice(0, limit).map((item) => {
|
|
1074
|
+
const blockerItem = item.blocked_by ? itemMap.get(item.blocked_by) : void 0;
|
|
1075
|
+
return {
|
|
1076
|
+
id: item.id,
|
|
1077
|
+
title: item.title,
|
|
1078
|
+
blocked_by: item.blocked_by ?? null,
|
|
1079
|
+
blocked_by_title: blockerItem?.title ?? null,
|
|
1080
|
+
blocked_by_status: blockerItem?.status ?? null,
|
|
1081
|
+
blocked_reason: item.blocked_reason ?? null,
|
|
1082
|
+
unblock_note: item.unblock_note ?? null
|
|
1083
|
+
};
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
function buildHotFiles(activeItems, limit) {
|
|
1087
|
+
const fileMap = /* @__PURE__ */ new Map();
|
|
1088
|
+
for (const item of activeItems) {
|
|
1089
|
+
for (const file of item.files ?? []) {
|
|
1090
|
+
const existing = fileMap.get(file.path) ?? /* @__PURE__ */ new Set();
|
|
1091
|
+
existing.add(item.id);
|
|
1092
|
+
fileMap.set(file.path, existing);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
return [...fileMap.entries()].map(([filePath, itemIds]) => ({
|
|
1096
|
+
path: filePath,
|
|
1097
|
+
references: itemIds.size,
|
|
1098
|
+
items: [...itemIds].sort()
|
|
1099
|
+
})).sort((a, b) => b.references - a.references).slice(0, limit);
|
|
1100
|
+
}
|
|
1101
|
+
function buildWorkload(activeItems, statusRegistry, limit) {
|
|
1102
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1103
|
+
for (const item of activeItems) {
|
|
1104
|
+
const key = item.assignee ?? null;
|
|
1105
|
+
const existing = groups.get(key) ?? [];
|
|
1106
|
+
existing.push(item);
|
|
1107
|
+
groups.set(key, existing);
|
|
1108
|
+
}
|
|
1109
|
+
return [...groups.entries()].map(([assignee, items]) => ({
|
|
1110
|
+
assignee,
|
|
1111
|
+
active: items.length,
|
|
1112
|
+
in_progress: items.filter((item) => isInProgressStatus(item.status, statusRegistry)).length,
|
|
1113
|
+
items: items.map((item) => item.id).sort()
|
|
1114
|
+
})).sort((a, b) => b.active - a.active).slice(0, limit);
|
|
1115
|
+
}
|
|
1116
|
+
function buildStaleness(allNonTerminal, staleThresholdDays, now, limit) {
|
|
1117
|
+
const cutoffMs = new Date(now).getTime() - staleThresholdDays * 24 * 60 * 60 * 1e3;
|
|
1118
|
+
return allNonTerminal.filter((item) => new Date(item.updated_at).getTime() < cutoffMs).map((item) => ({
|
|
1119
|
+
id: item.id,
|
|
1120
|
+
title: item.title,
|
|
1121
|
+
status: item.status,
|
|
1122
|
+
updated_at: item.updated_at,
|
|
1123
|
+
stale_days: Math.floor((new Date(now).getTime() - new Date(item.updated_at).getTime()) / (24 * 60 * 60 * 1e3))
|
|
1124
|
+
})).sort((a, b) => b.stale_days - a.stale_days).slice(0, limit);
|
|
1125
|
+
}
|
|
1126
|
+
function buildTestHealth(activeItems) {
|
|
1127
|
+
let itemsWithTests = 0;
|
|
1128
|
+
let itemsWithRecentRuns = 0;
|
|
1129
|
+
let passed = 0;
|
|
1130
|
+
let failed = 0;
|
|
1131
|
+
let skipped = 0;
|
|
1132
|
+
const itemsFailing = [];
|
|
1133
|
+
for (const item of activeItems) {
|
|
1134
|
+
if ((item.tests ?? []).length > 0) {
|
|
1135
|
+
itemsWithTests++;
|
|
1136
|
+
}
|
|
1137
|
+
const runs = item.test_runs ?? [];
|
|
1138
|
+
if (runs.length > 0) {
|
|
1139
|
+
itemsWithRecentRuns++;
|
|
1140
|
+
let itemHasFailure = false;
|
|
1141
|
+
for (const run of runs) {
|
|
1142
|
+
passed += run.passed ?? 0;
|
|
1143
|
+
failed += run.failed ?? 0;
|
|
1144
|
+
skipped += run.skipped ?? 0;
|
|
1145
|
+
if ((run.failed ?? 0) > 0) {
|
|
1146
|
+
itemHasFailure = true;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
if (itemHasFailure) {
|
|
1150
|
+
itemsFailing.push(item.id);
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
return {
|
|
1155
|
+
items_with_tests: itemsWithTests,
|
|
1156
|
+
items_with_recent_runs: itemsWithRecentRuns,
|
|
1157
|
+
recent_runs: { passed, failed, skipped },
|
|
1158
|
+
items_failing: itemsFailing.sort()
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
function formatClock(timestamp) {
|
|
1162
|
+
return `${new Date(timestamp).toISOString().slice(11, 16)}Z`;
|
|
1163
|
+
}
|
|
1164
|
+
function formatFocusLine(item) {
|
|
1165
|
+
const orderToken = item.order === null ? "-" : String(item.order);
|
|
1166
|
+
const deadlineToken = item.deadline ?? "-";
|
|
1167
|
+
return `${item.id} p${item.priority} ${item.status} ${item.type} order:${orderToken} deadline:${deadlineToken} ${item.title}`;
|
|
1168
|
+
}
|
|
1169
|
+
function formatAgendaLine(event) {
|
|
1170
|
+
const base = `${formatClock(event.at)} [${event.kind}] ${event.item_id} p${event.item_priority} ${event.item_status} ${event.item_title}`;
|
|
1171
|
+
if (event.kind === "reminder") {
|
|
1172
|
+
return `${base} \u2014 ${event.reminder_text}`;
|
|
1173
|
+
}
|
|
1174
|
+
if (event.kind === "event") {
|
|
1175
|
+
const recurringSuffix = event.event_recurring ? " (recurring)" : "";
|
|
1176
|
+
const title = event.event_title ?? event.item_title;
|
|
1177
|
+
return `${base} \u2014 ${title}${recurringSuffix}`;
|
|
1178
|
+
}
|
|
1179
|
+
return base;
|
|
1180
|
+
}
|
|
1181
|
+
function renderContextMarkdown(result) {
|
|
1182
|
+
const lines = [];
|
|
1183
|
+
lines.push("# pm context");
|
|
1184
|
+
lines.push("");
|
|
1185
|
+
lines.push(`- now: ${result.now}`);
|
|
1186
|
+
lines.push(`- depth: ${result.depth}`);
|
|
1187
|
+
lines.push(`- active_items: ${result.summary.active_items} (in_progress: ${result.summary.in_progress}, open: ${result.summary.open})`);
|
|
1188
|
+
if (result.summary.total_items !== void 0) {
|
|
1189
|
+
lines.push(`- total_items: ${result.summary.total_items} (closed: ${result.summary.closed ?? 0}, canceled: ${result.summary.canceled ?? 0})`);
|
|
1190
|
+
}
|
|
1191
|
+
lines.push(`- agenda_events: ${result.summary.agenda_events}`);
|
|
1192
|
+
lines.push(`- blocked_fallback_used: ${result.summary.blocked_fallback_used}`);
|
|
1193
|
+
if (result.sections_included.length > 0) {
|
|
1194
|
+
lines.push(`- sections: ${result.sections_included.join(", ")}`);
|
|
1195
|
+
}
|
|
1196
|
+
lines.push("");
|
|
1197
|
+
lines.push("## High-level focus");
|
|
1198
|
+
if (result.high_level.length === 0) {
|
|
1199
|
+
lines.push("No high-level active items.");
|
|
1200
|
+
} else {
|
|
1201
|
+
for (const item of result.high_level) {
|
|
1202
|
+
lines.push(`- ${formatFocusLine(item)}`);
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
lines.push("");
|
|
1206
|
+
lines.push("## Low-level focus");
|
|
1207
|
+
if (result.low_level.length === 0) {
|
|
1208
|
+
lines.push("No low-level active items.");
|
|
1209
|
+
} else {
|
|
1210
|
+
for (const item of result.low_level) {
|
|
1211
|
+
lines.push(`- ${formatFocusLine(item)}`);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
lines.push("");
|
|
1215
|
+
if (result.blocked_fallback.length > 0) {
|
|
1216
|
+
lines.push("## Blocked fallback");
|
|
1217
|
+
for (const item of result.blocked_fallback) {
|
|
1218
|
+
lines.push(`- ${formatFocusLine(item)}`);
|
|
1219
|
+
}
|
|
1220
|
+
lines.push("");
|
|
1221
|
+
}
|
|
1222
|
+
lines.push("## Agenda");
|
|
1223
|
+
lines.push(`- events: ${result.agenda.summary.events} (deadlines: ${result.agenda.summary.deadlines}, reminders: ${result.agenda.summary.reminders}, scheduled: ${result.agenda.summary.scheduled})`);
|
|
1224
|
+
if (result.agenda.events.length === 0) {
|
|
1225
|
+
lines.push("No agenda events matched the selected filters.");
|
|
1226
|
+
} else {
|
|
1227
|
+
for (const event of result.agenda.events) {
|
|
1228
|
+
lines.push(`- ${formatAgendaLine(event)}`);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
lines.push("");
|
|
1232
|
+
if (result.hierarchy && result.hierarchy.length > 0) {
|
|
1233
|
+
lines.push("## Hierarchy");
|
|
1234
|
+
for (const node of result.hierarchy) {
|
|
1235
|
+
const pct = node.children_total > 0 ? Math.round(node.children_closed / node.children_total * 100) : 0;
|
|
1236
|
+
lines.push(`- ${node.id} ${node.type} ${node.status} "${node.title}" [${node.children_closed}/${node.children_total} done ${pct}%]`);
|
|
1237
|
+
for (const child of node.children) {
|
|
1238
|
+
const cpct = child.children_total > 0 ? Math.round(child.children_closed / child.children_total * 100) : 0;
|
|
1239
|
+
lines.push(` - ${child.id} ${child.type} ${child.status} "${child.title}" [${child.children_closed}/${child.children_total} done ${cpct}%]`);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
lines.push("");
|
|
1243
|
+
}
|
|
1244
|
+
if (result.progress && result.progress.length > 0) {
|
|
1245
|
+
lines.push("## Progress");
|
|
1246
|
+
for (const entry of result.progress) {
|
|
1247
|
+
lines.push(`- ${entry.id} "${entry.title}" ${entry.completion_pct}% (${entry.closed}/${entry.total} closed, ${entry.in_progress} wip, ${entry.open} open, ${entry.blocked} blocked)`);
|
|
1248
|
+
}
|
|
1249
|
+
lines.push("");
|
|
1250
|
+
}
|
|
1251
|
+
if (result.activity && result.activity.length > 0) {
|
|
1252
|
+
lines.push("## Recent activity");
|
|
1253
|
+
for (const entry of result.activity) {
|
|
1254
|
+
const msg = entry.msg ? ` ${entry.msg}` : "";
|
|
1255
|
+
lines.push(`- ${entry.ts.slice(0, 16)}Z ${entry.id} ${entry.op} by:${entry.author}${msg}`);
|
|
1256
|
+
}
|
|
1257
|
+
lines.push("");
|
|
1258
|
+
}
|
|
1259
|
+
if (result.blockers && result.blockers.length > 0) {
|
|
1260
|
+
lines.push("## Blockers");
|
|
1261
|
+
for (const entry of result.blockers) {
|
|
1262
|
+
const by = entry.blocked_by ? `blocked_by:${entry.blocked_by}(${entry.blocked_by_status ?? "?"})` : "blocked_by:-";
|
|
1263
|
+
const reason = entry.blocked_reason ? ` reason:"${entry.blocked_reason}"` : "";
|
|
1264
|
+
const note = entry.unblock_note ? ` unblock:"${entry.unblock_note}"` : "";
|
|
1265
|
+
lines.push(`- ${entry.id} "${entry.title}" ${by}${reason}${note}`);
|
|
1266
|
+
}
|
|
1267
|
+
lines.push("");
|
|
1268
|
+
}
|
|
1269
|
+
if (result.files && result.files.length > 0) {
|
|
1270
|
+
lines.push("## Hot files");
|
|
1271
|
+
for (const file of result.files) {
|
|
1272
|
+
lines.push(`- ${file.path} refs:${file.references} items:[${file.items.join(",")}]`);
|
|
1273
|
+
}
|
|
1274
|
+
lines.push("");
|
|
1275
|
+
}
|
|
1276
|
+
if (result.workload && result.workload.length > 0) {
|
|
1277
|
+
lines.push("## Workload");
|
|
1278
|
+
for (const entry of result.workload) {
|
|
1279
|
+
const who = entry.assignee ?? "(unassigned)";
|
|
1280
|
+
lines.push(`- ${who} active:${entry.active} wip:${entry.in_progress} items:[${entry.items.join(",")}]`);
|
|
1281
|
+
}
|
|
1282
|
+
lines.push("");
|
|
1283
|
+
}
|
|
1284
|
+
if (result.staleness && result.staleness.length > 0) {
|
|
1285
|
+
lines.push("## Stale items");
|
|
1286
|
+
for (const entry of result.staleness) {
|
|
1287
|
+
lines.push(`- ${entry.id} ${entry.status} stale:${entry.stale_days}d last:${entry.updated_at.slice(0, 10)} "${entry.title}"`);
|
|
1288
|
+
}
|
|
1289
|
+
lines.push("");
|
|
1290
|
+
}
|
|
1291
|
+
if (result.tests) {
|
|
1292
|
+
lines.push("## Test health");
|
|
1293
|
+
lines.push(`- items_with_tests: ${result.tests.items_with_tests}`);
|
|
1294
|
+
lines.push(`- items_with_recent_runs: ${result.tests.items_with_recent_runs}`);
|
|
1295
|
+
lines.push(`- passed: ${result.tests.recent_runs.passed}, failed: ${result.tests.recent_runs.failed}, skipped: ${result.tests.recent_runs.skipped}`);
|
|
1296
|
+
if (result.tests.items_failing.length > 0) {
|
|
1297
|
+
lines.push(`- items_failing: [${result.tests.items_failing.join(",")}]`);
|
|
1298
|
+
}
|
|
1299
|
+
lines.push("");
|
|
1300
|
+
}
|
|
1301
|
+
const isEmpty = result.summary.active_items === 0 && result.summary.blocked === 0 && result.agenda.summary.events === 0;
|
|
1302
|
+
if (isEmpty) {
|
|
1303
|
+
lines.push("## Suggestions");
|
|
1304
|
+
lines.push("No active work items or upcoming events. Consider:");
|
|
1305
|
+
lines.push('- `pm create --type Task --title "..."` to add a new work item');
|
|
1306
|
+
lines.push("- `pm list --status closed --limit 5` to review recent completions");
|
|
1307
|
+
lines.push("- `pm search <keywords>` to find related past work");
|
|
1308
|
+
lines.push("- `pm aggregate` for a full project status overview");
|
|
1309
|
+
}
|
|
1310
|
+
return lines.join("\n");
|
|
1311
|
+
}
|
|
1312
|
+
async function runContext(options, global2) {
|
|
1313
|
+
const pmRoot = resolvePmRoot(process.cwd(), global2.path);
|
|
1314
|
+
const settings = await readSettings(pmRoot);
|
|
1315
|
+
const contextSettings = settings.context ?? SETTINGS_DEFAULTS.context;
|
|
1316
|
+
const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
|
|
1317
|
+
const limit = parseContextLimit(options.limit);
|
|
1318
|
+
const depth = parseContextDepth(options.depth, contextSettings);
|
|
1319
|
+
const sectionsIncluded = parseContextSections(options.section, depth, contextSettings);
|
|
1320
|
+
const activityLimit = parseActivityLimit(options.activityLimit, contextSettings);
|
|
1321
|
+
const staleThresholdDays = parseStaleThresholdDays(options.staleThreshold, contextSettings);
|
|
1322
|
+
const needsAllItems = sectionsIncluded.some((s) => ["hierarchy", "progress", "blockers", "staleness"].includes(s));
|
|
1323
|
+
const baseListOptions = stripListProjectionFlags(options);
|
|
1324
|
+
const listOptions = { ...baseListOptions, excludeTerminal: true };
|
|
1325
|
+
const listed = await runList(void 0, listOptions, global2);
|
|
1326
|
+
const listedFrontMatter = listed.items;
|
|
1327
|
+
let allItems = listedFrontMatter;
|
|
1328
|
+
if (needsAllItems) {
|
|
1329
|
+
const allListOptions = { ...baseListOptions, excludeTerminal: false };
|
|
1330
|
+
const allListed = await runList(void 0, allListOptions, global2);
|
|
1331
|
+
allItems = allListed.items;
|
|
1332
|
+
}
|
|
1333
|
+
const ranked = [...listedFrontMatter].sort((left, right) => compareCriticalItems(left, right, statusRegistry));
|
|
1334
|
+
const activeStatuses = statusRegistry.active_statuses.size > 0 ? statusRegistry.active_statuses : /* @__PURE__ */ new Set([statusRegistry.open_status]);
|
|
1335
|
+
const blockedStatuses = statusRegistry.blocked_statuses;
|
|
1336
|
+
const activeItems = ranked.filter((item) => activeStatuses.has(normalizeStatusForRegistry(item.status, statusRegistry)));
|
|
1337
|
+
const blockedItems = ranked.filter((item) => blockedStatuses.has(normalizeStatusForRegistry(item.status, statusRegistry)));
|
|
1338
|
+
const highLevel = activeItems.filter((item) => HIGH_LEVEL_TYPES.has(item.type)).slice(0, limit).map(toContextFocusItem);
|
|
1339
|
+
const lowLevel = activeItems.filter((item) => !HIGH_LEVEL_TYPES.has(item.type)).slice(0, limit).map(toContextFocusItem);
|
|
1340
|
+
const blockedFallbackUsed = activeItems.length === 0;
|
|
1341
|
+
const blockedFallback = blockedFallbackUsed ? blockedItems.slice(0, limit).map(toContextFocusItem) : [];
|
|
1342
|
+
const calendarOptions = {
|
|
1343
|
+
...baseListOptions,
|
|
1344
|
+
view: "agenda",
|
|
1345
|
+
include: "all",
|
|
1346
|
+
limit: String(limit)
|
|
1347
|
+
};
|
|
1348
|
+
const agenda = await runCalendar(calendarOptions, global2);
|
|
1349
|
+
const agendaEvents = filterTerminalCalendarEvents(agenda.events, statusRegistry).slice(0, limit);
|
|
1350
|
+
const agendaSummary = summarizeAgenda(agendaEvents);
|
|
1351
|
+
const warnings = [.../* @__PURE__ */ new Set([...listed.warnings ?? [], ...agenda.warnings ?? []])].sort((left, right) => left.localeCompare(right));
|
|
1352
|
+
const inProgressStatus = normalizeStatusInput("in_progress", statusRegistry);
|
|
1353
|
+
const openStatus = normalizeStatusInput("open", statusRegistry) ?? statusRegistry.open_status;
|
|
1354
|
+
const inProgressCount = inProgressStatus ? activeItems.filter((item) => normalizeStatusForRegistry(item.status, statusRegistry) === inProgressStatus).length : 0;
|
|
1355
|
+
const openCount = activeItems.filter((item) => normalizeStatusForRegistry(item.status, statusRegistry) === openStatus).length;
|
|
1356
|
+
const now = agenda.now;
|
|
1357
|
+
const itemMap = /* @__PURE__ */ new Map();
|
|
1358
|
+
for (const item of allItems) {
|
|
1359
|
+
itemMap.set(item.id, item);
|
|
1360
|
+
}
|
|
1361
|
+
const allNonTerminal = allItems.filter((item) => !isTerminalStatus(item.status, statusRegistry));
|
|
1362
|
+
const has = (section) => sectionsIncluded.includes(section);
|
|
1363
|
+
const hierarchy = has("hierarchy") ? buildHierarchy(allItems, activeItems, statusRegistry, limit) : void 0;
|
|
1364
|
+
const activity = has("activity") ? await buildActivity(activityLimit, global2) : void 0;
|
|
1365
|
+
const progress = has("progress") ? buildProgress(allItems, activeItems, statusRegistry, limit) : void 0;
|
|
1366
|
+
const blockersSection = has("blockers") ? buildBlockers(blockedItems, itemMap, limit) : void 0;
|
|
1367
|
+
const filesSection = has("files") ? buildHotFiles(activeItems, limit) : void 0;
|
|
1368
|
+
const workload = has("workload") ? buildWorkload(activeItems, statusRegistry, limit) : void 0;
|
|
1369
|
+
const staleness = has("staleness") ? buildStaleness(allNonTerminal, staleThresholdDays, now, limit) : void 0;
|
|
1370
|
+
const tests = has("tests") ? buildTestHealth(activeItems) : void 0;
|
|
1371
|
+
const summaryExtras = needsAllItems ? {
|
|
1372
|
+
total_items: allItems.length,
|
|
1373
|
+
closed: allItems.filter((i) => isClosedStatus(i.status, statusRegistry)).length,
|
|
1374
|
+
canceled: allItems.filter((i) => {
|
|
1375
|
+
const canceledStatus = normalizeStatusInput("canceled", statusRegistry);
|
|
1376
|
+
return canceledStatus ? normalizeStatusForRegistry(i.status, statusRegistry) === canceledStatus : false;
|
|
1377
|
+
}).length
|
|
1378
|
+
} : {};
|
|
1379
|
+
const result = {
|
|
1380
|
+
output_default: "toon",
|
|
1381
|
+
now,
|
|
1382
|
+
depth,
|
|
1383
|
+
sections_included: sectionsIncluded,
|
|
1384
|
+
window: {
|
|
1385
|
+
anchor: agenda.anchor,
|
|
1386
|
+
start: agenda.range.start,
|
|
1387
|
+
end: agenda.range.end,
|
|
1388
|
+
past: agenda.range.past,
|
|
1389
|
+
from: agenda.range.from,
|
|
1390
|
+
to: agenda.range.to
|
|
1391
|
+
},
|
|
1392
|
+
filters: {
|
|
1393
|
+
type: options.type ?? null,
|
|
1394
|
+
tag: options.tag ?? null,
|
|
1395
|
+
priority: options.priority ?? null,
|
|
1396
|
+
assignee: options.assignee ?? null,
|
|
1397
|
+
assignee_filter: options.assigneeFilter ?? null,
|
|
1398
|
+
sprint: options.sprint ?? null,
|
|
1399
|
+
release: options.release ?? null,
|
|
1400
|
+
limit: options.limit ?? null,
|
|
1401
|
+
runtime_filters: listed.filters.runtime_filters ?? agenda.filters.runtime_filters ?? {}
|
|
1402
|
+
},
|
|
1403
|
+
summary: {
|
|
1404
|
+
active_items: activeItems.length,
|
|
1405
|
+
in_progress: inProgressCount,
|
|
1406
|
+
open: openCount,
|
|
1407
|
+
blocked: blockedItems.length,
|
|
1408
|
+
blocked_fallback_used: blockedFallbackUsed,
|
|
1409
|
+
high_level: highLevel.length,
|
|
1410
|
+
low_level: lowLevel.length,
|
|
1411
|
+
agenda_events: agendaSummary.events,
|
|
1412
|
+
...summaryExtras
|
|
1413
|
+
},
|
|
1414
|
+
high_level: highLevel,
|
|
1415
|
+
low_level: lowLevel,
|
|
1416
|
+
blocked_fallback: blockedFallback,
|
|
1417
|
+
agenda: {
|
|
1418
|
+
summary: agendaSummary,
|
|
1419
|
+
events: agendaEvents
|
|
1420
|
+
}
|
|
1421
|
+
};
|
|
1422
|
+
if (hierarchy)
|
|
1423
|
+
result.hierarchy = hierarchy;
|
|
1424
|
+
if (activity)
|
|
1425
|
+
result.activity = activity;
|
|
1426
|
+
if (progress)
|
|
1427
|
+
result.progress = progress;
|
|
1428
|
+
if (blockersSection)
|
|
1429
|
+
result.blockers = blockersSection;
|
|
1430
|
+
if (filesSection)
|
|
1431
|
+
result.files = filesSection;
|
|
1432
|
+
if (workload)
|
|
1433
|
+
result.workload = workload;
|
|
1434
|
+
if (staleness)
|
|
1435
|
+
result.staleness = staleness;
|
|
1436
|
+
if (tests)
|
|
1437
|
+
result.tests = tests;
|
|
1438
|
+
if (warnings.length > 0)
|
|
1439
|
+
result.warnings = warnings;
|
|
1440
|
+
if (activeItems.length === 0 && blockedItems.length === 0 && agendaEvents.length === 0) {
|
|
1441
|
+
result.suggestions = [
|
|
1442
|
+
'pm create --type Task --title "..." to add a new work item',
|
|
1443
|
+
"pm list --status closed --limit 5 to review recent completions",
|
|
1444
|
+
"pm search <keywords> to find related past work",
|
|
1445
|
+
"pm aggregate for a full project status overview"
|
|
1446
|
+
];
|
|
1447
|
+
}
|
|
1448
|
+
return result;
|
|
1449
|
+
}
|
|
1450
|
+
export {
|
|
1451
|
+
CONTEXT_OUTPUT_VALUES,
|
|
1452
|
+
parseContextDepth,
|
|
1453
|
+
parseContextSections,
|
|
1454
|
+
renderContextMarkdown,
|
|
1455
|
+
resolveContextOutputFormat,
|
|
1456
|
+
runContext
|
|
1457
|
+
};
|
|
1458
|
+
//# sourceMappingURL=context-RZ5QPNJB.js.map
|