@unbrained/pm-cli 2026.9.11 → 2026.9.12

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 (133) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +22 -0
  3. package/dist/cli/error-guidance.d.ts +10 -0
  4. package/dist/cli/error-guidance.js +1 -1
  5. package/dist/cli/option-values.d.ts +3 -0
  6. package/dist/cli/option-values.js +2 -0
  7. package/dist/cli/register-mutation.d.ts +5 -0
  8. package/dist/cli/register-mutation.js +2 -16
  9. package/dist/cli/schema/registration.d.ts +4 -0
  10. package/dist/cli/schema/registration.js +16 -0
  11. package/dist/cli-bundle/bundle-manifest.json +155 -147
  12. package/dist/cli-bundle/chunks/{chunk-TDKWJQD7.js → chunk-2JAY4LFI.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-QER6OSOP.js → chunk-3ZJDGTYC.js} +53 -53
  14. package/dist/cli-bundle/chunks/{chunk-DAWH7TGV.js → chunk-67H4PKQ5.js} +2 -2
  15. package/dist/cli-bundle/chunks/{chunk-BN5QVWNY.js → chunk-7H33WPDF.js} +2 -2
  16. package/dist/cli-bundle/chunks/chunk-7KF6HCRC.js +20 -0
  17. package/dist/cli-bundle/chunks/chunk-DEGRLB6Y.js +235 -0
  18. package/dist/cli-bundle/chunks/{chunk-RJQSCK74.js → chunk-GKY655T7.js} +6 -6
  19. package/dist/cli-bundle/chunks/{chunk-JMQKJ7CJ.js → chunk-I6VQUHK6.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-IRUNFLLG.js → chunk-PTX2JRFR.js} +2 -2
  21. package/dist/cli-bundle/chunks/{chunk-VFKBNGF6.js → chunk-TAGDYARO.js} +2 -2
  22. package/dist/cli-bundle/chunks/{chunk-SGAKQIGQ.js → chunk-X6POOZKD.js} +27 -27
  23. package/dist/cli-bundle/chunks/{chunk-TFVKBJJ4.js → chunk-YU75JRTW.js} +103 -103
  24. package/dist/cli-bundle/chunks/{register-list-query-U6MY437C.js → register-list-query-KEZPDR6X.js} +2 -2
  25. package/dist/cli-bundle/chunks/register-mutation-HEXA3ZDM.js +20 -0
  26. package/dist/cli-bundle/chunks/{register-operations-EHWIZW3X.js → register-operations-TEZT65JF.js} +2 -2
  27. package/dist/cli-bundle/chunks/{register-setup-BZYL3HBL.js → register-setup-IIL74WUG.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/{chunk-VS6MR2HT.js → chunk-2BQ4JSJQ.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/{chunk-BEQAW7OT.js → chunk-5CRND7UA.js} +4 -4
  30. package/dist/cli-bundle/focused-chunks/chunk-5PSYV3AT.js +164 -0
  31. package/dist/cli-bundle/focused-chunks/{chunk-7WISPJRZ.js → chunk-7EKXAUKF.js} +52 -52
  32. package/dist/cli-bundle/focused-chunks/{chunk-TWE3GPQM.js → chunk-BIOWOU6S.js} +17 -17
  33. package/dist/cli-bundle/focused-chunks/{chunk-6JF66HAG.js → chunk-EIXGDI77.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/{chunk-ONDKO4EL.js → chunk-GAKFECOQ.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/chunk-HFAW3FJQ.js +2 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-HM6JS6Q3.js → chunk-IURELABV.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-UJCQXUD2.js → chunk-KK7KSXUP.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/{chunk-MOT32PR2.js → chunk-LWJBBM6X.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/chunk-MFVABYEU.js +2 -0
  40. package/dist/cli-bundle/focused-chunks/{chunk-GKUF7TM5.js → chunk-PERRTPIY.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/{chunk-FJDEFA64.js → chunk-SDQOOL34.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/{chunk-TGMSSI3Z.js → chunk-TTRB47KM.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/chunk-VWMP6W7Y.js +20 -0
  44. package/dist/cli-bundle/focused-chunks/chunk-YNBACVQ2.js +2 -0
  45. package/dist/cli-bundle/main.js +4 -4
  46. package/dist/cli-bundle/sdk-authoring.js +1 -1
  47. package/dist/cli-bundle/sdk-contracts.js +2 -2
  48. package/dist/cli-bundle/sdk-core.js +37 -37
  49. package/dist/cli-bundle/sdk-governance.js +1 -1
  50. package/dist/cli-bundle/sdk-graph.js +1 -1
  51. package/dist/cli-bundle/sdk-merge.js +42 -42
  52. package/dist/cli-bundle/sdk-query.js +1 -1
  53. package/dist/cli-bundle/sdk-runtime.js +1 -1
  54. package/dist/cli-bundle/sdk-testing.js +1 -1
  55. package/dist/cli-bundle/sdk.js +8 -8
  56. package/dist/core/history/history.js +1 -1
  57. package/dist/core/history/operation-contract.d.ts +30 -0
  58. package/dist/core/history/operation-contract.js +2 -0
  59. package/dist/core/history/tombstone.d.ts +3 -0
  60. package/dist/core/history/tombstone.js +2 -0
  61. package/dist/core/item/id.d.ts +8 -7
  62. package/dist/core/item/id.js +1 -1
  63. package/dist/core/output/mutation-projection.d.ts +1 -0
  64. package/dist/core/output/mutation-projection.js +1 -1
  65. package/dist/core/shared/command-line.d.ts +10 -0
  66. package/dist/core/shared/command-line.js +2 -0
  67. package/dist/core/shared/errors.d.ts +13 -0
  68. package/dist/core/shared/errors.js +1 -1
  69. package/dist/core/store/item-store.d.ts +5 -1
  70. package/dist/core/store/item-store.js +1 -1
  71. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +3 -0
  72. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  73. package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
  74. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  75. package/dist/sdk/command-line.d.ts +1 -6
  76. package/dist/sdk/command-line.js +1 -1
  77. package/dist/sdk/comments.js +1 -1
  78. package/dist/sdk/contracts.d.ts +1 -0
  79. package/dist/sdk/contracts.js +1 -1
  80. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  81. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  82. package/dist/sdk/governance/storage-integrity.js +1 -1
  83. package/dist/sdk/governance/workflow-completeness.js +1 -1
  84. package/dist/sdk/governance/workflow-policy.js +2 -2
  85. package/dist/sdk/index.d.ts +1 -0
  86. package/dist/sdk/index.js +1 -1
  87. package/dist/sdk/learnings.js +1 -1
  88. package/dist/sdk/lifecycle/claim.d.ts +2 -0
  89. package/dist/sdk/lifecycle/claim.js +1 -1
  90. package/dist/sdk/lifecycle/mcp-actions.d.ts +4 -0
  91. package/dist/sdk/lifecycle/mcp-actions.js +1 -1
  92. package/dist/sdk/lifecycle/task-composition.d.ts +2 -0
  93. package/dist/sdk/lifecycle/task-composition.js +1 -1
  94. package/dist/sdk/merge/reconcile.js +1 -1
  95. package/dist/sdk/merge/three-way.js +2 -2
  96. package/dist/sdk/notes.js +1 -1
  97. package/dist/sdk/public-surface.json +1 -1
  98. package/dist/sdk/query/projection-contracts.d.ts +1 -1
  99. package/dist/sdk/query/projection-contracts.js +1 -1
  100. package/dist/sdk/runtime.js +1 -1
  101. package/docs/AGENT_UX_CONTRACTS.md +8 -0
  102. package/docs/ARCHITECTURE.md +7 -0
  103. package/docs/HISTORY_OPERATIONS.md +46 -0
  104. package/docs/HISTORY_RECOVERY.md +27 -2
  105. package/docs/LIFECYCLE_COMMANDS.md +19 -2
  106. package/docs/MERGE_SAFETY.md +64 -3
  107. package/docs/WORKFLOW_POLICIES.md +47 -3
  108. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +6 -3
  109. package/marketplace.json +2 -2
  110. package/package.json +1 -1
  111. package/packages/pm-beads/package.json +1 -1
  112. package/packages/pm-calendar/package.json +1 -1
  113. package/packages/pm-command-kit/package.json +1 -1
  114. package/packages/pm-digital-twin/package.json +1 -1
  115. package/packages/pm-governance-audit/README.md +22 -0
  116. package/packages/pm-governance-audit/package.json +1 -1
  117. package/packages/pm-guide-shell/package.json +1 -1
  118. package/packages/pm-kanban/package.json +1 -1
  119. package/packages/pm-lifecycle-hooks/package.json +1 -1
  120. package/packages/pm-linked-test-adapters/package.json +1 -1
  121. package/packages/pm-search-advanced/package.json +1 -1
  122. package/packages/pm-templates/package.json +1 -1
  123. package/packages/pm-todos/package.json +1 -1
  124. package/packages/pm-vcs/package.json +1 -1
  125. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  126. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  127. package/dist/cli-bundle/chunks/chunk-FBY6PEIR.js +0 -20
  128. package/dist/cli-bundle/chunks/chunk-RJZFAXBW.js +0 -235
  129. package/dist/cli-bundle/chunks/register-mutation-HAPHD4S7.js +0 -20
  130. package/dist/cli-bundle/focused-chunks/chunk-3JVTLBCW.js +0 -20
  131. package/dist/cli-bundle/focused-chunks/chunk-DZ3ATEFS.js +0 -2
  132. package/dist/cli-bundle/focused-chunks/chunk-M74YW332.js +0 -164
  133. package/dist/cli-bundle/focused-chunks/chunk-YOPNRWSX.js +0 -2
@@ -12,7 +12,7 @@ export declare const LIST_COMMAND_DEFAULT_PROJECTIONS: {
12
12
  readonly "list-open": "brief";
13
13
  readonly "list-in-progress": "brief";
14
14
  readonly "list-blocked": "brief";
15
- readonly "list-closed": "full";
15
+ readonly "list-closed": "brief";
16
16
  readonly "list-canceled": "full";
17
17
  };
18
18
  /** Command names whose output defaults are described by the list projection contract. */
@@ -1,2 +1,2 @@
1
- !(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]="7bef182d-ada7-542d-8ffa-10876e5a97b0")}catch(e2){}})();import{ITEM_METADATA_KEY_ORDER}from"../../core/shared/item-metadata-contract.js";const DEFAULT_COMPACT_LIST_FIELDS=["id","title","status","type","priority","parent","updated_at"];const BRIEF_LIST_FIELDS=["id","status","type","title"];const LIST_COMMAND_DEFAULT_PROJECTIONS={list:"brief","list-all":"full","list-draft":"full","list-open":"brief","list-in-progress":"brief","list-blocked":"brief","list-closed":"full","list-canceled":"full"};const TREE_METADATA_FIELDS=["tree_depth","tree_parent","tree_children","tree_title"];function listListProjectionFields(runtimeMetadataKeys=[]){return[...new Set([...ITEM_METADATA_KEY_ORDER,"body",...TREE_METADATA_FIELDS,...runtimeMetadataKeys])].flatMap(field=>[field,`item.${field}`]).sort()}const GET_DEPTH_VALUES=["brief","standard","deep"];const GET_ROOT_PROJECTION_FIELDS=["body","linked","claim_state","children","schedule"];const GET_LINKED_PROJECTION_FIELDS=["linked.files","linked.tests","linked.docs"];const GET_CLAIM_STATE_PROJECTION_FIELDS=["claim_state.claimed","claim_state.assignee","claim_state.last_claim","claim_state.last_release"];const GET_SCHEDULE_PROJECTION_FIELDS=["schedule.deadline","schedule.start_at","schedule.end_at","schedule.location","schedule.reminders","schedule.events"];function listGetProjectionFields(runtimeMetadataKeys=[]){const itemFields=[...new Set([...ITEM_METADATA_KEY_ORDER,...runtimeMetadataKeys,"notes_count","tests_count","collection_counts"])];return[...itemFields.flatMap(field=>[field,`item.${field}`]),...GET_ROOT_PROJECTION_FIELDS,...GET_LINKED_PROJECTION_FIELDS,...GET_CLAIM_STATE_PROJECTION_FIELDS,...GET_SCHEDULE_PROJECTION_FIELDS].sort()}const DEFAULT_COMPACT_SEARCH_FIELDS=["id","title","status","type","priority","updated_at","score","matched_fields"];const SEARCH_HIT_FIELD_KEYS=["score","matched_fields","highlights"];const SEARCH_ITEM_FIELD_KEYS=["id","title","description","type","status","priority","tags","created_at","updated_at","deadline","assignee","author","estimated_minutes","acceptance_criteria","dependencies","comments","notes","learnings","reminders","events","files","tests","docs","close_reason","parent","reviewer","risk","confidence","sprint","release","blocked_by","blocked_reason","reporter","severity","environment","repro_steps","resolution","expected_result","actual_result","affected_version","fixed_version","component","regression","customer_impact","definition_of_ready","order","rank","goal","objective","value","impact","outcome","why_now","plan"];function listSearchProjectionFields(runtimeMetadataKeys=[]){const runtimeKeys=[...new Set(runtimeMetadataKeys)];return[...SEARCH_HIT_FIELD_KEYS,...SEARCH_ITEM_FIELD_KEYS,...SEARCH_ITEM_FIELD_KEYS.map(field=>`item.${field}`),...runtimeKeys,...runtimeKeys.map(field=>`item.${field}`)].sort()}export{BRIEF_LIST_FIELDS,DEFAULT_COMPACT_LIST_FIELDS,DEFAULT_COMPACT_SEARCH_FIELDS,GET_DEPTH_VALUES,LIST_COMMAND_DEFAULT_PROJECTIONS,SEARCH_HIT_FIELD_KEYS,SEARCH_ITEM_FIELD_KEYS,listGetProjectionFields,listListProjectionFields,listSearchProjectionFields};
1
+ !(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]="261c726f-338d-5618-8f6b-051b41a38c99")}catch(e2){}})();import{ITEM_METADATA_KEY_ORDER}from"../../core/shared/item-metadata-contract.js";const DEFAULT_COMPACT_LIST_FIELDS=["id","title","status","type","priority","parent","updated_at"];const BRIEF_LIST_FIELDS=["id","status","type","title"];const LIST_COMMAND_DEFAULT_PROJECTIONS={list:"brief","list-all":"full","list-draft":"full","list-open":"brief","list-in-progress":"brief","list-blocked":"brief","list-closed":"brief","list-canceled":"full"};const TREE_METADATA_FIELDS=["tree_depth","tree_parent","tree_children","tree_title"];function listListProjectionFields(runtimeMetadataKeys=[]){return[...new Set([...ITEM_METADATA_KEY_ORDER,"body",...TREE_METADATA_FIELDS,...runtimeMetadataKeys])].flatMap(field=>[field,`item.${field}`]).sort()}const GET_DEPTH_VALUES=["brief","standard","deep"];const GET_ROOT_PROJECTION_FIELDS=["body","linked","claim_state","children","schedule"];const GET_LINKED_PROJECTION_FIELDS=["linked.files","linked.tests","linked.docs"];const GET_CLAIM_STATE_PROJECTION_FIELDS=["claim_state.claimed","claim_state.assignee","claim_state.last_claim","claim_state.last_release"];const GET_SCHEDULE_PROJECTION_FIELDS=["schedule.deadline","schedule.start_at","schedule.end_at","schedule.location","schedule.reminders","schedule.events"];function listGetProjectionFields(runtimeMetadataKeys=[]){const itemFields=[...new Set([...ITEM_METADATA_KEY_ORDER,...runtimeMetadataKeys,"notes_count","tests_count","collection_counts"])];return[...itemFields.flatMap(field=>[field,`item.${field}`]),...GET_ROOT_PROJECTION_FIELDS,...GET_LINKED_PROJECTION_FIELDS,...GET_CLAIM_STATE_PROJECTION_FIELDS,...GET_SCHEDULE_PROJECTION_FIELDS].sort()}const DEFAULT_COMPACT_SEARCH_FIELDS=["id","title","status","type","priority","updated_at","score","matched_fields"];const SEARCH_HIT_FIELD_KEYS=["score","matched_fields","highlights"];const SEARCH_ITEM_FIELD_KEYS=["id","title","description","type","status","priority","tags","created_at","updated_at","deadline","assignee","author","estimated_minutes","acceptance_criteria","dependencies","comments","notes","learnings","reminders","events","files","tests","docs","close_reason","parent","reviewer","risk","confidence","sprint","release","blocked_by","blocked_reason","reporter","severity","environment","repro_steps","resolution","expected_result","actual_result","affected_version","fixed_version","component","regression","customer_impact","definition_of_ready","order","rank","goal","objective","value","impact","outcome","why_now","plan"];function listSearchProjectionFields(runtimeMetadataKeys=[]){const runtimeKeys=[...new Set(runtimeMetadataKeys)];return[...SEARCH_HIT_FIELD_KEYS,...SEARCH_ITEM_FIELD_KEYS,...SEARCH_ITEM_FIELD_KEYS.map(field=>`item.${field}`),...runtimeKeys,...runtimeKeys.map(field=>`item.${field}`)].sort()}export{BRIEF_LIST_FIELDS,DEFAULT_COMPACT_LIST_FIELDS,DEFAULT_COMPACT_SEARCH_FIELDS,GET_DEPTH_VALUES,LIST_COMMAND_DEFAULT_PROJECTIONS,SEARCH_HIT_FIELD_KEYS,SEARCH_ITEM_FIELD_KEYS,listGetProjectionFields,listListProjectionFields,listSearchProjectionFields};
2
2
  //# sourceMappingURL=projection-contracts.js.map
