@unbrained/pm-cli 2026.11.21 → 2026.11.23
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/.agents/skills/pm-developer/SKILL.md +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli/after-command-context-usage.js +1 -1
- package/dist/cli/argv-utils.js +1 -1
- package/dist/cli/bootstrap-args.js +1 -1
- package/dist/cli/bundle-integrity.js +2 -2
- package/dist/cli/command-namespaces.js +1 -1
- package/dist/cli/commander-usage.js +11 -11
- package/dist/cli/commands/annotations/comments.js +1 -1
- package/dist/cli/commands/annotations/docs.js +1 -1
- package/dist/cli/commands/annotations/files.js +1 -1
- package/dist/cli/commands/annotations/learnings.js +1 -1
- package/dist/cli/commands/annotations/notes.js +1 -1
- package/dist/cli/commands/extension/describe.js +1 -1
- package/dist/cli/commands/extension/extension.js +1 -1
- package/dist/cli/commands/extension/scaffold.js +1 -1
- package/dist/cli/commands/extension/shared.js +1 -1
- package/dist/cli/commands/governance/gc.js +1 -1
- package/dist/cli/commands/governance/health.js +1 -1
- package/dist/cli/commands/governance/telemetry.js +1 -1
- package/dist/cli/commands/governance/validate.js +1 -1
- package/dist/cli/commands/history/activity.js +1 -1
- package/dist/cli/commands/history/history-compact.js +1 -1
- package/dist/cli/commands/history/history-redact.js +1 -1
- package/dist/cli/commands/history/history-repair.js +1 -1
- package/dist/cli/commands/history/history.js +1 -1
- package/dist/cli/commands/history/restore.js +1 -1
- package/dist/cli/commands/lifecycle/append.js +1 -1
- package/dist/cli/commands/lifecycle/claim.js +1 -1
- package/dist/cli/commands/lifecycle/close-many.js +1 -1
- package/dist/cli/commands/lifecycle/close.js +1 -1
- package/dist/cli/commands/lifecycle/copy.js +1 -1
- package/dist/cli/commands/lifecycle/create.js +1 -1
- package/dist/cli/commands/lifecycle/delete.js +1 -1
- package/dist/cli/commands/lifecycle/focus.js +1 -1
- package/dist/cli/commands/lifecycle/plan.js +1 -1
- package/dist/cli/commands/lifecycle/update-many.js +1 -1
- package/dist/cli/commands/lifecycle/update.js +1 -1
- package/dist/cli/commands/query/aggregate.js +1 -1
- package/dist/cli/commands/query/context.js +1 -1
- package/dist/cli/commands/query/deps.js +1 -1
- package/dist/cli/commands/query/duplicates.js +1 -1
- package/dist/cli/commands/query/eval.js +1 -1
- package/dist/cli/commands/query/get.js +1 -1
- package/dist/cli/commands/query/graph.js +1 -1
- package/dist/cli/commands/query/list.js +1 -1
- package/dist/cli/commands/query/next.js +1 -1
- package/dist/cli/commands/query/search.js +1 -1
- package/dist/cli/commands/query/stats.js +1 -1
- package/dist/cli/commands/test/test-all.js +1 -1
- package/dist/cli/commands/test/test-runs.js +1 -1
- package/dist/cli/commands/test/test.js +1 -1
- package/dist/cli/commands/workspace/config.js +1 -1
- package/dist/cli/commands/workspace/contracts.js +1 -1
- package/dist/cli/commands/workspace/init.js +1 -1
- package/dist/cli/commands/workspace/merge.js +1 -1
- package/dist/cli/commands/workspace/profile.js +1 -1
- package/dist/cli/commands/workspace/schema.js +1 -1
- package/dist/cli/commands/workspace/upgrade.js +1 -1
- package/dist/cli/context-intent-invocation.js +1 -1
- package/dist/cli/description-stdin.js +1 -1
- package/dist/cli/error-guidance.js +5 -5
- package/dist/cli/expected-revisions.js +1 -1
- package/dist/cli/extension-command-help.js +6 -6
- package/dist/cli/extension-recovery.js +1 -1
- package/dist/cli/help-content.js +5 -5
- package/dist/cli/help-json-payload.js +7 -7
- package/dist/cli/invocation-profile.js +2 -2
- package/dist/cli/main.js +5 -5
- package/dist/cli/migration-gates.js +1 -1
- package/dist/cli/option-values.js +1 -1
- package/dist/cli/preflight-warnings.js +3 -3
- package/dist/cli/public.js +1 -1
- package/dist/cli/register-annotations.js +1 -1
- package/dist/cli/register-assurance.js +1 -1
- package/dist/cli/register-files-lookup.js +1 -1
- package/dist/cli/register-history-activity.js +1 -1
- package/dist/cli/register-history-author.js +1 -1
- package/dist/cli/register-history-maintenance.js +2 -2
- package/dist/cli/register-list-query.js +10 -10
- package/dist/cli/register-mutation-options.js +0 -1
- package/dist/cli/register-mutation.js +6 -6
- package/dist/cli/register-operations.js +1 -1
- package/dist/cli/register-setup.js +1 -1
- package/dist/cli/register-structured-mutation.js +1 -1
- package/dist/cli/registration-helpers.js +1 -1
- package/dist/cli/runtime/activation.js +1 -1
- package/dist/cli/runtime/annotation-option-retry.js +1 -1
- package/dist/cli/runtime/close-fields-retry.js +1 -1
- package/dist/cli/runtime/field-route-retry.js +1 -1
- package/dist/cli/runtime/invocation-options.js +1 -1
- package/dist/cli/runtime/invocation-rewrites.js +1 -1
- package/dist/cli/runtime/projection-retry.js +1 -1
- package/dist/cli/runtime/read-output-mutation-retry.js +1 -1
- package/dist/cli/runtime/refusal-credential-redaction.js +1 -1
- package/dist/cli/runtime/selection.js +1 -1
- package/dist/cli/runtime/telemetry-outcome.js +1 -1
- package/dist/cli/runtime-compatibility-boundary.js +4 -4
- package/dist/cli/schema/registration.js +15 -15
- package/dist/cli/schema-registration-helpers.js +1 -1
- package/dist/cli/search-refresh.js +1 -1
- package/dist/cli/stats-analytics-json.js +1 -1
- package/dist/cli/telemetry-flush.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-2UQU7HRR.js +9 -0
- package/dist/cli-bundle/chunks/chunk-5DUP4AZA.js +2 -0
- package/dist/cli-bundle/chunks/chunk-5WZZ5XEN.js +3 -0
- package/dist/cli-bundle/chunks/chunk-6H36ZHMI.js +2 -0
- package/dist/cli-bundle/chunks/chunk-6MYJLOSG.js +2 -0
- package/dist/cli-bundle/chunks/chunk-AA52P34H.js +3 -0
- package/dist/cli-bundle/chunks/chunk-AEOHUSUI.js +2289 -0
- package/dist/cli-bundle/chunks/chunk-BSRIVYTM.js +8 -0
- package/dist/cli-bundle/chunks/chunk-CFWLQFJM.js +71 -0
- package/dist/cli-bundle/chunks/chunk-D6PDUKUG.js +9 -0
- package/dist/cli-bundle/chunks/chunk-ENKXRSFZ.js +31 -0
- package/dist/cli-bundle/chunks/chunk-F2Z6XLZB.js +3 -0
- package/dist/cli-bundle/chunks/chunk-FJOEL75F.js +2 -0
- package/dist/cli-bundle/chunks/chunk-GDXCAC52.js +2 -0
- package/dist/cli-bundle/chunks/chunk-H7JEXRIN.js +6 -0
- package/dist/cli-bundle/chunks/chunk-J2PDAVBC.js +2 -0
- package/dist/cli-bundle/chunks/chunk-KE7HMBEW.js +2 -0
- package/dist/cli-bundle/chunks/chunk-KZHIBEJL.js +33 -0
- package/dist/cli-bundle/chunks/chunk-NGJ5ERBF.js +115 -0
- package/dist/cli-bundle/chunks/chunk-NQ54T7T2.js +2 -0
- package/dist/cli-bundle/chunks/chunk-O7JHS64G.js +3 -0
- package/dist/cli-bundle/chunks/chunk-OKEZF7HU.js +2 -0
- package/dist/cli-bundle/chunks/chunk-OKIKF4FD.js +2 -0
- package/dist/cli-bundle/chunks/chunk-OPJF254V.js +9 -0
- package/dist/cli-bundle/chunks/chunk-PZA7QECY.js +1 -0
- package/dist/cli-bundle/chunks/chunk-RWA5YZ5X.js +2 -0
- package/dist/cli-bundle/chunks/chunk-S32NGRQM.js +2 -0
- package/dist/cli-bundle/chunks/chunk-SLFRSZK6.js +1 -0
- package/dist/cli-bundle/chunks/chunk-TZY5MVJF.js +125 -0
- package/dist/cli-bundle/chunks/chunk-YYT3MIRF.js +3 -0
- package/dist/cli-bundle/chunks/chunk-ZPS4B6SI.js +8 -0
- package/dist/cli-bundle/chunks/context-budget-recovery-M5RFUEFG.js +2 -0
- package/dist/cli-bundle/chunks/indexed-receipt-blobs-BPYKN5Q7.js +4 -0
- package/dist/cli-bundle/chunks/{item-revision-R5SZPJZ5.js → item-revision-FMD4KWBB.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-SEHTH7N2.js +2 -0
- package/dist/cli-bundle/chunks/mutation-actor-SFGYIRPW.js +2 -0
- package/dist/cli-bundle/chunks/mutation-admission-57LBSKQI.js +2 -0
- package/dist/cli-bundle/chunks/{register-list-query-SPGPS3OS.js → register-list-query-L4IBU64P.js} +11 -11
- package/dist/cli-bundle/chunks/register-mutation-6NUOPHZ3.js +21 -0
- package/dist/cli-bundle/chunks/register-operations-JGYVORNN.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-C44SIXEH.js +2 -0
- package/dist/cli-bundle/chunks/settlement-hook-6MR32OOC.js +7 -0
- package/dist/cli-bundle/chunks/stage-PQ7AB63N.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-6LKTEKHS.js +6 -0
- package/dist/cli-bundle/focused-chunks/chunk-6LPXMFLM.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-A6VEMCRR.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-AIDL2ZNT.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-BKPUUW5O.js +1 -0
- package/dist/cli-bundle/focused-chunks/chunk-BWOVFE5B.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-HMDQDRV2.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-I66IKYKP.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-IIP6LZ5E.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-IR2J3NOT.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-IROZDIDX.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-ITKDHSBR.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-K53OIT5J.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-LQYYPXUK.js +26 -0
- package/dist/cli-bundle/focused-chunks/chunk-NQTEE66P.js +13 -0
- package/dist/cli-bundle/focused-chunks/chunk-O7Z73ALG.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-OTMMOKPM.js +91 -0
- package/dist/cli-bundle/focused-chunks/chunk-OXOCZJC6.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-QLAHEDT6.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-QQIIMMFU.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-RIE3SJSE.js +9 -0
- package/dist/cli-bundle/focused-chunks/chunk-TD544C74.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-UFTUNBMY.js +27 -0
- package/dist/cli-bundle/focused-chunks/chunk-X6CXWWNB.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-XRS3VNC6.js +44 -0
- package/dist/cli-bundle/focused-chunks/chunk-XYPEZGTR.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-Y2ESLKCF.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-YSJKQLFR.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-Z2X7HH3C.js +102 -0
- package/dist/cli-bundle/focused-chunks/chunk-ZHWPCVQL.js +78 -0
- package/dist/cli-bundle/focused-chunks/context-budget-recovery-CSJV3TY3.js +2 -0
- package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-EGEJMG3G.js +4 -0
- package/dist/cli-bundle/focused-chunks/{item-revision-3V3UIP5X.js → item-revision-YDACCDVY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-transaction-UKEQCTKB.js +2 -0
- package/dist/cli-bundle/focused-chunks/mutation-actor-AS465LRX.js +2 -0
- package/dist/cli-bundle/focused-chunks/mutation-admission-E5UHJZFE.js +2 -0
- package/dist/cli-bundle/focused-chunks/settlement-hook-FMLGKG7J.js +7 -0
- package/dist/cli-bundle/focused-chunks/stage-36J7YLGI.js +2 -0
- package/dist/cli-bundle/main.js +27 -27
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +5 -5
- package/dist/cli-bundle/sdk-core.js +1 -1
- 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 +72 -60
- 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 +13 -13
- package/dist/cli.js +1 -1
- package/dist/core/checkpoint/checkpoint-gc.js +1 -1
- package/dist/core/checkpoint/mutation-checkpoint.js +2 -2
- package/dist/core/checkpoint/mutation-context.js +1 -1
- package/dist/core/config/nested-settings.js +1 -1
- package/dist/core/config/positional-value.js +1 -1
- package/dist/core/diagnostics/remediation.js +1 -1
- package/dist/core/extensions/activation-summary-markdown.js +2 -2
- package/dist/core/extensions/activation-summary.js +1 -1
- package/dist/core/extensions/activation-transaction.js +1 -1
- package/dist/core/extensions/capability-usage.js +1 -1
- package/dist/core/extensions/command-hook-context.js +1 -1
- package/dist/core/extensions/command-metadata-contract.js +1 -1
- package/dist/core/extensions/command-visibility-tier.js +1 -1
- package/dist/core/extensions/contribution-inventory.js +1 -1
- package/dist/core/extensions/exporter-output-contract.js +1 -1
- package/dist/core/extensions/extension-candidate.js +1 -1
- package/dist/core/extensions/extension-capability-aliases.js +1 -1
- package/dist/core/extensions/extension-hook-runtime.js +1 -1
- package/dist/core/extensions/extension-policy.js +1 -1
- package/dist/core/extensions/extension-registries.js +1 -1
- package/dist/core/extensions/extension-runtime-helpers.js +1 -1
- package/dist/core/extensions/extension-types.js +1 -1
- package/dist/core/extensions/flag-definition-validation.js +1 -1
- package/dist/core/extensions/flag-value-types.js +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/item-field-types.js +1 -1
- package/dist/core/extensions/item-fields.js +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/extensions/manifest-parser.js +1 -1
- package/dist/core/extensions/manifest-schema.js +1 -1
- package/dist/core/extensions/module-graph-snapshot.js +1 -1
- package/dist/core/extensions/mutation-actor-snapshot.js +1 -1
- package/dist/core/extensions/mutation-actor.js +1 -1
- package/dist/core/extensions/preflight-ownership.js +1 -1
- package/dist/core/extensions/read-output-contract.js +1 -1
- package/dist/core/extensions/registration-contracts.js +1 -1
- package/dist/core/extensions/registration-validation.js +1 -1
- package/dist/core/extensions/registration-values.js +1 -1
- package/dist/core/extensions/reserved-host-flags.js +1 -1
- package/dist/core/extensions/runtime-registrations.js +1 -1
- package/dist/core/extensions/service-ownership.js +1 -1
- package/dist/core/extensions/version-compat.js +1 -1
- package/dist/core/extensions/version-diagnostics.js +1 -1
- package/dist/core/fs/atomic-create.js +1 -1
- package/dist/core/fs/file-glob.js +1 -1
- package/dist/core/fs/fs-utils.js +2 -2
- package/dist/core/fs/host-environment-errors.js +1 -1
- package/dist/core/fs/index.js +1 -1
- package/dist/core/fs/path-utils.js +1 -1
- package/dist/core/governance/content-fields.js +1 -1
- package/dist/core/governance/issue-codes.js +1 -1
- package/dist/core/governance/metadata-coverage.js +1 -1
- package/dist/core/history/bridge.js +2 -0
- package/dist/core/history/digest.js +1 -1
- package/dist/core/history/drift-cache.js +3 -3
- package/dist/core/history/drift-scan.js +1 -1
- package/dist/core/history/event-classification.js +1 -1
- package/dist/core/history/event-index.js +11 -11
- package/dist/core/history/history-compact-bulk.js +1 -1
- package/dist/core/history/history-diff.js +1 -1
- package/dist/core/history/history-rewrite.js +1 -1
- package/dist/core/history/history-storage-stats.js +1 -1
- package/dist/core/history/history-stream-policy.js +1 -1
- package/dist/core/history/history.d.ts +12 -0
- package/dist/core/history/history.js +2 -2
- package/dist/core/history/identity.js +1 -1
- package/dist/core/history/index.js +1 -1
- package/dist/core/history/operation-contract.js +1 -1
- package/dist/core/history/projection.js +1 -1
- package/dist/core/history/read.d.ts +9 -0
- package/dist/core/history/read.js +1 -1
- package/dist/core/history/replay.d.ts +46 -5
- package/dist/core/history/replay.js +2 -2
- package/dist/core/history/stream-summary.js +2 -2
- package/dist/core/history/tombstone.js +1 -1
- package/dist/core/history/version-address.js +1 -1
- package/dist/core/history/workspace-history.js +2 -2
- package/dist/core/io/body-file.js +1 -1
- package/dist/core/io/bulk-ids-input.js +2 -2
- package/dist/core/item/actionability.js +1 -1
- package/dist/core/item/deferred-fields.js +1 -1
- package/dist/core/item/dependency-reference.js +1 -1
- package/dist/core/item/id.js +1 -1
- package/dist/core/item/index.js +1 -1
- package/dist/core/item/item-format-version.js +1 -1
- package/dist/core/item/item-format.js +7 -7
- package/dist/core/item/item-record.js +1 -1
- package/dist/core/item/item-type-definition.js +1 -1
- package/dist/core/item/literal-mutation-input.js +1 -1
- package/dist/core/item/parent-reference-policy.js +1 -1
- package/dist/core/item/parse.js +8 -8
- package/dist/core/item/plan-lifecycle.js +1 -1
- package/dist/core/item/priority.js +1 -1
- package/dist/core/item/sprint-release-format.js +1 -1
- package/dist/core/item/status-filter.js +1 -1
- package/dist/core/item/status.js +1 -1
- package/dist/core/item/toon-decode.js +1 -1
- package/dist/core/item/type-registry.js +1 -1
- package/dist/core/item/type-synonyms.js +1 -1
- package/dist/core/lock/index.js +1 -1
- package/dist/core/lock/lock-confinement.js +1 -1
- package/dist/core/lock/lock-gc.js +1 -1
- package/dist/core/lock/lock-owner.js +1 -1
- package/dist/core/lock/lock.js +4 -4
- package/dist/core/output/linked-test-projection.js +5 -5
- package/dist/core/output/mutation-projection.js +1 -1
- package/dist/core/output/output-control.js +1 -1
- package/dist/core/output/output.js +19 -19
- package/dist/core/output/query-summary.js +1 -1
- package/dist/core/output/tabular.js +3 -3
- package/dist/core/packages/manifest.js +1 -1
- package/dist/core/packages/root.js +1 -1
- package/dist/core/policy/workflow-policy-schema.js +1 -1
- package/dist/core/policy/workflow-policy-store.js +1 -1
- package/dist/core/policy/workflow-policy.js +1 -1
- package/dist/core/profile/profile-describe.js +1 -1
- package/dist/core/profile/profile-lint.d.ts +1 -1
- package/dist/core/profile/profile-lint.js +1 -1
- package/dist/core/profile/profile-plan.js +1 -1
- package/dist/core/profile/profile-presets.js +4 -4
- package/dist/core/reproducibility/context.js +1 -1
- package/dist/core/schema/fields-file.js +2 -2
- package/dist/core/schema/item-types-file.js +2 -2
- package/dist/core/schema/runtime-field-filters.js +1 -1
- package/dist/core/schema/runtime-field-values.js +1 -1
- package/dist/core/schema/runtime-schema.js +2 -2
- package/dist/core/schema/status-defs-file.js +2 -2
- package/dist/core/schema/status-token.js +1 -1
- package/dist/core/schema/type-inference.js +1 -1
- package/dist/core/schema/type-presets.js +1 -1
- package/dist/core/schema/type-workflows.js +1 -1
- package/dist/core/search/background-refresh.js +2 -2
- package/dist/core/search/bm25.js +1 -1
- package/dist/core/search/cache.js +2 -2
- package/dist/core/search/corpus.js +1 -1
- package/dist/core/search/embedding-batches.js +1 -1
- package/dist/core/search/eval-thresholds.js +1 -1
- package/dist/core/search/eval.js +1 -1
- package/dist/core/search/http-client.js +1 -1
- package/dist/core/search/providers.js +1 -1
- package/dist/core/search/relevance.js +1 -1
- package/dist/core/search/semantic-defaults.js +1 -1
- package/dist/core/search/staleness.js +1 -1
- package/dist/core/search/vector-stores.js +2 -2
- package/dist/core/search/vectorization-metadata.js +1 -1
- package/dist/core/sentry/helpers.js +1 -1
- package/dist/core/sentry/instrument.js +1 -1
- package/dist/core/sentry/sensitive-assignments.js +1 -1
- package/dist/core/session/session-state.js +1 -1
- package/dist/core/shared/agent-session-context.js +1 -1
- package/dist/core/shared/author.js +5 -5
- package/dist/core/shared/command-line.js +1 -1
- package/dist/core/shared/command-types.js +0 -1
- package/dist/core/shared/conflict-markers.js +1 -1
- package/dist/core/shared/constants.js +1 -1
- package/dist/core/shared/error-details.js +1 -1
- package/dist/core/shared/errors.js +1 -1
- package/dist/core/shared/html-entity-decode.js +1 -1
- package/dist/core/shared/index.js +1 -1
- package/dist/core/shared/item-metadata-contract.js +1 -1
- package/dist/core/shared/lazy-module.js +1 -1
- package/dist/core/shared/levenshtein.js +1 -1
- package/dist/core/shared/memo.js +1 -1
- package/dist/core/shared/numeric-parsers.js +1 -1
- package/dist/core/shared/option-alias-visibility.js +1 -1
- package/dist/core/shared/output-unicode.js +1 -1
- package/dist/core/shared/primitives.js +1 -1
- package/dist/core/shared/process-tree.js +2 -2
- package/dist/core/shared/secret-rules.js +5 -5
- package/dist/core/shared/serial-queue.js +1 -1
- package/dist/core/shared/serialization.js +1 -1
- package/dist/core/shared/split-comma-list.js +1 -1
- package/dist/core/shared/text-normalization.js +1 -1
- package/dist/core/shared/time.js +2 -2
- package/dist/core/shared/url-credentials.js +1 -1
- package/dist/core/store/index.js +1 -1
- package/dist/core/store/item-format-migration.js +1 -1
- package/dist/core/store/item-metadata-cache.js +1 -1
- package/dist/core/store/item-metadata-query-index.js +11 -11
- package/dist/core/store/item-metadata-read-work.js +1 -1
- package/dist/core/store/item-mutation-precondition.js +1 -1
- package/dist/core/store/item-store.js +1 -1
- package/dist/core/store/paths.js +1 -1
- package/dist/core/store/settings-concurrency.js +1 -1
- package/dist/core/store/settings-read-cache.js +1 -1
- package/dist/core/store/settings-sections.js +2 -2
- package/dist/core/store/settings-validator.js +1 -1
- package/dist/core/store/settings.d.ts +3 -1
- package/dist/core/store/settings.js +6 -6
- package/dist/core/store/sqlite-runtime.js +1 -1
- package/dist/core/store/tracker-preflight.js +1 -1
- package/dist/core/store/transaction-coordinator-scope.js +1 -1
- package/dist/core/telemetry/consent.js +3 -3
- package/dist/core/telemetry/observability.js +1 -1
- package/dist/core/telemetry/policy.js +1 -1
- package/dist/core/telemetry/read-sampling.js +2 -2
- package/dist/core/telemetry/runtime.js +9 -9
- package/dist/core/test/background-runs.js +4 -4
- package/dist/core/test/item-test-run-tracking.js +1 -1
- package/dist/core/test/run-selectors.js +1 -1
- package/dist/core/validate/estimate-defaults.js +1 -1
- package/dist/core/validate/fix-planning.js +1 -1
- package/dist/core/validate/linked-artifact-reference.js +1 -1
- package/dist/core/validate/missing-by-type.js +1 -1
- package/dist/core/validate/missing-link-owners.js +1 -1
- package/dist/core/validate/stale-file-classification.js +1 -1
- package/dist/mcp/http-server.js +5 -5
- package/dist/mcp/legacy-adapter.js +1 -1
- package/dist/mcp/runtime-capabilities.js +1 -1
- package/dist/mcp/server.js +4 -4
- package/dist/mcp/tool-definitions.js +1 -1
- package/dist/sdk/actionability.js +1 -1
- package/dist/sdk/agent/closed-domain-contracts.js +1 -1
- package/dist/sdk/agent/command-recovery.js +1 -1
- package/dist/sdk/agent/command-suggestions.js +1 -1
- package/dist/sdk/agent/create-option-policy.js +1 -1
- package/dist/sdk/agent/identity-config.js +1 -1
- package/dist/sdk/agent/item-addressing.js +1 -1
- package/dist/sdk/agent/linked-resource-recovery.js +1 -1
- package/dist/sdk/agent/refusal-closure-census.js +2 -2
- package/dist/sdk/agent/refusal-corpus-contracts.js +1 -1
- package/dist/sdk/agent/subcommand-recovery.js +1 -1
- package/dist/sdk/agent-capability-contracts.js +3 -3
- package/dist/sdk/agent-session-context.js +1 -1
- package/dist/sdk/annotations.js +1 -1
- package/dist/sdk/author-attribution.js +1 -1
- package/dist/sdk/cli-bootstrap.js +1 -1
- package/dist/sdk/cli-contracts/agent-output-contracts.js +5 -5
- package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -1
- package/dist/sdk/cli-contracts/command-aliases.js +1 -1
- package/dist/sdk/cli-contracts/command-exit-contracts.js +1 -1
- package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
- package/dist/sdk/cli-contracts/commander-types.js +1 -1
- package/dist/sdk/cli-contracts/completeness.js +1 -1
- package/dist/sdk/cli-contracts/enum-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +2 -2
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
- package/dist/sdk/cli-contracts/registration-helpers.js +7 -7
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/cli-contracts/schemas/assurance-definition.js +1 -1
- package/dist/sdk/cli-contracts/string-lists.js +1 -1
- package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +2 -2
- package/dist/sdk/cli-contracts/typed-action-inputs.js +0 -1
- package/dist/sdk/cli-contracts.js +1 -1
- package/dist/sdk/cli-program.js +1 -1
- package/dist/sdk/command-line.js +1 -1
- package/dist/sdk/comments.js +1 -1
- package/dist/sdk/compile-cache.js +1 -1
- package/dist/sdk/completion/bash.js +2 -2
- package/dist/sdk/completion/fish.js +74 -73
- package/dist/sdk/completion/shared.js +1 -1
- package/dist/sdk/completion/zsh.js +77 -76
- package/dist/sdk/completion.js +1 -1
- package/dist/sdk/config.js +1 -1
- package/dist/sdk/context/recency.js +1 -1
- package/dist/sdk/context/semantic-session-attribution.js +1 -1
- package/dist/sdk/context/usage-egress.js +1 -1
- package/dist/sdk/context/usage-ledger.js +6 -6
- package/dist/sdk/context-intent-contracts.js +1 -1
- package/dist/sdk/context-intent-runtime.js +1 -1
- package/dist/sdk/context-packing.js +1 -1
- package/dist/sdk/context-relevance.js +1 -1
- package/dist/sdk/context-signal-store.js +2 -2
- package/dist/sdk/context-usage.js +1 -1
- package/dist/sdk/dependencies/context-budget-recovery.js +1 -1
- package/dist/sdk/dependencies.js +1 -1
- package/dist/sdk/dependency-flag-validation.js +1 -1
- package/dist/sdk/dependency-provenance.js +1 -1
- package/dist/sdk/docs.js +1 -1
- package/dist/sdk/duplicates.js +1 -1
- package/dist/sdk/environment/host-environment-errors.js +1 -1
- package/dist/sdk/environment/project-runtime-compatibility.js +2 -2
- package/dist/sdk/environment/source-context.js +1 -1
- package/dist/sdk/environment/tracker-preflight.js +1 -1
- package/dist/sdk/error-code-catalog.js +1 -1
- package/dist/sdk/error-runtime.js +1 -1
- package/dist/sdk/errors.js +1 -1
- package/dist/sdk/eval.js +1 -1
- package/dist/sdk/extension/author-manifest.js +1 -1
- package/dist/sdk/extension/bundled-catalog.js +1 -1
- package/dist/sdk/extension/command-options.js +1 -1
- package/dist/sdk/extension/concurrency.js +1 -1
- package/dist/sdk/extension/copy-scope.js +1 -1
- package/dist/sdk/extension/custom-field-collisions.js +1 -1
- package/dist/sdk/extension/describe.js +3 -3
- package/dist/sdk/extension/doctor.js +1 -1
- package/dist/sdk/extension/install-plan.js +1 -1
- package/dist/sdk/extension/install-receipts.js +1 -1
- package/dist/sdk/extension/install-runtime.js +3 -3
- package/dist/sdk/extension/install-snapshot.js +1 -1
- package/dist/sdk/extension/install-sources.js +5 -5
- package/dist/sdk/extension/managed-state.js +2 -2
- package/dist/sdk/extension/managed-update-status.js +1 -1
- package/dist/sdk/extension/migrations.js +2 -2
- package/dist/sdk/extension/native-command-options.js +1 -1
- package/dist/sdk/extension/output-ownership.js +1 -1
- package/dist/sdk/extension/runtime-summary.js +1 -1
- package/dist/sdk/extension/scaffold.js +11 -11
- package/dist/sdk/extension/shared.js +1 -1
- package/dist/sdk/extension/source-resolution.js +1 -1
- package/dist/sdk/extension/static-inventory.js +1 -1
- package/dist/sdk/extension/update-check.js +1 -1
- package/dist/sdk/extension-command-context.js +2 -2
- package/dist/sdk/extension-contracts.js +1 -1
- package/dist/sdk/extension.js +1 -1
- package/dist/sdk/files.js +1 -1
- package/dist/sdk/flag-invocation-contracts.js +1 -1
- package/dist/sdk/generated/error-code-catalog-rows.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/generated-error-code-catalog.js +1 -1
- package/dist/sdk/governance/assurance-action-contracts.js +0 -1
- package/dist/sdk/governance/assurance-action.js +1 -1
- package/dist/sdk/governance/assurance-limits.js +1 -1
- package/dist/sdk/governance/assurance-mutation-error.js +1 -1
- package/dist/sdk/governance/assurance-presets.js +1 -1
- package/dist/sdk/governance/assurance-runtime.js +1 -1
- package/dist/sdk/governance/assurance.js +4 -4
- package/dist/sdk/governance/boundary-fixtures.js +1 -1
- package/dist/sdk/governance/closure-timestamps.js +1 -1
- package/dist/sdk/governance/defect-recurrence-coverage.js +1 -1
- package/dist/sdk/governance/defect-recurrence-graph.js +1 -1
- package/dist/sdk/governance/defect-recurrence-signals.js +1 -1
- package/dist/sdk/governance/defect-recurrence.js +2 -2
- package/dist/sdk/governance/extension-host-version.js +1 -1
- package/dist/sdk/governance/gc.js +1 -1
- package/dist/sdk/governance/health/history-drift-remedies.js +2 -0
- package/dist/sdk/governance/health/projection.js +1 -1
- package/dist/sdk/governance/health-merge-evidence.js +1 -1
- package/dist/sdk/governance/health.js +2 -2
- package/dist/sdk/governance/hierarchy-validation.js +1 -1
- package/dist/sdk/governance/in-progress-work-health.js +1 -1
- package/dist/sdk/governance/lifecycle-dependency-cycles.js +1 -1
- package/dist/sdk/governance/linked-file-report.js +1 -1
- package/dist/sdk/governance/merge-receipt-history.js +1 -1
- package/dist/sdk/governance/provenance-health.js +4 -4
- package/dist/sdk/governance/reindex.js +5 -5
- package/dist/sdk/governance/stale-work.js +1 -1
- package/dist/sdk/governance/status-role-diagnostics.js +1 -1
- package/dist/sdk/governance/storage-integrity.js +1 -1
- package/dist/sdk/governance/tracked-runtime-cache.js +1 -1
- package/dist/sdk/governance/upgrade.js +2 -2
- package/dist/sdk/governance/validate-deferred-fields.js +1 -1
- package/dist/sdk/governance/validate-history-drift.js +1 -1
- package/dist/sdk/governance/validate-item-reader.js +1 -1
- package/dist/sdk/governance/validate-normalization.js +1 -1
- package/dist/sdk/governance/validate.js +1 -1
- package/dist/sdk/governance/workflow-completeness.js +1 -1
- package/dist/sdk/governance/workflow-policy.js +3 -3
- package/dist/sdk/governance/workspace-position.js +2 -2
- package/dist/sdk/graph/analytics.js +1 -1
- package/dist/sdk/graph/assembly.js +1 -1
- package/dist/sdk/graph/cache.js +1 -1
- package/dist/sdk/graph/cardinality-integrity.js +1 -1
- package/dist/sdk/graph/centrality.js +1 -1
- package/dist/sdk/graph/deadline-scheduling.js +1 -1
- package/dist/sdk/graph/durable-cache.js +1 -1
- package/dist/sdk/graph/governance-contracts.js +1 -1
- package/dist/sdk/graph/governance.js +1 -1
- package/dist/sdk/graph/hierarchy-integrity.js +1 -1
- package/dist/sdk/graph/lifecycle-coverage.js +1 -1
- package/dist/sdk/graph/mutation-advisory.js +1 -1
- package/dist/sdk/graph/query-contracts.js +1 -1
- package/dist/sdk/graph/remediation.js +1 -1
- package/dist/sdk/graph/run.js +1 -1
- package/dist/sdk/graph/scheduling.js +1 -1
- package/dist/sdk/graph/traversal.js +1 -1
- package/dist/sdk/graph/workspace-relationship-kind-registry.js +1 -1
- package/dist/sdk/guide-topics.js +1 -1
- package/dist/sdk/guide.js +7 -7
- package/dist/sdk/history/append-only-repair.d.ts +30 -0
- package/dist/sdk/history/append-only-repair.js +6 -0
- package/dist/sdk/history/attestation-command.js +2 -2
- package/dist/sdk/history/attestation-contract.js +1 -1
- package/dist/sdk/history/attestation-scan.js +1 -1
- package/dist/sdk/history/attestation.js +1 -1
- package/dist/sdk/history/maintenance.d.ts +8 -2
- package/dist/sdk/history/maintenance.js +1 -1
- package/dist/sdk/history/reanchor-refusal.js +2 -0
- package/dist/sdk/history/reseed.d.ts +15 -0
- package/dist/sdk/history/reseed.js +2 -0
- package/dist/sdk/history/salvage.d.ts +19 -8
- package/dist/sdk/history/salvage.js +5 -3
- package/dist/sdk/history/subject.js +1 -1
- package/dist/sdk/history-analytics.js +1 -1
- package/dist/sdk/history-compact.js +1 -1
- package/dist/sdk/history-mcp.js +1 -1
- package/dist/sdk/history-provenance.js +1 -1
- package/dist/sdk/history-read.js +1 -1
- package/dist/sdk/history-redact.js +1 -1
- package/dist/sdk/history-repair.d.ts +8 -2
- package/dist/sdk/history-repair.js +1 -1
- package/dist/sdk/improvement-ledger-validation.js +1 -1
- package/dist/sdk/improvement-ledger.js +2 -2
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/init-agent-guidance.js +10 -10
- package/dist/sdk/init.js +14 -14
- package/dist/sdk/invocation-author.js +1 -1
- package/dist/sdk/item-children.js +1 -1
- package/dist/sdk/item-metadata-index.js +1 -1
- package/dist/sdk/item-schedule.js +1 -1
- package/dist/sdk/item-transaction.d.ts +33 -1
- package/dist/sdk/item-transaction.js +1 -1
- package/dist/sdk/learnings.js +1 -1
- package/dist/sdk/lifecycle/append.js +3 -3
- package/dist/sdk/lifecycle/checkpoint-rollback.js +1 -1
- package/dist/sdk/lifecycle/claim.js +1 -1
- package/dist/sdk/lifecycle/cli-input.js +1 -1
- package/dist/sdk/lifecycle/close-many.js +1 -1
- package/dist/sdk/lifecycle/close.js +1 -1
- package/dist/sdk/lifecycle/copy.js +1 -1
- package/dist/sdk/lifecycle/core-field-recovery.js +1 -1
- package/dist/sdk/lifecycle/core-item-fields.js +1 -1
- package/dist/sdk/lifecycle/create-deferrals.js +1 -1
- package/dist/sdk/lifecycle/create.js +1 -1
- package/dist/sdk/lifecycle/delete.js +1 -1
- package/dist/sdk/lifecycle/dependency-removal.js +1 -1
- package/dist/sdk/lifecycle/event-validation-messages.js +1 -1
- package/dist/sdk/lifecycle/focus.js +1 -1
- package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -1
- package/dist/sdk/lifecycle/item-revision.js +1 -1
- package/dist/sdk/lifecycle/legacy-none-tokens.js +1 -1
- package/dist/sdk/lifecycle/lifecycle-transitions.js +1 -1
- package/dist/sdk/lifecycle/mcp-actions.js +1 -1
- package/dist/sdk/lifecycle/metadata-normalizers.js +1 -1
- package/dist/sdk/lifecycle/mutation-command-options.js +0 -1
- package/dist/sdk/lifecycle/mutation-facet-contracts.js +1 -1
- package/dist/sdk/lifecycle/mutation-option-validation.js +1 -1
- package/dist/sdk/lifecycle/plan-mutation-receipt.js +1 -1
- package/dist/sdk/lifecycle/plan.js +1 -1
- package/dist/sdk/lifecycle/recurrence-parsers.js +1 -1
- package/dist/sdk/lifecycle/release-handoff.js +1 -1
- package/dist/sdk/lifecycle/reopen.js +1 -1
- package/dist/sdk/lifecycle/repeatable-metadata-parsers.js +2 -2
- package/dist/sdk/lifecycle/repeated-terminal-state.js +1 -1
- package/dist/sdk/lifecycle/restore.js +1 -1
- package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
- package/dist/sdk/lifecycle/start-blockers.js +1 -1
- package/dist/sdk/lifecycle/structured-mutation-plan.js +1 -1
- package/dist/sdk/lifecycle/task-composition.js +1 -1
- package/dist/sdk/lifecycle/update-many.js +1 -1
- package/dist/sdk/lifecycle/update.js +2 -2
- package/dist/sdk/lifecycle/workflow-transition.js +1 -1
- package/dist/sdk/lifecycle-completion.js +1 -1
- package/dist/sdk/lifecycle-policy.js +1 -1
- package/dist/sdk/linked-artifacts.js +2 -2
- package/dist/sdk/mcp/apps.js +5 -5
- package/dist/sdk/mcp/authorization.js +1 -1
- package/dist/sdk/mcp/discovery.js +1 -1
- package/dist/sdk/mcp/executable.js +4 -4
- package/dist/sdk/mcp/interactions.js +1 -1
- package/dist/sdk/mcp/protocol.js +1 -1
- package/dist/sdk/mcp/skills.js +3 -3
- package/dist/sdk/mcp/subscriptions.js +1 -1
- package/dist/sdk/mcp/tasks.js +2 -2
- package/dist/sdk/mcp/transport.js +1 -1
- package/dist/sdk/merge/abandoned-receipts.js +1 -1
- package/dist/sdk/merge/driver.js +7 -7
- package/dist/sdk/merge/history-scalar-rebase.js +1 -1
- package/dist/sdk/merge/ignored-artifacts.js +1 -1
- package/dist/sdk/merge/index.js +1 -1
- package/dist/sdk/merge/indexed-receipt-blobs.js +2 -2
- package/dist/sdk/merge/install.js +6 -6
- package/dist/sdk/merge/receipt-file-boundary.js +1 -1
- package/dist/sdk/merge/receipt-operation.js +1 -1
- package/dist/sdk/merge/receipt-schema.js +1 -1
- package/dist/sdk/merge/receipts.js +4 -4
- package/dist/sdk/merge/reconcile.js +1 -1
- package/dist/sdk/merge/settlement-hook.js +4 -4
- package/dist/sdk/merge/stage.js +1 -1
- package/dist/sdk/merge/three-way.d.ts +22 -3
- package/dist/sdk/merge/three-way.js +9 -3
- package/dist/sdk/merge/worktree-config.js +2 -2
- package/dist/sdk/merge.js +1 -1
- package/dist/sdk/mutation-events.js +1 -1
- package/dist/sdk/mutation-guard.js +1 -1
- package/dist/sdk/notes.js +1 -1
- package/dist/sdk/output/fit-envelope.js +1 -1
- package/dist/sdk/output/list-envelope.js +1 -1
- package/dist/sdk/output/table-rows.js +1 -1
- package/dist/sdk/output-contracts.js +1 -1
- package/dist/sdk/output-projection.js +1 -1
- package/dist/sdk/output-token-accounting.js +1 -1
- package/dist/sdk/output.js +2 -2
- package/dist/sdk/ownership-source.js +1 -1
- package/dist/sdk/package-import-adapters.js +1 -1
- package/dist/sdk/package-migrations.js +1 -1
- package/dist/sdk/package-runtime-options.js +1 -1
- package/dist/sdk/pagination.js +1 -1
- package/dist/sdk/profile.js +5 -5
- package/dist/sdk/provenance.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/activity.js +1 -1
- package/dist/sdk/query/aggregate.js +1 -1
- package/dist/sdk/query/calendar.js +4 -4
- package/dist/sdk/query/complete-list.js +1 -1
- package/dist/sdk/query/context.js +2 -2
- package/dist/sdk/query/declared-blockers.js +1 -1
- package/dist/sdk/query/duplicate-candidates.js +1 -1
- package/dist/sdk/query/get-facet-roots.js +1 -1
- package/dist/sdk/query/get.js +1 -1
- package/dist/sdk/query/history.js +1 -1
- package/dist/sdk/query/item-filter-options.js +0 -1
- package/dist/sdk/query/light-metadata.js +1 -1
- package/dist/sdk/query/list-filter-shared.js +1 -1
- package/dist/sdk/query/list.js +1 -1
- package/dist/sdk/query/multi-value-filters.js +1 -1
- package/dist/sdk/query/next-ranking-policy.js +1 -1
- package/dist/sdk/query/next-ready-budget.js +1 -1
- package/dist/sdk/query/next.js +2 -2
- package/dist/sdk/query/parsers.js +1 -1
- package/dist/sdk/query/projection-contracts.js +1 -1
- package/dist/sdk/query/search/corpus.js +2 -2
- package/dist/sdk/query/search/filters.js +1 -1
- package/dist/sdk/query/search/input.js +1 -1
- package/dist/sdk/query/search/lexical.js +1 -1
- package/dist/sdk/query/search/response.js +1 -1
- package/dist/sdk/query/search/semantic.js +3 -3
- package/dist/sdk/query/search/types.js +0 -1
- package/dist/sdk/query/search-contracts.js +1 -1
- package/dist/sdk/query/search-pagination.js +1 -1
- package/dist/sdk/query/search-rendering.js +1 -1
- package/dist/sdk/query/search.js +1 -1
- package/dist/sdk/query/window-pagination.js +1 -1
- package/dist/sdk/query/workspace-contracts.js +1 -1
- package/dist/sdk/read-output/continuation.js +1 -1
- package/dist/sdk/read-output/extension.js +1 -1
- package/dist/sdk/read-output/options.js +1 -1
- package/dist/sdk/read-output/positional-rows.js +1 -1
- package/dist/sdk/read-output/provenance.js +1 -1
- package/dist/sdk/read-output/session-result.js +0 -1
- package/dist/sdk/read-output/surfaces.js +1 -1
- package/dist/sdk/read-output/tail-retention.js +1 -1
- package/dist/sdk/read-output-budget.js +1 -1
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/read-output-rows.js +1 -1
- package/dist/sdk/read-output-session.js +1 -1
- package/dist/sdk/relationship-analytics.js +1 -1
- package/dist/sdk/relationship-context.js +1 -1
- package/dist/sdk/relationship-history.js +6 -6
- package/dist/sdk/relationship-kinds/contract.js +1 -1
- package/dist/sdk/relationships.js +1 -1
- package/dist/sdk/reproducibility/process.js +1 -1
- package/dist/sdk/runtime/actions.js +1 -1
- package/dist/sdk/runtime/context.js +1 -1
- package/dist/sdk/runtime/mutation-admission.js +1 -1
- package/dist/sdk/runtime/mutation-value-validation.js +1 -1
- package/dist/sdk/runtime/schema-preview.js +1 -1
- package/dist/sdk/runtime/schema.js +1 -1
- package/dist/sdk/runtime-action-aliases.js +1 -1
- package/dist/sdk/runtime-extended-actions.js +1 -1
- package/dist/sdk/runtime-input.d.ts +8 -2
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +1 -1
- package/dist/sdk/runtime-public-contracts.js +0 -1
- package/dist/sdk/runtime-stats-options.js +1 -1
- package/dist/sdk/runtime.d.ts +9 -0
- package/dist/sdk/runtime.js +1 -1
- package/dist/sdk/scheduling-shortcuts.js +1 -1
- package/dist/sdk/schema/field-option-collisions.js +2 -0
- package/dist/sdk/schema-migration.js +4 -4
- package/dist/sdk/schema.js +7 -7
- package/dist/sdk/search-refresh-worker.js +1 -1
- package/dist/sdk/similarity-scoring.js +1 -1
- package/dist/sdk/similarity.js +1 -1
- package/dist/sdk/start-task-status.js +1 -1
- package/dist/sdk/stats.js +1 -1
- package/dist/sdk/structured-mutations.d.ts +5 -5
- package/dist/sdk/structured-mutations.js +1 -1
- package/dist/sdk/telemetry-flush.js +1 -1
- package/dist/sdk/telemetry.js +4 -4
- package/dist/sdk/templates.js +3 -3
- package/dist/sdk/test/batch.js +2 -2
- package/dist/sdk/test/command-args.js +1 -1
- package/dist/sdk/test/command-resolution.js +2 -2
- package/dist/sdk/test/entry.js +2 -2
- package/dist/sdk/test/execution-receipts.js +2 -2
- package/dist/sdk/test/execution.js +5 -5
- package/dist/sdk/test/json-path.js +1 -1
- package/dist/sdk/test/linked-command-detection.js +1 -1
- package/dist/sdk/test/measurements.js +1 -1
- package/dist/sdk/test/parsers.js +1 -1
- package/dist/sdk/test/prerequisites.js +1 -1
- package/dist/sdk/test/receipt-index-snapshot.js +1 -1
- package/dist/sdk/test/run-phases.js +1 -1
- package/dist/sdk/test/runs.js +1 -1
- package/dist/sdk/test/trust.js +2 -2
- package/dist/sdk/test/update.js +1 -1
- package/dist/sdk/test/workspace-snapshot.js +1 -1
- package/dist/sdk/traceability/runtime-files-lookup.js +1 -1
- package/dist/sdk/traceability/source-traceability.js +2 -2
- package/dist/sdk/tracker-root-discovery.js +1 -1
- package/dist/sdk/transactions/item-finalization.js +2 -0
- package/dist/sdk/workspace-contracts-cache.js +1 -1
- package/dist/sdk/workspace-contracts.js +1 -1
- package/dist/sdk/workspace-memory.js +2 -2
- package/dist/sdk/workspace-snapshot.js +5 -5
- package/dist/sdk/workspace-transaction-gc.js +1 -1
- package/dist/sdk/workspace-transaction.js +2 -2
- package/dist/sdk/workspace.js +6 -6
- package/dist/types/index.js +1 -1
- package/dist/types.d.ts +20 -0
- package/dist/types.js +1 -1
- package/docs/AGENT_GUIDE.md +1 -1
- package/docs/AGENT_RUNTIME_PRIMITIVES.md +1 -1
- package/docs/COMMANDS.md +7 -3
- package/docs/EXTENSIONS.md +1 -1
- package/docs/HISTORY_RECOVERY.md +229 -5
- package/docs/README.md +2 -2
- package/docs/SDK.md +174 -5
- package/docs/SDK_CONTEXT_COORDINATION.md +3 -2
- package/marketplace.json +1 -1
- package/node_modules/tar/package.json +2 -3
- package/package.json +31 -2
- 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-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/scripts/finalize-build.mjs +63 -24
- package/scripts/prepare-build-cache.mjs +28 -1
- package/dist/cli-bundle/chunks/chunk-2DXRTIC6.js +0 -21
- package/dist/cli-bundle/chunks/chunk-5647LU3A.js +0 -2287
- package/dist/cli-bundle/chunks/chunk-6QLEXRUG.js +0 -9
- package/dist/cli-bundle/chunks/chunk-AHQB7W2H.js +0 -3
- package/dist/cli-bundle/chunks/chunk-BKSVHOWI.js +0 -2
- package/dist/cli-bundle/chunks/chunk-CASX6SFI.js +0 -2
- package/dist/cli-bundle/chunks/chunk-CIKGG34F.js +0 -2
- package/dist/cli-bundle/chunks/chunk-D6ILFXZY.js +0 -2
- package/dist/cli-bundle/chunks/chunk-DEZPZOQ7.js +0 -2
- package/dist/cli-bundle/chunks/chunk-IB7UB5TE.js +0 -2
- package/dist/cli-bundle/chunks/chunk-IUIOTAF6.js +0 -9
- package/dist/cli-bundle/chunks/chunk-JVGRFU5H.js +0 -3
- package/dist/cli-bundle/chunks/chunk-KQIZ34SF.js +0 -3
- package/dist/cli-bundle/chunks/chunk-KVBIMFUG.js +0 -6
- package/dist/cli-bundle/chunks/chunk-LQBWLNZJ.js +0 -3
- package/dist/cli-bundle/chunks/chunk-NCFCBKIP.js +0 -2
- package/dist/cli-bundle/chunks/chunk-NT5AKFE5.js +0 -31
- package/dist/cli-bundle/chunks/chunk-PJXKA4QU.js +0 -125
- package/dist/cli-bundle/chunks/chunk-RMIRNYRG.js +0 -71
- package/dist/cli-bundle/chunks/chunk-RULHZRFN.js +0 -2
- package/dist/cli-bundle/chunks/chunk-S6HB3WL2.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SA4BNP3Q.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SPPHDVZE.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SRVTCYAU.js +0 -2
- package/dist/cli-bundle/chunks/chunk-WELSVDPU.js +0 -2
- package/dist/cli-bundle/chunks/chunk-XHJ3H5PL.js +0 -3
- package/dist/cli-bundle/chunks/chunk-XWHJIRNV.js +0 -8
- package/dist/cli-bundle/chunks/chunk-YJEBK7HU.js +0 -8
- package/dist/cli-bundle/chunks/chunk-YKJKQ7DM.js +0 -115
- package/dist/cli-bundle/chunks/chunk-YMUSRWV4.js +0 -9
- package/dist/cli-bundle/chunks/chunk-YR2KEBHP.js +0 -2
- package/dist/cli-bundle/chunks/context-budget-recovery-L2WP5S26.js +0 -2
- package/dist/cli-bundle/chunks/indexed-receipt-blobs-ITTXIN4K.js +0 -4
- package/dist/cli-bundle/chunks/item-transaction-7DFCG73I.js +0 -2
- package/dist/cli-bundle/chunks/mutation-actor-3TG636XG.js +0 -2
- package/dist/cli-bundle/chunks/mutation-admission-LICSDNNO.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-WWVECKFQ.js +0 -21
- package/dist/cli-bundle/chunks/register-operations-L6HFJNWD.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-K7UFG5TD.js +0 -2
- package/dist/cli-bundle/chunks/settlement-hook-BXN5LEQD.js +0 -7
- package/dist/cli-bundle/chunks/stage-57KH3KAC.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3IRCYJI5.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-3V53UBHN.js +0 -9
- package/dist/cli-bundle/focused-chunks/chunk-532WZV65.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-7A4QWNZX.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-C3O6JJPO.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-CR7CGEB2.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-CU2BRAOX.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-CWWKRI5P.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-EGN2HFRU.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-GHQVM6K6.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HGFNL5XI.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-I5LGPUWH.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-IQK5NPMG.js +0 -13
- package/dist/cli-bundle/focused-chunks/chunk-J63D6QST.js +0 -6
- package/dist/cli-bundle/focused-chunks/chunk-JMQJBZQ5.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-LNHUE4VV.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-MKM5NKD7.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-NP72ZDXE.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-OSLQD5VH.js +0 -102
- package/dist/cli-bundle/focused-chunks/chunk-QGKLRXP7.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-QSJW6NSQ.js +0 -66
- package/dist/cli-bundle/focused-chunks/chunk-RPE6IX26.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-SRDQSA6M.js +0 -91
- package/dist/cli-bundle/focused-chunks/chunk-SVOOGGAK.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-UOC6257J.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-URJ2E6AS.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-WXMI4AV5.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-XCJSHNXK.js +0 -27
- package/dist/cli-bundle/focused-chunks/chunk-XQQSSKJI.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-YOAYY3HE.js +0 -2
- package/dist/cli-bundle/focused-chunks/context-budget-recovery-5MKOCGY5.js +0 -2
- package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-AF4U3F3D.js +0 -4
- package/dist/cli-bundle/focused-chunks/item-transaction-HLBW7B3J.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-actor-62HKR5IO.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-X4PF2SG3.js +0 -2
- package/dist/cli-bundle/focused-chunks/settlement-hook-ARYCZQY4.js +0 -7
- package/dist/cli-bundle/focused-chunks/stage-O7T7CXBB.js +0 -2
- package/dist/sdk/agent/refusal-closure.js +0 -2
- package/dist/sdk/agent/refusal-reachability.js +0 -4
- package/dist/sdk/agent/task-transcript-contracts.js +0 -2
- package/dist/sdk/agent/tracker-preflight-contracts.js +0 -2
- package/dist/sdk/authoring.js +0 -2
- package/dist/sdk/compose.js +0 -2
- package/dist/sdk/contracts.js +0 -2
- package/dist/sdk/core-governance.js +0 -2
- package/dist/sdk/core.js +0 -2
- package/dist/sdk/corpus-shape.js +0 -2
- package/dist/sdk/define.js +0 -2
- package/dist/sdk/environment/agent-environment.js +0 -2
- package/dist/sdk/governance/artifact-ledgers.js +0 -2
- package/dist/sdk/governance/coverage-assurance.js +0 -2
- package/dist/sdk/governance/reliability.js +0 -2
- package/dist/sdk/governance.js +0 -2
- package/dist/sdk/graph/adapter.js +0 -2
- package/dist/sdk/graph/conformance.js +0 -2
- package/dist/sdk/graph/index.js +0 -2
- package/dist/sdk/graph.js +0 -2
- package/dist/sdk/index.js +0 -2
- package/dist/sdk/query.js +0 -2
- package/dist/sdk/relationship-migration.js +0 -2
- package/dist/sdk/testing.js +0 -8
- package/dist/sdk/workspace-recipe.js +0 -2
- package/docs/AGENT_PROVENANCE_ADR.md +0 -206
- package/docs/DEFECT_RECURRENCE.md +0 -257
- package/docs/PERFORMANCE.md +0 -204
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{quoteCommandArg as t,renderPmCommand as d}from"../command-line.js";function p(n,i){const a=d(["plan","show",n.plan.id,"--depth","deep",...i===void 0?[]:["--pm-path",i]]);return{kind:"plan_mutation",action:n.action,id:n.plan.id,status:n.plan.status,mode:n.plan.mode,steps_summary:n.plan.steps_summary,...n.step===void 0?{}:{step:{id:n.step.id,order:n.step.order,status:n.step.status}},materialized_count:n.materialized?.length??0,skipped_count:n.materialize_skipped?.length??0,warning_count:n.warnings.length,warnings:n.warnings.slice(0,3).map(e=>e.slice(0,160)),warnings_truncated:n.warnings.length>3||n.warnings.some(e=>e.length>160),next_action:n.next_actions?.[0]===void 0?a:i===void 0?n.next_actions[0]:`${n.next_actions[0]} --pm-path ${t(i)}`,inspection_command:a,omission_receipt:{has_omissions:!0,omitted_field_group_count:1,omitted_field_groups:[{name:"plan_detail",restore_with:a}]}}}export{p as buildPlanMutationReceipt};
|
|
2
2
|
//# sourceMappingURL=plan-mutation-receipt.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="caead750-d1ce-5727-a028-5d310494f6ea")}catch{}})();import{assertInitializedTracker}from"../environment/tracker-preflight.js";import{getActiveExtensionRegistrations,isTerminalStatus,resolveItemTypeRegistry,resolveRuntimeStatusRegistry,resolveTypeName,EXIT_CODE,PmCliError,splitCommaList,nowIso,locateItem,mutateItem,readLocatedItem,resolvePmRoot,readSettings,resolveAuthor,isTerminalPlanMode,preserveMutationStdinTokenFields,transferMutationStdinTokenPolicy}from"../runtime-primitives.js";import{PLAN_HARNESS_VALUES,PLAN_MODE_VALUES,PLAN_STEP_LINK_KIND_VALUES,PLAN_STEP_STATUS_VALUES}from"../../types/index.js";import{runCreate}from"./create.js";import{createUnknownSubcommandError}from"../agent/subcommand-recovery.js";import{parseIdentityOption}from"../../core/shared/url-credentials.js";import{PLAN_SHOW_DEPTH_VALUES}from"../query/projection-contracts.js";import{buildPlanMutationReceipt}from"./plan-mutation-receipt.js";const PLAN_SUBCOMMANDS=["create","show","add-step","update-step","complete-step","block-step","reorder-step","remove-step","link","unlink","decision","discovery","validation","resume","approve","materialize"],STEP_ID_PREFIX="plan-step-",DEFAULT_PLAN_MODE="draft",PLAN_TEMPLATE_NAMES=["bug-investigation","feature-implementation","refactoring-sprint"],PLAN_TEMPLATES={"bug-investigation":[{title:"Reproduce the bug",body:"Capture exact steps, inputs, and the observed vs expected behavior."},{title:"Locate the root cause",body:"Trace the failure to the responsible code path with evidence."},{title:"Write a failing test",body:"Add a regression test that fails for the current bug."},{title:"Implement the fix",body:"Apply the minimal change that makes the failing test pass."},{title:"Verify and document",body:"Run the full suite and record the resolution and verification."}],"feature-implementation":[{title:"Clarify requirements & acceptance criteria",body:"Confirm scope, edge cases, and done-conditions."},{title:"Design the approach",body:"Decide the data model, interfaces, and integration points."},{title:"Implement the change",body:"Build the feature behind the agreed design."},{title:"Add tests",body:"Cover the new behavior and its edge cases."},{title:"Update docs & changelog",body:"Document the feature and surface it to users."}],"refactoring-sprint":[{title:"Map the current structure & risks",body:"Inventory the code to change and its blast radius."},{title:"Add characterization tests",body:"Lock in current behavior before refactoring."},{title:"Refactor incrementally",body:"Apply small, reversible steps keeping tests green."},{title:"Verify behavior is unchanged",body:"Run the full suite and compare against the baseline."},{title:"Clean up & document",body:"Remove dead code and record the new structure."}]};function resolvePlanTemplateSteps(raw){const normalized=raw.trim().toLowerCase(),template=Object.prototype.hasOwnProperty.call(PLAN_TEMPLATES,normalized)?PLAN_TEMPLATES[normalized]:void 0;if(!template)throw new PmCliError(`Unknown plan template "${raw}". Allowed: ${PLAN_TEMPLATE_NAMES.join(", ")}`,EXIT_CODE.USAGE,{code:"unknown_plan_template",examples:[`pm plan create --title "Fix login crash" --template ${PLAN_TEMPLATE_NAMES[0]}`]});return template.map(step=>({...step}))}function planCompletionPct(completed,total){return total>0?Math.round(completed/total*100):0}function toOrderedStepTitles(value){return(Array.isArray(value)?value:value==null?[]:[value]).filter(entry=>entry!=null).map(entry=>(typeof entry=="string"?entry:String(entry)).trim()).filter(entry=>entry.length>0)}function toArray(value){return Array.isArray(value)?value.flatMap(entry=>splitCommaList(entry,{unique:!1})):typeof value=="string"&&value.trim().length>0?splitCommaList(value,{unique:!1}):[]}function toSpecArray(value){return Array.isArray(value)?value.map(entry=>entry.trim()).filter(Boolean):typeof value=="string"&&value.trim().length>0?[value.trim()]:[]}function asPlanMode(value,fallback=DEFAULT_PLAN_MODE){if(value===void 0)return fallback;const normalized=value.trim().toLowerCase(),found=PLAN_MODE_VALUES.find(entry=>entry===normalized);if(!found)throw new PmCliError(`Invalid plan mode "${value}". Allowed: ${PLAN_MODE_VALUES.join(", ")}`,EXIT_CODE.USAGE);return found}function asStepStatus(value,fallback="pending"){if(value===void 0)return fallback;const normalized=value.trim().toLowerCase(),found=PLAN_STEP_STATUS_VALUES.find(entry=>entry===normalized);if(!found)throw new PmCliError(`Invalid step status "${value}". Allowed: ${PLAN_STEP_STATUS_VALUES.join(", ")}`,EXIT_CODE.USAGE);return found}function asLinkKind(value,fallback="related"){if(value===void 0)return fallback;const normalized=value.trim().toLowerCase(),found=PLAN_STEP_LINK_KIND_VALUES.find(entry=>entry===normalized);if(!found)throw new PmCliError(`Invalid step link kind "${value}". Allowed: ${PLAN_STEP_LINK_KIND_VALUES.join(", ")}`,EXIT_CODE.USAGE);return found}function asHarness(value){if(value===void 0)return;const normalized=value.trim().toLowerCase();if(normalized.length===0)return;const found=PLAN_HARNESS_VALUES.find(entry=>entry===normalized);if(!found)throw new PmCliError(`Invalid plan harness "${value}". Allowed: ${PLAN_HARNESS_VALUES.join(", ")}`,EXIT_CODE.USAGE);return found}function asDepth(value){if(value===void 0)return"brief";const normalized=value.trim().toLowerCase(),found=PLAN_SHOW_DEPTH_VALUES.find(entry=>entry===normalized);if(!found)throw new PmCliError(`Invalid --depth "${value}". Allowed: ${PLAN_SHOW_DEPTH_VALUES.join(", ")}`,EXIT_CODE.USAGE);return found}function parsePlanFields(raw){if(raw===void 0)return null;const fields=raw.split(",").map(entry=>entry.trim()).filter(entry=>entry.length>0);if(fields.length===0)throw new PmCliError("Plan --fields requires a comma-separated list of plan field names",EXIT_CODE.USAGE);return fields}const PLAN_FIELD_KEYS=new Set(["id","title","status","mode","scope","harness","parent","resume_context","steps_summary","current_step","blocked_steps","steps","decisions","discoveries","validation","linked_items"]);function projectPlanForFields(plan,fields){const source=plan,projected={},unknownFields=[];for(const field of fields){const normalized=field.startsWith("plan.")?field.slice(5):field;if(normalized.length!==0){if(!PLAN_FIELD_KEYS.has(normalized)){unknownFields.push(field);continue}Object.prototype.hasOwnProperty.call(source,normalized)&&(projected[normalized]=source[normalized])}}if(unknownFields.length>0)throw new PmCliError(`Unknown Plan --fields value(s): ${unknownFields.join(", ")}`,EXIT_CODE.USAGE,{nextSteps:[`Use --fields ${[...PLAN_FIELD_KEYS].join(",")}`,"Run pm plan show <id> --depth brief for compact default fields."],recovery:{provided_fields:unknownFields,suggested_retry:`pm plan show <id> --fields ${[...PLAN_FIELD_KEYS].join(",")}`}});return projected}function parsePairList(raw,label){const out={};for(const entry of raw.split(",")){const trimmed=entry.trim();if(trimmed.length===0)continue;const equalsIndex=trimmed.indexOf("=");if(equalsIndex<=0)throw new PmCliError(`Invalid ${label} entry "${trimmed}"; expected key=value`,EXIT_CODE.USAGE,{code:"malformed_plan_step_evidence",required:`${label} entries must use comma-separated key=value fields.`,why:"Structured Plan evidence must be validated before it is persisted.",examples:['--file "path=src/index.ts,scope=project,note=implementation"','--test "command=pnpm test,note=regression"','--doc "path=docs/PLAN.md,scope=project"']});out[trimmed.slice(0,equalsIndex).trim().toLowerCase()]=trimmed.slice(equalsIndex+1).trim()}return out}function parseStepFile(spec){const fields=parsePairList(spec,"--file");if(!fields.path)throw new PmCliError("--file requires path=<value>",EXIT_CODE.USAGE,{code:"malformed_plan_step_evidence",required:"--file requires a non-empty path field.",why:"Plan file evidence needs a stable path for later verification."});const file={path:fields.path};return(fields.scope==="global"||fields.scope==="project")&&(file.scope=fields.scope),fields.note&&(file.note=fields.note),file}function parseStepTest(spec){const fields=parsePairList(spec,"--test");if(!fields.command&&!fields.path)throw new PmCliError("--test requires at least command=<value> or path=<value>",EXIT_CODE.USAGE,{code:"malformed_plan_step_evidence",required:"--test requires a command or path field.",why:"Plan test evidence must identify something runnable or inspectable."});const test={};return fields.command&&(test.command=fields.command),fields.path&&(test.path=fields.path),fields.note&&(test.note=fields.note),test}function parseStepDoc(spec){const fields=parsePairList(spec,"--doc");if(!fields.path)throw new PmCliError("--doc requires path=<value>",EXIT_CODE.USAGE,{code:"malformed_plan_step_evidence",required:"--doc requires a non-empty path field.",why:"Plan documentation evidence needs a stable path for later verification."});const doc={path:fields.path};return(fields.scope==="global"||fields.scope==="project")&&(doc.scope=fields.scope),fields.note&&(doc.note=fields.note),doc}function summarizeSteps(steps){const summary={total:steps.length,pending:0,in_progress:0,blocked:0,completed:0,skipped:0,superseded:0,completion_pct:0};for(const step of steps)summary[step.status]+=1;return summary.completion_pct=planCompletionPct(summary.completed,summary.total),summary}function newStepId(existing){const used=new Set(existing.map(step=>step.id));for(let cursor=existing.length+1;cursor<existing.length+1024;cursor+=1){const candidate=`${STEP_ID_PREFIX}${String(cursor).padStart(3,"0")}`;if(!used.has(candidate))return candidate}throw new PmCliError("Could not allocate step id (limit reached)",EXIT_CODE.GENERIC_FAILURE)}function resolveStepRef(steps,ref){const trimmed=ref.trim();if(trimmed.length===0)throw new PmCliError("Step reference cannot be empty",EXIT_CODE.USAGE);const direct=steps.find(step=>step.id===trimmed);if(direct)return direct;if(/^\d+$/.test(trimmed)){const order=Number.parseInt(trimmed,10),byOrder=steps.find(step=>step.order===order);if(byOrder)return byOrder}throw new PmCliError(`Step "${ref}" not found in plan`,EXIT_CODE.NOT_FOUND)}function classifyMaterializeSkip(step){if(step.status==="completed")return{reason:"already_completed"};const existingImplements=(step.linked_items??[]).find(link=>link.kind==="implements");if(existingImplements)return{reason:"already_materialized",existing_id:existingImplements.id}}function resolveMaterializeTargets(steps,refs){const allRefs=refs.filter(ref=>ref.trim().toLowerCase()==="all"),targets=[],skipped=[];if(allRefs.length>0){if(refs.length>allRefs.length)throw new PmCliError("pm plan materialize --steps all cannot be combined with other step refs",EXIT_CODE.USAGE);for(const step of steps.slice().sort((left,right)=>left.order-right.order)){const skip=classifyMaterializeSkip(step);if(skip){skipped.push({from_step:step.id,...skip});continue}targets.push(step)}return{targets,skipped}}const seen=new Set;for(const ref of refs){const step=resolveStepRef(steps,ref);if(seen.has(step.id))continue;seen.add(step.id);const skip=classifyMaterializeSkip(step);if(skip){skipped.push({from_step:step.id,...skip});continue}targets.push(step)}return{targets,skipped}}function resolvePlanLogText(kind,options){const canonical=kind==="decision"?options.decisionText:kind==="discovery"?options.discoveryText:options.validationText,shorthand=kind==="decision"?options.decision:kind==="discovery"?options.discovery:options.validation;return canonical?.trim()||shorthand?.trim()||void 0}function findCurrentStep(steps){return steps.find(step=>step.status==="in_progress")??steps.find(step=>step.status==="pending")}function blockedSteps(steps){return steps.filter(step=>step.status==="blocked").map(step=>({id:step.id,order:step.order,title:step.title,blocked_reason:step.blocked_reason}))}function projectPlan(item,depth="brief"){const steps=(item.plan_steps??[]).slice().sort((left,right)=>left.order-right.order),summary=summarizeSteps(steps),current=findCurrentStep(steps),projection={id:item.id,title:item.title,status:item.status,mode:item.plan_mode??DEFAULT_PLAN_MODE,scope:item.plan_scope,harness:item.plan_harness,parent:item.parent,resume_context:item.plan_resume_context,steps_summary:summary,current_step:current?{id:current.id,order:current.order,title:current.title,status:current.status}:void 0,blocked_steps:blockedSteps(steps),linked_items:(item.dependencies??[]).map(dep=>({id:dep.id,kind:dep.kind}))};return(depth==="standard"||depth==="deep")&&(projection.steps=steps),depth==="deep"&&(projection.decisions=item.plan_decisions??[],projection.discoveries=item.plan_discoveries??[],projection.validation=item.plan_validation??[]),projection}function nextActionsFor(planId,plan){const tips=[];return plan.steps_summary.total===0&&tips.push(`pm plan add-step ${planId} --step-title "First step"`),plan.current_step&&tips.push(`pm plan update-step ${planId} ${plan.current_step.id} --step-status in_progress`,`pm plan complete-step ${planId} ${plan.current_step.id} --step-evidence "..."`),plan.steps_summary.blocked>0&&tips.push(`pm plan show ${planId} --depth standard`),(plan.mode==="draft"||plan.mode==="research")&&tips.push(`pm plan approve ${planId} --message "ready to execute"`),plan.steps_summary.completed===plan.steps_summary.total&&plan.steps_summary.total>0&&!isTerminalPlanMode(plan.mode)&&plan.status!=="closed"&&plan.status!=="canceled"&&tips.push(`pm close ${planId} "plan complete"`),tips}function ensurePlanItem(item){if((item.type??"").trim().toLowerCase()!=="plan")throw new PmCliError(`Item ${item.id} is type ${item.type}; pm plan commands require type=Plan. Use pm plan create or pm create --type Plan first.`,EXIT_CODE.USAGE,{code:"wrong_item_type",required:"Use pm plan commands only with items whose type is Plan.",why:"Plan commands read and mutate Plan-specific step, decision, discovery, and validation fields.",examples:[`pm get ${item.id} --depth brief`,'pm plan create --title "Execution plan" --scope "<goal>"']})}async function loadContext(global2){const pmRoot=resolvePmRoot(process.cwd(),global2.path);await assertInitializedTracker(pmRoot);const settings=await readSettings(pmRoot);return{pmRoot,settings}}async function readPlanItem(ctx,id){const typeRegistry=resolveItemTypeRegistry(ctx.settings,getActiveExtensionRegistrations()),located=await locateItem(ctx.pmRoot,id,ctx.settings.id_prefix,ctx.settings.item_format,typeRegistry.type_to_folder);if(!located)throw new PmCliError(`Plan ${id} not found`,EXIT_CODE.NOT_FOUND);const loaded=await readLocatedItem(located,{schema:ctx.settings.schema});return ensurePlanItem(loaded.document.metadata),{document:loaded.document,itemId:located.id}}function buildPlanCreateDependencies(options){const deps=[];for(const ref of toArray(options.related))deps.push(`id=${ref},kind=related`);for(const ref of toArray(options.blocks))deps.push(`id=${ref},kind=blocks`);for(const ref of toArray(options.blockedBy))deps.push(`id=${ref},kind=blocked_by`);return deps.length>0?deps:void 0}function buildInitialValidation(options){const text=options.validationText?.trim(),command=options.validationCommand?.trim(),expected=options.validationExpected?.trim();if(!(!text&&!command&&!expected))return{text:text||command||"Validation check",command:command||void 0,expected:expected||void 0}}function hasPlanStepDetailOptions(options){return!!options.stepBody?.trim()||!!options.stepOwner?.trim()||!!options.stepStatus?.trim()||!!options.stepEvidence?.trim()||!!options.stepBlockedReason?.trim()||!!options.stepReplacement?.trim()||toArray(options.dependsOn).length>0||toArray(options.link).length>0}function resolveInitialStepSeed(options){const stepTitleFlag=options.stepTitle?.trim()||void 0,repeatedStepTitles=toOrderedStepTitles(options.step),templateSteps=options.template?.trim()?resolvePlanTemplateSteps(options.template):[];return{repeatedStepTitles,stepTitleFlag,stepTitles:[...stepTitleFlag?[stepTitleFlag]:[],...repeatedStepTitles,...templateSteps.map(step=>step.title)],templateSteps}}function assertInitialStepSeedAllowed(seed,hasPerStepDetailOptions){if((seed.stepTitleFlag||seed.repeatedStepTitles.length>0)&&seed.templateSteps.length>0)throw new PmCliError("pm plan create --template cannot be combined with --step-title or --step; choose one step seeding source",EXIT_CODE.USAGE,{code:"ambiguous_option_combination",examples:[`pm plan create --title "Fix login crash" --template ${PLAN_TEMPLATE_NAMES[0]}`,'pm plan create --title "Custom plan" --step "Read the code" --step "Write the fix"']});if(seed.stepTitles.length>1&&hasPerStepDetailOptions)throw new PmCliError("pm plan create per-step options apply to a single initial step; with multiple --step values create the plan first, then refine steps individually",EXIT_CODE.USAGE,{code:"ambiguous_option_combination",examples:['pm plan create --title "Execution plan" --step "Read the code" --step "Write the fix"','pm plan update-step <plan-id> plan-step-001 --step-body "Inspect retry path"']})}function buildSingleInitialStep(options,title){const status=asStepStatus(options.stepStatus,"pending"),linkedItems=buildLinkInputs(options,"depends_on"),files=toSpecArray(options.file).map(parseStepFile),tests=toSpecArray(options.test).map(parseStepTest),docs=toSpecArray(options.doc).map(parseStepDoc),now=nowIso();return{id:"plan-step-001",order:1,title,body:options.stepBody?.trim()||void 0,status,owner:resolveStepOwner(options.stepOwner),evidence:options.stepEvidence?.trim()||void 0,blocked_reason:status==="blocked"?options.stepBlockedReason?.trim()||"":void 0,linked_items:linkedItems.length>0?linkedItems:void 0,files:files.length>0?files:void 0,tests:tests.length>0?tests:void 0,docs:docs.length>0?docs:void 0,created_at:now,updated_at:now,completed_at:status==="completed"?now:void 0}}function buildInitialSteps(options){const seed=resolveInitialStepSeed(options),hasDetailOptions=hasPlanStepDetailOptions(options);if(assertInitialStepSeedAllowed(seed,hasDetailOptions),seed.stepTitles.length===0)return{steps:[],hasPerStepDetailOptions:hasDetailOptions};if(seed.stepTitles.length===1)return{steps:[buildSingleInitialStep(options,seed.stepTitles[0])],hasPerStepDetailOptions:hasDetailOptions};const now=nowIso();return{steps:seed.stepTitles.map((stepTitle,index)=>({id:`${STEP_ID_PREFIX}${String(index+1).padStart(3,"0")}`,order:index+1,title:stepTitle,body:seed.templateSteps[index]?.body,status:"pending",created_at:now,updated_at:now})),hasPerStepDetailOptions:hasDetailOptions}}function preservePlanCreateStdinPolicy(source,createOptions,derivedLiteralFields=[]){transferMutationStdinTokenPolicy(source,createOptions),derivedLiteralFields.length>0&&preserveMutationStdinTokenFields(createOptions,derivedLiteralFields)}async function planCreate(options,global2,ctx){const title=options.title?.trim();if(!title)throw new PmCliError("pm plan create requires --title",EXIT_CODE.USAGE,{code:"missing_required_option",examples:['pm plan create --title "Refactor lock retry" --scope pm-a1b2']});const mode=asPlanMode(options.mode,DEFAULT_PLAN_MODE),harness=asHarness(options.harness),fromSearch=options.fromSearch?.trim(),initialValidation=buildInitialValidation(options),{steps:initialSteps,hasPerStepDetailOptions}=buildInitialSteps(options);if(initialSteps.length===0&&hasPerStepDetailOptions)throw new PmCliError("pm plan create step options require --step-title (or a single --step)",EXIT_CODE.USAGE,{code:"missing_required_option",examples:['pm plan create --title "Execution plan" --step-title "Read the code"']});const description=options.description?.trim()??options.scope?.trim()??title,requestedAssignee=options.claim?resolveAuthor(options.author,ctx.settings.author_default):options.assignee?.trim()||void 0,createOptions={...options,title,description,type:"Plan",template:void 0,file:toSpecArray(options.file),test:toSpecArray(options.test),doc:toSpecArray(options.doc),field:toSpecArray(options.field),assignee:resolveAuthor(options.author,ctx.settings.author_default),blockedBy:void 0,dep:buildPlanCreateDependencies(options),message:options.message??(fromSearch?`plan create (search: ${fromSearch})`:"plan create")};preservePlanCreateStdinPolicy(options,createOptions);const createResult=await runCreate(createOptions,global2),seedResult=await mutateItem({pmRoot:ctx.pmRoot,settings:ctx.settings,id:createResult.item.id,op:"plan_create_metadata",author:resolveAuthor(options.author,ctx.settings.author_default),message:"seed plan metadata",mutate(doc){const changedFields=["plan_mode"];doc.metadata.plan_mode=mode,harness&&(doc.metadata.plan_harness=harness,changedFields.push("plan_harness"));const scope=options.scope?.trim();scope&&(doc.metadata.plan_scope=scope,changedFields.push("plan_scope"));const resumeContext=options.resumeContext?.trim();return resumeContext&&(doc.metadata.plan_resume_context=resumeContext,changedFields.push("plan_resume_context")),doc.metadata.plan_steps=initialSteps,changedFields.push("plan_steps"),initialValidation&&(doc.metadata.plan_validation=[...doc.metadata.plan_validation??[],initialValidation],changedFields.push("plan_validation")),requestedAssignee&&(doc.metadata.assignee=requestedAssignee,changedFields.push("assignee")),{changedFields}}}),plan=projectPlan(seedResult.item,"brief");return{action:"create",plan,step:initialSteps[0],next_actions:nextActionsFor(createResult.item.id,plan),warnings:[...createResult.warnings],generated_at:nowIso()}}async function planShow(id,options,ctx){const depth=asDepth(options.depth),fields=parsePlanFields(options.fields),{document,itemId}=await readPlanItem(ctx,id),fullPlan=projectPlan(document.metadata,fields===null?depth:"deep");return{action:"show",plan:fields===null?fullPlan:projectPlanForFields(fullPlan,fields),next_actions:nextActionsFor(itemId,fullPlan),warnings:[],generated_at:nowIso()}}function changedPlanMetadataFields(beforePlanFields,metadata){const afterPlanFields=new Map(Object.entries(metadata).filter(([key])=>key.startsWith("plan_")).map(([key,value])=>[key,JSON.stringify(value)]));return[...new Set([...beforePlanFields.keys(),...afterPlanFields.keys()])].filter(key=>beforePlanFields.get(key)!==afterPlanFields.get(key))}async function mutatePlanSteps(args){const author=resolveAuthor(args.options.author,args.ctx.settings.author_default);let resultStep;const result=await mutateItem({pmRoot:args.ctx.pmRoot,settings:args.ctx.settings,id:args.id,op:args.op,author,message:args.options.message??args.message,force:args.options.force,mutate(doc){ensurePlanItem(doc.metadata);const statusRegistry=resolveRuntimeStatusRegistry(args.ctx.settings.schema);if(isTerminalStatus(doc.metadata.status,statusRegistry)||isTerminalPlanMode(doc.metadata.plan_mode))throw new PmCliError(`Plan ${doc.metadata.id} is terminal (status=${doc.metadata.status}, plan_mode=${doc.metadata.plan_mode??"unset"}) and cannot be mutated.`,EXIT_CODE.CONFLICT,{code:"terminal_plan_mutation",required:"Create or reopen a non-terminal Plan before changing its execution context or steps.",why:"Terminal Plan history is immutable execution evidence."});const steps=(doc.metadata.plan_steps??[]).slice(),beforePlanFields=new Map(Object.entries(doc.metadata).filter(([key])=>key.startsWith("plan_")).map(([key,value])=>[key,JSON.stringify(value)])),outcome=args.mutator(steps,doc);resultStep=outcome.resultStep;const sorted=steps.slice().sort((left,right)=>left.order-right.order).map((step,index)=>({...step,order:index+1}));doc.metadata.plan_steps=sorted;const changedFields=changedPlanMetadataFields(beforePlanFields,doc.metadata);return changedFields.length===0&&outcome.changedSteps.length===0?{changedFields:[]}:{changedFields:changedFields.length>0?changedFields:["plan_steps"]}}});return{document:{metadata:result.item,body:result.body},resultStep,itemId:result.item.id}}async function planAddStep(id,options,ctx){const title=options.stepTitle?.trim();if(!title)throw new PmCliError("pm plan add-step requires --step-title",EXIT_CODE.USAGE);const status=asStepStatus(options.stepStatus,"pending"),allowMultipleActive=options.allowMultipleActive===!0,{document,resultStep,itemId}=await mutatePlanSteps({id,options,ctx,op:"plan_add_step",message:`plan add-step "${title}"`,mutator(steps){const order=steps.length+1;assertInProgressStepAllowed(steps,void 0,status,allowMultipleActive);const step=buildAddedPlanStep(steps,options,{order,title,status});return steps.push(step),{changedSteps:[step.id],resultStep:step}}}),plan=projectPlan(document.metadata,"standard");return{action:"add-step",plan,step:resultStep,next_actions:nextActionsFor(itemId,plan),warnings:[],generated_at:nowIso()}}function assertInProgressStepAllowed(steps,currentStepId,desiredStatus,allowMultipleActive){if(desiredStatus!=="in_progress"||allowMultipleActive)return;const activeStep=steps.find(step=>step.id!==currentStepId&&step.status==="in_progress");if(activeStep)throw new PmCliError(`Plan already has step ${activeStep.id} in_progress. Pass --allow-multiple-active or update that step first.`,EXIT_CODE.CONFLICT)}function buildAddedPlanStep(existingSteps,options,seed){const linkedItems=buildLinkInputs(options,"depends_on"),files=toSpecArray(options.file).map(parseStepFile),tests=toSpecArray(options.test).map(parseStepTest),docs=toSpecArray(options.doc).map(parseStepDoc),now=nowIso();return{id:newStepId(existingSteps),order:seed.order,title:seed.title,body:options.stepBody?.trim()||void 0,status:seed.status,owner:resolveStepOwner(options.stepOwner),evidence:options.stepEvidence?.trim()||void 0,blocked_reason:seed.status==="blocked"?options.stepBlockedReason?.trim()||"":void 0,linked_items:linkedItems.length>0?linkedItems:void 0,files:files.length>0?files:void 0,tests:tests.length>0?tests:void 0,docs:docs.length>0?docs:void 0,created_at:now,updated_at:now,completed_at:seed.status==="completed"?now:void 0}}function buildLinkInputs(options,fallbackKind){const dependsOn=toArray(options.dependsOn).map(id=>({id,kind:fallbackKind})),related=toArray(options.related).map(id=>({id,kind:"related"})),blocks=toArray(options.blocks).map(id=>({id,kind:"blocks"})),blockedBy=toArray(options.blockedBy).map(id=>({id,kind:"blocked_by"})),explicit=toArray(options.link),explicitKind=asLinkKind(options.linkKind,fallbackKind),note=options.linkNote?.trim(),explicitLinks=explicit.map(id=>{const link={id,kind:explicitKind};return note&&(link.note=note),link});return[...dependsOn,...related,...blocks,...blockedBy,...explicitLinks]}async function planUpdateStep(id,options,ctx,args){const{document,resultStep,itemId}=await mutatePlanSteps({id,options,ctx,op:args.op,message:options.message??`${args.op} ${args.stepRef}`,mutator(steps,doc){const step=resolveStepRef(steps,args.stepRef),now=nowIso(),desiredStatus=args.finalStatus??asStepStatus(options.stepStatus,step.status),allowMultipleActive=options.allowMultipleActive===!0||args.allowMultipleActive===!0;return assertInProgressStepAllowed(steps,step.status==="in_progress"?step.id:void 0,desiredStatus,allowMultipleActive),applyStepUpdates(step,options,desiredStatus,now),doc.metadata.updated_at=now,{changedSteps:[step.id],resultStep:step}}}),plan=projectPlan(document.metadata,"standard");return{action:args.op==="plan_complete_step"?"complete-step":args.op==="plan_block_step"?"block-step":"update-step",plan,step:resultStep,next_actions:nextActionsFor(itemId,plan),warnings:[],generated_at:nowIso()}}function resolveStepOwner(value){return parseIdentityOption(value?.trim(),"--step-owner")||void 0}function applyStepUpdates(step,options,desiredStatus,now){assertBlockedStepReason(step,options,desiredStatus),applyStepFieldUpdates(step,options),step.status=desiredStatus,step.updated_at=now,applyStepCompletionTimestamp(step,desiredStatus,now)}function assertBlockedStepReason(step,options,desiredStatus){if(!(desiredStatus!=="blocked"||options.stepBlockedReason?.trim()||step.blocked_reason))throw new PmCliError("Blocking a step requires --step-blocked-reason or an already-recorded blocked_reason.",EXIT_CODE.USAGE)}function applyStepFieldUpdates(step,options){const title=options.stepTitle?.trim();title&&(step.title=title),options.stepBody!==void 0&&(step.body=options.stepBody.trim()||void 0),options.stepOwner!==void 0&&(step.owner=resolveStepOwner(options.stepOwner)),options.stepEvidence!==void 0&&(step.evidence=options.stepEvidence.trim()||void 0),options.stepBlockedReason!==void 0&&(step.blocked_reason=options.stepBlockedReason.trim()||void 0),options.stepReplacement!==void 0&&(step.superseded_by=options.stepReplacement.trim()||void 0);const files=toSpecArray(options.file).map(parseStepFile),tests=toSpecArray(options.test).map(parseStepTest),docs=toSpecArray(options.doc).map(parseStepDoc);files.length>0&&(step.files=mergePlanStepEvidence(step.files,files)),tests.length>0&&(step.tests=mergePlanStepEvidence(step.tests,tests)),docs.length>0&&(step.docs=mergePlanStepEvidence(step.docs,docs))}function mergePlanStepEvidence(existing,added){const merged=[...existing??[]],seen=new Set(merged.map(entry=>JSON.stringify(entry)));for(const entry of added){const key=JSON.stringify(entry);seen.has(key)||(seen.add(key),merged.push(entry))}return merged}function applyStepCompletionTimestamp(step,desiredStatus,now){if(desiredStatus==="completed"&&!step.completed_at){step.completed_at=now;return}desiredStatus!=="completed"&&(step.completed_at=void 0)}async function planReorderStep(id,options,ctx,stepRef,newOrder){const{document,itemId,resultStep}=await mutatePlanSteps({id,options,ctx,op:"plan_reorder_step",message:options.message??`plan reorder-step ${stepRef} -> ${newOrder}`,mutator(steps){const step=resolveStepRef(steps,stepRef),filtered=steps.filter(entry=>entry.id!==step.id),clamped=Math.max(1,Math.min(newOrder,filtered.length+1));return filtered.splice(clamped-1,0,step),filtered.forEach((entry,index)=>{entry.order=index+1,entry.updated_at=nowIso()}),steps.length=0,steps.push(...filtered),{changedSteps:[step.id],resultStep:step}}}),plan=projectPlan(document.metadata,"standard");return{action:"reorder-step",plan,step:resultStep,next_actions:nextActionsFor(itemId,plan),warnings:[],generated_at:nowIso()}}async function planRemoveStep(id,options,ctx,stepRef){const{document,itemId,resultStep}=await mutatePlanSteps({id,options,ctx,op:"plan_remove_step",message:options.message??`plan remove-step ${stepRef}`,mutator(steps){const step=resolveStepRef(steps,stepRef),remaining=steps.filter(entry=>entry.id!==step.id);return remaining.forEach((entry,index)=>{entry.order=index+1}),steps.length=0,steps.push(...remaining),{changedSteps:[step.id],resultStep:step}}}),plan=projectPlan(document.metadata,"standard");return{action:"remove-step",plan,step:resultStep,next_actions:nextActionsFor(itemId,plan),warnings:[],generated_at:nowIso()}}async function planLink(id,options,ctx,stepRef){const newLinks=buildLinkInputs(options,asLinkKind(options.linkKind,"related"));if(newLinks.length===0)throw new PmCliError("pm plan link requires at least one --link/--related/--blocks/--blocked-by/--depends-on id",EXIT_CODE.USAGE);const promoteToItemDep=options.promoteToItemDep===!0,{document,itemId,resultStep}=await mutatePlanSteps({id,options,ctx,op:"plan_link_step",message:options.message??`plan link ${stepRef}`,mutator(steps,doc){const step=resolveStepRef(steps,stepRef),existing=step.linked_items??[],dedupKey=link=>`${link.kind}:${link.id}`,seen=new Set(existing.map(dedupKey));for(const link of newLinks){const key=dedupKey(link);seen.has(key)||(existing.push(link),seen.add(key))}if(step.linked_items=existing,step.updated_at=nowIso(),promoteToItemDep){const deps=doc.metadata.dependencies??[],depKey=dep=>`${dep.kind}:${dep.id}`,seenDeps=new Set(deps.map(depKey));for(const link of newLinks){const promotedKind=link.kind==="depends_on"?"blocked_by":link.kind,candidate={id:link.id,kind:promotedKind,created_at:nowIso(),author:resolveAuthor(options.author,ctx.settings.author_default)};seenDeps.has(depKey(candidate))||(deps.push(candidate),seenDeps.add(depKey(candidate)))}doc.metadata.dependencies=deps}return{changedSteps:[step.id],resultStep:step}}}),plan=projectPlan(document.metadata,"standard");return{action:"link",plan,step:resultStep,next_actions:nextActionsFor(itemId,plan),warnings:[],generated_at:nowIso()}}async function planUnlink(id,options,ctx,stepRef){const removeIds=toArray(options.link);if(removeIds.length===0)throw new PmCliError("pm plan unlink requires --link <id> to remove",EXIT_CODE.USAGE);const{document,itemId,resultStep}=await mutatePlanSteps({id,options,ctx,op:"plan_unlink_step",message:options.message??`plan unlink ${stepRef}`,mutator(steps){const step=resolveStepRef(steps,stepRef),filtered=(step.linked_items??[]).filter(link=>!removeIds.includes(link.id));return step.linked_items=filtered.length>0?filtered:void 0,step.updated_at=nowIso(),{changedSteps:[step.id],resultStep:step}}}),plan=projectPlan(document.metadata,"standard");return{action:"unlink",plan,step:resultStep,next_actions:nextActionsFor(itemId,plan),warnings:[],generated_at:nowIso()}}async function planAppendLog(id,options,ctx,kind){const logText=resolvePlanLogText(kind,options);if(!logText){const canonical=`--${kind}-text`,shorthand=`--${kind}`;throw new PmCliError(`pm plan ${kind} requires ${canonical}`,EXIT_CODE.USAGE,{code:"missing_required_option",examples:[`pm plan ${kind} <plan-id> ${canonical} "..."`,`pm plan ${kind} <plan-id> ${shorthand} "..."`],recovery:{suggested_retry:`pm plan ${kind} <plan-id> ${canonical} <value>`}})}const author=resolveAuthor(options.author,ctx.settings.author_default),{document,itemId}=await mutatePlanSteps({id,options,ctx,op:`plan_append_${kind}`,message:options.message??`plan ${kind} append`,mutator(_steps,doc){const now=nowIso();if(kind==="decision"){const list2=doc.metadata.plan_decisions??[];return list2.push({ts:now,author,decision:logText,rationale:options.decisionRationale?.trim()||void 0,evidence:options.decisionEvidence?.trim()||void 0}),doc.metadata.plan_decisions=list2,{changedSteps:[]}}if(kind==="discovery"){const list2=doc.metadata.plan_discoveries??[];return list2.push({ts:now,author,text:logText}),doc.metadata.plan_discoveries=list2,{changedSteps:[]}}const list=doc.metadata.plan_validation??[];return list.push({text:logText,command:options.validationCommand?.trim()||void 0,expected:options.validationExpected?.trim()||void 0}),doc.metadata.plan_validation=list,{changedSteps:[]}}}),plan=projectPlan(document.metadata,"deep");return{action:kind,plan,next_actions:nextActionsFor(itemId,plan),warnings:[],generated_at:nowIso()}}async function planResume(id,options,ctx){const text=options.resumeContext?.trim();if(!text)throw new PmCliError("pm plan resume requires --resume-context <text>",EXIT_CODE.USAGE);const{document,itemId}=await mutatePlanSteps({id,options,ctx,op:"plan_resume",message:options.message??"plan resume context update",mutator(_steps,doc){doc.metadata.plan_resume_context=text;const scope=options.scope?.trim();return scope&&(doc.metadata.plan_scope=scope),{changedSteps:[]}}}),plan=projectPlan(document.metadata,"brief");return{action:"resume",plan,next_actions:nextActionsFor(itemId,plan),warnings:[],generated_at:nowIso()}}async function planApprove(id,options,ctx){const mode=asPlanMode(options.mode??"approved","approved"),{document,itemId}=await mutatePlanSteps({id,options,ctx,op:"plan_approve",message:options.message??`plan approve mode=${mode}`,mutator(_steps,doc){doc.metadata.plan_mode=mode;const scope=options.scope?.trim();return scope&&(doc.metadata.plan_scope=scope),{changedSteps:[]}}}),plan=projectPlan(document.metadata,"brief");return{action:"approve",plan,next_actions:nextActionsFor(itemId,plan),warnings:[],generated_at:nowIso()}}function buildMaterializeSkippedWarnings(materializeSkipped){return materializeSkipped.map(entry=>`plan_materialize_skipped:${entry.from_step}:${entry.reason}${entry.existing_id?`:${entry.existing_id}`:""}`)}function buildMaterializeNoopResult(planRead,materializeSkipped){const plan=projectPlan(planRead.document.metadata,"standard");return{action:"materialize",plan,materialized:[],materialize_skipped:materializeSkipped,next_actions:nextActionsFor(planRead.itemId,plan),warnings:buildMaterializeSkippedWarnings(materializeSkipped),generated_at:nowIso()}}function buildMaterializeDependencies(parent,planItemId,step){const deps=[`id=${parent},kind=parent`,`id=${planItemId},kind=discovered_from`];for(const link of step.linked_items??[]){const realKind=link.kind==="blocked_by"||link.kind==="blocks"||link.kind==="related"||link.kind==="discovered_from"?link.kind:"related";deps.push(`id=${link.id},kind=${realKind}`)}return deps}async function createMaterializedStepItems(params){const materialized=[],materializeFields={},reservedMaterializeKeys=new Set(["title","description","type","parent","tags","author","message","dep"]);for(const specification of toSpecArray(params.options.field)){const separator=specification.indexOf("=");if(separator<=0)throw new PmCliError(`Invalid --field entry "${specification}"; expected name=value`,EXIT_CODE.USAGE);const name=specification.slice(0,separator).trim(),value=specification.slice(separator+1).trim();if(name.length===0)throw new PmCliError(`Invalid --field entry "${specification}"; expected name=value`,EXIT_CODE.USAGE);const segments=name.trim().replaceAll(/([a-z0-9])([A-Z])/g,"$1 $2").replaceAll(/[^A-Za-z0-9]+/g," ").split(/\s+/).filter(Boolean).map(segment=>segment.toLowerCase());if(segments.length===0)throw new PmCliError(`Invalid --field entry "${specification}"; expected name=value`,EXIT_CODE.USAGE);const[first,...rest]=segments,fieldKey=`${first}${rest.map(segment=>`${segment.slice(0,1).toUpperCase()}${segment.slice(1)}`).join("")}`;if(reservedMaterializeKeys.has(fieldKey))throw new PmCliError(`Invalid --field entry "${specification}"; "${fieldKey}" is reserved by materialize and cannot be overridden`,EXIT_CODE.USAGE);materializeFields[fieldKey]=value}for(const step of params.targets){const createOptions={...materializeFields,title:step.title,description:step.body?.trim()||step.title,type:params.resolvedTypeName,parent:params.parent,tags:params.tags,author:params.options.author,message:params.options.message??`materialized from plan ${params.planItemId} step ${step.id}`,dep:buildMaterializeDependencies(params.parent,params.planItemId,step)};preservePlanCreateStdinPolicy(params.options,createOptions,["description",...Object.keys(materializeFields)]);const created=await runCreate(createOptions,{path:params.pmRoot});materialized.push({id:created.item.id,title:created.item.title,type:params.resolvedTypeName,parent:created.item.parent,tags:created.item.tags??[],from_step:step.id})}return materialized}function linkMaterializedStepItems(currentSteps,targets,materialized){for(const target of targets){const matched=materialized.find(entry=>entry.from_step===target.id);if(!matched)continue;const step=currentSteps.find(entry=>entry.id===target.id);if(!step)continue;const links=step.linked_items??[];links.push({id:matched.id,kind:"implements",note:`materialized as ${matched.type}`}),step.linked_items=links,step.updated_at=nowIso()}}async function planMaterialize(id,options,ctx){const stepRefs=toArray(options.steps);if(stepRefs.length===0)throw new PmCliError("pm plan materialize requires --steps <ids|orders|all>",EXIT_CODE.USAGE);const targetType=options.materializeType?.trim()||"Task",typeRegistry=resolveItemTypeRegistry(ctx.settings,getActiveExtensionRegistrations()),resolvedTypeName=resolveTypeName(targetType,typeRegistry);if(!resolvedTypeName)throw new PmCliError(`Invalid --materialize-type "${targetType}"`,EXIT_CODE.USAGE);const parent=options.materializeParent?.trim()||id,tags=options.materializeTags,planRead=await readPlanItem(ctx,id),steps=(planRead.document.metadata.plan_steps??[]).slice(),{targets,skipped:materializeSkipped}=resolveMaterializeTargets(steps,stepRefs);if(targets.length===0){if(materializeSkipped.length>0)return buildMaterializeNoopResult(planRead,materializeSkipped);throw new PmCliError("No matching plan steps found for --steps",EXIT_CODE.NOT_FOUND)}const materialized=await createMaterializedStepItems({targets,parent,planItemId:planRead.itemId,resolvedTypeName,tags,options,pmRoot:ctx.pmRoot}),{document,itemId}=await mutatePlanSteps({id,options,ctx,op:"plan_materialize",message:options.message??`plan materialize ${stepRefs.join(",")}`,mutator(currentSteps){return linkMaterializedStepItems(currentSteps,targets,materialized),{changedSteps:targets.map(entry=>entry.id)}}}),plan=projectPlan(document.metadata,"standard");return{action:"materialize",plan,materialized,...materializeSkipped.length>0?{materialize_skipped:materializeSkipped}:{},next_actions:nextActionsFor(itemId,plan),warnings:buildMaterializeSkippedWarnings(materializeSkipped),generated_at:nowIso()}}function normalizePlanStepAliasInput(input){if(input.subcommand==="create")return input;const stepValues=toOrderedStepTitles(input.options.step);if(stepValues.length>1)throw new PmCliError(`pm plan ${input.subcommand} accepts a single --step/--step-title value (repeated --step seeds ordered steps only on pm plan create)`,EXIT_CODE.USAGE);return stepValues.length===1&&!input.options.stepTitle?.trim()?{...input,options:transferMutationStdinTokenPolicy(input.options,{...input.options,stepTitle:stepValues[0]})}:input}function requirePlanId(input,label){if(!input.id)throw new PmCliError(`pm plan ${label} requires a plan id`,EXIT_CODE.USAGE);return input.id}function requirePlanStepRef(input,label){const id=requirePlanId(input,label);if(!input.stepRef)throw new PmCliError(`pm plan ${label} requires <plan-id> <step>`,EXIT_CODE.USAGE);return{id,stepRef:input.stepRef}}function requireReorderTarget(input){const target=requirePlanStepRef(input,"reorder-step");if(input.reorderTo===void 0)throw new PmCliError("pm plan reorder-step requires <plan-id> <step> <new-order>",EXIT_CODE.USAGE);return{...target,reorderTo:input.reorderTo}}const PLAN_DISPATCHERS={create:(input,ctx)=>planCreate(input.options,input.global,ctx),show:(input,ctx)=>planShow(requirePlanId(input,"show"),input.options,ctx),"add-step":(input,ctx)=>planAddStep(requirePlanId(input,"add-step"),input.options,ctx),"update-step":(input,ctx)=>{const target=requirePlanStepRef(input,"update-step");return planUpdateStep(target.id,input.options,ctx,{stepRef:target.stepRef,op:"plan_update_step"})},"complete-step":(input,ctx)=>{const target=requirePlanStepRef(input,"complete-step");return planUpdateStep(target.id,input.options,ctx,{stepRef:target.stepRef,finalStatus:"completed",op:"plan_complete_step"})},"block-step":(input,ctx)=>{const target=requirePlanStepRef(input,"block-step");return planUpdateStep(target.id,input.options,ctx,{stepRef:target.stepRef,finalStatus:"blocked",op:"plan_block_step"})},"reorder-step":(input,ctx)=>{const target=requireReorderTarget(input);return planReorderStep(target.id,input.options,ctx,target.stepRef,target.reorderTo)},"remove-step":(input,ctx)=>{const target=requirePlanStepRef(input,"remove-step");return planRemoveStep(target.id,input.options,ctx,target.stepRef)},link:(input,ctx)=>{const target=requirePlanStepRef(input,"link");return planLink(target.id,input.options,ctx,target.stepRef)},unlink:(input,ctx)=>{const target=requirePlanStepRef(input,"unlink");return planUnlink(target.id,input.options,ctx,target.stepRef)},decision:(input,ctx)=>planAppendLog(requirePlanId(input,"decision"),input.options,ctx,"decision"),discovery:(input,ctx)=>planAppendLog(requirePlanId(input,"discovery"),input.options,ctx,"discovery"),validation:(input,ctx)=>planAppendLog(requirePlanId(input,"validation"),input.options,ctx,"validation"),resume:(input,ctx)=>planResume(requirePlanId(input,"resume"),input.options,ctx),approve:(input,ctx)=>planApprove(requirePlanId(input,"approve"),input.options,ctx),materialize:(input,ctx)=>planMaterialize(requirePlanId(input,"materialize"),input.options,ctx)};function resolvePlanDispatcher(subcommand){const dispatcher=PLAN_DISPATCHERS[subcommand];if(!dispatcher)throw createUnknownSubcommandError({command_path:"plan",token:subcommand,allowed:PLAN_SUBCOMMANDS});return dispatcher}async function runPlan(input){const ctx=await loadContext(input.global),normalizedInput=normalizePlanStepAliasInput(input),result=await resolvePlanDispatcher(normalizedInput.subcommand)(normalizedInput,ctx);return result.action==="show"?result:{...result,mutation_receipt:buildPlanMutationReceipt(result,ctx.pmRoot)}}const _testOnlyPlanCommand={changedPlanMetadataFields};export{PLAN_SHOW_DEPTH_VALUES,PLAN_SUBCOMMANDS,PLAN_TEMPLATE_NAMES,_testOnlyPlanCommand,resolvePlanTemplateSteps,runPlan};
|
|
1
|
+
import{assertInitializedTracker as _e}from"../environment/tracker-preflight.js";import{getActiveExtensionRegistrations as W,isTerminalStatus as we,resolveItemTypeRegistry as H,resolveRuntimeStatusRegistry as ye,resolveTypeName as Se,EXIT_CODE as u,PmCliError as f,splitCommaList as J,nowIso as g,locateItem as ke,mutateItem as X,readLocatedItem as be,resolvePmRoot as ve,readSettings as Ae,resolveAuthor as T,isTerminalPlanMode as Z,preserveMutationStdinTokenFields as $e,transferMutationStdinTokenPolicy as Y}from"../runtime-primitives.js";import{PLAN_HARNESS_VALUES as Q,PLAN_MODE_VALUES as ee,PLAN_STEP_LINK_KIND_VALUES as te,PLAN_STEP_STATUS_VALUES as ne}from"../../types/index.js";import{runCreate as ae}from"./create.js";import{createUnknownSubcommandError as xe}from"../agent/subcommand-recovery.js";import{parseIdentityOption as Ee}from"../../core/shared/url-credentials.js";import{PLAN_SHOW_DEPTH_VALUES as z}from"../query/projection-contracts.js";import{buildPlanMutationReceipt as Pe}from"./plan-mutation-receipt.js";const Ie=["create","show","add-step","update-step","complete-step","block-step","reorder-step","remove-step","link","unlink","decision","discovery","validation","resume","approve","materialize"],ie="plan-step-",L="draft",O=["bug-investigation","feature-implementation","refactoring-sprint"],se={"bug-investigation":[{title:"Reproduce the bug",body:"Capture exact steps, inputs, and the observed vs expected behavior."},{title:"Locate the root cause",body:"Trace the failure to the responsible code path with evidence."},{title:"Write a failing test",body:"Add a regression test that fails for the current bug."},{title:"Implement the fix",body:"Apply the minimal change that makes the failing test pass."},{title:"Verify and document",body:"Run the full suite and record the resolution and verification."}],"feature-implementation":[{title:"Clarify requirements & acceptance criteria",body:"Confirm scope, edge cases, and done-conditions."},{title:"Design the approach",body:"Decide the data model, interfaces, and integration points."},{title:"Implement the change",body:"Build the feature behind the agreed design."},{title:"Add tests",body:"Cover the new behavior and its edge cases."},{title:"Update docs & changelog",body:"Document the feature and surface it to users."}],"refactoring-sprint":[{title:"Map the current structure & risks",body:"Inventory the code to change and its blast radius."},{title:"Add characterization tests",body:"Lock in current behavior before refactoring."},{title:"Refactor incrementally",body:"Apply small, reversible steps keeping tests green."},{title:"Verify behavior is unchanged",body:"Run the full suite and compare against the baseline."},{title:"Clean up & document",body:"Remove dead code and record the new structure."}]};function Te(e){const t=e.trim().toLowerCase(),n=Object.prototype.hasOwnProperty.call(se,t)?se[t]:void 0;if(!n)throw new f(`Unknown plan template "${e}". Allowed: ${O.join(", ")}`,u.USAGE,{code:"unknown_plan_template",examples:[`pm plan create --title "Fix login crash" --template ${O[0]}`]});return n.map(a=>({...a}))}function Re(e,t){return t>0?Math.round(e/t*100):0}function re(e){return(Array.isArray(e)?e:e==null?[]:[e]).filter(n=>n!=null).map(n=>(typeof n=="string"?n:String(n)).trim()).filter(n=>n.length>0)}function b(e){return Array.isArray(e)?e.flatMap(t=>J(t,{unique:!1})):typeof e=="string"&&e.trim().length>0?J(e,{unique:!1}):[]}function y(e){return Array.isArray(e)?e.map(t=>t.trim()).filter(Boolean):typeof e=="string"&&e.trim().length>0?[e.trim()]:[]}function oe(e,t=L){if(e===void 0)return t;const n=e.trim().toLowerCase(),a=ee.find(i=>i===n);if(!a)throw new f(`Invalid plan mode "${e}". Allowed: ${ee.join(", ")}`,u.USAGE);return a}function C(e,t="pending"){if(e===void 0)return t;const n=e.trim().toLowerCase(),a=ne.find(i=>i===n);if(!a)throw new f(`Invalid step status "${e}". Allowed: ${ne.join(", ")}`,u.USAGE);return a}function de(e,t="related"){if(e===void 0)return t;const n=e.trim().toLowerCase(),a=te.find(i=>i===n);if(!a)throw new f(`Invalid step link kind "${e}". Allowed: ${te.join(", ")}`,u.USAGE);return a}function Ue(e){if(e===void 0)return;const t=e.trim().toLowerCase();if(t.length===0)return;const n=Q.find(a=>a===t);if(!n)throw new f(`Invalid plan harness "${e}". Allowed: ${Q.join(", ")}`,u.USAGE);return n}function ze(e){if(e===void 0)return"brief";const t=e.trim().toLowerCase(),n=z.find(a=>a===t);if(!n)throw new f(`Invalid --depth "${e}". Allowed: ${z.join(", ")}`,u.USAGE);return n}function Le(e){if(e===void 0)return null;const t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);if(t.length===0)throw new f("Plan --fields requires a comma-separated list of plan field names",u.USAGE);return t}const N=new Set(["id","title","status","mode","scope","harness","parent","resume_context","steps_summary","current_step","blocked_steps","steps","decisions","discoveries","validation","linked_items"]);function Oe(e,t){const n=e,a={},i=[];for(const s of t){const r=s.startsWith("plan.")?s.slice(5):s;if(r.length!==0){if(!N.has(r)){i.push(s);continue}Object.prototype.hasOwnProperty.call(n,r)&&(a[r]=n[r])}}if(i.length>0)throw new f(`Unknown Plan --fields value(s): ${i.join(", ")}`,u.USAGE,{nextSteps:[`Use --fields ${[...N].join(",")}`,"Run pm plan show <id> --depth brief for compact default fields."],recovery:{provided_fields:i,suggested_retry:`pm plan show <id> --fields ${[...N].join(",")}`}});return a}function q(e,t){const n={};for(const a of e.split(",")){const i=a.trim();if(i.length===0)continue;const s=i.indexOf("=");if(s<=0)throw new f(`Invalid ${t} entry "${i}"; expected key=value`,u.USAGE,{code:"malformed_plan_step_evidence",required:`${t} entries must use comma-separated key=value fields.`,why:"Structured Plan evidence must be validated before it is persisted.",examples:['--file "path=src/index.ts,scope=project,note=implementation"','--test "command=pnpm test,note=regression"','--doc "path=docs/PLAN.md,scope=project"']});n[i.slice(0,s).trim().toLowerCase()]=i.slice(s+1).trim()}return n}function G(e){const t=q(e,"--file");if(!t.path)throw new f("--file requires path=<value>",u.USAGE,{code:"malformed_plan_step_evidence",required:"--file requires a non-empty path field.",why:"Plan file evidence needs a stable path for later verification."});const n={path:t.path};return(t.scope==="global"||t.scope==="project")&&(n.scope=t.scope),t.note&&(n.note=t.note),n}function M(e){const t=q(e,"--test");if(!t.command&&!t.path)throw new f("--test requires at least command=<value> or path=<value>",u.USAGE,{code:"malformed_plan_step_evidence",required:"--test requires a command or path field.",why:"Plan test evidence must identify something runnable or inspectable."});const n={};return t.command&&(n.command=t.command),t.path&&(n.path=t.path),t.note&&(n.note=t.note),n}function D(e){const t=q(e,"--doc");if(!t.path)throw new f("--doc requires path=<value>",u.USAGE,{code:"malformed_plan_step_evidence",required:"--doc requires a non-empty path field.",why:"Plan documentation evidence needs a stable path for later verification."});const n={path:t.path};return(t.scope==="global"||t.scope==="project")&&(n.scope=t.scope),t.note&&(n.note=t.note),n}function Ce(e){const t={total:e.length,pending:0,in_progress:0,blocked:0,completed:0,skipped:0,superseded:0,completion_pct:0};for(const n of e)t[n.status]+=1;return t.completion_pct=Re(t.completed,t.total),t}function Ne(e){const t=new Set(e.map(n=>n.id));for(let n=e.length+1;n<e.length+1024;n+=1){const a=`${ie}${String(n).padStart(3,"0")}`;if(!t.has(a))return a}throw new f("Could not allocate step id (limit reached)",u.GENERIC_FAILURE)}function R(e,t){const n=t.trim();if(n.length===0)throw new f("Step reference cannot be empty",u.USAGE);const a=e.find(i=>i.id===n);if(a)return a;if(/^\d+$/.test(n)){const i=Number.parseInt(n,10),s=e.find(r=>r.order===i);if(s)return s}throw new f(`Step "${t}" not found in plan`,u.NOT_FOUND)}function le(e){if(e.status==="completed")return{reason:"already_completed"};const t=(e.linked_items??[]).find(n=>n.kind==="implements");if(t)return{reason:"already_materialized",existing_id:t.id}}function qe(e,t){const n=t.filter(r=>r.trim().toLowerCase()==="all"),a=[],i=[];if(n.length>0){if(t.length>n.length)throw new f("pm plan materialize --steps all cannot be combined with other step refs",u.USAGE);for(const r of e.slice().sort((o,l)=>o.order-l.order)){const o=le(r);if(o){i.push({from_step:r.id,...o});continue}a.push(r)}return{targets:a,skipped:i}}const s=new Set;for(const r of t){const o=R(e,r);if(s.has(o.id))continue;s.add(o.id);const l=le(o);if(l){i.push({from_step:o.id,...l});continue}a.push(o)}return{targets:a,skipped:i}}function Ge(e,t){const n=e==="decision"?t.decisionText:e==="discovery"?t.discoveryText:t.validationText,a=e==="decision"?t.decision:e==="discovery"?t.discovery:t.validation;return n?.trim()||a?.trim()||void 0}function Me(e){return e.find(t=>t.status==="in_progress")??e.find(t=>t.status==="pending")}function De(e){return e.filter(t=>t.status==="blocked").map(t=>({id:t.id,order:t.order,title:t.title,blocked_reason:t.blocked_reason}))}function S(e,t="brief"){const n=(e.plan_steps??[]).slice().sort((r,o)=>r.order-o.order),a=Ce(n),i=Me(n),s={id:e.id,title:e.title,status:e.status,mode:e.plan_mode??L,scope:e.plan_scope,harness:e.plan_harness,parent:e.parent,resume_context:e.plan_resume_context,steps_summary:a,current_step:i?{id:i.id,order:i.order,title:i.title,status:i.status}:void 0,blocked_steps:De(n),linked_items:(e.dependencies??[]).map(r=>({id:r.id,kind:r.kind}))};return(t==="standard"||t==="deep")&&(s.steps=n),t==="deep"&&(s.decisions=e.plan_decisions??[],s.discoveries=e.plan_discoveries??[],s.validation=e.plan_validation??[]),s}function k(e,t){const n=[];return t.steps_summary.total===0&&n.push(`pm plan add-step ${e} --step-title "First step"`),t.current_step&&n.push(`pm plan update-step ${e} ${t.current_step.id} --step-status in_progress`,`pm plan complete-step ${e} ${t.current_step.id} --step-evidence "..."`),t.steps_summary.blocked>0&&n.push(`pm plan show ${e} --depth standard`),(t.mode==="draft"||t.mode==="research")&&n.push(`pm plan approve ${e} --message "ready to execute"`),t.steps_summary.completed===t.steps_summary.total&&t.steps_summary.total>0&&!Z(t.mode)&&t.status!=="closed"&&t.status!=="canceled"&&n.push(`pm close ${e} "plan complete"`),n}function ce(e){if((e.type??"").trim().toLowerCase()!=="plan")throw new f(`Item ${e.id} is type ${e.type}; pm plan commands require type=Plan. Use pm plan create or pm create --type Plan first.`,u.USAGE,{code:"wrong_item_type",required:"Use pm plan commands only with items whose type is Plan.",why:"Plan commands read and mutate Plan-specific step, decision, discovery, and validation fields.",examples:[`pm get ${e.id} --depth brief`,'pm plan create --title "Execution plan" --scope "<goal>"']})}async function Fe(e){const t=ve(process.cwd(),e.path);await _e(t);const n=await Ae(t);return{pmRoot:t,settings:n}}async function pe(e,t){const n=H(e.settings,W()),a=await ke(e.pmRoot,t,e.settings.id_prefix,e.settings.item_format,n.type_to_folder);if(!a)throw new f(`Plan ${t} not found`,u.NOT_FOUND);const i=await be(a,{schema:e.settings.schema});return ce(i.document.metadata),{document:i.document,itemId:a.id}}function Be(e){const t=[];for(const n of b(e.related))t.push(`id=${n},kind=related`);for(const n of b(e.blocks))t.push(`id=${n},kind=blocks`);for(const n of b(e.blockedBy))t.push(`id=${n},kind=blocked_by`);return t.length>0?t:void 0}function je(e){const t=e.validationText?.trim(),n=e.validationCommand?.trim(),a=e.validationExpected?.trim();if(!(!t&&!n&&!a))return{text:t||n||"Validation check",command:n||void 0,expected:a||void 0}}function Ke(e){return!!e.stepBody?.trim()||!!e.stepOwner?.trim()||!!e.stepStatus?.trim()||!!e.stepEvidence?.trim()||!!e.stepBlockedReason?.trim()||!!e.stepReplacement?.trim()||b(e.dependsOn).length>0||b(e.link).length>0}function Ve(e){const t=e.stepTitle?.trim()||void 0,n=re(e.step),a=e.template?.trim()?Te(e.template):[];return{repeatedStepTitles:n,stepTitleFlag:t,stepTitles:[...t?[t]:[],...n,...a.map(i=>i.title)],templateSteps:a}}function We(e,t){if((e.stepTitleFlag||e.repeatedStepTitles.length>0)&&e.templateSteps.length>0)throw new f("pm plan create --template cannot be combined with --step-title or --step; choose one step seeding source",u.USAGE,{code:"ambiguous_option_combination",examples:[`pm plan create --title "Fix login crash" --template ${O[0]}`,'pm plan create --title "Custom plan" --step "Read the code" --step "Write the fix"']});if(e.stepTitles.length>1&&t)throw new f("pm plan create per-step options apply to a single initial step; with multiple --step values create the plan first, then refine steps individually",u.USAGE,{code:"ambiguous_option_combination",examples:['pm plan create --title "Execution plan" --step "Read the code" --step "Write the fix"','pm plan update-step <plan-id> plan-step-001 --step-body "Inspect retry path"']})}function He(e,t){const n=C(e.stepStatus,"pending"),a=F(e,"depends_on"),i=y(e.file).map(G),s=y(e.test).map(M),r=y(e.doc).map(D),o=g();return{id:"plan-step-001",order:1,title:t,body:e.stepBody?.trim()||void 0,status:n,owner:j(e.stepOwner),evidence:e.stepEvidence?.trim()||void 0,blocked_reason:n==="blocked"?e.stepBlockedReason?.trim()||"":void 0,linked_items:a.length>0?a:void 0,files:i.length>0?i:void 0,tests:s.length>0?s:void 0,docs:r.length>0?r:void 0,created_at:o,updated_at:o,completed_at:n==="completed"?o:void 0}}function Je(e){const t=Ve(e),n=Ke(e);if(We(t,n),t.stepTitles.length===0)return{steps:[],hasPerStepDetailOptions:n};if(t.stepTitles.length===1)return{steps:[He(e,t.stepTitles[0])],hasPerStepDetailOptions:n};const a=g();return{steps:t.stepTitles.map((i,s)=>({id:`${ie}${String(s+1).padStart(3,"0")}`,order:s+1,title:i,body:t.templateSteps[s]?.body,status:"pending",created_at:a,updated_at:a})),hasPerStepDetailOptions:n}}function me(e,t,n=[]){Y(e,t),n.length>0&&$e(t,n)}async function Xe(e,t,n){const a=e.title?.trim();if(!a)throw new f("pm plan create requires --title",u.USAGE,{code:"missing_required_option",examples:['pm plan create --title "Refactor lock retry" --scope pm-a1b2']});const i=oe(e.mode,L),s=Ue(e.harness),r=e.fromSearch?.trim(),o=je(e),{steps:l,hasPerStepDetailOptions:p}=Je(e);if(l.length===0&&p)throw new f("pm plan create step options require --step-title (or a single --step)",u.USAGE,{code:"missing_required_option",examples:['pm plan create --title "Execution plan" --step-title "Read the code"']});const d=e.description?.trim()??e.scope?.trim()??a,c=e.claim?T(e.author,n.settings.author_default):e.assignee?.trim()||void 0,m={...e,title:a,description:d,type:"Plan",template:void 0,file:y(e.file),test:y(e.test),doc:y(e.doc),field:y(e.field),assignee:T(e.author,n.settings.author_default),blockedBy:void 0,dep:Be(e),message:e.message??(r?`plan create (search: ${r})`:"plan create")};me(e,m);const h=await ae(m,t),x=await X({pmRoot:n.pmRoot,settings:n.settings,id:h.item.id,op:"plan_create_metadata",author:T(e.author,n.settings.author_default),message:"seed plan metadata",mutate(_){const w=["plan_mode"];_.metadata.plan_mode=i,s&&(_.metadata.plan_harness=s,w.push("plan_harness"));const P=e.scope?.trim();P&&(_.metadata.plan_scope=P,w.push("plan_scope"));const A=e.resumeContext?.trim();return A&&(_.metadata.plan_resume_context=A,w.push("plan_resume_context")),_.metadata.plan_steps=l,w.push("plan_steps"),o&&(_.metadata.plan_validation=[..._.metadata.plan_validation??[],o],w.push("plan_validation")),c&&(_.metadata.assignee=c,w.push("assignee")),{changedFields:w}}}),E=S(x.item,"brief");return{action:"create",plan:E,step:l[0],next_actions:k(h.item.id,E),warnings:[...h.warnings],generated_at:g()}}async function Ze(e,t,n){const a=ze(t.depth),i=Le(t.fields),{document:s,itemId:r}=await pe(n,e),o=S(s.metadata,i===null?a:"deep");return{action:"show",plan:i===null?o:Oe(o,i),next_actions:k(r,o),warnings:[],generated_at:g()}}function ue(e,t){const n=new Map(Object.entries(t).filter(([a])=>a.startsWith("plan_")).map(([a,i])=>[a,JSON.stringify(i)]));return[...new Set([...e.keys(),...n.keys()])].filter(a=>e.get(a)!==n.get(a))}async function v(e){const t=T(e.options.author,e.ctx.settings.author_default);let n;const a=await X({pmRoot:e.ctx.pmRoot,settings:e.ctx.settings,id:e.id,op:e.op,author:t,message:e.options.message??e.message,force:e.options.force,mutate(i){ce(i.metadata);const s=ye(e.ctx.settings.schema);if(we(i.metadata.status,s)||Z(i.metadata.plan_mode))throw new f(`Plan ${i.metadata.id} is terminal (status=${i.metadata.status}, plan_mode=${i.metadata.plan_mode??"unset"}) and cannot be mutated.`,u.CONFLICT,{code:"terminal_plan_mutation",required:"Create or reopen a non-terminal Plan before changing its execution context or steps.",why:"Terminal Plan history is immutable execution evidence."});const r=(i.metadata.plan_steps??[]).slice(),o=new Map(Object.entries(i.metadata).filter(([c])=>c.startsWith("plan_")).map(([c,m])=>[c,JSON.stringify(m)])),l=e.mutator(r,i);n=l.resultStep;const p=r.slice().sort((c,m)=>c.order-m.order).map((c,m)=>({...c,order:m+1}));i.metadata.plan_steps=p;const d=ue(o,i.metadata);return d.length===0&&l.changedSteps.length===0?{changedFields:[]}:{changedFields:d.length>0?d:["plan_steps"]}}});return{document:{metadata:a.item,body:a.body},resultStep:n,itemId:a.item.id}}async function Ye(e,t,n){const a=t.stepTitle?.trim();if(!a)throw new f("pm plan add-step requires --step-title",u.USAGE);const i=C(t.stepStatus,"pending"),s=t.allowMultipleActive===!0,{document:r,resultStep:o,itemId:l}=await v({id:e,options:t,ctx:n,op:"plan_add_step",message:`plan add-step "${a}"`,mutator(d){const c=d.length+1;fe(d,void 0,i,s);const m=Qe(d,t,{order:c,title:a,status:i});return d.push(m),{changedSteps:[m.id],resultStep:m}}}),p=S(r.metadata,"standard");return{action:"add-step",plan:p,step:o,next_actions:k(l,p),warnings:[],generated_at:g()}}function fe(e,t,n,a){if(n!=="in_progress"||a)return;const i=e.find(s=>s.id!==t&&s.status==="in_progress");if(i)throw new f(`Plan already has step ${i.id} in_progress. Pass --allow-multiple-active or update that step first.`,u.CONFLICT)}function Qe(e,t,n){const a=F(t,"depends_on"),i=y(t.file).map(G),s=y(t.test).map(M),r=y(t.doc).map(D),o=g();return{id:Ne(e),order:n.order,title:n.title,body:t.stepBody?.trim()||void 0,status:n.status,owner:j(t.stepOwner),evidence:t.stepEvidence?.trim()||void 0,blocked_reason:n.status==="blocked"?t.stepBlockedReason?.trim()||"":void 0,linked_items:a.length>0?a:void 0,files:i.length>0?i:void 0,tests:s.length>0?s:void 0,docs:r.length>0?r:void 0,created_at:o,updated_at:o,completed_at:n.status==="completed"?o:void 0}}function F(e,t){const n=b(e.dependsOn).map(d=>({id:d,kind:t})),a=b(e.related).map(d=>({id:d,kind:"related"})),i=b(e.blocks).map(d=>({id:d,kind:"blocks"})),s=b(e.blockedBy).map(d=>({id:d,kind:"blocked_by"})),r=b(e.link),o=de(e.linkKind,t),l=e.linkNote?.trim(),p=r.map(d=>{const c={id:d,kind:o};return l&&(c.note=l),c});return[...n,...a,...i,...s,...p]}async function B(e,t,n,a){const{document:i,resultStep:s,itemId:r}=await v({id:e,options:t,ctx:n,op:a.op,message:t.message??`${a.op} ${a.stepRef}`,mutator(l,p){const d=R(l,a.stepRef),c=g(),m=a.finalStatus??C(t.stepStatus,d.status),h=t.allowMultipleActive===!0||a.allowMultipleActive===!0;return fe(l,d.status==="in_progress"?d.id:void 0,m,h),et(d,t,m,c),p.metadata.updated_at=c,{changedSteps:[d.id],resultStep:d}}}),o=S(i.metadata,"standard");return{action:a.op==="plan_complete_step"?"complete-step":a.op==="plan_block_step"?"block-step":"update-step",plan:o,step:s,next_actions:k(r,o),warnings:[],generated_at:g()}}function j(e){return Ee(e?.trim(),"--step-owner")||void 0}function et(e,t,n,a){tt(e,t,n),nt(e,t),e.status=n,e.updated_at=a,at(e,n,a)}function tt(e,t,n){if(!(n!=="blocked"||t.stepBlockedReason?.trim()||e.blocked_reason))throw new f("Blocking a step requires --step-blocked-reason or an already-recorded blocked_reason.",u.USAGE)}function nt(e,t){const n=t.stepTitle?.trim();n&&(e.title=n),t.stepBody!==void 0&&(e.body=t.stepBody.trim()||void 0),t.stepOwner!==void 0&&(e.owner=j(t.stepOwner)),t.stepEvidence!==void 0&&(e.evidence=t.stepEvidence.trim()||void 0),t.stepBlockedReason!==void 0&&(e.blocked_reason=t.stepBlockedReason.trim()||void 0),t.stepReplacement!==void 0&&(e.superseded_by=t.stepReplacement.trim()||void 0);const a=y(t.file).map(G),i=y(t.test).map(M),s=y(t.doc).map(D);a.length>0&&(e.files=K(e.files,a)),i.length>0&&(e.tests=K(e.tests,i)),s.length>0&&(e.docs=K(e.docs,s))}function K(e,t){const n=[...e??[]],a=new Set(n.map(i=>JSON.stringify(i)));for(const i of t){const s=JSON.stringify(i);a.has(s)||(a.add(s),n.push(i))}return n}function at(e,t,n){if(t==="completed"&&!e.completed_at){e.completed_at=n;return}t!=="completed"&&(e.completed_at=void 0)}async function it(e,t,n,a,i){const{document:s,itemId:r,resultStep:o}=await v({id:e,options:t,ctx:n,op:"plan_reorder_step",message:t.message??`plan reorder-step ${a} -> ${i}`,mutator(p){const d=R(p,a),c=p.filter(h=>h.id!==d.id),m=Math.max(1,Math.min(i,c.length+1));return c.splice(m-1,0,d),c.forEach((h,x)=>{h.order=x+1,h.updated_at=g()}),p.length=0,p.push(...c),{changedSteps:[d.id],resultStep:d}}}),l=S(s.metadata,"standard");return{action:"reorder-step",plan:l,step:o,next_actions:k(r,l),warnings:[],generated_at:g()}}async function st(e,t,n,a){const{document:i,itemId:s,resultStep:r}=await v({id:e,options:t,ctx:n,op:"plan_remove_step",message:t.message??`plan remove-step ${a}`,mutator(l){const p=R(l,a),d=l.filter(c=>c.id!==p.id);return d.forEach((c,m)=>{c.order=m+1}),l.length=0,l.push(...d),{changedSteps:[p.id],resultStep:p}}}),o=S(i.metadata,"standard");return{action:"remove-step",plan:o,step:r,next_actions:k(s,o),warnings:[],generated_at:g()}}async function rt(e,t,n,a){const i=F(t,de(t.linkKind,"related"));if(i.length===0)throw new f("pm plan link requires at least one --link/--related/--blocks/--blocked-by/--depends-on id",u.USAGE);const s=t.promoteToItemDep===!0,{document:r,itemId:o,resultStep:l}=await v({id:e,options:t,ctx:n,op:"plan_link_step",message:t.message??`plan link ${a}`,mutator(d,c){const m=R(d,a),h=m.linked_items??[],x=_=>`${_.kind}:${_.id}`,E=new Set(h.map(x));for(const _ of i){const w=x(_);E.has(w)||(h.push(_),E.add(w))}if(m.linked_items=h,m.updated_at=g(),s){const _=c.metadata.dependencies??[],w=A=>`${A.kind}:${A.id}`,P=new Set(_.map(w));for(const A of i){const ge=A.kind==="depends_on"?"blocked_by":A.kind,U={id:A.id,kind:ge,created_at:g(),author:T(t.author,n.settings.author_default)};P.has(w(U))||(_.push(U),P.add(w(U)))}c.metadata.dependencies=_}return{changedSteps:[m.id],resultStep:m}}}),p=S(r.metadata,"standard");return{action:"link",plan:p,step:l,next_actions:k(o,p),warnings:[],generated_at:g()}}async function ot(e,t,n,a){const i=b(t.link);if(i.length===0)throw new f("pm plan unlink requires --link <id> to remove",u.USAGE);const{document:s,itemId:r,resultStep:o}=await v({id:e,options:t,ctx:n,op:"plan_unlink_step",message:t.message??`plan unlink ${a}`,mutator(p){const d=R(p,a),c=(d.linked_items??[]).filter(m=>!i.includes(m.id));return d.linked_items=c.length>0?c:void 0,d.updated_at=g(),{changedSteps:[d.id],resultStep:d}}}),l=S(s.metadata,"standard");return{action:"unlink",plan:l,step:o,next_actions:k(r,l),warnings:[],generated_at:g()}}async function V(e,t,n,a){const i=Ge(a,t);if(!i){const p=`--${a}-text`,d=`--${a}`;throw new f(`pm plan ${a} requires ${p}`,u.USAGE,{code:"missing_required_option",examples:[`pm plan ${a} <plan-id> ${p} "..."`,`pm plan ${a} <plan-id> ${d} "..."`],recovery:{suggested_retry:`pm plan ${a} <plan-id> ${p} <value>`}})}const s=T(t.author,n.settings.author_default),{document:r,itemId:o}=await v({id:e,options:t,ctx:n,op:`plan_append_${a}`,message:t.message??`plan ${a} append`,mutator(p,d){const c=g();if(a==="decision"){const h=d.metadata.plan_decisions??[];return h.push({ts:c,author:s,decision:i,rationale:t.decisionRationale?.trim()||void 0,evidence:t.decisionEvidence?.trim()||void 0}),d.metadata.plan_decisions=h,{changedSteps:[]}}if(a==="discovery"){const h=d.metadata.plan_discoveries??[];return h.push({ts:c,author:s,text:i}),d.metadata.plan_discoveries=h,{changedSteps:[]}}const m=d.metadata.plan_validation??[];return m.push({text:i,command:t.validationCommand?.trim()||void 0,expected:t.validationExpected?.trim()||void 0}),d.metadata.plan_validation=m,{changedSteps:[]}}}),l=S(r.metadata,"deep");return{action:a,plan:l,next_actions:k(o,l),warnings:[],generated_at:g()}}async function dt(e,t,n){const a=t.resumeContext?.trim();if(!a)throw new f("pm plan resume requires --resume-context <text>",u.USAGE);const{document:i,itemId:s}=await v({id:e,options:t,ctx:n,op:"plan_resume",message:t.message??"plan resume context update",mutator(o,l){l.metadata.plan_resume_context=a;const p=t.scope?.trim();return p&&(l.metadata.plan_scope=p),{changedSteps:[]}}}),r=S(i.metadata,"brief");return{action:"resume",plan:r,next_actions:k(s,r),warnings:[],generated_at:g()}}async function lt(e,t,n){const a=oe(t.mode??"approved","approved"),{document:i,itemId:s}=await v({id:e,options:t,ctx:n,op:"plan_approve",message:t.message??`plan approve mode=${a}`,mutator(o,l){l.metadata.plan_mode=a;const p=t.scope?.trim();return p&&(l.metadata.plan_scope=p),{changedSteps:[]}}}),r=S(i.metadata,"brief");return{action:"approve",plan:r,next_actions:k(s,r),warnings:[],generated_at:g()}}function he(e){return e.map(t=>`plan_materialize_skipped:${t.from_step}:${t.reason}${t.existing_id?`:${t.existing_id}`:""}`)}function ct(e,t){const n=S(e.document.metadata,"standard");return{action:"materialize",plan:n,materialized:[],materialize_skipped:t,next_actions:k(e.itemId,n),warnings:he(t),generated_at:g()}}function pt(e,t,n){const a=[`id=${e},kind=parent`,`id=${t},kind=discovered_from`];for(const i of n.linked_items??[]){const s=i.kind==="blocked_by"||i.kind==="blocks"||i.kind==="related"||i.kind==="discovered_from"?i.kind:"related";a.push(`id=${i.id},kind=${s}`)}return a}async function mt(e){const t=[],n={},a=new Set(["title","description","type","parent","tags","author","message","dep"]);for(const i of y(e.options.field)){const s=i.indexOf("=");if(s<=0)throw new f(`Invalid --field entry "${i}"; expected name=value`,u.USAGE);const r=i.slice(0,s).trim(),o=i.slice(s+1).trim();if(r.length===0)throw new f(`Invalid --field entry "${i}"; expected name=value`,u.USAGE);const l=r.trim().replaceAll(/([a-z0-9])([A-Z])/g,"$1 $2").replaceAll(/[^A-Za-z0-9]+/g," ").split(/\s+/).filter(Boolean).map(m=>m.toLowerCase());if(l.length===0)throw new f(`Invalid --field entry "${i}"; expected name=value`,u.USAGE);const[p,...d]=l,c=`${p}${d.map(m=>`${m.slice(0,1).toUpperCase()}${m.slice(1)}`).join("")}`;if(a.has(c))throw new f(`Invalid --field entry "${i}"; "${c}" is reserved by materialize and cannot be overridden`,u.USAGE);n[c]=o}for(const i of e.targets){const s={...n,title:i.title,description:i.body?.trim()||i.title,type:e.resolvedTypeName,parent:e.parent,tags:e.tags,author:e.options.author,message:e.options.message??`materialized from plan ${e.planItemId} step ${i.id}`,dep:pt(e.parent,e.planItemId,i)};me(e.options,s,["description",...Object.keys(n)]);const r=await ae(s,{path:e.pmRoot});t.push({id:r.item.id,title:r.item.title,type:e.resolvedTypeName,parent:r.item.parent,tags:r.item.tags??[],from_step:i.id})}return t}function ut(e,t,n){for(const a of t){const i=n.find(o=>o.from_step===a.id);if(!i)continue;const s=e.find(o=>o.id===a.id);if(!s)continue;const r=s.linked_items??[];r.push({id:i.id,kind:"implements",note:`materialized as ${i.type}`}),s.linked_items=r,s.updated_at=g()}}async function ft(e,t,n){const a=b(t.steps);if(a.length===0)throw new f("pm plan materialize requires --steps <ids|orders|all>",u.USAGE);const i=t.materializeType?.trim()||"Task",s=H(n.settings,W()),r=Se(i,s);if(!r)throw new f(`Invalid --materialize-type "${i}"`,u.USAGE);const o=t.materializeParent?.trim()||e,l=t.materializeTags,p=await pe(n,e),d=(p.document.metadata.plan_steps??[]).slice(),{targets:c,skipped:m}=qe(d,a);if(c.length===0){if(m.length>0)return ct(p,m);throw new f("No matching plan steps found for --steps",u.NOT_FOUND)}const h=await mt({targets:c,parent:o,planItemId:p.itemId,resolvedTypeName:r,tags:l,options:t,pmRoot:n.pmRoot}),{document:x,itemId:E}=await v({id:e,options:t,ctx:n,op:"plan_materialize",message:t.message??`plan materialize ${a.join(",")}`,mutator(w){return ut(w,c,h),{changedSteps:c.map(P=>P.id)}}}),_=S(x.metadata,"standard");return{action:"materialize",plan:_,materialized:h,...m.length>0?{materialize_skipped:m}:{},next_actions:k(E,_),warnings:he(m),generated_at:g()}}function ht(e){if(e.subcommand==="create")return e;const t=re(e.options.step);if(t.length>1)throw new f(`pm plan ${e.subcommand} accepts a single --step/--step-title value (repeated --step seeds ordered steps only on pm plan create)`,u.USAGE);return t.length===1&&!e.options.stepTitle?.trim()?{...e,options:Y(e.options,{...e.options,stepTitle:t[0]})}:e}function $(e,t){if(!e.id)throw new f(`pm plan ${t} requires a plan id`,u.USAGE);return e.id}function I(e,t){const n=$(e,t);if(!e.stepRef)throw new f(`pm plan ${t} requires <plan-id> <step>`,u.USAGE);return{id:n,stepRef:e.stepRef}}function gt(e){const t=I(e,"reorder-step");if(e.reorderTo===void 0)throw new f("pm plan reorder-step requires <plan-id> <step> <new-order>",u.USAGE);return{...t,reorderTo:e.reorderTo}}const _t={create:(e,t)=>Xe(e.options,e.global,t),show:(e,t)=>Ze($(e,"show"),e.options,t),"add-step":(e,t)=>Ye($(e,"add-step"),e.options,t),"update-step":(e,t)=>{const n=I(e,"update-step");return B(n.id,e.options,t,{stepRef:n.stepRef,op:"plan_update_step"})},"complete-step":(e,t)=>{const n=I(e,"complete-step");return B(n.id,e.options,t,{stepRef:n.stepRef,finalStatus:"completed",op:"plan_complete_step"})},"block-step":(e,t)=>{const n=I(e,"block-step");return B(n.id,e.options,t,{stepRef:n.stepRef,finalStatus:"blocked",op:"plan_block_step"})},"reorder-step":(e,t)=>{const n=gt(e);return it(n.id,e.options,t,n.stepRef,n.reorderTo)},"remove-step":(e,t)=>{const n=I(e,"remove-step");return st(n.id,e.options,t,n.stepRef)},link:(e,t)=>{const n=I(e,"link");return rt(n.id,e.options,t,n.stepRef)},unlink:(e,t)=>{const n=I(e,"unlink");return ot(n.id,e.options,t,n.stepRef)},decision:(e,t)=>V($(e,"decision"),e.options,t,"decision"),discovery:(e,t)=>V($(e,"discovery"),e.options,t,"discovery"),validation:(e,t)=>V($(e,"validation"),e.options,t,"validation"),resume:(e,t)=>dt($(e,"resume"),e.options,t),approve:(e,t)=>lt($(e,"approve"),e.options,t),materialize:(e,t)=>ft($(e,"materialize"),e.options,t)};function wt(e){const t=_t[e];if(!t)throw xe({command_path:"plan",token:e,allowed:Ie});return t}async function Et(e){const t=await Fe(e.global),n=ht(e),a=await wt(n.subcommand)(n,t);return a.action==="show"?a:{...a,mutation_receipt:Pe(a,t.pmRoot)}}const Pt={changedPlanMetadataFields:ue};export{z as PLAN_SHOW_DEPTH_VALUES,Ie as PLAN_SUBCOMMANDS,O as PLAN_TEMPLATE_NAMES,Pt as _testOnlyPlanCommand,Te as resolvePlanTemplateSteps,Et as runPlan};
|
|
2
2
|
//# sourceMappingURL=plan.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{parseOptionalNumber as p,EXIT_CODE as o,PmCliError as u,resolveIsoOrRelative as w}from"../runtime-primitives.js";import{RECURRENCE_FREQUENCY_VALUES as U,RECURRENCE_WEEKDAY_VALUES as g,weekdayOrderIndex as R}from"../../types/index.js";function O(e,n){const r=e.trim().toLowerCase();if(r==="true"||r==="1"||r==="yes")return!0;if(r==="false"||r==="0"||r==="no")return!1;throw new u(`${n} must be one of true|false|1|0|yes|no`,o.USAGE)}function i(e){return e?e.split("|").map(n=>n.trim()).filter(n=>n.length>0):[]}function h(e,n,r,t=r){if(!n.includes(e))throw new u(`Invalid ${r} value "${e}". Allowed: ${n.join(", ")}`,o.USAGE,{field:t,value:e,recovery:{allowed_values:[...n]},required:`${r} must be one of: ${n.join(", ")}.`,nextSteps:[`Choose an allowed ${r} and retry the mutation.`]});return e}const V=["recur_freq","recur_interval","recur_count","recur_until","recur_by_weekday","recur_by_month_day","recur_exdates"];function I(e,n){return n==="defined"?e!==void 0:!!e}function v(e,n,r){if(!I(e,r))return;const t=p(e,`event ${n}`);if(!Number.isInteger(t)||t<1)throw new u(`--event ${n} must be an integer >= 1`,o.USAGE);return t}function $(e,n,r){const t=e?w(e,r,"event.recur_until"):void 0;if(t&&t<n)throw new u("--event recur_until must be at or after start",o.USAGE);return t}function q(e){return Array.from(new Set(i(e).map(n=>h(n.toLowerCase(),g,"event weekday")))).sort((n,r)=>R(n)-R(r))}function D(e){return Array.from(new Set(i(e).map(n=>{const r=p(n,"event recur_by_month_day");if(!Number.isInteger(r)||r<1||r>31)throw new u("--event recur_by_month_day values must be integers 1..31",o.USAGE);return r}))).sort((n,r)=>n-r)}function L(e,n){return Array.from(new Set(i(e).map(r=>w(r,n,"event.recur_exdates")))).sort((r,t)=>r.localeCompare(t))}function W(e,n,r,t){const c=e.recur_freq?.trim(),s=e.recur_interval?.trim(),a=e.recur_count?.trim(),d=e.recur_until?.trim(),f=e.recur_by_weekday?.trim(),_=e.recur_by_month_day?.trim(),y=e.recur_exdates?.trim();if(![c,s,a,d,f,_,y].some(A=>A!==void 0))return;if(!c)throw new u("--event recurrence fields require recur_freq=<daily|weekly|monthly|yearly>",o.USAGE);const b=h(c.toLowerCase(),U,"event recurrence frequency"),C=v(s,"recur_interval",t),x=v(a,"recur_count",t),S=$(d,n,r),m=q(f),l=D(_),E=L(y,r);return{freq:b,interval:C,count:x,until:S,by_weekday:m.length>0?m:void 0,by_month_day:l.length>0?l:void 0,exdates:E.length>0?E:void 0}}export{V as RECURRENCE_CSV_KEYS,h as ensureEnumValue,i as parseDelimitedList,O as parseEventBoolean,W as parseRecurrenceRule};
|
|
2
2
|
//# sourceMappingURL=recurrence-parsers.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{normalizeStatusInputWithRegistry as p,statusIsTerminal as a}from"../../core/schema/runtime-schema.js";import{resolveTypeWorkflows as d}from"../../core/schema/type-workflows.js";import{EXIT_CODE as o}from"../../core/shared/constants.js";import{PmCliError as s}from"../../core/shared/errors.js";import{enforceTypeWorkflowTransition as h}from"./workflow-transition.js";function k(e,t){if(e.handoff===void 0)return;if(e.pause===!0)throw new s("--handoff cannot be combined with --pause. Choose a handoff queue or pause the item.",o.USAGE);const n=typeof e.handoff=="string"?p(e.handoff,t):void 0;if(n===void 0||a(n,t)||n===t.in_progress_status)throw new s("--handoff must name a configured non-terminal status distinct from the in-progress status. Inspect pm schema statuses or add a project queue with pm schema add-status <queue> --role active.",o.USAGE);if(typeof e.message!="string"||e.message.trim().length===0)throw new s("--handoff requires --message with implementation evidence and the next verification step.",o.USAGE);return n}function C(e,t,n,r,u){if(a(e.status,r)||!e.assignee?.trim())throw new s("Handoff requires a claimed, non-terminal item. Claim the active work before handing it off; use pm item reopen for completed work.",o.CONFLICT);const f=n.governance.workflow_enforcement??"off",i=h({enforcement:f,typeWorkflows:f==="off"?[]:d(n.schema),statusRegistry:r,typeName:e.type,fromStatus:e.status,toStatus:t}),m={from_status:e.status,to_status:t,message:u},c=e.status===t?[]:["status"];return e.status=t,{receipt:m,warnings:i?[i]:[],changedFields:c}}export{C as applyReleaseHandoff,k as resolveReleaseHandoff};
|
|
2
2
|
//# sourceMappingURL=release-handoff.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{EXIT_CODE as p}from"../../core/shared/constants.js";import{PmCliError as d}from"../../core/shared/errors.js";import{renderPmCommand as _}from"../command-line.js";import{normalizeStatusInput as h}from"../../core/item/status.js";import{resolveRuntimeStatusRegistry as w}from"../../core/schema/runtime-schema.js";import{resolvePmRoot as y}from"../../core/store/paths.js";import{readSettings as S}from"../../core/store/settings.js";import{resolveStartTaskInProgressStatus as R}from"../start-task-status.js";import{assertMutationStringOperand as f,assertReopenMutationValues as v}from"../runtime/mutation-value-validation.js";import{runReopenUpdate as x}from"./update.js";async function I(e,g,t,l){f(e,"reopen","id"),f(g,"reopen","reason"),v(t);const o=g.trim();if(o.length===0)throw new d("pm item reopen requires a non-empty recurrence reason.",p.USAGE,{code:"reopen_reason_required",required:"Describe why the terminal work became active again.",recovery:{suggested_retry:`pm item reopen ${e} "<recurrence reason>"`,suggested_retry_args:["item","reopen",e,"<recurrence reason>"]}});const a=y(process.cwd(),l.path),s=t.expectedResult?.trim();if(s!==void 0&&s.length===0)throw new d("Reopen expected result must describe the current active outcome.",p.USAGE);const u=w((await S(a)).schema),r=u.open_status,c=R(u),i=t.status??r,m=h(i,u)??i;if(m!==r&&m!==c)throw new d(`Reopen target status must be ${r} or ${c}; received ${i}.`,p.USAGE,{code:"reopen_target_status_invalid",required:"Choose the workspace open or in-progress lifecycle status.",recovery:{allowed_values:[...new Set([r,c])],suggested_retry:`pm item reopen ${e} "${o}" --status ${r}`,suggested_retry_args:["item","reopen",e,o,"--status",r]}});const n=await x(e,{status:m,expectedResult:s,unset:["close-reason","resolution",...s===void 0?["expected-result"]:[],"actual-result","fixed-version"],author:t.author,message:t.message,force:t.force},l,o);return{item:n.item,changed_fields:n.changed_fields,warnings:n.warnings,recurrence:n.lifecycle_transition,...s===void 0?{recovery:{missing:["expected_result"],suggested_retry_args:["--pm-path",a,"update",e,"--expected-result","<current expected outcome>"],suggested_retry:_(["--pm-path",a,"update",e,"--expected-result","<current expected outcome>"])}}:{}}}export{I as runReopen};
|
|
2
2
|
//# sourceMappingURL=reopen.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
`)||
|
|
1
|
+
import{assertNoUnknownCsvKeys as u,parseCsvKv as p,EXIT_CODE as c,PmCliError as d,resolveIsoOrRelative as k}from"../runtime-primitives.js";import{resolveEventEndAt as I}from"./event-validation-messages.js";import{parseEventBoolean as b,parseRecurrenceRule as N,RECURRENCE_CSV_KEYS as T}from"./recurrence-parsers.js";const q=["at","date","text","title"],z=["start","date","end","duration","title","description","location","timezone","all_day",...T],D=["key","value"];function h(n,r){return r==="trimmed"?n?.trim():n}function Y(n,r){return r==="defined"?n!==void 0:!!n}function j(n,r,a){return n.map(e=>{const t=p(e,"--reminder");u(t,"--reminder",q);const i=h(t.at??t.date,a.valueMode),s=h(t.text??t.title,a.valueMode);if(!i||!s)throw new d("--reminder requires at=<iso|relative> or date=<iso|relative>, plus text=<value> or title=<value>",c.USAGE);const o=s.trim();if(!o)throw new d("--reminder text must not be empty",c.USAGE);return{at:k(i,r,"reminder.at"),text:o}})}function B(n,r,a){return n.map(e=>{const t=p(e,"--event");u(t,"--event",z);const i=(t.start??t.date)?.trim();if(!i)throw new d("--event requires start=<iso|relative> or date=<iso|relative>",c.USAGE);const s=k(i,r,"event.start"),o=t.end?.trim(),m=t.duration?.trim(),l=I(s,o,m,r),v=t.title,E=t.description,f=t.location,y=t.timezone,w=v?.trim(),R=E?.trim(),x=f?.trim(),S=y?.trim(),A=[["title",v,w],["description",E,R],["location",f,x],["timezone",y,S]];for(const[U,C,K]of A)if(C!==void 0&&!K)throw new d(`--event ${U} must not be empty`,c.USAGE);const _=t.all_day?.trim(),G=N(t,s,r,a.recurrenceEmptyNumericGuard),O=Y(_,a.allDayEmptyGuard)?b(_,"--event all_day"):void 0;return{start_at:s,end_at:l,title:w,description:R,location:x,all_day:O,timezone:S,recurrence:G}})}function V(n){const r={};for(const a of n){const e=a.trim();if(e.length===0)throw new d("--type-option values must not be empty",c.USAGE);let t,i;if(e.includes(",")||e.includes(`
|
|
2
|
+
`)||e.startsWith("```")||/^(?:[-*+]\s+)?(?:key|value)\s*[:=]/i.test(e)){const o=p(e,"--type-option");u(o,"--type-option",D),t=o.key?.trim(),i=o.value?.trim()}else{const o=e.indexOf("="),m=e.indexOf(":");let l=o;if(o<=0&&m>0&&(l=m),l<=0||l===e.length-1)throw new d("--type-option requires key=value or key=<name>,value=<value> entries",c.USAGE);t=e.slice(0,l).trim(),i=e.slice(l+1).trim()}if(!t||!i)throw new d("--type-option requires key and value",c.USAGE);r[t]=i}return Object.fromEntries(Object.entries(r).sort((a,e)=>a[0].localeCompare(e[0])))}export{B as parseEventEntries,j as parseReminderEntries,V as parseTypeOptionEntries};
|
|
3
3
|
//# sourceMappingURL=repeatable-metadata-parsers.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{buildItemNotFoundError as u,locateItem as l,normalizeStatusInput as f,readLocatedItem as m,resolveIsoOrRelative as p,toItemRecord as c,transferMutationStdinTokenPolicy as _}from"../runtime-primitives.js";import{requireTerminalReason as g}from"../lifecycle-policy.js";import{CLOSE_REASON_UNSET_ALIASES as R,expandUnsetFieldTokens as w}from"./shared-unset-fields.js";const o="terminal_state_unchanged";function a(e){const n=e?.trim();return n!==void 0&&n.length>0?n:void 0}function T(e,n){return f(e,n)===n.close_status}function A(e){const n=t=>R.includes(t.trim().toLowerCase());return w(e.unset??[],n).some(n)}function C(e){!e.settings.governance.require_close_reason||!A(e.options)||g({explicit:e.options.closeReason},!0)}function I(e,n,t,r=!1){if(!T(e.status,t))return!1;const s=a(n.closeReason);return r&&n.closeReason!==void 0&&s===void 0||s!==void 0&&s!==a(e.close_reason)?!1:n.completedAt===void 0||p(n.completedAt,new Date,"completed-at")===e.completed_at}async function E(e){const n=await l(e.pmRoot,e.id,e.settings.id_prefix,e.settings.item_format,e.typeRegistry.type_to_folder);if(!n)throw await u(e.pmRoot,e.id,e.settings.id_prefix,e.typeRegistry.type_to_folder);const{document:t}=await m(n,{schema:e.settings.schema});return t.metadata}async function N(e,n,t,r,s){if(t.length===0)return{item:c(n),changed_fields:[],warnings:[...e.workflowTransitionWarnings,o]};const d=_(e.options,{...e.options,status:void 0,closeReason:void 0,completedAt:void 0}),i=await r(e.id,d,e.global);return I(i.item,e.options,e.statusRegistry,e.settings.governance.require_close_reason)?{item:i.item,changed_fields:i.changed_fields,warnings:[...e.workflowTransitionWarnings,...i.warnings,o]}:s(i)}export{o as TERMINAL_STATE_UNCHANGED_WARNING,N as applyRepeatedTerminalStateUpdate,C as assertRoutedCloseKeepsRequiredReason,I as describesCurrentTerminalState,E as readRoutedItemMetadata};
|
|
2
2
|
//# sourceMappingURL=repeated-terminal-state.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6d26f43a-2279-5f83-98ed-dca98f105c8c")}catch{}})();import{assertInitializedTracker}from"../environment/tracker-preflight.js";import{normalizeItemFormatVersion,requiredItemFormatVersion}from"../../core/item/item-format-version.js";import{assertProjectRuntimeFormatGuard}from"../environment/project-runtime-compatibility.js";import{enforceWorkflowMutation}from"../../core/policy/workflow-policy-store.js";import jsonPatch from"fast-json-patch";import fs from"node:fs/promises";import{readLocatedItemSnapshot}from"../../core/store/item-store.js";import{advanceItemMutationPreconditions,assertItemMutationPreconditions,assertItemRevisionExpectationsOnUnreadable,transactionCompensationHistoryContext}from"../../core/store/item-mutation-precondition.js";import{EMPTY_CANONICAL_DOCUMENT}from"../../core/shared/constants.js";import{readHistorySnapshot}from"../../core/history/read.js";import{verifyHistoryRewriteNoDrift}from"../../core/history/history-rewrite.js";import{resolveHistorySubject}from"../history/subject.js";import{historyVersionOffset}from"../../core/history/version-address.js";import{writeFileAtomic,appendHistoryEntry,createHistoryEntry,replayToCanonicalItemDocument,replayToItemDocument,toReplayDocument,enforceHistoryStreamPolicyForItem,canonicalDocument,serializeItemDocument,resolveItemTypeRegistry,acquireLockLease,EXIT_CODE,PmCliError,nowIso,getActiveExtensionRegistrations,projectAfterCommandItemSnapshot,recordAfterCommandAffectedItem,runActiveOnWriteHooks,runActiveBeforeMutationHooks,createMutationGuardSdk,getItemPath,resolvePmRoot,resolveWorkspaceRoot,readSettings,resolveAuthor}from"../runtime-primitives.js";import{applyHistoryPatch,ensureMaterializedHistoryTarget as ensureMaterializedRestoreTarget,extractPatchFailureContext,replayHistoryToTarget as replayToTarget,resolveHistoryTarget}from"../history-read.js";import{acquireItemMetadataDerivedIndexLock,refreshItemMetadataDerivedIndex}from"../item-metadata-index.js";import{redactOptionalIdentityCredentials}from"../../core/shared/url-credentials.js";async function readRestoreItem(located,settings,history){const snapshot=await readLocatedItemSnapshot(located,{schema:settings.schema});return snapshot.error===null?{raw:snapshot.raw,document:snapshot.document}:{raw:snapshot.raw,document:replayCurrentDocument(history),recovered:!0}}function ensureReplayTarget(target,history){return resolveHistoryTarget(target,history,{errorSubject:"restore",allowFutureTimestamp:!0})}function replayCurrentDocument(history){const currentReplay=replayToTarget(history,history.length-1);return Object.keys(currentReplay.metadata).length===0?{metadata:{},body:currentReplay.body}:canonicalDocument(replayToItemDocument(currentReplay))}async function resolveRestoreSubject(pmRoot,id,settings,typeToFolder){const subject=await resolveHistorySubject(pmRoot,id,settings,typeToFolder),historyPolicy=subject.located?await enforceHistoryStreamPolicyForItem({pmRoot,settings,itemId:subject.id,commandLabel:"restore"}):{warnings:[]};return{...subject,historyPolicyWarnings:historyPolicy.warnings}}function changedFields(beforeDocument,afterDocument){const beforeReplay=toReplayDocument(beforeDocument),afterReplay=toReplayDocument(afterDocument),patch=jsonPatch.compare(beforeReplay,afterReplay),fields=new Set;for(const op of patch){if(op.path==="/body"||op.path.startsWith("/body/")){fields.add("body");continue}const segment=op.path.replace(/^\/(?:metadata|front_matter)\/?/,"").split("/")[0];fields.add(segment.replaceAll("~1","/").replaceAll("~0","~"))}return Array.from(fields).sort((a,b)=>a.localeCompare(b))}async function loadRestoreStateUnderLock(params){const verified=await verifyHistoryRewriteNoDrift({pmRoot:params.pmRoot,subject:params.subject,settings:params.settings,typeRegistry:params.typeRegistry,historyRawBeforeLock:params.historyRawBeforeLock,currentItemRawBeforeLock:params.currentItemRawBeforeLock,operation:"restore",readItem:located=>readRestoreItem(located,params.settings,params.history)});return{loadedItemUnderLock:verified.loadedItemUnderLock,existingItemPath:verified.locatedUnderLock?.itemPath??null}}function resolveRestoreCurrentState(loadedItemUnderLock,history){return loadedItemUnderLock?{document:loadedItemUnderLock.document,originalRaw:loadedItemUnderLock.raw}:{document:replayCurrentDocument(history),originalRaw:null}}function collectRestoreOwnershipWarnings(params){const stored=params.document.metadata.assignee?.trim(),hasOwnershipConflict=stored&&stored!==params.author&&!params.force,assigned=redactOptionalIdentityCredentials(stored);if(!hasOwnershipConflict)return[];if(params.enforcement==="strict")throw new PmCliError(`Item ${params.resolvedId} is assigned to ${assigned}. Use --force to override.`,EXIT_CODE.CONFLICT);return params.enforcement==="warn"?[`ownership_warning:assignee_conflict:${params.resolvedId}:${assigned}`]:[]}function restoreHistoryContext(context){return Object.keys(context).length===0?void 0:context}async function restorePreviousItemAfterHistoryFailure(params){if(params.existingItemPath&¶ms.resolvedOriginalRaw!==null&¶ms.restoredItemPath!==params.existingItemPath){await writeFileAtomic(params.existingItemPath,params.resolvedOriginalRaw),await fs.rm(params.restoredItemPath,{force:!0});return}if(params.existingItemPath&¶ms.resolvedOriginalRaw!==null){await writeFileAtomic(params.existingItemPath,params.resolvedOriginalRaw);return}await fs.rm(params.restoredItemPath,{force:!0})}async function runRestoreWriteHooks(params){return[...await runActiveOnWriteHooks({path:params.restoredItemPath,scope:"project",op:"restore",item_id:params.after.metadata.id,item_type:params.after.metadata.type,before:params.before,after:params.after,changed_fields:["restored"]}),...await runActiveOnWriteHooks({path:params.historyPath,scope:"project",op:"restore:history",item_id:params.after.metadata.id,item_type:params.after.metadata.type,before:params.before,after:params.after,changed_fields:["restored"]})]}async function runRestore(id,target,options,global2){const pmRoot=resolvePmRoot(process.cwd(),global2.path);await assertInitializedTracker(pmRoot);const settings=await readSettings(pmRoot),typeRegistry=resolveItemTypeRegistry(settings,getActiveExtensionRegistrations()),subject=await resolveRestoreSubject(pmRoot,id,settings,typeRegistry.type_to_folder),resolvedId=subject.id,{raw:historyRawBeforeLock,entries:history}=await readHistorySnapshot(subject.historyPath,resolvedId);if(history.length===0)throw new PmCliError(`No history exists for ${resolvedId}; restore is unavailable.`,EXIT_CODE.NOT_FOUND);const resolvedTarget=ensureReplayTarget(target,history),replayDocument=ensureMaterializedRestoreTarget(replayToTarget(history,resolvedTarget.historyIndex),resolvedTarget),restoredDocument=replayToCanonicalItemDocument(replayDocument,{schema:settings.schema});if(restoredDocument.metadata.id!==resolvedId)throw new PmCliError(`Restore target resolved to item ${restoredDocument.metadata.id}, expected ${resolvedId}.`,EXIT_CODE.GENERIC_FAILURE);const currentItemRawBeforeLock=(subject.located?await readRestoreItem(subject.located,settings,history):null)?.raw??null,author=resolveAuthor(options.author,settings.author_default),lease=await acquireLockLease(pmRoot,resolvedId,settings.locks.ttl_seconds,author,!!options.force,settings.governance.force_required_for_stale_lock,settings.locks.wait_ms,{waitPolicy:"progress"}),releaseLock=lease.release;try{const{loadedItemUnderLock,existingItemPath}=await loadRestoreStateUnderLock({pmRoot,subject,settings,typeRegistry,historyRawBeforeLock,currentItemRawBeforeLock,history}),itemFormat="toon",currentState=resolveRestoreCurrentState(loadedItemUnderLock,history);loadedItemUnderLock?.recovered===!0&&assertItemRevisionExpectationsOnUnreadable(pmRoot,resolvedId,loadedItemUnderLock.raw),assertItemMutationPreconditions(pmRoot,loadedItemUnderLock?.document??EMPTY_CANONICAL_DOCUMENT,resolvedId),restoredDocument.metadata.pm_format_version=normalizeItemFormatVersion(Math.max(requiredItemFormatVersion(restoredDocument.metadata),requiredItemFormatVersion(currentState.document.metadata))),assertProjectRuntimeFormatGuard(resolveWorkspaceRoot(pmRoot),requiredItemFormatVersion(restoredDocument.metadata));const ownershipWarnings=collectRestoreOwnershipWarnings({document:currentState.document,author,force:options.force,enforcement:settings.governance.ownership_enforcement,resolvedId}),restoreChangedFields=changedFields(currentState.document,restoredDocument),workflowPolicy=await enforceWorkflowMutation({pmRoot,settings,operation:"restore",author,before:currentState.document,after:restoredDocument});await runActiveBeforeMutationHooks({pm_root:pmRoot,operation:"restore",before:currentState.document,after:restoredDocument,changed_fields:restoreChangedFields,author,sdk:createMutationGuardSdk({pmRoot,settings,typeToFolder:typeRegistry.type_to_folder})});const serializedRestore=serializeItemDocument(restoredDocument,{format:itemFormat,schema:settings.schema}),restoredItemPath=getItemPath(pmRoot,restoredDocument.metadata.type,resolvedId,itemFormat,typeRegistry.type_to_folder),derivedIndexWarnings=await lease.fence(async()=>{const releaseDerivedIndexLock=await acquireItemMetadataDerivedIndexLock(pmRoot,author);let derivedIndexWarnings2;try{await writeFileAtomic(restoredItemPath,serializedRestore),existingItemPath&&restoredItemPath!==existingItemPath&&await fs.rm(existingItemPath);const historyEntry=createHistoryEntry({nowIso:nowIso(),author,op:"restore",before:currentState.document,after:restoredDocument,message:options.message,context:restoreHistoryContext({...workflowPolicy.decisions.length===0?{}:{workflow_policies:workflowPolicy.decisions},...transactionCompensationHistoryContext(pmRoot,[resolvedId,currentState.document.metadata.id,restoredDocument.metadata.id],"restore")})});try{await appendHistoryEntry(subject.historyPath,historyEntry)}catch(error){throw await restorePreviousItemAfterHistoryFailure({existingItemPath,resolvedOriginalRaw:currentState.originalRaw,restoredItemPath}),error}derivedIndexWarnings2=await refreshItemMetadataDerivedIndex({pmRoot,preferredFormat:settings.item_format,typeToFolder:typeRegistry.type_to_folder,schema:settings.schema,itemPath:restoredItemPath,previousItemPath:existingItemPath??void 0,document:restoredDocument})}finally{await releaseDerivedIndexLock()}return derivedIndexWarnings2});advanceItemMutationPreconditions(pmRoot,restoredDocument,resolvedId);const hookWarnings=await runRestoreWriteHooks({restoredItemPath,historyPath:subject.historyPath,before:currentState.document,after:restoredDocument});recordAfterCommandAffectedItem({id:restoredDocument.metadata.id,op:"restore",item_type:restoredDocument.metadata.type,previous_status:currentState.document.metadata.status,status:restoredDocument.metadata.status,previous:projectAfterCommandItemSnapshot(currentState.document.metadata,restoreChangedFields),current:projectAfterCommandItemSnapshot(restoredDocument.metadata,restoreChangedFields),changed_fields:restoreChangedFields});const targetEntry=history[resolvedTarget.historyIndex],offset=historyVersionOffset(history,!0);return{item:restoredDocument.metadata,restored_from:{kind:resolvedTarget.kind,target:resolvedTarget.raw,history_index:resolvedTarget.historyIndex+1,version:offset===null?null:offset+resolvedTarget.historyIndex+1,entry_ts:targetEntry.ts,entry_op:targetEntry.op},changed_fields:restoreChangedFields,warnings:[...workflowPolicy.warnings,...loadedItemUnderLock?.recovered?["restore_unreadable_item_recovered"]:[],...subject.historyPolicyWarnings,...ownershipWarnings,...derivedIndexWarnings,...hookWarnings]}}finally{await releaseLock()}}const _testOnlyRestoreCommand={applyHistoryPatch,changedFields,ensureMaterializedRestoreTarget,ensureReplayTarget,extractPatchFailureContext,replayCurrentDocument,replayToTarget,resolveRestoreSubject};export{_testOnlyRestoreCommand,runRestore};
|
|
1
|
+
import{collectRegisteredItemFieldNames as Q}from"../../core/extensions/item-fields.js";import{assertInitializedTracker as Z}from"../environment/tracker-preflight.js";import{normalizeItemFormatVersion as ee,requiredItemFormatVersion as I}from"../../core/item/item-format-version.js";import{assertProjectRuntimeFormatGuard as te}from"../environment/project-runtime-compatibility.js";import{enforceWorkflowMutation as re}from"../../core/policy/workflow-policy-store.js";import oe from"fast-json-patch";import _ from"node:fs/promises";import{readLocatedItemSnapshot as ae}from"../../core/store/item-store.js";import{advanceItemMutationPreconditions as ne,assertItemMutationPreconditions as ie,assertItemRevisionExpectationsOnUnreadable as se,transactionCompensationHistoryContext as ce}from"../../core/store/item-mutation-precondition.js";import{EMPTY_CANONICAL_DOCUMENT as de}from"../../core/shared/constants.js";import{readHistorySnapshot as me}from"../../core/history/read.js";import{verifyHistoryRewriteNoDrift as le}from"../../core/history/history-rewrite.js";import{resolveHistorySubject as fe}from"../history/subject.js";import{historyVersionOffset as ue}from"../../core/history/version-address.js";import{writeFileAtomic as R,appendHistoryEntry as ye,createHistoryEntry as he,replayToCanonicalItemDocument as we,replayToItemDocument as ge,toReplayDocument as H,enforceHistoryStreamPolicyForItem as pe,canonicalDocument as Ie,serializeItemDocument as _e,resolveItemTypeRegistry as Re,acquireLockLease as ve,EXIT_CODE as v,PmCliError as P,nowIso as Pe,getActiveExtensionRegistrations as A,projectAfterCommandItemSnapshot as D,recordAfterCommandAffectedItem as ke,runActiveOnWriteHooks as j,runActiveBeforeMutationHooks as xe,createMutationGuardSdk as be,getItemPath as Ce,resolvePmRoot as Le,resolveWorkspaceRoot as Te,readSettings as Fe,resolveAuthor as Oe}from"../runtime-primitives.js";import{applyHistoryPatch as He,ensureMaterializedHistoryTarget as E,extractPatchFailureContext as Ae,replayHistoryToTarget as k,resolveHistoryTarget as De}from"../history-read.js";import{acquireItemMetadataDerivedIndexLock as je,refreshItemMetadataDerivedIndex as Ee}from"../item-metadata-index.js";import{redactOptionalIdentityCredentials as Se}from"../../core/shared/url-credentials.js";function x(e){return{schema:e.schema,extensionFieldNames:Q(A())}}async function S(e,t,n){const i=await ae(e,x(t));return i.error===null?{raw:i.raw,document:i.document}:{raw:i.raw,document:b(n),recovered:!0}}function M(e,t){return De(e,t,{errorSubject:"restore",allowFutureTimestamp:!0})}function b(e){const t=k(e,e.length-1);return Object.keys(t.metadata).length===0?{metadata:{},body:t.body}:Ie(ge(t))}async function W(e,t,n,i){const r=await fe(e,t,n,i),o=r.located?await pe({pmRoot:e,settings:n,itemId:r.id,commandLabel:"restore"}):{warnings:[]};return{...r,historyPolicyWarnings:o.warnings}}function N(e,t){const n=H(e),i=H(t),r=oe.compare(n,i),o=new Set;for(const c of r){if(c.path==="/body"||c.path.startsWith("/body/")){o.add("body");continue}const s=c.path.replace(/^\/(?:metadata|front_matter)\/?/,"").split("/")[0];o.add(s.replaceAll("~1","/").replaceAll("~0","~"))}return Array.from(o).sort((c,s)=>c.localeCompare(s))}async function Me(e){const t=await le({pmRoot:e.pmRoot,subject:e.subject,settings:e.settings,typeRegistry:e.typeRegistry,historyRawBeforeLock:e.historyRawBeforeLock,currentItemRawBeforeLock:e.currentItemRawBeforeLock,operation:"restore",readItem:n=>S(n,e.settings,e.history)});return{loadedItemUnderLock:t.loadedItemUnderLock,existingItemPath:t.locatedUnderLock?.itemPath??null}}function We(e,t){return e?{document:e.document,originalRaw:e.raw}:{document:b(t),originalRaw:null}}function Ne(e){const t=e.document.metadata.assignee?.trim(),n=t&&t!==e.author&&!e.force,i=Se(t);if(!n)return[];if(e.enforcement==="strict")throw new P(`Item ${e.resolvedId} is assigned to ${i}. Use --force to override.`,v.CONFLICT);return e.enforcement==="warn"?[`ownership_warning:assignee_conflict:${e.resolvedId}:${i}`]:[]}function Be(e){return Object.keys(e).length===0?void 0:e}async function Ue(e){if(e.existingItemPath&&e.resolvedOriginalRaw!==null&&e.restoredItemPath!==e.existingItemPath){await R(e.existingItemPath,e.resolvedOriginalRaw),await _.rm(e.restoredItemPath,{force:!0});return}if(e.existingItemPath&&e.resolvedOriginalRaw!==null){await R(e.existingItemPath,e.resolvedOriginalRaw);return}await _.rm(e.restoredItemPath,{force:!0})}async function $e(e){return[...await j({path:e.restoredItemPath,scope:"project",op:"restore",item_id:e.after.metadata.id,item_type:e.after.metadata.type,before:e.before,after:e.after,changed_fields:["restored"]}),...await j({path:e.historyPath,scope:"project",op:"restore:history",item_id:e.after.metadata.id,item_type:e.after.metadata.type,before:e.before,after:e.after,changed_fields:["restored"]})]}async function dt(e,t,n,i){const r=Le(process.cwd(),i.path);await Z(r);const o=await Fe(r),c=Re(o,A()),s=await W(r,e,o,c.type_to_folder),d=s.id,{raw:B,entries:l}=await me(s.historyPath,d);if(l.length===0)throw new P(`No history exists for ${d}; restore is unavailable.`,v.NOT_FOUND);const f=M(t,l),U=E(k(l,f.historyIndex),f),a=we(U,x(o));if(a.metadata.id!==d)throw new P(`Restore target resolved to item ${a.metadata.id}, expected ${d}.`,v.GENERIC_FAILURE);const $=(s.located?await S(s.located,o,l):null)?.raw??null,u=Oe(n.author,o.author_default),C=await ve(r,d,o.locks.ttl_seconds,u,!!n.force,o.governance.force_required_for_stale_lock,o.locks.wait_ms,{waitPolicy:"progress"}),z=C.release;try{const{loadedItemUnderLock:y,existingItemPath:h}=await Me({pmRoot:r,subject:s,settings:o,typeRegistry:c,historyRawBeforeLock:B,currentItemRawBeforeLock:$,history:l}),L="toon",m=We(y,l);y?.recovered===!0&&se(r,d,y.raw),ie(r,y?.document??de,d),a.metadata.pm_format_version=ee(Math.max(I(a.metadata),I(m.document.metadata))),te(Te(r),I(a.metadata));const q=Ne({document:m.document,author:u,force:n.force,enforcement:o.governance.ownership_enforcement,resolvedId:d}),w=N(m.document,a),p=await re({pmRoot:r,settings:o,operation:"restore",author:u,before:m.document,after:a});await xe({pm_root:r,operation:"restore",before:m.document,after:a,changed_fields:w,author:u,sdk:be({pmRoot:r,settings:o,typeToFolder:c.type_to_folder})});const G=_e(a,{format:L,...x(o)}),g=Ce(r,a.metadata.type,d,L,c.type_to_folder),V=await C.fence(async()=>{const Y=await je(r,u);let O;try{await R(g,G),h&&g!==h&&await _.rm(h);const J=he({nowIso:Pe(),author:u,op:"restore",before:m.document,after:a,message:n.message,context:Be({...p.decisions.length===0?{}:{workflow_policies:p.decisions},...ce(r,[d,m.document.metadata.id,a.metadata.id],"restore")})});try{await ye(s.historyPath,J)}catch(K){throw await Ue({existingItemPath:h,resolvedOriginalRaw:m.originalRaw,restoredItemPath:g}),K}O=await Ee({pmRoot:r,preferredFormat:o.item_format,typeToFolder:c.type_to_folder,schema:o.schema,itemPath:g,previousItemPath:h??void 0,document:a})}finally{await Y()}return O});ne(r,a,d);const X=await $e({restoredItemPath:g,historyPath:s.historyPath,before:m.document,after:a});ke({id:a.metadata.id,op:"restore",item_type:a.metadata.type,previous_status:m.document.metadata.status,status:a.metadata.status,previous:D(m.document.metadata,w),current:D(a.metadata,w),changed_fields:w});const T=l[f.historyIndex],F=ue(l,!0);return{item:a.metadata,restored_from:{kind:f.kind,target:f.raw,history_index:f.historyIndex+1,version:F===null?null:F+f.historyIndex+1,entry_ts:T.ts,entry_op:T.op},changed_fields:w,warnings:[...p.warnings,...y?.recovered?["restore_unreadable_item_recovered"]:[],...s.historyPolicyWarnings,...q,...V,...X]}}finally{await z()}}const mt={applyHistoryPatch:He,changedFields:N,ensureMaterializedRestoreTarget:E,ensureReplayTarget:M,extractPatchFailureContext:Ae,replayCurrentDocument:b,replayToTarget:k,resolveRestoreSubject:W};export{mt as _testOnlyRestoreCommand,dt as runRestore};
|
|
2
2
|
//# sourceMappingURL=restore.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{EXIT_CODE as c,PmCliError as l}from"../runtime-primitives.js";import{isLegacyNoneToken as _}from"./legacy-none-tokens.js";const K=["close_reason","close-reason"],y=[{canonical:"tags",aliases:["tags"],optionKey:"tags",metadataKey:"tags"}],m=[{canonical:"deadline",aliases:["deadline"],optionKey:"deadline",metadataKey:"deadline"},{canonical:"estimate",aliases:["estimate","estimated_minutes","estimated-minutes"],optionKey:"estimatedMinutes",metadataKey:"estimated_minutes"},{canonical:"acceptance-criteria",aliases:["acceptance_criteria","acceptance-criteria","ac"],optionKey:"acceptanceCriteria",metadataKey:"acceptance_criteria"},{canonical:"definition-of-ready",aliases:["definition_of_ready","definition-of-ready"],optionKey:"definitionOfReady",metadataKey:"definition_of_ready"},{canonical:"order",aliases:["order","rank"],optionKey:"order",metadataKey:"order"},{canonical:"goal",aliases:["goal"],optionKey:"goal",metadataKey:"goal"},{canonical:"objective",aliases:["objective"],optionKey:"objective",metadataKey:"objective"},{canonical:"value",aliases:["value"],optionKey:"value",metadataKey:"value"},{canonical:"impact",aliases:["impact"],optionKey:"impact",metadataKey:"impact"},{canonical:"outcome",aliases:["outcome"],optionKey:"outcome",metadataKey:"outcome"},{canonical:"why-now",aliases:["why_now","why-now"],optionKey:"whyNow",metadataKey:"why_now"}],E=[...y,...m],f=[{canonical:"assignee",aliases:["assignee"],optionKey:"assignee",metadataKey:"assignee"},{canonical:"parent",aliases:["parent"],optionKey:"parent",metadataKey:"parent"},{canonical:"reviewer",aliases:["reviewer"],optionKey:"reviewer",metadataKey:"reviewer"},{canonical:"risk",aliases:["risk"],optionKey:"risk",metadataKey:"risk"},{canonical:"confidence",aliases:["confidence"],optionKey:"confidence",metadataKey:"confidence"},{canonical:"sprint",aliases:["sprint"],optionKey:"sprint",metadataKey:"sprint"},{canonical:"release",aliases:["release"],optionKey:"release",metadataKey:"release"},{canonical:"blocked-by",aliases:["blocked_by","blocked-by"],optionKey:"blockedBy",metadataKey:"blocked_by"},{canonical:"blocked-reason",aliases:["blocked_reason","blocked-reason"],optionKey:"blockedReason",metadataKey:"blocked_reason"},{canonical:"unblock-note",aliases:["unblock_note","unblock-note"],optionKey:"unblockNote",metadataKey:"unblock_note"},{canonical:"reporter",aliases:["reporter"],optionKey:"reporter",metadataKey:"reporter"},{canonical:"severity",aliases:["severity"],optionKey:"severity",metadataKey:"severity"},{canonical:"environment",aliases:["environment"],optionKey:"environment",metadataKey:"environment"},{canonical:"repro-steps",aliases:["repro_steps","repro-steps"],optionKey:"reproSteps",metadataKey:"repro_steps"},{canonical:"resolution",aliases:["resolution"],optionKey:"resolution",metadataKey:"resolution"},{canonical:"expected-result",aliases:["expected_result","expected-result"],optionKey:"expectedResult",metadataKey:"expected_result"},{canonical:"actual-result",aliases:["actual_result","actual-result"],optionKey:"actualResult",metadataKey:"actual_result"},{canonical:"affected-version",aliases:["affected_version","affected-version"],optionKey:"affectedVersion",metadataKey:"affected_version"},{canonical:"fixed-version",aliases:["fixed_version","fixed-version"],optionKey:"fixedVersion",metadataKey:"fixed_version"},{canonical:"component",aliases:["component"],optionKey:"component",metadataKey:"component"},{canonical:"regression",aliases:["regression"],optionKey:"regression",metadataKey:"regression"},{canonical:"customer-impact",aliases:["customer_impact","customer-impact"],optionKey:"customerImpact",metadataKey:"customer_impact"}],d=[...E,{canonical:"author",aliases:["author"],optionKey:"author",metadataKey:"author"},...f],w=[...y,{canonical:"close-reason",aliases:K,optionKey:"closeReason",metadataKey:"close_reason"},...m,...f],S=new Set(["none","null","-"]);function u(e){return e==="create"?d:w}function T(e,t){const a=t.unset;if(a!==void 0&&typeof a!="string"&&!Array.isArray(a))return;const s=[];for(const n of u(e))n.optionKey==="author"||!Object.hasOwn(t,n.optionKey)||t[n.optionKey]!==null||(Reflect.deleteProperty(t,n.optionKey),s.push(n.canonical));s.length!==0&&(t.unset=[...a===void 0?[]:typeof a=="string"?[a]:a,...s])}function p(e){return typeof e=="string"&&S.has(e.trim().toLowerCase())}function C(e,t,a,s){return a?u(e).flatMap(n=>{const o=t[n.optionKey],i=s[n.metadataKey];return p(o)&&(p(i)||Array.isArray(i)&&i.some(p))?[`literal_sentinel_stored:${n.canonical}:${o.trim()}`]:[]}):[]}function g(e,t){return e.flatMap(a=>a.includes(",")&&t(a)?[a]:a.split(","))}function N(e){const t=new Set,a=new Set;if(!e.raw||e.raw.length===0)return{metadataKeys:t,optionKeys:a};const s=g(e.raw,n=>e.resolveDefinition(n.trim().toLowerCase())!==void 0);for(const n of s){const o=n.trim().toLowerCase();if(!o)throw new l("--unset values must not be empty; name each field once, for example --unset parent,release",c.USAGE);if(_(o))throw new l('--unset no longer accepts "none" or "null". Specify concrete field names such as --unset deadline',c.USAGE);const i=e.resolveDefinition(o);if(!i)throw new l(`Unsupported --unset field "${n}". Supported fields: ${e.supportedFields}`,c.USAGE);t.add(i.metadataKey),a.add(i.optionKey)}return{metadataKeys:t,optionKeys:a}}function k(e,t,a){const s=e.trim().toLowerCase();if(!a)return;const n=a.command_to_fields?.get(t)??[];for(const o of n){if(o.allow_unset===!1)continue;const i=new Set;if(typeof o.key=="string"&&o.key.length>0&&i.add(o.key.toLowerCase()),typeof o.metadata_key=="string"&&o.metadata_key.length>0&&i.add(o.metadata_key.toLowerCase()),typeof o.cli_flag=="string"&&o.cli_flag.length>0&&(i.add(o.cli_flag.replaceAll("-","_").toLowerCase()),i.add(o.cli_flag.toLowerCase())),Array.isArray(o.cli_aliases))for(const r of o.cli_aliases)typeof r!="string"||r.length===0||(i.add(r.replaceAll("-","_").toLowerCase()),i.add(r.toLowerCase()));if(i.has(s))return{optionKey:o.key,metadataKey:o.metadata_key}}}const v=(()=>{const e=new Map;for(const t of d)for(const a of t.aliases)e.set(a,{optionKey:t.optionKey,metadataKey:t.metadataKey});return e})(),O=d.map(e=>e.canonical).sort((e,t)=>e.localeCompare(t)).join(", ");function L(e,t){return N({raw:e,supportedFields:O,resolveDefinition:a=>v.get(a)??k(a,"create",t)})}export{K as CLOSE_REASON_UNSET_ALIASES,f as COMMON_UNSET_FIELD_DEFINITIONS_AFTER_AUTHOR,m as COMMON_UNSET_FIELD_DEFINITIONS_AFTER_CLOSE_REASON_BEFORE_AUTHOR,E as COMMON_UNSET_FIELD_DEFINITIONS_BEFORE_AUTHOR,y as COMMON_UNSET_FIELD_DEFINITIONS_BEFORE_CLOSE_REASON,d as CREATE_UNSET_FIELD_DEFINITIONS,w as UPDATE_UNSET_FIELD_DEFINITIONS,g as expandUnsetFieldTokens,T as foldNullClearsIntoUnset,C as literalSentinelAdvisories,N as parseCommandUnsetTargets,L as parseCreateUnsetTargets,k as resolveRuntimeUnsetFieldDefinition};
|
|
2
2
|
//# sourceMappingURL=shared-unset-fields.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{AsyncLocalStorage as p}from"node:async_hooks";import{getActiveExtensionRegistrations as b}from"../../core/extensions/index.js";import{normalizeItemId as _}from"../../core/item/id.js";import{renderPmCommand as s}from"../../core/shared/command-line.js";import{normalizeStatusForRegistry as a}from"../../core/item/status.js";import{resolveItemTypeRegistry as y}from"../../core/item/type-registry.js";import{EXIT_CODE as k}from"../../core/shared/constants.js";import{PmCliError as w}from"../../core/shared/errors.js";import{isPmCliExpectedError as h}from"../errors.js";import{resolveDeclaredBlockers as C}from"../query/declared-blockers.js";import{resolveStartTaskInProgressStatus as u}from"../start-task-status.js";import{normalizeItemReference as S}from"../dependency-provenance.js";import{resolveCanonicalRelationshipKind as E}from"../relationships.js";const v="strict",M="start_blocked_by_open_dependency";function m(e,r,t){if(r===void 0)return!1;const n=a(u(t),t);return a(r,t)===n&&a(e??"",t)!==n}function l(e,r,t){const n=i=>_(i.trim(),t).toLowerCase();return n(e)===n(r)}const R=new Set(["cli:create:blocked_by","cli:update:blocked_by"]);function x(e,r,t){if(e.kind!=="blocked_by"||typeof r!="string"||r.trim().length===0)return!1;const n=e.id.trim().toLowerCase();return n===r.trim().toLowerCase()?!0:n===_(r.trim(),t).toLowerCase()&&R.has(e.source_kind?.trim().toLowerCase()??"")}function L(e,r,t){const n=e.dependencies??[],i=n.filter(o=>o.kind==="blocked_by");if(n.some(o=>o.kind!=="blocked_by"&&E(o.kind)==="blocked_by"&&l(o.id,r,t)))return s(["get",e.id,"--fields","blocked_by,dependencies"]);if(!(typeof e.blocked_by=="string"&&l(e.blocked_by,r,t))){const o=i.filter(d=>l(d.id,r,t));return o.length===1&&o.every(d=>d.id===S(d.id,t,void 0))?s(["update",e.id,"--dep-remove",`id=${o[0].id},kind=blocked_by`]):s(["get",e.id,"--fields","blocked_by,dependencies"])}return i.filter(o=>l(o.id,r,t)).every(o=>x(o,e.blocked_by,t))?s(["update",e.id,"--unset","blocked_by"]):s(["get",e.id,"--fields","blocked_by,dependencies"])}const T=new Set(["item_document_invalid","item_document_encoding_invalid","item_format_version_unsupported","item_identity_ambiguous","item_identity_conflict"]);async function $(e,r){try{return(await C(e)).filter(t=>!t.resolved)}catch(t){const n=h(t)?t.context.code:void 0;if(!r||typeof n!="string"||!T.has(n))throw t;return n}}async function g(e){const r=e.settings.governance.start_blocker_enforcement??v;if(r==="off")return[];const t=y(e.settings,b()).type_to_folder,n=e.metadata.id,i=await $({pmRoot:e.pmRoot,settings:e.settings,typeToFolder:t,metadata:e.metadata},r==="warn"||e.force===!0);if(typeof i=="string")return[`start_blocker_unverifiable:${n}:${i}`];if(i.length===0)return[];const c=i.map(o=>o.id).join(",");if(r==="warn")return[`start_with_open_blockers:${n}:${c}`];if(e.force===!0)return[`start_blocker_override:${n}:${c}`];throw new w(`Cannot start ${n}: ${i.length===1?"its blocker":`${i.length} of its blockers`} ${c} ${i.length===1?"is":"are"} still open.`,k.CONFLICT,{code:"start_blocked_by_open_dependency",item_id:n,required:`Finish or close the open blocker${i.length===1?"":"s"} first, remove the blocked_by edge if it no longer applies, or start anyway with --force.`,why:"Starting work that a declared blocker still gates would leave an in-progress item that validate reports as non_blocked_status_has_blocked_by. governance.start_blocker_enforcement (strict by default) governs this check.",nextSteps:[...i.filter(o=>o.external!==!0).slice(0,3).map(o=>s(["get",o.id])),L(e.metadata,i[0].id,e.settings.id_prefix),"pm next"],details:{enforcement:r,open_blockers:i.map(o=>({id:o.id,title:o.title,status:o.status,external:o.external===!0}))}})}async function W(e){if(e.requested===!1||!m(e.fromStatus,e.metadata.status,e.registry))return[];const r=await g(e),t=f.getStore()?.warnings??new Set;return r.filter(n=>!t.has(n))}const f=new p;function X(e){return f.run({warnings:new Set},e)}async function Y(e){const r=f.getStore();if(r===void 0)return[];const t=m(e.metadata.status,u(e.registry),e.registry)?await g(e):[];for(const n of t)r.warnings.add(n);return t}export{M as START_BLOCKED_REFUSAL_CODE,v as START_BLOCKER_ENFORCEMENT_DEFAULT,Y as admitExplicitStartClaim,W as admitStartTransition,g as admitStartWithOpenBlockers,m as isStartTransition,X as runAsExplicitStart,x as scalarClearRemovesDependency};
|
|
2
2
|
//# sourceMappingURL=start-blockers.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{resolveRuntimeFieldRegistry as u,runtimeFieldOptionTarget as p}from"../../core/schema/runtime-schema.js";import{listUpsertKeyCandidates as l,previewItemMutations as f,resolveTransactionSchema as g}from"../item-transaction.js";import{readSettings as w}from"../../core/store/settings.js";import{resolveCoreUpsertMetadataKey as y}from"./core-item-fields.js";import{EXIT_CODE as v}from"../../core/shared/constants.js";import{PmCliError as h}from"../../core/shared/errors.js";import{deriveMutationTransactionId as x,resolveItemMutationDocument as I}from"../structured-mutations.js";async function E(e){const{plan:t}=e,r=await f({pmRoot:e.pmRoot,author:e.author,transactionId:t.transaction_id,mutations:t.mutations}),a=new Map(r.warnings.map(n=>[n.index,n.warnings])),o=t.rows.map(n=>{const i={...n};delete i.warnings;const m=a.get(n.index);return m!==void 0&&(i.warnings=m),i});return{validation:r,rows:o}}async function S(e){const t=e.upsertKey?.trim();if(t!==void 0&&t.length===0)throw new h("Upsert key must be a non-empty field name.",v.USAGE);const r=e.settings??await w(e.pmRoot),a=e.transactionId?.trim()??"",o=a.length>0?a:x(e.input),n=await g(e.pmRoot,r),i=u(n.schema).definitions,c=(i.find(d=>d.metadata_key===t)??i.find(d=>d.key===t||p(d)===t))?.metadata_key??y(t),s=c===void 0?void 0:{key:c,existing:await l(e.pmRoot,r,n,c)};return{...I(e.input,{transactionId:o,idPrefix:r.id_prefix,runtimeFields:i,...s===void 0?{}:{upsert:s}}),transaction_id:o,transaction_id_source:a.length>0?"explicit":"derived",...s===void 0?{}:{upsert_key:s.key}}}export{S as planItemMutationDocument,E as previewItemMutationDocument};
|
|
2
2
|
//# sourceMappingURL=structured-mutation-plan.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{PmCliError as o}from"../../core/shared/errors.js";import{EXIT_CODE as u}from"../../core/shared/constants.js";import{resolveRuntimeStatusRegistry as h}from"../../core/schema/runtime-schema.js";import{resolvePmRoot as p}from"../../core/store/paths.js";import{readSettings as w}from"../../core/store/settings.js";import{runClaim as y,runRelease as f}from"./claim.js";import{resolveReleaseHandoff as v}from"./release-handoff.js";import{runClose as S}from"./close.js";import{runUpdate as x}from"./update.js";import{resolveStartTaskInProgressStatus as _}from"../start-task-status.js";import{runAsExplicitStart as g,START_BLOCKED_REFUSAL_CODE as C}from"./start-blockers.js";import{runWithItemMutationPrecondition as R}from"../../core/store/item-mutation-precondition.js";import{mutationOptionsWithOverrides as l}from"../runtime-input.js";async function d(e,t,a){try{return await a()}catch(r){const s=r instanceof o?r.context:{},i=new o(r instanceof Error?r.message:String(r),r instanceof o?r.exitCode:u.GENERIC_FAILURE,{...s,item_id:e,why:`${t} completed for ${e} before the following step failed. No rollback was performed.${s.why?` ${s.why}`:""}`,nextSteps:[`Inspect the persisted state with pm get ${e} and pm history ${e} before retrying the failed step.`,...s.nextSteps??[]]});throw i.cause=r,i}}async function G(e,t,a){if(t.next===!0||t.ifAvailable===!0)throw new o("--start cannot be combined with --next or --if-available for an explicit item",u.USAGE,{code:"invalid_argument_value",required:"Remove --next and --if-available when starting an explicit item.",nextSteps:["Remove --next and --if-available, keep the explicit item ID and other supplied arguments, then retry."]});const r=await w(p(process.cwd(),a.path)),s=_(h(r.schema));return g(async()=>{const i=await y(e,t.force===!0,a,l(t,{},["start"])),n=i.item.id,c=await d(n,"claim",()=>x(n,l(t,{status:s},["assignee","start","next","ifAvailable","maxAttempts","takeoverStale"]),a)).catch(async m=>{throw await k(m,i,a,t.author)});return{id:n,action:"start_task",claim:i,update:c}})}async function k(e,t,a,r){if(!(e instanceof o)||e.code!==C||t.previous_assignee!==null)return e;const s=String(t.item.id);try{await R({pmRoot:p(process.cwd(),a.path),id:s,validate:n=>{if(n.metadata.assignee!==t.claimed_by||n.metadata.claim_principal!==t.item.claim_principal)throw new o("The claim this start took is no longer its own.",u.CONFLICT)}},()=>f(s,!1,a,{author:r,message:"Release the claim: a blocker opened before its start could be recorded"}))}catch{return e}const i=e.cause instanceof o?e.cause:e;return new o(i.message,i.exitCode,{...i.context,why:`${i.context.why??""} A blocker opened after this start's claim, so the claim was released and no ownership remains.`.trim()})}async function W(e,t,a){const r=await w(p(process.cwd(),a.path)),s=h(r.schema);v({...t,pause:!0},s);const i=s.open_status,n=await x(e,l(t,{status:i},["assignee","pause"]),a),c=n.item.id,m=await d(c,"update",()=>f(c,t.force===!0,a,t));return{id:c,action:"pause_task",update:n,release:m}}async function q(e,t,a,r){const s=await S(e,t,a,r),i=s.item.id,n=await d(i,"close",()=>f(i,a.force===!0,r,a));return{id:i,action:"close_task",close:s,release:n}}export{d as finishComposition,k as releaseRefusedStartClaim,q as runCloseTask,W as runPauseTask,G as runStartTask};
|
|
2
2
|
//# sourceMappingURL=task-composition.js.map
|