@unbrained/pm-cli 2026.5.18 → 2026.5.24

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 (225) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +2 -1
  3. package/dist/cli/commander-usage.js +16 -2
  4. package/dist/cli/commander-usage.js.map +1 -1
  5. package/dist/cli/commands/annotation-command.d.ts +49 -0
  6. package/dist/cli/commands/annotation-command.js +135 -0
  7. package/dist/cli/commands/annotation-command.js.map +1 -0
  8. package/dist/cli/commands/append.js +3 -7
  9. package/dist/cli/commands/append.js.map +1 -1
  10. package/dist/cli/commands/calendar.js +3 -6
  11. package/dist/cli/commands/calendar.js.map +1 -1
  12. package/dist/cli/commands/claim.js +12 -22
  13. package/dist/cli/commands/claim.js.map +1 -1
  14. package/dist/cli/commands/close.js +61 -9
  15. package/dist/cli/commands/close.js.map +1 -1
  16. package/dist/cli/commands/comments.d.ts +5 -0
  17. package/dist/cli/commands/comments.js +27 -117
  18. package/dist/cli/commands/comments.js.map +1 -1
  19. package/dist/cli/commands/completion.js +102 -15
  20. package/dist/cli/commands/completion.js.map +1 -1
  21. package/dist/cli/commands/context.js +4 -10
  22. package/dist/cli/commands/context.js.map +1 -1
  23. package/dist/cli/commands/contracts.js +168 -36
  24. package/dist/cli/commands/contracts.js.map +1 -1
  25. package/dist/cli/commands/create.js +49 -44
  26. package/dist/cli/commands/create.js.map +1 -1
  27. package/dist/cli/commands/dedupe-audit.js +7 -4
  28. package/dist/cli/commands/dedupe-audit.js.map +1 -1
  29. package/dist/cli/commands/delete.d.ts +3 -0
  30. package/dist/cli/commands/delete.js +9 -8
  31. package/dist/cli/commands/delete.js.map +1 -1
  32. package/dist/cli/commands/docs.d.ts +1 -0
  33. package/dist/cli/commands/docs.js +4 -8
  34. package/dist/cli/commands/docs.js.map +1 -1
  35. package/dist/cli/commands/event-validation-messages.d.ts +3 -0
  36. package/dist/cli/commands/event-validation-messages.js +44 -0
  37. package/dist/cli/commands/event-validation-messages.js.map +1 -0
  38. package/dist/cli/commands/extension.d.ts +1 -0
  39. package/dist/cli/commands/extension.js +138 -21
  40. package/dist/cli/commands/extension.js.map +1 -1
  41. package/dist/cli/commands/files.js +6 -13
  42. package/dist/cli/commands/files.js.map +1 -1
  43. package/dist/cli/commands/gc.js +17 -4
  44. package/dist/cli/commands/gc.js.map +1 -1
  45. package/dist/cli/commands/get.d.ts +3 -2
  46. package/dist/cli/commands/get.js +50 -8
  47. package/dist/cli/commands/get.js.map +1 -1
  48. package/dist/cli/commands/health.d.ts +10 -0
  49. package/dist/cli/commands/health.js +254 -75
  50. package/dist/cli/commands/health.js.map +1 -1
  51. package/dist/cli/commands/history-redact.d.ts +8 -0
  52. package/dist/cli/commands/history-redact.js +14 -97
  53. package/dist/cli/commands/history-redact.js.map +1 -1
  54. package/dist/cli/commands/history-repair.d.ts +33 -0
  55. package/dist/cli/commands/history-repair.js +166 -0
  56. package/dist/cli/commands/history-repair.js.map +1 -0
  57. package/dist/cli/commands/history.d.ts +4 -4
  58. package/dist/cli/commands/history.js +10 -88
  59. package/dist/cli/commands/history.js.map +1 -1
  60. package/dist/cli/commands/index.d.ts +3 -1
  61. package/dist/cli/commands/index.js +5 -3
  62. package/dist/cli/commands/index.js.map +1 -1
  63. package/dist/cli/commands/init.d.ts +28 -0
  64. package/dist/cli/commands/init.js +23 -2
  65. package/dist/cli/commands/init.js.map +1 -1
  66. package/dist/cli/commands/learnings.js +20 -119
  67. package/dist/cli/commands/learnings.js.map +1 -1
  68. package/dist/cli/commands/linked-test-entry.d.ts +3 -0
  69. package/dist/cli/commands/linked-test-entry.js +62 -0
  70. package/dist/cli/commands/linked-test-entry.js.map +1 -0
  71. package/dist/cli/commands/list.js +32 -22
  72. package/dist/cli/commands/list.js.map +1 -1
  73. package/dist/cli/commands/notes.js +20 -119
  74. package/dist/cli/commands/notes.js.map +1 -1
  75. package/dist/cli/commands/plan.d.ts +3 -0
  76. package/dist/cli/commands/plan.js +184 -22
  77. package/dist/cli/commands/plan.js.map +1 -1
  78. package/dist/cli/commands/restore.js +7 -50
  79. package/dist/cli/commands/restore.js.map +1 -1
  80. package/dist/cli/commands/schema.d.ts +31 -0
  81. package/dist/cli/commands/schema.js +98 -0
  82. package/dist/cli/commands/schema.js.map +1 -0
  83. package/dist/cli/commands/search.js +151 -40
  84. package/dist/cli/commands/search.js.map +1 -1
  85. package/dist/cli/commands/templates.d.ts +4 -0
  86. package/dist/cli/commands/templates.js +89 -17
  87. package/dist/cli/commands/templates.js.map +1 -1
  88. package/dist/cli/commands/test-all.js +4 -8
  89. package/dist/cli/commands/test-all.js.map +1 -1
  90. package/dist/cli/commands/test.d.ts +1 -0
  91. package/dist/cli/commands/test.js +7 -10
  92. package/dist/cli/commands/test.js.map +1 -1
  93. package/dist/cli/commands/update-many.js +4 -8
  94. package/dist/cli/commands/update-many.js.map +1 -1
  95. package/dist/cli/commands/update.js +109 -51
  96. package/dist/cli/commands/update.js.map +1 -1
  97. package/dist/cli/commands/validate.d.ts +3 -1
  98. package/dist/cli/commands/validate.js +23 -71
  99. package/dist/cli/commands/validate.js.map +1 -1
  100. package/dist/cli/error-guidance.js +96 -6
  101. package/dist/cli/error-guidance.js.map +1 -1
  102. package/dist/cli/extension-command-help.d.ts +0 -1
  103. package/dist/cli/extension-command-help.js +2 -13
  104. package/dist/cli/extension-command-help.js.map +1 -1
  105. package/dist/cli/extension-command-options.d.ts +1 -0
  106. package/dist/cli/extension-command-options.js +106 -7
  107. package/dist/cli/extension-command-options.js.map +1 -1
  108. package/dist/cli/help-content.d.ts +0 -1
  109. package/dist/cli/help-content.js +13 -9
  110. package/dist/cli/help-content.js.map +1 -1
  111. package/dist/cli/help-json-payload.d.ts +1 -0
  112. package/dist/cli/help-json-payload.js +33 -3
  113. package/dist/cli/help-json-payload.js.map +1 -1
  114. package/dist/cli/main.js +35 -29
  115. package/dist/cli/main.js.map +1 -1
  116. package/dist/cli/register-list-query.d.ts +1 -1
  117. package/dist/cli/register-list-query.js +40 -17
  118. package/dist/cli/register-list-query.js.map +1 -1
  119. package/dist/cli/register-mutation.d.ts +1 -1
  120. package/dist/cli/register-mutation.js +232 -64
  121. package/dist/cli/register-mutation.js.map +1 -1
  122. package/dist/cli/register-operations.js +16 -11
  123. package/dist/cli/register-operations.js.map +1 -1
  124. package/dist/cli/register-setup.js +26 -14
  125. package/dist/cli/register-setup.js.map +1 -1
  126. package/dist/cli/registration-helpers.d.ts +0 -2
  127. package/dist/cli/registration-helpers.js +13 -40
  128. package/dist/cli/registration-helpers.js.map +1 -1
  129. package/dist/cli.js +23 -3
  130. package/dist/cli.js.map +1 -1
  131. package/dist/core/extensions/index.d.ts +0 -1
  132. package/dist/core/extensions/index.js +2 -14
  133. package/dist/core/extensions/index.js.map +1 -1
  134. package/dist/core/extensions/loader.js +3 -9
  135. package/dist/core/extensions/loader.js.map +1 -1
  136. package/dist/core/fs/path-utils.d.ts +1 -0
  137. package/dist/core/fs/path-utils.js +12 -0
  138. package/dist/core/fs/path-utils.js.map +1 -0
  139. package/dist/core/history/drift-scan.d.ts +11 -0
  140. package/dist/core/history/drift-scan.js +67 -0
  141. package/dist/core/history/drift-scan.js.map +1 -0
  142. package/dist/core/history/replay.d.ts +82 -0
  143. package/dist/core/history/replay.js +249 -0
  144. package/dist/core/history/replay.js.map +1 -0
  145. package/dist/core/item/item-format.js +11 -8
  146. package/dist/core/item/item-format.js.map +1 -1
  147. package/dist/core/item/item-type-definition.d.ts +52 -0
  148. package/dist/core/item/item-type-definition.js +123 -0
  149. package/dist/core/item/item-type-definition.js.map +1 -0
  150. package/dist/core/item/parse.js +3 -2
  151. package/dist/core/item/parse.js.map +1 -1
  152. package/dist/core/item/priority.d.ts +23 -0
  153. package/dist/core/item/priority.js +55 -0
  154. package/dist/core/item/priority.js.map +1 -0
  155. package/dist/core/item/status.d.ts +14 -1
  156. package/dist/core/item/status.js +22 -2
  157. package/dist/core/item/status.js.map +1 -1
  158. package/dist/core/item/toon-decode.d.ts +19 -0
  159. package/dist/core/item/toon-decode.js +69 -0
  160. package/dist/core/item/toon-decode.js.map +1 -0
  161. package/dist/core/item/type-registry.js +13 -84
  162. package/dist/core/item/type-registry.js.map +1 -1
  163. package/dist/core/packages/manifest.js +3 -9
  164. package/dist/core/packages/manifest.js.map +1 -1
  165. package/dist/core/schema/item-types-file.d.ts +85 -0
  166. package/dist/core/schema/item-types-file.js +243 -0
  167. package/dist/core/schema/item-types-file.js.map +1 -0
  168. package/dist/core/schema/runtime-schema.d.ts +2 -1
  169. package/dist/core/schema/runtime-schema.js +11 -9
  170. package/dist/core/schema/runtime-schema.js.map +1 -1
  171. package/dist/core/search/semantic-defaults.js +3 -3
  172. package/dist/core/search/semantic-defaults.js.map +1 -1
  173. package/dist/core/shared/author.d.ts +1 -0
  174. package/dist/core/shared/author.js +9 -0
  175. package/dist/core/shared/author.js.map +1 -0
  176. package/dist/core/shared/lazy-module.d.ts +1 -0
  177. package/dist/core/shared/lazy-module.js +11 -0
  178. package/dist/core/shared/lazy-module.js.map +1 -0
  179. package/dist/core/shared/option-alias-visibility.d.ts +44 -0
  180. package/dist/core/shared/option-alias-visibility.js +76 -0
  181. package/dist/core/shared/option-alias-visibility.js.map +1 -0
  182. package/dist/core/shared/text-normalization.d.ts +0 -1
  183. package/dist/core/shared/text-normalization.js +2 -5
  184. package/dist/core/shared/text-normalization.js.map +1 -1
  185. package/dist/core/store/item-store.d.ts +2 -0
  186. package/dist/core/store/item-store.js +70 -39
  187. package/dist/core/store/item-store.js.map +1 -1
  188. package/dist/core/store/settings-validator.d.ts +106 -0
  189. package/dist/core/store/settings-validator.js +279 -0
  190. package/dist/core/store/settings-validator.js.map +1 -0
  191. package/dist/core/store/settings.js +6 -343
  192. package/dist/core/store/settings.js.map +1 -1
  193. package/dist/core/telemetry/runtime.js +5 -3
  194. package/dist/core/telemetry/runtime.js.map +1 -1
  195. package/dist/mcp/server.js +64 -13
  196. package/dist/mcp/server.js.map +1 -1
  197. package/dist/sdk/cli-contracts.d.ts +9 -2
  198. package/dist/sdk/cli-contracts.js +204 -13
  199. package/dist/sdk/cli-contracts.js.map +1 -1
  200. package/dist/sdk/runtime.d.ts +25 -1
  201. package/dist/sdk/runtime.js +46 -3
  202. package/dist/sdk/runtime.js.map +1 -1
  203. package/dist/types.d.ts +6 -0
  204. package/dist/types.js +10 -2
  205. package/dist/types.js.map +1 -1
  206. package/docs/AGENT_GUIDE.md +7 -1
  207. package/docs/ARCHITECTURE.md +1 -1
  208. package/docs/COMMANDS.md +39 -6
  209. package/docs/CONFIGURATION.md +1 -1
  210. package/docs/RELEASING.md +11 -7
  211. package/docs/SDK.md +11 -2
  212. package/package.json +12 -11
  213. package/packages/pm-calendar/README.md +3 -1
  214. package/packages/pm-calendar/extensions/calendar/index.js +21 -2
  215. package/packages/pm-calendar/extensions/calendar/index.ts +21 -2
  216. package/packages/pm-search-advanced/README.md +8 -0
  217. package/packages/pm-search-advanced/extensions/search-advanced/index.js +74 -0
  218. package/packages/pm-search-advanced/extensions/search-advanced/index.ts +74 -0
  219. package/packages/pm-search-advanced/extensions/search-advanced/runtime.js +67 -9
  220. package/packages/pm-search-advanced/extensions/search-advanced/runtime.ts +67 -9
  221. package/packages/pm-templates/extensions/templates/runtime.js +11 -202
  222. package/packages/pm-templates/extensions/templates/runtime.ts +38 -230
  223. package/dist/core/output/command-aware.d.ts +0 -1
  224. package/dist/core/output/command-aware.js +0 -397
  225. package/dist/core/output/command-aware.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="dc0f1970-8a30-56c5-827f-573784a38d54")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="478936e5-660a-5f89-b15d-93b37468c7ed")}catch(e){}}();