@@ -1,2 +1,2 @@
1
- !(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]="8571dfa8-111e-595a-8bfa-e4c76be78a20")}catch(e2){}})();import{PM_GITIGNORE_END,PM_GITIGNORE_START,ensurePmGitignore,getPmGitignoreBlock}from"./workspace.js";import{SEARCH_EXTENSION_FLAG_DEFINITIONS}from"./extension-contracts.js";export*from"./cli-contracts/agent-output-contracts.js";import{AsyncLocalStorage}from"node:async_hooks";import{createEmptyExtensionCommandRegistry,createEmptyExtensionHookRegistry,createEmptyExtensionParserRegistry,createEmptyExtensionPreflightRegistry,createEmptyExtensionRegistrationRegistry,createEmptyExtensionRendererRegistry,createEmptyExtensionServiceRegistry}from"../core/extensions/extension-registries.js";import{activateExtensions,deactivateExtensions,loadExtensions,runActiveCommandHandler,runWithIsolatedExtensionRuntime,setActiveExtensionCommands,setActiveExtensionHooks,setActiveExtensionParsers,setActiveExtensionPreflight,setActiveExtensionRegistrations,setActiveExtensionRenderers,setActiveExtensionServices}from"../core/extensions/index.js";import{pathExists}from"../core/fs/fs-utils.js";import{projectMutationResult}from"../core/output/mutation-projection.js";import{withQuerySummary}from"../core/output/query-summary.js";import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";import{asRecordClone}from"../core/shared/primitives.js";import{createAsyncReadWriteGate}from"../core/shared/serial-queue.js";import{getSettingsPath,resolvePmRoot}from"../core/store/paths.js";import{readSettings}from"../core/store/settings.js";import{listClientItemMetadataLight}from"./query/light-metadata.js";import{certifyCompleteListResult,createCompleteListOptions}from"./query/complete-list.js";import{PmCompleteListValidationError,assertCompleteListResult,certifyCompleteListResult as certifyCompleteListResult2,createCompleteListOptions as createCompleteListOptions2,inspectCompleteListResult}from"./query/complete-list.js";import{getWorkspaceContracts}from"./query/workspace-contracts.js";import{PM_TOOL_ACTIONS}from"./cli-contracts/enum-contracts.js";import{clearWorkspaceContractsCache}from"./workspace-contracts-cache.js";import{SDK_ACTION_ALIASES}from"./runtime-action-aliases.js";import{createExtensionCommandSdk}from"./extension-command-context.js";import{createUnknownSubcommandError}from"./agent/subcommand-recovery.js";import{applyContextIntentProjection,attachReadOutputContracts}from"./context-intent-contracts.js";import{finalizeContextUsageEgress}from"./context/usage-egress.js";import{runWithDiscoveredContextIntentContracts}from"./context-intent-runtime.js";import{normalizeReadOutputIncludeModeOptions,validateReadOutputOptions}from"./read-output-contracts.js";import{clearWorkspaceContractsCache as clearWorkspaceContractsCache2}from"./workspace-contracts-cache.js";import{normalizeActivityProjectionOptions,runActivity}from"./query/activity.js";import{runAssuranceDispatch}from"./governance/assurance-action.js";import{WORKFLOW_POLICY_ACTIONS,runWorkflowPolicyAction}from"./governance/workflow-policy.js";export*from"./governance/workflow-policy.js";import{runAggregate}from"./query/aggregate.js";import{runAppend}from"./lifecycle/append.js";import{runRelease}from"./lifecycle/claim.js";import{runStartTask,runPauseTask,runCloseTask}from"./lifecycle/task-composition.js";import{runStartTask as runStartTask2,runPauseTask as runPauseTask2,runCloseTask as runCloseTask2}from"./lifecycle/task-composition.js";import{runCloseMany}from"./lifecycle/close-many.js";import{normalizeAnnotationTransportOptions}from"./annotations.js";import{runComments}from"./comments.js";import{runHistory}from"./query/history.js";import{runHistoryAttest}from"./history/attestation-command.js";import{runLearnings}from"./learnings.js";import{runNotes}from"./notes.js";import{runUpdateMany}from"./lifecycle/update-many.js";import{runUpgrade}from"./governance/upgrade.js";import{runCreate}from"./lifecycle/create.js";import{runUpdate}from"./lifecycle/update.js";import{runPlan}from"./lifecycle/plan.js";import{runContext}from"./query/context.js";import{runNext}from"./query/next.js";import{runCopy}from"./lifecycle/copy.js";import{runDelete}from"./lifecycle/delete.js";import{runRestore}from"./lifecycle/restore.js";import{runFocus}from"./lifecycle/focus.js";import{runGet}from"./query/get.js";import{runGc}from"./governance/gc.js";import{runHealth}from"./governance/health.js";import{runValidate}from"./governance/validate.js";import{runExtension}from"./extension.js";import{runConfig}from"./config.js";import{INIT_INVOCATION_CWD,runInit}from"./init.js";import{runRuntimeEvalAction,runRuntimeEventsAction,runRuntimeMergeAction,runRuntimeSchedulingAction,runRuntimeWorkspaceAction}from"./runtime-extended-actions.js";import{acknowledgeUnknownAuthorHistoryEventsFromTransport}from"./author-attribution.js";import{PROFILE_SUBCOMMANDS,runProfileApply,runProfileLint,runProfileList,runProfileShow}from"./profile.js";import{runHistoryRedact}from"./history-redact.js";import{runMcpHistoryCompactAction,runMcpHistoryRepairAction}from"./history-mcp.js";import{runMcpClaimAction,runMcpCloseAction,runMcpReopenAction}from"./lifecycle/mcp-actions.js";import{actionGlobalOptions as globalOptions,closeManyOptionsFromFlat,extensionOptionsFromArgs,graphOptionsFromFlat,mutationListOptions,mutationOptionsWithOverrides,normalizeActionName,normalizeCommandPath,normalizeMcpOptionsArrays,normalizeMcpUpdateOptions,optionsWithAuthor,parseRuntimeInteger as parseMcpInteger,readRuntimeScalarString as readScalarString,readRuntimeScalarStringAllowBlank as readScalarStringAllowBlank,readRuntimeString as readString,readRuntimeStringArray as readStringArray,resolveRuntimeLimit,shouldInvalidateWorkspaceContractsCacheAfterAction,updateManyOptionsFromFlat,withAddNoteOption,withFilesDiscoveryOptions,withMutationCompaction}from"./runtime-input.js";import{runDeps}from"./dependencies.js";import{runDocs}from"./docs.js";import{runGraph}from"./graph/run.js";import{runFiles,runFilesDiscover,runFilesLookup}from"./files.js";import{runtimeFilesLookupOptions}from"./traceability/runtime-files-lookup.js";import{runContracts}from"./cli-contracts/runtime-contracts.js";import{runList}from"./query/list.js";import{runSearch}from"./query/search.js";import{runStats}from"./stats.js";import{statsCommandOptionsFromRuntime}from"./runtime-stats-options.js";import{runDuplicates}from"./duplicates.js";import{runTelemetry}from"./telemetry.js";import{runTest}from"./test/execution.js";import{runTestAll}from"./test/batch.js";import{SCHEMA_SUBCOMMANDS,runSchemaAddField,runSchemaAddStatus,runSchemaAddType,runSchemaApplyPreset,runSchemaInferTypes,runSchemaList,runSchemaListFields,runSchemaEvolutionMigration,runSchemaRemoveField,runSchemaRemoveStatus,runSchemaRemoveType,runSchemaShow,runSchemaShowField,runSchemaShowStatus}from"./schema.js";import{getActiveExtensionRegistrations,runActiveOnReadHooks,runActiveOnWriteHooks}from"../core/extensions/index.js";import{pathExists as pathExists2,readFileIfExists,removeFileIfExists,writeFileAtomic}from"../core/fs/fs-utils.js";import{appendHistoryEntry,createHistoryEntry}from"../core/history/history.js";import{classifyHistoryEvent,HISTORY_EVENT_CLASSIFICATION_VERSION,MAINTENANCE_HISTORY_OPERATIONS,SUBSTANTIVE_HISTORY_OPERATIONS}from"../core/history/event-classification.js";import{generateItemId,normalizeItemId,normalizeRawItemId}from"../core/item/id.js";import{readBooleanOption,readCsvListOption,readStringOption}from"./package-runtime-options.js";import{PM_CLI_EXPECTED_ERROR_NAME,createPmCliExpectedError,isPmCliExpectedError}from"./errors.js";import{commitImportedItem,emptyImportedDocument,ensureTrackerInitialized,selectImportAuthor,toEstimatedMinutesValue,toImportBoolean,toImportConfidence,toImportInteger,toImportLinkedDocs,toImportLinkedFiles,toImportLinkedTests,toImportLogEntries,toImportNormalizedEnum,toImportNumberMap,toImportPriority,toImportStatus,toImportStringList,toImportStringMap,toImportTags,toNonEmptyImportString}from"./package-import-adapters.js";import{canonicalDocument,normalizeItemMetadata,serializeItemDocument,splitFrontMatter}from"../core/item/item-format.js";import{BASELINE_ITEM_FORMAT_VERSION,CURRENT_ITEM_FORMAT_VERSION,classifyItemFormatVersion,effectiveItemFormatVersion,normalizeItemFormatVersion,scanItemFormatVersions}from"../core/item/item-format-version.js";import{parseTags}from"../core/item/parse.js";import{isTerminalStatus,normalizeStatusInput}from"../core/item/status.js";import{resolveItemTypeRegistry}from"../core/item/type-registry.js";import{acquireLock}from"../core/lock/lock.js";import{resolveRuntimeFieldRegistry,resolveRuntimeStatusRegistry}from"../core/schema/runtime-schema.js";import{PmCliError as PmCliError2}from"../core/shared/errors.js";import{isTimestampLiteral,nowIso}from"../core/shared/time.js";import{jaccardSimilarity,normalizeSimilarityText,scoreItemSimilarity,tokenizeSimilarityText}from"./similarity-scoring.js";import{listAllItemMetadata,listAllItemMetadataLight,locateItem,readLocatedItem}from"../core/store/item-store.js";import{getHistoryPath,getItemPath,getSettingsPath as getSettingsPath2,resolveImplicitPmRoot,resolvePmRoot as resolvePmRoot2}from"../core/store/paths.js";import{readSettings as readSettings2}from"../core/store/settings.js";import{runAggregate as runAggregate2}from"./query/aggregate.js";import{CONTEXT_OUTPUT_VALUES,runContext as runContext2}from"./query/context.js";import{runGet as runGet2}from"./query/get.js";import{runList as runList2}from"./query/list.js";import{closeItem,runClose}from"./lifecycle/close.js";import{runCopy as runCopy2}from"./lifecycle/copy.js";import{runDelete as runDelete2}from"./lifecycle/delete.js";import{runFocus as runFocus2}from"./lifecycle/focus.js";import{runRestore as runRestore2}from"./lifecycle/restore.js";import{DEFAULT_TERMINAL_TRANSITION_POLICY,applyTerminalOrderingPolicy,requireTerminalReason,resolveTerminalReason}from"./lifecycle-policy.js";import{runUpdate as runUpdate2}from"./lifecycle/update.js";import{runReopen}from"./lifecycle/reopen.js";import{NEXT_OUTPUT_VALUES,runNext as runNext2}from"./query/next.js";import{runSearch as runSearch2}from"./query/search.js";import{runStats as runStats2}from"./stats.js";import{runDuplicates as runDuplicates2}from"./duplicates.js";import{renderCalendarMarkdown,renderCalendarToon,resolveCalendarOutputFormat,runCalendar}from"./query/calendar.js";import{renderGuideMarkdown,resolveGuideOutputFormat,runGuide}from"./guide.js";import{runCompletion}from"./completion.js";import{runReindex}from"./governance/reindex.js";import{loadCreateTemplateOptions,runTemplatesList,runTemplatesSave,runTemplatesShow}from"./templates.js";import{runTestRunsList,runTestRunsLogs,runTestRunsResume,runTestRunsStatus,runTestRunsStop}from"./test/runs.js";import{CONFIDENCE_TEXT_VALUES,DEPENDENCY_KIND_VALUES,BUILTIN_ITEM_TYPE_VALUES,ISSUE_SEVERITY_VALUES,ITEM_TYPE_VALUES,RISK_VALUES,STATUS_VALUES}from"../types/index.js";const ACTIVE_EXTENSION_HOST_CONTEXT=Symbol("pm.active-extension-host-context");function splitFullClientMutationOptions(options){return{fullChangedFields:true,options}}class PmClient{defaults;constructor(options={}){this.defaults={...options.pmRoot===void 0?{}:{path:options.pmRoot},...options.cwd===void 0?{}:{cwd:options.cwd},...options.author===void 0?{}:{author:options.author},...options.noExtensions===void 0?{}:{noExtensions:options.noExtensions}}}static forActiveExtensionHost(options){const client=new PmClient({...options,noExtensions:true});client.defaults[ACTIVE_EXTENSION_HOST_CONTEXT]=true;return client}run(action,args={}){return runAction({...this.defaults,...args,action})}runTyped(action,args={}){return this.run(action,args)}context(options={}){return this.runTyped("context",{options})}listAllItemMetadataLight(){return listClientItemMetadataLight(this.defaults.path,this.defaults.cwd)}list(options={}){return this.runTyped("list",{options})}async listAllComplete(options={}){return certifyCompleteListResult(await this.list(createCompleteListOptions(options)))}search(query,options={}){return this.runTyped("search",{query,options})}get(id,options={}){return this.runTyped("get",{id,options})}next(options={}){return this.runTyped("next",{options})}aggregate(options={}){return this.runTyped("aggregate",{options})}stats(options={}){return this.runTyped("stats",{options})}duplicates(options={}){return this.runTyped("duplicates",{options})}comments(id,options={}){return this.runTyped("comments",{id,options})}notes(id,options={}){return this.runTyped("notes",{id,options})}learnings(id,options={}){return this.runTyped("learnings",{id,options})}files(id,options={}){return this.runTyped("files",{id,options})}filesDiscover(id,options={}){return this.runTyped("files-discover",{id,options})}filesLookup(options){return this.runTyped("files-lookup",{options})}docs(id,options={}){return this.runTyped("docs",{id,options})}deps(id,options={}){return this.runTyped("deps",{id,options})}graph(subcommand,ids={},options={}){return this.runTyped("graph",{subcommand,...ids,options})}append(id,body,options={}){return this.runTyped("append",{id,...splitFullClientMutationOptions(mutationOptionsWithOverrides(options,{body}))})}init(prefix,options={}){return this.runTyped("init",{...prefix===void 0?{}:{prefix},options})}config(scope,configAction,key,value,options={}){return this.runTyped("config",{scope,configAction,...key===void 0?{}:{key},...value===void 0?{}:{value},options})}schema(subcommand,options={}){return this.runTyped("schema",{options:{...options,subcommand}})}workflowPolicy(action,name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:action}})}schemaList(){return this.runTyped("schema",{options:{subcommand:"list"}})}schemaShow(name){return this.runTyped("schema",{name,options:{subcommand:"show"}})}schemaAddType(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"add-type"}})}schemaRemoveType(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"remove-type"}})}schemaAddStatus(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"add-status"}})}schemaRemoveStatus(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"remove-status"}})}schemaAddField(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"add-field"}})}schemaRemoveField(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"remove-field"}})}schemaListFields(){return this.runTyped("schema",{options:{subcommand:"list-fields"}})}schemaShowField(name){return this.runTyped("schema",{name,options:{subcommand:"show-field"}})}schemaApplyPreset(typePreset,options={}){return this.runTyped("schema",{typePreset,options:{...options,subcommand:"apply-preset"}})}schemaInferTypes(options={}){return this.runTyped("schema",{options:{...options,subcommand:"add-type",infer:true}})}schemaRenameType(from,to,options){return this.runTyped("schema",{name:from,options:{...options,subcommand:"rename-type",to}})}schemaRenameField(from,to,options,type){return this.runTyped("schema",{name:from,options:{...options,subcommand:"rename-field",to,...type?{fieldTypeScope:type}:{}}})}schemaRemapStatus(from,to,options){return this.runTyped("schema",{name:from,options:{...options,subcommand:"remap-status",to}})}schemaShowStatus(name){return this.runTyped("schema",{name,options:{subcommand:"show-status"}})}profile(subcommand,options={}){return this.runTyped("profile",{options:{...options,subcommand}})}profileList(){return this.runTyped("profile",{options:{subcommand:"list"}})}profileShow(name){return this.runTyped("profile",{name,options:{subcommand:"show"}})}profileApply(name,options={}){return this.runTyped("profile",{name,options:{...options,subcommand:"apply"}})}profileLint(name){return this.runTyped("profile",{name,options:{subcommand:"lint"}})}validate(options={}){return this.runTyped("validate",{options})}health(options={}){return this.runTyped("health",{options})}gc(options={}){return this.runTyped("gc",{options})}assurance(input){return this.runTyped("assurance",{options:{...input,subcommand:input.action}})}historyRedact(id,options){return this.runTyped("history-redact",{id,options})}historyRepair(id,options={}){return this.runTyped("history-repair",{id,options})}historyRepairAll(options={}){return this.runTyped("history-repair",{options:{...options,all:true}})}historyAttest(options={}){return this.runTyped("history-attest",{options})}historyCompact(id,options={}){return this.runTyped("history-compact",{id,options})}historyCompactBulk(options){return this.runTyped("history-compact",{options})}historyAuthorAcknowledge(options){return this.runTyped("history-author-acknowledge",{historyEvent:(options.events??[]).map(event=>`${event.item_id}:${String(event.line)}`),allActionable:options.all_actionable===true,dryRun:options.dry_run===true,planFingerprint:options.plan_fingerprint,limit:options.coordinate_limit,attributedAuthor:options.attributed_author,reviewer:options.reviewer,reason:options.reason})}plan(subcommand,id,options={},stepRef,reorderTo){return this.runTyped("plan",{...id===void 0?{}:{id},...stepRef===void 0?{}:{stepRef},...reorderTo===void 0?{}:{reorderTo},options:mutationOptionsWithOverrides(options,{subcommand})})}planCreate(options){return this.plan("create",void 0,options)}planShow(id,options={}){return this.plan("show",id,options)}planAddStep(id,options){return this.plan("add-step",id,options)}planUpdateStep(id,stepRef,options){return this.plan("update-step",id,options,stepRef)}planCompleteStep(id,stepRef,options={}){return this.plan("complete-step",id,options,stepRef)}planBlockStep(id,stepRef,options){return this.plan("block-step",id,options,stepRef)}planReorderStep(id,stepRef,reorderTo,options={}){return this.plan("reorder-step",id,options,stepRef,reorderTo)}planRemoveStep(id,stepRef,options={}){return this.plan("remove-step",id,options,stepRef)}planLink(id,stepRef,options){return this.plan("link",id,options,stepRef)}planUnlink(id,stepRef,options){return this.plan("unlink",id,options,stepRef)}planDecision(id,options){return this.plan("decision",id,options)}planDiscovery(id,options){return this.plan("discovery",id,options)}planValidation(id,options){return this.plan("validation",id,options)}planResume(id,options){return this.plan("resume",id,options)}planApprove(id,options={}){return this.plan("approve",id,options)}planMaterialize(id,options){return this.plan("materialize",id,options)}create(options={}){return this.runTyped("create",splitFullClientMutationOptions(options))}update(id,options={}){return this.runTyped("update",{id,...splitFullClientMutationOptions(options)})}reopen(id,reason,options={}){return this.runTyped("item-reopen",{id,reason,fullChangedFields:true,options})}close(id,reason,options={}){return this.runTyped("close",{id,reason,...splitFullClientMutationOptions(options)})}claim(id,options={}){return this.runTyped("claim",{id,...splitFullClientMutationOptions(options)})}claimNext(options={}){return this.runTyped("claim",{next:true,...splitFullClientMutationOptions(options)})}release(id,options={}){return this.runTyped("release",{id,...splitFullClientMutationOptions(options)})}copy(id,options={}){return this.runTyped("copy",{id,...splitFullClientMutationOptions(options)})}delete(id,options={}){return this.runTyped("delete",{id,...splitFullClientMutationOptions(options)})}restore(id,target,options={}){return this.runTyped("restore",{fullChangedFields:true,id,options:{...options,target}})}focus(id,options={}){return this.runTyped("focus",{...id===void 0?{}:{id},...splitFullClientMutationOptions(options)})}startTask(id,options={}){return this.runTyped("start-task",{id,...splitFullClientMutationOptions(options)})}pauseTask(id,options={}){return this.runTyped("pause-task",{id,...splitFullClientMutationOptions(options)})}closeTask(id,reason,options={}){return this.runTyped("close-task",{id,reason,...splitFullClientMutationOptions(options)})}extension(target,options={}){return this.runTyped("extension",{...target===void 0?{}:{target},options})}extensionList(options={}){return this.extension("list",options)}extensionActivate(target,options={}){return this.runTyped("extension-activate",{target,options})}extensionDeactivate(target,options={}){return this.runTyped("extension-deactivate",{target,options})}package(target,options={}){return this.runTyped("package",{...target===void 0?{}:{target},options:{...options,vocabulary:"package"}})}packageList(options={}){return this.package("list",options)}packageInstall(target,options={}){return this.runTyped("package-install",{target,options})}packageUninstall(target,options={}){return this.runTyped("package-uninstall",{target,options})}packageDoctor(options={}){return this.runTyped("package-doctor",{options})}packageManage(target,options={}){return this.runTyped("package-manage",{...target===void 0?{}:{target},options})}packageDescribe(target,options={}){return this.runTyped("package-describe",{...target===void 0?{}:{target},options})}packageReload(options={}){return this.runTyped("package-reload",{options})}packageCatalog(options={}){return this.runTyped("package-catalog",{options})}packageActivate(target,options={}){return this.runTyped("package-activate",{target,options})}packageDeactivate(target,options={}){return this.runTyped("package-deactivate",{target,options})}packageMigrate(options={}){return this.package(void 0,{...options,migrate:true})}upgrade(target,options={}){return this.runTyped("upgrade",{...target===void 0?{}:{target},options})}}function context(options={},clientOptions={}){return new PmClient(clientOptions).context(options)}function list(options={},clientOptions={}){return new PmClient(clientOptions).list(options)}function listAllComplete(options={},clientOptions={}){return new PmClient(clientOptions).listAllComplete(options)}function search(query,options={},clientOptions={}){return new PmClient(clientOptions).search(query,options)}function get(id,options={},clientOptions={}){return new PmClient(clientOptions).get(id,options)}function next(options={},clientOptions={}){return new PmClient(clientOptions).next(options)}function aggregate(options={},clientOptions={}){return new PmClient(clientOptions).aggregate(options)}function stats(options={},clientOptions={}){return new PmClient(clientOptions).stats(options)}function duplicates(options={},clientOptions={}){return new PmClient(clientOptions).duplicates(options)}function comments(id,options={},clientOptions={}){return new PmClient(clientOptions).comments(id,options)}function notes(id,options={},clientOptions={}){return new PmClient(clientOptions).notes(id,options)}function learnings(id,options={},clientOptions={}){return new PmClient(clientOptions).learnings(id,options)}function files(id,options={},clientOptions={}){return new PmClient(clientOptions).files(id,options)}function filesDiscover(id,options={},clientOptions={}){return new PmClient(clientOptions).filesDiscover(id,options)}function filesLookup(options,clientOptions={}){return new PmClient(clientOptions).filesLookup(options)}function docs(id,options={},clientOptions={}){return new PmClient(clientOptions).docs(id,options)}function deps(id,options={},clientOptions={}){return new PmClient(clientOptions).deps(id,options)}function graph(subcommand,ids={},options={},clientOptions={}){return new PmClient(clientOptions).graph(subcommand,ids,options)}function append(id,body,options={},clientOptions={}){return new PmClient(clientOptions).append(id,body,options)}function init(prefix,options={},clientOptions={}){return new PmClient(clientOptions).init(prefix,options)}function config(scope,configAction,key,value,options={},clientOptions={}){return new PmClient(clientOptions).config(scope,configAction,key,value,options)}function schema(subcommand,options={},clientOptions={}){return new PmClient(clientOptions).schema(subcommand,options)}function schemaList(clientOptions={}){return new PmClient(clientOptions).schemaList()}function schemaShow(name,clientOptions={}){return new PmClient(clientOptions).schemaShow(name)}function schemaAddType(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaAddType(name,options)}function schemaRemoveType(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaRemoveType(name,options)}function schemaAddStatus(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaAddStatus(name,options)}function schemaRemoveStatus(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaRemoveStatus(name,options)}function schemaAddField(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaAddField(name,options)}function schemaRemoveField(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaRemoveField(name,options)}function schemaListFields(clientOptions={}){return new PmClient(clientOptions).schemaListFields()}function schemaShowField(name,clientOptions={}){return new PmClient(clientOptions).schemaShowField(name)}function schemaApplyPreset(typePreset,options={},clientOptions={}){return new PmClient(clientOptions).schemaApplyPreset(typePreset,options)}function schemaInferTypes(options={},clientOptions={}){return new PmClient(clientOptions).schemaInferTypes(options)}function schemaRenameType(from,to,options,clientOptions={}){return new PmClient(clientOptions).schemaRenameType(from,to,options)}function schemaRenameField(from,to,options,type,clientOptions={}){return new PmClient(clientOptions).schemaRenameField(from,to,options,type)}function schemaRemapStatus(from,to,options,clientOptions={}){return new PmClient(clientOptions).schemaRemapStatus(from,to,options)}function schemaShowStatus(name,clientOptions={}){return new PmClient(clientOptions).schemaShowStatus(name)}function profile(subcommand,options={},clientOptions={}){return new PmClient(clientOptions).profile(subcommand,options)}function profileList(clientOptions={}){return new PmClient(clientOptions).profileList()}function profileShow(name,clientOptions={}){return new PmClient(clientOptions).profileShow(name)}function profileApply(name,options={},clientOptions={}){return new PmClient(clientOptions).profileApply(name,options)}function profileLint(name,clientOptions={}){return new PmClient(clientOptions).profileLint(name)}function validate(options={},clientOptions={}){return new PmClient(clientOptions).validate(options)}function health(options={},clientOptions={}){return new PmClient(clientOptions).health(options)}function gc(options={},clientOptions={}){return new PmClient(clientOptions).gc(options)}function historyRedact(id,options,clientOptions={}){return new PmClient(clientOptions).historyRedact(id,options)}function historyRepair(id,options={},clientOptions={}){return new PmClient(clientOptions).historyRepair(id,options)}function historyRepairAll(options={},clientOptions={}){return new PmClient(clientOptions).historyRepairAll(options)}function historyCompact(id,options={},clientOptions={}){return new PmClient(clientOptions).historyCompact(id,options)}function historyCompactBulk(options,clientOptions={}){return new PmClient(clientOptions).historyCompactBulk(options)}function create(options={},clientOptions={}){return new PmClient(clientOptions).create(options)}function update(id,options={},clientOptions={}){return new PmClient(clientOptions).update(id,options)}function reopen(id,reason,options={},clientOptions={}){return new PmClient(clientOptions).reopen(id,reason,options)}function close(id,reason,options={},clientOptions={}){return new PmClient(clientOptions).close(id,reason,options)}function claim(id,options={},clientOptions={}){return new PmClient(clientOptions).claim(id,options)}function claimNext(options={},clientOptions={}){return new PmClient(clientOptions).claimNext(options)}function release(id,options={},clientOptions={}){return new PmClient(clientOptions).release(id,options)}function copy(id,options={},clientOptions={}){return new PmClient(clientOptions).copy(id,options)}function deleteItem(id,options={},clientOptions={}){return new PmClient(clientOptions).delete(id,options)}function restore(id,target,options={},clientOptions={}){return new PmClient(clientOptions).restore(id,target,options)}function focus(id,options={},clientOptions={}){return new PmClient(clientOptions).focus(id,options)}function startTask(id,options={},clientOptions={}){return new PmClient(clientOptions).startTask(id,options)}function pauseTask(id,options={},clientOptions={}){return new PmClient(clientOptions).pauseTask(id,options)}function closeTask(id,reason,options={},clientOptions={}){return new PmClient(clientOptions).closeTask(id,reason,options)}function extension(target,options={},clientOptions={}){return new PmClient(clientOptions).extension(target,options)}function extensionList(options={},clientOptions={}){return new PmClient(clientOptions).extensionList(options)}function extensionActivate(target,options={},clientOptions={}){return new PmClient(clientOptions).extensionActivate(target,options)}function extensionDeactivate(target,options={},clientOptions={}){return new PmClient(clientOptions).extensionDeactivate(target,options)}function packageLifecycle(target,options={},clientOptions={}){return new PmClient(clientOptions).package(target,options)}function packageList(options={},clientOptions={}){return new PmClient(clientOptions).packageList(options)}function packageInstall(target,options={},clientOptions={}){return new PmClient(clientOptions).packageInstall(target,options)}function packageUninstall(target,options={},clientOptions={}){return new PmClient(clientOptions).packageUninstall(target,options)}function packageDoctor(options={},clientOptions={}){return new PmClient(clientOptions).packageDoctor(options)}function packageManage(target,options={},clientOptions={}){return new PmClient(clientOptions).packageManage(target,options)}function packageDescribe(target,options={},clientOptions={}){return new PmClient(clientOptions).packageDescribe(target,options)}function packageReload(options={},clientOptions={}){return new PmClient(clientOptions).packageReload(options)}function packageCatalog(options={},clientOptions={}){return new PmClient(clientOptions).packageCatalog(options)}function packageActivate(target,options={},clientOptions={}){return new PmClient(clientOptions).packageActivate(target,options)}function packageDeactivate(target,options={},clientOptions={}){return new PmClient(clientOptions).packageDeactivate(target,options)}function upgrade(target,options={},clientOptions={}){return new PmClient(clientOptions).upgrade(target,options)}async function getContracts(pmRootOrOptions,options={}){const resolvedOptions=typeof pmRootOrOptions==="string"?{...options,pmRoot:pmRootOrOptions}:pmRootOrOptions??options;const global2={json:true,quiet:resolvedOptions.quiet??true,noExtensions:resolvedOptions.noExtensions??false,noPager:true,profile:resolvedOptions.profile??false,path:resolvedOptions.pmRoot};return runContracts(resolvedOptions,global2)}function readRequiredString(args,key){const value=readString(args,key);if(!value){throw new PmCliError(`Missing required argument: ${key}`,64)}return value}const extensionActivationGate=createAsyncReadWriteGate();const activeExtensionScope=new AsyncLocalStorage;function resetActiveExtensionRegistries(){setActiveExtensionHooks(createEmptyExtensionHookRegistry());setActiveExtensionCommands(createEmptyExtensionCommandRegistry());setActiveExtensionParsers(createEmptyExtensionParserRegistry());setActiveExtensionPreflight(createEmptyExtensionPreflightRegistry());setActiveExtensionServices(createEmptyExtensionServiceRegistry());setActiveExtensionRenderers(createEmptyExtensionRendererRegistry());setActiveExtensionRegistrations(createEmptyExtensionRegistrationRegistry())}async function withActiveExtensions(global2,explicitCwd,resolutionCwd,run){return runWithIsolatedExtensionRuntime(()=>explicitCwd===void 0?extensionActivationGate.read(()=>withActiveExtensionsExclusively(global2,resolutionCwd,run)):extensionActivationGate.write(()=>withCwd(explicitCwd,()=>withActiveExtensionsExclusively(global2,resolutionCwd,run))))}async function runWithActiveExtensions(options,run){const explicitCwd=options.cwd;const resolutionCwd=explicitCwd??process.cwd();return withActiveExtensions(globalOptions({path:options.path,noExtensions:options.noExtensions}),explicitCwd,resolutionCwd,()=>activeExtensionScope.run(true,run))}async function withActiveExtensionsExclusively(global2,cwd,run){const pmRoot=resolvePmRoot(cwd,global2.path);if(global2.noExtensions){resetActiveExtensionRegistries();return runWithDiscoveredContextIntentContracts({pmRoot},()=>run(null))}if(!await pathExists(getSettingsPath(pmRoot))){resetActiveExtensionRegistries();return run(null)}let active=null;let activated;try{const settings=await readSettings(pmRoot);const loadResult=await loadExtensions({pmRoot,settings,cwd,noExtensions:false});const activationResult=await activateExtensions({...loadResult,loaded:loadResult.loaded});activated={loadResult,activationResult};setActiveExtensionHooks(activationResult.hooks);setActiveExtensionCommands(activationResult.commands);setActiveExtensionParsers(activationResult.parsers);setActiveExtensionPreflight(activationResult.preflight);setActiveExtensionServices(activationResult.services);setActiveExtensionRenderers(activationResult.renderers);setActiveExtensionRegistrations(activationResult.registrations);active={registrations:activationResult.registrations,commands:activationResult.commands,pmRoot,packages:loadResult.loaded}}catch(error){resetActiveExtensionRegistries();console.error("[pm-sdk] extension activation failed; continuing without active extensions:",error)}try{return await runWithDiscoveredContextIntentContracts({pmRoot,packages:active?.packages},()=>run(active))}finally{resetActiveExtensionRegistries();if(activated){await deactivateExtensions(activated.loadResult,activated.activationResult).catch(()=>void 0)}}}async function dispatchActiveExtensionAction(action,args,options,global2,active){if(!active){throw new PmCliError(`Unsupported native pm action: ${action}`,EXIT_CODE.USAGE)}const normalizedAction=normalizeActionName(action);const definition=active.registrations.commands.find(entry=>normalizeActionName(entry.action)===normalizedAction);const command=definition?.command??active.commands.handlers.find(entry=>normalizeActionName(entry.command)===normalizedAction)?.command;if(!command){throw new PmCliError(`Unsupported native pm action: ${action}`,EXIT_CODE.USAGE)}const handlerResult=await runActiveCommandHandler({command:normalizeCommandPath(command),args:readStringArray(options.args??args.args),options:extensionOptionsFromArgs(args,options),global:global2,pm_root:active.pmRoot,sdk:createExtensionCommandSdk(active.pmRoot,PmClient.forActiveExtensionHost({pmRoot:active.pmRoot,author:typeof global2.author==="string"&&global2.author.trim()?global2.author.trim():"pm-extension"}))});if(!handlerResult.handled){const suffix=handlerResult.warnings.length>0?` (${handlerResult.warnings.join(", ")})`:"";throw new PmCliError(`Unsupported native pm action: ${action}${suffix}`,EXIT_CODE.USAGE)}return handlerResult.result}async function withCwd(cwd,run){const previous=process.cwd();process.chdir(cwd);try{return await run()}finally{process.chdir(previous)}}function resolveSdkActionInput(args){const rawAction=readRequiredString(args,"action");const normalizedAction=normalizeActionName(rawAction);const alias=getOwnHandler(SDK_ACTION_ALIASES,normalizedAction);const action=alias?.action??normalizedAction;const resolvedArgs={...args,action};if(alias?.options!==void 0){resolvedArgs.options={...alias.options,...asRecordClone(args.options)}}if(action==="package"){resolvedArgs.options={...asRecordClone(resolvedArgs.options),vocabulary:"package"}}return{action,args:resolvedArgs}}async function runAction(args){const resolved=resolveSdkActionInput(args);const global2=globalOptions(resolved.args);const invalidateWorkspaceContractsCache=shouldInvalidateWorkspaceContractsCacheAfterAction(resolved.action);const explicitCwd=readString(resolved.args,"cwd");const resolutionCwd=explicitCwd??process.cwd();if(resolved.action==="init"){global2[INIT_INVOCATION_CWD]=resolutionCwd}if(resolved.action!=="init"||global2.path!==void 0||(process.env.PM_PATH?.trim().length??0)>0){global2.path=resolvePmRoot(resolutionCwd,global2.path)}try{if(resolved.action==="history-attest"){return await dispatchAction(resolved.action,resolved.args,global2,null)}if(args[ACTIVE_EXTENSION_HOST_CONTEXT]===true||activeExtensionScope.getStore()===true){return await dispatchAction(resolved.action,resolved.args,global2,null)}return await withActiveExtensions(global2,explicitCwd,resolutionCwd,activeExtensions=>dispatchAction(resolved.action,resolved.args,global2,activeExtensions))}finally{if(invalidateWorkspaceContractsCache){clearWorkspaceContractsCache()}}}function getOwnHandler(handlers,key){return Object.prototype.hasOwnProperty.call(handlers,key)?handlers[key]:void 0}function readMcpTarget(ctx){return readString(ctx.args,"target")??readString(ctx.options,"target")}function requireMcpItemId(ctx,source=ctx.options){return ctx.id??readRequiredString(source,"id")}async function runMcpListAction(ctx){const listOptions=applyContextIntentProjection("list",ctx.options);if(listOptions.compact===void 0&&listOptions.brief===void 0&&listOptions.full===void 0&&listOptions.fields===void 0&&listOptions.includeBody===void 0){listOptions.compact=true}return withQuerySummary(await runList(readString(ctx.args,"status")??readString(listOptions,"status"),listOptions,ctx.global),listOptions)}async function runMcpSearchAction(ctx){const query=readRequiredString(ctx.args,"query");const searchOptions=applyContextIntentProjection("search",ctx.options,[query]);if(searchOptions.compact===void 0&&searchOptions.full===void 0&&searchOptions.fields===void 0){searchOptions.compact=true}return withQuerySummary(await runSearch(query,searchOptions,ctx.global),searchOptions)}async function runMcpCreateAction(ctx){const{changedFields,idOnly,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);return projectMutationResult(await runCreate(runnerOptions,ctx.global),{changedFields,compactEnvelope:changedFields==="compact"&&!idOnly,idOnly})}async function runMcpCopyAction(ctx){const{changedFields,idOnly,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);const copyOptions={...runnerOptions,...runnerOptions.title===void 0&&typeof ctx.args.title==="string"?{title:ctx.args.title}:{},...runnerOptions.message===void 0&&typeof ctx.args.message==="string"?{message:ctx.args.message}:{}};return projectMutationResult(await runCopy(requireMcpItemId(ctx,copyOptions),copyOptions,ctx.global),{changedFields,compactEnvelope:changedFields==="compact"&&!idOnly,idOnly})}async function runMcpUpdateAction(ctx){const{changedFields,idOnly,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);return projectMutationResult(await runUpdate(requireMcpItemId(ctx,runnerOptions),runnerOptions,ctx.global),{changedFields,compactEnvelope:changedFields==="compact"&&!idOnly,idOnly})}function runMcpCommentsAction(ctx){const commentOptions=normalizeAnnotationTransportOptions(ctx.options);const isListing=commentOptions.add===void 0&&commentOptions.stdin===void 0&&commentOptions.file===void 0&&commentOptions.edit===void 0&&commentOptions.delete===void 0;if(isListing){commentOptions.includeMeta=true;if(commentOptions.limit===void 0&&commentOptions.fullHistory!==true){commentOptions.limit="20"}}return runComments(requireMcpItemId(ctx),commentOptions,ctx.global)}function runMcpFilesLookupAction(ctx,paths){return runFilesLookup(runtimeFilesLookupOptions(ctx.options,paths,parseMcpInteger),ctx.global)}function runMcpFilesAction(ctx){const lookupPaths=readStringArray(ctx.options.lookupPath);if(lookupPaths&&lookupPaths.length>0){return runMcpFilesLookupAction(ctx,lookupPaths)}const fileId=requireMcpItemId(ctx);return ctx.options.discover===true?runFilesDiscover(fileId,withFilesDiscoveryOptions(ctx.options),ctx.global):runFiles(fileId,withAddNoteOption(ctx.options),ctx.global)}function runMcpTelemetryAction(ctx){return runTelemetry({subcommand:readString(ctx.args,"subcommand")??readString(ctx.options,"subcommand"),limit:resolveRuntimeLimit(ctx.args,ctx.options)},ctx.global)}function runMcpHealthAction(ctx){const healthOptions={...ctx.options};if(healthOptions.brief===void 0&&healthOptions.summary===void 0&&healthOptions.full===void 0){healthOptions.summary=true}return runHealth(ctx.global,healthOptions)}function runMcpConfigAction(ctx){const configAction=readString(ctx.args,"configAction")??readString(ctx.options,"configAction")??readString(ctx.options,"action");if(configAction===void 0)throw new PmCliError("Missing required argument: configAction",64);const value=readString(ctx.args,"value")??readString(ctx.options,"value");const options=readString(ctx.options,"policy")!==void 0&&value!==void 0?{...ctx.options,value}:ctx.options;return runConfig(readString(ctx.args,"scope")??readString(ctx.options,"scope")??"project",configAction,readString(ctx.args,"key")??readString(ctx.options,"key"),options,ctx.global,readString(ctx.options,"policy")===void 0?value:void 0)}function runMcpActivityAction(ctx){const options=ctx.options;return runActivity(normalizeActivityProjectionOptions(options),ctx.global)}function parseMcpIntegerPrefix(value,label){if(typeof value==="number"){if(!Number.isFinite(value)||!Number.isInteger(value)){throw new PmCliError(`${label} must be a finite integer.`,64)}return value}if(typeof value==="string"&&value.trim().length>0){const trimmed=value.trim();if(!/^[+-]?\d+(?:st|nd|rd|th)?$/i.test(trimmed)){throw new PmCliError(`${label} must be a finite integer.`,64)}const parsed=Number.parseInt(trimmed,10);if(!Number.isInteger(parsed)){throw new PmCliError(`${label} must be a finite integer.`,64)}return parsed}return void 0}function runMcpPlanAction(ctx){const subcommand=readString(ctx.args,"subcommand")??readRequiredString(ctx.options,"subcommand");const planRecord=ctx.options;return runPlan({subcommand,id:typeof ctx.id==="string"?ctx.id:typeof planRecord.id==="string"?planRecord.id:void 0,stepRef:readMcpPlanStepRef(ctx),reorderTo:parseMcpIntegerPrefix(planRecord.reorderTo??ctx.args.reorderTo,"plan reorderTo"),options:ctx.options,global:ctx.global})}function readMcpPlanStepRef(ctx){return typeof ctx.options.stepRef==="string"?ctx.options.stepRef:typeof ctx.args.stepRef==="string"?ctx.args.stepRef:void 0}function createMcpSchemaContext(ctx){const subcommand=readString(ctx.args,"subcommand")??readRequiredString(ctx.options,"subcommand");const aliasSource=ctx.args.alias??ctx.options.alias;return{ctx,subcommand:subcommand.trim().toLowerCase(),name:readString(ctx.args,"name")??readString(ctx.options,"name"),author:readString(ctx.args,"author")??readString(ctx.options,"author"),force:ctx.args.force===true||ctx.options.force===true,aliases:aliasSource===void 0?void 0:readStringArray(aliasSource)}}function runMcpSchemaReadOrRemoveAction(schema2){const{ctx,subcommand,name,author,force}=schema2;const simpleHandlers={list:()=>runSchemaList(ctx.global),show:()=>runSchemaShow(name,ctx.global),"show-status":()=>runSchemaShowStatus(name,ctx.global),"list-fields":()=>runSchemaListFields(ctx.global),"show-field":()=>runSchemaShowField(name,ctx.global),"remove-type":()=>runSchemaRemoveType(name,{author,force},ctx.global),"remove-field":()=>runSchemaRemoveField(name,{author,force},ctx.global),"remove-status":()=>runSchemaRemoveStatus(name,{author,force},ctx.global),"apply-preset":()=>runSchemaApplyPreset(readString(ctx.args,"typePreset")??readString(ctx.options,"typePreset"),{author,force},ctx.global)};const handler=getOwnHandler(simpleHandlers,subcommand);return handler?handler():null}function runMcpSchemaAddFieldAction(schema2){const{ctx,name,author,force,aliases}=schema2;const commandsSource=ctx.args.commands??ctx.options.commands;const requiredTypesSource=ctx.args.requiredTypes??ctx.options.requiredTypes;return runSchemaAddField(name,{type:readString(ctx.args,"fieldType")??readString(ctx.options,"fieldType"),commands:commandsSource===void 0?void 0:readStringArray(commandsSource),description:readString(ctx.args,"description")??readString(ctx.options,"description"),cliFlag:readString(ctx.args,"cliFlag")??readString(ctx.options,"cliFlag"),alias:aliases,required:ctx.args.required===true||ctx.options.required===true,requiredOnCreate:ctx.args.requiredOnCreate===true||ctx.options.requiredOnCreate===true,allowUnset:!(ctx.args.allowUnset===false||ctx.options.allowUnset===false),requiredTypes:requiredTypesSource===void 0?void 0:readStringArray(requiredTypesSource),author,force},ctx.global)}function runMcpSchemaAddStatusAction(schema2){const{ctx,name,author,force,aliases}=schema2;const roleSource=ctx.args.role??ctx.options.role;return runSchemaAddStatus(name,{role:roleSource===void 0?void 0:readStringArray(roleSource),alias:aliases,description:readString(ctx.args,"description")??readString(ctx.options,"description"),order:parseMcpInteger(ctx.args.order??ctx.options.order,"schema add-status order"),author,force},ctx.global)}function runMcpSchemaAddTypeAction(schema2){const{ctx,name,author,force,aliases}=schema2;return runSchemaAddType(name,{description:readString(ctx.args,"description")??readString(ctx.options,"description"),defaultStatus:readString(ctx.args,"defaultStatus")??readString(ctx.args,"default_status")??readString(ctx.options,"defaultStatus")??readString(ctx.options,"default_status"),folder:readString(ctx.args,"folder")??readString(ctx.options,"folder"),alias:aliases,author,force},ctx.global)}function runMcpSchemaMigrationAction(schema2){const{ctx,subcommand,name,author,force}=schema2;const to=readString(ctx.args,"to")??readRequiredString(ctx.options,"to");const migrationId=readString(ctx.args,"migrationId")??readString(ctx.args,"migration_id")??readString(ctx.options,"migrationId")??readString(ctx.options,"migration_id");const fieldTypeScope=readString(ctx.args,"fieldTypeScope")??readString(ctx.options,"fieldTypeScope")??readString(ctx.args,"type")??readString(ctx.options,"type");const request=subcommand==="rename-type"?{kind:"rename-type",from:name??"",to}:subcommand==="rename-field"?{kind:"rename-field",from:name??"",to,...fieldTypeScope===void 0?{}:{type:fieldTypeScope}}:{kind:"remap-status",from:name??"",to};return runSchemaEvolutionMigration(request,{migrationId,dryRun:ctx.args.dryRun===true||ctx.options.dryRun===true,author,force},ctx.global)}function runMcpSchemaAction(ctx){const schema2=createMcpSchemaContext(ctx);const policyAction=WORKFLOW_POLICY_ACTIONS.find(action=>action===schema2.subcommand);if(policyAction)return runWorkflowPolicyAction(policyAction,schema2.name,{definition:ctx.args.definition??ctx.options.definition,policy:readString(ctx.args,"policy")??readString(ctx.options,"policy"),message:readString(ctx.args,"message")??readString(ctx.options,"message"),author:schema2.author,dryRun:ctx.args.dryRun===true||ctx.options.dryRun===true},ctx.global);const simpleResult=runMcpSchemaReadOrRemoveAction(schema2);if(simpleResult!==null){return simpleResult}if(["rename-type","rename-field","remap-status"].includes(schema2.subcommand)){return runMcpSchemaMigrationAction(schema2)}if(schema2.subcommand==="add-field"){return runMcpSchemaAddFieldAction(schema2)}if(schema2.subcommand==="add-status"){return runMcpSchemaAddStatusAction(schema2)}if(schema2.subcommand==="add-type"){if(ctx.args.infer===true||ctx.options.infer===true){return runSchemaInferTypes({minCount:parseMcpInteger(ctx.args.minCount??ctx.options.minCount,"schema infer minCount"),apply:ctx.args.apply===true||ctx.options.apply===true,author:schema2.author,force:schema2.force},ctx.global)}return runMcpSchemaAddTypeAction(schema2)}throw createUnknownSubcommandError({command_path:"schema",token:schema2.subcommand,allowed:SCHEMA_SUBCOMMANDS,exit_code:64})}function runMcpProfileAction(ctx){const subcommand=readString(ctx.args,"subcommand")??readRequiredString(ctx.options,"subcommand");const normalizedSubcommand=subcommand.trim().toLowerCase();const profileName=readString(ctx.args,"name")??readString(ctx.options,"name");const handlers={list:()=>runProfileList(),show:()=>runProfileShow(profileName),lint:()=>runProfileLint(profileName),apply:()=>runProfileApply(profileName,{dryRun:ctx.args.dryRun===true||ctx.options.dryRun===true,author:readString(ctx.args,"author")??readString(ctx.options,"author"),force:ctx.args.force===true||ctx.options.force===true},ctx.global)};const handler=getOwnHandler(handlers,normalizedSubcommand);if(!handler){throw createUnknownSubcommandError({command_path:"profile",token:subcommand,allowed:PROFILE_SUBCOMMANDS,exit_code:64})}return handler()}async function runMcpAppendAction(ctx){const{changedFields,idOnly,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);return projectMutationResult(await runAppend(requireMcpItemId(ctx,runnerOptions),runnerOptions,ctx.global),{changedFields,compactEnvelope:changedFields==="compact"&&!idOnly,idOnly})}async function runMcpUpdateManyAction(ctx){const{changedFields,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);return projectMutationResult(await runUpdateMany(updateManyOptionsFromFlat(runnerOptions),ctx.global),{changedFields})}async function runMcpCloseManyAction(ctx){const{changedFields,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);const topLevelReason=readString(ctx.args,"reason");const closeManyRunnerOptions=topLevelReason!==void 0&&runnerOptions.reason===void 0?{...runnerOptions,reason:topLevelReason}:{...runnerOptions};if(ctx.force&&closeManyRunnerOptions.force===void 0){closeManyRunnerOptions.force=true}return projectMutationResult(await runCloseMany(closeManyOptionsFromFlat(closeManyRunnerOptions),ctx.global),{changedFields})}async function runMcpRestoreAction(ctx){const{changedFields,idOnly,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);const target=readString(runnerOptions,"target")??readRequiredString(ctx.args,"target");return projectMutationResult(await runRestore(requireMcpItemId(ctx,runnerOptions),target,runnerOptions,ctx.global),{changedFields,compactEnvelope:changedFields==="compact"&&!idOnly,idOnly})}async function runMcpPauseTaskAction(ctx){return runPauseTask(requireMcpItemId(ctx),mutationOptionsWithOverrides(ctx.options,{force:ctx.force}),ctx.global)}async function runMcpCloseTaskAction(ctx){const id=requireMcpItemId(ctx);const closeReason=readString(ctx.args,"reason")??readString(ctx.args,"text")??readString(ctx.options,"reason")??readString(ctx.options,"text");return runCloseTask(id,closeReason,mutationOptionsWithOverrides(ctx.options,{force:ctx.force}),ctx.global)}function runMcpGraphAction(ctx){const merged={...ctx.args,...ctx.options};return runGraph(readRequiredString(merged,"subcommand"),readString(merged,"id")??ctx.id,readString(merged,"target"),graphOptionsFromFlat(merged),ctx.global)}function runMcpHistoryAuthorAcknowledgeAction(ctx){return acknowledgeUnknownAuthorHistoryEventsFromTransport(resolvePmRoot(process.cwd(),ctx.global.path),{...ctx.args,...ctx.options})}const SDK_ACTION_HANDLERS={init:ctx=>runInit(readString(ctx.args,"prefix"),ctx.global,ctx.options),context:ctx=>runContext(applyContextIntentProjection("context",ctx.options),ctx.global),next:ctx=>runNext(applyContextIntentProjection("next",ctx.options),ctx.global),eval:runRuntimeEvalAction,events:runRuntimeEventsAction,merge:runRuntimeMergeAction,workspace:runRuntimeWorkspaceAction,meet:runRuntimeSchedulingAction,event:runRuntimeSchedulingAction,remind:runRuntimeSchedulingAction,list:runMcpListAction,get:ctx=>{const id=requireMcpItemId(ctx);return runGet(id,ctx.global,applyContextIntentProjection("get",ctx.options,[id]))},search:runMcpSearchAction,duplicates:ctx=>{const status=typeof ctx.options.status==="string"?[ctx.options.status]:readStringArray(ctx.options.status);return runDuplicates(ctx.global,{exhaustive:ctx.options.exhaustive===true,...status.length===0?{}:{status},since:readString(ctx.options,"since"),threshold:typeof ctx.options.threshold==="number"?ctx.options.threshold:void 0,limit:ctx.options.limit==="default"?void 0:parseMcpInteger(ctx.options.limit,"limit")})},create:runMcpCreateAction,copy:runMcpCopyAction,focus:ctx=>runFocus(ctx.id,{clear:ctx.options.clear===true||ctx.args.clear===true},ctx.global),update:runMcpUpdateAction,"item-reopen":runMcpReopenAction,restore:runMcpRestoreAction,claim:runMcpClaimAction,release:ctx=>ctx.options.pause===true?runMcpPauseTaskAction(ctx):runRelease(requireMcpItemId(ctx),ctx.force,ctx.global,ctx.options),"start-task":ctx=>runStartTask(requireMcpItemId(ctx),mutationOptionsWithOverrides(ctx.options,{force:ctx.force}),ctx.global),"pause-task":runMcpPauseTaskAction,"close-task":runMcpCloseTaskAction,close:runMcpCloseAction,comments:runMcpCommentsAction,notes:ctx=>runNotes(requireMcpItemId(ctx),normalizeAnnotationTransportOptions(ctx.options),ctx.global),learnings:ctx=>runLearnings(requireMcpItemId(ctx),normalizeAnnotationTransportOptions(ctx.options),ctx.global),files:runMcpFilesAction,docs:ctx=>runDocs(requireMcpItemId(ctx),withAddNoteOption(ctx.options),ctx.global),test:ctx=>runTest(requireMcpItemId(ctx),ctx.options,ctx.global),"test-all":ctx=>runTestAll(ctx.options,ctx.global),telemetry:runMcpTelemetryAction,validate:ctx=>runValidate(ctx.options,ctx.global,{runUpdate:(id,options,global2)=>runUpdate(id,options,global2)}),health:runMcpHealthAction,assurance:ctx=>runAssuranceDispatch(ctx.args,ctx.options,ctx.global),contracts:ctx=>runContracts(ctx.options,ctx.global),config:runMcpConfigAction,activity:runMcpActivityAction,aggregate:ctx=>runAggregate(ctx.options,ctx.global),extension:ctx=>runExtension(readMcpTarget(ctx),ctx.options,ctx.global),package:ctx=>runExtension(readMcpTarget(ctx),ctx.options,ctx.global),install:ctx=>runExtension(readMcpTarget(ctx),{...ctx.options,install:true},ctx.global),upgrade:ctx=>runUpgrade(readMcpTarget(ctx),ctx.options,ctx.global),delete:ctx=>runDelete(requireMcpItemId(ctx),ctx.options,ctx.global),deps:ctx=>runDeps(requireMcpItemId(ctx),ctx.options,ctx.global),graph:runMcpGraphAction,"files-discover":ctx=>runFilesDiscover(requireMcpItemId(ctx),ctx.options,ctx.global),"files-lookup":ctx=>runMcpFilesLookupAction(ctx,readStringArray(ctx.options.paths)),history:ctx=>runHistory(requireMcpItemId(ctx),ctx.options,ctx.global),"history-redact":ctx=>runHistoryRedact(requireMcpItemId(ctx),ctx.options,ctx.global),"history-repair":runMcpHistoryRepairAction,"history-compact":runMcpHistoryCompactAction,"history-attest":ctx=>runHistoryAttest(ctx.options,ctx.global),"history-author-acknowledge":runMcpHistoryAuthorAcknowledgeAction,plan:runMcpPlanAction,schema:runMcpSchemaAction,profile:runMcpProfileAction,stats:ctx=>runStats(ctx.global,statsCommandOptionsFromRuntime(ctx.options)),append:runMcpAppendAction,"update-many":runMcpUpdateManyAction,"close-many":runMcpCloseManyAction,gc:ctx=>runGc(ctx.global,ctx.options)};function analyzeSdkActionCoverage(actions=PM_TOOL_ACTIONS){return actions.map(action=>{const normalized=normalizeActionName(action);const alias=getOwnHandler(SDK_ACTION_ALIASES,normalized);const resolvedAction=alias?.action??normalized;const covered=getOwnHandler(SDK_ACTION_HANDLERS,resolvedAction)!==void 0;return{action,resolved_action:resolvedAction,covered,route:covered?alias?"alias":"native":"missing"}})}async function dispatchAction(action,args,global2,activeExtensions){const options=optionsWithAuthor(args,action);validateReadOutputOptions(action,options);normalizeReadOutputIncludeModeOptions(action,options);const ctx={action,args,options,id:readString(args,"id"),force:args.force===true||options.force===true,global:global2,activeExtensions};const handler=getOwnHandler(SDK_ACTION_HANDLERS,action);const result=handler?await handler(ctx):await dispatchActiveExtensionAction(action,args,options,global2,activeExtensions);if(action==="history-attest"){return result}else{options.resolvedOutputFormat="json";const projected=attachReadOutputContracts(action,options,result);await finalizeContextUsageEgress(resolvePmRoot(process.cwd(),global2.path),projected);return projected}}const actionRunnerTestHooks={closeManyOptionsFromFlat,extensionOptionsFromArgs,globalOptions,mutationListOptions,normalizeActionName,normalizeCommandPath,normalizeMcpUpdateOptions,normalizeMcpOptionsArrays,optionsWithAuthor,readRequiredString,readScalarString,readScalarStringAllowBlank,readStringArray,updateManyOptionsFromFlat,withAddNoteOption,withFilesDiscoveryOptions,withMutationCompaction};if(process.env.NODE_ENV==="test"||process.env.VITEST!==void 0||process.env.VITEST_WORKER_ID!==void 0){globalThis.__pmCliActionRunnerTestHooks=actionRunnerTestHooks}export{BASELINE_ITEM_FORMAT_VERSION,BUILTIN_ITEM_TYPE_VALUES,CONFIDENCE_TEXT_VALUES,CONTEXT_OUTPUT_VALUES,CURRENT_ITEM_FORMAT_VERSION,DEFAULT_TERMINAL_TRANSITION_POLICY,DEPENDENCY_KIND_VALUES,EXIT_CODE,HISTORY_EVENT_CLASSIFICATION_VERSION,ISSUE_SEVERITY_VALUES,ITEM_TYPE_VALUES,MAINTENANCE_HISTORY_OPERATIONS,NEXT_OUTPUT_VALUES,PM_CLI_EXPECTED_ERROR_NAME,PM_GITIGNORE_END,PM_GITIGNORE_START,PmCliError2 as PmCliError,PmClient,PmCompleteListValidationError,RISK_VALUES,SEARCH_EXTENSION_FLAG_DEFINITIONS,STATUS_VALUES,SUBSTANTIVE_HISTORY_OPERATIONS,acquireLock,aggregate,analyzeSdkActionCoverage,append,appendHistoryEntry,applyTerminalOrderingPolicy,assertCompleteListResult,canonicalDocument,certifyCompleteListResult2 as certifyCompleteListResult,claim,claimNext,classifyHistoryEvent,classifyItemFormatVersion,clearWorkspaceContractsCache2 as clearWorkspaceContractsCache,close,closeItem,closeTask,comments,commitImportedItem,config,context,copy,create,createCompleteListOptions2 as createCompleteListOptions,createHistoryEntry,createPmCliExpectedError,deleteItem,deps,docs,duplicates,effectiveItemFormatVersion,emptyImportedDocument,ensurePmGitignore,ensureTrackerInitialized,extension,extensionActivate,extensionDeactivate,extensionList,files,filesDiscover,filesLookup,focus,gc,generateItemId,get,getActiveExtensionRegistrations,getContracts,getHistoryPath,getItemPath,getPmGitignoreBlock,getSettingsPath2 as getSettingsPath,getWorkspaceContracts,graph,health,historyCompact,historyCompactBulk,historyRedact,historyRepair,historyRepairAll,init,inspectCompleteListResult,isPmCliExpectedError,isTerminalStatus,isTimestampLiteral,jaccardSimilarity,learnings,list,listAllComplete,listAllItemMetadata,listAllItemMetadataLight,loadCreateTemplateOptions,locateItem,next,normalizeItemFormatVersion,normalizeItemId,normalizeItemMetadata,normalizeRawItemId,normalizeSimilarityText,normalizeStatusInput,notes,nowIso,packageActivate,packageCatalog,packageDeactivate,packageDescribe,packageDoctor,packageInstall,packageLifecycle,packageList,packageManage,packageReload,packageUninstall,parseTags,pathExists2 as pathExists,pauseTask,profile,profileApply,profileLint,profileList,profileShow,readBooleanOption,readCsvListOption,readFileIfExists,readLocatedItem,readRequiredString,readSettings2 as readSettings,readStringOption,release,removeFileIfExists,renderCalendarMarkdown,renderCalendarToon,renderGuideMarkdown,reopen,requireTerminalReason,resolveCalendarOutputFormat,resolveGuideOutputFormat,resolveImplicitPmRoot,resolveItemTypeRegistry,resolvePmRoot2 as resolvePmRoot,resolveRuntimeFieldRegistry,resolveRuntimeStatusRegistry,resolveTerminalReason,restore,runAction,runActiveOnReadHooks,runActiveOnWriteHooks,runAggregate2 as runAggregate,runCalendar,runClose,runCloseTask2 as runCloseTask,runCompletion,runContext2 as runContext,runCopy2 as runCopy,runDelete2 as runDelete,runDuplicates2 as runDuplicates,runFocus2 as runFocus,runGet2 as runGet,runGuide,runList2 as runList,runNext2 as runNext,runPauseTask2 as runPauseTask,runReindex,runReopen,runRestore2 as runRestore,runSearch2 as runSearch,runStartTask2 as runStartTask,runStats2 as runStats,runTemplatesList,runTemplatesSave,runTemplatesShow,runTestRunsList,runTestRunsLogs,runTestRunsResume,runTestRunsStatus,runTestRunsStop,runUpdate2 as runUpdate,runWithActiveExtensions,scanItemFormatVersions,schema,schemaAddField,schemaAddStatus,schemaAddType,schemaApplyPreset,schemaInferTypes,schemaList,schemaListFields,schemaRemapStatus,schemaRemoveField,schemaRemoveStatus,schemaRemoveType,schemaRenameField,schemaRenameType,schemaShow,schemaShowField,schemaShowStatus,scoreItemSimilarity,search,selectImportAuthor,serializeItemDocument,splitFrontMatter,startTask,stats,toEstimatedMinutesValue,toImportBoolean,toImportConfidence,toImportInteger,toImportLinkedDocs,toImportLinkedFiles,toImportLinkedTests,toImportLogEntries,toImportNormalizedEnum,toImportNumberMap,toImportPriority,toImportStatus,toImportStringList,toImportStringMap,toImportTags,toNonEmptyImportString,tokenizeSimilarityText,update,upgrade,validate,writeFileAtomic};
1
+ !(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]="2a537d27-e794-5aa6-946f-4b2a3102b0ab")}catch(e2){}})();import{PM_GITIGNORE_END,PM_GITIGNORE_START,ensurePmGitignore,getPmGitignoreBlock}from"./workspace.js";import{SEARCH_EXTENSION_FLAG_DEFINITIONS}from"./extension-contracts.js";export*from"./cli-contracts/agent-output-contracts.js";import{AsyncLocalStorage}from"node:async_hooks";import{createEmptyExtensionCommandRegistry,createEmptyExtensionHookRegistry,createEmptyExtensionParserRegistry,createEmptyExtensionPreflightRegistry,createEmptyExtensionRegistrationRegistry,createEmptyExtensionRendererRegistry,createEmptyExtensionServiceRegistry}from"../core/extensions/extension-registries.js";import{activateExtensions,deactivateExtensions,loadExtensions,runActiveCommandHandler,runWithIsolatedExtensionRuntime,setActiveExtensionCommands,setActiveExtensionHooks,setActiveExtensionParsers,setActiveExtensionPreflight,setActiveExtensionRegistrations,setActiveExtensionRenderers,setActiveExtensionServices}from"../core/extensions/index.js";import{pathExists}from"../core/fs/fs-utils.js";import{projectMutationResult}from"../core/output/mutation-projection.js";import{withQuerySummary}from"../core/output/query-summary.js";import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";import{asRecordClone}from"../core/shared/primitives.js";import{createAsyncReadWriteGate}from"../core/shared/serial-queue.js";import{getSettingsPath,resolvePmRoot}from"../core/store/paths.js";import{readSettings}from"../core/store/settings.js";import{listClientItemMetadataLight}from"./query/light-metadata.js";import{certifyCompleteListResult,createCompleteListOptions}from"./query/complete-list.js";import{PmCompleteListValidationError,assertCompleteListResult,certifyCompleteListResult as certifyCompleteListResult2,createCompleteListOptions as createCompleteListOptions2,inspectCompleteListResult}from"./query/complete-list.js";import{getWorkspaceContracts}from"./query/workspace-contracts.js";import{PM_TOOL_ACTIONS}from"./cli-contracts/enum-contracts.js";import{clearWorkspaceContractsCache}from"./workspace-contracts-cache.js";import{SDK_ACTION_ALIASES}from"./runtime-action-aliases.js";import{createExtensionCommandSdk}from"./extension-command-context.js";import{createUnknownSubcommandError}from"./agent/subcommand-recovery.js";import{applyContextIntentProjection,attachReadOutputContracts}from"./context-intent-contracts.js";import{finalizeContextUsageEgress}from"./context/usage-egress.js";import{runWithDiscoveredContextIntentContracts}from"./context-intent-runtime.js";import{normalizeReadOutputIncludeModeOptions,validateReadOutputOptions}from"./read-output-contracts.js";import{clearWorkspaceContractsCache as clearWorkspaceContractsCache2}from"./workspace-contracts-cache.js";import{normalizeActivityProjectionOptions,runActivity}from"./query/activity.js";import{runAssuranceDispatch}from"./governance/assurance-action.js";import{WORKFLOW_POLICY_ACTIONS,runWorkflowPolicyAction}from"./governance/workflow-policy.js";export*from"./governance/workflow-policy.js";import{runAggregate}from"./query/aggregate.js";import{runAppend}from"./lifecycle/append.js";import{runStartTask,runPauseTask,runCloseTask}from"./lifecycle/task-composition.js";import{runCloseMany}from"./lifecycle/close-many.js";import{normalizeAnnotationTransportOptions}from"./annotations.js";import{runComments}from"./comments.js";import{runHistory}from"./query/history.js";import{runHistoryAttest}from"./history/attestation-command.js";import{runLearnings}from"./learnings.js";import{runNotes}from"./notes.js";import{runUpdateMany}from"./lifecycle/update-many.js";import{runUpgrade}from"./governance/upgrade.js";import{runCreate}from"./lifecycle/create.js";import{runUpdate}from"./lifecycle/update.js";import{runPlan}from"./lifecycle/plan.js";import{runContext}from"./query/context.js";import{runNext}from"./query/next.js";import{runCopy}from"./lifecycle/copy.js";import{runDelete}from"./lifecycle/delete.js";import{runRestore}from"./lifecycle/restore.js";import{runFocus}from"./lifecycle/focus.js";import{runGet}from"./query/get.js";import{runGc}from"./governance/gc.js";import{runHealth}from"./governance/health.js";import{runValidate}from"./governance/validate.js";import{runExtension}from"./extension.js";import{runConfig}from"./config.js";import{INIT_INVOCATION_CWD,runInit}from"./init.js";import{runRuntimeEvalAction,runRuntimeEventsAction,runRuntimeMergeAction,runRuntimeSchedulingAction,runRuntimeWorkspaceAction}from"./runtime-extended-actions.js";import{acknowledgeUnknownAuthorHistoryEventsFromTransport}from"./author-attribution.js";import{PROFILE_SUBCOMMANDS,runProfileApply,runProfileLint,runProfileList,runProfileShow}from"./profile.js";import{runHistoryRedact}from"./history-redact.js";import{runMcpHistoryCompactAction,runMcpHistoryRepairAction}from"./history-mcp.js";import{runMcpClaimAction,runMcpCloseAction,runMcpReopenAction,runMcpReleaseAction,runMcpTaskCompositionAction}from"./lifecycle/mcp-actions.js";import{actionGlobalOptions as globalOptions,closeManyOptionsFromFlat,extensionOptionsFromArgs,graphOptionsFromFlat,mutationListOptions,mutationOptionsWithOverrides,normalizeActionName,normalizeCommandPath,normalizeMcpOptionsArrays,normalizeMcpUpdateOptions,optionsWithAuthor,parseRuntimeInteger as parseMcpInteger,readRuntimeScalarString as readScalarString,readRuntimeScalarStringAllowBlank as readScalarStringAllowBlank,readRuntimeString as readString,readRuntimeStringArray as readStringArray,resolveRuntimeLimit,shouldInvalidateWorkspaceContractsCacheAfterAction,updateManyOptionsFromFlat,withAddNoteOption,withFilesDiscoveryOptions,withMutationCompaction}from"./runtime-input.js";import{runDeps}from"./dependencies.js";import{runDocs}from"./docs.js";import{runGraph}from"./graph/run.js";import{runFiles,runFilesDiscover,runFilesLookup}from"./files.js";import{runtimeFilesLookupOptions}from"./traceability/runtime-files-lookup.js";import{runContracts}from"./cli-contracts/runtime-contracts.js";import{runList}from"./query/list.js";import{runSearch}from"./query/search.js";import{runStats}from"./stats.js";import{statsCommandOptionsFromRuntime}from"./runtime-stats-options.js";import{runDuplicates}from"./duplicates.js";import{runTelemetry}from"./telemetry.js";import{runTest}from"./test/execution.js";import{runTestAll}from"./test/batch.js";import{SCHEMA_SUBCOMMANDS,runSchemaAddField,runSchemaAddStatus,runSchemaAddType,runSchemaApplyPreset,runSchemaInferTypes,runSchemaList,runSchemaListFields,runSchemaEvolutionMigration,runSchemaRemoveField,runSchemaRemoveStatus,runSchemaRemoveType,runSchemaShow,runSchemaShowField,runSchemaShowStatus}from"./schema.js";import{getActiveExtensionRegistrations,runActiveOnReadHooks,runActiveOnWriteHooks}from"../core/extensions/index.js";import{pathExists as pathExists2,readFileIfExists,removeFileIfExists,writeFileAtomic}from"../core/fs/fs-utils.js";import{appendHistoryEntry,createHistoryEntry}from"../core/history/history.js";import{classifyHistoryEvent,HISTORY_EVENT_CLASSIFICATION_VERSION,MAINTENANCE_HISTORY_OPERATIONS,SUBSTANTIVE_HISTORY_OPERATIONS}from"../core/history/event-classification.js";import{generateItemId,normalizeItemId,normalizeRawItemId}from"../core/item/id.js";import{readBooleanOption,readCsvListOption,readStringOption}from"./package-runtime-options.js";import{PM_CLI_EXPECTED_ERROR_NAME,createPmCliExpectedError,isPmCliExpectedError}from"./errors.js";import{commitImportedItem,emptyImportedDocument,ensureTrackerInitialized,selectImportAuthor,toEstimatedMinutesValue,toImportBoolean,toImportConfidence,toImportInteger,toImportLinkedDocs,toImportLinkedFiles,toImportLinkedTests,toImportLogEntries,toImportNormalizedEnum,toImportNumberMap,toImportPriority,toImportStatus,toImportStringList,toImportStringMap,toImportTags,toNonEmptyImportString}from"./package-import-adapters.js";import{canonicalDocument,normalizeItemMetadata,serializeItemDocument,splitFrontMatter}from"../core/item/item-format.js";import{BASELINE_ITEM_FORMAT_VERSION,CURRENT_ITEM_FORMAT_VERSION,classifyItemFormatVersion,effectiveItemFormatVersion,normalizeItemFormatVersion,scanItemFormatVersions}from"../core/item/item-format-version.js";import{parseTags}from"../core/item/parse.js";import{isTerminalStatus,normalizeStatusInput}from"../core/item/status.js";import{resolveItemTypeRegistry}from"../core/item/type-registry.js";import{acquireLock}from"../core/lock/lock.js";import{resolveRuntimeFieldRegistry,resolveRuntimeStatusRegistry}from"../core/schema/runtime-schema.js";import{PmCliError as PmCliError2}from"../core/shared/errors.js";import{isTimestampLiteral,nowIso}from"../core/shared/time.js";import{jaccardSimilarity,normalizeSimilarityText,scoreItemSimilarity,tokenizeSimilarityText}from"./similarity-scoring.js";import{listAllItemMetadata,listAllItemMetadataLight,locateItem,readLocatedItem}from"../core/store/item-store.js";import{getHistoryPath,getItemPath,getSettingsPath as getSettingsPath2,resolveImplicitPmRoot,resolvePmRoot as resolvePmRoot2}from"../core/store/paths.js";import{readSettings as readSettings2}from"../core/store/settings.js";import{runAggregate as runAggregate2}from"./query/aggregate.js";import{CONTEXT_OUTPUT_VALUES,runContext as runContext2}from"./query/context.js";import{runGet as runGet2}from"./query/get.js";import{runList as runList2}from"./query/list.js";import{closeItem,runClose}from"./lifecycle/close.js";import{runCopy as runCopy2}from"./lifecycle/copy.js";import{runDelete as runDelete2}from"./lifecycle/delete.js";import{runFocus as runFocus2}from"./lifecycle/focus.js";import{runRestore as runRestore2}from"./lifecycle/restore.js";import{DEFAULT_TERMINAL_TRANSITION_POLICY,applyTerminalOrderingPolicy,requireTerminalReason,resolveTerminalReason}from"./lifecycle-policy.js";import{runUpdate as runUpdate2}from"./lifecycle/update.js";import{runReopen}from"./lifecycle/reopen.js";import{NEXT_OUTPUT_VALUES,runNext as runNext2}from"./query/next.js";import{runSearch as runSearch2}from"./query/search.js";import{runStats as runStats2}from"./stats.js";import{runDuplicates as runDuplicates2}from"./duplicates.js";import{renderCalendarMarkdown,renderCalendarToon,resolveCalendarOutputFormat,runCalendar}from"./query/calendar.js";import{renderGuideMarkdown,resolveGuideOutputFormat,runGuide}from"./guide.js";import{runCompletion}from"./completion.js";import{runReindex}from"./governance/reindex.js";import{loadCreateTemplateOptions,runTemplatesList,runTemplatesSave,runTemplatesShow}from"./templates.js";import{runTestRunsList,runTestRunsLogs,runTestRunsResume,runTestRunsStatus,runTestRunsStop}from"./test/runs.js";import{CONFIDENCE_TEXT_VALUES,DEPENDENCY_KIND_VALUES,BUILTIN_ITEM_TYPE_VALUES,ISSUE_SEVERITY_VALUES,ITEM_TYPE_VALUES,RISK_VALUES,STATUS_VALUES}from"../types/index.js";const ACTIVE_EXTENSION_HOST_CONTEXT=Symbol("pm.active-extension-host-context");function splitFullClientMutationOptions(options){return{fullChangedFields:true,options}}class PmClient{defaults;constructor(options={}){this.defaults={...options.pmRoot===void 0?{}:{path:options.pmRoot},...options.cwd===void 0?{}:{cwd:options.cwd},...options.author===void 0?{}:{author:options.author},...options.noExtensions===void 0?{}:{noExtensions:options.noExtensions}}}static forActiveExtensionHost(options){const client=new PmClient({...options,noExtensions:true});client.defaults[ACTIVE_EXTENSION_HOST_CONTEXT]=true;return client}run(action,args={}){return runAction({...this.defaults,...args,action})}runTyped(action,args={}){return this.run(action,args)}context(options={}){return this.runTyped("context",{options})}listAllItemMetadataLight(){return listClientItemMetadataLight(this.defaults.path,this.defaults.cwd)}list(options={}){return this.runTyped("list",{options})}async listAllComplete(options={}){return certifyCompleteListResult(await this.list(createCompleteListOptions(options)))}search(query,options={}){return this.runTyped("search",{query,options})}get(id,options={}){return this.runTyped("get",{id,options})}next(options={}){return this.runTyped("next",{options})}aggregate(options={}){return this.runTyped("aggregate",{options})}stats(options={}){return this.runTyped("stats",{options})}duplicates(options={}){return this.runTyped("duplicates",{options})}comments(id,options={}){return this.runTyped("comments",{id,options})}notes(id,options={}){return this.runTyped("notes",{id,options})}learnings(id,options={}){return this.runTyped("learnings",{id,options})}files(id,options={}){return this.runTyped("files",{id,options})}filesDiscover(id,options={}){return this.runTyped("files-discover",{id,options})}filesLookup(options){return this.runTyped("files-lookup",{options})}docs(id,options={}){return this.runTyped("docs",{id,options})}deps(id,options={}){return this.runTyped("deps",{id,options})}graph(subcommand,ids={},options={}){return this.runTyped("graph",{subcommand,...ids,options})}append(id,body,options={}){return this.runTyped("append",{id,...splitFullClientMutationOptions(mutationOptionsWithOverrides(options,{body}))})}init(prefix,options={}){return this.runTyped("init",{...prefix===void 0?{}:{prefix},options})}config(scope,configAction,key,value,options={}){return this.runTyped("config",{scope,configAction,...key===void 0?{}:{key},...value===void 0?{}:{value},options})}schema(subcommand,options={}){return this.runTyped("schema",{options:{...options,subcommand}})}workflowPolicy(action,name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:action}})}schemaList(){return this.runTyped("schema",{options:{subcommand:"list"}})}schemaShow(name){return this.runTyped("schema",{name,options:{subcommand:"show"}})}schemaAddType(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"add-type"}})}schemaRemoveType(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"remove-type"}})}schemaAddStatus(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"add-status"}})}schemaRemoveStatus(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"remove-status"}})}schemaAddField(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"add-field"}})}schemaRemoveField(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"remove-field"}})}schemaListFields(){return this.runTyped("schema",{options:{subcommand:"list-fields"}})}schemaShowField(name){return this.runTyped("schema",{name,options:{subcommand:"show-field"}})}schemaApplyPreset(typePreset,options={}){return this.runTyped("schema",{typePreset,options:{...options,subcommand:"apply-preset"}})}schemaInferTypes(options={}){return this.runTyped("schema",{options:{...options,subcommand:"add-type",infer:true}})}schemaRenameType(from,to,options){return this.runTyped("schema",{name:from,options:{...options,subcommand:"rename-type",to}})}schemaRenameField(from,to,options,type){return this.runTyped("schema",{name:from,options:{...options,subcommand:"rename-field",to,...type?{fieldTypeScope:type}:{}}})}schemaRemapStatus(from,to,options){return this.runTyped("schema",{name:from,options:{...options,subcommand:"remap-status",to}})}schemaShowStatus(name){return this.runTyped("schema",{name,options:{subcommand:"show-status"}})}profile(subcommand,options={}){return this.runTyped("profile",{options:{...options,subcommand}})}profileList(){return this.runTyped("profile",{options:{subcommand:"list"}})}profileShow(name){return this.runTyped("profile",{name,options:{subcommand:"show"}})}profileApply(name,options={}){return this.runTyped("profile",{name,options:{...options,subcommand:"apply"}})}profileLint(name){return this.runTyped("profile",{name,options:{subcommand:"lint"}})}validate(options={}){return this.runTyped("validate",{options})}health(options={}){return this.runTyped("health",{options})}gc(options={}){return this.runTyped("gc",{options})}assurance(input){return this.runTyped("assurance",{options:{...input,subcommand:input.action}})}historyRedact(id,options){return this.runTyped("history-redact",{id,options})}historyRepair(id,options={}){return this.runTyped("history-repair",{id,options})}historyRepairAll(options={}){return this.runTyped("history-repair",{options:{...options,all:true}})}historyAttest(options={}){return this.runTyped("history-attest",{options})}historyCompact(id,options={}){return this.runTyped("history-compact",{id,options})}historyCompactBulk(options){return this.runTyped("history-compact",{options})}historyAuthorAcknowledge(options){return this.runTyped("history-author-acknowledge",{historyEvent:(options.events??[]).map(event=>`${event.item_id}:${String(event.line)}`),allActionable:options.all_actionable===true,dryRun:options.dry_run===true,planFingerprint:options.plan_fingerprint,limit:options.coordinate_limit,attributedAuthor:options.attributed_author,reviewer:options.reviewer,reason:options.reason})}plan(subcommand,id,options={},stepRef,reorderTo){return this.runTyped("plan",{...id===void 0?{}:{id},...stepRef===void 0?{}:{stepRef},...reorderTo===void 0?{}:{reorderTo},options:mutationOptionsWithOverrides(options,{subcommand})})}planCreate(options){return this.plan("create",void 0,options)}planShow(id,options={}){return this.plan("show",id,options)}planAddStep(id,options){return this.plan("add-step",id,options)}planUpdateStep(id,stepRef,options){return this.plan("update-step",id,options,stepRef)}planCompleteStep(id,stepRef,options={}){return this.plan("complete-step",id,options,stepRef)}planBlockStep(id,stepRef,options){return this.plan("block-step",id,options,stepRef)}planReorderStep(id,stepRef,reorderTo,options={}){return this.plan("reorder-step",id,options,stepRef,reorderTo)}planRemoveStep(id,stepRef,options={}){return this.plan("remove-step",id,options,stepRef)}planLink(id,stepRef,options){return this.plan("link",id,options,stepRef)}planUnlink(id,stepRef,options){return this.plan("unlink",id,options,stepRef)}planDecision(id,options){return this.plan("decision",id,options)}planDiscovery(id,options){return this.plan("discovery",id,options)}planValidation(id,options){return this.plan("validation",id,options)}planResume(id,options){return this.plan("resume",id,options)}planApprove(id,options={}){return this.plan("approve",id,options)}planMaterialize(id,options){return this.plan("materialize",id,options)}create(options={}){return this.runTyped("create",splitFullClientMutationOptions(options))}update(id,options={}){return this.runTyped("update",{id,...splitFullClientMutationOptions(options)})}reopen(id,reason,options={}){return this.runTyped("item-reopen",{id,reason,fullChangedFields:true,options})}close(id,reason,options={}){return this.runTyped("close",{id,reason,...splitFullClientMutationOptions(options)})}claim(id,options={}){return this.runTyped("claim",{id,...splitFullClientMutationOptions(options)})}claimNext(options={}){return this.runTyped("claim",{next:true,...splitFullClientMutationOptions(options)})}release(id,options={}){return this.runTyped("release",{id,...splitFullClientMutationOptions(options)})}copy(id,options={}){return this.runTyped("copy",{id,...splitFullClientMutationOptions(options)})}delete(id,options={}){return this.runTyped("delete",{id,...splitFullClientMutationOptions(options)})}restore(id,target,options={}){return this.runTyped("restore",{fullChangedFields:true,id,options:{...options,target}})}focus(id,options={}){return this.runTyped("focus",{...id===void 0?{}:{id},...splitFullClientMutationOptions(options)})}startTask(id,options={}){return this.runTyped("start-task",{id,...splitFullClientMutationOptions(options)})}pauseTask(id,options={}){return this.runTyped("pause-task",{id,...splitFullClientMutationOptions(options)})}closeTask(id,reason,options={}){return this.runTyped("close-task",{id,reason,...splitFullClientMutationOptions(options)})}extension(target,options={}){return this.runTyped("extension",{...target===void 0?{}:{target},options})}extensionList(options={}){return this.extension("list",options)}extensionActivate(target,options={}){return this.runTyped("extension-activate",{target,options})}extensionDeactivate(target,options={}){return this.runTyped("extension-deactivate",{target,options})}package(target,options={}){return this.runTyped("package",{...target===void 0?{}:{target},options:{...options,vocabulary:"package"}})}packageList(options={}){return this.package("list",options)}packageInstall(target,options={}){return this.runTyped("package-install",{target,options})}packageUninstall(target,options={}){return this.runTyped("package-uninstall",{target,options})}packageDoctor(options={}){return this.runTyped("package-doctor",{options})}packageManage(target,options={}){return this.runTyped("package-manage",{...target===void 0?{}:{target},options})}packageDescribe(target,options={}){return this.runTyped("package-describe",{...target===void 0?{}:{target},options})}packageReload(options={}){return this.runTyped("package-reload",{options})}packageCatalog(options={}){return this.runTyped("package-catalog",{options})}packageActivate(target,options={}){return this.runTyped("package-activate",{target,options})}packageDeactivate(target,options={}){return this.runTyped("package-deactivate",{target,options})}packageMigrate(options={}){return this.package(void 0,{...options,migrate:true})}upgrade(target,options={}){return this.runTyped("upgrade",{...target===void 0?{}:{target},options})}}function context(options={},clientOptions={}){return new PmClient(clientOptions).context(options)}function list(options={},clientOptions={}){return new PmClient(clientOptions).list(options)}function listAllComplete(options={},clientOptions={}){return new PmClient(clientOptions).listAllComplete(options)}function search(query,options={},clientOptions={}){return new PmClient(clientOptions).search(query,options)}function get(id,options={},clientOptions={}){return new PmClient(clientOptions).get(id,options)}function next(options={},clientOptions={}){return new PmClient(clientOptions).next(options)}function aggregate(options={},clientOptions={}){return new PmClient(clientOptions).aggregate(options)}function stats(options={},clientOptions={}){return new PmClient(clientOptions).stats(options)}function duplicates(options={},clientOptions={}){return new PmClient(clientOptions).duplicates(options)}function comments(id,options={},clientOptions={}){return new PmClient(clientOptions).comments(id,options)}function notes(id,options={},clientOptions={}){return new PmClient(clientOptions).notes(id,options)}function learnings(id,options={},clientOptions={}){return new PmClient(clientOptions).learnings(id,options)}function files(id,options={},clientOptions={}){return new PmClient(clientOptions).files(id,options)}function filesDiscover(id,options={},clientOptions={}){return new PmClient(clientOptions).filesDiscover(id,options)}function filesLookup(options,clientOptions={}){return new PmClient(clientOptions).filesLookup(options)}function docs(id,options={},clientOptions={}){return new PmClient(clientOptions).docs(id,options)}function deps(id,options={},clientOptions={}){return new PmClient(clientOptions).deps(id,options)}function graph(subcommand,ids={},options={},clientOptions={}){return new PmClient(clientOptions).graph(subcommand,ids,options)}function append(id,body,options={},clientOptions={}){return new PmClient(clientOptions).append(id,body,options)}function init(prefix,options={},clientOptions={}){return new PmClient(clientOptions).init(prefix,options)}function config(scope,configAction,key,value,options={},clientOptions={}){return new PmClient(clientOptions).config(scope,configAction,key,value,options)}function schema(subcommand,options={},clientOptions={}){return new PmClient(clientOptions).schema(subcommand,options)}function schemaList(clientOptions={}){return new PmClient(clientOptions).schemaList()}function schemaShow(name,clientOptions={}){return new PmClient(clientOptions).schemaShow(name)}function schemaAddType(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaAddType(name,options)}function schemaRemoveType(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaRemoveType(name,options)}function schemaAddStatus(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaAddStatus(name,options)}function schemaRemoveStatus(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaRemoveStatus(name,options)}function schemaAddField(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaAddField(name,options)}function schemaRemoveField(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaRemoveField(name,options)}function schemaListFields(clientOptions={}){return new PmClient(clientOptions).schemaListFields()}function schemaShowField(name,clientOptions={}){return new PmClient(clientOptions).schemaShowField(name)}function schemaApplyPreset(typePreset,options={},clientOptions={}){return new PmClient(clientOptions).schemaApplyPreset(typePreset,options)}function schemaInferTypes(options={},clientOptions={}){return new PmClient(clientOptions).schemaInferTypes(options)}function schemaRenameType(from,to,options,clientOptions={}){return new PmClient(clientOptions).schemaRenameType(from,to,options)}function schemaRenameField(from,to,options,type,clientOptions={}){return new PmClient(clientOptions).schemaRenameField(from,to,options,type)}function schemaRemapStatus(from,to,options,clientOptions={}){return new PmClient(clientOptions).schemaRemapStatus(from,to,options)}function schemaShowStatus(name,clientOptions={}){return new PmClient(clientOptions).schemaShowStatus(name)}function profile(subcommand,options={},clientOptions={}){return new PmClient(clientOptions).profile(subcommand,options)}function profileList(clientOptions={}){return new PmClient(clientOptions).profileList()}function profileShow(name,clientOptions={}){return new PmClient(clientOptions).profileShow(name)}function profileApply(name,options={},clientOptions={}){return new PmClient(clientOptions).profileApply(name,options)}function profileLint(name,clientOptions={}){return new PmClient(clientOptions).profileLint(name)}function validate(options={},clientOptions={}){return new PmClient(clientOptions).validate(options)}function health(options={},clientOptions={}){return new PmClient(clientOptions).health(options)}function gc(options={},clientOptions={}){return new PmClient(clientOptions).gc(options)}function historyRedact(id,options,clientOptions={}){return new PmClient(clientOptions).historyRedact(id,options)}function historyRepair(id,options={},clientOptions={}){return new PmClient(clientOptions).historyRepair(id,options)}function historyRepairAll(options={},clientOptions={}){return new PmClient(clientOptions).historyRepairAll(options)}function historyCompact(id,options={},clientOptions={}){return new PmClient(clientOptions).historyCompact(id,options)}function historyCompactBulk(options,clientOptions={}){return new PmClient(clientOptions).historyCompactBulk(options)}function create(options={},clientOptions={}){return new PmClient(clientOptions).create(options)}function update(id,options={},clientOptions={}){return new PmClient(clientOptions).update(id,options)}function reopen(id,reason,options={},clientOptions={}){return new PmClient(clientOptions).reopen(id,reason,options)}function close(id,reason,options={},clientOptions={}){return new PmClient(clientOptions).close(id,reason,options)}function claim(id,options={},clientOptions={}){return new PmClient(clientOptions).claim(id,options)}function claimNext(options={},clientOptions={}){return new PmClient(clientOptions).claimNext(options)}function release(id,options={},clientOptions={}){return new PmClient(clientOptions).release(id,options)}function copy(id,options={},clientOptions={}){return new PmClient(clientOptions).copy(id,options)}function deleteItem(id,options={},clientOptions={}){return new PmClient(clientOptions).delete(id,options)}function restore(id,target,options={},clientOptions={}){return new PmClient(clientOptions).restore(id,target,options)}function focus(id,options={},clientOptions={}){return new PmClient(clientOptions).focus(id,options)}function startTask(id,options={},clientOptions={}){return new PmClient(clientOptions).startTask(id,options)}function pauseTask(id,options={},clientOptions={}){return new PmClient(clientOptions).pauseTask(id,options)}function closeTask(id,reason,options={},clientOptions={}){return new PmClient(clientOptions).closeTask(id,reason,options)}function extension(target,options={},clientOptions={}){return new PmClient(clientOptions).extension(target,options)}function extensionList(options={},clientOptions={}){return new PmClient(clientOptions).extensionList(options)}function extensionActivate(target,options={},clientOptions={}){return new PmClient(clientOptions).extensionActivate(target,options)}function extensionDeactivate(target,options={},clientOptions={}){return new PmClient(clientOptions).extensionDeactivate(target,options)}function packageLifecycle(target,options={},clientOptions={}){return new PmClient(clientOptions).package(target,options)}function packageList(options={},clientOptions={}){return new PmClient(clientOptions).packageList(options)}function packageInstall(target,options={},clientOptions={}){return new PmClient(clientOptions).packageInstall(target,options)}function packageUninstall(target,options={},clientOptions={}){return new PmClient(clientOptions).packageUninstall(target,options)}function packageDoctor(options={},clientOptions={}){return new PmClient(clientOptions).packageDoctor(options)}function packageManage(target,options={},clientOptions={}){return new PmClient(clientOptions).packageManage(target,options)}function packageDescribe(target,options={},clientOptions={}){return new PmClient(clientOptions).packageDescribe(target,options)}function packageReload(options={},clientOptions={}){return new PmClient(clientOptions).packageReload(options)}function packageCatalog(options={},clientOptions={}){return new PmClient(clientOptions).packageCatalog(options)}function packageActivate(target,options={},clientOptions={}){return new PmClient(clientOptions).packageActivate(target,options)}function packageDeactivate(target,options={},clientOptions={}){return new PmClient(clientOptions).packageDeactivate(target,options)}function upgrade(target,options={},clientOptions={}){return new PmClient(clientOptions).upgrade(target,options)}async function getContracts(pmRootOrOptions,options={}){const resolvedOptions=typeof pmRootOrOptions==="string"?{...options,pmRoot:pmRootOrOptions}:pmRootOrOptions??options;const global2={json:true,quiet:resolvedOptions.quiet??true,noExtensions:resolvedOptions.noExtensions??false,noPager:true,profile:resolvedOptions.profile??false,path:resolvedOptions.pmRoot};return runContracts(resolvedOptions,global2)}function readRequiredString(args,key){const value=readString(args,key);if(!value){throw new PmCliError(`Missing required argument: ${key}`,64)}return value}const extensionActivationGate=createAsyncReadWriteGate();const activeExtensionScope=new AsyncLocalStorage;function resetActiveExtensionRegistries(){setActiveExtensionHooks(createEmptyExtensionHookRegistry());setActiveExtensionCommands(createEmptyExtensionCommandRegistry());setActiveExtensionParsers(createEmptyExtensionParserRegistry());setActiveExtensionPreflight(createEmptyExtensionPreflightRegistry());setActiveExtensionServices(createEmptyExtensionServiceRegistry());setActiveExtensionRenderers(createEmptyExtensionRendererRegistry());setActiveExtensionRegistrations(createEmptyExtensionRegistrationRegistry())}async function withActiveExtensions(global2,explicitCwd,resolutionCwd,run){return runWithIsolatedExtensionRuntime(()=>explicitCwd===void 0?extensionActivationGate.read(()=>withActiveExtensionsExclusively(global2,resolutionCwd,run)):extensionActivationGate.write(()=>withCwd(explicitCwd,()=>withActiveExtensionsExclusively(global2,resolutionCwd,run))))}async function runWithActiveExtensions(options,run){const explicitCwd=options.cwd;const resolutionCwd=explicitCwd??process.cwd();return withActiveExtensions(globalOptions({path:options.path,noExtensions:options.noExtensions}),explicitCwd,resolutionCwd,()=>activeExtensionScope.run(true,run))}async function withActiveExtensionsExclusively(global2,cwd,run){const pmRoot=resolvePmRoot(cwd,global2.path);if(global2.noExtensions){resetActiveExtensionRegistries();return runWithDiscoveredContextIntentContracts({pmRoot},()=>run(null))}if(!await pathExists(getSettingsPath(pmRoot))){resetActiveExtensionRegistries();return run(null)}let active=null;let activated;try{const settings=await readSettings(pmRoot);const loadResult=await loadExtensions({pmRoot,settings,cwd,noExtensions:false});const activationResult=await activateExtensions({...loadResult,loaded:loadResult.loaded});activated={loadResult,activationResult};setActiveExtensionHooks(activationResult.hooks);setActiveExtensionCommands(activationResult.commands);setActiveExtensionParsers(activationResult.parsers);setActiveExtensionPreflight(activationResult.preflight);setActiveExtensionServices(activationResult.services);setActiveExtensionRenderers(activationResult.renderers);setActiveExtensionRegistrations(activationResult.registrations);active={registrations:activationResult.registrations,commands:activationResult.commands,pmRoot,packages:loadResult.loaded}}catch(error){resetActiveExtensionRegistries();console.error("[pm-sdk] extension activation failed; continuing without active extensions:",error)}try{return await runWithDiscoveredContextIntentContracts({pmRoot,packages:active?.packages},()=>run(active))}finally{resetActiveExtensionRegistries();if(activated){await deactivateExtensions(activated.loadResult,activated.activationResult).catch(()=>void 0)}}}async function dispatchActiveExtensionAction(action,args,options,global2,active){if(!active){throw new PmCliError(`Unsupported native pm action: ${action}`,EXIT_CODE.USAGE)}const normalizedAction=normalizeActionName(action);const definition=active.registrations.commands.find(entry=>normalizeActionName(entry.action)===normalizedAction);const command=definition?.command??active.commands.handlers.find(entry=>normalizeActionName(entry.command)===normalizedAction)?.command;if(!command){throw new PmCliError(`Unsupported native pm action: ${action}`,EXIT_CODE.USAGE)}const handlerResult=await runActiveCommandHandler({command:normalizeCommandPath(command),args:readStringArray(options.args??args.args),options:extensionOptionsFromArgs(args,options),global:global2,pm_root:active.pmRoot,sdk:createExtensionCommandSdk(active.pmRoot,PmClient.forActiveExtensionHost({pmRoot:active.pmRoot,author:typeof global2.author==="string"&&global2.author.trim()?global2.author.trim():"pm-extension"}))});if(!handlerResult.handled){const suffix=handlerResult.warnings.length>0?` (${handlerResult.warnings.join(", ")})`:"";throw new PmCliError(`Unsupported native pm action: ${action}${suffix}`,EXIT_CODE.USAGE)}return handlerResult.result}async function withCwd(cwd,run){const previous=process.cwd();process.chdir(cwd);try{return await run()}finally{process.chdir(previous)}}function resolveSdkActionInput(args){const rawAction=readRequiredString(args,"action");const normalizedAction=normalizeActionName(rawAction);const alias=getOwnHandler(SDK_ACTION_ALIASES,normalizedAction);const action=alias?.action??normalizedAction;const resolvedArgs={...args,action};if(alias?.options!==void 0){resolvedArgs.options={...alias.options,...asRecordClone(args.options)}}if(action==="package"){resolvedArgs.options={...asRecordClone(resolvedArgs.options),vocabulary:"package"}}return{action,args:resolvedArgs}}async function runAction(args){const resolved=resolveSdkActionInput(args);const global2=globalOptions(resolved.args);const invalidateWorkspaceContractsCache=shouldInvalidateWorkspaceContractsCacheAfterAction(resolved.action);const explicitCwd=readString(resolved.args,"cwd");const resolutionCwd=explicitCwd??process.cwd();if(resolved.action==="init"){global2[INIT_INVOCATION_CWD]=resolutionCwd}if(resolved.action!=="init"||global2.path!==void 0||(process.env.PM_PATH?.trim().length??0)>0){global2.path=resolvePmRoot(resolutionCwd,global2.path)}try{if(resolved.action==="history-attest"){return await dispatchAction(resolved.action,resolved.args,global2,null)}if(args[ACTIVE_EXTENSION_HOST_CONTEXT]===true||activeExtensionScope.getStore()===true){return await dispatchAction(resolved.action,resolved.args,global2,null)}return await withActiveExtensions(global2,explicitCwd,resolutionCwd,activeExtensions=>dispatchAction(resolved.action,resolved.args,global2,activeExtensions))}finally{if(invalidateWorkspaceContractsCache){clearWorkspaceContractsCache()}}}function getOwnHandler(handlers,key){return Object.prototype.hasOwnProperty.call(handlers,key)?handlers[key]:void 0}function readMcpTarget(ctx){return readString(ctx.args,"target")??readString(ctx.options,"target")}function requireMcpItemId(ctx,source=ctx.options){return ctx.id??readRequiredString(source,"id")}async function runMcpListAction(ctx){const listOptions=applyContextIntentProjection("list",ctx.options);if(listOptions.compact===void 0&&listOptions.brief===void 0&&listOptions.full===void 0&&listOptions.fields===void 0&&listOptions.includeBody===void 0){listOptions.compact=true}return withQuerySummary(await runList(readString(ctx.args,"status")??readString(listOptions,"status"),listOptions,ctx.global),listOptions)}async function runMcpSearchAction(ctx){const query=readRequiredString(ctx.args,"query");const searchOptions=applyContextIntentProjection("search",ctx.options,[query]);if(searchOptions.compact===void 0&&searchOptions.full===void 0&&searchOptions.fields===void 0){searchOptions.compact=true}return withQuerySummary(await runSearch(query,searchOptions,ctx.global),searchOptions)}async function runMcpCreateAction(ctx){const{changedFields,idOnly,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);return projectMutationResult(await runCreate(runnerOptions,ctx.global),{changedFields,compactEnvelope:changedFields==="compact"&&!idOnly,idOnly})}async function runMcpCopyAction(ctx){const{changedFields,idOnly,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);const copyOptions={...runnerOptions,...runnerOptions.title===void 0&&typeof ctx.args.title==="string"?{title:ctx.args.title}:{},...runnerOptions.message===void 0&&typeof ctx.args.message==="string"?{message:ctx.args.message}:{}};return projectMutationResult(await runCopy(requireMcpItemId(ctx,copyOptions),copyOptions,ctx.global),{changedFields,compactEnvelope:changedFields==="compact"&&!idOnly,idOnly})}async function runMcpUpdateAction(ctx){const{changedFields,idOnly,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);return projectMutationResult(await runUpdate(requireMcpItemId(ctx,runnerOptions),runnerOptions,ctx.global),{changedFields,compactEnvelope:changedFields==="compact"&&!idOnly,idOnly})}function runMcpCommentsAction(ctx){const commentOptions=normalizeAnnotationTransportOptions(ctx.options);const isListing=commentOptions.add===void 0&&commentOptions.stdin===void 0&&commentOptions.file===void 0&&commentOptions.edit===void 0&&commentOptions.delete===void 0;if(isListing){commentOptions.includeMeta=true;if(commentOptions.limit===void 0&&commentOptions.fullHistory!==true){commentOptions.limit="20"}}return runComments(requireMcpItemId(ctx),commentOptions,ctx.global)}function runMcpFilesLookupAction(ctx,paths){return runFilesLookup(runtimeFilesLookupOptions(ctx.options,paths,parseMcpInteger),ctx.global)}function runMcpFilesAction(ctx){const lookupPaths=readStringArray(ctx.options.lookupPath);if(lookupPaths&&lookupPaths.length>0){return runMcpFilesLookupAction(ctx,lookupPaths)}const fileId=requireMcpItemId(ctx);return ctx.options.discover===true?runFilesDiscover(fileId,withFilesDiscoveryOptions(ctx.options),ctx.global):runFiles(fileId,withAddNoteOption(ctx.options),ctx.global)}function runMcpTelemetryAction(ctx){return runTelemetry({subcommand:readString(ctx.args,"subcommand")??readString(ctx.options,"subcommand"),limit:resolveRuntimeLimit(ctx.args,ctx.options)},ctx.global)}function runMcpHealthAction(ctx){const healthOptions={...ctx.options};if(healthOptions.brief===void 0&&healthOptions.summary===void 0&&healthOptions.full===void 0){healthOptions.summary=true}return runHealth(ctx.global,healthOptions)}function runMcpConfigAction(ctx){const configAction=readString(ctx.args,"configAction")??readString(ctx.options,"configAction")??readString(ctx.options,"action");if(configAction===void 0)throw new PmCliError("Missing required argument: configAction",64);const value=readString(ctx.args,"value")??readString(ctx.options,"value");const options=readString(ctx.options,"policy")!==void 0&&value!==void 0?{...ctx.options,value}:ctx.options;return runConfig(readString(ctx.args,"scope")??readString(ctx.options,"scope")??"project",configAction,readString(ctx.args,"key")??readString(ctx.options,"key"),options,ctx.global,readString(ctx.options,"policy")===void 0?value:void 0)}function runMcpActivityAction(ctx){const options=ctx.options;return runActivity(normalizeActivityProjectionOptions(options),ctx.global)}function parseMcpIntegerPrefix(value,label){if(typeof value==="number"){if(!Number.isFinite(value)||!Number.isInteger(value)){throw new PmCliError(`${label} must be a finite integer.`,64)}return value}if(typeof value==="string"&&value.trim().length>0){const trimmed=value.trim();if(!/^[+-]?\d+(?:st|nd|rd|th)?$/i.test(trimmed)){throw new PmCliError(`${label} must be a finite integer.`,64)}const parsed=Number.parseInt(trimmed,10);if(!Number.isInteger(parsed)){throw new PmCliError(`${label} must be a finite integer.`,64)}return parsed}return void 0}function runMcpPlanAction(ctx){const subcommand=readString(ctx.args,"subcommand")??readRequiredString(ctx.options,"subcommand");const planRecord=ctx.options;return runPlan({subcommand,id:typeof ctx.id==="string"?ctx.id:typeof planRecord.id==="string"?planRecord.id:void 0,stepRef:readMcpPlanStepRef(ctx),reorderTo:parseMcpIntegerPrefix(planRecord.reorderTo??ctx.args.reorderTo,"plan reorderTo"),options:ctx.options,global:ctx.global})}function readMcpPlanStepRef(ctx){return typeof ctx.options.stepRef==="string"?ctx.options.stepRef:typeof ctx.args.stepRef==="string"?ctx.args.stepRef:void 0}function createMcpSchemaContext(ctx){const subcommand=readString(ctx.args,"subcommand")??readRequiredString(ctx.options,"subcommand");const aliasSource=ctx.args.alias??ctx.options.alias;return{ctx,subcommand:subcommand.trim().toLowerCase(),name:readString(ctx.args,"name")??readString(ctx.options,"name"),author:readString(ctx.args,"author")??readString(ctx.options,"author"),force:ctx.args.force===true||ctx.options.force===true,aliases:aliasSource===void 0?void 0:readStringArray(aliasSource)}}function runMcpSchemaReadOrRemoveAction(schema2){const{ctx,subcommand,name,author,force}=schema2;const simpleHandlers={list:()=>runSchemaList(ctx.global),show:()=>runSchemaShow(name,ctx.global),"show-status":()=>runSchemaShowStatus(name,ctx.global),"list-fields":()=>runSchemaListFields(ctx.global),"show-field":()=>runSchemaShowField(name,ctx.global),"remove-type":()=>runSchemaRemoveType(name,{author,force},ctx.global),"remove-field":()=>runSchemaRemoveField(name,{author,force},ctx.global),"remove-status":()=>runSchemaRemoveStatus(name,{author,force},ctx.global),"apply-preset":()=>runSchemaApplyPreset(readString(ctx.args,"typePreset")??readString(ctx.options,"typePreset"),{author,force},ctx.global)};const handler=getOwnHandler(simpleHandlers,subcommand);return handler?handler():null}function runMcpSchemaAddFieldAction(schema2){const{ctx,name,author,force,aliases}=schema2;const commandsSource=ctx.args.commands??ctx.options.commands;const requiredTypesSource=ctx.args.requiredTypes??ctx.options.requiredTypes;return runSchemaAddField(name,{type:readString(ctx.args,"fieldType")??readString(ctx.options,"fieldType"),commands:commandsSource===void 0?void 0:readStringArray(commandsSource),description:readString(ctx.args,"description")??readString(ctx.options,"description"),cliFlag:readString(ctx.args,"cliFlag")??readString(ctx.options,"cliFlag"),alias:aliases,required:ctx.args.required===true||ctx.options.required===true,requiredOnCreate:ctx.args.requiredOnCreate===true||ctx.options.requiredOnCreate===true,allowUnset:!(ctx.args.allowUnset===false||ctx.options.allowUnset===false),requiredTypes:requiredTypesSource===void 0?void 0:readStringArray(requiredTypesSource),author,force},ctx.global)}function runMcpSchemaAddStatusAction(schema2){const{ctx,name,author,force,aliases}=schema2;const roleSource=ctx.args.role??ctx.options.role;return runSchemaAddStatus(name,{role:roleSource===void 0?void 0:readStringArray(roleSource),alias:aliases,description:readString(ctx.args,"description")??readString(ctx.options,"description"),order:parseMcpInteger(ctx.args.order??ctx.options.order,"schema add-status order"),author,force},ctx.global)}function runMcpSchemaAddTypeAction(schema2){const{ctx,name,author,force,aliases}=schema2;return runSchemaAddType(name,{description:readString(ctx.args,"description")??readString(ctx.options,"description"),defaultStatus:readString(ctx.args,"defaultStatus")??readString(ctx.args,"default_status")??readString(ctx.options,"defaultStatus")??readString(ctx.options,"default_status"),folder:readString(ctx.args,"folder")??readString(ctx.options,"folder"),alias:aliases,author,force},ctx.global)}function runMcpSchemaMigrationAction(schema2){const{ctx,subcommand,name,author,force}=schema2;const to=readString(ctx.args,"to")??readRequiredString(ctx.options,"to");const migrationId=readString(ctx.args,"migrationId")??readString(ctx.args,"migration_id")??readString(ctx.options,"migrationId")??readString(ctx.options,"migration_id");const fieldTypeScope=readString(ctx.args,"fieldTypeScope")??readString(ctx.options,"fieldTypeScope")??readString(ctx.args,"type")??readString(ctx.options,"type");const request=subcommand==="rename-type"?{kind:"rename-type",from:name??"",to}:subcommand==="rename-field"?{kind:"rename-field",from:name??"",to,...fieldTypeScope===void 0?{}:{type:fieldTypeScope}}:{kind:"remap-status",from:name??"",to};return runSchemaEvolutionMigration(request,{migrationId,dryRun:ctx.args.dryRun===true||ctx.options.dryRun===true,author,force},ctx.global)}function runMcpSchemaAction(ctx){const schema2=createMcpSchemaContext(ctx);const policyAction=WORKFLOW_POLICY_ACTIONS.find(action=>action===schema2.subcommand);if(policyAction)return runWorkflowPolicyAction(policyAction,schema2.name,{definition:ctx.args.definition??ctx.options.definition,policy:readString(ctx.args,"policy")??readString(ctx.options,"policy"),message:readString(ctx.args,"message")??readString(ctx.options,"message"),author:schema2.author,dryRun:ctx.args.dryRun===true||ctx.options.dryRun===true},ctx.global);const simpleResult=runMcpSchemaReadOrRemoveAction(schema2);if(simpleResult!==null){return simpleResult}if(["rename-type","rename-field","remap-status"].includes(schema2.subcommand)){return runMcpSchemaMigrationAction(schema2)}if(schema2.subcommand==="add-field"){return runMcpSchemaAddFieldAction(schema2)}if(schema2.subcommand==="add-status"){return runMcpSchemaAddStatusAction(schema2)}if(schema2.subcommand==="add-type"){if(ctx.args.infer===true||ctx.options.infer===true){return runSchemaInferTypes({minCount:parseMcpInteger(ctx.args.minCount??ctx.options.minCount,"schema infer minCount"),apply:ctx.args.apply===true||ctx.options.apply===true,author:schema2.author,force:schema2.force},ctx.global)}return runMcpSchemaAddTypeAction(schema2)}throw createUnknownSubcommandError({command_path:"schema",token:schema2.subcommand,allowed:SCHEMA_SUBCOMMANDS,exit_code:64})}function runMcpProfileAction(ctx){const subcommand=readString(ctx.args,"subcommand")??readRequiredString(ctx.options,"subcommand");const normalizedSubcommand=subcommand.trim().toLowerCase();const profileName=readString(ctx.args,"name")??readString(ctx.options,"name");const handlers={list:()=>runProfileList(),show:()=>runProfileShow(profileName),lint:()=>runProfileLint(profileName),apply:()=>runProfileApply(profileName,{dryRun:ctx.args.dryRun===true||ctx.options.dryRun===true,author:readString(ctx.args,"author")??readString(ctx.options,"author"),force:ctx.args.force===true||ctx.options.force===true},ctx.global)};const handler=getOwnHandler(handlers,normalizedSubcommand);if(!handler){throw createUnknownSubcommandError({command_path:"profile",token:subcommand,allowed:PROFILE_SUBCOMMANDS,exit_code:64})}return handler()}async function runMcpAppendAction(ctx){const{changedFields,idOnly,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);return projectMutationResult(await runAppend(requireMcpItemId(ctx,runnerOptions),runnerOptions,ctx.global),{changedFields,compactEnvelope:changedFields==="compact"&&!idOnly,idOnly})}async function runMcpUpdateManyAction(ctx){const{changedFields,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);return projectMutationResult(await runUpdateMany(updateManyOptionsFromFlat(runnerOptions),ctx.global),{changedFields})}async function runMcpCloseManyAction(ctx){const{changedFields,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);const topLevelReason=readString(ctx.args,"reason");const closeManyRunnerOptions=topLevelReason!==void 0&&runnerOptions.reason===void 0?{...runnerOptions,reason:topLevelReason}:{...runnerOptions};if(ctx.force&&closeManyRunnerOptions.force===void 0){closeManyRunnerOptions.force=true}return projectMutationResult(await runCloseMany(closeManyOptionsFromFlat(closeManyRunnerOptions),ctx.global),{changedFields})}async function runMcpRestoreAction(ctx){const{changedFields,idOnly,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);const target=readString(runnerOptions,"target")??readRequiredString(ctx.args,"target");return projectMutationResult(await runRestore(requireMcpItemId(ctx,runnerOptions),target,runnerOptions,ctx.global),{changedFields,compactEnvelope:changedFields==="compact"&&!idOnly,idOnly})}function runMcpGraphAction(ctx){const merged={...ctx.args,...ctx.options};return runGraph(readRequiredString(merged,"subcommand"),readString(merged,"id")??ctx.id,readString(merged,"target"),graphOptionsFromFlat(merged),ctx.global)}function runMcpHistoryAuthorAcknowledgeAction(ctx){return acknowledgeUnknownAuthorHistoryEventsFromTransport(resolvePmRoot(process.cwd(),ctx.global.path),{...ctx.args,...ctx.options})}const SDK_ACTION_HANDLERS={init:ctx=>runInit(readString(ctx.args,"prefix"),ctx.global,ctx.options),context:ctx=>runContext(applyContextIntentProjection("context",ctx.options),ctx.global),next:ctx=>runNext(applyContextIntentProjection("next",ctx.options),ctx.global),eval:runRuntimeEvalAction,events:runRuntimeEventsAction,merge:runRuntimeMergeAction,workspace:runRuntimeWorkspaceAction,meet:runRuntimeSchedulingAction,event:runRuntimeSchedulingAction,remind:runRuntimeSchedulingAction,list:runMcpListAction,get:ctx=>{const id=requireMcpItemId(ctx);return runGet(id,ctx.global,applyContextIntentProjection("get",ctx.options,[id]))},search:runMcpSearchAction,duplicates:ctx=>{const status=typeof ctx.options.status==="string"?[ctx.options.status]:readStringArray(ctx.options.status);return runDuplicates(ctx.global,{exhaustive:ctx.options.exhaustive===true,...status.length===0?{}:{status},since:readString(ctx.options,"since"),threshold:typeof ctx.options.threshold==="number"?ctx.options.threshold:void 0,limit:ctx.options.limit==="default"?void 0:parseMcpInteger(ctx.options.limit,"limit")})},create:runMcpCreateAction,copy:runMcpCopyAction,focus:ctx=>runFocus(ctx.id,{clear:ctx.options.clear===true||ctx.args.clear===true},ctx.global),update:runMcpUpdateAction,"item-reopen":runMcpReopenAction,restore:runMcpRestoreAction,claim:runMcpClaimAction,release:runMcpReleaseAction,"start-task":ctx=>runMcpTaskCompositionAction(ctx,"start_task"),"pause-task":ctx=>runMcpTaskCompositionAction(ctx,"pause_task"),"close-task":ctx=>runMcpTaskCompositionAction(ctx,"close_task"),close:runMcpCloseAction,comments:runMcpCommentsAction,notes:ctx=>runNotes(requireMcpItemId(ctx),normalizeAnnotationTransportOptions(ctx.options),ctx.global),learnings:ctx=>runLearnings(requireMcpItemId(ctx),normalizeAnnotationTransportOptions(ctx.options),ctx.global),files:runMcpFilesAction,docs:ctx=>runDocs(requireMcpItemId(ctx),withAddNoteOption(ctx.options),ctx.global),test:ctx=>runTest(requireMcpItemId(ctx),ctx.options,ctx.global),"test-all":ctx=>runTestAll(ctx.options,ctx.global),telemetry:runMcpTelemetryAction,validate:ctx=>runValidate(ctx.options,ctx.global,{runUpdate:(id,options,global2)=>runUpdate(id,options,global2)}),health:runMcpHealthAction,assurance:ctx=>runAssuranceDispatch(ctx.args,ctx.options,ctx.global),contracts:ctx=>runContracts(ctx.options,ctx.global),config:runMcpConfigAction,activity:runMcpActivityAction,aggregate:ctx=>runAggregate(ctx.options,ctx.global),extension:ctx=>runExtension(readMcpTarget(ctx),ctx.options,ctx.global),package:ctx=>runExtension(readMcpTarget(ctx),ctx.options,ctx.global),install:ctx=>runExtension(readMcpTarget(ctx),{...ctx.options,install:true},ctx.global),upgrade:ctx=>runUpgrade(readMcpTarget(ctx),ctx.options,ctx.global),delete:ctx=>runDelete(requireMcpItemId(ctx),ctx.options,ctx.global),deps:ctx=>runDeps(requireMcpItemId(ctx),ctx.options,ctx.global),graph:runMcpGraphAction,"files-discover":ctx=>runFilesDiscover(requireMcpItemId(ctx),ctx.options,ctx.global),"files-lookup":ctx=>runMcpFilesLookupAction(ctx,readStringArray(ctx.options.paths)),history:ctx=>runHistory(requireMcpItemId(ctx),ctx.options,ctx.global),"history-redact":ctx=>runHistoryRedact(requireMcpItemId(ctx),ctx.options,ctx.global),"history-repair":runMcpHistoryRepairAction,"history-compact":runMcpHistoryCompactAction,"history-attest":ctx=>runHistoryAttest(ctx.options,ctx.global),"history-author-acknowledge":runMcpHistoryAuthorAcknowledgeAction,plan:runMcpPlanAction,schema:runMcpSchemaAction,profile:runMcpProfileAction,stats:ctx=>runStats(ctx.global,statsCommandOptionsFromRuntime(ctx.options)),append:runMcpAppendAction,"update-many":runMcpUpdateManyAction,"close-many":runMcpCloseManyAction,gc:ctx=>runGc(ctx.global,ctx.options)};function analyzeSdkActionCoverage(actions=PM_TOOL_ACTIONS){return actions.map(action=>{const normalized=normalizeActionName(action);const alias=getOwnHandler(SDK_ACTION_ALIASES,normalized);const resolvedAction=alias?.action??normalized;const covered=getOwnHandler(SDK_ACTION_HANDLERS,resolvedAction)!==void 0;return{action,resolved_action:resolvedAction,covered,route:covered?alias?"alias":"native":"missing"}})}async function dispatchAction(action,args,global2,activeExtensions){const options=optionsWithAuthor(args,action);validateReadOutputOptions(action,options);normalizeReadOutputIncludeModeOptions(action,options);const ctx={action,args,options,id:readString(args,"id"),force:args.force===true||options.force===true,global:global2,activeExtensions};const handler=getOwnHandler(SDK_ACTION_HANDLERS,action);const result=handler?await handler(ctx):await dispatchActiveExtensionAction(action,args,options,global2,activeExtensions);if(action==="history-attest"){return result}else{options.resolvedOutputFormat="json";const projected=attachReadOutputContracts(action,options,result);await finalizeContextUsageEgress(resolvePmRoot(process.cwd(),global2.path),projected);return projected}}const actionRunnerTestHooks={closeManyOptionsFromFlat,extensionOptionsFromArgs,globalOptions,mutationListOptions,normalizeActionName,normalizeCommandPath,normalizeMcpUpdateOptions,normalizeMcpOptionsArrays,optionsWithAuthor,readRequiredString,readScalarString,readScalarStringAllowBlank,readStringArray,updateManyOptionsFromFlat,withAddNoteOption,withFilesDiscoveryOptions,withMutationCompaction};if(process.env.NODE_ENV==="test"||process.env.VITEST!==void 0||process.env.VITEST_WORKER_ID!==void 0){globalThis.__pmCliActionRunnerTestHooks=actionRunnerTestHooks}export{BASELINE_ITEM_FORMAT_VERSION,BUILTIN_ITEM_TYPE_VALUES,CONFIDENCE_TEXT_VALUES,CONTEXT_OUTPUT_VALUES,CURRENT_ITEM_FORMAT_VERSION,DEFAULT_TERMINAL_TRANSITION_POLICY,DEPENDENCY_KIND_VALUES,EXIT_CODE,HISTORY_EVENT_CLASSIFICATION_VERSION,ISSUE_SEVERITY_VALUES,ITEM_TYPE_VALUES,MAINTENANCE_HISTORY_OPERATIONS,NEXT_OUTPUT_VALUES,PM_CLI_EXPECTED_ERROR_NAME,PM_GITIGNORE_END,PM_GITIGNORE_START,PmCliError2 as PmCliError,PmClient,PmCompleteListValidationError,RISK_VALUES,SEARCH_EXTENSION_FLAG_DEFINITIONS,STATUS_VALUES,SUBSTANTIVE_HISTORY_OPERATIONS,acquireLock,aggregate,analyzeSdkActionCoverage,append,appendHistoryEntry,applyTerminalOrderingPolicy,assertCompleteListResult,canonicalDocument,certifyCompleteListResult2 as certifyCompleteListResult,claim,claimNext,classifyHistoryEvent,classifyItemFormatVersion,clearWorkspaceContractsCache2 as clearWorkspaceContractsCache,close,closeItem,closeTask,comments,commitImportedItem,config,context,copy,create,createCompleteListOptions2 as createCompleteListOptions,createHistoryEntry,createPmCliExpectedError,deleteItem,deps,docs,duplicates,effectiveItemFormatVersion,emptyImportedDocument,ensurePmGitignore,ensureTrackerInitialized,extension,extensionActivate,extensionDeactivate,extensionList,files,filesDiscover,filesLookup,focus,gc,generateItemId,get,getActiveExtensionRegistrations,getContracts,getHistoryPath,getItemPath,getPmGitignoreBlock,getSettingsPath2 as getSettingsPath,getWorkspaceContracts,graph,health,historyCompact,historyCompactBulk,historyRedact,historyRepair,historyRepairAll,init,inspectCompleteListResult,isPmCliExpectedError,isTerminalStatus,isTimestampLiteral,jaccardSimilarity,learnings,list,listAllComplete,listAllItemMetadata,listAllItemMetadataLight,loadCreateTemplateOptions,locateItem,next,normalizeItemFormatVersion,normalizeItemId,normalizeItemMetadata,normalizeRawItemId,normalizeSimilarityText,normalizeStatusInput,notes,nowIso,packageActivate,packageCatalog,packageDeactivate,packageDescribe,packageDoctor,packageInstall,packageLifecycle,packageList,packageManage,packageReload,packageUninstall,parseTags,pathExists2 as pathExists,pauseTask,profile,profileApply,profileLint,profileList,profileShow,readBooleanOption,readCsvListOption,readFileIfExists,readLocatedItem,readRequiredString,readSettings2 as readSettings,readStringOption,release,removeFileIfExists,renderCalendarMarkdown,renderCalendarToon,renderGuideMarkdown,reopen,requireTerminalReason,resolveCalendarOutputFormat,resolveGuideOutputFormat,resolveImplicitPmRoot,resolveItemTypeRegistry,resolvePmRoot2 as resolvePmRoot,resolveRuntimeFieldRegistry,resolveRuntimeStatusRegistry,resolveTerminalReason,restore,runAction,runActiveOnReadHooks,runActiveOnWriteHooks,runAggregate2 as runAggregate,runCalendar,runClose,runCloseTask,runCompletion,runContext2 as runContext,runCopy2 as runCopy,runDelete2 as runDelete,runDuplicates2 as runDuplicates,runFocus2 as runFocus,runGet2 as runGet,runGuide,runList2 as runList,runNext2 as runNext,runPauseTask,runReindex,runReopen,runRestore2 as runRestore,runSearch2 as runSearch,runStartTask,runStats2 as runStats,runTemplatesList,runTemplatesSave,runTemplatesShow,runTestRunsList,runTestRunsLogs,runTestRunsResume,runTestRunsStatus,runTestRunsStop,runUpdate2 as runUpdate,runWithActiveExtensions,scanItemFormatVersions,schema,schemaAddField,schemaAddStatus,schemaAddType,schemaApplyPreset,schemaInferTypes,schemaList,schemaListFields,schemaRemapStatus,schemaRemoveField,schemaRemoveStatus,schemaRemoveType,schemaRenameField,schemaRenameType,schemaShow,schemaShowField,schemaShowStatus,scoreItemSimilarity,search,selectImportAuthor,serializeItemDocument,splitFrontMatter,startTask,stats,toEstimatedMinutesValue,toImportBoolean,toImportConfidence,toImportInteger,toImportLinkedDocs,toImportLinkedFiles,toImportLinkedTests,toImportLogEntries,toImportNormalizedEnum,toImportNumberMap,toImportPriority,toImportStatus,toImportStringList,toImportStringMap,toImportTags,toNonEmptyImportString,tokenizeSimilarityText,update,upgrade,validate,writeFileAtomic};
2
2
  //# sourceMappingURL=runtime.js.map
