@unbrained/pm-cli 2026.5.29 → 2026.5.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +29 -12
  2. package/dist/cli/bootstrap-args.d.ts +1 -1
  3. package/dist/cli/bootstrap-args.js +59 -9
  4. package/dist/cli/bootstrap-args.js.map +1 -1
  5. package/dist/cli/commands/activity.js +4 -4
  6. package/dist/cli/commands/activity.js.map +1 -1
  7. package/dist/cli/commands/calendar.js +4 -4
  8. package/dist/cli/commands/calendar.js.map +1 -1
  9. package/dist/cli/commands/close.js +4 -4
  10. package/dist/cli/commands/close.js.map +1 -1
  11. package/dist/cli/commands/completion.js +4 -4
  12. package/dist/cli/commands/completion.js.map +1 -1
  13. package/dist/cli/commands/create.js +18 -5
  14. package/dist/cli/commands/create.js.map +1 -1
  15. package/dist/cli/commands/deps.js +4 -4
  16. package/dist/cli/commands/deps.js.map +1 -1
  17. package/dist/cli/commands/extension/install-sources.d.ts +1 -0
  18. package/dist/cli/commands/extension/install-sources.js +20 -2
  19. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  20. package/dist/cli/commands/extension.js +26 -5
  21. package/dist/cli/commands/extension.js.map +1 -1
  22. package/dist/cli/commands/get.js +6 -3
  23. package/dist/cli/commands/get.js.map +1 -1
  24. package/dist/cli/commands/list.js +25 -6
  25. package/dist/cli/commands/list.js.map +1 -1
  26. package/dist/cli/commands/search.js +3 -3
  27. package/dist/cli/commands/search.js.map +1 -1
  28. package/dist/cli/commands/stats.js +4 -4
  29. package/dist/cli/commands/stats.js.map +1 -1
  30. package/dist/cli/commands/test-all.js +4 -4
  31. package/dist/cli/commands/test-all.js.map +1 -1
  32. package/dist/cli/main.d.ts +2 -0
  33. package/dist/cli/main.js +39 -11
  34. package/dist/cli/main.js.map +1 -1
  35. package/dist/cli/register-list-query.js +3 -3
  36. package/dist/cli/register-list-query.js.map +1 -1
  37. package/dist/cli/register-setup.js +3 -3
  38. package/dist/cli/register-setup.js.map +1 -1
  39. package/dist/cli-bundle/chunks/chunk-PB2YU2E3.js +164 -0
  40. package/dist/cli-bundle/chunks/chunk-PB2YU2E3.js.map +7 -0
  41. package/dist/cli-bundle/chunks/chunk-RJONRNXN.js +682 -0
  42. package/dist/cli-bundle/chunks/chunk-RJONRNXN.js.map +7 -0
  43. package/dist/cli-bundle/chunks/chunk-SW5BMMCU.js +13864 -0
  44. package/dist/cli-bundle/chunks/chunk-SW5BMMCU.js.map +7 -0
  45. package/dist/cli-bundle/chunks/commands-XJ4TJ5UN.js +24225 -0
  46. package/dist/cli-bundle/chunks/commands-XJ4TJ5UN.js.map +7 -0
  47. package/dist/cli-bundle/chunks/register-list-query-EIVQ5FMR.js +223 -0
  48. package/dist/cli-bundle/chunks/register-list-query-EIVQ5FMR.js.map +7 -0
  49. package/dist/cli-bundle/chunks/register-mutation-RSZNPSGI.js +702 -0
  50. package/dist/cli-bundle/chunks/register-mutation-RSZNPSGI.js.map +7 -0
  51. package/dist/cli-bundle/chunks/register-operations-APUSYDMR.js +355 -0
  52. package/dist/cli-bundle/chunks/register-operations-APUSYDMR.js.map +7 -0
  53. package/dist/cli-bundle/chunks/register-setup-OZOKSMPJ.js +237 -0
  54. package/dist/cli-bundle/chunks/register-setup-OZOKSMPJ.js.map +7 -0
  55. package/dist/cli-bundle/main.js +6896 -0
  56. package/dist/cli-bundle/main.js.map +7 -0
  57. package/dist/cli.js +1 -1
  58. package/dist/core/config/nested-settings.d.ts +2 -0
  59. package/dist/core/config/nested-settings.js +17 -2
  60. package/dist/core/config/nested-settings.js.map +1 -1
  61. package/dist/core/item/type-synonyms.d.ts +20 -0
  62. package/dist/core/item/type-synonyms.js +42 -0
  63. package/dist/core/item/type-synonyms.js.map +1 -0
  64. package/dist/core/search/cache.js +46 -4
  65. package/dist/core/search/cache.js.map +1 -1
  66. package/dist/core/search/semantic-defaults.js +73 -32
  67. package/dist/core/search/semantic-defaults.js.map +1 -1
  68. package/dist/core/sentry/helpers.d.ts +1 -1
  69. package/dist/core/sentry/helpers.js +4 -4
  70. package/dist/core/sentry/helpers.js.map +1 -1
  71. package/dist/core/shared/constants.js +3 -2
  72. package/dist/core/shared/constants.js.map +1 -1
  73. package/dist/core/shared/html-entity-decode.d.ts +2 -1
  74. package/dist/core/shared/html-entity-decode.js +14 -9
  75. package/dist/core/shared/html-entity-decode.js.map +1 -1
  76. package/dist/core/shared/time.js +52 -2
  77. package/dist/core/shared/time.js.map +1 -1
  78. package/dist/core/store/front-matter-cache.d.ts +24 -0
  79. package/dist/core/store/front-matter-cache.js +119 -8
  80. package/dist/core/store/front-matter-cache.js.map +1 -1
  81. package/dist/core/store/item-store.d.ts +7 -0
  82. package/dist/core/store/item-store.js +13 -3
  83. package/dist/core/store/item-store.js.map +1 -1
  84. package/dist/core/store/settings-validator.d.ts +1 -0
  85. package/dist/core/store/settings-validator.js +3 -2
  86. package/dist/core/store/settings-validator.js.map +1 -1
  87. package/dist/core/store/settings.js +19 -3
  88. package/dist/core/store/settings.js.map +1 -1
  89. package/dist/mcp/server.js +3 -3
  90. package/dist/mcp/server.js.map +1 -1
  91. package/dist/sdk/cli-contracts.js +5 -5
  92. package/dist/sdk/cli-contracts.js.map +1 -1
  93. package/dist/types.d.ts +2 -0
  94. package/dist/types.js +2 -2
  95. package/dist/types.js.map +1 -1
  96. package/docs/CONFIGURATION.md +11 -0
  97. package/package.json +7 -4
  98. package/packages/pm-calendar/extensions/calendar/index.js +27 -2
  99. package/packages/pm-calendar/extensions/calendar/index.ts +28 -2
  100. package/scripts/bundle-cli.mjs +39 -0
