@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
|
+
const t={include:"--output-include",amount:"--output-limit",cost:"--output-budget",encoding:"--output-format"},e=Object.freeze(["--output-session","--output-cursor","--output-row-contract"]),o=["list","context","search","get","next","health","deps","graph","history","activity","validate","events","contracts","comments","notes","learnings","files","docs","stats","aggregate","duplicates","package-catalog","package-manage","comments-audit","assurance"];export{o as PM_READ_OUTPUT_SURFACES,e as READ_OUTPUT_COMPOSITION_FLAGS,t as READ_OUTPUT_DIMENSION_FLAGS};
|
|
2
2
|
//# sourceMappingURL=options.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const t=Object.freeze({comments:Object.freeze(["comments"]),notes:Object.freeze(["notes"]),learnings:Object.freeze(["learnings"])});function n(e){return e===void 0||!Object.hasOwn(t,e)?[]:t[e]}export{t as PM_READ_OUTPUT_POSITIONAL_ROW_PATHS,n as readOutputPositionalRowPaths};
|
|
2
2
|
//# sourceMappingURL=positional-rows.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const t=Symbol.for("pm.readOutputInvocationProvenance");function o(e,n){return Reflect.set(e,t,{canonical_include_modes:[...n],explicit_legacy_aliases:[],sdk_invocation_observed:!0}),e}export{t as READ_OUTPUT_INVOCATION_PROVENANCE,o as markCanonicalSdkReadOutputOptions};
|
|
2
2
|
//# sourceMappingURL=provenance.js.map
|
|
@@ -1,2 +1 @@
|
|
|
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]="8ee4b7eb-d69e-5d95-9acc-e75dd61aaa9c")}catch{}})();
|
|
2
1
|
//# sourceMappingURL=session-result.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{PM_READ_OUTPUT_SURFACES as i}from"./options.js";const c={list:{include:["--brief","--compact","--fields","--full"],amount:["--after","--limit","--no-truncate"],cost:["--token-budget"],encoding:["--format","--stream"]},context:{include:["--fields","--section"],amount:["--after","--depth","--limit"],cost:["--token-budget"],encoding:["--format"]},search:{include:["--compact","--fields","--full"],amount:["--after","--limit"],cost:["--token-budget"],encoding:["--format"]},get:{include:["--fields","--full"],amount:["--depth"],cost:["--token-budget"],encoding:["--format"]},next:{amount:["--blocked-limit","--limit"],encoding:["--format"]},health:{include:["--brief","--check-only","--full","--summary"]},deps:{include:["--collapse","--full","--summary"],amount:["--edge-limit","--max-depth","--node-limit"],cost:["--token-budget"],encoding:["--format"]},graph:{include:["--full","--summary"],amount:["--after","--limit","--max-depth","--max-paths"]},history:{include:["--compact","--full"],amount:["--limit"],encoding:["--format"]},activity:{include:["--compact","--full"],amount:["--limit","--unbounded","--after"],encoding:["--stream"]},validate:{include:["--counts","--full"]},events:{include:["--full"],amount:["--limit"],encoding:["--follow"]},contracts:{include:["--full","--summary"]},comments:{amount:["--limit"]},notes:{amount:["--limit"]},learnings:{amount:["--limit"]},files:{amount:["--limit","--no-truncate","--offset"]},docs:{},stats:{},aggregate:{},duplicates:{amount:["--limit"]},"package-catalog":{},"package-manage":{},"comments-audit":{},assurance:{}},s=new Set(["--collapse","--fields","--section"]),u=Object.freeze({"--after":"--after retains cursor-position semantics; use --output-limit <n> separately to bound returned rows.","--check-only":"--check-only retains health side-effect semantics; --output-include does not suppress vector refresh.","--collapse":"--collapse retains dependency grouping semantics; --output-include does not replace it.","--depth":"--depth retains traversal or detail-depth semantics; --output-limit does not replace it.","--follow":"--follow retains event-tail semantics; --output-format does not enable following.","--max-depth":"--max-depth retains graph traversal-depth semantics; --output-limit does not replace it.","--max-paths":"--max-paths retains graph path-search semantics; use --output-limit separately to bound returned rows.","--no-truncate":"--no-truncate is a compatibility alias; prefer --output-limit unbounded --output-budget unbounded.","--offset":"--offset retains positional pagination semantics; use --output-limit separately to bound returned rows.","--stream":"--stream retains command streaming semantics; --output-format selects only static result encoding.","--unbounded":"--unbounded is a compatibility alias; prefer --output-limit unbounded."});function l(t){return t.slice(2).replaceAll("-","_")}function d(t,e={}){const a=t==="package catalog"||t==="packages catalog"||t==="package-catalog"||(t==="package"||t==="packages"||t==="extension")&&(e.catalog===!0||e.target==="catalog"||e.action==="catalog")?"package-catalog":t==="package manage"||t==="package-manage"?"package-manage":t.split(" ")[0],n=a.startsWith("list-")?"list":a==="ctx"?"context":a;return i.includes(n)?n:void 0}function m(t){return new Map((c[t]?.include??[]).filter(e=>!s.has(e)&&u[e]===void 0).map(e=>[l(e),r(e)]))}function r(t){return t.slice(2).replace(/-([a-z])/gu,(e,o)=>o.toUpperCase())}export{u as BEHAVIOR_PRESERVING_MIGRATION_HINTS,c as LEGACY_FLAGS_BY_COMMAND,s as VALUE_BEARING_INCLUDE_ALIASES,l as flagSelector,r as optionKey,m as readOutputIncludeModeOptionsForSurface,d as resolveNativeReadOutputSurface};
|
|
2
2
|
//# sourceMappingURL=surfaces.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const t=Object.freeze({comments:Object.freeze({paths:Object.freeze(["comments"]),total_key:"total_count"}),notes:Object.freeze({paths:Object.freeze(["notes"]),total_key:"total_count",delivered_row_counters:Object.freeze([Object.freeze({key:"structured_event_count",field:"format",equals:"json"})])}),learnings:Object.freeze({paths:Object.freeze(["learnings"]),total_key:"total_count"})});function o(e,n){return e===void 0?!1:(Object.hasOwn(t,e)?t[e]:void 0)?.paths.includes(n)===!0}export{t as PM_READ_OUTPUT_TAIL_RETENTION_POLICIES,o as readOutputRetainsTail};
|
|
2
2
|
//# sourceMappingURL=tail-retention.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{formatBuiltInOutput as T}from"../core/output/output.js";import{COMPACTED_STRING_LENGTH as C,compactExplanatoryString as x,isContinuationTokenKey as M,isTrackerItemDocumentKey as k}from"../core/shared/text-normalization.js";import{countReadOutputRows as j,readOutputBudgetCollections as S}from"./read-output-rows.js";const D=8,P=64,B=5,G=4,w=100,I=new WeakMap,N=new WeakMap;function J(t,e){I.set(t,e)}function $(t){return I.get(t)}function q(t,e){N.set(t,e)}function Q(t,e,n){if(t!=="get"||!b(n.item)||["fields","outputInclude","output_include","outputCursor","output_cursor"].some(s=>e[s]!==void 0)||e.full===!0||e.tree===!0||e.depth!==void 0&&e.depth!=="standard")return;const r=n.item,o=["linked","claim_state","schedule"],u=o.filter(s=>Object.hasOwn(n,s)),f=Object.fromEntries(Object.entries(n).filter(([s])=>!o.includes(s)));f.item=Object.fromEntries(Object.entries(r).filter(([s])=>s!=="body")),Object.hasOwn(r,"body")&&u.push("body");const i=[...b(n.omission_receipt)&&Array.isArray(n.omission_receipt.omitted_field_groups)?n.omission_receipt.omitted_field_groups:[],...u.map(s=>({name:s,restore_with:`--fields ${s}`}))];return f.omission_receipt={has_omissions:i.length>0,omitted_field_group_count:i.length,omitted_field_groups:i},f}function Z(t){const e=Math.trunc(t.effective_budget_tokens),n=Math.trunc(t.measured_result_tokens);if(!Number.isSafeInteger(e)||e<=0||!Number.isSafeInteger(n)||n<=0)return{output_budget:"unbounded",recovery_budget_multiplier:null,rule_version:"v1"};const r=Math.max(e+1,n),o=Math.ceil(r*B/G),u=Math.ceil(o/w)*w;return Number.isSafeInteger(u)?{output_budget:u,recovery_budget_multiplier:u/e,rule_version:"v1"}:{output_budget:"unbounded",recovery_budget_multiplier:null,rule_version:"v1"}}function K(t,e,n=!1){const r=Object.getOwnPropertyDescriptor(t,"row_contract");r&&(n||r.enumerable===!1)&&Object.defineProperty(e,"row_contract",{...r,enumerable:!1})}function z(t){const e=t.resolvedOutputFormat??t.outputFormat??t.output_format??t.format;return e==="json"||e==="toon"?e:void 0}let d;function tt(t,e,n){const r=d;d={format:t,render:e};try{return n()}finally{d=r}}function H(t,e){const n=e===void 0?JSON.stringify(t):d!==void 0&&d.format===e?Y(d,t):T(t,e);return Math.ceil(Buffer.byteLength(n,"utf8")/4)}function Y(t,e){d=void 0;try{return t.render(e)}finally{d=t}}function b(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function y(t,e,n=!1,r=!0){return typeof t=="string"?n?t:(t.length>C&&(e.compacted=!0),x(t)):Array.isArray(t)?t.map(o=>y(o,e,n,r)):b(t)?Object.fromEntries(Object.entries(t).map(([o,u])=>[o,y(u,e,n||r&&(o==="focus_row_states"||typeof u=="string"&&M(o)),r)])):t}function R(t,e,n){let r=e.estimated_tokens;for(let o=0;o<D;o+=1){A(t,e,r);const u=H(t,n);if(u===r)return!0;r=u}return A(t,e,r),!1}function A(t,e,n){e.estimated_tokens=n,N.get(e)?.(t,n)}const F=4;function E(t,e,n,r){R(t,e,r);const o=e.estimated_tokens;o<=n||o-10**(String(o).length-1)>=F||(e.estimated_tokens=0,!(R(t,e,r)&&e.estimated_tokens<=n)&&A(t,e,o))}const et={settleCandidateEstimate:E};function L(t,e){return S(t).filter(n=>(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length)>Math.max(1,e.get(n.path)??0)).map(n=>({collection:n,length:Array.isArray(n.value)?n.value.length:Object.keys(n.value).length})).sort((n,r)=>r.length-n.length||n.collection.path.localeCompare(r.collection.path))[0]?.collection}function U(t,e,n,r,o,u,f){for(let _=0;_<P;_+=1){if(u?.(t),E(t,e,n,o),e.estimated_tokens<=n)return;const i=L(t,r);if(!i)return;const s=Math.max(1,r.get(i.path)??0),c=Array.isArray(i.value)?[...i.value]:Object.entries(i.value),p=f(i.path),l=a=>{const O=p?c.length-a:0;if(Array.isArray(i.value)){i.value.length=a;for(let m=0;m<a;m+=1)i.value[m]=c[O+m]}else{for(const m of Object.keys(i.value))delete i.value[m];Object.defineProperties(i.value,Object.getOwnPropertyDescriptors(Object.fromEntries(c.slice(O,O+a))))}typeof t.count=="number"&&(t.count=j(t)),typeof t.returned_count=="number"&&(t.returned_count=j(t)),i.path==="items"&&(t.applied_limit=a),u?.(t),E(t,e,n,o)};e.rows_compacted=!0,e.compacted_row_paths=[...new Set([...e.compacted_row_paths??[],i.path])].sort((a,O)=>a.localeCompare(O)),t.has_more=!0,t.truncated=!0;let g=s,h=c.length-1,v=s;for(;g<=h;){const a=Math.floor((g+h)/2);l(a),e.estimated_tokens<=n?(v=a,g=a+1):h=a-1}l(v)}}function nt(t,e,n,r=new Map,o,u,f=!1,_=()=>!1,i){const s={compacted:!1},c=Object.fromEntries(Object.entries(t).map(([p,l])=>[p,y(l,s,f&&p==="diff"||typeof l=="string"&&M(p),!k(i,p))]));return K(t,c),e.strings_compacted=s.compacted,c.read_output=e,U(c,e,n,r,o,u,_),R(c,e,o),c}export{D as MAX_ESTIMATE_ITERATIONS,et as _testOnly,nt as compactReadOutputToBudget,H as estimateReadOutputTokens,q as mirrorReadOutputReceiptEstimate,K as preserveReadOutputRowContract,Q as projectReadOutputItemToBrief,z as readOutputMeasurementFormat,J as registerReadOutputPassHooks,$ as resolveReadOutputPassHooks,Z as resolveReadOutputRecoveryBudget,R as updateReadOutputReceiptEstimate,tt as withDeliveredOutputRenderer};
|
|
2
2
|
//# sourceMappingURL=read-output-budget.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]="0456278a-5928-5a60-8d53-d12ffb1a7a5d")}catch{}})();import{READ_OUTPUT_DIMENSION_FLAGS,READ_OUTPUT_COMPOSITION_FLAGS,PM_READ_OUTPUT_SURFACES}from"./read-output/options.js";import{resolvePmHistoryOperation}from"./cli-contracts/command-aliases.js";import{resolveExtensionOutputCommand}from"./read-output/extension.js";import{BEHAVIOR_PRESERVING_MIGRATION_HINTS,LEGACY_FLAGS_BY_COMMAND,VALUE_BEARING_INCLUDE_ALIASES,flagSelector,optionKey,readOutputIncludeModeOptionsForSurface,resolveNativeReadOutputSurface}from"./read-output/surfaces.js";import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";import{compactReadOutputToBudget,estimateReadOutputTokens,readOutputMeasurementFormat,projectReadOutputItemToBrief,preserveReadOutputRowContract,mirrorReadOutputReceiptEstimate,resolveReadOutputPassHooks,resolveReadOutputRecoveryBudget,updateReadOutputReceiptEstimate}from"./read-output-budget.js";import{resolveReadOutputRecoveryBudget as resolveReadOutputRecoveryBudget2}from"./read-output-budget.js";import{resolvePmCommandOutputBudget}from"./cli-contracts/agent-output-contracts.js";import{boundReadOutputRows,countReadOutputRows,mapReadOutputRows,readOutputBudgetCollections,readOutputContinuationRowCollections,readOutputRowPaths,readOutputRowCollections,refreshReadOutputDeliveredCounts}from"./read-output-rows.js";import{applyReadOutputContinuation,decodeReadOutputContinuationCursor,encodeReadOutputContinuationCursor,prioritizeAssuranceAssertions,readOutputCollectionFingerprint,refreshReadOutputDeliveredRowCounters}from"./read-output/continuation.js";import{PM_READ_OUTPUT_TAIL_RETENTION_POLICIES,readOutputRetainsTail}from"./read-output/tail-retention.js";import{decodeReadOutputContinuationCursor as decodeReadOutputContinuationCursor2,encodeReadOutputContinuationCursor as encodeReadOutputContinuationCursor2,PM_READ_OUTPUT_CONTINUATION_FINGERPRINT_POLICIES,readOutputCollectionFingerprint as readOutputCollectionFingerprint2}from"./read-output/continuation.js";import{PM_READ_OUTPUT_TAIL_RETENTION_POLICIES as PM_READ_OUTPUT_TAIL_RETENTION_POLICIES2,readOutputRetainsTail as readOutputRetainsTail2}from"./read-output/tail-retention.js";import{applyReadOutputSessionReferences,attachReadOutputSessionReceipt,parseReadOutputSession,readOutputSessionRemainingTokens}from"./read-output-session.js";import{decodeQueryCursorEnvelope,encodeQueryCursor}from"./pagination.js";import{READ_OUTPUT_INVOCATION_PROVENANCE}from"./read-output/provenance.js";const PM_READ_OUTPUT_DIMENSIONS=["include","amount","cost","encoding"];import{PM_READ_OUTPUT_SURFACES as PM_READ_OUTPUT_SURFACES2}from"./read-output/options.js";const READ_OUTPUT_PRECEDENCE=["canonical","legacy","intent","default"],CANONICAL_OPTIONS=READ_OUTPUT_DIMENSION_FLAGS,PM_READ_OUTPUT_OPTION_FLAGS=Object.freeze(PM_READ_OUTPUT_DIMENSIONS.map(dimension=>CANONICAL_OPTIONS[dimension])),PM_READ_OUTPUT_COMPOSITION_OPTION_FLAGS=READ_OUTPUT_COMPOSITION_FLAGS;function migrationHint(flag,dimension){const behaviorHint=BEHAVIOR_PRESERVING_MIGRATION_HINTS[flag];if(behaviorHint!==void 0)return behaviorHint;const suffix=dimension==="include"?VALUE_BEARING_INCLUDE_ALIASES.has(flag)?"<csv>":flagSelector(flag):dimension==="amount"?"<n>":dimension==="cost"?"<tokens>":"<toon|json>";return`${flag} is a compatibility alias; prefer ${CANONICAL_OPTIONS[dimension]} ${suffix}.`}function buildSurfaceContract(command){const legacy=LEGACY_FLAGS_BY_COMMAND[command]??{},dimensions=Object.freeze(Object.fromEntries(PM_READ_OUTPUT_DIMENSIONS.map(dimension=>[dimension,Object.freeze({dimension,canonical_option:CANONICAL_OPTIONS[dimension],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((legacy[dimension]??[]).map(flag=>Object.freeze({flag,semantics:BEHAVIOR_PRESERVING_MIGRATION_HINTS[flag]===void 0?"replacement":"behavior_preserving",migration_hint:migrationHint(flag,dimension),visibility:"hidden_alias"})))})])));return Object.freeze({command,dimensions,precedence:READ_OUTPUT_PRECEDENCE,budget_retention_policy:command==="assurance"?"verdict_priority":Object.hasOwn(PM_READ_OUTPUT_TAIL_RETENTION_POLICIES,command)?"ordered_suffix":"ordered_prefix",projection_modes:Object.freeze([...readOutputIncludeModeOptionsForSurface(command).keys()])})}const PM_READ_OUTPUT_SURFACE_CONTRACTS=Object.freeze(PM_READ_OUTPUT_SURFACES.map(buildSurfaceContract)),SURFACE_CONTRACT_BY_COMMAND=new Map(PM_READ_OUTPUT_SURFACE_CONTRACTS.map(contract=>[contract.command,contract]));function resolveReadOutputSurface(command,options={}){const normalizedCommand=resolvePmHistoryOperation(command.trim().toLowerCase()),extension=resolveExtensionOutputCommand(normalizedCommand);return extension!==void 0?extension.read_output===void 0?void 0:`extension:${extension.command}`:resolveNativeReadOutputSurface(normalizedCommand,options)}const CANONICAL_OPTION_KEYS=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],HYBRID_READ_MUTATION_KEYS={comments:["add","body","comment","text","stdin","file","edit","delete"],notes:["add","note","text","addJson","stdin","file","edit","delete"],learnings:["add","learning","text","stdin","file","edit","delete"],files:["add","addGlob","remove","migrate","apply","note"],docs:["add","addGlob","remove","migrate","note"],"package-catalog":["activate","adopt","adoptAll","deactivate","doctor","init","install","manage","migrate","reload","scaffold","uninstall"]};function hasCanonicalReadOutputOptions(options){return CANONICAL_OPTION_KEYS.some(key=>key!=="outputFormat"&&key!=="output_format"&&options[key]!==void 0)}const READ_OUTPUT_VALUE_VALIDATORS=[{keys:["outputInclude","output_include"],valid:value=>stringList(value)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:value=>value==="unbounded"||positiveInteger(value)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:value=>value==="unbounded"||positiveInteger(value)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputSession","output_session"],valid:value=>(parseReadOutputSession(value),!0),message:"--output-session must be a valid session-state object."},{keys:["outputCursor","output_cursor"],valid:value=>typeof value=="string"&&value.trim().length>0,message:"--output-cursor requires a non-empty continuation cursor."}],READ_OUTPUT_MUTATION_CONFLICT_CODE="read_output_mutation_conflict",READ_OUTPUT_SHAPING_CONTROLS=[{flag:"--output-include",keys:["outputInclude","output_include"]},{flag:"--output-limit",keys:["outputLimit","output_limit"]},{flag:"--output-budget",keys:["outputBudget","output_budget"]},{flag:"--output-session",keys:["outputSession","output_session"]},{flag:"--output-cursor",keys:["outputCursor","output_cursor"]},{flag:"--output-row-contract",keys:["outputRowContract","output_row_contract"]}],READ_OUTPUT_SHAPING_CONTROL_FLAGS=READ_OUTPUT_SHAPING_CONTROLS.map(({flag})=>flag);function readOutputMutationConflict(surface,options,mutationOptions){const present=READ_OUTPUT_SHAPING_CONTROLS.filter(({keys})=>keys.some(key=>options[key]!==void 0)),flags=present.map(({flag})=>flag),optionKeys=present.flatMap(({keys})=>keys.filter(key=>options[key]!==void 0)),listed=flags.join(", ");return new PmCliError(`Universal output controls (${listed}) cannot be combined with a ${surface} mutation; nothing was written.`,EXIT_CODE.USAGE,{code:"read_output_mutation_conflict",field:flags[0],details:{surface,output_controls:flags,output_option_keys:optionKeys,mutation_options:[...mutationOptions]},required:`Retry the ${surface} mutation without ${listed}. To bound or page the result, read it with those controls in a separate call after the write.`,why:"Universal output controls shape a read. A mutation returns its own bounded receipt, so the controls have nothing to shape and the write is refused before it runs.",examples:[...READ_OUTPUT_MUTATION_RETRY_EXAMPLES[surface]]})}const READ_OUTPUT_MUTATION_RETRY_EXAMPLES={comments:['pm comments <id> --add "<text>"',"pm comments <id> --output-limit 5"],notes:['pm notes <id> --add "<text>"',"pm notes <id> --output-limit 5"],learnings:['pm learnings <id> --add "<text>"',"pm learnings <id> --output-limit 5"],files:["pm files <id> --add path=<path>","pm files <id> --output-limit 5"],docs:["pm docs <id> --add path=<path>","pm docs <id> --output-limit 5"],"package-catalog":["pm package install <source> --project","pm package catalog --output-limit 5"]};function validateReadOutputOptions(command,options){const encoding=options.outputFormat??options.output_format;if(encoding!==void 0&&encoding!=="json"&&encoding!=="toon")throw new PmCliError("--output-format must be toon or json.",EXIT_CODE.USAGE);if(!hasCanonicalReadOutputOptions(options))return;const normalizedCommand=resolveReadOutputSurface(command,options);if(!normalizedCommand)throw new PmCliError(`Universal output controls apply only to read commands; ${command||"this command"} is not a read surface.`,EXIT_CODE.USAGE);if(Object.hasOwn(HYBRID_READ_MUTATION_KEYS,normalizedCommand)){const surface=normalizedCommand,mutationOptions=HYBRID_READ_MUTATION_KEYS[surface].filter(key=>options[key]!==void 0&&options[key]!==!1);if(mutationOptions.length>0)throw readOutputMutationConflict(surface,options,mutationOptions)}for(const validator of READ_OUTPUT_VALUE_VALIDATORS){const value=validator.keys.map(key=>options[key]).find(entry=>entry!==void 0);if(value!==void 0&&!validator.valid(value))throw new PmCliError(validator.message,EXIT_CODE.USAGE)}}function readOutputIncludeModeOptions(command){const surface=resolveReadOutputSurface(command);return surface?readOutputIncludeModeOptionsForSurface(surface):new Map}function applyReadOutputIncludeModes(command,includeValue,commandOptions){const requested=stringList(includeValue)??[],modeOptions=readOutputIncludeModeOptions(command),selectors=[],modes=[],optionsWithProvenance=commandOptions,existingProvenance=optionsWithProvenance[READ_OUTPUT_INVOCATION_PROVENANCE],canonicalModes=new Set(existingProvenance?.canonical_include_modes??[]),explicitLegacyAliases=new Set(existingProvenance?.explicit_legacy_aliases??[]);for(const token of requested){const option=modeOptions.get(token);if(option===void 0){selectors.push(token);continue}const legacyFlag=`--${token.replaceAll("_","-")}`;isRequestedOption(readOption(commandOptions,legacyFlag))&&explicitLegacyAliases.add(legacyFlag),commandOptions[option]=!0,modes.push(token),canonicalModes.add(token)}const forwardedGetFieldSelectors=resolveReadOutputSurface(command)==="get"?selectors.filter(selector=>selector!=="item"):[],forwardedGetFields=forwardedGetFieldSelectors.length>0;return forwardedGetFields&&(commandOptions.fields=[...new Set([...stringList(commandOptions.fields)??[],...forwardedGetFieldSelectors])].join(","),canonicalModes.add("fields")),(modes.length>0||forwardedGetFields)&&(optionsWithProvenance[READ_OUTPUT_INVOCATION_PROVENANCE]={canonical_include_modes:[...canonicalModes],explicit_legacy_aliases:[...explicitLegacyAliases],...existingProvenance?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors,modes}}function normalizeReadOutputIncludeModeOptions(command,options){const include=options.outputInclude??options.output_include;if(include===void 0)return;const{selectors,modes}=applyReadOutputIncludeModes(command,include,options);if(modes.length===0)return;const residual=selectors.length>0?selectors.join(","):void 0;options.outputInclude=residual,Object.hasOwn(options,"output_include")&&(options.output_include=residual)}function readOption(options,flag){const key=optionKey(flag);if(Object.hasOwn(options,key))return options[key];const snakeKey=flag.slice(2).replaceAll("-","_");if(Object.hasOwn(options,snakeKey))return options[snakeKey];if(flag==="--no-truncate"&&options.truncate===!1)return!0}function isRequestedOption(value){return value!==void 0&&value!==!1&&value!==null}function stringList(value){const normalized=(Array.isArray(value)?value:[value]).flatMap(entry=>typeof entry=="string"?entry.split(","):[]).map(entry=>entry.trim()).filter(Boolean);return normalized.length>0?[...new Set(normalized)]:void 0}function positiveInteger(value){const parsed=typeof value=="number"?value:typeof value=="string"&&/^\d+$/u.test(value.trim())?Number(value):Number.NaN;return Number.isSafeInteger(parsed)&&parsed>0?parsed:void 0}function resolveLegacyDimension(contract,options,usable,ignore){for(const alias of contract.legacy_aliases){if(ignore(alias.flag))continue;const value=readOption(options,alias.flag),candidate={value,flag:alias.flag};if(isRequestedOption(value)&&usable(candidate))return candidate}}function resolveIncludeValue(canonical,legacy){const canonicalList=stringList(canonical);if(canonicalList)return{source:"canonical",value:canonicalList};if(legacy)return{source:"legacy",value:stringList(legacy.value)??[flagSelector(legacy.flag)]}}function resolveAmountValue(canonical,legacy){if(canonical==="unbounded")return{source:"canonical",value:"unbounded"};const canonicalLimit=positiveInteger(canonical);if(canonicalLimit!==void 0)return{source:"canonical",value:canonicalLimit};if(!legacy)return;if(legacy.flag==="--no-truncate"||legacy.flag==="--unbounded")return{source:"legacy",value:"unbounded"};const legacyLimit=positiveInteger(legacy.value);return legacyLimit===void 0?void 0:{source:"legacy",value:legacyLimit}}function resolveCostValue(canonical,legacy){if(canonical==="unbounded")return{source:"canonical",value:"unbounded"};const canonicalBudget=positiveInteger(canonical);if(canonicalBudget!==void 0)return{source:"canonical",value:canonicalBudget};if(!legacy)return;const legacyBudget=positiveInteger(legacy.value);return legacyBudget===void 0?void 0:{source:"legacy",value:legacyBudget}}function resolveEncodingValue(canonical,legacy){if(canonical==="json"||canonical==="toon")return{source:"canonical",value:canonical};if(legacy)return legacy.flag==="--stream"||legacy.flag==="--follow"?{source:"legacy",value:"stream"}:legacy.value==="json"||legacy.value==="toon"?{source:"legacy",value:legacy.value}:void 0}function shouldIgnoreReadOutputLegacyAlias(provenance,dimension,flag){if(!provenance)return!1;const explicitLegacyAliases=new Set(provenance.explicit_legacy_aliases);if(provenance.cli_invocation_observed===!0||provenance.sdk_invocation_observed===!0)return!explicitLegacyAliases.has(flag);const forwardedIncludeAliases=new Set(provenance.canonical_include_modes.map(mode=>`--${mode.replaceAll("_","-")}`));return dimension==="include"&&forwardedIncludeAliases.has(flag)&&!explicitLegacyAliases.has(flag)}function hasCompleteReadOutputIntent(command,legacyByDimension,provenance,options){return command.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||isRequestedOption(readOption(options,"--no-truncate"))&&!shouldIgnoreReadOutputLegacyAlias(provenance,"amount","--no-truncate")||legacyByDimension.amount?.flag==="--no-truncate"||legacyByDimension.include?.flag==="--full"||provenance?.canonical_include_modes.includes("full")===!0}function canonicalReadOutputOptionsUsed(resolvedByDimension,provenance){return PM_READ_OUTPUT_DIMENSIONS.flatMap(dimension=>resolvedByDimension[dimension]?.source==="canonical"||dimension==="include"&&(provenance?.canonical_include_modes.length??0)>0?[CANONICAL_OPTIONS[dimension]]:[])}function resolveReadOutputDimensions(command,options){const normalizedCommand=resolveReadOutputSurface(command,options);if(!normalizedCommand)return;const contract=SURFACE_CONTRACT_BY_COMMAND.get(normalizedCommand)??buildSurfaceContract(normalizedCommand),invocationProvenance=options[READ_OUTPUT_INVOCATION_PROVENANCE],legacyResolvers={include:candidate=>resolveIncludeValue(void 0,candidate),amount:candidate=>resolveAmountValue(void 0,candidate),cost:candidate=>resolveCostValue(void 0,candidate),encoding:candidate=>resolveEncodingValue(void 0,candidate)},legacyByDimension=Object.fromEntries(PM_READ_OUTPUT_DIMENSIONS.map(dimension=>[dimension,resolveLegacyDimension(contract.dimensions[dimension],options,candidate=>legacyResolvers[dimension](candidate)!==void 0,flag=>shouldIgnoreReadOutputLegacyAlias(invocationProvenance,dimension,flag))])),legacyAliasesUsed=PM_READ_OUTPUT_DIMENSIONS.flatMap(dimension=>{const resolved=legacyByDimension[dimension];return resolved?[resolved.flag]:[]}),migrationHints=PM_READ_OUTPUT_DIMENSIONS.flatMap(dimension=>{const resolved=legacyByDimension[dimension];return resolved?[contract.dimensions[dimension].legacy_aliases.find(entry=>entry.flag===resolved.flag).migration_hint]:[]}),encoding=resolveEncodingValue(options.outputFormat??options.output_format,legacyByDimension.encoding),include=resolveIncludeValue(options.outputInclude??options.output_include,legacyByDimension.include),amount=resolveAmountValue(options.outputLimit??options.output_limit,legacyByDimension.amount),explicitCost=resolveCostValue(options.outputBudget??options.output_budget,legacyByDimension.cost),completeResultIntent=hasCompleteReadOutputIntent(command,legacyByDimension,invocationProvenance,options),budget=resolvePmCommandOutputBudget(command,{generateFallback:!0}),resolvedOutputFormat=encoding?.value==="json"||options.resolvedOutputFormat==="json"?"json":"toon",cost=explicitCost??(completeResultIntent?{source:"intent",value:"unbounded"}:{source:"default",value:budget.default_max_estimated_tokens_by_format[resolvedOutputFormat]});return{command:normalizedCommand,include,amount,cost,encoding,canonical_options_used:canonicalReadOutputOptionsUsed({include,amount,cost,encoding},invocationProvenance),legacy_aliases_used:legacyAliasesUsed,migration_hints:migrationHints,precedence:READ_OUTPUT_PRECEDENCE}}function isRecord(value){return value!==null&&typeof value=="object"&&!Array.isArray(value)}const ENVELOPE_KEYS=new Set(["applied_bound","applied_limit","completeness","continuation_kind","continuation_path","continuation_contract","count","filters","has_more","next_cursor","now","omission_receipt","projection","budget_retention_policy","row_contract","sorting","total","truncated"]),GET_STABLE_DERIVED_ITEM_SELECTORS=["collection_counts","notes_count","tests_count"];function projectRecordFields(value,selectors){const selected=new Set(selectors.map(selector=>selector.split(".")[0]));return Object.fromEntries(Object.entries(value).filter(([key])=>selected.has(key)))}function getProjectionVocabulary(result){const item=isRecord(result.item)?result.item:{},itemFields=[...new Set([...Object.keys(item),...GET_STABLE_DERIVED_ITEM_SELECTORS.filter(key=>Object.hasOwn(item,key))])].sort((left,right)=>left.localeCompare(right)),sections=Object.keys(result).filter(key=>key!=="item"&&key!=="read_output"&&!ENVELOPE_KEYS.has(key)).sort((left,right)=>left.localeCompare(right));return{item,itemFields,sections,valid:[...itemFields,"item",...itemFields.map(field=>`item.${field}`),...sections]}}function applyGetIncludeProjection(result,selectors){const vocabulary=getProjectionVocabulary(result),unknown=selectors.filter(selector=>!vocabulary.valid.includes(selector));if(unknown.length>0)throw new PmCliError(`Unknown --output-include selector(s) for get: ${unknown.join(", ")}. Valid selectors: ${vocabulary.valid.join(", ")}.`,EXIT_CODE.USAGE);const fullItem=selectors.includes("item"),itemSelectors=selectors.flatMap(selector=>selector.startsWith("item.")?[selector.slice(5)]:vocabulary.itemFields.includes(selector)?[selector]:[]).filter((selector,index,values)=>values.indexOf(selector)===index);if(fullItem&&itemSelectors.length>0)throw new PmCliError("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",EXIT_CODE.USAGE);const selectedSections=new Set(selectors.filter(selector=>vocabulary.sections.includes(selector))),projected=Object.fromEntries(Object.entries(result).filter(([key])=>ENVELOPE_KEYS.has(key)||selectedSections.has(key)));fullItem?projected.item=vocabulary.item:itemSelectors.length>0&&(projected.item=projectRecordFields(vocabulary.item,itemSelectors));const omittedFieldGroups=[...fullItem?[]:itemSelectors.length>0?vocabulary.itemFields.filter(field=>!itemSelectors.includes(field)).map(field=>({name:`item.${field}`,restore_with:`--output-include item.${field}`})):[{name:"item",restore_with:"--output-include item"}],...vocabulary.sections.filter(section=>!selectedSections.has(section)).map(section=>({name:section,restore_with:`--output-include ${section}`}))],combinedOmittedFieldGroups=[...isRecord(projected.omission_receipt)&&Array.isArray(projected.omission_receipt.omitted_field_groups)?projected.omission_receipt.omitted_field_groups:[],...omittedFieldGroups];return projected.omission_receipt={has_omissions:combinedOmittedFieldGroups.length>0,omitted_field_group_count:combinedOmittedFieldGroups.length,omitted_field_groups:combinedOmittedFieldGroups},projected}function countPopulatedRows(result){let populated=0;return mapReadOutputRows({...result},entry=>(isRecord(entry)&&Object.keys(entry).length>0&&(populated+=1),entry)),populated}function rejectEmptyIncludeProjection(command,original,shaped,selectors){if(countPopulatedRows(original)===0||countPopulatedRows(shaped)>0)return;const modes=[...readOutputIncludeModeOptions(command).keys()],domain=modes.length>0?` Declared ${command} projection modes: ${modes.join(", ")}.`:` The ${command} surface declares no projection modes; name row fields instead.`;throw new PmCliError(`Unknown --output-include selector(s) for ${command}: ${selectors.join(", ")}. No selector matched any returned row field.${domain}`,EXIT_CODE.USAGE)}function applyIncludeProjection(command,result,selectors){if(command==="get")return applyGetIncludeProjection(result,selectors);const rows=readOutputRowPaths(result),qualifiedRowSelectors=selectors.flatMap(selector=>rows.flatMap(rowPath=>selector.startsWith(`${rowPath}.`)?[selector.slice(rowPath.length+1)]:[])),selectedRoot=selectors.some(selector=>Object.hasOwn(result,selector.split(".")[0])&&!rows.some(rowPath=>selector.startsWith(`${rowPath}.`)));if(rows.length>0&&(!selectedRoot||qualifiedRowSelectors.length>0)){const projected={...result},rowSelectors=qualifiedRowSelectors.length>0?qualifiedRowSelectors:selectors,shaped=mapReadOutputRows(projected,entry=>isRecord(entry)?projectRecordFields(entry,rowSelectors):entry);return rejectEmptyIncludeProjection(command,result,shaped,rowSelectors),shaped}return Object.fromEntries(Object.entries(result).filter(([key])=>selectors.some(selector=>selector.split(".")[0]===key)||ENVELOPE_KEYS.has(key)))}function applyAmountBound(result,amount,command,collectionsBeforeBound){if(amount==="unbounded")return result;const{result:bounded,truncated}=boundReadOutputRows(result,amount,path=>readOutputRetainsTail(command,path));if(!truncated)return bounded;if(bounded.has_more=!0,bounded.truncated=!0,attachTailRetentionTotal(bounded,command,[...collectionsBeforeBound.entries()].flatMap(([path,before])=>before.rows>amount?[{path,total_rows:before.totalRows}]:[])),typeof bounded.count=="number"){const activeRowKey=isRecord(bounded.projection)?bounded.projection.row_key:void 0;bounded.count=typeof activeRowKey=="string"&&Array.isArray(bounded[activeRowKey])?bounded[activeRowKey].length:countReadOutputRows(bounded)}return typeof bounded.returned_count=="number"&&(bounded.returned_count=countReadOutputRows(bounded)),bounded.applied_bound={kind:"output_limit",source:"explicit",value:amount},bounded}function requestedDimensions(resolved){return PM_READ_OUTPUT_DIMENSIONS.filter(dimension=>resolved[dimension]!==void 0&&resolved[dimension]?.source!=="default"||resolved.canonical_options_used.includes(CANONICAL_OPTIONS[dimension]))}function attachReadOutputSessionContracts(result,state,receipt,format){let withSession=attachReadOutputSessionReceipt(result,state,format);preserveReadOutputRowContract(result,withSession);for(let iteration=0;iteration<8;iteration+=1){const previousReadEstimate=receipt.estimated_tokens,previousSessionEstimate=withSession.read_session.spent_this_call_tokens;updateReadOutputReceiptEstimate(withSession,receipt,format);const previous=withSession;withSession=attachReadOutputSessionReceipt(withSession,state,format),preserveReadOutputRowContract(previous,withSession);const sessionEstimate=withSession.read_session.spent_this_call_tokens;if(receipt.estimated_tokens===previousReadEstimate&&sessionEstimate===previousSessionEstimate)return withSession}return withSession}function stabilizeReadOutputReceiptEstimates(result,options){if(!isRecord(result.read_output))return result;const format=readOutputMeasurementFormat(options),receipt=result.read_output,session=parseReadOutputSession(options.outputSession??options.output_session);return session===void 0?(updateReadOutputReceiptEstimate(result,receipt,format),result):attachReadOutputSessionContracts(result,session,receipt,format)}function attachValidateDiagnosticRowContract(command,result){if(command!=="validate")return result;const projection=isRecord(result.projection)?result.projection:void 0;if(!(Array.isArray(projection?.declared_field_groups)?projection.declared_field_groups:[]).some(group=>isRecord(group)&&group.name==="diagnostic_rows"))return result;const diagnosticCollectionPaths=[...new Set(readOutputBudgetCollections(result).map(({path})=>path).filter(path=>/^checks\.\d+\.details\./u.test(path)))],diagnosticRowKeys=diagnosticCollectionPaths.filter(path=>!diagnosticCollectionPaths.some(candidate=>candidate!==path&&path.startsWith(`${candidate}.`)));if(diagnosticRowKeys.length===0)return result;const existingContract=isRecord(result.row_contract)?result.row_contract:{},existingRowKeys=Array.isArray(existingContract.row_keys)?existingContract.row_keys.filter(entry=>typeof entry=="string"):[],existingContinuationRowKeys=Array.isArray(existingContract.continuation_row_keys)?existingContract.continuation_row_keys.filter(entry=>typeof entry=="string"):[],rowKeys=existingRowKeys.length>0?existingRowKeys:diagnosticRowKeys,continuationRowKeys=[...new Set(diagnosticRowKeys)];return JSON.stringify(rowKeys)===JSON.stringify(existingRowKeys)&&JSON.stringify(continuationRowKeys)===JSON.stringify(existingContinuationRowKeys)?result:{...result,row_contract:{...existingContract,row_keys:rowKeys,continuation_row_keys:continuationRowKeys,jq_selector:typeof existingContract.jq_selector=="string"?existingContract.jq_selector:".checks[].details"}}}function includeProjectionApplies(resolved,result){return resolved.include?.source==="canonical"&&!isReadResultOmittedForBudget(result)}function prepareReadOutputContinuationSource(result,resolved){let projected={...result};return includeProjectionApplies(resolved,result)&&(projected=applyIncludeProjection(resolved.command,projected,resolved.include.value)),resolved.command==="assurance"?prioritizeAssuranceAssertions(projected):projected}function resolveReadOutputContinuationBindings(resolved,options){const binding=resolveReadOutputPassHooks(options)?.continuationBinding;if(binding===void 0)return;const source=prepareReadOutputContinuationSource(attachValidateDiagnosticRowContract(resolved.command,binding),resolved);return new Map(readOutputContinuationRowCollections(source).filter(collection=>!readOutputRetainsTail(resolved.command,collection.path)).map(collection=>[collection.path,collection]))}function projectReadOutputRows(result,resolved,session,cursor,options){let projected=prepareReadOutputContinuationSource(result,resolved);refreshReadOutputDeliveredCounts(projected,result);const bindings=resolveReadOutputContinuationBindings(resolved,options);if(projected=applyReadOutputContinuation(projected,resolved.command,cursor,bindings),resolved.command==="history"&&cursor){const historyRowKeys=["compact_history","provenance_history","history","diff"];if(projected=Object.fromEntries(Object.entries(projected).filter(([key])=>!historyRowKeys.includes(key)||key===cursor.path)),isRecord(projected.projection)&&(projected.projection={...projected.projection,row_key:cursor.path}),isRecord(projected.row_contract)){const rowContract=projected.row_contract;projected.row_contract={...rowContract,row_keys:[cursor.path],...Array.isArray(rowContract.continuation_row_keys)?{continuation_row_keys:[cursor.path]}:{}}}projected.count=Object.keys(projected[cursor.path]).length}const continuationSource=result.count_only===!0?{...projected,count_only:!0,count:result.count}:projected,continuationState=captureReadOutputContinuationState(projected,result,resolved.command,cursor,options,bindings);return resolved.amount?.source==="canonical"&&(projected=applyAmountBound(projected,resolved.amount.value,resolved.command,continuationState.collectionsBeforeBudget),continuationState.cursorContinuesExistingPage&&rebaseCompactedProducerCursor(projected,continuationState.originalItems,continuationState.cursorSource,!0,continuationState.originalItemOffset)),refreshReadOutputDeliveredCounts(projected,continuationSource),refreshTailRetentionRowCounters(projected,resolved.command,continuationState),{projected:session===void 0?projected:applyReadOutputSessionReferences(projected,session),continuationState}}function resolveBindingReadOutputBudget(resolved,session){return[...resolved.cost!==void 0&&resolved.cost.value!=="unbounded"&&(resolved.cost.source==="canonical"||resolved.cost.source==="default"||resolved.command==="context"&&resolved.cost.source==="legacy")?[{source:resolved.cost.source,tokens:resolved.cost.value}]:[],...session===void 0?[]:[{source:"session",tokens:readOutputSessionRemainingTokens(session)}]].sort((left,right)=>left.tokens-right.tokens)[0]}function canonicalReadOutputReceiptFields(resolved){const canonicalOptions=resolved.canonical_options_used;return canonicalOptions&&canonicalOptions.length>0?{canonical_options_used:canonicalOptions}:{}}function hasContextIntentBudgetReceipt(result,tokens){return isRecord(result.context_intent)&&result.context_intent.command==="context"&&result.context_intent.token_budget===tokens&&result.context_intent.within_budget===!0}function requiresNextSelectionBudgetAudit(resolved,options,result){return resolved.command!=="next"||(options.tokenBudget??options.token_budget)===void 0?!1:!(isRecord(result.context_intent)&&result.context_intent.command==="next"&&result.context_intent.within_budget===!0)}function readOutputBudgetReceiptFields(budget,result={}){return budget?.source==="default"||budget?.source==="legacy"&&!hasContextIntentBudgetReceipt(result,budget.tokens)?{budget_source:budget.source,budget_tokens:budget.tokens}:{}}function omitReadOutputForBudget(resolved,requested,session,bindingBudget,omittedResultEstimatedTokens,format){const minimalReceipt={contract_version:1,command:resolved.command,requested_dimensions:requested,...readOutputBudgetReceiptFields(bindingBudget),precedence:resolved.precedence,...canonicalReadOutputReceiptFields(resolved),legacy_aliases_used:[],migration_hints:[],estimated_tokens:0,within_budget:!1,strings_compacted:!1,rows_compacted:!1,result_omitted:!0,...session===void 0?{omitted_result_estimated_tokens:omittedResultEstimatedTokens}:{}},omitted={output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},read_output:minimalReceipt},boundedOmission=session===void 0?omitted:attachReadOutputSessionContracts(omitted,session,minimalReceipt,format);if(session===void 0&&updateReadOutputReceiptEstimate(boundedOmission,minimalReceipt,format),session!==void 0&&minimalReceipt.estimated_tokens>bindingBudget.tokens)throw new PmCliError("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",EXIT_CODE.USAGE);return boundedOmission}function requiresReadOutputAudit(resolved,options,result){return resolved.command==="context"&&resolved.cost?.source==="legacy"&&!hasContextIntentBudgetReceipt(result,resolved.cost.value)||requiresNextSelectionBudgetAudit(resolved,options,result)||options.outputRowContract===!0||options.output_row_contract===!0||resolved.canonical_options_used.includes("--output-include")||resolved.command==="list"&&resolved.canonical_options_used.length>0&&resolved.include?.value.includes("full")===!0}function canReturnReadOutputUnchanged(resolved,session,result,format,options){if(session!==void 0||isReadResultOmittedForBudget(result)||requiresReadOutputAudit(resolved,options,result))return!1;if(resolved.amount?.source==="canonical"&&resolved.amount.value!=="unbounded"){const limit=resolved.amount.value;if(readOutputRowCollections(result).some(({value})=>(Array.isArray(value)?value.length:Object.keys(value).length)>limit))return!1}return resolved.cost===void 0||resolved.cost.value==="unbounded"||resolved.cost.source==="legacy"&&resolved.command!=="context"||estimateReadOutputTokens(options.outputRowContract===!1?Object.fromEntries(Object.entries(result).filter(([key])=>key!=="row_contract")):result,format)<=resolved.cost.value}function attachTailRetentionTotal(projected,command,continuations){const policy=Object.hasOwn(PM_READ_OUTPUT_TAIL_RETENTION_POLICIES,command)?PM_READ_OUTPUT_TAIL_RETENTION_POLICIES[command]:void 0,withheld=continuations.find(entry=>policy?.paths.includes(entry.path));policy!==void 0&&withheld!==void 0&&typeof projected[policy.total_key]!="number"&&(projected[policy.total_key]=withheld.total_rows)}function refreshTailRetentionRowCounters(delivered,command,continuationState){const path=PM_READ_OUTPUT_TAIL_RETENTION_POLICIES[command]?.paths[0];path!==void 0&&refreshReadOutputDeliveredRowCounters(delivered,command,continuationState.producer,continuationState.collectionsBeforeBudget.get(path)?.rows)}function buildReadOutputContinuation(command,path,before,retainedRows){const offset=before.backward?before.rows-retainedRows:before.baseOffset+retainedRows;return{path,cursor:encodeReadOutputContinuationCursor({command,path,offset,total_rows:before.totalRows,fingerprint:before.fingerprint,...before.backward?{direction:"backward"}:{}}),retained_rows:retainedRows,remaining_rows:before.backward?offset:before.totalRows-offset,total_rows:before.totalRows}}function attachReadOutputTruncationDisclosure(projected,resolved,receipt,bindingBudget,continuationCursorRebased,measuredResultTokens,collectionsBeforeBudget){if(!receipt.rows_compacted)return;const overridden=resolved.amount?.value==="unbounded"?["amount"]:[],afterByPath=new Map(readOutputContinuationRowCollections(projected).map(collection=>[collection.path,Array.isArray(collection.value)?collection.value.length:Object.keys(collection.value).length])),continuations=[...collectionsBeforeBudget.entries()].flatMap(([path,before])=>{const retainedRows=afterByPath.get(path);return retainedRows>=before.rows?[]:[buildReadOutputContinuation(resolved.command,path,before,retainedRows)]}),primary=continuations[0];attachTailRetentionTotal(projected,resolved.command,continuations);const continuationHint=primary?"; page --output-cursor":"",budgetHint=bindingBudget.source==="session"?`Truncated by the remaining ${bindingBudget.tokens}-token session budget; start a new output session with a larger token_budget${continuationHint}.`:`${bindingBudget.tokens}-token: raise --output-budget${continuationHint}`;receipt.migration_hints=[budgetHint,...resolved.migration_hints];const recoveryBudget=resolveReadOutputRecoveryBudget({effective_budget_tokens:bindingBudget.tokens,measured_result_tokens:measuredResultTokens});primary&&!continuationCursorRebased&&(typeof projected.next_cursor!="string"||projected.continuation_kind==="output_cursor")&&(projected.next_cursor=primary.cursor),projected.continuation_kind=continuationCursorRebased?"producer_cursor":primary?"output_cursor":"none",projected.output_budget_truncation={reason:"output_budget_reached",budget_source:bindingBudget.source,budget_tokens:bindingBudget.tokens,overridden_dimensions:overridden,compacted_row_paths:receipt.compacted_row_paths,continuation_cursor_rebased:continuationCursorRebased,continuation_available:continuations.length>0,recovery_budget_multiplier:primary?1:recoveryBudget.recovery_budget_multiplier,continuations,restore_with:primary?"recovery":`Retry with --output-budget ${recoveryBudget.output_budget} because no declared row collection can be continued.`,recovery:primary?{cursor:primary.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:`--output-budget ${recoveryBudget.output_budget}`,sdk:{outputBudget:recoveryBudget.output_budget},mcp:{outputBudget:recoveryBudget.output_budget}}}}function rebaseCompactedProducerCursor(projected,originalItems,cursorSource,cursorContinuesExistingPage,originalItemOffset){if(typeof cursorSource!="string"||!Array.isArray(projected.items))return!1;const retainedCount=projected.items.length,originalItemCount=originalItems.length;if(retainedCount===0||retainedCount>=originalItemCount)return!1;let cursor;try{cursor=decodeQueryCursorEnvelope(cursorSource)}catch{return!1}const sourceIndex=cursor.after_index;if(sourceIndex===void 0)return!1;const last=originalItems[retainedCount-1];if(Object.prototype.toString.call(last)!=="[object Object]")return!1;const lastId=Reflect.get(last,"id");if(typeof lastId!="string"||lastId.length===0)return!1;const afterIndex=cursorContinuesExistingPage?sourceIndex-(originalItemCount-retainedCount):sourceIndex+originalItemOffset+retainedCount;return afterIndex<0?!1:(projected.next_cursor=encodeQueryCursor(cursor.fingerprint,lastId,afterIndex,cursor.snapshot),!0)}function rowCount(value){return Array.isArray(value)?value.length:Object.keys(value).length}function captureReadOutputContinuationState(projected,source,command,cursor,options,bindings){const collectionsBeforeBudget=new Map(readOutputContinuationRowCollections(projected).map(collection=>{const rows=rowCount(collection.value),continued=cursor?.path===collection.path,backward=readOutputRetainsTail(command,collection.path),bound=bindings?.get(collection.path)??collection;let fingerprint;return[collection.path,{rows,totalRows:continued?cursor.total_rows:rowCount(bound.value),baseOffset:continued&&!backward?cursor.offset:0,backward,get fingerprint(){return fingerprint??=continued?cursor.fingerprint:readOutputCollectionFingerprint(collection.path,bound.value,command),fingerprint}}]})),cursorContinuesExistingPage=typeof projected.next_cursor=="string",originalItemOffset=cursor?.path==="items"?cursor.offset:0;return{collectionsBeforeBudget,originalItems:Array.isArray(source.items)?originalItemOffset>0?source.items.slice(originalItemOffset):source.items:[],originalItemOffset,cursorContinuesExistingPage,cursorSource:cursorContinuesExistingPage?projected.next_cursor:options.after,producer:source}}function compactReadOutputProjection(projected,source,countOnly,resolved,receipt,bindingBudget,session,continuationState,measuredResultTokens,format){const deliveredSource={...source,count_only:countOnly},assuranceMinimumRows=resolved.command==="assurance"&&Array.isArray(projected.assertions)?projected.assertions.filter(row=>isRecord(row)&&row.verdict!=="pass").length:0,minimumRowsByPath=new Map;if(assuranceMinimumRows>0&&minimumRowsByPath.set("assertions",assuranceMinimumRows),resolved.command==="history"&&Array.isArray(projected.diff))for(const collection of readOutputBudgetCollections(projected))collection.path.startsWith("diff.")&&minimumRowsByPath.set(collection.path,Object.keys(collection.value).length);return compactReadOutputToBudget(projected,receipt,bindingBudget.tokens,minimumRowsByPath,format,compacted=>{refreshReadOutputDeliveredCounts(compacted,deliveredSource),refreshTailRetentionRowCounters(compacted,resolved.command,continuationState);const continuationCursorRebased=rebaseCompactedProducerCursor(compacted,continuationState.originalItems,continuationState.cursorSource,continuationState.cursorContinuesExistingPage,continuationState.originalItemOffset);if(attachReadOutputTruncationDisclosure(compacted,resolved,receipt,bindingBudget,continuationCursorRebased,measuredResultTokens,continuationState.collectionsBeforeBudget),resolved.command==="history"&&isRecord(compacted.projection)){compacted.has_more=typeof compacted.next_cursor=="string"||compacted.applied_bound?.kind==="output_limit";const rowKey=compacted.projection.row_key;typeof rowKey=="string"&&Array.isArray(compacted[rowKey])&&(compacted.count=compacted[rowKey].length)}session!==void 0&&Object.assign(compacted,attachReadOutputSessionContracts(compacted,session,receipt,format))},resolved.command==="history"&&Array.isArray(projected.diff),path=>readOutputRetainsTail(resolved.command,path),resolved.command)}function applyReadOutputDimensions(command,options,result){const resolved=resolveReadOutputDimensions(command,options);if(!resolved)return result;const format=readOutputMeasurementFormat(options),session=parseReadOutputSession(options.outputSession??options.output_session),rawCursor=options.outputCursor??options.output_cursor,cursor=typeof rawCursor=="string"?decodeReadOutputContinuationCursor(rawCursor):void 0,requested=requestedDimensions(resolved),continuationReadyResult=attachValidateDiagnosticRowContract(resolved.command,result);if(cursor===void 0&&canReturnReadOutputUnchanged(resolved,session,continuationReadyResult,format,options))return continuationReadyResult;const bindingBudget=resolveBindingReadOutputBudget(resolved,session),projection=projectReadOutputRows(continuationReadyResult,resolved,session,cursor,options);let projected=projection.projected;preserveReadOutputRowContract(projected,projected,options.outputRowContract===!1);const intentOmitted=isReadResultOmittedForBudget(projected),receipt={contract_version:1,command:resolved.command,requested_dimensions:requested,...readOutputBudgetReceiptFields(bindingBudget,projected),precedence:resolved.precedence,...canonicalReadOutputReceiptFields(resolved),legacy_aliases_used:resolved.legacy_aliases_used,migration_hints:resolved.migration_hints,estimated_tokens:0,within_budget:!intentOmitted,strings_compacted:!1,rows_compacted:!1,result_omitted:intentOmitted};projected.read_output=receipt;const estimateMirror=resolveReadOutputPassHooks(options)?.mirrorEstimate;if(estimateMirror!==void 0&&mirrorReadOutputReceiptEstimate(receipt,estimateMirror),projected=session===void 0?projected:attachReadOutputSessionContracts(projected,session,receipt,format),updateReadOutputReceiptEstimate(projected,receipt,format),bindingBudget!==void 0&&receipt.estimated_tokens>bindingBudget.tokens){const brief=projectReadOutputItemToBrief(resolved.command,options,projected);brief!==void 0&&(receipt.applied_depth="brief",receipt.degradation_reason="output_budget_reached",preserveReadOutputRowContract(projected,brief),projected=stabilizeReadOutputReceiptEstimates(brief,options)),receipt.estimated_tokens>bindingBudget.tokens&&(projected=compactReadOutputProjection(projected,projected,continuationReadyResult.count_only===!0,resolved,receipt,bindingBudget,session,projection.continuationState,receipt.estimated_tokens,format))}return bindingBudget!==void 0&&receipt.estimated_tokens>bindingBudget.tokens?omitReadOutputForBudget(resolved,requested,session,bindingBudget,receipt.estimated_tokens,format):projected}function isContextIntentResultOmitted(result){return isRecord(result)&&isRecord(result.context_intent)&&result.context_intent.result_omitted===!0}function isReadResultOmittedForBudget(result){return isReadOutputBudgetExceeded(result)||isContextIntentResultOmitted(result)}function isReadOutputBudgetExceeded(result){return isRecord(result)&&isRecord(result.output_budget_exceeded)&&result.output_budget_exceeded.omitted_result===!0&&result.output_budget_exceeded.reason==="requested_budget_infeasible"}function resolveReadOutputEncoding(command,options){const canonical=options.outputFormat??options.output_format;if(canonical==="json"||canonical==="toon")return canonical;const encoding=resolveReadOutputDimensions(command,options)?.encoding;return encoding?.value==="json"||encoding?.value==="toon"?encoding.value:void 0}export{PM_READ_OUTPUT_COMPOSITION_OPTION_FLAGS,PM_READ_OUTPUT_CONTINUATION_FINGERPRINT_POLICIES,PM_READ_OUTPUT_DIMENSIONS,PM_READ_OUTPUT_OPTION_FLAGS,PM_READ_OUTPUT_SURFACES2 as PM_READ_OUTPUT_SURFACES,PM_READ_OUTPUT_SURFACE_CONTRACTS,PM_READ_OUTPUT_TAIL_RETENTION_POLICIES2 as PM_READ_OUTPUT_TAIL_RETENTION_POLICIES,READ_OUTPUT_MUTATION_CONFLICT_CODE,READ_OUTPUT_SHAPING_CONTROL_FLAGS,applyReadOutputDimensions,applyReadOutputIncludeModes,decodeReadOutputContinuationCursor2 as decodeReadOutputContinuationCursor,encodeReadOutputContinuationCursor2 as encodeReadOutputContinuationCursor,isReadOutputBudgetExceeded,isReadResultOmittedForBudget,normalizeReadOutputIncludeModeOptions,readOutputCollectionFingerprint2 as readOutputCollectionFingerprint,readOutputIncludeModeOptions,readOutputRetainsTail2 as readOutputRetainsTail,resolveReadOutputDimensions,resolveReadOutputEncoding,resolveReadOutputRecoveryBudget2 as resolveReadOutputRecoveryBudget,resolveReadOutputSurface,stabilizeReadOutputReceiptEstimates,validateReadOutputOptions};
|
|
1
|
+
import{READ_OUTPUT_DIMENSION_FLAGS as ht,READ_OUTPUT_COMPOSITION_FLAGS as yt,PM_READ_OUTPUT_SURFACES as wt}from"./read-output/options.js";import{resolvePmHistoryOperation as Rt}from"./cli-contracts/command-aliases.js";import{resolveExtensionOutputCommand as bt}from"./read-output/extension.js";import{BEHAVIOR_PRESERVING_MIGRATION_HINTS as L,LEGACY_FLAGS_BY_COMMAND as At,VALUE_BEARING_INCLUDE_ALIASES as Ct,flagSelector as G,optionKey as kt,readOutputIncludeModeOptionsForSurface as $,resolveNativeReadOutputSurface as Et}from"./read-output/surfaces.js";import{EXIT_CODE as w}from"../core/shared/constants.js";import{PmCliError as R}from"../core/shared/errors.js";import{compactReadOutputToBudget as St,estimateReadOutputTokens as Tt,readOutputMeasurementFormat as q,projectReadOutputItemToBrief as xt,preserveReadOutputRowContract as E,mirrorReadOutputReceiptEstimate as It,resolveReadOutputPassHooks as V,resolveReadOutputRecoveryBudget as jt,updateReadOutputReceiptEstimate as S}from"./read-output-budget.js";import{resolveReadOutputRecoveryBudget as Xe}from"./read-output-budget.js";import{resolvePmCommandOutputBudget as vt}from"./cli-contracts/agent-output-contracts.js";import{boundReadOutputRows as Pt,countReadOutputRows as z,mapReadOutputRows as K,readOutputBudgetCollections as H,readOutputContinuationRowCollections as v,readOutputRowPaths as Ut,readOutputRowCollections as Nt,refreshReadOutputDeliveredCounts as P}from"./read-output-rows.js";import{applyReadOutputContinuation as Mt,decodeReadOutputContinuationCursor as Dt,encodeReadOutputContinuationCursor as Bt,prioritizeAssuranceAssertions as Ft,readOutputCollectionFingerprint as Lt,refreshReadOutputDeliveredRowCounters as Gt}from"./read-output/continuation.js";import{PM_READ_OUTPUT_TAIL_RETENTION_POLICIES as T,readOutputRetainsTail as x}from"./read-output/tail-retention.js";import{decodeReadOutputContinuationCursor as tn,encodeReadOutputContinuationCursor as en,PM_READ_OUTPUT_CONTINUATION_FINGERPRINT_POLICIES as nn,readOutputCollectionFingerprint as on}from"./read-output/continuation.js";import{PM_READ_OUTPUT_TAIL_RETENTION_POLICIES as rn,readOutputRetainsTail as sn}from"./read-output/tail-retention.js";import{applyReadOutputSessionReferences as $t,attachReadOutputSessionReceipt as Y,parseReadOutputSession as U,readOutputSessionRemainingTokens as qt}from"./read-output-session.js";import{decodeQueryCursorEnvelope as Vt,encodeQueryCursor as zt}from"./pagination.js";import{READ_OUTPUT_INVOCATION_PROVENANCE as N}from"./read-output/provenance.js";const b=["include","amount","cost","encoding"];import{PM_READ_OUTPUT_SURFACES as cn}from"./read-output/options.js";const W=["canonical","legacy","intent","default"],C=ht,$e=Object.freeze(b.map(t=>C[t])),qe=yt;function Kt(t,e){const n=L[t];if(n!==void 0)return n;const o=e==="include"?Ct.has(t)?"<csv>":G(t):e==="amount"?"<n>":e==="cost"?"<tokens>":"<toon|json>";return`${t} is a compatibility alias; prefer ${C[e]} ${o}.`}function J(t){const e=At[t]??{},n=Object.freeze(Object.fromEntries(b.map(o=>[o,Object.freeze({dimension:o,canonical_option:C[o],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((e[o]??[]).map(u=>Object.freeze({flag:u,semantics:L[u]===void 0?"replacement":"behavior_preserving",migration_hint:Kt(u,o),visibility:"hidden_alias"})))})])));return Object.freeze({command:t,dimensions:n,precedence:W,budget_retention_policy:t==="assurance"?"verdict_priority":Object.hasOwn(T,t)?"ordered_suffix":"ordered_prefix",projection_modes:Object.freeze([...$(t).keys()])})}const Ht=Object.freeze(wt.map(J)),Yt=new Map(Ht.map(t=>[t.command,t]));function I(t,e={}){const n=Rt(t.trim().toLowerCase()),o=bt(n);return o!==void 0?o.read_output===void 0?void 0:`extension:${o.command}`:Et(n,e)}const Wt=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],Q={comments:["add","body","comment","text","stdin","file","edit","delete"],notes:["add","note","text","addJson","stdin","file","edit","delete"],learnings:["add","learning","text","stdin","file","edit","delete"],files:["add","addGlob","remove","migrate","apply","note"],docs:["add","addGlob","remove","migrate","note"],"package-catalog":["activate","adopt","adoptAll","deactivate","doctor","init","install","manage","migrate","reload","scaffold","uninstall"]};function Jt(t){return Wt.some(e=>e!=="outputFormat"&&e!=="output_format"&&t[e]!==void 0)}const Qt=[{keys:["outputInclude","output_include"],valid:t=>k(t)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:t=>t==="unbounded"||A(t)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:t=>t==="unbounded"||A(t)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputSession","output_session"],valid:t=>(U(t),!0),message:"--output-session must be a valid session-state object."},{keys:["outputCursor","output_cursor"],valid:t=>typeof t=="string"&&t.trim().length>0,message:"--output-cursor requires a non-empty continuation cursor."}],Ve="read_output_mutation_conflict",X=[{flag:"--output-include",keys:["outputInclude","output_include"]},{flag:"--output-limit",keys:["outputLimit","output_limit"]},{flag:"--output-budget",keys:["outputBudget","output_budget"]},{flag:"--output-session",keys:["outputSession","output_session"]},{flag:"--output-cursor",keys:["outputCursor","output_cursor"]},{flag:"--output-row-contract",keys:["outputRowContract","output_row_contract"]}],ze=X.map(({flag:t})=>t);function Xt(t,e,n){const o=X.filter(({keys:s})=>s.some(d=>e[d]!==void 0)),u=o.map(({flag:s})=>s),i=o.flatMap(({keys:s})=>s.filter(d=>e[d]!==void 0)),r=u.join(", ");return new R(`Universal output controls (${r}) cannot be combined with a ${t} mutation; nothing was written.`,w.USAGE,{code:"read_output_mutation_conflict",field:u[0],details:{surface:t,output_controls:u,output_option_keys:i,mutation_options:[...n]},required:`Retry the ${t} mutation without ${r}. To bound or page the result, read it with those controls in a separate call after the write.`,why:"Universal output controls shape a read. A mutation returns its own bounded receipt, so the controls have nothing to shape and the write is refused before it runs.",examples:[...Zt[t]]})}const Zt={comments:['pm comments <id> --add "<text>"',"pm comments <id> --output-limit 5"],notes:['pm notes <id> --add "<text>"',"pm notes <id> --output-limit 5"],learnings:['pm learnings <id> --add "<text>"',"pm learnings <id> --output-limit 5"],files:["pm files <id> --add path=<path>","pm files <id> --output-limit 5"],docs:["pm docs <id> --add path=<path>","pm docs <id> --output-limit 5"],"package-catalog":["pm package install <source> --project","pm package catalog --output-limit 5"]};function Ke(t,e){const n=e.outputFormat??e.output_format;if(n!==void 0&&n!=="json"&&n!=="toon")throw new R("--output-format must be toon or json.",w.USAGE);if(!Jt(e))return;const o=I(t,e);if(!o)throw new R(`Universal output controls apply only to read commands; ${t||"this command"} is not a read surface.`,w.USAGE);if(Object.hasOwn(Q,o)){const u=o,i=Q[u].filter(r=>e[r]!==void 0&&e[r]!==!1);if(i.length>0)throw Xt(u,e,i)}for(const u of Qt){const i=u.keys.map(r=>e[r]).find(r=>r!==void 0);if(i!==void 0&&!u.valid(i))throw new R(u.message,w.USAGE)}}function Z(t){const e=I(t);return e?$(e):new Map}function te(t,e,n){const o=k(e)??[],u=Z(t),i=[],r=[],s=n,d=s[N],f=new Set(d?.canonical_include_modes??[]),l=new Set(d?.explicit_legacy_aliases??[]);for(const c of o){const _=u.get(c);if(_===void 0){i.push(c);continue}const O=`--${c.replaceAll("_","-")}`;D(M(n,O))&&l.add(O),n[_]=!0,r.push(c),f.add(c)}const a=I(t)==="get"?i.filter(c=>c!=="item"):[],p=a.length>0;return p&&(n.fields=[...new Set([...k(n.fields)??[],...a])].join(","),f.add("fields")),(r.length>0||p)&&(s[N]={canonical_include_modes:[...f],explicit_legacy_aliases:[...l],...d?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:r}}function He(t,e){const n=e.outputInclude??e.output_include;if(n===void 0)return;const{selectors:o,modes:u}=te(t,n,e);if(u.length===0)return;const i=o.length>0?o.join(","):void 0;e.outputInclude=i,Object.hasOwn(e,"output_include")&&(e.output_include=i)}function M(t,e){const n=kt(e);if(Object.hasOwn(t,n))return t[n];const o=e.slice(2).replaceAll("-","_");if(Object.hasOwn(t,o))return t[o];if(e==="--no-truncate"&&t.truncate===!1)return!0}function D(t){return t!==void 0&&t!==!1&&t!==null}function k(t){const n=(Array.isArray(t)?t:[t]).flatMap(o=>typeof o=="string"?o.split(","):[]).map(o=>o.trim()).filter(Boolean);return n.length>0?[...new Set(n)]:void 0}function A(t){const e=typeof t=="number"?t:typeof t=="string"&&/^\d+$/u.test(t.trim())?Number(t):Number.NaN;return Number.isSafeInteger(e)&&e>0?e:void 0}function ee(t,e,n,o){for(const u of t.legacy_aliases){if(o(u.flag))continue;const i=M(e,u.flag),r={value:i,flag:u.flag};if(D(i)&&n(r))return r}}function tt(t,e){const n=k(t);if(n)return{source:"canonical",value:n};if(e)return{source:"legacy",value:k(e.value)??[G(e.flag)]}}function et(t,e){if(t==="unbounded")return{source:"canonical",value:"unbounded"};const n=A(t);if(n!==void 0)return{source:"canonical",value:n};if(!e)return;if(e.flag==="--no-truncate"||e.flag==="--unbounded")return{source:"legacy",value:"unbounded"};const o=A(e.value);return o===void 0?void 0:{source:"legacy",value:o}}function nt(t,e){if(t==="unbounded")return{source:"canonical",value:"unbounded"};const n=A(t);if(n!==void 0)return{source:"canonical",value:n};if(!e)return;const o=A(e.value);return o===void 0?void 0:{source:"legacy",value:o}}function ot(t,e){if(t==="json"||t==="toon")return{source:"canonical",value:t};if(e)return e.flag==="--stream"||e.flag==="--follow"?{source:"legacy",value:"stream"}:e.value==="json"||e.value==="toon"?{source:"legacy",value:e.value}:void 0}function ut(t,e,n){if(!t)return!1;const o=new Set(t.explicit_legacy_aliases);if(t.cli_invocation_observed===!0||t.sdk_invocation_observed===!0)return!o.has(n);const u=new Set(t.canonical_include_modes.map(i=>`--${i.replaceAll("_","-")}`));return e==="include"&&u.has(n)&&!o.has(n)}function ne(t,e,n,o){return t.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||D(M(o,"--no-truncate"))&&!ut(n,"amount","--no-truncate")||e.amount?.flag==="--no-truncate"||e.include?.flag==="--full"||n?.canonical_include_modes.includes("full")===!0}function oe(t,e){return b.flatMap(n=>t[n]?.source==="canonical"||n==="include"&&(e?.canonical_include_modes.length??0)>0?[C[n]]:[])}function it(t,e){const n=I(t,e);if(!n)return;const o=Yt.get(n)??J(n),u=e[N],i={include:g=>tt(void 0,g),amount:g=>et(void 0,g),cost:g=>nt(void 0,g),encoding:g=>ot(void 0,g)},r=Object.fromEntries(b.map(g=>[g,ee(o.dimensions[g],e,y=>i[g](y)!==void 0,y=>ut(u,g,y))])),s=b.flatMap(g=>{const y=r[g];return y?[y.flag]:[]}),d=b.flatMap(g=>{const y=r[g];return y?[o.dimensions[g].legacy_aliases.find(Ot=>Ot.flag===y.flag).migration_hint]:[]}),f=ot(e.outputFormat??e.output_format,r.encoding),l=tt(e.outputInclude??e.output_include,r.include),a=et(e.outputLimit??e.output_limit,r.amount),p=nt(e.outputBudget??e.output_budget,r.cost),c=ne(t,r,u,e),_=vt(t,{generateFallback:!0}),O=f?.value==="json"||e.resolvedOutputFormat==="json"?"json":"toon",h=p??(c?{source:"intent",value:"unbounded"}:{source:"default",value:_.default_max_estimated_tokens_by_format[O]});return{command:n,include:l,amount:a,cost:h,encoding:f,canonical_options_used:oe({include:l,amount:a,cost:h,encoding:f},u),legacy_aliases_used:s,migration_hints:d,precedence:W}}function m(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}const B=new Set(["applied_bound","applied_limit","completeness","continuation_kind","continuation_path","continuation_contract","count","filters","has_more","next_cursor","now","omission_receipt","projection","budget_retention_policy","row_contract","sorting","total","truncated"]),ue=["collection_counts","notes_count","tests_count"];function rt(t,e){const n=new Set(e.map(o=>o.split(".")[0]));return Object.fromEntries(Object.entries(t).filter(([o])=>n.has(o)))}function ie(t){const e=m(t.item)?t.item:{},n=[...new Set([...Object.keys(e),...ue.filter(u=>Object.hasOwn(e,u))])].sort((u,i)=>u.localeCompare(i)),o=Object.keys(t).filter(u=>u!=="item"&&u!=="read_output"&&!B.has(u)).sort((u,i)=>u.localeCompare(i));return{item:e,itemFields:n,sections:o,valid:[...n,"item",...n.map(u=>`item.${u}`),...o]}}function re(t,e){const n=ie(t),o=e.filter(a=>!n.valid.includes(a));if(o.length>0)throw new R(`Unknown --output-include selector(s) for get: ${o.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,w.USAGE);const u=e.includes("item"),i=e.flatMap(a=>a.startsWith("item.")?[a.slice(5)]:n.itemFields.includes(a)?[a]:[]).filter((a,p,c)=>c.indexOf(a)===p);if(u&&i.length>0)throw new R("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",w.USAGE);const r=new Set(e.filter(a=>n.sections.includes(a))),s=Object.fromEntries(Object.entries(t).filter(([a])=>B.has(a)||r.has(a)));u?s.item=n.item:i.length>0&&(s.item=rt(n.item,i));const d=[...u?[]:i.length>0?n.itemFields.filter(a=>!i.includes(a)).map(a=>({name:`item.${a}`,restore_with:`--output-include item.${a}`})):[{name:"item",restore_with:"--output-include item"}],...n.sections.filter(a=>!r.has(a)).map(a=>({name:a,restore_with:`--output-include ${a}`}))],l=[...m(s.omission_receipt)&&Array.isArray(s.omission_receipt.omitted_field_groups)?s.omission_receipt.omitted_field_groups:[],...d];return s.omission_receipt={has_omissions:l.length>0,omitted_field_group_count:l.length,omitted_field_groups:l},s}function st(t){let e=0;return K({...t},n=>(m(n)&&Object.keys(n).length>0&&(e+=1),n)),e}function se(t,e,n,o){if(st(e)===0||st(n)>0)return;const u=[...Z(t).keys()],i=u.length>0?` Declared ${t} projection modes: ${u.join(", ")}.`:` The ${t} surface declares no projection modes; name row fields instead.`;throw new R(`Unknown --output-include selector(s) for ${t}: ${o.join(", ")}. No selector matched any returned row field.${i}`,w.USAGE)}function ae(t,e,n){if(t==="get")return re(e,n);const o=Ut(e),u=n.flatMap(r=>o.flatMap(s=>r.startsWith(`${s}.`)?[r.slice(s.length+1)]:[])),i=n.some(r=>Object.hasOwn(e,r.split(".")[0])&&!o.some(s=>r.startsWith(`${s}.`)));if(o.length>0&&(!i||u.length>0)){const r={...e},s=u.length>0?u:n,d=K(r,f=>m(f)?rt(f,s):f);return se(t,e,d,s),d}return Object.fromEntries(Object.entries(e).filter(([r])=>n.some(s=>s.split(".")[0]===r)||B.has(r)))}function ce(t,e,n,o){if(e==="unbounded")return t;const{result:u,truncated:i}=Pt(t,e,r=>x(n,r));if(!i)return u;if(u.has_more=!0,u.truncated=!0,pt(u,n,[...o.entries()].flatMap(([r,s])=>s.rows>e?[{path:r,total_rows:s.totalRows}]:[])),typeof u.count=="number"){const r=m(u.projection)?u.projection.row_key:void 0;u.count=typeof r=="string"&&Array.isArray(u[r])?u[r].length:z(u)}return typeof u.returned_count=="number"&&(u.returned_count=z(u)),u.applied_bound={kind:"output_limit",source:"explicit",value:e},u}function de(t){return b.filter(e=>t[e]!==void 0&&t[e]?.source!=="default"||t.canonical_options_used.includes(C[e]))}function j(t,e,n,o){let u=Y(t,e,o);E(t,u);for(let i=0;i<8;i+=1){const r=n.estimated_tokens,s=u.read_session.spent_this_call_tokens;S(u,n,o);const d=u;u=Y(u,e,o),E(d,u);const f=u.read_session.spent_this_call_tokens;if(n.estimated_tokens===r&&f===s)return u}return u}function le(t,e){if(!m(t.read_output))return t;const n=q(e),o=t.read_output,u=U(e.outputSession??e.output_session);return u===void 0?(S(t,o,n),t):j(t,u,o,n)}function at(t,e){if(t!=="validate")return e;const n=m(e.projection)?e.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(a=>m(a)&&a.name==="diagnostic_rows"))return e;const u=[...new Set(H(e).map(({path:a})=>a).filter(a=>/^checks\.\d+\.details\./u.test(a)))],i=u.filter(a=>!u.some(p=>p!==a&&a.startsWith(`${p}.`)));if(i.length===0)return e;const r=m(e.row_contract)?e.row_contract:{},s=Array.isArray(r.row_keys)?r.row_keys.filter(a=>typeof a=="string"):[],d=Array.isArray(r.continuation_row_keys)?r.continuation_row_keys.filter(a=>typeof a=="string"):[],f=s.length>0?s:i,l=[...new Set(i)];return JSON.stringify(f)===JSON.stringify(s)&&JSON.stringify(l)===JSON.stringify(d)?e:{...e,row_contract:{...r,row_keys:f,continuation_row_keys:l,jq_selector:typeof r.jq_selector=="string"?r.jq_selector:".checks[].details"}}}function fe(t,e){return t.include?.source==="canonical"&&!F(e)}function ct(t,e){let n={...t};return fe(e,t)&&(n=ae(e.command,n,e.include.value)),e.command==="assurance"?Ft(n):n}function pe(t,e){const n=V(e)?.continuationBinding;if(n===void 0)return;const o=ct(at(t.command,n),t);return new Map(v(o).filter(u=>!x(t.command,u.path)).map(u=>[u.path,u]))}function _e(t,e,n,o,u){let i=ct(t,e);P(i,t);const r=pe(e,u);if(i=Mt(i,e.command,o,r),e.command==="history"&&o){const f=["compact_history","provenance_history","history","diff"];if(i=Object.fromEntries(Object.entries(i).filter(([l])=>!f.includes(l)||l===o.path)),m(i.projection)&&(i.projection={...i.projection,row_key:o.path}),m(i.row_contract)){const l=i.row_contract;i.row_contract={...l,row_keys:[o.path],...Array.isArray(l.continuation_row_keys)?{continuation_row_keys:[o.path]}:{}}}i.count=Object.keys(i[o.path]).length}const s=t.count_only===!0?{...i,count_only:!0,count:t.count}:i,d=be(i,t,e.command,o,u,r);return e.amount?.source==="canonical"&&(i=ce(i,e.amount.value,e.command,d.collectionsBeforeBudget),d.cursorContinuesExistingPage&&mt(i,d.originalItems,d.cursorSource,!0,d.originalItemOffset)),P(i,s),_t(i,e.command,d),{projected:n===void 0?i:$t(i,n),continuationState:d}}function me(t,e){return[...t.cost!==void 0&&t.cost.value!=="unbounded"&&(t.cost.source==="canonical"||t.cost.source==="default"||t.command==="context"&&t.cost.source==="legacy")?[{source:t.cost.source,tokens:t.cost.value}]:[],...e===void 0?[]:[{source:"session",tokens:qt(e)}]].sort((o,u)=>o.tokens-u.tokens)[0]}function dt(t){const e=t.canonical_options_used;return e&&e.length>0?{canonical_options_used:e}:{}}function lt(t,e){return m(t.context_intent)&&t.context_intent.command==="context"&&t.context_intent.token_budget===e&&t.context_intent.within_budget===!0}function ge(t,e,n){return t.command!=="next"||(e.tokenBudget??e.token_budget)===void 0?!1:!(m(n.context_intent)&&n.context_intent.command==="next"&&n.context_intent.within_budget===!0)}function ft(t,e={}){return t?.source==="default"||t?.source==="legacy"&&!lt(e,t.tokens)?{budget_source:t.source,budget_tokens:t.tokens}:{}}function Oe(t,e,n,o,u,i){const r={contract_version:1,command:t.command,requested_dimensions:e,...ft(o),precedence:t.precedence,...dt(t),legacy_aliases_used:[],migration_hints:[],estimated_tokens:0,within_budget:!1,strings_compacted:!1,rows_compacted:!1,result_omitted:!0,...n===void 0?{omitted_result_estimated_tokens:u}:{}},s={output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},read_output:r},d=n===void 0?s:j(s,n,r,i);if(n===void 0&&S(d,r,i),n!==void 0&&r.estimated_tokens>o.tokens)throw new R("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",w.USAGE);return d}function he(t,e,n){return t.command==="context"&&t.cost?.source==="legacy"&&!lt(n,t.cost.value)||ge(t,e,n)||e.outputRowContract===!0||e.output_row_contract===!0||t.canonical_options_used.includes("--output-include")||t.command==="list"&&t.canonical_options_used.length>0&&t.include?.value.includes("full")===!0}function ye(t,e,n,o,u){if(e!==void 0||F(n)||he(t,u,n))return!1;if(t.amount?.source==="canonical"&&t.amount.value!=="unbounded"){const i=t.amount.value;if(Nt(n).some(({value:r})=>(Array.isArray(r)?r.length:Object.keys(r).length)>i))return!1}return t.cost===void 0||t.cost.value==="unbounded"||t.cost.source==="legacy"&&t.command!=="context"||Tt(u.outputRowContract===!1?Object.fromEntries(Object.entries(n).filter(([i])=>i!=="row_contract")):n,o)<=t.cost.value}function pt(t,e,n){const o=Object.hasOwn(T,e)?T[e]:void 0,u=n.find(i=>o?.paths.includes(i.path));o!==void 0&&u!==void 0&&typeof t[o.total_key]!="number"&&(t[o.total_key]=u.total_rows)}function _t(t,e,n){const o=T[e]?.paths[0];o!==void 0&&Gt(t,e,n.producer,n.collectionsBeforeBudget.get(o)?.rows)}function we(t,e,n,o){const u=n.backward?n.rows-o:n.baseOffset+o;return{path:e,cursor:Bt({command:t,path:e,offset:u,total_rows:n.totalRows,fingerprint:n.fingerprint,...n.backward?{direction:"backward"}:{}}),retained_rows:o,remaining_rows:n.backward?u:n.totalRows-u,total_rows:n.totalRows}}function Re(t,e,n,o,u,i,r){if(!n.rows_compacted)return;const s=e.amount?.value==="unbounded"?["amount"]:[],d=new Map(v(t).map(_=>[_.path,Array.isArray(_.value)?_.value.length:Object.keys(_.value).length])),f=[...r.entries()].flatMap(([_,O])=>{const h=d.get(_);return h>=O.rows?[]:[we(e.command,_,O,h)]}),l=f[0];pt(t,e.command,f);const a=l?"; page --output-cursor":"",p=o.source==="session"?`Truncated by the remaining ${o.tokens}-token session budget; start a new output session with a larger token_budget${a}.`:`${o.tokens}-token: raise --output-budget${a}`;n.migration_hints=[p,...e.migration_hints];const c=jt({effective_budget_tokens:o.tokens,measured_result_tokens:i});l&&!u&&(typeof t.next_cursor!="string"||t.continuation_kind==="output_cursor")&&(t.next_cursor=l.cursor),t.continuation_kind=u?"producer_cursor":l?"output_cursor":"none",t.output_budget_truncation={reason:"output_budget_reached",budget_source:o.source,budget_tokens:o.tokens,overridden_dimensions:s,compacted_row_paths:n.compacted_row_paths,continuation_cursor_rebased:u,continuation_available:f.length>0,recovery_budget_multiplier:l?1:c.recovery_budget_multiplier,continuations:f,restore_with:l?"recovery":`Retry with --output-budget ${c.output_budget} because no declared row collection can be continued.`,recovery:l?{cursor:l.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:`--output-budget ${c.output_budget}`,sdk:{outputBudget:c.output_budget},mcp:{outputBudget:c.output_budget}}}}function mt(t,e,n,o,u){if(typeof n!="string"||!Array.isArray(t.items))return!1;const i=t.items.length,r=e.length;if(i===0||i>=r)return!1;let s;try{s=Vt(n)}catch{return!1}const d=s.after_index;if(d===void 0)return!1;const f=e[i-1];if(Object.prototype.toString.call(f)!=="[object Object]")return!1;const l=Reflect.get(f,"id");if(typeof l!="string"||l.length===0)return!1;const a=o?d-(r-i):d+u+i;return a<0?!1:(t.next_cursor=zt(s.fingerprint,l,a,s.snapshot),!0)}function gt(t){return Array.isArray(t)?t.length:Object.keys(t).length}function be(t,e,n,o,u,i){const r=new Map(v(t).map(f=>{const l=gt(f.value),a=o?.path===f.path,p=x(n,f.path),c=i?.get(f.path)??f;let _;return[f.path,{rows:l,totalRows:a?o.total_rows:gt(c.value),baseOffset:a&&!p?o.offset:0,backward:p,get fingerprint(){return _??=a?o.fingerprint:Lt(f.path,c.value,n),_}}]})),s=typeof t.next_cursor=="string",d=o?.path==="items"?o.offset:0;return{collectionsBeforeBudget:r,originalItems:Array.isArray(e.items)?d>0?e.items.slice(d):e.items:[],originalItemOffset:d,cursorContinuesExistingPage:s,cursorSource:s?t.next_cursor:u.after,producer:e}}function Ae(t,e,n,o,u,i,r,s,d,f){const l={...e,count_only:n},a=o.command==="assurance"&&Array.isArray(t.assertions)?t.assertions.filter(c=>m(c)&&c.verdict!=="pass").length:0,p=new Map;if(a>0&&p.set("assertions",a),o.command==="history"&&Array.isArray(t.diff))for(const c of H(t))c.path.startsWith("diff.")&&p.set(c.path,Object.keys(c.value).length);return St(t,u,i.tokens,p,f,c=>{P(c,l),_t(c,o.command,s);const _=mt(c,s.originalItems,s.cursorSource,s.cursorContinuesExistingPage,s.originalItemOffset);if(Re(c,o,u,i,_,d,s.collectionsBeforeBudget),o.command==="history"&&m(c.projection)){c.has_more=typeof c.next_cursor=="string"||c.applied_bound?.kind==="output_limit";const O=c.projection.row_key;typeof O=="string"&&Array.isArray(c[O])&&(c.count=c[O].length)}r!==void 0&&Object.assign(c,j(c,r,u,f))},o.command==="history"&&Array.isArray(t.diff),c=>x(o.command,c),o.command)}function Ye(t,e,n){const o=it(t,e);if(!o)return n;const u=q(e),i=U(e.outputSession??e.output_session),r=e.outputCursor??e.output_cursor,s=typeof r=="string"?Dt(r):void 0,d=de(o),f=at(o.command,n);if(s===void 0&&ye(o,i,f,u,e))return f;const l=me(o,i),a=_e(f,o,i,s,e);let p=a.projected;E(p,p,e.outputRowContract===!1);const c=F(p),_={contract_version:1,command:o.command,requested_dimensions:d,...ft(l,p),precedence:o.precedence,...dt(o),legacy_aliases_used:o.legacy_aliases_used,migration_hints:o.migration_hints,estimated_tokens:0,within_budget:!c,strings_compacted:!1,rows_compacted:!1,result_omitted:c};p.read_output=_;const O=V(e)?.mirrorEstimate;if(O!==void 0&&It(_,O),p=i===void 0?p:j(p,i,_,u),S(p,_,u),l!==void 0&&_.estimated_tokens>l.tokens){const h=xt(o.command,e,p);h!==void 0&&(_.applied_depth="brief",_.degradation_reason="output_budget_reached",E(p,h),p=le(h,e)),_.estimated_tokens>l.tokens&&(p=Ae(p,p,f.count_only===!0,o,_,l,i,a.continuationState,_.estimated_tokens,u))}return l!==void 0&&_.estimated_tokens>l.tokens?Oe(o,d,i,l,_.estimated_tokens,u):p}function Ce(t){return m(t)&&m(t.context_intent)&&t.context_intent.result_omitted===!0}function F(t){return ke(t)||Ce(t)}function ke(t){return m(t)&&m(t.output_budget_exceeded)&&t.output_budget_exceeded.omitted_result===!0&&t.output_budget_exceeded.reason==="requested_budget_infeasible"}function We(t,e){const n=e.outputFormat??e.output_format;if(n==="json"||n==="toon")return n;const o=it(t,e)?.encoding;return o?.value==="json"||o?.value==="toon"?o.value:void 0}export{qe as PM_READ_OUTPUT_COMPOSITION_OPTION_FLAGS,nn as PM_READ_OUTPUT_CONTINUATION_FINGERPRINT_POLICIES,b as PM_READ_OUTPUT_DIMENSIONS,$e as PM_READ_OUTPUT_OPTION_FLAGS,cn as PM_READ_OUTPUT_SURFACES,Ht as PM_READ_OUTPUT_SURFACE_CONTRACTS,rn as PM_READ_OUTPUT_TAIL_RETENTION_POLICIES,Ve as READ_OUTPUT_MUTATION_CONFLICT_CODE,ze as READ_OUTPUT_SHAPING_CONTROL_FLAGS,Ye as applyReadOutputDimensions,te as applyReadOutputIncludeModes,tn as decodeReadOutputContinuationCursor,en as encodeReadOutputContinuationCursor,ke as isReadOutputBudgetExceeded,F as isReadResultOmittedForBudget,He as normalizeReadOutputIncludeModeOptions,on as readOutputCollectionFingerprint,Z as readOutputIncludeModeOptions,sn as readOutputRetainsTail,it as resolveReadOutputDimensions,We as resolveReadOutputEncoding,Xe as resolveReadOutputRecoveryBudget,I as resolveReadOutputSurface,le as stabilizeReadOutputReceiptEstimates,Ke as validateReadOutputOptions};
|
|
2
2
|
//# sourceMappingURL=read-output-contracts.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const b=new Set(["applied_bound","completeness","budget_retention_policy","continuation_contract","continuation_kind","continuation_path","filters","omission_receipt","output_budget_truncation","projection","read_output","read_session","row_contract","sorting"]);function u(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function A(t,r){let e=t;for(const n of r.split("."))if(Array.isArray(e)){if(!/^\d+$/u.test(n))return;e=e[Number(n)]}else{if(!u(e))return;e=e[n]}return e}function y(t,r,e){const n=r.split("."),i=(s,o)=>{if(o===n.length)return e;const c=n[o];if(Array.isArray(s)){const l=Number(c),f=[...s];return f[l]=i(s[l],o+1),f}const a=s;return{...a,[c]:i(a[c],o+1)}};return i(t,0)}function C(t,r,e,n){const i=w(t).find(c=>c.path===r);if(!i)return t;const s=Array.isArray(i.value)?i.value.slice(e,n):Object.fromEntries(Object.entries(i.value).slice(e,n)),o=y(t,r,s);return u(o.summary)&&u(o.summary.focus_row_states)&&typeof o.summary.focus_row_states[r]=="string"&&(o.summary={...o.summary,focus_row_states:{...o.summary.focus_row_states,[r]:o.summary.focus_row_states[r].slice(e,n)}}),S(o),o}function g(t){const r=t.row_contract;return u(r)&&Array.isArray(r.row_keys)?r.row_keys.filter(e=>typeof e=="string"&&e.trim().length>0):Object.entries(t).filter(([,e])=>Array.isArray(e)).map(([e])=>e)}function O(t){const r=t.row_contract;return u(r)&&Array.isArray(r.continuation_row_keys)?r.continuation_row_keys.filter(e=>typeof e=="string"&&e.trim().length>0):g(t)}function p(t){return g(t).flatMap(r=>{const e=A(t,r);return Array.isArray(e)||u(e)?[{path:r,value:e}]:[]})}function w(t){return O(t).flatMap(r=>{const e=A(t,r);return Array.isArray(e)||u(e)?[{path:r,value:e}]:[]})}function x(t){const r=p(t),e=new Set(r.map(i=>i.path)),n=(i,s)=>{if(Array.isArray(i)){e.has(s)||r.push({path:s,value:i}),i.forEach((o,c)=>n(o,`${s}.${c}`));return}if(u(i))for(const[o,c]of Object.entries(i))s.length===0&&b.has(o)||n(c,s.length===0?o:`${s}.${o}`)};return n(t,""),r}function E(t){return p(t).reduce((r,e)=>r+(Array.isArray(e.value)?e.value.length:Object.keys(e.value).length),0)}function M(t,r){let e=t;for(const n of p(e)){const i=Array.isArray(n.value)?n.value.map((s,o)=>r(s,n.path,o)):Object.fromEntries(Object.entries(n.value).map(([s,o],c)=>[s,r(o,n.path,c)]));e=y(e,n.path,i)}return e}function $(t,r,e=()=>!1){let n=t,i=!1;for(const s of p(n)){const o=Array.isArray(s.value)?s.value:Object.entries(s.value);if(o.length<=r)continue;i=!0;const c=e(s.path)?o.length-r:0,a=o.slice(c,c+r),l=Array.isArray(s.value)?a:Object.fromEntries(a);n=y(n,s.path,l)}return{result:n,truncated:i}}const h=["high_level","low_level","blocked_fallback"];function d(t){const r=t.status==="in_progress"?"i":"o";return t.blocked===!0?r.toUpperCase():r}function k(t,r){if(!u(t.summary)||!u(t.summary.returned_focus))return;const e=new Map(r.map(n=>[n.id,n]));t.summary={...t.summary,focus_row_states:Object.fromEntries(h.map(n=>[n,Array.isArray(t[n])?t[n].filter(u).map(i=>d(e.get(i.id)??i)).join(""):""]))}}function v(t,r){if(t!==void 0){if(typeof t!="string"||t.length!==r||!/^[iIoO]*$/u.test(t))throw new TypeError("Context focus classification receipt must contain one i/I/o/O code per delivered record");return t}}function j(t,r,e,n){const i=Array.isArray(r[e])?r[e].filter(u):[],s=v(n[e],i.length)??i.map(d).join(""),o=new Map(i.flatMap((f,m)=>f.id===void 0?[]:[[f.id,s[m]]])),c=Array.isArray(t[e])?t[e].filter(u):[];let a=!1;return{states:c.map((f,m)=>{const _=o.get(f.id)??(f.id===void 0?s[m]:void 0)??d(f);return _!==d(f)&&(a=!0),_}).join(""),needsStates:a}}function R(t,r){typeof t.count=="number"&&(t.count_only===!0||r.count_only===!0?typeof r.count=="number"&&(t.count=r.count):Array.isArray(t.items)&&(t.count=t.items.length))}function S(t,r=t){if(R(t,r),!u(t.summary)||!u(t.summary.returned_focus))return;const e={...t.summary},n=u(r.summary)&&u(r.summary.focus_row_states)?r.summary.focus_row_states:{},i=h.map(a=>({key:a,...j(t,r,a,n)})),s=Object.fromEntries(i.map(({key:a,states:l})=>[a,l])),o=i.some(a=>a.needsStates),c=Object.values(s).join("");typeof e.high_level=="number"&&(e.high_level=Array.isArray(t.high_level)?t.high_level.length:0),typeof e.low_level=="number"&&(e.low_level=Array.isArray(t.low_level)?t.low_level.length:0),e.returned_focus={active_items:c.length,in_progress:[...c].filter(a=>a.toLowerCase()==="i").length,open:[...c].filter(a=>a.toLowerCase()==="o").length,blocked:[...c].filter(a=>a===a.toUpperCase()).length},o?e.focus_row_states=s:delete e.focus_row_states,t.summary=e}export{$ as boundReadOutputRows,E as countReadOutputRows,M as mapReadOutputRows,x as readOutputBudgetCollections,w as readOutputContinuationRowCollections,O as readOutputContinuationRowPaths,p as readOutputRowCollections,g as readOutputRowPaths,S as refreshReadOutputDeliveredCounts,k as rememberReadOutputFocusRows,C as sliceReadOutputRowCollection};
|
|
2
2
|
//# sourceMappingURL=read-output-rows.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{estimateReadOutputTokens as O}from"./read-output-budget.js";import{EXIT_CODE as R}from"../core/shared/constants.js";import{PmCliError as E}from"../core/shared/errors.js";import{mapReadOutputRows as x,readOutputRowCollections as A}from"./read-output-rows.js";function j(e){return typeof e=="object"&&e!==null&&"id"in e&&typeof e.id=="string"&&"context_ref"in e&&typeof e.context_ref=="string"&&e.context_ref.startsWith("session:")&&e.context_ref.endsWith(`:${e.id}`)}const S=256,b=1e4,N=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,y=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,w=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),T=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&N.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=S,reason:`token_budget must be a safe integer of at least ${S}.`},{valid:e=>Number.isSafeInteger(e.spent_tokens)&&e.spent_tokens>=0&&e.spent_tokens<=e.token_budget,reason:"spent_tokens must be a non-negative safe integer no larger than token_budget."},{valid:e=>Array.isArray(e.seen_item_ids)&&e.seen_item_ids.length<=b&&e.seen_item_ids.every(t=>typeof t=="string"&&y.test(t)),reason:`seen_item_ids must contain at most ${b} portable item identifiers.`}];function p(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function f(e){throw new E(`--output-session ${e}`,R.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function C(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{f("must be a valid JSON object.")}p(t)||f("must be a JSON object.");const r=Object.keys(t).filter(_=>!w.has(_));r.length>0&&f(`contains unknown field "${r.sort()[0]}".`);const n=T.find(_=>!_.valid(t));n!==void 0&&f(n.reason);const o=[...new Set(t.seen_item_ids)].sort();return{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:o}}function I(e){if(p(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:p(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function v(e){const t=new Set;let r=0;const n=A(e),o=new Set(n.map(({path:s})=>s)),_=Object.entries(e).flatMap(([s,d])=>Array.isArray(d)&&!o.has(s)?[{path:s,value:d}]:[]);for(const s of[...n,..._]){const d=Array.isArray(s.value)?s.value:Object.values(s.value);for(const a of d){if(!p(a))continue;if(typeof a.context_ref=="string"){r+=1;continue}const u=I(a);u!==void 0&&y.test(u)&&t.add(u)}}return{deliveredIds:t,suppressedRepeatCount:r}}function z(e,t){const r=new Set(t.seen_item_ids);return x(e,n=>{const o=I(n);return o!==void 0&&r.has(o)?{id:o,context_ref:`session:${t.id}:${o}`}:n})}function U(e,t,r){const{deliveredIds:n,suppressedRepeatCount:o}=v(e),_=new Set(t.seen_item_ids),s=[...n].filter(c=>!_.has(c)).sort(),d=s.slice(0,b-t.seen_item_ids.length),a=[...t.seen_item_ids,...d].sort(),u=s.length-d.length,i={contract_version:1,id:t.id,measurement_scope:"complete_read_envelope",estimator:"ceil(utf8_bytes / 4)",token_budget:t.token_budget,spent_before_tokens:t.spent_tokens,spent_this_call_tokens:0,charged_this_call_tokens:0,spent_total_tokens:t.spent_tokens,remaining_tokens:t.token_budget-t.spent_tokens,exhausted:!1,seen_before_count:t.seen_item_ids.length,new_item_count:n.size,...u===0?{}:{seen_item_overflow_count:u},suppressed_repeat_count:o,reference_format:"session:<session-id>:<item-id>",restore_reference_with:"pm get <item-id> --depth brief",next_state:{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:a}},m={...e,read_session:i},h=c=>{i.spent_this_call_tokens=c,i.charged_this_call_tokens=Math.min(t.token_budget-t.spent_tokens,c),i.spent_total_tokens=Math.min(t.token_budget,t.spent_tokens+i.charged_this_call_tokens),i.remaining_tokens=Math.max(0,t.token_budget-i.spent_total_tokens),i.exhausted=i.remaining_tokens<S,i.next_state.spent_tokens=i.spent_total_tokens};let l=0,k=0;for(let c=0;c<8;c+=1){h(l);const g=O(m,r);if(g===l)return m;k=Math.max(k,g),l=g}return h(k),m}function Z(e){return Math.max(0,e.token_budget-e.spent_tokens)}export{b as PM_READ_OUTPUT_SESSION_MAX_SEEN_ITEM_IDS,S as PM_READ_OUTPUT_SESSION_MIN_TOKENS,z as applyReadOutputSessionReferences,U as attachReadOutputSessionReceipt,j as isReadOutputSessionReference,C as parseReadOutputSession,Z as readOutputSessionRemainingTokens};
|
|
2
2
|
//# sourceMappingURL=read-output-session.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]="403706c5-987d-5db1-95d2-b0eaded98e92")}catch{}})();import{createQueryFingerprint,decodeQueryCursor,encodeQueryCursor}from"./pagination.js";import{createRelationshipKindRegistry}from"./relationships.js";function visitImpactNeighbor(state,id,parent,root,after,limit){if(state.seen.has(id))return"skip";if(state.cursorFound&&state.affected.length>=limit)return"truncate";state.seen.add(id),state.parents.set(id,parent.id);const depth=parent.depth+1;return state.queue.push({id,depth}),state.cursorFound?(state.affected.push({id,distance:depth,path:reconstructImpactPath(root,id,state.parents)}),"continue"):(state.cursorFound=id===after,"skip")}function resolveImpactCursor(root,options,direction,maxDepth){const fingerprint=createQueryFingerprint("graph impact",{root,direction,kinds:[...options.kinds??[]].sort(),max_depth:Number.isFinite(maxDepth)?maxDepth:"unbounded"});return{fingerprint,after:options.after===void 0?void 0:decodeQueryCursor(options.after,fingerprint)}}function appendNeighbor(adjacency,source,target){adjacency.get(source).add(target)}function createAdjacency(nodes){return new Map(nodes.map(node=>[node,new Set]))}function sortComponents(components){for(const component of components)component.sort();return components.sort((left,right)=>right.length-left.length||left[0].localeCompare(right[0]))}function stableJsonValue(value){if(Array.isArray(value))return value.map(entry=>stableJsonValue(entry));if(value===null||typeof value!="object")return value;const toJSON=value.toJSON;return typeof toJSON=="function"?stableJsonValue(toJSON.call(value)):Object.fromEntries(Object.entries(value).sort(([left],[right])=>left.localeCompare(right)).map(([key,entry])=>[key,stableJsonValue(entry)]))}function relationshipEdgeKey(edge){return JSON.stringify(stableJsonValue(edge))}function appendFinishingOrder(start,adjacency,visited,order){const stack=[{id:start,expanded:!1}];for(;stack.length>0;){const current=stack.pop();if(current.expanded){order.push(current.id);continue}if(visited.has(current.id))continue;visited.add(current.id),stack.push({id:current.id,expanded:!0});const neighbors=[...adjacency.get(current.id)].sort().reverse();for(const neighbor of neighbors)visited.has(neighbor)||stack.push({id:neighbor,expanded:!1})}}function computeFinishingOrder(nodes,adjacency){const visited=new Set,order=[];for(const start of nodes)visited.has(start)||appendFinishingOrder(start,adjacency,visited,order);return order}function collectReverseComponents(order,reverse){const visited=new Set,components=[];for(const start of[...order].reverse()){if(visited.has(start))continue;const component=[],stack=[start];for(visited.add(start);stack.length>0;){const current=stack.pop();component.push(current);for(const neighbor of reverse.get(current))visited.has(neighbor)||(visited.add(neighbor),stack.push(neighbor))}components.push(component)}return sortComponents(components)}function stronglyConnectedComponents(nodes,adjacency){const reverse=createAdjacency(nodes);for(const[source,targets]of adjacency)for(const target of targets)appendNeighbor(reverse,target,source);return collectReverseComponents(computeFinishingOrder(nodes,adjacency),reverse)}function buildExecutionAdjacency(graph,registry){const adjacency=createAdjacency(graph.nodes());for(const edge of graph.edges()){const definition=registry.require(edge.kind);if(!definition.ordering)continue;const sourceFirst=(definition.precedence??"source_before_target")==="source_before_target";appendNeighbor(adjacency,sourceFirst?edge.source:edge.target,sourceFirst?edge.target:edge.source)}return adjacency}function topologicalLayers(nodes,adjacency){const indegree=new Map(nodes.map(node=>[node,0]));for(const targets of adjacency.values())for(const target of targets)indegree.set(target,indegree.get(target)+1);let frontier=nodes.filter(node=>indegree.get(node)===0).sort();const layers=[];for(;frontier.length>0;){layers.push(frontier);const next=[];for(const source of frontier)for(const target of adjacency.get(source)){const remaining=indegree.get(target)-1;indegree.set(target,remaining),remaining===0&&next.push(target)}frontier=next.sort()}return layers}function longestPath(order,adjacency){const depth=new Map(order.map(node=>[node,0])),parent=new Map;for(const source of order)for(const target of adjacency.get(source)){if(!depth.has(target))continue;const candidate=depth.get(source)+1,currentParent=parent.get(target);(candidate>depth.get(target)||candidate===depth.get(target)&&(currentParent===void 0||source.localeCompare(currentParent)<0))&&(depth.set(target,candidate),parent.set(target,source))}const end=[...order].sort((left,right)=>depth.get(right)-depth.get(left)||left.localeCompare(right))[0],path=end===void 0?[]:[end];for(;path[0]!==void 0&&parent.has(path[0]);)path.unshift(parent.get(path[0]));return{depth:Object.fromEntries(depth),path}}function reconstructImpactPath(root,target,parents){const path=[target];let cursor=target;for(;cursor!==root;)cursor=parents.get(cursor),path.push(cursor);return path.reverse()}function analyzeRelationshipExecution(graph,options={}){const registry=options.registry??createRelationshipKindRegistry(),nodes=[...graph.nodes()],adjacency=buildExecutionAdjacency(graph,registry),layers=topologicalLayers(nodes,adjacency),order=layers.flat(),acyclic=order.length===nodes.length,cycles=acyclic?[]:stronglyConnectedComponents(nodes,adjacency).filter(component=>component.length>1||adjacency.get(component[0]).has(component[0])),longest=longestPath(order,adjacency);return{exact:!0,acyclic,order,layers,frontier:layers[0]??[],depth:longest.depth,criticalPath:longest.path,criticalPathLength:Math.max(0,longest.path.length-1),cycles,provenance:{algorithm:"kahn-longest-path",edgeFamily:"ordering"}}}function buildImpactAdjacency(graph,direction,kinds){const adjacency=createAdjacency(graph.nodes()),selectedKinds=kinds===void 0?void 0:new Set(kinds.map(kind=>graph.registry().require(kind).kind)),edges=graph.edges();for(const edge of edges){const definition=graph.registry().require(edge.kind);selectedKinds!==void 0&&!selectedKinds.has(edge.kind)&&(definition.inverse===void 0||!selectedKinds.has(definition.inverse))||appendNeighbor(adjacency,direction==="incoming"?edge.target:edge.source,direction==="incoming"?edge.source:edge.target)}return{adjacency,inspectedEdges:edges.length}}function analyzeBidirectionalGraphImpact(graph,root,options,after,limit,cursorFingerprint){const incoming=analyzeGraphImpact(graph,root,{...options,after:void 0,direction:"incoming",limit:void 0}),outgoing=analyzeGraphImpact(graph,root,{...options,after:void 0,direction:"outgoing",limit:void 0}),rows=new Map,candidates=[...incoming.affected,...outgoing.affected].sort((left,right)=>left.distance-right.distance||left.id.localeCompare(right.id)||left.path.join("\0").localeCompare(right.path.join("\0")));for(const row of candidates)rows.has(row.id)||rows.set(row.id,row);const ordered=[...rows.values()].sort((left,right)=>left.distance-right.distance||left.id.localeCompare(right.id)),afterIndex=after===void 0||after===root?-1:ordered.findIndex(row=>row.id===after);if(after!==void 0&&after!==root&&afterIndex<0)throw new TypeError(`Unknown impact cursor item: ${after}`);const affected=ordered.slice(afterIndex+1,afterIndex+1+limit),rowLimitTruncated=afterIndex+1+affected.length<ordered.length;return{root,affected,exact:!0,truncated:incoming.truncated||outgoing.truncated||rowLimitTruncated,...rowLimitTruncated?{nextCursor:encodeQueryCursor(cursorFingerprint,affected.at(-1)?.id??root)}:{},cost:{visitedNodes:incoming.cost.visitedNodes+outgoing.cost.visitedNodes,inspectedEdges:incoming.cost.inspectedEdges+outgoing.cost.inspectedEdges}}}function analyzeUnidirectionalGraphImpact(graph,root,options){const direction=options.direction,maxDepth=options.maxDepth??Number.POSITIVE_INFINITY,limit=options.limit??Number.POSITIVE_INFINITY,{fingerprint:cursorFingerprint,after}=resolveImpactCursor(root,options,direction,maxDepth),{adjacency,inspectedEdges}=buildImpactAdjacency(graph,direction,options.kinds),state={queue:[{id:root,depth:0}],seen:new Set([root]),parents:new Map,affected:[],cursorFound:after===void 0||after===root};let visitedNodes=0,truncated=!1,rowLimitTruncated=!1;traversal:for(let index=0;index<state.queue.length;index+=1){options.signal?.throwIfAborted();const current=state.queue[index];visitedNodes+=1;const adjacent=[...adjacency.get(current.id)].sort();if(current.depth>=maxDepth){adjacent.some(id=>!state.seen.has(id))&&(truncated=!0);continue}for(const id of adjacent)if(visitImpactNeighbor(state,id,current,root,after,limit)==="truncate"){truncated=!0,rowLimitTruncated=!0;break traversal}}if(!state.cursorFound)throw new TypeError(`Unknown impact cursor item: ${after}`);return{root,affected:state.affected,exact:!0,truncated,...rowLimitTruncated?{nextCursor:encodeQueryCursor(cursorFingerprint,state.affected.at(-1)?.id??root)}:{},cost:{visitedNodes,inspectedEdges}}}function analyzeGraphImpact(graph,root,options={}){const direction=options.direction??"outgoing";if(direction!=="both")return analyzeUnidirectionalGraphImpact(graph,root,{...options,direction});const maxDepth=options.maxDepth??Number.POSITIVE_INFINITY,limit=options.limit??Number.POSITIVE_INFINITY,{fingerprint,after}=resolveImpactCursor(root,options,direction,maxDepth);return analyzeBidirectionalGraphImpact(graph,root,options,after,limit,fingerprint)}function analyzeKnowledgeGraph(graph){const nodes=[...graph.nodes()],weak=createAdjacency(nodes),directed=createAdjacency(nodes);for(const edge of graph.edges())appendNeighbor(weak,edge.source,edge.target),appendNeighbor(weak,edge.target,edge.source),appendNeighbor(directed,edge.source,edge.target);const components=[],visited=new Set;for(const start of nodes){if(visited.has(start))continue;const component=[],stack=[start];for(visited.add(start);stack.length>0;){const current=stack.pop();component.push(current);for(const neighbor of weak.get(current))visited.has(neighbor)||(visited.add(neighbor),stack.push(neighbor))}components.push(component)}const degrees=nodes.map(id=>({id,degree:weak.get(id).size})),maximum=Math.max(0,...degrees.map(({degree})=>degree));return{components:sortComponents(components),stronglyConnected:stronglyConnectedComponents(nodes,directed),orphans:degrees.filter(({degree})=>degree===0).map(({id})=>id),hubs:degrees.filter(({degree})=>degree>0&°ree===maximum),exact:!0,provenance:{algorithm:"component-degree",edgeFamily:"all"}}}function compareRelationshipSnapshots(before,after){const earlier=new Map(before.edges.map(edge=>[relationshipEdgeKey(edge),edge])),later=new Map(after.edges.map(edge=>[relationshipEdgeKey(edge),edge]));return{fromVersion:before.version,toVersion:after.version,added:[...later].filter(([key])=>!earlier.has(key)).map(([,edge])=>edge),removed:[...earlier].filter(([key])=>!later.has(key)).map(([,edge])=>edge),unchangedCount:[...earlier.keys()].filter(key=>later.has(key)).length,exact:!0}}export{analyzeGraphImpact,analyzeKnowledgeGraph,analyzeRelationshipExecution,compareRelationshipSnapshots};
|
|
1
|
+
import{createQueryFingerprint as v,decodeQueryCursor as S,encodeQueryCursor as b}from"./pagination.js";import{createRelationshipKindRegistry as j}from"./relationships.js";function O(t,n,e,o,r,c){if(t.seen.has(n))return"skip";if(t.cursorFound&&t.affected.length>=c)return"truncate";t.seen.add(n),t.parents.set(n,e.id);const s=e.depth+1;return t.queue.push({id:n,depth:s}),t.cursorFound?(t.affected.push({id:n,distance:s,path:z(o,n,t.parents)}),"continue"):(t.cursorFound=n===r,"skip")}function N(t,n,e,o){const r=v("graph impact",{root:t,direction:e,kinds:[...n.kinds??[]].sort(),max_depth:Number.isFinite(o)?o:"unbounded"});return{fingerprint:r,after:n.after===void 0?void 0:S(n.after,r)}}function l(t,n,e){t.get(n).add(e)}function y(t){return new Map(t.map(n=>[n,new Set]))}function C(t){for(const n of t)n.sort();return t.sort((n,e)=>e.length-n.length||n[0].localeCompare(e[0]))}function w(t){if(Array.isArray(t))return t.map(e=>w(e));if(t===null||typeof t!="object")return t;const n=t.toJSON;return typeof n=="function"?w(n.call(t)):Object.fromEntries(Object.entries(t).sort(([e],[o])=>e.localeCompare(o)).map(([e,o])=>[e,w(o)]))}function k(t){return JSON.stringify(w(t))}function T(t,n,e,o){const r=[{id:t,expanded:!1}];for(;r.length>0;){const c=r.pop();if(c.expanded){o.push(c.id);continue}if(e.has(c.id))continue;e.add(c.id),r.push({id:c.id,expanded:!0});const s=[...n.get(c.id)].sort().reverse();for(const a of s)e.has(a)||r.push({id:a,expanded:!1})}}function M(t,n){const e=new Set,o=[];for(const r of t)e.has(r)||T(r,n,e,o);return o}function P(t,n){const e=new Set,o=[];for(const r of[...t].reverse()){if(e.has(r))continue;const c=[],s=[r];for(e.add(r);s.length>0;){const a=s.pop();c.push(a);for(const i of n.get(a))e.has(i)||(e.add(i),s.push(i))}o.push(c)}return C(o)}function F(t,n){const e=y(t);for(const[o,r]of n)for(const c of r)l(e,c,o);return P(M(t,n),e)}function _(t,n){const e=y(t.nodes());for(const o of t.edges()){const r=n.require(o.kind);if(!r.ordering)continue;const c=(r.precedence??"source_before_target")==="source_before_target";l(e,c?o.source:o.target,c?o.target:o.source)}return e}function q(t,n){const e=new Map(t.map(c=>[c,0]));for(const c of n.values())for(const s of c)e.set(s,e.get(s)+1);let o=t.filter(c=>e.get(c)===0).sort();const r=[];for(;o.length>0;){r.push(o);const c=[];for(const s of o)for(const a of n.get(s)){const i=e.get(a)-1;e.set(a,i),i===0&&c.push(a)}o=c.sort()}return r}function V(t,n){const e=new Map(t.map(s=>[s,0])),o=new Map;for(const s of t)for(const a of n.get(s)){if(!e.has(a))continue;const i=e.get(s)+1,f=o.get(a);(i>e.get(a)||i===e.get(a)&&(f===void 0||s.localeCompare(f)<0))&&(e.set(a,i),o.set(a,s))}const r=[...t].sort((s,a)=>e.get(a)-e.get(s)||s.localeCompare(a))[0],c=r===void 0?[]:[r];for(;c[0]!==void 0&&o.has(c[0]);)c.unshift(o.get(c[0]));return{depth:Object.fromEntries(e),path:c}}function z(t,n,e){const o=[n];let r=n;for(;r!==t;)r=e.get(r),o.push(r);return o.reverse()}function Y(t,n={}){const e=n.registry??j(),o=[...t.nodes()],r=_(t,e),c=q(o,r),s=c.flat(),a=s.length===o.length,i=a?[]:F(o,r).filter(d=>d.length>1||r.get(d[0]).has(d[0])),f=V(s,r);return{exact:!0,acyclic:a,order:s,layers:c,frontier:c[0]??[],depth:f.depth,criticalPath:f.path,criticalPathLength:Math.max(0,f.path.length-1),cycles:i,provenance:{algorithm:"kahn-longest-path",edgeFamily:"ordering"}}}function A(t,n,e){const o=y(t.nodes()),r=e===void 0?void 0:new Set(e.map(s=>t.registry().require(s).kind)),c=t.edges();for(const s of c){const a=t.registry().require(s.kind);r!==void 0&&!r.has(s.kind)&&(a.inverse===void 0||!r.has(a.inverse))||l(o,n==="incoming"?s.target:s.source,n==="incoming"?s.source:s.target)}return{adjacency:o,inspectedEdges:c.length}}function R(t,n,e,o,r,c){const s=E(t,n,{...e,after:void 0,direction:"incoming",limit:void 0}),a=E(t,n,{...e,after:void 0,direction:"outgoing",limit:void 0}),i=new Map,f=[...s.affected,...a.affected].sort((u,h)=>u.distance-h.distance||u.id.localeCompare(h.id)||u.path.join("\0").localeCompare(h.path.join("\0")));for(const u of f)i.has(u.id)||i.set(u.id,u);const d=[...i.values()].sort((u,h)=>u.distance-h.distance||u.id.localeCompare(h.id)),g=o===void 0||o===n?-1:d.findIndex(u=>u.id===o);if(o!==void 0&&o!==n&&g<0)throw new TypeError(`Unknown impact cursor item: ${o}`);const p=d.slice(g+1,g+1+r),m=g+1+p.length<d.length;return{root:n,affected:p,exact:!0,truncated:s.truncated||a.truncated||m,...m?{nextCursor:b(c,p.at(-1)?.id??n)}:{},cost:{visitedNodes:s.cost.visitedNodes+a.cost.visitedNodes,inspectedEdges:s.cost.inspectedEdges+a.cost.inspectedEdges}}}function G(t,n,e){const o=e.direction,r=e.maxDepth??Number.POSITIVE_INFINITY,c=e.limit??Number.POSITIVE_INFINITY,{fingerprint:s,after:a}=N(n,e,o,r),{adjacency:i,inspectedEdges:f}=A(t,o,e.kinds),d={queue:[{id:n,depth:0}],seen:new Set([n]),parents:new Map,affected:[],cursorFound:a===void 0||a===n};let g=0,p=!1,m=!1;e:for(let u=0;u<d.queue.length;u+=1){e.signal?.throwIfAborted();const h=d.queue[u];g+=1;const x=[...i.get(h.id)].sort();if(h.depth>=r){x.some(I=>!d.seen.has(I))&&(p=!0);continue}for(const I of x)if(O(d,I,h,n,a,c)==="truncate"){p=!0,m=!0;break e}}if(!d.cursorFound)throw new TypeError(`Unknown impact cursor item: ${a}`);return{root:n,affected:d.affected,exact:!0,truncated:p,...m?{nextCursor:b(s,d.affected.at(-1)?.id??n)}:{},cost:{visitedNodes:g,inspectedEdges:f}}}function E(t,n,e={}){const o=e.direction??"outgoing";if(o!=="both")return G(t,n,{...e,direction:o});const r=e.maxDepth??Number.POSITIVE_INFINITY,c=e.limit??Number.POSITIVE_INFINITY,{fingerprint:s,after:a}=N(n,e,o,r);return R(t,n,e,a,c,s)}function D(t){const n=[...t.nodes()],e=y(n),o=y(n);for(const i of t.edges())l(e,i.source,i.target),l(e,i.target,i.source),l(o,i.source,i.target);const r=[],c=new Set;for(const i of n){if(c.has(i))continue;const f=[],d=[i];for(c.add(i);d.length>0;){const g=d.pop();f.push(g);for(const p of e.get(g))c.has(p)||(c.add(p),d.push(p))}r.push(f)}const s=n.map(i=>({id:i,degree:e.get(i).size})),a=Math.max(0,...s.map(({degree:i})=>i));return{components:C(r),stronglyConnected:F(n,o),orphans:s.filter(({degree:i})=>i===0).map(({id:i})=>i),hubs:s.filter(({degree:i})=>i>0&&i===a),exact:!0,provenance:{algorithm:"component-degree",edgeFamily:"all"}}}function Q(t,n){const e=new Map(t.edges.map(r=>[k(r),r])),o=new Map(n.edges.map(r=>[k(r),r]));return{fromVersion:t.version,toVersion:n.version,added:[...o].filter(([r])=>!e.has(r)).map(([,r])=>r),removed:[...e].filter(([r])=>!o.has(r)).map(([,r])=>r),unchangedCount:[...e.keys()].filter(r=>o.has(r)).length,exact:!0}}export{E as analyzeGraphImpact,D as analyzeKnowledgeGraph,Y as analyzeRelationshipExecution,Q as compareRelationshipSnapshots};
|
|
2
2
|
//# sourceMappingURL=relationship-analytics.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{createQueryFingerprint as P,encodeQueryCursor as $,resolveQueryCursorStart as A}from"./pagination.js";import{createRelationshipKindRegistry as F}from"./relationships.js";const Q=1200,j=["prerequisite","dependent","ancestor","descendant","provenance","related"],H=new TextEncoder;function y(e,n,i){const o=e??n;if(!Number.isInteger(o)||o<1)throw new TypeError(`Relationship context ${i} must be positive`);return o}function T(e){return Math.max(1,Math.ceil(H.encode(JSON.stringify(e)).byteLength/4))}function N(e,n,i){const o=i.resolve(e.kind);if(o?.ordering){const t=(o.precedence??"source_before_target")==="source_before_target"?e.source:e.target;return n===t?"prerequisite":"dependent"}if(o?.hierarchy){const t=o.hierarchyDirection==="source_parent"?e.source:e.target;return n===t?"ancestor":"descendant"}return e.kind==="discovered_from"||e.kind==="incident_from"?"provenance":"related"}function K(e,n,i,o){const s=e.filter(t=>t.source===n&&t.target===i||t.target===n&&t.source===i).map(t=>N(t,i,o));return[...new Set(s)].sort()}function U(e){return j.find(n=>e.includes(n))}function X(e,n,i,o){const s=o.direction??"both",t=o.maxDepth??3;if(!Number.isInteger(t)||t<0)throw new TypeError("Relationship context maxDepth must be non-negative");const r=new Set([n]),d=[{id:n,distance:0}],c=[];let h=0,v=!1;for(let g=0;g<d.length;g+=1){o.signal?.throwIfAborted();const u=d[g];if(u.distance>=t&&v)continue;const f=e.neighborEdges(u.id,{direction:s,kinds:o.kinds,signal:o.signal});if(h+=f.meta.inspectedEdges,u.distance>=t){f.value.some(a=>!r.has(a.id))&&(v=!0);continue}for(const{id:a,edge:b}of f.value){if(r.has(a))continue;r.add(a);const l={id:a,distance:u.distance+1,via:u.id,role:N(b,a,i)};c.push(l),d.push(l)}}return{rows:c,visitedNodes:d.length,inspectedEdges:h,depthTruncated:v}}function z(e,n,i,o){const s={prerequisite:0,dependent:0,ancestor:0,descendant:0,provenance:0,related:0},t=e.neighborEdges(n,{direction:o.direction??"both",kinds:o.kinds,signal:o.signal}).value;for(const{id:r,edge:d}of t)s[N(d,r,i)]+=1;return{directEdges:s,directTotal:t.length,rootEdges:t.map(({edge:r})=>r)}}function G(e,n,i,o){const s=new Set;for(const t of n){const r=t.source===i?t.target:t.source,d=N(t,r,o);(d==="prerequisite"||d==="ancestor")&&s.add(r)}return[...e].sort((t,r)=>Number(s.has(r.id))-Number(s.has(t.id))||t.distance-r.distance||t.id.localeCompare(r.id))}function J(e,n){const i=e.distance===1?K(n.rootEdges,n.rootId,e.id,n.registry):[];return{...n.details.get(e.id)??{id:e.id},distance:e.distance,role:i.length>0?U(i):e.role,via:e.via,reasons:i.length>0?i:[`${e.role} via ${e.via} (depth ${e.distance})`]}}function Y(e){const n=[];let i=e.initialTokens,o=0;for(const s of e.candidates){if(n.length>=e.nodeLimit)break;const t=J(s,e),r=T(t);if(i+r>e.tokenBudget)break;const d=e.rootEdges.filter(c=>c.source===s.id||c.target===s.id).reduce((c,h)=>c+T(h),0);if(i+o+r+d>e.tokenBudget){if(n.length>0)break}else o+=d;n.push(t),i+=r}if(e.candidates.length>0&&n.length===0)throw new TypeError("Relationship context tokenBudget cannot fit one node");return{nodes:n,usedTokens:i}}function V(e){const n=e.options.kinds?new Set(e.options.kinds.map(t=>e.registry.require(t).kind)):void 0,i=e.graph.edges().filter(t=>{if(!e.included.has(t.source)||!e.included.has(t.target))return!1;if(n===void 0||n.has(t.kind))return!0;const r=e.registry.resolve(t.kind)?.inverse;return r!==void 0&&n.has(r)}).sort((t,r)=>+(r.source===e.rootId||r.target===e.rootId)-+(t.source===e.rootId||t.target===e.rootId)),o=[];let s=e.initialTokens;for(const t of i){if(o.length>=e.edgeLimit)break;const r=T(t);s+r>e.tokenBudget||(o.push(t),s+=r)}return{edges:o,usedTokens:s,candidateCount:i.length}}function ee(e,n,i,o={}){if(!e.nodes().includes(n))throw new TypeError(`Relationship node not found: ${n}`);const s=y(o.nodeLimit,20,"nodeLimit"),t=y(o.edgeLimit,40,"edgeLimit"),r=y(o.tokenBudget,Q,"tokenBudget"),d=o.registry??F(),c=new Map(i.map(k=>[k.id,k])),h=c.get(n)??{id:n},{evidence:v=[],...g}=h,u=[...v],f=X(e,n,d,o),{rootEdges:a,...b}=z(e,n,d,o),l=G(f.rows,a,n,d),R=P("relationship-context",{rootId:n,direction:o.direction??"both",kinds:[...o.kinds??[]].sort(),maxDepth:o.maxDepth??3,ordering:"required-root-evidence-first-v1"}),C=A(l,o.cursor,R,({id:k})=>k,"--cursor"),q=l.slice(C),S=T(g)+T(u);if(S>r)throw new TypeError("Relationship context tokenBudget cannot fit root and evidence");const _=Y({candidates:q,details:c,rootEdges:a,rootId:n,registry:d,nodeLimit:s,tokenBudget:r,initialTokens:S}),{nodes:E}=_,I=new Set([n,...E.map(({id:k})=>k)]),L=V({graph:e,rootId:n,included:I,options:o,registry:d,edgeLimit:t,tokenBudget:r,initialTokens:_.usedTokens}),{edges:p,usedTokens:O}=L,m=C+E.length,w=m<l.length,D=E.at(-1),x=L.candidateCount-p.length,B=f.depthTruncated||w||x>0,M={rootId:n,...g.status===void 0?{}:{rootStatus:g.status},...b,discoveredNodes:l.length,returnedNodes:E.length,returnedEdges:p.length,omittedNodes:l.length-m,omittedEdges:x,evidenceCount:u.length,hasMore:w};return{root:g,summary:M,nodes:E,edges:p,evidence:u,meta:{exact:!0,truncated:B,completeness:B?"truncated":"complete",nodeLimit:s,edgeLimit:t,tokenBudget:r,usedTokens:O,visitedNodes:f.visitedNodes,inspectedEdges:f.inspectedEdges,omittedNodes:l.length-m,omittedEdges:x,...w&&D?{nextCursor:$(R,D.id,m-1)}:{}}}}export{Q as DEFAULT_RELATIONSHIP_CONTEXT_TOKEN_BUDGET,ee as buildRelationshipContext};
|
|
2
2
|
//# sourceMappingURL=relationship-context.js.map
|