@@ -4,6 +4,14 @@ Tracker references: [pm-v1yo](../.agents/pm/issues/pm-v1yo.toon), [pm-i6pi](../.
4
4
 
5
5
  These contracts keep common agent loops deterministic, token-efficient, and recoverable. Runtime contracts and `--help --json` remain the exact source for available flags.
6
6
 
7
+ Closed-item triage and schema authoring are also tracked by
8
+ [pm-gdi7](../.agents/pm/tasks/pm-gdi7.toon). `pm list --status closed` and the
9
+ compatibility `pm list-closed` default to brief rows. Use `--full` for complete
10
+ metadata or `--fields` for a precise projection. `pm schema --help` groups
11
+ `add-field` options separately from type inference and migration controls.
12
+ Unknown-option recovery derives valid flags and accepting command paths from
13
+ the active contracts; it refuses an unrecognized flag before execution.
14
+
7
15
  ## Relationship mutations
8
16
 
9
17
  `pm create`, `pm update`, and `pm update-many` preserve existing relationship data, including legacy cycles. When a mutation introduces a new cycle through an ordering relationship such as `blocked_by`, the result includes an `ordering_cycle_created:` warning with a concrete cycle path and a `pm graph audit` recovery pointer.
@@ -36,6 +36,8 @@ src/
36
36
  register-mutation.ts
37
37
  register-operations.ts
38
38
  registration-helpers.ts
39
+ schema/
40
+ registration.ts
39
41
  commands/
40
42
  help-content.ts
41
43
  error-guidance.ts
@@ -290,6 +292,11 @@ allowance file:
290
292
  Do not add new CLI/MCP behavior by deep-importing `src/core`. Add or extend an
291
293
  SDK primitive first, then consume that SDK surface from the presentation layer.
292
294
 
295
+ Schema command registration and rendering live in `src/cli/schema/registration.ts`,
296
+ with field, workflow, and migration behavior delegated to the SDK-backed schema
297
+ adapter. This keeps the general mutation registrar focused on family wiring
298
+ ([pm-gdi7](../.agents/pm/tasks/pm-gdi7.toon)).
299
+
293
300
  Progressive tool discovery follows this boundary directly: `src/sdk/mcp/discovery.ts` owns ranking, authorization filtering, budgets, cursors, omissions, cache identity, and the canonical result contract. `src/mcp/server.ts` only negotiates the extension, selects the entry catalog, and adapts compatibility text. See [Progressive Tool Discovery](PROGRESSIVE_TOOL_DISCOVERY.md).
294
301
 
295
302
  ## Telemetry Schema Negotiation
@@ -0,0 +1,46 @@
1
+ # History operation contracts
2
+
3
+ Tracked by [pm-0elqjj](../.agents/pm/issues/pm-0elqjj.toon).
4
+
5
+ History operation names are durable data. The public
6
+ `PM_HISTORY_OPERATION_CONTRACT` declares native item operations, workspace
7
+ operations, parameterized families, and historical aliases. Inspect it through
8
+ `pm contracts --command history --json` or import it from
9
+ `@unbrained/pm-cli/sdk/contracts`.
10
+
11
+ Native write sites are checked against that declaration by the mandatory
12
+ `operation-source-contract.spec.ts` test. New literal operation names fail the
13
+ gate until their contract is declared. Schema migration families also have a
14
+ type-exhaustive test covering their forward and compensation identities. JSON Patch verbs, extension write-hook
15
+ labels, remediation-plan verbs, and telemetry span names are different domains;
16
+ they do not become history operations merely because they have an `op` field.
17
+
18
+ `createHistoryEntry` canonicalizes declared aliases before sealing new records.
19
+ Both `init:type-preset` and `init:type_preset` write `init:type_preset`.
20
+ Existing
21
+ records retain their exact operation and hashes. Readers can explicitly call
22
+ `resolveHistoryOperation` for comparison; unknown historical operations remain
23
+ unchanged so a newer writer does not make an older reader destroy information.
24
+ These additive naming contracts do not change the item storage format or hash
25
+ epochs.
26
+
27
+ Custom SDK consumers retain their own operation identities. New packages should
28
+ use `extension:<package_name>:<snake_case_operation>`. Legacy custom names remain
29
+ accepted when they use lowercase alphanumeric segments separated by underscores,
30
+ hyphens, colons, or dots. Workspace retry keys remain opaque colon suffixes,
31
+ including schema reference paths. Whitespace and control characters are rejected
32
+ before new record construction. The native inventory
33
+ gate is stricter than this compatibility grammar: a typo in product code cannot
34
+ silently become a custom operation.
35
+
36
+ Validation separates the prefix from its opaque suffix at the first colon.
37
+ Both checks run in linear time, including long invalid inputs; no arbitrary
38
+ length cap truncates or rejects otherwise valid SDK identities.
39
+
40
+ `requireHistoryOperation` validates a native identity or a declared parameterized
41
+ family. `normalizeHistoryOperationForWrite` applies the compatible SDK writer
42
+ grammar. Existing append/rewrite primitives retain their responsibility to
43
+ preserve imported and historical records; reading old records does not run a
44
+ new-writer naming migration. Custom writers using other spellings must select
45
+ grammar-compliant identities for new events; their retained records remain
46
+ readable under their original names.
@@ -3,8 +3,9 @@
3
3
  Tracked by [pm-96fsma](../.agents/pm/issues/pm-96fsma.toon),
4
4
  [pm-m0yjtg](../.agents/pm/issues/pm-m0yjtg.toon),
5
5
  [pm-qw1uw6](../.agents/pm/issues/pm-qw1uw6.toon),
6
- [pm-e3gn0z](../.agents/pm/issues/pm-e3gn0z.toon), and
7
- [pm-wlqxg3](../.agents/pm/tasks/pm-wlqxg3.toon).
6
+ [pm-e3gn0z](../.agents/pm/issues/pm-e3gn0z.toon),
7
+ [pm-wlqxg3](../.agents/pm/tasks/pm-wlqxg3.toon), and
8
+ [pm-nb4zwz](../.agents/pm/issues/pm-nb4zwz.toon).
8
9
 
9
10
  Project management depends on trustworthy context. History is not just an
10
11
  activity feed: it is the reconstructable source for prior item states, including
@@ -104,6 +105,30 @@ separate recovery implementation.
104
105
 
105
106
  ## Permanent item identities
106
107
 
108
+ Reading a deleted ID returns `item_deleted`, distinct from an unknown ID.
109
+ The SDK error context and JSON diagnostic include `item_id` and a bounded
110
+ `tombstone` with deletion time, recoverability, and the last materialized durable
111
+ version. Human output supplies the same recovery commands:
112
+
113
+ ```bash
114
+ pm get <id> --at <last-materialized-version>
115
+ pm restore <id> <last-materialized-version>
116
+ ```
117
+
118
+ The not-found exit code remains `3`. Hosts that branch on diagnostic codes
119
+ should handle `item_deleted` alongside other not-found cases; the new context
120
+ fields are optional on general SDK errors. No existing required SDK input changes.
121
+
122
+ The diagnostic verifies retained history before claiming deletion. A missing
123
+ file whose history ends in a live state is not called deleted. A corrupt stream
124
+ retains its integrity refusal. For legacy compacted streams, a timestamp is
125
+ suggested only if it selects exactly the last materialized state; ambiguous
126
+ timestamps or a pruned materialized state report `recoverable: false` and direct
127
+ the caller to retained history and version control. The suggested read is
128
+ available as `recovery.suggested_retry_args` for execution without shell parsing.
129
+
130
+ Immutable event naming is documented in [History operations](HISTORY_OPERATIONS.md).
131
+
107
132
  Deleting an item retains its identity reservation through its history file.
108
133
  Generated IDs skip those reservations, even under reproducible execution.
109
134
  Explicit recreation fails with `item_identity_reserved`; use restore to recover
@@ -1,7 +1,8 @@
1
1
  # Lifecycle Commands and Ownership
2
2
 
3
3
  Tracked by [pm-ik19](../.agents/pm/tasks/pm-ik19.toon) and
4
- [pm-eq4x](../.agents/pm/tasks/pm-eq4x.toon).
4
+ [pm-eq4x](../.agents/pm/tasks/pm-eq4x.toon) and
5
+ [pm-r1f9f1](../.agents/pm/tasks/pm-r1f9f1.toon).
5
6
 
6
7
  Bulk mutations and ownership compositions share SDK implementations with their
7
8
  compatibility spellings. Runtime help and contracts describe the active surface:
@@ -41,7 +42,23 @@ close and its inline evidence, then releases ownership.
41
42
  Each constituent operation enforces its own policy and writes its own history.
42
43
  Compositions do not provide rollback across operations: for example, if the
43
44
  status transition fails after a successful claim, the claim remains. Inspect the
44
- item before retrying after an error.
45
+ item before retrying after an error. A second-step failure retains the original
46
+ error code and adds recovery guidance naming the completed operation. Its SDK
47
+ error `cause` retains the underlying failure.
48
+
49
+ ## Compact transport receipts
50
+
51
+ CLI and MCP compositions default to an `id`, final `status`, `action`, and
52
+ `changed_field_count`, plus compact receipts for each constituent step. The root
53
+ count is the number of distinct fields touched across the steps, not their sum.
54
+ Step receipts retain ownership, close reason, warnings, and recovery evidence.
55
+ Item descriptions, bodies, and annotation histories are not echoed by default.
56
+
57
+ Use CLI `--full-changed-fields` or MCP `fullChangedFields: true` for complete
58
+ constituent results; `--id-only` or `idOnly: true` returns only the final identity
59
+ and status. CLI `--no-changed-fields` preserves item snapshots while replacing
60
+ field arrays with counts. Plain release supports the same output controls.
61
+ Typed `PmClient` methods and the direct SDK primitives retain full results.
45
62
 
46
63
  ## SDK and MCP
47
64
 
@@ -235,18 +235,79 @@ Deleting or ignoring them would lose the evidence needed by other clones.
235
235
 
236
236
  ## Cross-branch id collision safety
237
237
 
238
- Item ids are `<prefix>` plus random base36 characters, and uniqueness is only probed against the local working tree — two agents branching from the same commit can mint the same id for different items (GH-600 / pm-pibw). Two controls bound that risk:
238
+ Tracked by [pm-qx95lz](../.agents/pm/issues/pm-qx95lz.toon).
239
+
240
+ Item ids are `<prefix>` plus random base36 characters. Local allocation reserves
241
+ both live documents and retained history, but cannot see independent creations
242
+ on another branch. The four-character default is a small, synchronized-workspace
243
+ setting; it is not a fleet uniqueness guarantee. `ids.token_length` accepts 4–12.
244
+ The allocator increases width after 32 local collisions to escape local density;
245
+ this does not measure concurrent branch activity.
246
+
247
+ For a shared base containing `n` reserved ids and `m` unsynchronized creations,
248
+ choose width `L` so `m*(m-1)/(2*(36^L-n))` stays below the desired per-sync
249
+ collision probability. This birthday union bound assumes independent uniform
250
+ allocation and all branches know the same reserved ids. At one million reserved
251
+ ids, eight characters keep 1,000 concurrent creations below one in a million;
252
+ nine characters do so for 10,000 creations. Configure the width before branching:
239
253
 
240
- - **Entropy budget** — `ids.token_length` in `settings.json` (default 4, accepted range 4–12) sets the random token length for newly minted ids. Approximate 1%-birthday-collision workloads per length: 4 chars ≈ 1.68M ids (~184 concurrent unsynced creations), 6 chars ≈ 2.18B (~6.6k), 8 chars ≈ 2.8T (~238k). Multi-agent repositories that fan out many branches between merges should raise it, e.g. `pm config project set ids_token_length 6`.
241
- - **Post-merge detection** — the `storage_integrity` validate check reports `validate_storage_duplicate_item_ids` whenever one id is claimed by multiple item documents (across type folders or format variants), which is how a same-id/different-item merge materializes. Remediation: keep one document, recreate the other item under a fresh id (`pm copy` then delete the colliding file), and re-point any dependencies.
254
+ ```bash
255
+ pm config project set ids_token_length 8
256
+ ```
257
+
258
+ The SDK item merge refuses an empty common ancestor with
259
+ `item_identity_conflict`, even for equal item content: document equality alone
260
+ cannot prove a common creation. It leaves the driver output untouched instead
261
+ of combining two identities through scalar preference. The history merge also
262
+ refuses different create events across its inputs, multiple creates in either
263
+ input, or creations on both sides when the ancestor lacks a create event even
264
+ when their bytes match, before fast-forwarding or reanchoring. A common ancestor
265
+ containing the shared create event remains valid.
266
+
267
+ `storage_integrity` detects multiple physical documents and a second create event
268
+ within one history stream, reporting its line in `history_unparseable_streams`
269
+ as an invalid lifecycle. This check also protects merges Git resolves without
270
+ invoking a content driver. `pm get` and SDK item lookup refuse multiple physical
271
+ matches with `item_identity_ambiguous`; the message lists tracker-relative paths
272
+ and SDK error context exposes a typed `paths` array. Format preference cannot
273
+ select a winner. Only candidate paths are probed, so lookup
274
+ does not enumerate every item in the workspace.
275
+
276
+ Preserve both branches when a collision is reported. Recover each item from its
277
+ unambiguous source branch, create the second under a fresh id, and update its
278
+ references before retrying the merge. Do not repair a fused stream merely to
279
+ make its hashes pass: a new hash chain does not recover a lost identity.
242
280
 
243
281
  Within one working tree, create and copy serialize on the candidate id and
244
282
  recheck every built-in and extension-defined type folder before the
245
283
  authoritative write. A raced collision fails with `item_id_collision` instead
246
284
  of replacing the existing document.
247
285
 
286
+ ### Executable convergence evidence
287
+
288
+ [pm-1tns7o](../.agents/pm/tasks/pm-1tns7o.toon) replaces the tag-only property
289
+ with generated complete-document comparisons. Fixed branch snapshots are folded
290
+ in original, reversed, and rotated order, with both ours/theirs directions.
291
+ Cases cover conflicting scalar writes and bodies, collection additions, distinct
292
+ and equal timestamps, disjoint edits, and optional-field deletion. Independent
293
+ expected documents are constructed directly for every N-branch case to check
294
+ retained values and preserved context. A policy table
295
+ also asserts that the compatibility `preferred_side` option is directional.
296
+ The field-class inventories are pinned so changes require an explicit test update.
297
+
298
+ These properties exercise the declared three-way policies; they do not turn the
299
+ document-level timestamp into per-field causal provenance. In particular, the
300
+ N-branch conflict fixture compares competing writes to the same scalar set.
301
+ Arbitrary histories, ordered executable test definitions with receiving-clone
302
+ trust, and relationship-event ordering retain their separate conformance contracts.
303
+
248
304
  ## Required post-merge gate
249
305
 
306
+ Reconciliation resolves receipt discovery and settlement from the requested
307
+ tracker. An explicit tracker outside Git does not consume clone-local receipts
308
+ from an unrelated invocation directory; see
309
+ [pm-q5grv5](../.agents/pm/issues/pm-q5grv5.toon).
310
+
250
311
  After every branch merge that touches `.agents/pm`, run:
251
312
 
252
313
  ```bash