@unbrained/pm-cli 2026.9.18 → 2026.9.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +963 -924
- package/dist/cli/invocation-profile.d.ts +26 -0
- package/dist/cli/invocation-profile.js +3 -0
- package/dist/cli/main.d.ts +10 -76
- package/dist/cli/main.js +1 -2
- package/dist/cli/register-operations.js +1 -1
- package/dist/cli/runtime/activation.d.ts +51 -0
- package/dist/cli/runtime/activation.js +2 -0
- package/dist/cli/runtime/invocation-options.d.ts +41 -0
- package/dist/cli/runtime/invocation-options.js +2 -0
- package/dist/cli/runtime/selection.d.ts +29 -0
- package/dist/cli/runtime/selection.js +2 -0
- package/dist/cli/runtime/telemetry-outcome.d.ts +20 -0
- package/dist/cli/runtime/telemetry-outcome.js +2 -0
- package/dist/cli-bundle/bundle-manifest.json +156 -156
- package/dist/cli-bundle/chunks/{chunk-T4J2X3RK.js → chunk-2FEKKSLN.js} +1255 -1255
- package/dist/cli-bundle/chunks/{chunk-XFGWFVR3.js → chunk-2QLXN6HZ.js} +46 -46
- package/dist/cli-bundle/chunks/chunk-2UNYUB4A.js +2 -0
- package/dist/cli-bundle/chunks/chunk-33R5PEKI.js +8 -0
- package/dist/cli-bundle/chunks/chunk-7YUYLYJQ.js +6 -0
- package/dist/cli-bundle/chunks/{chunk-GRFRKHFC.js → chunk-FBWAECBI.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-GRHSNUQO.js +20 -0
- package/dist/cli-bundle/chunks/chunk-HAFSMFJK.js +3 -0
- package/dist/cli-bundle/chunks/chunk-JBJUOOJI.js +238 -0
- package/dist/cli-bundle/chunks/chunk-K7RWRJLT.js +29 -0
- package/dist/cli-bundle/chunks/{chunk-AOD5WE6U.js → chunk-QZTS23BV.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-TTFVQB4S.js +2 -0
- package/dist/cli-bundle/chunks/{register-list-query-43EQISX7.js → register-list-query-5V43MYPN.js} +6 -6
- package/dist/cli-bundle/chunks/{register-mutation-TSZNAKEU.js → register-mutation-EVRYSU72.js} +4 -4
- package/dist/cli-bundle/chunks/register-operations-LJU5H2CU.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-HJUNGYBB.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-3XPBKIV6.js +12 -0
- package/dist/cli-bundle/focused-chunks/{chunk-PNCUNPSA.js → chunk-5BLRMUMK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-QVVOXVYI.js → chunk-6MNKQKT6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-246P5AK7.js → chunk-DPBTIFW7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-DRNXMOSV.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-FXAZPSU6.js +165 -0
- package/dist/cli-bundle/focused-chunks/{chunk-YJYSFWSW.js → chunk-HYPK5OPA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-GEFWBVPQ.js → chunk-IA5CCSBB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-C6SH62BX.js → chunk-ISEOBALS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7UZHYT5B.js → chunk-K5ZCBC6Y.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-L6L4XCLY.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-N6KI3LWF.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-PC6ZZVNP.js +20 -0
- package/dist/cli-bundle/focused-chunks/chunk-RQL5WLNZ.js +30 -0
- package/dist/cli-bundle/focused-chunks/{chunk-MMX7BQLH.js → chunk-U2SB2BMM.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-UIS5FVHH.js +59 -0
- package/dist/cli-bundle/main.js +26 -27
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +2 -2
- package/dist/cli-bundle/sdk-core.js +39 -39
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +42 -42
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +8 -8
- package/dist/cli.js +1 -1
- package/dist/core/checkpoint/mutation-checkpoint.d.ts +1 -1
- package/dist/core/checkpoint/mutation-checkpoint.js +2 -2
- package/dist/core/diagnostics/remediation.js +1 -1
- package/dist/core/extensions/extension-types.d.ts +2 -2
- package/dist/core/extensions/loader.d.ts +9 -15
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/extensions/manifest-parser.d.ts +5 -0
- package/dist/core/extensions/manifest-parser.js +2 -0
- package/dist/core/extensions/registration-contracts.d.ts +34 -0
- package/dist/core/extensions/registration-contracts.js +2 -0
- package/dist/core/fs/atomic-create.d.ts +7 -0
- package/dist/core/fs/atomic-create.js +2 -0
- package/dist/core/governance/issue-codes.d.ts +10 -1
- package/dist/core/governance/issue-codes.js +1 -1
- package/dist/core/history/history.js +1 -1
- package/dist/core/schema/runtime-schema.d.ts +1 -1
- package/dist/core/schema/runtime-schema.js +2 -2
- package/dist/core/session/session-state.js +1 -1
- package/dist/core/store/settings-concurrency.d.ts +7 -0
- package/dist/core/store/settings-concurrency.js +2 -0
- package/dist/core/store/settings.d.ts +8 -1
- package/dist/core/store/settings.js +3 -2
- package/dist/core/validate/fix-planning.d.ts +3 -3
- package/dist/core/validate/fix-planning.js +1 -1
- package/dist/sdk/agent/refusal-reachability.d.ts +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/completion/bash.d.ts +3 -0
- package/dist/sdk/completion/bash.js +2 -0
- package/dist/sdk/completion/fish.d.ts +3 -0
- package/dist/sdk/completion/fish.js +1054 -0
- package/dist/sdk/completion/shared.d.ts +103 -0
- package/dist/sdk/completion/shared.js +2 -0
- package/dist/sdk/completion/zsh.d.ts +3 -0
- package/dist/sdk/completion/zsh.js +1109 -0
- package/dist/sdk/completion.d.ts +5 -30
- package/dist/sdk/completion.js +1 -2160
- package/dist/sdk/contracts.d.ts +1 -0
- package/dist/sdk/contracts.js +1 -1
- package/dist/sdk/extension/install-runtime.d.ts +1 -1
- package/dist/sdk/extension/install-runtime.js +2 -2
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/governance/closure-timestamps.d.ts +32 -0
- package/dist/sdk/governance/closure-timestamps.js +2 -0
- package/dist/sdk/governance/health.js +1 -1
- package/dist/sdk/governance/provenance-health.d.ts +27 -0
- package/dist/sdk/governance/provenance-health.js +1 -1
- package/dist/sdk/governance/validate-normalization.d.ts +2 -0
- package/dist/sdk/governance/validate-normalization.js +1 -1
- package/dist/sdk/governance/validate.js +1 -1
- package/dist/sdk/governance.d.ts +1 -0
- package/dist/sdk/governance.js +1 -1
- package/dist/sdk/graph/index.d.ts +1 -0
- package/dist/sdk/graph/index.js +1 -1
- package/dist/sdk/graph/query-contracts.d.ts +18 -0
- package/dist/sdk/graph/query-contracts.js +2 -0
- package/dist/sdk/graph/run.d.ts +2 -0
- package/dist/sdk/graph/run.js +1 -1
- package/dist/sdk/graph/traversal.js +1 -1
- package/dist/sdk/lifecycle-policy.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/search/corpus.d.ts +27 -0
- package/dist/sdk/query/search/corpus.js +2 -0
- package/dist/sdk/query/search/filters.d.ts +27 -0
- package/dist/sdk/query/search/filters.js +2 -0
- package/dist/sdk/query/search/input.d.ts +28 -0
- package/dist/sdk/query/search/input.js +2 -0
- package/dist/sdk/query/search/lexical.d.ts +34 -0
- package/dist/sdk/query/search/lexical.js +2 -0
- package/dist/sdk/query/search/response.d.ts +34 -0
- package/dist/sdk/query/search/response.js +2 -0
- package/dist/sdk/query/search/semantic.d.ts +229 -0
- package/dist/sdk/query/search/semantic.js +3 -0
- package/dist/sdk/query/search/types.d.ts +123 -0
- package/dist/sdk/query/search/types.js +2 -0
- package/dist/sdk/query/search.d.ts +13 -364
- package/dist/sdk/query/search.js +1 -2
- package/dist/sdk/runtime/actions.d.ts +4 -0
- package/dist/sdk/runtime/actions.js +2 -0
- package/dist/sdk/runtime/context.d.ts +38 -0
- package/dist/sdk/runtime/context.js +2 -0
- package/dist/sdk/runtime/schema.d.ts +4 -0
- package/dist/sdk/runtime/schema.js +2 -0
- package/dist/sdk/runtime.d.ts +90 -95
- package/dist/sdk/runtime.js +1 -1
- package/docs/ARCHITECTURE.md +68 -0
- package/docs/HISTORY_GOVERNANCE_REPAIR.md +66 -0
- package/docs/MCP_OPTION_CONFORMANCE.md +41 -0
- package/docs/OUTPUT_PROJECTION_CONTRACTS.md +18 -2
- package/docs/PERFORMANCE.md +37 -0
- package/docs/README.md +1 -0
- package/docs/SDK_AGENT_SESSION_CONTEXT.md +28 -4
- package/docs/SDK_LIFECYCLE.md +16 -2
- package/docs/WORKSPACE_CONCURRENCY.md +67 -0
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
- package/marketplace.json +2 -2
- package/package.json +3 -3
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/dist/cli-bundle/chunks/chunk-CA5DRNGA.js +0 -29
- package/dist/cli-bundle/chunks/chunk-CI2JCBN2.js +0 -237
- package/dist/cli-bundle/chunks/chunk-FZZVWWQP.js +0 -2
- package/dist/cli-bundle/chunks/chunk-IPR2ICDO.js +0 -20
- package/dist/cli-bundle/chunks/chunk-WD7BQXA7.js +0 -6
- package/dist/cli-bundle/chunks/chunk-WUDF7HWM.js +0 -2
- package/dist/cli-bundle/chunks/chunk-X2EVS624.js +0 -3
- package/dist/cli-bundle/chunks/chunk-Y2OK7IAD.js +0 -8
- package/dist/cli-bundle/chunks/register-operations-KFZIKATY.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-KTJ4ZE65.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-7D6M45AN.js +0 -30
- package/dist/cli-bundle/focused-chunks/chunk-BVOQRMHF.js +0 -164
- package/dist/cli-bundle/focused-chunks/chunk-HRANNGHM.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-LG3SYXBX.js +0 -20
- package/dist/cli-bundle/focused-chunks/chunk-LI6IGGB3.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-QKG7JD34.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-QYQFBJXD.js +0 -59
- package/dist/cli-bundle/focused-chunks/chunk-ZDX2BCOT.js +0 -12
package/dist/sdk/runtime.js
CHANGED
|
@@ -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]="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};
|
|
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]="856f6aeb-4343-5cda-8b04-66d786e351d9")}catch(e2){}})();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{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{PM_TOOL_ACTIONS}from"./cli-contracts/enum-contracts.js";import{runContracts}from"./cli-contracts/runtime-contracts.js";import{attachReadOutputContracts}from"./context-intent-contracts.js";import{runWithDiscoveredContextIntentContracts}from"./context-intent-runtime.js";import{finalizeContextUsageEgress}from"./context/usage-egress.js";import{createExtensionCommandSdk}from"./extension-command-context.js";import{INIT_INVOCATION_CWD}from"./init.js";import{certifyCompleteListResult,createCompleteListOptions}from"./query/complete-list.js";import{listClientItemMetadataLight}from"./query/light-metadata.js";import{normalizeReadOutputIncludeModeOptions,validateReadOutputOptions}from"./read-output-contracts.js";import{SDK_ACTION_ALIASES}from"./runtime-action-aliases.js";import{closeManyOptionsFromFlat,extensionOptionsFromArgs,actionGlobalOptions as globalOptions,mutationListOptions,mutationOptionsWithOverrides,normalizeActionName,normalizeCommandPath,normalizeMcpOptionsArrays,normalizeMcpUpdateOptions,optionsWithAuthor,readRuntimeScalarString as readScalarString,readRuntimeScalarStringAllowBlank as readScalarStringAllowBlank,readRuntimeString as readString,readRuntimeStringArray as readStringArray,shouldInvalidateWorkspaceContractsCacheAfterAction,updateManyOptionsFromFlat,withAddNoteOption,withFilesDiscoveryOptions,withMutationCompaction}from"./runtime-input.js";import{SDK_ACTION_HANDLERS}from"./runtime/actions.js";import{getOwnHandler,readRequiredString}from"./runtime/context.js";import{clearWorkspaceContractsCache}from"./workspace-contracts-cache.js";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{PmCompleteListValidationError,assertCompleteListResult,certifyCompleteListResult as certifyCompleteListResult2,createCompleteListOptions as createCompleteListOptions2,inspectCompleteListResult}from"./query/complete-list.js";import{getWorkspaceContracts}from"./query/workspace-contracts.js";import{clearWorkspaceContractsCache as clearWorkspaceContractsCache2}from"./workspace-contracts-cache.js";export*from"./governance/workflow-policy.js";import{runCloseTask,runPauseTask,runStartTask}from"./lifecycle/task-composition.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{HISTORY_EVENT_CLASSIFICATION_VERSION,MAINTENANCE_HISTORY_OPERATIONS,SUBSTANTIVE_HISTORY_OPERATIONS,classifyHistoryEvent}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}from"./query/aggregate.js";import{CONTEXT_OUTPUT_VALUES,runContext}from"./query/context.js";import{runGet}from"./query/get.js";import{runList}from"./query/list.js";import{closeItem,runClose}from"./lifecycle/close.js";import{runCopy}from"./lifecycle/copy.js";import{runDelete}from"./lifecycle/delete.js";import{runFocus}from"./lifecycle/focus.js";import{runRestore}from"./lifecycle/restore.js";import{DEFAULT_TERMINAL_TRANSITION_POLICY,applyTerminalOrderingPolicy,requireTerminalReason,resolveTerminalReason}from"./lifecycle-policy.js";import{runUpdate}from"./lifecycle/update.js";import{runReopen}from"./lifecycle/reopen.js";import{NEXT_OUTPUT_VALUES,runNext}from"./query/next.js";import{runSearch}from"./query/search.js";import{runStats}from"./stats.js";import{runDuplicates}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{BUILTIN_ITEM_TYPE_VALUES,CONFIDENCE_TEXT_VALUES,DEPENDENCY_KIND_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)}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 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}import{readRequiredString as readRequiredString2}from"./runtime/context.js";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,readRequiredString2 as 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,runAggregate,runCalendar,runClose,runCloseTask,runCompletion,runContext,runCopy,runDelete,runDuplicates,runFocus,runGet,runGuide,runList,runNext,runPauseTask,runReindex,runReopen,runRestore,runSearch,runStartTask,runStats,runTemplatesList,runTemplatesSave,runTemplatesShow,runTestRunsList,runTestRunsLogs,runTestRunsResume,runTestRunsStatus,runTestRunsStop,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
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -11,6 +11,8 @@ This page is for contributors changing `pm-cli` internals. Users should start wi
|
|
|
11
11
|
- `pm contracts` is the machine-readable runtime contract source.
|
|
12
12
|
|
|
13
13
|
Tracked documentation work: [pm-u9d0](../.agents/pm/epics/pm-u9d0.toon).
|
|
14
|
+
Search and invocation decomposition: [pm-jt3b](../.agents/pm/tasks/pm-jt3b.toon)
|
|
15
|
+
and [pm-yh8r](../.agents/pm/chores/pm-yh8r.toon).
|
|
14
16
|
|
|
15
17
|
## System Overview
|
|
16
18
|
|
|
@@ -31,6 +33,11 @@ src/
|
|
|
31
33
|
cli.ts
|
|
32
34
|
cli/
|
|
33
35
|
main.ts
|
|
36
|
+
runtime/
|
|
37
|
+
activation.ts
|
|
38
|
+
invocation-options.ts
|
|
39
|
+
selection.ts
|
|
40
|
+
telemetry-outcome.ts
|
|
34
41
|
register-setup.ts
|
|
35
42
|
register-list-query.ts
|
|
36
43
|
register-mutation.ts
|
|
@@ -44,6 +51,9 @@ src/
|
|
|
44
51
|
extension-command-options.ts
|
|
45
52
|
core/
|
|
46
53
|
extensions/
|
|
54
|
+
loader.ts
|
|
55
|
+
manifest-parser.ts
|
|
56
|
+
registration-contracts.ts
|
|
47
57
|
fs/
|
|
48
58
|
history/
|
|
49
59
|
item/
|
|
@@ -62,6 +72,27 @@ src/
|
|
|
62
72
|
sdk/
|
|
63
73
|
cli-contracts.ts
|
|
64
74
|
index.ts
|
|
75
|
+
runtime.ts
|
|
76
|
+
runtime/
|
|
77
|
+
actions.ts
|
|
78
|
+
context.ts
|
|
79
|
+
schema.ts
|
|
80
|
+
completion.ts
|
|
81
|
+
completion/
|
|
82
|
+
shared.ts
|
|
83
|
+
bash.ts
|
|
84
|
+
zsh.ts
|
|
85
|
+
fish.ts
|
|
86
|
+
query/
|
|
87
|
+
search.ts
|
|
88
|
+
search/
|
|
89
|
+
input.ts
|
|
90
|
+
filters.ts
|
|
91
|
+
corpus.ts
|
|
92
|
+
lexical.ts
|
|
93
|
+
semantic.ts
|
|
94
|
+
response.ts
|
|
95
|
+
types.ts
|
|
65
96
|
mcp/
|
|
66
97
|
discovery.ts
|
|
67
98
|
types/
|
|
@@ -297,6 +328,23 @@ with field, workflow, and migration behavior delegated to the SDK-backed schema
|
|
|
297
328
|
adapter. This keeps the general mutation registrar focused on family wiring
|
|
298
329
|
([pm-gdi7](../.agents/pm/tasks/pm-gdi7.toon)).
|
|
299
330
|
|
|
331
|
+
`src/cli/main.ts` owns invocation state and lifecycle sequencing. Its `runtime/`
|
|
332
|
+
modules separately own extension activation decisions, command-family selection,
|
|
333
|
+
option validation and provenance, and telemetry outcome classification. These
|
|
334
|
+
modules consume SDK contracts and never import the main entrypoint. Mutable
|
|
335
|
+
invocation caches remain in the orchestrator so repeated calls retain the same
|
|
336
|
+
reset boundary.
|
|
337
|
+
|
|
338
|
+
`src/sdk/runtime.ts` owns the public client, extension lifecycle isolation and
|
|
339
|
+
final read projection. `runtime/actions.ts` routes built-in actions to SDK
|
|
340
|
+
operations, `runtime/schema.ts` translates schema requests, and
|
|
341
|
+
`runtime/context.ts` owns shared dispatch types and argument validation. These
|
|
342
|
+
modules do not import the runtime entrypoint. Public imports remain stable.
|
|
343
|
+
|
|
344
|
+
Completion generation follows the same pattern: `src/sdk/completion.ts` selects
|
|
345
|
+
the shell, `completion/shared.ts` derives shared vocabulary from contracts, and
|
|
346
|
+
the Bash, Zsh and Fish modules render their respective scripts.
|
|
347
|
+
|
|
300
348
|
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).
|
|
301
349
|
|
|
302
350
|
## Telemetry Schema Negotiation
|
|
@@ -321,6 +369,20 @@ The renderer omits null, undefined, empty arrays, and empty objects from sparse
|
|
|
321
369
|
|
|
322
370
|
## Search Architecture
|
|
323
371
|
|
|
372
|
+
`src/sdk/query/search.ts` is the search orchestrator and compatibility export
|
|
373
|
+
surface. Its `search/` directory separates input parsing, metadata filtering,
|
|
374
|
+
corpus reads, lexical scoring and highlighting, semantic provider execution,
|
|
375
|
+
response projection, and shared type contracts. The CLI search adapter delegates
|
|
376
|
+
to this SDK pipeline; package consumers continue to use the published SDK
|
|
377
|
+
entrypoints rather than these internal module paths.
|
|
378
|
+
|
|
379
|
+
Inline `field:value` filters are extracted before keyword tokenization; explicit
|
|
380
|
+
flags take precedence. Filtering precedes ranking, and projection follows
|
|
381
|
+
ranking and pagination. Lexical scoring and highlighting share their field
|
|
382
|
+
definitions, while linked-content reads retain both path and realpath containment
|
|
383
|
+
checks. Changes to a stage must preserve this ordering and the public result
|
|
384
|
+
contract.
|
|
385
|
+
|
|
324
386
|
Search supports:
|
|
325
387
|
|
|
326
388
|
- keyword mode, always available
|
|
@@ -385,6 +447,12 @@ the synchronous mutation path. See the observability epic
|
|
|
385
447
|
|
|
386
448
|
## Extension Host
|
|
387
449
|
|
|
450
|
+
`core/extensions/loader.ts` sequences discovery and extension lifecycle calls.
|
|
451
|
+
`manifest-parser.ts` parses untrusted manifest data without loading code;
|
|
452
|
+
`registration-contracts.ts` validates contributed definitions before the
|
|
453
|
+
registrar publishes them. Containment checks, activation rollback and teardown
|
|
454
|
+
remain at their original lifecycle boundaries.
|
|
455
|
+
|
|
388
456
|
Load order:
|
|
389
457
|
|
|
390
458
|
1. core commands
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# History-derived governance repair
|
|
2
|
+
|
|
3
|
+
Tracked by [pm-wrbe](../.agents/pm/tasks/pm-wrbe.toon) and
|
|
4
|
+
[pm-pivf](../.agents/pm/chores/pm-pivf.toon).
|
|
5
|
+
|
|
6
|
+
Project history is context: maintenance must preserve when work happened and
|
|
7
|
+
why related occurrences share an identity.
|
|
8
|
+
|
|
9
|
+
## Recovering legacy closure dates
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pm validate --check-metadata --fix-hints
|
|
13
|
+
pm validate --check-metadata --auto-fix --fix-scope timestamps --dry-run --json
|
|
14
|
+
pm validate --check-metadata --auto-fix --fix-scope timestamps --json
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The `timestamps` scope is opt-in. It fills only missing `closed_at` fields on
|
|
18
|
+
terminal items. The exact scope allowlist leaves unrelated metadata, estimates,
|
|
19
|
+
resolution and lifecycle repairs gated. A dry run performs no item mutation.
|
|
20
|
+
Checks describe the pre-repair state; run validation again to prove convergence.
|
|
21
|
+
|
|
22
|
+
Dates come from verified replay of the item's complete available history,
|
|
23
|
+
including a comparison against the current item. The selected date is the first
|
|
24
|
+
transition in its final uninterrupted terminal interval. A reopen resets that
|
|
25
|
+
interval. Ordinary metadata edits do not advance it. Terminal creation counts;
|
|
26
|
+
a compaction or repair baseline carrying terminal state alone does not establish
|
|
27
|
+
when the original closure happened. Existing dates and `completed_at` are never
|
|
28
|
+
rewritten. Custom terminal statuses and their registered aliases are recognized.
|
|
29
|
+
|
|
30
|
+
Missing, unreadable, invalid or insufficient history is reported in
|
|
31
|
+
`closure_timestamp_residual` with a reason and total count. Bounded human output
|
|
32
|
+
marks truncated rows; JSON or `--verbose-diagnostics` restores full diagnostics
|
|
33
|
+
(subject to the separately declared output budget). `closure_history_inspected`
|
|
34
|
+
distinguishes a lightweight missing-date count from a verified derivation pass.
|
|
35
|
+
|
|
36
|
+
Every applied date is re-derived under the normal item mutation lock and appends
|
|
37
|
+
an audited `update` event. A stale proposal fails instead of assigning an
|
|
38
|
+
unverified date. Retrying an already repaired item is a no-op.
|
|
39
|
+
|
|
40
|
+
The public `@unbrained/pm-cli/sdk/governance` surface exposes
|
|
41
|
+
`deriveClosureTimestamp`, `scanClosureTimestamps`, `applyClosureTimestampFix`
|
|
42
|
+
and `runValidate`. SDK hosts can use `runValidate({checkMetadata: true,
|
|
43
|
+
autoFix: true, fixScope: ["timestamps"], dryRun: true}, {path: pmRoot})` to obtain
|
|
44
|
+
the same plan as the CLI; timestamp repairs do not need a CLI mutation adapter.
|
|
45
|
+
|
|
46
|
+
## Shared issue codes and typed lineage
|
|
47
|
+
|
|
48
|
+
Duplicate issue-code validation accepts explicit `discovered_from`, `supersedes`
|
|
49
|
+
and `incident_from` links targeting another item in the same issue-code group.
|
|
50
|
+
This joins the existing parent/child and adjudicated-duplicate rules. A follow-up
|
|
51
|
+
can retain its real upstream issue code without renaming historical work.
|
|
52
|
+
|
|
53
|
+
Derivation must reach a root. Cycles and their dependent followers remain
|
|
54
|
+
collisions, as do unrelated items, self references, references to different code
|
|
55
|
+
groups, and `related`, `implements` or ordering links. An independent collision
|
|
56
|
+
still appears when a group also contains legitimate follow-ups. No graph edges
|
|
57
|
+
are fabricated to satisfy validation.
|
|
58
|
+
|
|
59
|
+
## Repository backfill verification
|
|
60
|
+
|
|
61
|
+
Before applying a historical backfill, save the generated changelog's item-to-
|
|
62
|
+
release membership and inspect the complete repair preview. Regenerate with the
|
|
63
|
+
latest `pm-changelog` package afterward and compare membership. Row ordering may
|
|
64
|
+
change when a proven date replaces a mutable fallback; release attribution must
|
|
65
|
+
remain intact. Run history-drift validation and repeat the timestamp preview to
|
|
66
|
+
prove integrity and idempotence. Any generator defect belongs in `pm-changelog`.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# MCP Option Conformance
|
|
2
|
+
|
|
3
|
+
Tracked by [pm-v0s2rm](../.agents/pm/chores/pm-v0s2rm.toon).
|
|
4
|
+
|
|
5
|
+
An integration test can pass while an undeclared option is ignored. That leaves
|
|
6
|
+
the test asserting a behavior it never exercised. The repository therefore
|
|
7
|
+
treats emitted MCP unknown-option diagnostics as test failures, while the
|
|
8
|
+
production server retains its advisory warning behavior for clients.
|
|
9
|
+
|
|
10
|
+
Every run using [vitest.config.ts](../vitest.config.ts) installs
|
|
11
|
+
[McpContractReporter](../scripts/mcp-contract-reporter.mts). The reporter records
|
|
12
|
+
the emitting file, full test name, option, tool, and action, and rejects the run
|
|
13
|
+
after execution even when all assertions pass. Unattributed warnings also fail.
|
|
14
|
+
Diagnostics retain option names, never option values.
|
|
15
|
+
|
|
16
|
+
The sandboxed test runner also retains the reporter when command-line reporter
|
|
17
|
+
selection overrides the config, including CI coverage shards that emit blobs.
|
|
18
|
+
|
|
19
|
+
Intentional negative tests must have an exact entry in
|
|
20
|
+
`MCP_OPTION_WARNING_ALLOWLIST`, including a reason. A matching file or test alone
|
|
21
|
+
does not exempt other warning identities. The current exemption verifies that
|
|
22
|
+
mutation-shaped options cannot mutate a read tool. New integration behavior
|
|
23
|
+
should use declared parameters and assert the actual resulting state.
|
|
24
|
+
|
|
25
|
+
The [gate registry](../scripts/release/gate-registry.json) registers this check
|
|
26
|
+
as `mcp-option-contracts`. Its
|
|
27
|
+
[negative control](../tests/unit/scripts/mcp-contract-reporter.spec.ts) starts a
|
|
28
|
+
real Vitest child process whose assertion passes but whose undeclared-option
|
|
29
|
+
diagnostic must produce exit status 1. Run the gate and its integration consumers
|
|
30
|
+
with the sandboxed repository runner:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
node scripts/run-tests.mjs test -- tests/unit/scripts/mcp-contract-reporter.spec.ts tests/integration/mcp-dynamic-package-actions.spec.ts tests/unit/mcp/mcp-server-nested-options.spec.ts
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Published MCP acceptance also isolates project and global configuration, tracked
|
|
37
|
+
by [pm-prmt1y](../.agents/pm/issues/pm-prmt1y.toon). The npm, npx, and bunx checks
|
|
38
|
+
use temporary tracker roots for both stdio and HTTP servers. This prevents a
|
|
39
|
+
caller's installed skills from changing discovery pagination and hiding the
|
|
40
|
+
bundled skills being verified. Protocol and skill-content assertions remain
|
|
41
|
+
mandatory; acceptance processes disable production telemetry and Sentry.
|
|
@@ -19,7 +19,11 @@ and canonical TOON tables are tracked by
|
|
|
19
19
|
is tracked by [pm-8nev0o](../.agents/pm/issues/pm-8nev0o.toon) and
|
|
20
20
|
[pm-oahhyc](../.agents/pm/issues/pm-oahhyc.toon). Exact command-local
|
|
21
21
|
projection discovery is tracked by
|
|
22
|
-
[pm-q4isdq](../.agents/pm/issues/pm-q4isdq.toon).
|
|
22
|
+
[pm-q4isdq](../.agents/pm/issues/pm-q4isdq.toon). Shared graph defaults and
|
|
23
|
+
scale enforcement are tracked by [pm-mfy1ux](../.agents/pm/issues/pm-mfy1ux.toon).
|
|
24
|
+
|
|
25
|
+
For enforcement of declared MCP input options in repository tests, see
|
|
26
|
+
[MCP Option Conformance](MCP_OPTION_CONFORMANCE.md).
|
|
23
27
|
|
|
24
28
|
## Agent Quick Context
|
|
25
29
|
|
|
@@ -167,7 +171,19 @@ Passing `--full` with the corresponding compact flag is a usage error. An
|
|
|
167
171
|
explicit full request and the default full request produce the same payload
|
|
168
172
|
shape; the flag exists as a machine-actionable restore instruction.
|
|
169
173
|
|
|
170
|
-
|
|
174
|
+
Graph row collections default to ten rows, including hierarchy and ordering
|
|
175
|
+
traversals, audit findings, and slack's critical path. The public
|
|
176
|
+
`GRAPH_QUERY_DEFAULTS` contract is available from `@unbrained/pm-cli/sdk/graph`
|
|
177
|
+
and `@unbrained/pm-cli/sdk/contracts`; `pm contracts --command graph --flags-only`
|
|
178
|
+
declares the same defaults before invoking a graph query. Analytics still compute over the complete graph. `--full`
|
|
179
|
+
restores row collections, while `--limit` chooses a finite cap; combining those
|
|
180
|
+
two controls is rejected. Path enumeration retains its separate five-path,
|
|
181
|
+
eight-edge-depth and 10,000-expansion safety defaults. Audit evidence uses
|
|
182
|
+
`--sample` independently of the finding-row limit. The thousand-item graph
|
|
183
|
+
regression enumerates every registered subcommand, bounds serialized output,
|
|
184
|
+
and proves full traversal and cursor continuation.
|
|
185
|
+
|
|
186
|
+
`graph impact` returns `next_cursor` when
|
|
171
187
|
more affected nodes exist, and accepts `--after <cursor>` to resume in stable
|
|
172
188
|
breadth-first order. `graph impact --full` is the explicit unbounded override;
|
|
173
189
|
combining `--full` with `--limit` is rejected. A zero-row page remains
|
package/docs/PERFORMANCE.md
CHANGED
|
@@ -135,3 +135,40 @@ Review the report and budget diff together. Before a refresh, compare the delive
|
|
|
135
135
|
## Startup and observability
|
|
136
136
|
|
|
137
137
|
Sentry is loaded only when an error-reporting path actually initializes it. Disabled and normal successful commands do not resolve or compile the `@sentry/node` → OpenTelemetry → Undici graph. The loader uses the package's supported CommonJS export after the opt-out gate, preserving the repo-wide ban on dynamic/inline imports while keeping enabled capture, sanitization, and flush behavior intact.
|
|
138
|
+
|
|
139
|
+
## Invocation timing
|
|
140
|
+
|
|
141
|
+
Tracked by [pm-ag9nka](../.agents/pm/issues/pm-ag9nka.toon).
|
|
142
|
+
|
|
143
|
+
Use `pm --profile list --limit 5` to print diagnostics on stderr while retaining
|
|
144
|
+
normal stdout (including JSON). Every executable invocation with `--profile`
|
|
145
|
+
emits one final receipt on normal process drain, including help, version, and
|
|
146
|
+
handled refusals:
|
|
147
|
+
|
|
148
|
+
```text
|
|
149
|
+
profile:command=list took_ms=20
|
|
150
|
+
profile:invocation total_ms=324.125 scope=process_start_to_output_drain command_took_ms_scope=handler
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`total_ms` uses monotonic runtime uptime, starting before module initialization
|
|
154
|
+
and ending after pending command output and event-loop work drain. It includes
|
|
155
|
+
bootstrap, settings/schema and extension loading, dispatch, rendering, and
|
|
156
|
+
foreground cleanup. Existing `profile:command` records retain their compatible
|
|
157
|
+
`took_ms` field; `command_took_ms_scope=handler` explicitly labels those narrower
|
|
158
|
+
spans. Extension discovery timing is another component, never an invocation
|
|
159
|
+
total. Components may overlap and must not be added to the total.
|
|
160
|
+
|
|
161
|
+
The total excludes parent-side scheduling/spawn, final OS teardown, and remote
|
|
162
|
+
telemetry delivery after a detached flush. A forcibly terminated process may
|
|
163
|
+
never reach the drain callback. In-process SDK calls do not emit a process-total
|
|
164
|
+
receipt: their host owns the lifetime. `--profile` after the `--` positional
|
|
165
|
+
terminator does not enable the receipt.
|
|
166
|
+
|
|
167
|
+
The real-process regression compares the reported total against external wall
|
|
168
|
+
time across query, mutation, configuration, schema, health, discovery, and
|
|
169
|
+
refusal paths. It permits parent/teardown overhead of the greater of 250 ms or
|
|
170
|
+
25% of external wall time, and no more than 5 ms of clock rounding above it.
|
|
171
|
+
This is an instrument agreement tolerance, not a performance budget. Existing
|
|
172
|
+
transport/scale gates retain external end-to-end process wall time and their
|
|
173
|
+
unchanged stricter regression budgets; never gate invocation latency on handler
|
|
174
|
+
`took_ms`.
|
package/docs/README.md
CHANGED
|
@@ -65,6 +65,7 @@ pm guide release --json
|
|
|
65
65
|
- [Universal Read Output Contracts](READ_OUTPUT_CONTRACTS.md) - cross-command include, amount, cost, and encoding controls for CLI, SDK, MCP, and packages.
|
|
66
66
|
- [Diagnostic Output Contracts](DIAGNOSTIC_OUTPUT_CONTRACTS.md) - action-first error budgets, deterministic degradation, SDK projection, and executable refusal assurance.
|
|
67
67
|
- [History Algorithms and Detached Attestations](HISTORY_ATTESTATION.md) - named record digests, portable exact-byte proofs, and read-only verification.
|
|
68
|
+
- [History-derived Governance Repair](HISTORY_GOVERNANCE_REPAIR.md) - verified closure timestamps and typed issue-code lineage.
|
|
68
69
|
- [History Maintenance and Recovery](HISTORY_MAINTENANCE.md) - native history commands, permanent aliases, shared SDK transforms, and transactional recovery.
|
|
69
70
|
- [Declarative Workflow Policies](WORKFLOW_POLICIES.md) - portable lifecycle requirements, independent approvals, and completeness reports.
|
|
70
71
|
- [Mutation Integrity](MUTATION_INTEGRITY.md) - shared CLI/SDK/MCP author, secret, append-only disposition, and stale-work guardrails.
|
|
@@ -7,7 +7,8 @@ Tracker references: [pm-9wbiye](../.agents/pm/issues/pm-9wbiye.toon),
|
|
|
7
7
|
[pm-eq9dlw](../.agents/pm/issues/pm-eq9dlw.toon), and
|
|
8
8
|
[pm-lu6sca](../.agents/pm/features/pm-lu6sca.toon), plus
|
|
9
9
|
[pm-5q8wa0](../.agents/pm/issues/pm-5q8wa0.toon) and
|
|
10
|
-
[pm-c0lrdm](../.agents/pm/features/pm-c0lrdm.toon)
|
|
10
|
+
[pm-c0lrdm](../.agents/pm/features/pm-c0lrdm.toon) and
|
|
11
|
+
[pm-4f1l7f](../.agents/pm/issues/pm-4f1l7f.toon).
|
|
11
12
|
|
|
12
13
|
Project management is context management. The public SDK therefore carries a
|
|
13
14
|
session's purpose and episode boundary through the same immutable history that
|
|
@@ -129,8 +130,8 @@ public SDK exports for custom hosts.
|
|
|
129
130
|
the bounded built-in resolver. It never contains environment values, session
|
|
130
131
|
paths, prompts, or file contents.
|
|
131
132
|
|
|
132
|
-
New mutation history records failed
|
|
133
|
-
resolver outcomes under `context.agent_provenance_outcomes`; dimensions with
|
|
133
|
+
New mutation history records successful probes, failed probes, and explicitly
|
|
134
|
+
unavailable configured resolver outcomes under `context.agent_provenance_outcomes`; dimensions with
|
|
134
135
|
no configured resolver retain the compact legacy-compatible null projection.
|
|
135
136
|
A resolver is only counted as
|
|
136
137
|
attempted when its required input belongs to the detected harness; a foreign
|
|
@@ -138,7 +139,30 @@ host's shared `AI_AGENT` value is not Codex input. Consequently `pm health` can
|
|
|
138
139
|
`provenance_resolver_zero_success:<harness>:<dimension>:<resolver>:<attempts>`
|
|
139
140
|
without confusing an unavailable harness signal with a failed resolver. The
|
|
140
141
|
warning is advisory and the storage check includes the bounded attempt and
|
|
141
|
-
success counters for diagnosis.
|
|
142
|
+
success counters for diagnosis. Resolved environment, session, client, and
|
|
143
|
+
inferred observations do not count as probe successes merely because that
|
|
144
|
+
harness declares a resolver. Existing immutable records are preserved; a new
|
|
145
|
+
successful probe clears an all-failed advisory when the complete sample includes
|
|
146
|
+
that event.
|
|
147
|
+
|
|
148
|
+
`scanProvenanceResolverHealth()` from `@unbrained/pm-cli/sdk/governance` returns
|
|
149
|
+
`sample`, also exposed as `checks[name=storage].details.provenance_sample` by
|
|
150
|
+
`pm health --full --json`. The receipt declares `scope=history_prefix`, the
|
|
151
|
+
10,000-event and 8 MiB ceilings, events/bytes read, truncation, unreadable sources, malformed rows,
|
|
152
|
+
and the earliest/latest valid event timestamps inspected. Files are traversed
|
|
153
|
+
by sorted name and events by append order: this is a bounded history prefix,
|
|
154
|
+
not a rolling recent window. Timestamp bounds describe observed events only.
|
|
155
|
+
`sample.complete=false` suppresses population-wide zero-success conclusions;
|
|
156
|
+
`truncated` separately identifies byte/event limits. Missing or malformed input
|
|
157
|
+
is diagnosed by the integrity checks. An empty or unavailable-only sample is
|
|
158
|
+
not proof that a resolver works. These measurements describe the sampled
|
|
159
|
+
history, not current probe availability or an unobserved historical success.
|
|
160
|
+
The optional `eventLimit` argument must be a non-negative safe integer;
|
|
161
|
+
invalid bounds throw `RangeError`, and zero requests an empty bounded sample.
|
|
162
|
+
|
|
163
|
+
The `ProvenanceResolverHealthScan` TypeScript result adds a required `sample`
|
|
164
|
+
receipt. Consumers that construct this result themselves must supply the receipt;
|
|
165
|
+
consumers that only read returned scans retain all prior fields unchanged.
|
|
142
166
|
|
|
143
167
|
Older immutable history can also contain roles outside the controlled domain,
|
|
144
168
|
including values recorded from presence-only harness flags before semantic role
|