3
3
  import { EXIT_CODE, SETTINGS_DEFAULTS } from "../../core/shared/constants.js";
4
4
  import { PmCliError } from "../../core/shared/errors.js";
5
5
  import { activateExtensions, getActiveExtensionRegistrations, loadExtensions, } from "../../core/extensions/index.js";
@@ -8,7 +8,7 @@ import { commandOptionFlagLabel, resolveCommandOptionPolicyState, resolveItemTyp
8
8
  import { resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, } from "../../core/schema/runtime-schema.js";
9
9
  import { getSettingsPath, resolvePmRoot } from "../../core/store/paths.js";
10
10
  import { readSettings } from "../../core/store/settings.js";
11
- import { ACTIVITY_COMMANDER_STRING_OPTION_CONTRACTS, ACTIVITY_FLAG_CONTRACTS, AGGREGATE_FLAG_CONTRACTS, APPEND_FLAG_CONTRACTS, CALENDAR_COMMANDER_STRING_OPTION_CONTRACTS, CALENDAR_FLAG_CONTRACTS, CLAIM_FLAG_CONTRACTS, CLOSE_TASK_FLAG_CONTRACTS, COMMENTS_FLAG_CONTRACTS, COMMENTS_AUDIT_FLAG_CONTRACTS, CLOSE_FLAG_CONTRACTS, COMPLETION_FLAG_CONTRACTS, CONFIG_FLAG_CONTRACTS, CONTRACTS_FLAG_CONTRACTS, CONTEXT_COMMANDER_STRING_OPTION_CONTRACTS, CONTEXT_FLAG_CONTRACTS, CREATE_COMMANDER_REPEATABLE_OPTION_CONTRACTS, CREATE_COMMANDER_STRING_OPTION_CONTRACTS, CREATE_FLAG_CONTRACTS, DELETE_FLAG_CONTRACTS, DEPS_FLAG_CONTRACTS, DEDUPE_AUDIT_FLAG_CONTRACTS, DOCS_FLAG_CONTRACTS, EXTENSION_FLAG_CONTRACTS, FILES_FLAG_CONTRACTS, GC_FLAG_CONTRACTS, GET_FLAG_CONTRACTS, GUIDE_FLAG_CONTRACTS, GLOBAL_FLAG_CONTRACTS, HEALTH_FLAG_CONTRACTS, HISTORY_FLAG_CONTRACTS, HISTORY_REDACT_FLAG_CONTRACTS, INSTALL_FLAG_CONTRACTS, INIT_FLAG_CONTRACTS, LEARNINGS_FLAG_CONTRACTS, LIST_COMMANDER_STRING_OPTION_CONTRACTS, LIST_FILTER_FLAG_CONTRACTS, NORMALIZE_FLAG_CONTRACTS, NOTES_FLAG_CONTRACTS, PM_EXTENSION_CAPABILITY_CONTRACTS, PM_EXTENSION_POLICY_MODE_CONTRACTS, PM_EXTENSION_POLICY_SURFACE_CONTRACTS, PM_EXTENSION_SANDBOX_PROFILE_CONTRACTS, PM_EXTENSION_SERVICE_NAME_CONTRACTS, PM_EXTENSION_TRUST_MODE_CONTRACTS, PLAN_FLAG_CONTRACTS, PM_CORE_COMMAND_NAMES, PM_TOOL_ACTIONS, PM_TOOL_PARAMETERS_SCHEMA, REINDEX_FLAG_CONTRACTS, RELEASE_FLAG_CONTRACTS, RESTORE_FLAG_CONTRACTS, SEARCH_COMMANDER_STRING_OPTION_CONTRACTS, SEARCH_FLAG_CONTRACTS, START_TASK_FLAG_CONTRACTS, PAUSE_TASK_FLAG_CONTRACTS, TEST_ALL_FLAG_CONTRACTS, TEST_FLAG_CONTRACTS, TEST_RUNS_FLAG_CONTRACTS, UPDATE_COMMANDER_REPEATABLE_OPTION_CONTRACTS, UPDATE_COMMANDER_STRING_OPTION_CONTRACTS, UPDATE_FLAG_CONTRACTS, UPDATE_MANY_FLAG_CONTRACTS, UPGRADE_FLAG_CONTRACTS, VALIDATE_FLAG_CONTRACTS, compactFlagAliasContracts, } from "../../sdk/cli-contracts.js";
11
+ import { ACTIVITY_COMMANDER_STRING_OPTION_CONTRACTS, ACTIVITY_FLAG_CONTRACTS, AGGREGATE_FLAG_CONTRACTS, APPEND_FLAG_CONTRACTS, CALENDAR_COMMANDER_STRING_OPTION_CONTRACTS, CALENDAR_FLAG_CONTRACTS, CLAIM_FLAG_CONTRACTS, CLOSE_TASK_FLAG_CONTRACTS, COMMENTS_FLAG_CONTRACTS, COMMENTS_AUDIT_FLAG_CONTRACTS, CLOSE_FLAG_CONTRACTS, COMPLETION_FLAG_CONTRACTS, CONFIG_FLAG_CONTRACTS, CONTRACTS_FLAG_CONTRACTS, CONTEXT_COMMANDER_STRING_OPTION_CONTRACTS, CONTEXT_FLAG_CONTRACTS, CREATE_COMMANDER_REPEATABLE_OPTION_CONTRACTS, CREATE_COMMANDER_STRING_OPTION_CONTRACTS, CREATE_FLAG_CONTRACTS, DELETE_FLAG_CONTRACTS, DEPS_FLAG_CONTRACTS, DEDUPE_AUDIT_FLAG_CONTRACTS, DOCS_FLAG_CONTRACTS, EXTENSION_FLAG_CONTRACTS, FILES_FLAG_CONTRACTS, GC_FLAG_CONTRACTS, GET_FLAG_CONTRACTS, GUIDE_FLAG_CONTRACTS, GLOBAL_FLAG_CONTRACTS, HEALTH_FLAG_CONTRACTS, HISTORY_FLAG_CONTRACTS, HISTORY_REDACT_FLAG_CONTRACTS, HISTORY_REPAIR_FLAG_CONTRACTS, INSTALL_FLAG_CONTRACTS, INIT_FLAG_CONTRACTS, LEARNINGS_FLAG_CONTRACTS, LIST_COMMANDER_STRING_OPTION_CONTRACTS, LIST_FILTER_FLAG_CONTRACTS, NORMALIZE_FLAG_CONTRACTS, NOTES_FLAG_CONTRACTS, PM_EXTENSION_CAPABILITY_CONTRACTS, PM_EXTENSION_POLICY_MODE_CONTRACTS, PM_EXTENSION_POLICY_SURFACE_CONTRACTS, PM_EXTENSION_SANDBOX_PROFILE_CONTRACTS, PM_EXTENSION_SERVICE_NAME_CONTRACTS, PM_EXTENSION_TRUST_MODE_CONTRACTS, PLAN_FLAG_CONTRACTS, PM_CORE_COMMAND_NAMES, PM_TOOL_ACTIONS, PM_TOOL_PARAMETERS_SCHEMA, REINDEX_FLAG_CONTRACTS, RELEASE_FLAG_CONTRACTS, RESTORE_FLAG_CONTRACTS, SCHEMA_FLAG_CONTRACTS, SEARCH_COMMANDER_STRING_OPTION_CONTRACTS, SEARCH_FLAG_CONTRACTS, START_TASK_FLAG_CONTRACTS, PAUSE_TASK_FLAG_CONTRACTS, TEST_ALL_FLAG_CONTRACTS, TEST_FLAG_CONTRACTS, TEST_RUNS_FLAG_CONTRACTS, UPDATE_COMMANDER_REPEATABLE_OPTION_CONTRACTS, UPDATE_COMMANDER_STRING_OPTION_CONTRACTS, UPDATE_FLAG_CONTRACTS, UPDATE_MANY_FLAG_CONTRACTS, UPGRADE_FLAG_CONTRACTS, VALIDATE_FLAG_CONTRACTS, compactFlagAliasContracts, } from "../../sdk/cli-contracts.js";
12
12
  const LIST_COMMAND_NAMES = new Set([
13
13
  "list",
14
14
  "list-all",
@@ -57,6 +57,27 @@ const PACKAGE_OWNED_COMMANDS = new Set([
57
57
  "test-runs stop",
58
58
  "test-runs resume",
59
59
  ]);
60
+ const PACKAGE_OWNED_COMMAND_INSTALL_HINTS = new Map([
61
+ ["cal", "calendar"],
62
+ ["calendar", "calendar"],
63
+ ["comments-audit", "governance-audit"],
64
+ ["completion", "guide-shell"],
65
+ ["completion-tags", "guide-shell"],
66
+ ["dedupe-audit", "governance-audit"],
67
+ ["guide", "guide-shell"],
68
+ ["normalize", "governance-audit"],
69
+ ["reindex", "search-advanced"],
70
+ ["templates", "templates"],
71
+ ["templates list", "templates"],
72
+ ["templates save", "templates"],
73
+ ["templates show", "templates"],
74
+ ["test-runs", "linked-test-adapters"],
75
+ ["test-runs list", "linked-test-adapters"],
76
+ ["test-runs status", "linked-test-adapters"],
77
+ ["test-runs logs", "linked-test-adapters"],
78
+ ["test-runs stop", "linked-test-adapters"],
79
+ ["test-runs resume", "linked-test-adapters"],
80
+ ]);
60
81
  const CANONICAL_COMMAND_ALIASES = [
61
82
  {
62
83
  canonical: "context",
@@ -90,11 +111,18 @@ function actionDescriptorMatchesSelectedCommand(descriptor, selectedCommand) {
90
111
  if (descriptor.command_path === null) {
91
112
  return false;
92
113
  }
93
- const commandPath = normalizeCommandPath(descriptor.command_path);
94
- if (commandPath === selectedCommand) {
95
- return true;
96
- }
97
- return commandPath.startsWith(`${selectedCommand} `);
114
+ return splitCommandPathAliases(descriptor.command_path).some((commandPath) => {
115
+ if (commandPath === selectedCommand) {
116
+ return true;
117
+ }
118
+ return commandPath.startsWith(`${selectedCommand} `);
119
+ });
120
+ }
121
+ function splitCommandPathAliases(commandPath) {
122
+ return commandPath
123
+ .split("|")
124
+ .map((entry) => normalizeCommandPath(entry))
125
+ .filter((entry) => entry.length > 0);
98
126
  }
99
127
  function resolveScopedCommandsFromActionDescriptors(descriptors, commandCatalog) {
100
128
  const commandSet = new Set(commandCatalog);
@@ -103,18 +131,19 @@ function resolveScopedCommandsFromActionDescriptors(descriptors, commandCatalog)
103
131
  if (!descriptor.command_path) {
104
132
  continue;
105
133
  }
106
- const commandPath = normalizeCommandPath(descriptor.command_path);
107
- const tokens = commandPath.split(" ").filter((entry) => entry.length > 0);
108
- if (tokens.length === 0) {
109
- continue;
110
- }
111
- for (let end = tokens.length; end > 0; end -= 1) {
112
- const candidate = tokens.slice(0, end).join(" ");
113
- if (!commandSet.has(candidate)) {
134
+ for (const commandPath of splitCommandPathAliases(descriptor.command_path)) {
135
+ const tokens = commandPath.split(" ").filter((entry) => entry.length > 0);
136
+ if (tokens.length === 0) {
114
137
  continue;
115
138
  }
116
- scoped.add(candidate);
117
- break;
139
+ for (let end = tokens.length; end > 0; end -= 1) {
140
+ const candidate = tokens.slice(0, end).join(" ");
141
+ if (!commandSet.has(candidate)) {
142
+ continue;
143
+ }
144
+ scoped.add(candidate);
145
+ break;
146
+ }
118
147
  }
119
148
  }
120
149
  return [...scoped].sort((left, right) => left.localeCompare(right));
@@ -224,6 +253,28 @@ function toExtensionFlagContract(definition) {
224
253
  if (normalizedShort && normalizedLong) {
225
254
  contract.short = normalizedShort;
226
255
  }
256
+ const description = toOptionalTrimmedString(definition.description);
257
+ if (description) {
258
+ contract.description = description;
259
+ }
260
+ if (definition.required === true) {
261
+ contract.required = true;
262
+ }
263
+ if (definition.repeatable === true) {
264
+ contract.repeatable = true;
265
+ }
266
+ const valueName = toOptionalTrimmedString(definition.value_name);
267
+ if (valueName) {
268
+ contract.value_name = valueName;
269
+ }
270
+ const rawValueType = [
271
+ toOptionalTrimmedString(definition.value_type),
272
+ toOptionalTrimmedString(definition.type),
273
+ valueName ? "string" : null,
274
+ ].find((candidate) => candidate === "string" || candidate === "number" || candidate === "boolean");
275
+ if (rawValueType) {
276
+ contract.value_type = rawValueType;
277
+ }
227
278
  return contract;
228
279
  }
229
280
  function collectExtensionFlagContractsByCommand(registrations) {
@@ -363,6 +414,10 @@ function extensionSchemaPropertyNameFromFlag(flag) {
363
414
  return cleaned.length > 0 ? cleaned : null;
364
415
  }
365
416
  function buildExtensionActionSchemaBranch(contract) {
417
+ const commands = contract.command
418
+ .split("|")
419
+ .map((command) => command.trim())
420
+ .filter((command) => command.length > 0);
366
421
  const properties = {
367
422
  action: {
368
423
  type: "string",
@@ -398,11 +453,16 @@ function buildExtensionActionSchemaBranch(contract) {
398
453
  if (!propertyName || properties[propertyName] !== undefined) {
399
454
  continue;
400
455
  }
401
- const isBooleanFlag = !flag.flag.includes(" ");
456
+ const valueType = flag.value_type ?? "boolean";
457
+ const schemaType = valueType === "boolean" ? "boolean" : valueType === "number" ? ["number", "string"] : "string";
402
458
  properties[propertyName] = {
403
- type: isBooleanFlag ? ["boolean", "string"] : "string",
404
- description: `Extension option '${flag.flag}' for action '${contract.action}'.`,
459
+ type: flag.repeatable ? "array" : schemaType,
460
+ ...(flag.repeatable ? { items: { type: schemaType } } : {}),
461
+ description: flag.description ?? `Extension option '${flag.flag}' for action '${contract.action}'.`,
405
462
  };
463
+ if (flag.required === true) {
464
+ required.push(propertyName);
465
+ }
406
466
  }
407
467
  return {
408
468
  type: "object",
@@ -410,9 +470,57 @@ function buildExtensionActionSchemaBranch(contract) {
410
470
  required,
411
471
  additionalProperties: true,
412
472
  "x-extension-source": contract.source,
413
- "x-extension-command": contract.command,
473
+ "x-extension-command": commands[0] ?? contract.command,
474
+ "x-extension-commands": commands,
414
475
  };
415
476
  }
477
+ function mergeExtensionFlagContract(existing, incoming) {
478
+ existing.description ??= incoming.description;
479
+ existing.value_name ??= incoming.value_name;
480
+ existing.value_type ??= incoming.value_type;
481
+ if (incoming.required === true) {
482
+ existing.required = true;
483
+ }
484
+ if (incoming.repeatable === true) {
485
+ existing.repeatable = true;
486
+ }
487
+ }
488
+ function mergeExtensionContractsByAction(contracts) {
489
+ const byAction = new Map();
490
+ for (const contract of contracts) {
491
+ const existing = byAction.get(contract.action);
492
+ if (!existing) {
493
+ byAction.set(contract.action, {
494
+ ...contract,
495
+ flags: [...contract.flags],
496
+ examples: [...contract.examples],
497
+ failure_hints: [...contract.failure_hints],
498
+ });
499
+ continue;
500
+ }
501
+ existing.command = [...new Set([existing.command, contract.command])]
502
+ .sort((left, right) => left.localeCompare(right))
503
+ .join("|");
504
+ existing.arguments = existing.arguments.length >= contract.arguments.length ? existing.arguments : contract.arguments;
505
+ const flagKeys = new Set(existing.flags.map((flag) => `${flag.flag}|${flag.short ?? ""}`));
506
+ for (const flag of contract.flags) {
507
+ const key = `${flag.flag}|${flag.short ?? ""}`;
508
+ if (!flagKeys.has(key)) {
509
+ flagKeys.add(key);
510
+ existing.flags.push(flag);
511
+ }
512
+ else {
513
+ const existingFlag = existing.flags.find((candidate) => `${candidate.flag}|${candidate.short ?? ""}` === key);
514
+ if (existingFlag) {
515
+ mergeExtensionFlagContract(existingFlag, flag);
516
+ }
517
+ }
518
+ }
519
+ existing.examples = [...new Set([...existing.examples, ...contract.examples])];
520
+ existing.failure_hints = [...new Set([...existing.failure_hints, ...contract.failure_hints])];
521
+ }
522
+ return [...byAction.values()].sort((left, right) => left.action.localeCompare(right.action));
523
+ }
416
524
  async function resolveRuntimeExtensionActionProbe(global) {
417
525
  const defaultPolicyState = {
418
526
  mode: SETTINGS_DEFAULTS.extensions.policy.mode,
@@ -425,6 +533,7 @@ async function resolveRuntimeExtensionActionProbe(global) {
425
533
  disabledReason: "extensions_disabled",
426
534
  commandDefinitions: [],
427
535
  flagRegistrations: [],
536
+ registrations: null,
428
537
  policyState: defaultPolicyState,
429
538
  };
430
539
  }
@@ -435,6 +544,7 @@ async function resolveRuntimeExtensionActionProbe(global) {
435
544
  disabledReason: null,
436
545
  commandDefinitions: [],
437
546
  flagRegistrations: [],
547
+ registrations: null,
438
548
  policyState: defaultPolicyState,
439
549
  };
440
550
  }
@@ -456,6 +566,7 @@ async function resolveRuntimeExtensionActionProbe(global) {
456
566
  disabledReason: null,
457
567
  commandDefinitions: activationResult.registrations.commands,
458
568
  flagRegistrations: activationResult.registrations.flags,
569
+ registrations: activationResult.registrations,
459
570
  policyState: {
460
571
  mode: loadResult.policy.mode,
461
572
  trust_mode: loadResult.policy.trust_mode,
@@ -469,6 +580,7 @@ async function resolveRuntimeExtensionActionProbe(global) {
469
580
  disabledReason: "extension_runtime_probe_failed",
470
581
  commandDefinitions: [],
471
582
  flagRegistrations: [],
583
+ registrations: null,
472
584
  policyState: defaultPolicyState,
473
585
  };
474
586
  }
@@ -513,10 +625,10 @@ function resolveActionAvailability(descriptor, runtimeProbe) {
513
625
  cli_exposed: descriptor.command_path !== null,
514
626
  };
515
627
  }
516
- const commandPath = descriptor.command_path
517
- ? normalizeCommandPath(descriptor.command_path)
518
- : "";
519
- const extensionCommandAvailable = commandPath.length > 0 && runtimeProbe.handlers.has(commandPath);
628
+ const commandPaths = descriptor.command_path
629
+ ? splitCommandPathAliases(descriptor.command_path)
630
+ : [];
631
+ const extensionCommandAvailable = commandPaths.some((commandPath) => runtimeProbe.handlers.has(commandPath));
520
632
  const invocable = runtimeProbe.disabledReason === null && extensionCommandAvailable;
521
633
  return {
522
634
  action: descriptor.action,
@@ -599,6 +711,12 @@ function resolveCoreCommandFlags(command) {
599
711
  if (command === "history-redact") {
600
712
  return HISTORY_REDACT_FLAG_CONTRACTS;
601
713
  }
714
+ if (command === "history-repair") {
715
+ return HISTORY_REPAIR_FLAG_CONTRACTS;
716
+ }
717
+ if (command === "schema") {
718
+ return SCHEMA_FLAG_CONTRACTS;
719
+ }
602
720
  if (command === "plan") {
603
721
  return PLAN_FLAG_CONTRACTS;
604
722
  }
@@ -941,15 +1059,16 @@ export async function runContracts(options, global) {
941
1059
  catch {
942
1060
  settings = structuredClone(SETTINGS_DEFAULTS);
943
1061
  }
944
- const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
1062
+ const runtimeProbe = await resolveRuntimeExtensionActionProbe(global);
1063
+ const typeRegistry = resolveItemTypeRegistry(settings, runtimeProbe.registrations ?? getActiveExtensionRegistrations());
945
1064
  const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
946
1065
  const runtimeFieldRegistry = resolveRuntimeFieldRegistry(settings.schema);
947
1066
  const runtimeFieldFlagMap = buildRuntimeFieldFlagContracts(runtimeFieldRegistry);
948
1067
  const createRequiredOptionContracts = buildCreateRequiredOptionContracts(typeRegistry);
949
- const runtimeProbe = await resolveRuntimeExtensionActionProbe(global);
950
1068
  const extensionContracts = collectExtensionCommandContracts(runtimeProbe);
1069
+ const mergedExtensionContracts = mergeExtensionContractsByAction(extensionContracts);
951
1070
  const extensionFlagMap = collectExtensionFlagContractsByCommand(runtimeProbe.flagRegistrations);
952
- const actionDescriptors = collectActionContractDescriptors(extensionContracts);
1071
+ const actionDescriptors = collectActionContractDescriptors(mergedExtensionContracts);
953
1072
  const actionNames = new Set(actionDescriptors.map((entry) => entry.action));
954
1073
  if (selectedAction && !actionNames.has(selectedAction)) {
955
1074
  throw new PmCliError(`Unknown action: "${options.action}".`, EXIT_CODE.USAGE);
@@ -957,7 +1076,7 @@ export async function runContracts(options, global) {
957
1076
  const commandCatalog = [
958
1077
  ...new Set([
959
1078
  ...PM_CORE_COMMAND_NAMES.filter((entry) => !PACKAGE_OWNED_COMMANDS.has(entry)),
960
- ...extensionContracts.map((entry) => entry.command),
1079
+ ...mergedExtensionContracts.flatMap((entry) => entry.command.split("|")),
961
1080
  ]),
962
1081
  ]
963
1082
  .map((entry) => normalizeCommandPath(entry))
@@ -965,6 +1084,16 @@ export async function runContracts(options, global) {
965
1084
  .sort((left, right) => left.localeCompare(right));
966
1085
  const commandNames = new Set(commandCatalog);
967
1086
  if (selectedCommand && !commandNames.has(selectedCommand)) {
1087
+ const packageHint = PACKAGE_OWNED_COMMAND_INSTALL_HINTS.get(selectedCommand);
1088
+ if (packageHint) {
1089
+ throw new PmCliError(`Unknown command: "${options.command}". Command "${selectedCommand}" is provided by the optional "${packageHint}" package. Run "pm install ${packageHint} --project" and retry.`, EXIT_CODE.USAGE, {
1090
+ examples: [`pm install ${packageHint} --project`, `pm contracts --command ${selectedCommand} --flags-only --json`],
1091
+ nextSteps: [`Install the optional package first: pm install ${packageHint} --project`],
1092
+ recovery: {
1093
+ suggested_retry: `pm install ${packageHint} --project`,
1094
+ },
1095
+ });
1096
+ }
968
1097
  throw new PmCliError(`Unknown command: "${options.command}".`, EXIT_CODE.USAGE);
969
1098
  }
970
1099
  const commandScopedDescriptors = selectedCommand
@@ -991,7 +1120,7 @@ export async function runContracts(options, global) {
991
1120
  return typeof actionConst === "string" ? actionConst : null;
992
1121
  })
993
1122
  .filter((entry) => entry !== null));
994
- const extensionBranches = extensionContracts
1123
+ const extensionBranches = mergedExtensionContracts
995
1124
  .filter((contract) => !schemaActionSet.has(contract.action))
996
1125
  .map((contract) => buildExtensionActionSchemaBranch(contract));
997
1126
  const mergedSchema = extensionBranches.length > 0
@@ -1035,6 +1164,7 @@ export async function runContracts(options, global) {
1035
1164
  : selectedAction
1036
1165
  ? extensionContracts.filter((entry) => outputCommands.includes(normalizeCommandPath(entry.command)))
1037
1166
  : extensionContracts;
1167
+ const includeRuntimeContractSections = !(flagsOnly && !fullOutput);
1038
1168
  const result = {
1039
1169
  schema_version: typeof mergedSchema["x-schema-version"] === "string"
1040
1170
  ? mergedSchema["x-schema-version"]
@@ -1052,7 +1182,9 @@ export async function runContracts(options, global) {
1052
1182
  command_scoped: selectedCommand !== undefined,
1053
1183
  },
1054
1184
  commands: outputCommands,
1055
- runtime_schema: {
1185
+ };
1186
+ if (includeRuntimeContractSections) {
1187
+ result.runtime_schema = {
1056
1188
  statuses: statusRegistry.definitions.map((definition) => definition.id),
1057
1189
  open_status: statusRegistry.open_status,
1058
1190
  close_status: statusRegistry.close_status,
@@ -1064,8 +1196,8 @@ export async function runContracts(options, global) {
1064
1196
  ...new Set(definitions.map((definition) => `--${definition.cli_flag}`)),
1065
1197
  ].sort((left, right) => left.localeCompare(right)),
1066
1198
  ])),
1067
- },
1068
- extension_contracts: {
1199
+ };
1200
+ result.extension_contracts = {
1069
1201
  capabilities: [...PM_EXTENSION_CAPABILITY_CONTRACTS],
1070
1202
  services: [...PM_EXTENSION_SERVICE_NAME_CONTRACTS],
1071
1203
  policy_modes: [...PM_EXTENSION_POLICY_MODE_CONTRACTS],
@@ -1078,8 +1210,8 @@ export async function runContracts(options, global) {
1078
1210
  previous: ["v1"],
1079
1211
  breaking_strategy: "versioned_breaking",
1080
1212
  },
1081
- },
1082
- };
1213
+ };
1214
+ }
1083
1215
  if (!flagsOnly) {
1084
1216
  result.actions = actions;
1085
1217
  result.action_availability = actionAvailability;
@@ -1114,4 +1246,4 @@ export async function runContracts(options, global) {
1114
1246
  return result;
1115
1247
  }
1116
1248
  //# sourceMappingURL=contracts.js.map
1117
- //# debugId=dc0f1970-8a30-56c5-827f-573784a38d54
1249
+ //# debugId=478936e5-660a-5f89-b15d-93b37468c7ed