@@ -0,0 +1,702 @@
1
+ import {
2
+ collect,
3
+ createLazyModule,
4
+ extractUpdateManyMutationOptionSource,
5
+ formatHookWarnings,
6
+ getGlobalOptions,
7
+ invalidateSearchCachesForMutation,
8
+ normalizeCreateOptions,
9
+ normalizeUpdateOptions
10
+ } from "./chunk-RJONRNXN.js";
11
+ import {
12
+ BUILTIN_ITEM_TYPE_VALUES,
13
+ CREATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS,
14
+ EXIT_CODE,
15
+ PmCliError,
16
+ UPDATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS,
17
+ printError,
18
+ printResult,
19
+ writeStdout
20
+ } from "./chunk-SW5BMMCU.js";
21
+
22
+ // dist/cli/register-mutation.js
23
+ import { Option } from "commander";
24
+
25
+ // dist/core/shared/option-alias-visibility.js
26
+ !(function() {
27
+ try {
28
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
29
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "9682a7a8-88b3-512a-9c6b-d2dfbe6bc2fb");
30
+ } catch (e2) {
31
+ }
32
+ })();
33
+ function extractLongFlags(flagSpec) {
34
+ return flagSpec.split(/[\s,|]+/).map((token) => token.trim()).filter((token) => token.startsWith("--"));
35
+ }
36
+ function extractLongFlag(flagSpec) {
37
+ return extractLongFlags(flagSpec)[0] ?? null;
38
+ }
39
+ function isPureSnakeCaseAlias(canonicalFlagSpec, aliasFlagSpec) {
40
+ const aliasLong = extractLongFlag(aliasFlagSpec);
41
+ if (aliasLong === null) {
42
+ return false;
43
+ }
44
+ const normalize = (long) => long.slice(2).replaceAll("-", "_");
45
+ return extractLongFlags(canonicalFlagSpec).some((canonicalLong) => {
46
+ if (!canonicalLong.slice(2).includes("-")) {
47
+ return false;
48
+ }
49
+ if (aliasLong === canonicalLong) {
50
+ return false;
51
+ }
52
+ return normalize(aliasLong) === normalize(canonicalLong);
53
+ });
54
+ }
55
+
56
+ // dist/cli/register-mutation.js
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] = "1c5454e2-e849-5b5f-b7a1-2681e8a90eac");
61
+ } catch (e2) {
62
+ }
63
+ })();
64
+ var BUILTIN_TYPE_NAME_LOOKUP = new Set(BUILTIN_ITEM_TYPE_VALUES.map((value) => value.toLowerCase()));
65
+ var loadMutationCommandsModule = createLazyModule(() => import("./commands-XJ4TJ5UN.js"));
66
+ function addHiddenOption(command, flags, description, repeatable) {
67
+ const option = new Option(flags, description).hideHelp();
68
+ if (repeatable) {
69
+ option.argParser(collect);
70
+ }
71
+ command.addOption(option);
72
+ }
73
+ function registerCommanderOptionContracts(command, contracts) {
74
+ for (const contract of contracts) {
75
+ if (contract.required) {
76
+ command.requiredOption(contract.option, contract.description);
77
+ } else if (contract.repeatable) {
78
+ command.option(contract.option, contract.description, collect);
79
+ } else {
80
+ command.option(contract.option, contract.description);
81
+ }
82
+ for (const aliasContract of contract.aliasOptions ?? []) {
83
+ if (isPureSnakeCaseAlias(contract.option, aliasContract.option)) {
84
+ addHiddenOption(command, aliasContract.option, aliasContract.description, contract.repeatable === true);
85
+ } else if (contract.repeatable) {
86
+ command.option(aliasContract.option, aliasContract.description, collect);
87
+ } else {
88
+ command.option(aliasContract.option, aliasContract.description);
89
+ }
90
+ }
91
+ }
92
+ }
93
+ function registerMutationCommands(program) {
94
+ const createCommand = program.command("create").argument("[typeOrTitle]", 'Item title, or item type when a title follows (e.g. `pm create task "Fix bug"`)').argument("[title]", "Item title when the first argument is an item type").description("Create a new project management item.");
95
+ registerCommanderOptionContracts(createCommand, CREATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS);
96
+ createCommand.option("--clear-deps", "Clear dependency entries").option("--clear-comments", "Clear comments").option("--clear-notes", "Clear notes").option("--clear-learnings", "Clear learnings").option("--clear-files", "Clear linked files").option("--clear-tests", "Clear linked tests").option("--clear-docs", "Clear linked docs").option("--clear-reminders", "Clear reminders").option("--clear-events", "Clear events").option("--clear-type-options", "Clear type options").action(async (typeOrTitle, secondTitle, options, command) => {
97
+ const globalOptions = getGlobalOptions(command);
98
+ const startedAt = Date.now();
99
+ let positionalType;
100
+ let positionalTitle;
101
+ if (typeof secondTitle === "string" && secondTitle.length > 0) {
102
+ positionalType = typeOrTitle;
103
+ positionalTitle = secondTitle;
104
+ } else if (typeof typeOrTitle === "string" && typeOrTitle.length > 0) {
105
+ positionalTitle = typeOrTitle;
106
+ }
107
+ if (positionalType === void 0 && typeof positionalTitle === "string" && positionalTitle.length > 0 && options.title === void 0 && options.type === void 0 && BUILTIN_TYPE_NAME_LOOKUP.has(positionalTitle.trim().toLowerCase())) {
108
+ const matchedType = positionalTitle.trim();
109
+ throw new PmCliError(`pm create needs a title \u2014 "${matchedType}" looks like an item type, not a title. Use either: pm create ${matchedType} "<title>" or pm create "<title>" --type ${matchedType}.`, EXIT_CODE.USAGE, {
110
+ code: "create_positional_type_without_title",
111
+ why: 'Without this guard the single positional is used as the title and the type defaults to Task \u2014 so the command would silently create a Task literally titled "' + matchedType + '".',
112
+ examples: [
113
+ `pm create ${matchedType} "Wire up SSO for the agent harness"`,
114
+ `pm create "Wire up SSO for the agent harness" --type ${matchedType}`
115
+ ],
116
+ nextSteps: [
117
+ `Re-run with both type and title: pm create ${matchedType} "<title>"`
118
+ ]
119
+ });
120
+ }
121
+ if (typeof positionalType === "string" && positionalType.length > 0 && options.type === void 0) {
122
+ options.type = positionalType;
123
+ }
124
+ if (typeof positionalTitle === "string" && positionalTitle.length > 0 && options.title === void 0) {
125
+ options.title = positionalTitle;
126
+ }
127
+ const normalized = normalizeCreateOptions(options, { requireType: false });
128
+ const { runCreate } = await loadMutationCommandsModule();
129
+ const result = await runCreate(normalized, globalOptions);
130
+ await invalidateSearchCachesForMutation(globalOptions, result);
131
+ printResult(result, globalOptions);
132
+ if (globalOptions.profile) {
133
+ printError(`profile:command=create took_ms=${Date.now() - startedAt}`);
134
+ }
135
+ });
136
+ const updateCommand = program.command("update").argument("<id>", "Item id").description("Update item fields and metadata.");
137
+ registerCommanderOptionContracts(updateCommand, UPDATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS);
138
+ updateCommand.option("--replace-deps", "Atomically replace dependency entries with the provided --dep values").option("--replace-tests", "Atomically replace linked test entries with the provided --test values").option("--clear-deps", "Clear dependency entries").option("--clear-comments", "Clear comments").option("--clear-notes", "Clear notes").option("--clear-learnings", "Clear learnings").option("--clear-files", "Clear linked files").option("--clear-tests", "Clear linked tests").option("--clear-docs", "Clear linked docs").option("--clear-reminders", "Clear reminders").option("--clear-events", "Clear events").option("--clear-type-options", "Clear type options").option("--allow-audit-update", "Allow non-owner metadata-only audit updates without requiring --force").option("--allow-audit-dep-update", "Allow non-owner append-only dependency updates without requiring --force").option("--force", "Force ownership override");
139
+ addHiddenOption(updateCommand, "--allow_audit_update", "Alias for --allow-audit-update", false);
140
+ addHiddenOption(updateCommand, "--allow_audit_dep_update", "Alias for --allow-audit-dep-update", false);
141
+ updateCommand.action(async (id, options, command) => {
142
+ const globalOptions = getGlobalOptions(command);
143
+ const startedAt = Date.now();
144
+ const { runUpdate } = await loadMutationCommandsModule();
145
+ const result = await runUpdate(id, normalizeUpdateOptions(options), globalOptions);
146
+ await invalidateSearchCachesForMutation(globalOptions, result);
147
+ printResult(result, globalOptions);
148
+ if (globalOptions.profile) {
149
+ printError(`profile:command=update took_ms=${Date.now() - startedAt}`);
150
+ }
151
+ });
152
+ const updateManyCommand = program.command("update-many").description("Bulk-update matched items with dry-run plans and rollback checkpoints.").option("--filter-status <value>", "Filter by status before applying updates").option("--filter-type <value>", "Filter by item type before applying updates").option("--filter-tag <value>", "Filter by tag before applying updates").option("--filter-priority <value>", "Filter by priority before applying updates").option("--filter-deadline-before <value>", "Filter by deadline upper bound before applying updates").option("--filter-deadline-after <value>", "Filter by deadline lower bound before applying updates").option("--filter-assignee <value>", "Filter by assignee before applying updates").option("--filter-assignee-filter <value>", "Filter assignee presence: assigned|unassigned before applying updates").option("--filter-parent <value>", "Filter by parent item ID before applying updates").option("--filter-sprint <value>", "Filter by sprint before applying updates").option("--filter-release <value>", "Filter by release before applying updates").option("--limit <n>", "Limit matched item count before apply/preview").option("--offset <n>", "Skip first n matched rows before apply/preview").option("--dry-run", "Preview per-item diffs and checkpoint intent without mutating").option("--rollback <value>", "Rollback a prior update-many checkpoint ID").option("--no-checkpoint", "Disable checkpoint creation during apply mode").option("--title, -t <value>", "Set title").option("--description, -d <value>", "Set description").option("--body, -b <value>", "Set body (allow empty string)").option("--status, -s <value>", "Set status (use close command for closed)").option("--priority, -p <value>", "Set priority").option("--type <value>", "Set type").option("--tags <value>", "Set comma-separated tags (replaces existing). Use --add-tags / --remove-tags to mutate additively.").option("--add-tags <value>", "Add tags additively without replacing existing (repeatable; CSV accepted)", collect).option("--remove-tags <value>", "Remove tags from the existing list (repeatable; CSV accepted)", collect).option("--deadline <value>", "Set deadline (ISO/date string or relative)").option("--estimate, --estimated-minutes <value>", "Set estimated minutes").option("--acceptance-criteria <value>", "Set acceptance criteria").option("--ac <value>", "Alias for --acceptance-criteria").option("--definition-of-ready <value>", "Set definition of ready").option("--order <value>", "Set planning order/rank integer").option("--rank <value>", "Alias for --order").option("--goal <value>", "Set goal identifier").option("--objective <value>", "Set objective identifier").option("--value <value>", "Set business value summary").option("--impact <value>", "Set business impact summary").option("--outcome <value>", "Set expected outcome summary").option("--why-now <value>", "Set why-now rationale").option("--assignee <value>", "Set assignee").option("--parent <value>", "Set parent item ID").option("--reviewer <value>", "Set reviewer").option("--risk <value>", "Set risk level").option("--confidence <value>", "Set confidence level").option("--sprint <value>", "Set sprint identifier").option("--release <value>", "Set release identifier").option("--blocked-by <value>", "Set blocked-by item ID or reason").option("--blocked-reason <value>", "Set blocked reason").option("--unblock-note <value>", "Set unblock rationale note").option("--reporter <value>", "Set issue reporter").option("--severity <value>", "Set issue severity").option("--environment <value>", "Set issue environment context").option("--repro-steps <value>", "Set issue reproduction steps").option("--resolution <value>", "Set issue resolution summary").option("--expected-result <value>", "Set issue expected behavior").option("--expected <value>", "Short alias for --expected-result").option("--actual-result <value>", "Set issue observed behavior").option("--actual <value>", "Short alias for --actual-result").option("--affected-version <value>", "Set affected version identifier").option("--fixed-version <value>", "Set fixed version identifier").option("--component <value>", "Set issue component ownership").option("--regression <value>", "Set regression marker: true|false|1|0").option("--customer-impact <value>", "Set customer impact summary").option("--dep <value>", "Add dependency entry id=<id>,kind=<kind>,author=<author>,created_at=<timestamp>", collect).option("--dep-remove <value>", "Remove dependency entries by id/kind/author/timestamp signature", collect).option("--replace-deps", "Atomically replace dependency entries with provided --dep values").option("--replace-tests", "Atomically replace linked tests with provided --test values").option("--comment <value>", "Add comment seed author=<value>,created_at=<iso|now>,text=<value>", collect).option("--note <value>", "Add note seed author=<value>,created_at=<iso|now>,text=<value>", collect).option("--learning <value>", "Add learning seed author=<value>,created_at=<iso|now>,text=<value>", collect).option("--file <value>", "Add linked file path=<value>,scope=<project|global>,note=<text>", collect).option("--test <value>", "Add linked test command=<value>,path=<value>,scope=<project|global>", collect).option("--doc <value>", "Add linked doc path=<value>,scope=<project|global>,note=<text>", collect).option("--reminder <value>", "Add reminder entry at=<iso|relative>|date=<iso|relative>,text=<text>|title=<text>", collect).option("--event <value>", "Add event entry start=<iso|relative>,end=<iso|relative>,recur_*", collect).option("--type-option <value>", "Set type options key=value (repeatable)", collect).option("--unset <field>", "Clear scalar metadata field by name (repeatable)", collect).option("--clear-deps", "Clear dependency entries").option("--clear-comments", "Clear comments").option("--clear-notes", "Clear notes").option("--clear-learnings", "Clear learnings").option("--clear-files", "Clear linked files").option("--clear-tests", "Clear linked tests").option("--clear-docs", "Clear linked docs").option("--clear-reminders", "Clear reminders").option("--clear-events", "Clear events").option("--clear-type-options", "Clear type options").option("--allow-audit-update", "Allow non-owner metadata-only audit updates without requiring --force").option("--allow-audit-dep-update", "Allow non-owner append-only dependency updates without requiring --force").option("--author <value>", "Mutation author").option("--message <value>", "Mutation message").option("--force", "Force ownership override");
153
+ for (const [flags, description] of [
154
+ ["--filter-assignee_filter <value>", "Alias for --filter-assignee-filter"],
155
+ ["--estimated_minutes <value>", "Alias for --estimated-minutes"],
156
+ ["--acceptance_criteria <value>", "Alias for --acceptance-criteria"],
157
+ ["--definition_of_ready <value>", "Alias for --definition-of-ready"],
158
+ ["--why_now <value>", "Alias for --why-now"],
159
+ ["--blocked_by <value>", "Alias for --blocked-by"],
160
+ ["--blocked_reason <value>", "Alias for --blocked-reason"],
161
+ ["--unblock_note <value>", "Alias for --unblock-note"],
162
+ ["--repro_steps <value>", "Alias for --repro-steps"],
163
+ ["--expected_result <value>", "Alias for --expected-result"],
164
+ ["--actual_result <value>", "Alias for --actual-result"],
165
+ ["--affected_version <value>", "Alias for --affected-version"],
166
+ ["--fixed_version <value>", "Alias for --fixed-version"],
167
+ ["--customer_impact <value>", "Alias for --customer-impact"],
168
+ ["--allow_audit_update", "Alias for --allow-audit-update"],
169
+ ["--allow_audit_dep_update", "Alias for --allow-audit-dep-update"]
170
+ ]) {
171
+ addHiddenOption(updateManyCommand, flags, description, false);
172
+ }
173
+ for (const [flags, description] of [
174
+ ["--dep_remove <value>", "Alias for --dep-remove"],
175
+ ["--type_option <value>", "Alias for --type-option"],
176
+ ["--add_tags <value>", "Alias for --add-tags"],
177
+ ["--remove_tags <value>", "Alias for --remove-tags"]
178
+ ]) {
179
+ addHiddenOption(updateManyCommand, flags, description, true);
180
+ }
181
+ updateManyCommand.action(async (options, command) => {
182
+ const globalOptions = getGlobalOptions(command);
183
+ const startedAt = Date.now();
184
+ const { runUpdateMany } = await loadMutationCommandsModule();
185
+ const result = await runUpdateMany({
186
+ status: typeof options.filterStatus === "string" ? options.filterStatus : void 0,
187
+ list: {
188
+ type: typeof options.filterType === "string" ? options.filterType : void 0,
189
+ tag: typeof options.filterTag === "string" ? options.filterTag : void 0,
190
+ priority: typeof options.filterPriority === "string" ? options.filterPriority : void 0,
191
+ deadlineBefore: typeof options.filterDeadlineBefore === "string" ? options.filterDeadlineBefore : void 0,
192
+ deadlineAfter: typeof options.filterDeadlineAfter === "string" ? options.filterDeadlineAfter : void 0,
193
+ assignee: typeof options.filterAssignee === "string" ? options.filterAssignee : void 0,
194
+ assigneeFilter: typeof options.filterAssigneeFilter === "string" ? options.filterAssigneeFilter : typeof options.filterAssignee_filter === "string" ? options.filterAssignee_filter : void 0,
195
+ parent: typeof options.filterParent === "string" ? options.filterParent : void 0,
196
+ sprint: typeof options.filterSprint === "string" ? options.filterSprint : void 0,
197
+ release: typeof options.filterRelease === "string" ? options.filterRelease : void 0,
198
+ limit: typeof options.limit === "string" ? options.limit : void 0,
199
+ offset: typeof options.offset === "string" ? options.offset : void 0,
200
+ includeBody: true
201
+ },
202
+ update: normalizeUpdateOptions(extractUpdateManyMutationOptionSource(options)),
203
+ dryRun: options.dryRun === true ? true : void 0,
204
+ rollback: typeof options.rollback === "string" ? options.rollback : void 0,
205
+ checkpoint: options.checkpoint === false ? false : void 0
206
+ }, globalOptions);
207
+ await invalidateSearchCachesForMutation(globalOptions, result);
208
+ printResult(result, globalOptions);
209
+ if (globalOptions.profile) {
210
+ printError(`profile:command=update-many took_ms=${Date.now() - startedAt}`);
211
+ }
212
+ });
213
+ const closeCommand = program.command("close").argument("<id>", "Item id").argument("[text]", "Close reason text (alias: --reason)").option("--reason <value>", "Close reason text (alias for positional <text>)").option("--close-reason <value>", "Close reason text (alias for positional <text>)").option("--author <value>", "Mutation author").option("--message <value>", "History message").option("--validate-close [mode]", 'Validate closure metadata before close: "off", "warn", or "strict" (default: settings governance preset)').option("--resolution <value>", "Set the closure resolution summary inline (same field --validate-close strict checks; previously required a prior pm update)").option("--expected-result <value>", "Set the expected-result note inline (closure validation field)").option("--expected <value>", "Short alias for --expected-result").option("--actual-result <value>", "Set the actual-result note inline (closure validation field)").option("--actual <value>", "Short alias for --actual-result").option("--force", "Force ownership override").description("Close an item with a required reason.");
214
+ addHiddenOption(closeCommand, "--expected_result <value>", "Alias for --expected-result", false);
215
+ addHiddenOption(closeCommand, "--actual_result <value>", "Alias for --actual-result", false);
216
+ closeCommand.action(async (id, text, options, command) => {
217
+ const globalOptions = getGlobalOptions(command);
218
+ const startedAt = Date.now();
219
+ const { runClose } = await loadMutationCommandsModule();
220
+ const reasonFromOption = typeof options.reason === "string" && options.reason.trim().length > 0 && options.reason || typeof options.closeReason === "string" && options.closeReason.trim().length > 0 && options.closeReason || void 0;
221
+ const resolvedText = typeof text === "string" && text.length > 0 ? text : reasonFromOption;
222
+ if (typeof resolvedText !== "string" || resolvedText.length === 0) {
223
+ throw new PmCliError("pm close requires a close reason as the second positional argument or via --reason.", EXIT_CODE.USAGE, {
224
+ code: "missing_required_argument",
225
+ why: "Close mutations are auditable; a reason is mandatory for the history record.",
226
+ examples: [
227
+ `pm close ${id} "All acceptance criteria met"`,
228
+ `pm close ${id} --reason "Verified by integration test"`
229
+ ],
230
+ nextSteps: [
231
+ 'Re-run with the close reason as the second positional argument, or pass --reason "<text>".'
232
+ ]
233
+ });
234
+ }
235
+ const pickInlineString = (...candidates) => {
236
+ for (const candidate of candidates) {
237
+ if (typeof candidate === "string") {
238
+ return candidate;
239
+ }
240
+ }
241
+ return void 0;
242
+ };
243
+ const result = await runClose(id, resolvedText, {
244
+ author: typeof options.author === "string" ? options.author : void 0,
245
+ message: typeof options.message === "string" ? options.message : void 0,
246
+ validateClose: options.validateClose === true ? "warn" : typeof options.validateClose === "string" ? options.validateClose : void 0,
247
+ force: Boolean(options.force),
248
+ resolution: typeof options.resolution === "string" ? options.resolution : void 0,
249
+ expectedResult: pickInlineString(options.expectedResult, options.expected_result, options.expected),
250
+ actualResult: pickInlineString(options.actualResult, options.actual_result, options.actual)
251
+ }, globalOptions);
252
+ await invalidateSearchCachesForMutation(globalOptions, result);
253
+ printResult(result, globalOptions);
254
+ if (globalOptions.profile) {
255
+ printError(`profile:command=close took_ms=${Date.now() - startedAt}`);
256
+ }
257
+ });
258
+ program.command("delete").argument("<id>", "Item id").option("--author <value>", "Mutation author").option("--message <value>", "History message").option("--force", "Force ownership override").option("--dry-run", "Preview the item file that would be deleted without mutating").description("Delete an item and record the change in history.").action(async (id, options, command) => {
259
+ const globalOptions = getGlobalOptions(command);
260
+ const startedAt = Date.now();
261
+ const { runDelete } = await loadMutationCommandsModule();
262
+ const result = await runDelete(id, {
263
+ author: typeof options.author === "string" ? options.author : void 0,
264
+ message: typeof options.message === "string" ? options.message : void 0,
265
+ force: Boolean(options.force),
266
+ dryRun: options.dryRun === true
267
+ }, globalOptions);
268
+ if (result.dry_run !== true) {
269
+ await invalidateSearchCachesForMutation(globalOptions, result);
270
+ }
271
+ printResult(result, globalOptions);
272
+ if (globalOptions.profile) {
273
+ printError(`profile:command=delete took_ms=${Date.now() - startedAt}`);
274
+ }
275
+ });
276
+ program.command("append").argument("<id>", "Item id").argument("[text]", "Optional body text shorthand (equivalent to --body; use - for stdin)").option("--body <value>", "Text to append to body (or - for stdin)").option("--text <value>", "Alias for --body").option("--author <value>", "Mutation author").option("--message <value>", "Mutation message").option("--force", "Force ownership override").description("Append text to an item's body.").action(async (id, text, options, command) => {
277
+ const globalOptions = getGlobalOptions(command);
278
+ const startedAt = Date.now();
279
+ const bodyFromOption = typeof options.body === "string" ? options.body : void 0;
280
+ const bodyFromAlias = typeof options.text === "string" ? options.text : void 0;
281
+ const bodyFromPositional = typeof text === "string" ? text : void 0;
282
+ const bodySourceCount = [bodyFromOption, bodyFromAlias, bodyFromPositional].filter((value) => value !== void 0).length;
283
+ if (bodySourceCount > 1) {
284
+ throw new PmCliError("Specify append text with exactly one source: positional [text], --body, or --text", EXIT_CODE.USAGE);
285
+ }
286
+ const resolvedBody = bodyFromOption ?? bodyFromAlias ?? bodyFromPositional;
287
+ if (resolvedBody === void 0) {
288
+ throw new PmCliError("Missing append text. Provide it as positional [text], --body <value>, or --text <value> (use - for stdin).", EXIT_CODE.USAGE);
289
+ }
290
+ const { runAppend } = await loadMutationCommandsModule();
291
+ const result = await runAppend(id, {
292
+ body: resolvedBody,
293
+ author: typeof options.author === "string" ? options.author : void 0,
294
+ message: typeof options.message === "string" ? options.message : void 0,
295
+ force: Boolean(options.force)
296
+ }, globalOptions);
297
+ await invalidateSearchCachesForMutation(globalOptions, result);
298
+ printResult(result, globalOptions);
299
+ if (globalOptions.profile) {
300
+ printError(`profile:command=append took_ms=${Date.now() - startedAt}`);
301
+ }
302
+ });
303
+ program.command("restore").argument("<id>", "Item id").argument("<target>", "Restore target timestamp or version number").option("--author <value>", "Mutation author").option("--message <value>", "History message").option("--force", "Force ownership/lock override").description("Restore an item to an earlier timestamp or version.").action(async (id, target, options, command) => {
304
+ const globalOptions = getGlobalOptions(command);
305
+ const startedAt = Date.now();
306
+ const { runRestore } = await loadMutationCommandsModule();
307
+ const result = await runRestore(id, target, {
308
+ author: typeof options.author === "string" ? options.author : void 0,
309
+ message: typeof options.message === "string" ? options.message : void 0,
310
+ force: Boolean(options.force)
311
+ }, globalOptions);
312
+ await invalidateSearchCachesForMutation(globalOptions, result);
313
+ printResult(result, globalOptions);
314
+ if (globalOptions.profile) {
315
+ printError(`profile:command=restore took_ms=${Date.now() - startedAt}`);
316
+ }
317
+ });
318
+ const planCommand = program.command("plan").description("Agent-optimized Plan item workflow: create, manage steps, link dependencies, approve, and materialize.").argument("[subcommand]", "Plan subcommand: create|show|add-step|update-step|complete-step|block-step|reorder-step|remove-step|link|unlink|decision|discovery|validation|resume|approve|materialize").argument("[id]", "Plan id (required for non-create subcommands); for create this may be the positional title").argument("[stepRef]", "Step reference: stable id (plan-step-001) or order integer").argument("[reorderTo]", "New order integer for reorder-step").option("--title <value>", "Plan title").option("--description <value>", "Plan description").option("--scope <value>", "Short scope statement of the target change or investigation").option("--parent <value>", "Parent pm item id").option("--related <value>", "Related pm item ids (repeatable, csv-friendly)", collect).option("--blocks <value>", "Pm item ids this plan blocks (repeatable, csv-friendly)", collect).option("--blocked-by <value>", "Pm item ids that block this plan (repeatable, csv-friendly)", collect).option("--harness <value>", "Plan harness provenance: codex|claude-code|cursor|generic").option("--mode <value>", "Plan mode: draft|research|review|approved|executing|paused|completed|superseded").option("--resume-context <value>", "Compact context summary for a future stateless agent").option("--tags <value>", "Comma-separated tags").option("--priority <value>", "Priority 0-4").option("--body <value>", "Plan item body").option("--claim", "Claim the plan on create for the author").option("--from-search <value>", "Record the search query that led to plan creation").option("--step-title <value>", "Step title for add-step / update-step").option("--step <value>", "Alias for --step-title").option("--step-body <value>", "Step body text").option("--step-owner <value>", "Step owner").option("--step-status <value>", "Step status: pending|in_progress|completed|blocked|skipped|superseded").option("--step-evidence <value>", "Step evidence text (used by update-step/complete-step)").option("--step-blocked-reason <value>", "Step blocked reason (required when blocking)").option("--step-replacement <value>", "Replacement reference for a superseded step").option("--depends-on <value>", "Pm item ids the step depends on (repeatable, csv-friendly)", collect).option("--link <value>", "Pm item id to link (repeatable, csv-friendly)", collect).option("--link-kind <value>", "Link kind: related|blocks|blocked_by|depends_on|discovered_from|implements|verifies|supersedes").option("--link-note <value>", "Optional note for the link").option("--promote-to-item-dep", "Also add the linked id as a top-level item dependency when linking").option("--allow-multiple-active", "Allow multiple steps to be in_progress at once").option("--file <value>", "Step linked file path=<value>[,scope=project|global,note=<text>] (repeatable)", collect).option("--test <value>", "Step linked test command=<value>[,path=<value>,note=<text>] (repeatable)", collect).option("--doc <value>", "Step linked doc path=<value>[,scope=project|global,note=<text>] (repeatable)", collect).option("--decision-text <value>", "Decision log entry text").option("--decision <value>", "Alias for --decision-text").option("--decision-rationale <value>", "Decision log entry rationale").option("--decision-evidence <value>", "Decision log entry evidence").option("--discovery-text <value>", "Discovery log entry text").option("--discovery <value>", "Alias for --discovery-text").option("--validation-text <value>", "Validation log entry text").option("--validation <value>", "Alias for --validation-text").option("--validation-command <value>", "Validation log entry command").option("--validation-expected <value>", "Validation log entry expected outcome").option("--depth <value>", "Show depth: brief|standard|deep (default: brief)").option("--fields <value>", "Comma-separated field projection for show output").option("--steps <value>", "Comma-separated step ids/orders for materialize").option("--materialize-type <value>", "Item type for materialized steps (default: Task)").option("--materialize-parent <value>", "Parent item id for materialized children (default: the plan)").option("--materialize-tags <value>", "Comma-separated tags for materialized children").option("--author <value>", "Mutation author").option("--message <value>", "Mutation message").option("--force", "Force ownership override");
319
+ for (const [flags, description] of [
320
+ ["--resume_context <value>", "Alias for --resume-context"],
321
+ ["--from_search <value>", "Alias for --from-search"],
322
+ ["--step_title <value>", "Alias for --step-title"],
323
+ ["--step_body <value>", "Alias for --step-body"],
324
+ ["--step_owner <value>", "Alias for --step-owner"],
325
+ ["--step_status <value>", "Alias for --step-status"],
326
+ ["--step_evidence <value>", "Alias for --step-evidence"],
327
+ ["--step_blocked_reason <value>", "Alias for --step-blocked-reason"],
328
+ ["--step_replacement <value>", "Alias for --step-replacement"],
329
+ ["--link_kind <value>", "Alias for --link-kind"],
330
+ ["--link_note <value>", "Alias for --link-note"],
331
+ ["--promote_to_item_dep", "Alias for --promote-to-item-dep"],
332
+ ["--allow_multiple_active", "Alias for --allow-multiple-active"],
333
+ ["--decision_text <value>", "Alias for --decision-text"],
334
+ ["--decision_rationale <value>", "Alias for --decision-rationale"],
335
+ ["--decision_evidence <value>", "Alias for --decision-evidence"],
336
+ ["--discovery_text <value>", "Alias for --discovery-text"],
337
+ ["--validation_text <value>", "Alias for --validation-text"],
338
+ ["--validation_command <value>", "Alias for --validation-command"],
339
+ ["--validation_expected <value>", "Alias for --validation-expected"],
340
+ ["--materialize_type <value>", "Alias for --materialize-type"],
341
+ ["--materialize_parent <value>", "Alias for --materialize-parent"],
342
+ ["--materialize_tags <value>", "Alias for --materialize-tags"]
343
+ ]) {
344
+ addHiddenOption(planCommand, flags, description, false);
345
+ }
346
+ for (const [flags, description] of [
347
+ ["--blocked_by <value>", "Alias for --blocked-by"],
348
+ ["--depends_on <value>", "Alias for --depends-on"]
349
+ ]) {
350
+ addHiddenOption(planCommand, flags, description, true);
351
+ }
352
+ planCommand.action(async (subcommand, id, stepRef, reorderToken, options, command) => {
353
+ const globalOptions = getGlobalOptions(command);
354
+ const startedAt = Date.now();
355
+ const { runPlan, PLAN_SUBCOMMANDS } = await loadMutationCommandsModule();
356
+ const normalizedSubcommand = (subcommand ?? "").trim().toLowerCase();
357
+ if (!normalizedSubcommand) {
358
+ throw new PmCliError(`pm plan requires a subcommand. Allowed: ${PLAN_SUBCOMMANDS.join(", ")}`, EXIT_CODE.USAGE, {
359
+ code: "missing_required_argument",
360
+ examples: [
361
+ 'pm plan create --title "Refactor lock retry"',
362
+ "pm plan show pm-a1b2 --depth standard",
363
+ 'pm plan add-step pm-a1b2 --step-title "Read lock.ts"'
364
+ ]
365
+ });
366
+ }
367
+ if (!PLAN_SUBCOMMANDS.includes(normalizedSubcommand)) {
368
+ const didYouMean = normalizedSubcommand === "list" || normalizedSubcommand === "ls" ? ["pm list --type Plan", "pm list-all --type Plan"] : void 0;
369
+ throw new PmCliError(`Unknown pm plan subcommand "${subcommand}". Allowed: ${PLAN_SUBCOMMANDS.join(", ")}`, EXIT_CODE.USAGE, didYouMean ? { code: "unknown_subcommand", examples: didYouMean } : void 0);
370
+ }
371
+ const planOptions = { ...options };
372
+ const aliasPairs = [
373
+ ["blocked_by", "blockedBy"],
374
+ ["resume_context", "resumeContext"],
375
+ ["from_search", "fromSearch"],
376
+ ["step", "stepTitle"],
377
+ ["step_title", "stepTitle"],
378
+ ["step_body", "stepBody"],
379
+ ["step_owner", "stepOwner"],
380
+ ["step_status", "stepStatus"],
381
+ ["step_evidence", "stepEvidence"],
382
+ ["step_blocked_reason", "stepBlockedReason"],
383
+ ["step_replacement", "stepReplacement"],
384
+ ["depends_on", "dependsOn"],
385
+ ["link_kind", "linkKind"],
386
+ ["link_note", "linkNote"],
387
+ ["promote_to_item_dep", "promoteToItemDep"],
388
+ ["allow_multiple_active", "allowMultipleActive"],
389
+ ["decision_text", "decisionText"],
390
+ ["decision_rationale", "decisionRationale"],
391
+ ["decision_evidence", "decisionEvidence"],
392
+ ["discovery_text", "discoveryText"],
393
+ ["validation_text", "validationText"],
394
+ ["validation_command", "validationCommand"],
395
+ ["validation_expected", "validationExpected"],
396
+ ["materialize_type", "materializeType"],
397
+ ["materialize_parent", "materializeParent"],
398
+ ["materialize_tags", "materializeTags"]
399
+ ];
400
+ for (const [snake, camel] of aliasPairs) {
401
+ if (planOptions[snake] !== void 0 && planOptions[camel] === void 0) {
402
+ planOptions[camel] = planOptions[snake];
403
+ }
404
+ }
405
+ let reorderTo;
406
+ if (normalizedSubcommand === "reorder-step" && typeof reorderToken === "string") {
407
+ const parsed = Number.parseInt(reorderToken, 10);
408
+ if (!Number.isFinite(parsed)) {
409
+ throw new PmCliError(`reorder-step requires an integer new order, got "${reorderToken}"`, EXIT_CODE.USAGE);
410
+ }
411
+ reorderTo = parsed;
412
+ }
413
+ let planId = id;
414
+ if (normalizedSubcommand === "create" && typeof id === "string" && id.length > 0 && planOptions.title === void 0) {
415
+ planOptions.title = id;
416
+ planId = void 0;
417
+ }
418
+ const result = await runPlan({
419
+ subcommand: normalizedSubcommand,
420
+ id: planId,
421
+ stepRef,
422
+ reorderTo,
423
+ options: planOptions,
424
+ global: globalOptions
425
+ });
426
+ await invalidateSearchCachesForMutation(globalOptions, result);
427
+ printResult(result, globalOptions);
428
+ if (globalOptions.profile) {
429
+ printError(`profile:command=plan took_ms=${Date.now() - startedAt}`);
430
+ }
431
+ });
432
+ void planCommand;
433
+ program.command("history-redact").argument("<id>", "Item id").option("--literal <value>", "Literal string to redact (repeatable)", collect).option("--regex <value>", "Regex pattern to redact (repeatable; accepts /pattern/flags or raw pattern)", collect).option("--replacement <value>", 'Replacement string (default: "[redacted]")').option("--dry-run", "Preview redaction impact without writing item/history files").option("--author <value>", "Mutation author").option("--message <value>", "Audit history message for the redaction marker entry").option("--force", "Force ownership/lock override").description("Redact sensitive literals/patterns from an item history stream and recompute hashes.").action(async (id, options, command) => {
434
+ const globalOptions = getGlobalOptions(command);
435
+ const startedAt = Date.now();
436
+ const { runHistoryRedact } = await loadMutationCommandsModule();
437
+ const literal = Array.isArray(options.literal) ? options.literal : void 0;
438
+ const regex = Array.isArray(options.regex) ? options.regex : void 0;
439
+ const result = await runHistoryRedact(id, {
440
+ literal,
441
+ regex,
442
+ replacement: typeof options.replacement === "string" ? options.replacement : void 0,
443
+ dryRun: options.dryRun === true,
444
+ author: typeof options.author === "string" ? options.author : void 0,
445
+ message: typeof options.message === "string" ? options.message : void 0,
446
+ force: Boolean(options.force)
447
+ }, globalOptions);
448
+ if (result.changed && !result.dry_run) {
449
+ await invalidateSearchCachesForMutation(globalOptions, result);
450
+ }
451
+ printResult(result, globalOptions);
452
+ if (globalOptions.profile) {
453
+ printError(`profile:command=history-redact took_ms=${Date.now() - startedAt}`);
454
+ }
455
+ });
456
+ program.command("history-repair").argument("<id>", "Item id").option("--dry-run", "Preview the re-anchor impact without writing the history file").option("--author <value>", "Mutation author").option("--message <value>", "Audit history message for the repair marker entry").option("--force", "Force ownership/lock override").description("Re-anchor a drifted item history chain (recompute hashes, reconcile with the on-disk item) and record an audit marker.").action(async (id, options, command) => {
457
+ const globalOptions = getGlobalOptions(command);
458
+ const startedAt = Date.now();
459
+ const { runHistoryRepair } = await loadMutationCommandsModule();
460
+ const result = await runHistoryRepair(id, {
461
+ dryRun: options.dryRun === true,
462
+ author: typeof options.author === "string" ? options.author : void 0,
463
+ message: typeof options.message === "string" ? options.message : void 0,
464
+ force: Boolean(options.force)
465
+ }, globalOptions);
466
+ printResult(result, globalOptions);
467
+ if (globalOptions.profile) {
468
+ printError(`profile:command=history-repair took_ms=${Date.now() - startedAt}`);
469
+ }
470
+ });
471
+ const schemaCommand = program.command("schema").argument("[subcommand]", "Schema subcommand: add-type, or a custom item type name shorthand").argument("[name]", "Custom item type name (for add-type)").option("--description <text>", "Human description for the custom item type").option("--default-status <status>", "Default status hint recorded for the custom item type").option("--folder <dir>", "Storage folder for items of this custom type").option("--alias <name>", "Alias for the custom type (repeatable, csv-friendly)", collect).option("--author <value>", "Mutation author").option("--force", "Force ownership/lock override").description("Manage config-driven runtime schema: register custom item types into .agents/pm/schema/types.json.");
472
+ addHiddenOption(schemaCommand, "--default_status <status>", "Alias for --default-status", false);
473
+ schemaCommand.action(async (subcommand, name, options, command) => {
474
+ const globalOptions = getGlobalOptions(command);
475
+ const startedAt = Date.now();
476
+ const { runSchemaAddType, formatSchemaAddTypeHuman, SCHEMA_SUBCOMMANDS } = await loadMutationCommandsModule();
477
+ let normalizedSubcommand = (subcommand ?? "").trim().toLowerCase();
478
+ let typeName = name;
479
+ if (!normalizedSubcommand) {
480
+ throw new PmCliError(`pm schema requires a subcommand. Allowed: ${SCHEMA_SUBCOMMANDS.join(", ")}`, EXIT_CODE.USAGE, {
481
+ code: "missing_required_argument",
482
+ examples: [
483
+ 'pm schema add-type Spike --description "Time-boxed investigation" --default-status open',
484
+ "pm schema add-type Spike --alias spike --alias research"
485
+ ]
486
+ });
487
+ }
488
+ const aliases = typeof options.alias === "string" ? [options.alias] : Array.isArray(options.alias) ? options.alias : void 0;
489
+ const defaultStatus = typeof options.defaultStatus === "string" ? options.defaultStatus : typeof options.default_status === "string" ? options.default_status : void 0;
490
+ const usedAddTypeOption = typeof options.description === "string" || typeof defaultStatus === "string" || typeof options.folder === "string" || (aliases?.length ?? 0) > 0;
491
+ if (!SCHEMA_SUBCOMMANDS.includes(normalizedSubcommand) && typeName === void 0 && usedAddTypeOption) {
492
+ typeName = subcommand;
493
+ normalizedSubcommand = "add-type";
494
+ }
495
+ if (!SCHEMA_SUBCOMMANDS.includes(normalizedSubcommand)) {
496
+ throw new PmCliError(`Unknown pm schema subcommand "${subcommand}". Allowed: ${SCHEMA_SUBCOMMANDS.join(", ")}`, EXIT_CODE.USAGE, { code: "unknown_subcommand" });
497
+ }
498
+ const result = await runSchemaAddType(typeName, {
499
+ description: typeof options.description === "string" ? options.description : void 0,
500
+ defaultStatus,
501
+ folder: typeof options.folder === "string" ? options.folder : void 0,
502
+ alias: aliases,
503
+ author: typeof options.author === "string" ? options.author : void 0,
504
+ force: Boolean(options.force)
505
+ }, globalOptions);
506
+ if (globalOptions.json === true || globalOptions.defaultOutputFormat === "json") {
507
+ printResult(result, globalOptions);
508
+ } else if (!globalOptions.quiet) {
509
+ writeStdout(`${formatSchemaAddTypeHuman(result)}
510
+ `);
511
+ if (result.warnings.length > 0) {
512
+ printError(`schema add-type warnings: ${formatHookWarnings(result.warnings)}`);
513
+ }
514
+ }
515
+ if (globalOptions.profile) {
516
+ printError(`profile:command=schema took_ms=${Date.now() - startedAt}`);
517
+ }
518
+ });
519
+ program.command("comments").argument("<id>", "Item id").argument("[text]", "Optional comment text shorthand (equivalent to --add)").option("--add <text>", "Add one comment entry (plain text fallback, text=<value>, markdown pairs, or - for stdin; CSV-like key fragments are preserved as plain text unless text is explicit)").option("--stdin", "Read comment text from stdin (supports multiline markdown)").option("--file <path>", "Read comment text from file (supports multiline markdown)").option("--limit <n>", "Return only latest n comments").option("--author [value]", "Comment author (optional; falls back to PM_AUTHOR/settings)").option("--message <value>", "History message").option("--allow-audit-comment", "Allow non-owner append-only comment audits without requiring --force").option("--force", "Force ownership override").description("List or add comments for an item.").action(async (id, text, options, command) => {
520
+ const globalOptions = getGlobalOptions(command);
521
+ const startedAt = Date.now();
522
+ const addFromOption = typeof options.add === "string" ? options.add : void 0;
523
+ const addFromPositional = typeof text === "string" ? text : void 0;
524
+ const readFromStdin = options.stdin === true;
525
+ const readFromFile = typeof options.file === "string" ? options.file : void 0;
526
+ const sourceCount = Number(addFromOption !== void 0) + Number(addFromPositional !== void 0) + Number(readFromStdin) + Number(readFromFile !== void 0);
527
+ if (sourceCount > 1) {
528
+ if (addFromOption !== void 0 && addFromPositional !== void 0 && !readFromStdin && readFromFile === void 0) {
529
+ throw new PmCliError("Specify comment text either as positional [text] or with --add, not both", EXIT_CODE.USAGE);
530
+ }
531
+ throw new PmCliError("Specify comment text with exactly one source: positional [text], --add, --stdin, or --file", EXIT_CODE.USAGE);
532
+ }
533
+ const add = addFromOption ?? addFromPositional;
534
+ const { runComments } = await loadMutationCommandsModule();
535
+ const result = await runComments(id, {
536
+ add,
537
+ stdin: readFromStdin,
538
+ file: readFromFile,
539
+ limit: typeof options.limit === "string" ? options.limit : void 0,
540
+ author: typeof options.author === "string" ? options.author : void 0,
541
+ message: typeof options.message === "string" ? options.message : void 0,
542
+ allowAuditComment: Boolean(options.allowAuditComment),
543
+ force: Boolean(options.force)
544
+ }, globalOptions);
545
+ if (typeof add === "string" || readFromStdin || readFromFile !== void 0) {
546
+ await invalidateSearchCachesForMutation(globalOptions, result);
547
+ }
548
+ printResult(result, globalOptions);
549
+ if (globalOptions.profile) {
550
+ printError(`profile:command=comments took_ms=${Date.now() - startedAt}`);
551
+ }
552
+ });
553
+ program.command("notes").argument("<id>", "Item id").argument("[text]", "Optional note text shorthand (equivalent to --add; use - for stdin)").option("--add <text>", "Add one note entry (plain text fallback, text=<value>, markdown pairs, or - for stdin; CSV-like key fragments are preserved as plain text unless text is explicit)").option("--limit <n>", "Return only latest n notes").option("--author [value]", "Note author (optional; falls back to PM_AUTHOR/settings)").option("--message <value>", "History message").option("--allow-audit-note", "Allow non-owner append-only note audits without requiring --force").option("--allow-audit-comment", "Backward-compatible alias for --allow-audit-note").option("--force", "Force ownership override").description("List or add notes for an item.").action(async (id, text, options, command) => {
554
+ const globalOptions = getGlobalOptions(command);
555
+ const startedAt = Date.now();
556
+ const addFromOption = typeof options.add === "string" ? options.add : void 0;
557
+ const addFromPositional = typeof text === "string" ? text : void 0;
558
+ if (addFromOption !== void 0 && addFromPositional !== void 0) {
559
+ throw new PmCliError("Specify note text either as positional [text] or with --add, not both", EXIT_CODE.USAGE);
560
+ }
561
+ const add = addFromOption ?? addFromPositional;
562
+ const { runNotes } = await loadMutationCommandsModule();
563
+ const result = await runNotes(id, {
564
+ add,
565
+ limit: typeof options.limit === "string" ? options.limit : void 0,
566
+ author: typeof options.author === "string" ? options.author : void 0,
567
+ message: typeof options.message === "string" ? options.message : void 0,
568
+ allowAuditComment: Boolean(options.allowAuditNote || options.allowAuditComment),
569
+ force: Boolean(options.force)
570
+ }, globalOptions);
571
+ if (typeof add === "string") {
572
+ await invalidateSearchCachesForMutation(globalOptions, result);
573
+ }
574
+ printResult(result, globalOptions);
575
+ if (globalOptions.profile) {
576
+ printError(`profile:command=notes took_ms=${Date.now() - startedAt}`);
577
+ }
578
+ });
579
+ program.command("learnings").argument("<id>", "Item id").argument("[text]", "Optional learning text shorthand (equivalent to --add; use - for stdin)").option("--add <text>", "Add one learning entry (plain text fallback, text=<value>, markdown pairs, or - for stdin; CSV-like key fragments are preserved as plain text unless text is explicit)").option("--limit <n>", "Return only latest n learnings").option("--author [value]", "Learning author (optional; falls back to PM_AUTHOR/settings)").option("--message <value>", "History message").option("--allow-audit-learning", "Allow non-owner append-only learning audits without requiring --force").option("--allow-audit-comment", "Backward-compatible alias for --allow-audit-learning").option("--force", "Force ownership override").description("List or add learnings for an item.").action(async (id, text, options, command) => {
580
+ const globalOptions = getGlobalOptions(command);
581
+ const startedAt = Date.now();
582
+ const addFromOption = typeof options.add === "string" ? options.add : void 0;
583
+ const addFromPositional = typeof text === "string" ? text : void 0;
584
+ if (addFromOption !== void 0 && addFromPositional !== void 0) {
585
+ throw new PmCliError("Specify learning text either as positional [text] or with --add, not both", EXIT_CODE.USAGE);
586
+ }
587
+ const add = addFromOption ?? addFromPositional;
588
+ const { runLearnings } = await loadMutationCommandsModule();
589
+ const result = await runLearnings(id, {
590
+ add,
591
+ limit: typeof options.limit === "string" ? options.limit : void 0,
592
+ author: typeof options.author === "string" ? options.author : void 0,
593
+ message: typeof options.message === "string" ? options.message : void 0,
594
+ allowAuditComment: Boolean(options.allowAuditLearning || options.allowAuditComment),
595
+ force: Boolean(options.force)
596
+ }, globalOptions);
597
+ if (typeof add === "string") {
598
+ await invalidateSearchCachesForMutation(globalOptions, result);
599
+ }
600
+ printResult(result, globalOptions);
601
+ if (globalOptions.profile) {
602
+ printError(`profile:command=learnings took_ms=${Date.now() - startedAt}`);
603
+ }
604
+ });
605
+ const filesCommand = program.command("files").description("Manage files linked to an item.");
606
+ filesCommand.argument("<id>", "Item id").option("--add <value>", "Add linked file entry (CSV/markdown pairs or - for stdin)", collect).option("--add-glob <value>", "Add linked file entries from a glob (plain glob or pattern=<glob>,scope=<scope>,note=<text>; repeatable)", collect).option("--remove <value>", "Remove linked file by path (path=<value>, path:<value>, plain path, or - for stdin)", collect).option("--migrate <value>", "Migrate linked file paths in-place (from=<prefix>,to=<prefix>; repeatable)", collect).option("--list", "List linked files without mutating").option("--append-stable", "Preserve existing linked-file order and append new links without full-array resorting").option("--validate-paths", "Validate linked file paths for existence and file shape").option("--audit", "Audit linked file usage across all items for this item's linked paths").option("--author <value>", "Mutation author").option("--message <value>", "History message").option("--force", "Force ownership override").action(async (id, options, command) => {
607
+ const globalOptions = getGlobalOptions(command);
608
+ const startedAt = Date.now();
609
+ const addValues = Array.isArray(options.add) ? options.add : [];
610
+ const addGlobValues = Array.isArray(options.addGlob) ? options.addGlob : [];
611
+ const removeValues = Array.isArray(options.remove) ? options.remove : [];
612
+ const migrateValues = Array.isArray(options.migrate) ? options.migrate : [];
613
+ const { runFiles } = await loadMutationCommandsModule();
614
+ const result = await runFiles(id, {
615
+ add: addValues,
616
+ addGlob: addGlobValues,
617
+ remove: removeValues,
618
+ migrate: migrateValues,
619
+ list: Boolean(options.list),
620
+ appendStable: Boolean(options.appendStable),
621
+ validatePaths: Boolean(options.validatePaths),
622
+ audit: Boolean(options.audit),
623
+ author: typeof options.author === "string" ? options.author : void 0,
624
+ message: typeof options.message === "string" ? options.message : void 0,
625
+ force: Boolean(options.force)
626
+ }, globalOptions);
627
+ if (addValues.length > 0 || addGlobValues.length > 0 || removeValues.length > 0 || migrateValues.length > 0) {
628
+ await invalidateSearchCachesForMutation(globalOptions, result);
629
+ }
630
+ printResult(result, globalOptions);
631
+ if (globalOptions.profile) {
632
+ printError(`profile:command=files took_ms=${Date.now() - startedAt}`);
633
+ }
634
+ });
635
+ filesCommand.command("discover").argument("<id>", "Item id").option("--apply", "Add discovered missing files to the item").option("--note <value>", "Note to attach to discovered file links").option("--append-stable", "Preserve existing linked-file order and append discovered links without full-array resorting").option("--author <value>", "Mutation author").option("--message <value>", "History message").option("--force", "Force ownership override").description("Discover existing file paths referenced in item text and optionally link missing files.").action(async (id, options, command) => {
636
+ const globalOptions = getGlobalOptions(command);
637
+ const startedAt = Date.now();
638
+ const { runFilesDiscover } = await loadMutationCommandsModule();
639
+ const result = await runFilesDiscover(id, {
640
+ apply: Boolean(options.apply),
641
+ note: typeof options.note === "string" ? options.note : void 0,
642
+ appendStable: Boolean(options.appendStable),
643
+ author: typeof options.author === "string" ? options.author : void 0,
644
+ message: typeof options.message === "string" ? options.message : void 0,
645
+ force: Boolean(options.force)
646
+ }, globalOptions);
647
+ if (result.changed) {
648
+ await invalidateSearchCachesForMutation(globalOptions, result);
649
+ }
650
+ printResult(result, globalOptions);
651
+ if (globalOptions.profile) {
652
+ printError(`profile:command=files.discover took_ms=${Date.now() - startedAt}`);
653
+ }
654
+ });
655
+ program.command("docs").argument("<id>", "Item id").option("--add <value>", "Add linked doc entry (CSV/markdown pairs or - for stdin)", collect).option("--add-glob <value>", "Add linked doc entries from a glob (plain glob or pattern=<glob>,scope=<scope>,note=<text>; repeatable)", collect).option("--remove <value>", "Remove linked doc by path (path=<value>, path:<value>, plain path, or - for stdin)", collect).option("--migrate <value>", "Migrate linked doc paths in-place (from=<prefix>,to=<prefix>; repeatable)", collect).option("--list", "List linked docs without mutating").option("--validate-paths", "Validate linked doc paths for existence and file shape").option("--audit", "Audit linked doc usage across all items for this item's linked paths").option("--author <value>", "Mutation author").option("--message <value>", "History message").option("--force", "Force ownership override").description("Manage docs linked to an item.").action(async (id, options, command) => {
656
+ const globalOptions = getGlobalOptions(command);
657
+ const startedAt = Date.now();
658
+ const addValues = Array.isArray(options.add) ? options.add : [];
659
+ const addGlobValues = Array.isArray(options.addGlob) ? options.addGlob : [];
660
+ const removeValues = Array.isArray(options.remove) ? options.remove : [];
661
+ const migrateValues = Array.isArray(options.migrate) ? options.migrate : [];
662
+ const { runDocs } = await loadMutationCommandsModule();
663
+ const result = await runDocs(id, {
664
+ add: addValues,
665
+ addGlob: addGlobValues,
666
+ remove: removeValues,
667
+ migrate: migrateValues,
668
+ list: Boolean(options.list),
669
+ validatePaths: Boolean(options.validatePaths),
670
+ audit: Boolean(options.audit),
671
+ author: typeof options.author === "string" ? options.author : void 0,
672
+ message: typeof options.message === "string" ? options.message : void 0,
673
+ force: Boolean(options.force)
674
+ }, globalOptions);
675
+ if (addValues.length > 0 || addGlobValues.length > 0 || removeValues.length > 0 || migrateValues.length > 0) {
676
+ await invalidateSearchCachesForMutation(globalOptions, result);
677
+ }
678
+ printResult(result, globalOptions);
679
+ if (globalOptions.profile) {
680
+ printError(`profile:command=docs took_ms=${Date.now() - startedAt}`);
681
+ }
682
+ });
683
+ program.command("deps").argument("<id>", "Item id").option("--format <value>", "Output format (tree or graph)", "tree").option("--max-depth <value>", "Maximum dependency traversal depth (0 keeps only the root)").option("--collapse <value>", "Collapse mode (none or repeated)", "none").option("--summary", "Return counts only without full tree/graph payload").description("Show dependency relationships for an item.").action(async (id, options, command) => {
684
+ const globalOptions = getGlobalOptions(command);
685
+ const startedAt = Date.now();
686
+ const { runDeps } = await loadMutationCommandsModule();
687
+ const result = await runDeps(id, {
688
+ format: typeof options.format === "string" ? options.format : void 0,
689
+ maxDepth: typeof options.maxDepth === "string" ? options.maxDepth : void 0,
690
+ collapse: typeof options.collapse === "string" ? options.collapse : void 0,
691
+ summary: options.summary === true
692
+ }, globalOptions);
693
+ printResult(result, globalOptions);
694
+ if (globalOptions.profile) {
695
+ printError(`profile:command=deps took_ms=${Date.now() - startedAt}`);
696
+ }
697
+ });
698
+ }
699
+ export {
700
+ registerMutationCommands
701
+ };
702
+ //# sourceMappingURL=register-mutation-RSZNPSGI.js.map