@unbrained/pm-cli 2026.9.7 → 2026.9.8
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 +12 -4
- package/.agents/skills/pm-developer/references/MULTI_AGENT_MERGE.md +19 -10
- package/.agents/skills/pm-extensions/SKILL.md +6 -0
- package/.agents/skills/pm-sdk/SKILL.md +11 -2
- package/.agents/skills/pm-user/SKILL.md +5 -0
- package/.agents/skills/pm-user/references/ECOSYSTEM_PLANNING.md +95 -0
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +211 -181
- package/dist/cli/after-command-context-usage.js +1 -48
- package/dist/cli/argv-utils.js +1 -40
- package/dist/cli/bootstrap-args.js +1 -9
- package/dist/cli/bundle-integrity.js +2 -110
- package/dist/cli/commander-usage.js +11 -771
- package/dist/cli/commands/activity.js +1 -9
- package/dist/cli/commands/aggregate.js +1 -5
- package/dist/cli/commands/append.js +1 -5
- package/dist/cli/commands/claim.js +1 -5
- package/dist/cli/commands/close-many.js +1 -5
- package/dist/cli/commands/close.js +1 -9
- package/dist/cli/commands/comments.js +1 -5
- package/dist/cli/commands/config.js +1 -9
- package/dist/cli/commands/context.js +1 -9
- package/dist/cli/commands/contracts.js +1 -5
- package/dist/cli/commands/copy.js +1 -9
- package/dist/cli/commands/create.js +1 -9
- package/dist/cli/commands/delete.js +1 -9
- package/dist/cli/commands/deps.js +1 -9
- package/dist/cli/commands/docs.js +1 -9
- package/dist/cli/commands/duplicates.js +1 -9
- package/dist/cli/commands/eval.js +1 -9
- package/dist/cli/commands/extension/describe.js +1 -5
- package/dist/cli/commands/extension/scaffold.js +1 -5
- package/dist/cli/commands/extension/shared.js +1 -5
- package/dist/cli/commands/extension.js +1 -9
- package/dist/cli/commands/files.js +1 -9
- package/dist/cli/commands/focus.js +1 -9
- package/dist/cli/commands/gc.js +1 -9
- package/dist/cli/commands/get.js +1 -9
- package/dist/cli/commands/graph.js +1 -10
- package/dist/cli/commands/health.js +1 -9
- package/dist/cli/commands/history-compact.js +1 -10
- package/dist/cli/commands/history-redact.js +1 -11
- package/dist/cli/commands/history-repair.js +1 -10
- package/dist/cli/commands/history.js +1 -5
- package/dist/cli/commands/index.js +1 -58
- package/dist/cli/commands/init-agent-guidance.js +1 -9
- package/dist/cli/commands/init.js +1 -9
- package/dist/cli/commands/learnings.js +1 -5
- package/dist/cli/commands/lifecycle-transitions.js +1 -5
- package/dist/cli/commands/list.js +1 -9
- package/dist/cli/commands/merge.js +1 -11
- package/dist/cli/commands/next.js +1 -9
- package/dist/cli/commands/notes.js +1 -5
- package/dist/cli/commands/plan.js +1 -9
- package/dist/cli/commands/profile.js +1 -9
- package/dist/cli/commands/restore.js +1 -9
- package/dist/cli/commands/scheduling-shortcuts.js +1 -9
- package/dist/cli/commands/schema.js +1 -10
- package/dist/cli/commands/search.js +1 -9
- package/dist/cli/commands/stats.js +1 -9
- package/dist/cli/commands/telemetry.js +1 -9
- package/dist/cli/commands/test-all.js +1 -9
- package/dist/cli/commands/test-runs.js +1 -9
- package/dist/cli/commands/test.js +1 -9
- package/dist/cli/commands/update-many.js +1 -5
- package/dist/cli/commands/update.js +1 -9
- package/dist/cli/commands/upgrade.js +1 -5
- package/dist/cli/commands/validate.js +1 -15
- package/dist/cli/context-intent-invocation.js +1 -20
- package/dist/cli/description-stdin.js +1 -17
- package/dist/cli/error-guidance.js +1 -1353
- package/dist/cli/extension-command-help.js +5 -636
- package/dist/cli/extension-command-options.js +1 -427
- package/dist/cli/extension-recovery.js +1 -126
- package/dist/cli/help-content.js +2 -1001
- package/dist/cli/help-json-payload.js +4 -570
- package/dist/cli/main.d.ts +4 -0
- package/dist/cli/main.js +5 -2573
- package/dist/cli/migration-gates.js +1 -289
- package/dist/cli/public.js +1 -20
- package/dist/cli/register-annotations.js +1 -270
- package/dist/cli/register-assurance.js +1 -62
- package/dist/cli/register-files-lookup.js +1 -56
- package/dist/cli/register-history-activity.d.ts +8 -0
- package/dist/cli/register-history-activity.js +2 -0
- package/dist/cli/register-history-author.js +1 -38
- package/dist/cli/register-history-maintenance.d.ts +9 -0
- package/dist/cli/register-history-maintenance.js +2 -0
- package/dist/cli/register-list-query.js +10 -943
- package/dist/cli/register-mutation-options.js +1 -9
- package/dist/cli/register-mutation.js +19 -1893
- package/dist/cli/register-operations.js +1 -920
- package/dist/cli/register-setup.js +1 -716
- package/dist/cli/register-structured-mutation.js +1 -196
- package/dist/cli/registration-helpers.js +1 -5
- package/dist/cli/runtime-compatibility-boundary.js +4 -42
- package/dist/cli/schema-registration-helpers.js +1 -73
- package/dist/cli/search-refresh.js +1 -13
- package/dist/cli/stats-analytics-json.js +1 -68
- package/dist/cli/telemetry-flush.js +1 -10
- package/dist/cli-bundle/bundle-manifest.json +164 -156
- package/dist/cli-bundle/chunks/chunk-3BZZA6A3.js +5 -0
- package/dist/cli-bundle/chunks/chunk-AMRDVX36.js +235 -0
- package/dist/cli-bundle/chunks/chunk-DAM4CBBR.js +2202 -0
- package/dist/cli-bundle/chunks/{chunk-WYRZZ5ZE.js → chunk-DEZPZOQ7.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-FLDWYEND.js +77 -0
- package/dist/cli-bundle/chunks/{chunk-NPN5I67J.js → chunk-G5ADGQ2D.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-JAAEYHUA.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-JX4DH4WC.js → chunk-KR3RP4FH.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-LEZOUXG6.js +2 -0
- package/dist/cli-bundle/chunks/chunk-NSAPNEYH.js +2 -0
- package/dist/cli-bundle/chunks/chunk-QOEKOECV.js +29 -0
- package/dist/cli-bundle/chunks/chunk-RHSFOMHU.js +2 -0
- package/dist/cli-bundle/chunks/chunk-XOD2PCB6.js +20 -0
- package/dist/cli-bundle/chunks/{chunk-JT6XF6GE.js → chunk-YVEQ2AMO.js} +4 -4
- package/dist/cli-bundle/chunks/register-list-query-KSK3R63M.js +11 -0
- package/dist/cli-bundle/chunks/register-mutation-IQ5C7U6O.js +20 -0
- package/dist/cli-bundle/chunks/{register-operations-I5W3KMGB.js → register-operations-DWVHR2NC.js} +2 -2
- package/dist/cli-bundle/chunks/register-setup-BQ5SVD4B.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-3WRPWLA7.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-7MBUII7U.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-COPBO5HW.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-DUN4IXYN.js +20 -0
- package/dist/cli-bundle/focused-chunks/{chunk-LIJIA4TY.js → chunk-EE5QSM4Z.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-HJVARYM3.js +6 -0
- package/dist/cli-bundle/focused-chunks/chunk-IAUOUGVR.js +177 -0
- package/dist/cli-bundle/focused-chunks/chunk-KOOMJ54F.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-MZDXX7JY.js +56 -0
- package/dist/cli-bundle/focused-chunks/{chunk-M6PBRFSH.js → chunk-OPFHFGDD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-QHNETP77.js +9 -0
- package/dist/cli-bundle/focused-chunks/{chunk-3BZEOXLT.js → chunk-RMWES4M6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-RXT4P5QH.js +10 -0
- package/dist/cli-bundle/focused-chunks/chunk-SDOL6FM2.js +12 -0
- package/dist/cli-bundle/focused-chunks/chunk-SQV4AAUC.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-PEFABF7E.js → chunk-WE3IUNIW.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-YALOUBWJ.js +2 -0
- package/dist/cli-bundle/main.js +20 -20
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +2 -2
- package/dist/cli-bundle/sdk-core.js +29 -29
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +42 -42
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +11 -11
- package/dist/cli.js +1 -104
- package/dist/core/checkpoint/checkpoint-gc.js +1 -169
- package/dist/core/checkpoint/mutation-checkpoint.js +2 -133
- package/dist/core/config/nested-settings.js +1 -534
- package/dist/core/config/positional-value.js +1 -109
- package/dist/core/diagnostics/remediation.js +1 -506
- package/dist/core/extensions/activation-summary-markdown.js +2 -145
- package/dist/core/extensions/activation-summary.js +1 -92
- package/dist/core/extensions/activation-transaction.js +1 -46
- package/dist/core/extensions/capability-usage.js +1 -173
- package/dist/core/extensions/command-hook-context.js +1 -13
- package/dist/core/extensions/command-metadata-contract.js +1 -22
- package/dist/core/extensions/command-visibility-tier.js +1 -29
- package/dist/core/extensions/contribution-inventory.js +1 -173
- package/dist/core/extensions/exporter-output-contract.js +1 -66
- package/dist/core/extensions/extension-candidate.js +1 -18
- package/dist/core/extensions/extension-capability-aliases.js +1 -158
- package/dist/core/extensions/extension-hook-runtime.js +1 -699
- package/dist/core/extensions/extension-policy.js +1 -599
- package/dist/core/extensions/extension-registries.js +1 -62
- package/dist/core/extensions/extension-runtime-helpers.js +1 -33
- package/dist/core/extensions/extension-types.js +1 -102
- package/dist/core/extensions/flag-definition-validation.js +1 -52
- package/dist/core/extensions/flag-value-types.js +1 -64
- package/dist/core/extensions/index.js +1 -526
- package/dist/core/extensions/item-field-types.js +1 -39
- package/dist/core/extensions/item-fields.js +1 -261
- package/dist/core/extensions/loader.js +1 -2223
- package/dist/core/extensions/manifest-schema.js +1 -69
- package/dist/core/extensions/module-graph-snapshot.js +1 -33
- package/dist/core/extensions/preflight-ownership.js +1 -41
- package/dist/core/extensions/registration-validation.js +1 -82
- package/dist/core/extensions/registration-values.js +1 -209
- package/dist/core/extensions/reserved-host-flags.js +1 -36
- package/dist/core/extensions/runtime-registrations.js +1 -67
- package/dist/core/extensions/service-ownership.js +1 -19
- package/dist/core/extensions/version-compat.js +1 -216
- package/dist/core/fs/fs-utils.js +2 -158
- package/dist/core/fs/host-environment-errors.js +1 -141
- package/dist/core/fs/index.js +1 -9
- package/dist/core/fs/path-utils.js +1 -17
- package/dist/core/governance/content-fields.js +1 -160
- package/dist/core/governance/issue-codes.js +1 -151
- package/dist/core/governance/metadata-coverage.js +1 -358
- package/dist/core/history/drift-cache.js +3 -72
- package/dist/core/history/drift-scan.js +1 -342
- package/dist/core/history/event-classification.js +1 -109
- package/dist/core/history/event-index.js +8 -784
- package/dist/core/history/history-compact-bulk.js +1 -104
- package/dist/core/history/history-diff.js +1 -158
- package/dist/core/history/history-rewrite.d.ts +6 -1
- package/dist/core/history/history-rewrite.js +1 -107
- package/dist/core/history/history-storage-stats.js +1 -102
- package/dist/core/history/history-stream-policy.js +1 -62
- package/dist/core/history/history.js +2 -617
- package/dist/core/history/identity.js +1 -30
- package/dist/core/history/index.js +1 -9
- package/dist/core/history/projection.js +1 -196
- package/dist/core/history/read.d.ts +9 -0
- package/dist/core/history/read.js +1 -57
- package/dist/core/history/replay.js +2 -439
- package/dist/core/history/version-address.js +1 -32
- package/dist/core/history/workspace-history.js +2 -433
- package/dist/core/io/body-file.js +1 -62
- package/dist/core/io/bulk-ids-input.js +1 -112
- package/dist/core/item/actionability.js +1 -327
- package/dist/core/item/dependency-reference.js +1 -20
- package/dist/core/item/id.js +1 -112
- package/dist/core/item/index.js +1 -12
- package/dist/core/item/item-format-version.js +1 -78
- package/dist/core/item/item-format.js +5 -1473
- package/dist/core/item/item-record.js +1 -23
- package/dist/core/item/item-type-definition.js +1 -133
- package/dist/core/item/parent-reference-policy.js +1 -57
- package/dist/core/item/parse.js +2 -603
- package/dist/core/item/plan-lifecycle.js +1 -19
- package/dist/core/item/priority.js +1 -61
- package/dist/core/item/sprint-release-format.js +1 -38
- package/dist/core/item/status-filter.js +1 -115
- package/dist/core/item/status.js +1 -43
- package/dist/core/item/toon-decode.js +1 -29
- package/dist/core/item/type-registry.js +1 -715
- package/dist/core/item/type-synonyms.js +1 -38
- package/dist/core/lock/index.js +1 -9
- package/dist/core/lock/lock-gc.js +1 -240
- package/dist/core/lock/lock.js +3 -590
- package/dist/core/output/mutation-projection.js +1 -217
- package/dist/core/output/output-control.js +1 -25
- package/dist/core/output/output.js +11 -494
- package/dist/core/output/query-summary.js +1 -58
- package/dist/core/output/tabular.js +1 -77
- package/dist/core/packages/manifest.js +1 -244
- package/dist/core/packages/root.js +1 -84
- package/dist/core/profile/profile-describe.js +1 -83
- package/dist/core/profile/profile-lint.js +1 -415
- package/dist/core/profile/profile-plan.js +0 -0
- package/dist/core/profile/profile-presets.js +1 -370
- package/dist/core/reproducibility/context.js +1 -82
- package/dist/core/schema/fields-file.js +2 -288
- package/dist/core/schema/item-types-file.js +2 -296
- package/dist/core/schema/runtime-field-filters.js +1 -49
- package/dist/core/schema/runtime-field-values.js +1 -313
- package/dist/core/schema/runtime-schema.js +2 -826
- package/dist/core/schema/status-defs-file.js +2 -227
- package/dist/core/schema/status-token.js +1 -31
- package/dist/core/schema/type-inference.js +1 -95
- package/dist/core/schema/type-presets.js +1 -87
- package/dist/core/schema/type-workflows.js +1 -104
- package/dist/core/search/background-refresh.js +2 -286
- package/dist/core/search/bm25.js +1 -146
- package/dist/core/search/cache.js +2 -534
- package/dist/core/search/corpus.js +1 -311
- package/dist/core/search/embedding-batches.js +1 -163
- package/dist/core/search/eval.js +1 -225
- package/dist/core/search/http-client.js +1 -75
- package/dist/core/search/providers.js +1 -242
- package/dist/core/search/relevance.js +1 -244
- package/dist/core/search/semantic-defaults.js +1 -199
- package/dist/core/search/staleness.js +1 -30
- package/dist/core/search/vector-stores.js +2 -664
- package/dist/core/search/vectorization-metadata.js +1 -81
- package/dist/core/sentry/helpers.js +1 -272
- package/dist/core/sentry/instrument.js +1 -387
- package/dist/core/session/session-state.js +1 -260
- package/dist/core/shared/agent-session-context.js +1 -133
- package/dist/core/shared/author.js +1 -1172
- package/dist/core/shared/command-types.js +1 -4
- package/dist/core/shared/conflict-markers.js +1 -31
- package/dist/core/shared/constants.js +1 -405
- package/dist/core/shared/errors.js +1 -20
- package/dist/core/shared/html-entity-decode.js +1 -131
- package/dist/core/shared/index.js +1 -12
- package/dist/core/shared/item-metadata-contract.js +1 -89
- package/dist/core/shared/lazy-module.js +1 -16
- package/dist/core/shared/levenshtein.js +1 -61
- package/dist/core/shared/memo.js +1 -19
- package/dist/core/shared/numeric-parsers.js +1 -20
- package/dist/core/shared/option-alias-visibility.js +1 -67
- package/dist/core/shared/primitives.js +1 -127
- package/dist/core/shared/serial-queue.js +1 -79
- package/dist/core/shared/serialization.js +1 -210
- package/dist/core/shared/split-comma-list.js +1 -30
- package/dist/core/shared/text-normalization.js +1 -38
- package/dist/core/shared/time.js +1 -306
- package/dist/core/store/index.js +1 -12
- package/dist/core/store/item-format-migration.js +1 -125
- package/dist/core/store/item-metadata-cache.js +1 -1116
- package/dist/core/store/item-metadata-query-index.js +9 -394
- package/dist/core/store/item-metadata-read-work.js +1 -43
- package/dist/core/store/item-store.js +1 -693
- package/dist/core/store/paths.d.ts +1 -1
- package/dist/core/store/paths.js +1 -214
- package/dist/core/store/settings-read-cache.js +1 -85
- package/dist/core/store/settings-validator.js +1 -421
- package/dist/core/store/settings.js +3 -1309
- package/dist/core/store/tracker-preflight.js +1 -141
- package/dist/core/telemetry/consent.js +5 -108
- package/dist/core/telemetry/observability.js +1 -246
- package/dist/core/telemetry/runtime.js +4 -1988
- package/dist/core/test/background-runs.js +4 -945
- package/dist/core/test/item-test-run-tracking.js +1 -63
- package/dist/core/test/run-selectors.js +1 -120
- package/dist/core/validate/estimate-defaults.js +1 -89
- package/dist/core/validate/fix-planning.js +1 -189
- package/dist/core/validate/linked-artifact-reference.js +1 -36
- package/dist/core/validate/missing-by-type.js +1 -34
- package/dist/core/validate/missing-link-owners.js +1 -95
- package/dist/core/validate/stale-file-classification.js +1 -82
- package/dist/mcp/http-server.js +5 -448
- package/dist/mcp/legacy-adapter.js +1 -77
- package/dist/mcp/runtime-capabilities.js +1 -200
- package/dist/mcp/server.js +4 -1233
- package/dist/mcp/tool-definitions.js +1 -804
- package/dist/sdk/actionability.js +1 -13
- package/dist/sdk/agent/closed-domain-contracts.js +1 -161
- package/dist/sdk/agent/command-recovery.js +1 -59
- package/dist/sdk/agent/command-suggestions.js +1 -66
- package/dist/sdk/agent/create-option-policy.js +1 -31
- package/dist/sdk/agent/identity-config.js +1 -106
- package/dist/sdk/agent/item-addressing.js +1 -207
- package/dist/sdk/agent/refusal-closure-census.js +1 -151
- package/dist/sdk/agent/refusal-closure.js +1 -133
- package/dist/sdk/agent/refusal-corpus-contracts.js +1 -193
- package/dist/sdk/agent/refusal-reachability.js +1 -593
- package/dist/sdk/agent/subcommand-recovery.js +1 -83
- package/dist/sdk/agent/task-transcript-contracts.js +1 -197
- package/dist/sdk/agent/tracker-preflight-contracts.js +1 -126
- package/dist/sdk/agent-capability-contracts.js +1 -428
- package/dist/sdk/agent-session-context.js +1 -9
- package/dist/sdk/annotations.js +1 -448
- package/dist/sdk/author-attribution.js +1 -468
- package/dist/sdk/authoring.js +1 -20
- package/dist/sdk/cli-bootstrap.js +1 -838
- package/dist/sdk/cli-contracts/agent-output-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts/agent-output-contracts.js +4 -476
- package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -79
- package/dist/sdk/cli-contracts/command-aliases.d.ts +4 -0
- package/dist/sdk/cli-contracts/command-aliases.js +1 -107
- package/dist/sdk/cli-contracts/command-exit-contracts.js +1 -151
- package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1081
- package/dist/sdk/cli-contracts/commander-types.js +1 -159
- package/dist/sdk/cli-contracts/completeness.js +1 -393
- package/dist/sdk/cli-contracts/enum-contracts.js +1 -222
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1947
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -347
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -986
- package/dist/sdk/cli-contracts/registration-helpers.js +7 -990
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +5 -0
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -2090
- package/dist/sdk/cli-contracts/schemas/assurance-definition.js +1 -324
- package/dist/sdk/cli-contracts/string-lists.js +1 -16
- package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -461
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -2167
- package/dist/sdk/cli-contracts/tool-schema.d.ts +3 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1664
- package/dist/sdk/cli-contracts/typed-action-inputs.js +1 -4
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +1 -17
- package/dist/sdk/cli-program.js +1 -49
- package/dist/sdk/command-line.d.ts +2 -5
- package/dist/sdk/command-line.js +1 -78
- package/dist/sdk/comments.js +1 -133
- package/dist/sdk/compile-cache.js +1 -73
- package/dist/sdk/completion.js +157 -837
- package/dist/sdk/compose.js +1 -1090
- package/dist/sdk/config.js +1 -1204
- package/dist/sdk/context/recency.js +1 -33
- package/dist/sdk/context/semantic-session-attribution.js +1 -82
- package/dist/sdk/context/usage-egress.js +1 -29
- package/dist/sdk/context/usage-ledger.js +3 -185
- package/dist/sdk/context-intent-contracts.js +1 -709
- package/dist/sdk/context-intent-runtime.js +1 -115
- package/dist/sdk/context-packing.js +1 -218
- package/dist/sdk/context-relevance.js +1 -503
- package/dist/sdk/context-signal-store.js +2 -426
- package/dist/sdk/context-usage.js +1 -367
- package/dist/sdk/contracts.js +1 -23
- package/dist/sdk/core-governance.js +1 -14
- package/dist/sdk/core.js +1 -14
- package/dist/sdk/corpus-shape.js +1 -401
- package/dist/sdk/define.js +1 -220
- package/dist/sdk/dependencies.js +1 -718
- package/dist/sdk/dependency-flag-validation.js +1 -156
- package/dist/sdk/dependency-provenance.js +1 -135
- package/dist/sdk/docs.js +1 -14
- package/dist/sdk/duplicates.js +1 -40
- package/dist/sdk/environment/agent-environment.js +1 -466
- package/dist/sdk/environment/host-environment-errors.js +1 -8
- package/dist/sdk/environment/project-runtime-compatibility.js +1 -481
- package/dist/sdk/environment/source-context.js +1 -28
- package/dist/sdk/environment/tracker-preflight.js +1 -9
- package/dist/sdk/error-code-catalog.js +1 -153
- package/dist/sdk/error-runtime.js +1 -58
- package/dist/sdk/errors.js +1 -58
- package/dist/sdk/eval.js +1 -190
- package/dist/sdk/extension/author-manifest.js +1 -92
- package/dist/sdk/extension/bundled-catalog.js +1 -332
- package/dist/sdk/extension/concurrency.js +1 -25
- package/dist/sdk/extension/copy-scope.d.ts +2 -0
- package/dist/sdk/extension/copy-scope.js +2 -0
- package/dist/sdk/extension/custom-field-collisions.js +1 -30
- package/dist/sdk/extension/describe.js +3 -189
- package/dist/sdk/extension/doctor.js +1 -606
- package/dist/sdk/extension/install-plan.d.ts +69 -0
- package/dist/sdk/extension/install-plan.js +2 -0
- package/dist/sdk/extension/install-receipts.d.ts +7 -0
- package/dist/sdk/extension/install-receipts.js +2 -0
- package/dist/sdk/extension/install-runtime.js +3 -313
- package/dist/sdk/extension/install-snapshot.js +1 -66
- package/dist/sdk/extension/install-sources.js +5 -1057
- package/dist/sdk/extension/managed-state.js +2 -252
- package/dist/sdk/extension/migrations.js +2 -174
- package/dist/sdk/extension/output-ownership.js +1 -25
- package/dist/sdk/extension/runtime-summary.js +1 -18
- package/dist/sdk/extension/scaffold.js +4 -2308
- package/dist/sdk/extension/shared.js +1 -147
- package/dist/sdk/extension/source-resolution.js +1 -65
- package/dist/sdk/extension/update-check.js +1 -67
- package/dist/sdk/extension-command-context.js +1 -44
- package/dist/sdk/extension-contracts.js +1 -73
- package/dist/sdk/extension.d.ts +7 -2
- package/dist/sdk/extension.js +1 -2196
- package/dist/sdk/files.js +1 -535
- package/dist/sdk/flag-invocation-contracts.d.ts +0 -5
- package/dist/sdk/flag-invocation-contracts.js +1 -344
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -2224
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -2236
- package/dist/sdk/generated-error-code-catalog.js +1 -16
- package/dist/sdk/governance/assurance-action-contracts.js +1 -4
- package/dist/sdk/governance/assurance-action.js +1 -411
- package/dist/sdk/governance/assurance-limits.js +1 -10
- package/dist/sdk/governance/assurance-mutation-error.js +1 -81
- package/dist/sdk/governance/assurance-presets.js +1 -135
- package/dist/sdk/governance/assurance-runtime.js +1 -238
- package/dist/sdk/governance/assurance.js +4 -1182
- package/dist/sdk/governance/boundary-fixtures.js +1 -200
- package/dist/sdk/governance/coverage-assurance.js +1 -60
- package/dist/sdk/governance/defect-recurrence-coverage.js +1 -188
- package/dist/sdk/governance/defect-recurrence-graph.js +1 -120
- package/dist/sdk/governance/defect-recurrence-signals.js +1 -24
- package/dist/sdk/governance/defect-recurrence.js +1 -623
- package/dist/sdk/governance/extension-host-version.js +1 -115
- package/dist/sdk/governance/gc.js +1 -368
- package/dist/sdk/governance/health.js +1 -2367
- package/dist/sdk/governance/hierarchy-validation.js +1 -108
- package/dist/sdk/governance/linked-file-report.js +1 -71
- package/dist/sdk/governance/merge-receipt-history.js +1 -206
- package/dist/sdk/governance/provenance-health.js +1 -282
- package/dist/sdk/governance/reindex.js +4 -761
- package/dist/sdk/governance/stale-work.js +1 -82
- package/dist/sdk/governance/status-role-diagnostics.js +1 -35
- package/dist/sdk/governance/storage-integrity.js +1 -280
- package/dist/sdk/governance/tracked-runtime-cache.js +1 -106
- package/dist/sdk/governance/upgrade.js +2 -327
- package/dist/sdk/governance/validate-history-drift.js +1 -81
- package/dist/sdk/governance/validate-item-reader.js +1 -17
- package/dist/sdk/governance/validate-normalization.js +1 -36
- package/dist/sdk/governance/validate.js +1 -2261
- package/dist/sdk/governance/workspace-position.js +1 -163
- package/dist/sdk/governance.d.ts +1 -0
- package/dist/sdk/governance.js +1 -31
- package/dist/sdk/graph/adapter.js +1 -181
- package/dist/sdk/graph/analytics.js +1 -474
- package/dist/sdk/graph/assembly.js +1 -377
- package/dist/sdk/graph/cache.js +1 -160
- package/dist/sdk/graph/centrality.js +1 -258
- package/dist/sdk/graph/conformance.js +1 -130
- package/dist/sdk/graph/deadline-scheduling.d.ts +90 -0
- package/dist/sdk/graph/deadline-scheduling.js +2 -0
- package/dist/sdk/graph/durable-cache.d.ts +1 -1
- package/dist/sdk/graph/durable-cache.js +1 -361
- package/dist/sdk/graph/governance-contracts.js +1 -34
- package/dist/sdk/graph/governance.d.ts +13 -1
- package/dist/sdk/graph/governance.js +1 -735
- package/dist/sdk/graph/hierarchy-integrity.js +1 -310
- package/dist/sdk/graph/index.d.ts +3 -2
- package/dist/sdk/graph/index.js +1 -26
- package/dist/sdk/graph/lifecycle-coverage.d.ts +32 -0
- package/dist/sdk/graph/lifecycle-coverage.js +2 -0
- package/dist/sdk/graph/mutation-advisory.js +1 -176
- package/dist/sdk/graph/remediation.js +1 -197
- package/dist/sdk/graph/run.d.ts +15 -1
- package/dist/sdk/graph/run.js +1 -768
- package/dist/sdk/graph/scheduling.js +1 -124
- package/dist/sdk/graph/traversal.js +1 -284
- package/dist/sdk/graph/workspace-relationship-kind-registry.js +1 -27
- package/dist/sdk/graph.js +1 -15
- package/dist/sdk/guide-topics.js +1 -707
- package/dist/sdk/guide.js +1 -279
- package/dist/sdk/history/maintenance.d.ts +71 -0
- package/dist/sdk/history/maintenance.js +2 -0
- package/dist/sdk/history/salvage.js +2 -247
- package/dist/sdk/history/subject.d.ts +19 -0
- package/dist/sdk/history/subject.js +2 -0
- package/dist/sdk/history-analytics.js +1 -282
- package/dist/sdk/history-compact.js +1 -527
- package/dist/sdk/history-mcp.js +1 -68
- package/dist/sdk/history-provenance.js +1 -182
- package/dist/sdk/history-read.js +1 -96
- package/dist/sdk/history-redact.d.ts +1 -14
- package/dist/sdk/history-redact.js +1 -643
- package/dist/sdk/history-repair.d.ts +5 -0
- package/dist/sdk/history-repair.js +1 -657
- package/dist/sdk/improvement-ledger-validation.js +1 -62
- package/dist/sdk/improvement-ledger.js +2 -257
- package/dist/sdk/index.d.ts +4 -0
- package/dist/sdk/index.js +1 -183
- package/dist/sdk/init-agent-guidance.js +2 -496
- package/dist/sdk/init.js +2 -820
- package/dist/sdk/invocation-author.js +1 -39
- package/dist/sdk/item-children.js +1 -90
- package/dist/sdk/item-metadata-index.js +1 -15
- package/dist/sdk/item-schedule.js +1 -27
- package/dist/sdk/item-transaction.js +1 -396
- package/dist/sdk/learnings.js +1 -29
- package/dist/sdk/lifecycle/append.js +2 -53
- package/dist/sdk/lifecycle/claim.d.ts +2 -0
- package/dist/sdk/lifecycle/claim.js +1 -242
- package/dist/sdk/lifecycle/close-many.js +1 -438
- package/dist/sdk/lifecycle/close.js +1 -468
- package/dist/sdk/lifecycle/copy.js +1 -212
- package/dist/sdk/lifecycle/create.js +1 -1949
- package/dist/sdk/lifecycle/delete.js +1 -45
- package/dist/sdk/lifecycle/event-validation-messages.js +1 -91
- package/dist/sdk/lifecycle/focus.js +1 -91
- package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -24
- package/dist/sdk/lifecycle/legacy-none-tokens.js +1 -149
- package/dist/sdk/lifecycle/lifecycle-transitions.js +1 -40
- package/dist/sdk/lifecycle/mcp-actions.d.ts +2 -0
- package/dist/sdk/lifecycle/mcp-actions.js +1 -51
- package/dist/sdk/lifecycle/metadata-normalizers.js +1 -46
- package/dist/sdk/lifecycle/mutation-command-options.js +1 -9
- package/dist/sdk/lifecycle/plan.js +1 -1606
- package/dist/sdk/lifecycle/recurrence-parsers.js +1 -147
- package/dist/sdk/lifecycle/reopen.js +1 -68
- package/dist/sdk/lifecycle/repeatable-metadata-parsers.js +1 -143
- package/dist/sdk/lifecycle/restore.d.ts +1 -0
- package/dist/sdk/lifecycle/restore.js +1 -330
- package/dist/sdk/lifecycle/shared-unset-fields.js +1 -295
- package/dist/sdk/lifecycle/update-many.js +1 -861
- package/dist/sdk/lifecycle/update.js +1 -2136
- package/dist/sdk/lifecycle-completion.js +1 -92
- package/dist/sdk/lifecycle-policy.js +1 -120
- package/dist/sdk/linked-artifacts.js +1 -530
- package/dist/sdk/mcp/apps.js +4 -133
- package/dist/sdk/mcp/authorization.js +1 -404
- package/dist/sdk/mcp/discovery.js +1 -494
- package/dist/sdk/mcp/interactions.js +1 -336
- package/dist/sdk/mcp/protocol.d.ts +7 -0
- package/dist/sdk/mcp/protocol.js +1 -184
- package/dist/sdk/mcp/skills.js +1 -389
- package/dist/sdk/mcp/subscriptions.js +1 -211
- package/dist/sdk/mcp/tasks.js +2 -430
- package/dist/sdk/mcp/transport.js +1 -260
- package/dist/sdk/merge/abandoned-receipts.js +1 -46
- package/dist/sdk/merge/driver.js +1 -212
- package/dist/sdk/merge/index.js +1 -16
- package/dist/sdk/merge/install.js +3 -561
- package/dist/sdk/merge/receipt-file-boundary.js +1 -46
- package/dist/sdk/merge/receipt-operation.js +1 -96
- package/dist/sdk/merge/receipt-schema.js +1 -397
- package/dist/sdk/merge/receipts.js +4 -525
- package/dist/sdk/merge/reconcile.js +1 -352
- package/dist/sdk/merge/three-way.js +3 -775
- package/dist/sdk/merge.js +1 -10
- package/dist/sdk/mutation-events.js +1 -292
- package/dist/sdk/mutation-guard.js +1 -216
- package/dist/sdk/notes.js +1 -139
- package/dist/sdk/output-contracts.js +1 -172
- package/dist/sdk/output-projection.js +1 -430
- package/dist/sdk/output-token-accounting.js +1 -140
- package/dist/sdk/output.js +1 -64
- package/dist/sdk/ownership-source.js +1 -21
- package/dist/sdk/package-import-adapters.js +1 -442
- package/dist/sdk/package-migrations.js +1 -20
- package/dist/sdk/package-runtime-options.js +1 -80
- package/dist/sdk/pagination.js +1 -162
- package/dist/sdk/profile.js +1 -454
- package/dist/sdk/provenance.js +1 -258
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/activity.js +1 -401
- package/dist/sdk/query/aggregate.d.ts +16 -0
- package/dist/sdk/query/aggregate.js +1 -390
- package/dist/sdk/query/calendar.js +1 -964
- package/dist/sdk/query/complete-list.js +1 -215
- package/dist/sdk/query/context.js +1 -1702
- package/dist/sdk/query/duplicate-candidates.js +1 -70
- package/dist/sdk/query/get.js +1 -450
- package/dist/sdk/query/history.js +1 -186
- package/dist/sdk/query/item-filter-options.js +1 -9
- package/dist/sdk/query/light-metadata.js +1 -18
- package/dist/sdk/query/list-filter-shared.js +1 -81
- package/dist/sdk/query/list.js +1 -1304
- package/dist/sdk/query/multi-value-filters.js +1 -78
- package/dist/sdk/query/next.js +1 -513
- package/dist/sdk/query/parsers.js +1 -44
- package/dist/sdk/query/projection-contracts.js +1 -184
- package/dist/sdk/query/search-contracts.js +1 -230
- package/dist/sdk/query/search-pagination.js +1 -35
- package/dist/sdk/query/search-rendering.js +1 -105
- package/dist/sdk/query/search.js +2 -1987
- package/dist/sdk/query.js +1 -35
- package/dist/sdk/read-output/continuation.js +1 -194
- package/dist/sdk/read-output-budget.js +1 -135
- package/dist/sdk/read-output-contracts.js +1 -1225
- package/dist/sdk/read-output-rows.js +1 -186
- package/dist/sdk/read-output-session.js +1 -208
- package/dist/sdk/relationship-analytics.js +1 -410
- package/dist/sdk/relationship-context.js +1 -284
- package/dist/sdk/relationship-history.js +4 -519
- package/dist/sdk/relationship-kinds/contract.js +1 -22
- package/dist/sdk/relationship-migration.js +1 -77
- package/dist/sdk/relationships.js +1 -579
- package/dist/sdk/reproducibility/process.js +1 -87
- package/dist/sdk/runtime-action-aliases.js +1 -59
- package/dist/sdk/runtime-extended-actions.js +1 -177
- package/dist/sdk/runtime-input.js +1 -614
- package/dist/sdk/runtime-primitives.js +1 -84
- package/dist/sdk/runtime-public-contracts.js +1 -4
- package/dist/sdk/runtime-stats-options.js +1 -38
- package/dist/sdk/runtime.js +1 -1928
- package/dist/sdk/scheduling-shortcuts.js +1 -63
- package/dist/sdk/schema-migration.js +3 -856
- package/dist/sdk/schema.js +1 -1376
- package/dist/sdk/search-refresh-worker.js +1 -18
- package/dist/sdk/similarity-scoring.js +1 -53
- package/dist/sdk/similarity.js +1 -326
- package/dist/sdk/start-task-status.js +1 -14
- package/dist/sdk/stats.js +1 -270
- package/dist/sdk/structured-mutations.js +1 -580
- package/dist/sdk/telemetry-flush.js +1 -13
- package/dist/sdk/telemetry.js +1 -405
- package/dist/sdk/templates.js +2 -292
- package/dist/sdk/test/batch.js +2 -509
- package/dist/sdk/test/entry.js +1 -70
- package/dist/sdk/test/execution.js +6 -2211
- package/dist/sdk/test/linked-command-detection.js +1 -546
- package/dist/sdk/test/measurements.js +1 -91
- package/dist/sdk/test/parsers.js +1 -545
- package/dist/sdk/test/runs.js +1 -193
- package/dist/sdk/test/trust.js +2 -206
- package/dist/sdk/testing.js +4 -1391
- package/dist/sdk/traceability/runtime-files-lookup.js +1 -32
- package/dist/sdk/traceability/source-traceability.js +1 -292
- package/dist/sdk/tracker-root-discovery.js +1 -9
- package/dist/sdk/workspace-contracts-cache.js +1 -28
- package/dist/sdk/workspace-contracts.js +1 -33
- package/dist/sdk/workspace-memory.js +2 -318
- package/dist/sdk/workspace-recipe.js +1 -71
- package/dist/sdk/workspace-snapshot.js +4 -613
- package/dist/sdk/workspace-transaction-gc.js +1 -149
- package/dist/sdk/workspace-transaction.js +2 -363
- package/dist/sdk/workspace.js +3 -127
- package/dist/types/index.js +1 -9
- package/dist/types.js +1 -245
- package/docs/AGENT_GUIDE.md +1 -1
- package/docs/CONTEXT_ALGORITHM_PORTFOLIO.md +167 -0
- package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +9 -3
- package/docs/EXTENSIONS.md +1 -0
- package/docs/HISTORY_MAINTENANCE.md +125 -0
- package/docs/MCP_2026_07_28_CONFORMANCE.md +20 -10
- package/docs/PACKAGE_EVIDENCE.md +92 -0
- package/docs/PLANNING_MEASUREMENTS.md +183 -0
- package/docs/README.md +3 -0
- package/docs/SCRIPTING.md +21 -0
- package/docs/TESTING.md +23 -0
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +5 -5
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +2 -2
- package/marketplace.json +2 -2
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/scripts/finalize-build.mjs +45 -3
- package/dist/cli-bundle/chunks/chunk-AZDFJGH6.js +0 -9
- package/dist/cli-bundle/chunks/chunk-BAX2BYUW.js +0 -2111
- package/dist/cli-bundle/chunks/chunk-CKOL5U7J.js +0 -77
- package/dist/cli-bundle/chunks/chunk-OF76PSDQ.js +0 -5
- package/dist/cli-bundle/chunks/chunk-QUWFABDM.js +0 -232
- package/dist/cli-bundle/chunks/chunk-QWRRFYK3.js +0 -2
- package/dist/cli-bundle/chunks/chunk-RWWBOWJ5.js +0 -2
- package/dist/cli-bundle/chunks/chunk-WGAOYSYH.js +0 -40
- package/dist/cli-bundle/chunks/chunk-WI2AYPA7.js +0 -2
- package/dist/cli-bundle/chunks/register-list-query-5JL52D33.js +0 -11
- package/dist/cli-bundle/chunks/register-mutation-ZPG7KMVP.js +0 -20
- package/dist/cli-bundle/chunks/register-setup-H4SVAVX7.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-AL5ON6K6.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-CHC2IDXA.js +0 -6
- package/dist/cli-bundle/focused-chunks/chunk-CK6QFAPZ.js +0 -20
- package/dist/cli-bundle/focused-chunks/chunk-EZR3GHFE.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-H2WJWK7L.js +0 -56
- package/dist/cli-bundle/focused-chunks/chunk-NTPY5GSO.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-P5O7MP5Y.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-PDMW2E36.js +0 -177
- package/dist/cli-bundle/focused-chunks/chunk-QTVCLMSZ.js +0 -6
- package/dist/cli-bundle/focused-chunks/chunk-QTZRBUYA.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-SGQST3PQ.js +0 -12
- package/dist/cli-bundle/focused-chunks/chunk-UKHASMMP.js +0 -10
- package/dist/cli-bundle/focused-chunks/chunk-ZPEKQHOC.js +0 -2
|
@@ -1,1310 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Reads and writes tracker storage with format-aware helpers for Settings.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5b95183e-9fd3-55cf-9059-8736f692e96e")}catch(e){}}();
|
|
8
|
-
import { validateSettings } from "./settings-validator.js";
|
|
9
|
-
import { runActiveOnReadHooks, runActiveOnWriteHooks, } from "../extensions/index.js";
|
|
10
|
-
import { GOVERNANCE_PRESET_DEFAULTS, SETTINGS_DEFAULTS, } from "../shared/constants.js";
|
|
11
|
-
import { resolveAuthor } from "../shared/author.js";
|
|
12
|
-
import { readFileIfExists } from "../fs/fs-utils.js";
|
|
13
|
-
import { writeWorkspaceJsonWithHistory } from "../history/workspace-history.js";
|
|
14
|
-
import { DEFAULT_RUNTIME_SCHEMA_FILE_PATHS, ensureRuntimeSchemaFileScaffold, filePathForSchemaSection, loadRuntimeSchemaFromOptionalFiles, normalizeRuntimeSchemaSettings, } from "../schema/runtime-schema.js";
|
|
15
|
-
import { getSettingsPath } from "./paths.js";
|
|
16
|
-
import { orderObject, stableValueEquals } from "../shared/serialization.js";
|
|
17
|
-
import { normalizeItemTypeDefinition } from "../item/item-type-definition.js";
|
|
18
|
-
import { normalizeEstimateDefaultOverrides } from "../validate/estimate-defaults.js";
|
|
19
|
-
import { clearSettingsReadCache, collectSettingsReadCacheSignatures, getSettingsReadCacheEntry, setSettingsReadCacheEntry, settingsReadCacheSignaturesEqual, } from "./settings-read-cache.js";
|
|
20
|
-
const SETTINGS_WRITE_OP = "settings:write";
|
|
21
|
-
const SETTINGS_PERSIST_SOURCE_SYMBOL = Symbol("pm.settings.persist_source");
|
|
22
|
-
const MAX_VECTOR_STORE_COLLECTION_NAME_LENGTH = 128;
|
|
23
|
-
const DUPLICATE_DETECTION_MODES = new Set(["off", "advisory", "strict"]);
|
|
24
|
-
function resolveGovernanceKnobsFromPreset(preset) {
|
|
25
|
-
return structuredClone(GOVERNANCE_PRESET_DEFAULTS[preset]);
|
|
26
|
-
}
|
|
27
|
-
function normalizeGovernancePreset(value) {
|
|
28
|
-
if (value === "minimal" ||
|
|
29
|
-
value === "default" ||
|
|
30
|
-
value === "strict" ||
|
|
31
|
-
value === "custom") {
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
34
|
-
return SETTINGS_DEFAULTS.governance.preset;
|
|
35
|
-
}
|
|
36
|
-
// Create defaults, workflow enforcement, and duplicate detection are orthogonal to the
|
|
37
|
-
// governance preset (they tune create/update behavior, not the preset knobs),
|
|
38
|
-
// so they must survive a write regardless of preset — otherwise a project on a
|
|
39
|
-
// non-custom preset would silently drop them on every settings write.
|
|
40
|
-
function withGovernanceExtras(base, governance) {
|
|
41
|
-
const createDefaultType = typeof governance.create_default_type === "string"
|
|
42
|
-
? governance.create_default_type.trim()
|
|
43
|
-
: undefined;
|
|
44
|
-
if (createDefaultType && createDefaultType.length > 0) {
|
|
45
|
-
base.create_default_type = createDefaultType;
|
|
46
|
-
}
|
|
47
|
-
if (governance.workflow_enforcement === "off" ||
|
|
48
|
-
governance.workflow_enforcement === "warn" ||
|
|
49
|
-
governance.workflow_enforcement === "strict") {
|
|
50
|
-
base.workflow_enforcement = governance.workflow_enforcement;
|
|
51
|
-
}
|
|
52
|
-
if (governance.require_close_reason === false) {
|
|
53
|
-
base.require_close_reason = false;
|
|
54
|
-
}
|
|
55
|
-
base.duplicate_detection_mode = governance.duplicate_detection_mode;
|
|
56
|
-
base.duplicate_detection_threshold = governance.duplicate_detection_threshold;
|
|
57
|
-
base.duplicate_detection_limit = governance.duplicate_detection_limit;
|
|
58
|
-
return base;
|
|
59
|
-
}
|
|
60
|
-
function normalizeGovernanceForPersist(governance) {
|
|
61
|
-
if (governance.preset === "custom") {
|
|
62
|
-
return withGovernanceExtras({
|
|
63
|
-
preset: "custom",
|
|
64
|
-
ownership_enforcement: governance.ownership_enforcement,
|
|
65
|
-
create_mode_default: governance.create_mode_default,
|
|
66
|
-
close_validation_default: governance.close_validation_default,
|
|
67
|
-
parent_reference: governance.parent_reference,
|
|
68
|
-
metadata_profile: governance.metadata_profile,
|
|
69
|
-
force_required_for_stale_lock: governance.force_required_for_stale_lock,
|
|
70
|
-
}, governance);
|
|
71
|
-
}
|
|
72
|
-
return withGovernanceExtras({
|
|
73
|
-
preset: governance.preset,
|
|
74
|
-
}, governance);
|
|
75
|
-
}
|
|
76
|
-
// Preset-orthogonal knobs that must be carried through resolve from the raw
|
|
77
|
-
// governance regardless of preset (see normalizeGovernanceForPersist).
|
|
78
|
-
function resolveGovernanceExtras(rawGovernance) {
|
|
79
|
-
const createDefaultType = typeof rawGovernance.create_default_type === "string"
|
|
80
|
-
? rawGovernance.create_default_type.trim()
|
|
81
|
-
: undefined;
|
|
82
|
-
const extras = {};
|
|
83
|
-
if (createDefaultType && createDefaultType.length > 0) {
|
|
84
|
-
extras.create_default_type = createDefaultType;
|
|
85
|
-
}
|
|
86
|
-
if (rawGovernance.workflow_enforcement === "off" ||
|
|
87
|
-
rawGovernance.workflow_enforcement === "warn" ||
|
|
88
|
-
rawGovernance.workflow_enforcement === "strict") {
|
|
89
|
-
extras.workflow_enforcement = rawGovernance.workflow_enforcement;
|
|
90
|
-
}
|
|
91
|
-
if (typeof rawGovernance.require_close_reason === "boolean") {
|
|
92
|
-
extras.require_close_reason = rawGovernance.require_close_reason;
|
|
93
|
-
}
|
|
94
|
-
if (DUPLICATE_DETECTION_MODES.has(String(rawGovernance.duplicate_detection_mode))) {
|
|
95
|
-
extras.duplicate_detection_mode =
|
|
96
|
-
rawGovernance.duplicate_detection_mode;
|
|
97
|
-
}
|
|
98
|
-
const threshold = rawGovernance.duplicate_detection_threshold;
|
|
99
|
-
if ([
|
|
100
|
-
typeof threshold === "number",
|
|
101
|
-
Number.isFinite(threshold),
|
|
102
|
-
Number(threshold) >= 0,
|
|
103
|
-
Number(threshold) <= 1,
|
|
104
|
-
].every(Boolean)) {
|
|
105
|
-
extras.duplicate_detection_threshold = threshold;
|
|
106
|
-
}
|
|
107
|
-
const limit = rawGovernance.duplicate_detection_limit;
|
|
108
|
-
if ([
|
|
109
|
-
typeof limit === "number",
|
|
110
|
-
Number.isSafeInteger(limit),
|
|
111
|
-
Number(limit) >= 0,
|
|
112
|
-
Number(limit) <= 20,
|
|
113
|
-
].every(Boolean)) {
|
|
114
|
-
extras.duplicate_detection_limit = limit;
|
|
115
|
-
}
|
|
116
|
-
return extras;
|
|
117
|
-
}
|
|
118
|
-
/** Implements resolve governance knobs for the public runtime surface of this module. */
|
|
119
|
-
export function resolveGovernanceKnobs(settings) {
|
|
120
|
-
const rawGovernance = settings.governance ?? {};
|
|
121
|
-
const preset = normalizeGovernancePreset(rawGovernance.preset);
|
|
122
|
-
const extras = resolveGovernanceExtras(rawGovernance);
|
|
123
|
-
if (preset === "custom") {
|
|
124
|
-
const baseline = resolveGovernanceKnobsFromPreset("default");
|
|
125
|
-
const requireCloseReason = extras.require_close_reason ?? baseline.require_close_reason;
|
|
126
|
-
return {
|
|
127
|
-
preset,
|
|
128
|
-
ownership_enforcement: rawGovernance.ownership_enforcement ?? baseline.ownership_enforcement,
|
|
129
|
-
create_mode_default: rawGovernance.create_mode_default ?? baseline.create_mode_default,
|
|
130
|
-
close_validation_default: rawGovernance.close_validation_default ??
|
|
131
|
-
baseline.close_validation_default,
|
|
132
|
-
parent_reference: rawGovernance.parent_reference ?? baseline.parent_reference,
|
|
133
|
-
metadata_profile: rawGovernance.metadata_profile ?? baseline.metadata_profile,
|
|
134
|
-
force_required_for_stale_lock: rawGovernance.force_required_for_stale_lock ??
|
|
135
|
-
baseline.force_required_for_stale_lock,
|
|
136
|
-
...extras,
|
|
137
|
-
require_close_reason: requireCloseReason,
|
|
138
|
-
duplicate_detection_mode: extras.duplicate_detection_mode ?? baseline.duplicate_detection_mode,
|
|
139
|
-
duplicate_detection_threshold: extras.duplicate_detection_threshold ??
|
|
140
|
-
baseline.duplicate_detection_threshold,
|
|
141
|
-
duplicate_detection_limit: extras.duplicate_detection_limit ?? baseline.duplicate_detection_limit,
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
const baseline = resolveGovernanceKnobsFromPreset(preset);
|
|
145
|
-
const requireCloseReason = extras.require_close_reason ?? baseline.require_close_reason;
|
|
146
|
-
return {
|
|
147
|
-
preset,
|
|
148
|
-
...baseline,
|
|
149
|
-
...extras,
|
|
150
|
-
require_close_reason: requireCloseReason,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
function cloneDefaults() {
|
|
154
|
-
return structuredClone(SETTINGS_DEFAULTS);
|
|
155
|
-
}
|
|
156
|
-
function normalizeSearchMutationRefreshPolicy(value) {
|
|
157
|
-
if (value === "cache_only" ||
|
|
158
|
-
value === "semantic_configured" ||
|
|
159
|
-
value === "semantic_auto") {
|
|
160
|
-
return value;
|
|
161
|
-
}
|
|
162
|
-
return SETTINGS_DEFAULTS.search.mutation_refresh_policy;
|
|
163
|
-
}
|
|
164
|
-
function normalizeSearchQueryExpansionEnabled(value) {
|
|
165
|
-
if (typeof value === "boolean") {
|
|
166
|
-
return value;
|
|
167
|
-
}
|
|
168
|
-
return SETTINGS_DEFAULTS.search.query_expansion.enabled;
|
|
169
|
-
}
|
|
170
|
-
function normalizeSearchQueryExpansionProvider(value) {
|
|
171
|
-
if (typeof value !== "string") {
|
|
172
|
-
return SETTINGS_DEFAULTS.search.query_expansion.provider;
|
|
173
|
-
}
|
|
174
|
-
return value.trim();
|
|
175
|
-
}
|
|
176
|
-
function normalizeSearchRerankEnabled(value) {
|
|
177
|
-
if (typeof value === "boolean") {
|
|
178
|
-
return value;
|
|
179
|
-
}
|
|
180
|
-
return SETTINGS_DEFAULTS.search.rerank.enabled;
|
|
181
|
-
}
|
|
182
|
-
function normalizeSearchRerankModel(value) {
|
|
183
|
-
if (typeof value !== "string") {
|
|
184
|
-
return SETTINGS_DEFAULTS.search.rerank.model;
|
|
185
|
-
}
|
|
186
|
-
return value.trim();
|
|
187
|
-
}
|
|
188
|
-
function normalizeSearchRerankTopK(value) {
|
|
189
|
-
if (typeof value === "number" &&
|
|
190
|
-
Number.isFinite(value) &&
|
|
191
|
-
Number.isInteger(value) &&
|
|
192
|
-
value > 0) {
|
|
193
|
-
return value;
|
|
194
|
-
}
|
|
195
|
-
return SETTINGS_DEFAULTS.search.rerank.top_k;
|
|
196
|
-
}
|
|
197
|
-
function normalizeVectorStoreCollectionName(value) {
|
|
198
|
-
if (typeof value !== "string") {
|
|
199
|
-
return SETTINGS_DEFAULTS.vector_store.collection_name;
|
|
200
|
-
}
|
|
201
|
-
const sanitized = value.trim().replaceAll(/[^a-zA-Z0-9_-]/g, "_");
|
|
202
|
-
const truncated = sanitized.slice(0, MAX_VECTOR_STORE_COLLECTION_NAME_LENGTH);
|
|
203
|
-
return truncated.length > 0
|
|
204
|
-
? truncated
|
|
205
|
-
: SETTINGS_DEFAULTS.vector_store.collection_name;
|
|
206
|
-
}
|
|
207
|
-
function cloneOptionalArray(value) {
|
|
208
|
-
return {
|
|
209
|
-
present: Array.isArray(value),
|
|
210
|
-
values: Array.isArray(value) ? structuredClone(value) : [],
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
function buildSettingsPersistSourceSnapshot(parsedSettings, runtimeSettings) {
|
|
214
|
-
const sourceSchema = parsedSettings.schema;
|
|
215
|
-
const sourceStatuses = cloneOptionalArray(sourceSchema?.statuses);
|
|
216
|
-
const sourceFields = cloneOptionalArray(sourceSchema?.fields);
|
|
217
|
-
const sourceTypeWorkflows = cloneOptionalArray(sourceSchema?.type_workflows);
|
|
218
|
-
return {
|
|
219
|
-
source_settings: structuredClone(parsedSettings),
|
|
220
|
-
has_source_item_type_definitions: Array.isArray(parsedSettings.item_types?.definitions),
|
|
221
|
-
source_item_type_definitions: normalizeItemTypeDefinitions(parsedSettings.item_types?.definitions),
|
|
222
|
-
has_source_schema_statuses: sourceStatuses.present,
|
|
223
|
-
source_schema_statuses: sourceStatuses.values,
|
|
224
|
-
has_source_schema_fields: sourceFields.present,
|
|
225
|
-
source_schema_fields: sourceFields.values,
|
|
226
|
-
has_source_schema_type_workflows: sourceTypeWorkflows.present,
|
|
227
|
-
source_schema_type_workflows: sourceTypeWorkflows.values,
|
|
228
|
-
runtime_item_type_definitions: normalizeItemTypeDefinitions(runtimeSettings.item_types?.definitions),
|
|
229
|
-
runtime_schema_statuses: structuredClone(runtimeSettings.schema.statuses),
|
|
230
|
-
runtime_schema_fields: structuredClone(runtimeSettings.schema.fields),
|
|
231
|
-
runtime_schema_type_workflows: structuredClone(runtimeSettings.schema.type_workflows ?? []),
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
function attachSettingsPersistSourceSnapshot(settings, source) {
|
|
235
|
-
Object.defineProperty(settings, SETTINGS_PERSIST_SOURCE_SYMBOL, {
|
|
236
|
-
value: source,
|
|
237
|
-
writable: true,
|
|
238
|
-
configurable: true,
|
|
239
|
-
enumerable: false,
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
function getSettingsPersistSourceSnapshot(settings) {
|
|
243
|
-
const candidate = settings[SETTINGS_PERSIST_SOURCE_SYMBOL];
|
|
244
|
-
if (!candidate || typeof candidate !== "object") {
|
|
245
|
-
return undefined;
|
|
246
|
-
}
|
|
247
|
-
return candidate;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Mark the runtime-selected item format as intentional persisted state while
|
|
251
|
-
* preserving every other default-backed setting as a sparse omission.
|
|
252
|
-
*/
|
|
253
|
-
export function persistSelectedItemFormat(settings) {
|
|
254
|
-
const source = getSettingsPersistSourceSnapshot(settings);
|
|
255
|
-
if (source) {
|
|
256
|
-
const detachedSource = structuredClone(source);
|
|
257
|
-
detachedSource.source_settings.item_format = settings.item_format;
|
|
258
|
-
attachSettingsPersistSourceSnapshot(settings, detachedSource);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
function cloneSettingsReadResult(result) {
|
|
262
|
-
const clonedSettings = structuredClone(result.settings);
|
|
263
|
-
const persistSource = getSettingsPersistSourceSnapshot(result.settings);
|
|
264
|
-
if (persistSource) {
|
|
265
|
-
attachSettingsPersistSourceSnapshot(clonedSettings, persistSource);
|
|
266
|
-
}
|
|
267
|
-
return {
|
|
268
|
-
settings: clonedSettings,
|
|
269
|
-
metadata: {
|
|
270
|
-
has_explicit_item_format: result.metadata.has_explicit_item_format,
|
|
271
|
-
},
|
|
272
|
-
warnings: [...result.warnings],
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
function resolveSettingsReadTrackedPaths(pmRoot, schema, settingsPath) {
|
|
276
|
-
const normalizedSchema = normalizeRuntimeSchemaSettings(schema);
|
|
277
|
-
return [
|
|
278
|
-
settingsPath,
|
|
279
|
-
filePathForSchemaSection(pmRoot, normalizedSchema.files.types, DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.types),
|
|
280
|
-
filePathForSchemaSection(pmRoot, normalizedSchema.files.statuses, DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.statuses),
|
|
281
|
-
filePathForSchemaSection(pmRoot, normalizedSchema.files.fields, DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.fields),
|
|
282
|
-
filePathForSchemaSection(pmRoot, normalizedSchema.files.workflows, DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.workflows),
|
|
283
|
-
];
|
|
284
|
-
}
|
|
285
|
-
async function cacheSettingsReadResult(pmRoot, trackedPaths, result) {
|
|
286
|
-
const signatures = await collectSettingsReadCacheSignatures(trackedPaths);
|
|
287
|
-
setSettingsReadCacheEntry(pmRoot, {
|
|
288
|
-
tracked_paths: trackedPaths,
|
|
289
|
-
signatures,
|
|
290
|
-
value: cloneSettingsReadResult(result),
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
async function cacheSettingsReadResultSafe(pmRoot, trackedPaths, result) {
|
|
294
|
-
try {
|
|
295
|
-
await cacheSettingsReadResult(pmRoot, trackedPaths, result);
|
|
296
|
-
}
|
|
297
|
-
catch {
|
|
298
|
-
clearSettingsReadCache(pmRoot);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
function findSettingsReadCacheSignature(signatures, targetPath) {
|
|
302
|
-
return signatures.find((signature) => signature.path === targetPath);
|
|
303
|
-
}
|
|
304
|
-
function selectedSettingsReadCacheSignaturesEqual(before, after, targetPaths) {
|
|
305
|
-
for (const targetPath of targetPaths) {
|
|
306
|
-
const beforeSignature = findSettingsReadCacheSignature(before, targetPath);
|
|
307
|
-
const afterSignature = findSettingsReadCacheSignature(after, targetPath);
|
|
308
|
-
if (!beforeSignature ||
|
|
309
|
-
!afterSignature ||
|
|
310
|
-
!settingsReadCacheSignaturesEqual([beforeSignature], [afterSignature])) {
|
|
311
|
-
return false;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
return true;
|
|
315
|
-
}
|
|
316
|
-
async function cacheSettingsReadResultIfStable(pmRoot, trackedPaths, result, stableSignatures, stablePaths) {
|
|
317
|
-
try {
|
|
318
|
-
const currentSignatures = await collectSettingsReadCacheSignatures(trackedPaths);
|
|
319
|
-
if (!selectedSettingsReadCacheSignaturesEqual(stableSignatures, currentSignatures, stablePaths)) {
|
|
320
|
-
clearSettingsReadCache(pmRoot);
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
setSettingsReadCacheEntry(pmRoot, {
|
|
324
|
-
tracked_paths: trackedPaths,
|
|
325
|
-
signatures: currentSignatures,
|
|
326
|
-
value: cloneSettingsReadResult(result),
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
catch {
|
|
330
|
-
clearSettingsReadCache(pmRoot);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
function resolvePersistedFileBackedSchemaSections(settings, source) {
|
|
334
|
-
const normalizedSchema = normalizeRuntimeSchemaSettings(settings.schema);
|
|
335
|
-
const currentItemTypeDefinitions = normalizeItemTypeDefinitions(settings.item_types?.definitions);
|
|
336
|
-
if (!source) {
|
|
337
|
-
return {
|
|
338
|
-
item_type_definitions: currentItemTypeDefinitions,
|
|
339
|
-
schema_statuses: normalizedSchema.statuses,
|
|
340
|
-
schema_fields: normalizedSchema.fields,
|
|
341
|
-
schema_type_workflows: normalizedSchema.type_workflows,
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
const currentTypeWorkflows = normalizedSchema.type_workflows ?? [];
|
|
345
|
-
const itemTypeDefinitionsUnchanged = stableValueEquals(currentItemTypeDefinitions, source.runtime_item_type_definitions);
|
|
346
|
-
const schemaStatusesUnchanged = stableValueEquals(normalizedSchema.statuses, source.runtime_schema_statuses);
|
|
347
|
-
const schemaFieldsUnchanged = stableValueEquals(normalizedSchema.fields, source.runtime_schema_fields);
|
|
348
|
-
const schemaTypeWorkflowsUnchanged = stableValueEquals(currentTypeWorkflows, source.runtime_schema_type_workflows);
|
|
349
|
-
return {
|
|
350
|
-
item_type_definitions: itemTypeDefinitionsUnchanged
|
|
351
|
-
? source.has_source_item_type_definitions
|
|
352
|
-
? normalizeItemTypeDefinitions(source.source_item_type_definitions)
|
|
353
|
-
: []
|
|
354
|
-
: currentItemTypeDefinitions,
|
|
355
|
-
schema_statuses: schemaStatusesUnchanged
|
|
356
|
-
? source.has_source_schema_statuses
|
|
357
|
-
? structuredClone(source.source_schema_statuses)
|
|
358
|
-
: []
|
|
359
|
-
: normalizedSchema.statuses,
|
|
360
|
-
schema_fields: schemaFieldsUnchanged
|
|
361
|
-
? source.has_source_schema_fields
|
|
362
|
-
? structuredClone(source.source_schema_fields)
|
|
363
|
-
: []
|
|
364
|
-
: normalizedSchema.fields,
|
|
365
|
-
schema_type_workflows: schemaTypeWorkflowsUnchanged
|
|
366
|
-
? source.has_source_schema_type_workflows
|
|
367
|
-
? structuredClone(source.source_schema_type_workflows)
|
|
368
|
-
: undefined
|
|
369
|
-
: normalizedSchema.type_workflows,
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
function buildFallbackSettingsReadResult(warning) {
|
|
373
|
-
return {
|
|
374
|
-
settings: cloneDefaults(),
|
|
375
|
-
metadata: {
|
|
376
|
-
has_explicit_item_format: false,
|
|
377
|
-
},
|
|
378
|
-
warnings: warning ? [warning] : [],
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
function hasExplicitItemFormat(raw) {
|
|
382
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
383
|
-
return false;
|
|
384
|
-
}
|
|
385
|
-
const itemFormat = raw.item_format;
|
|
386
|
-
return itemFormat === "toon" || itemFormat === "json_markdown";
|
|
387
|
-
}
|
|
388
|
-
function normalizeStringList(values) {
|
|
389
|
-
return [
|
|
390
|
-
...new Set((values ?? [])
|
|
391
|
-
.map((value) => value.trim())
|
|
392
|
-
.filter((value) => value.length > 0)),
|
|
393
|
-
].sort((left, right) => left.localeCompare(right));
|
|
394
|
-
}
|
|
395
|
-
function normalizeAgentGuidanceSettings(value) {
|
|
396
|
-
const defaults = SETTINGS_DEFAULTS.agent_guidance;
|
|
397
|
-
const templateVersion = value?.template_version;
|
|
398
|
-
return {
|
|
399
|
-
prompt_completed: value?.prompt_completed === true,
|
|
400
|
-
declined: value?.declined === true,
|
|
401
|
-
declined_at: typeof value?.declined_at === "string"
|
|
402
|
-
? value.declined_at
|
|
403
|
-
: defaults.declined_at,
|
|
404
|
-
template_version: typeof templateVersion === "number" &&
|
|
405
|
-
Number.isInteger(templateVersion) &&
|
|
406
|
-
templateVersion > 0
|
|
407
|
-
? templateVersion
|
|
408
|
-
: defaults.template_version,
|
|
409
|
-
last_checked_files: normalizeStringList(value?.last_checked_files ?? defaults.last_checked_files),
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
function normalizeLowerStringList(values) {
|
|
413
|
-
return [
|
|
414
|
-
...new Set((values ?? [])
|
|
415
|
-
.map((value) => value.trim().toLowerCase())
|
|
416
|
-
.filter((value) => value.length > 0)),
|
|
417
|
-
].sort((left, right) => left.localeCompare(right));
|
|
418
|
-
}
|
|
419
|
-
function normalizeExtensionPolicyMode(value) {
|
|
420
|
-
if (value === "off" || value === "warn" || value === "enforce") {
|
|
421
|
-
return value;
|
|
422
|
-
}
|
|
423
|
-
return SETTINGS_DEFAULTS.extensions.policy.mode;
|
|
424
|
-
}
|
|
425
|
-
function normalizeExtensionTrustMode(value) {
|
|
426
|
-
if (value === "off" || value === "warn" || value === "enforce") {
|
|
427
|
-
return value;
|
|
428
|
-
}
|
|
429
|
-
return SETTINGS_DEFAULTS.extensions.policy.trust_mode;
|
|
430
|
-
}
|
|
431
|
-
function normalizeExtensionSandboxProfile(value) {
|
|
432
|
-
if (value === "none" || value === "restricted" || value === "strict") {
|
|
433
|
-
return value;
|
|
434
|
-
}
|
|
435
|
-
return SETTINGS_DEFAULTS.extensions.policy.default_sandbox_profile;
|
|
436
|
-
}
|
|
437
|
-
function normalizeExtensionPolicyOverride(override) {
|
|
438
|
-
const name = override.name.trim().toLowerCase();
|
|
439
|
-
if (name.length === 0) {
|
|
440
|
-
return null;
|
|
441
|
-
}
|
|
442
|
-
const normalized = {
|
|
443
|
-
name,
|
|
444
|
-
};
|
|
445
|
-
if (override.disabled === true) {
|
|
446
|
-
normalized.disabled = true;
|
|
447
|
-
}
|
|
448
|
-
if (override.require_trusted === true) {
|
|
449
|
-
normalized.require_trusted = true;
|
|
450
|
-
}
|
|
451
|
-
if (override.require_provenance === true) {
|
|
452
|
-
normalized.require_provenance = true;
|
|
453
|
-
}
|
|
454
|
-
if (override.sandbox_profile !== undefined) {
|
|
455
|
-
normalized.sandbox_profile = normalizeExtensionSandboxProfile(override.sandbox_profile);
|
|
456
|
-
}
|
|
457
|
-
const allowedCapabilities = normalizeLowerStringList(override.allowed_capabilities);
|
|
458
|
-
const blockedCapabilities = normalizeLowerStringList(override.blocked_capabilities);
|
|
459
|
-
const allowedSurfaces = normalizeLowerStringList(override.allowed_surfaces);
|
|
460
|
-
const blockedSurfaces = normalizeLowerStringList(override.blocked_surfaces);
|
|
461
|
-
const allowedCommands = normalizeLowerStringList(override.allowed_commands);
|
|
462
|
-
const blockedCommands = normalizeLowerStringList(override.blocked_commands);
|
|
463
|
-
const allowedActions = normalizeLowerStringList(override.allowed_actions);
|
|
464
|
-
const blockedActions = normalizeLowerStringList(override.blocked_actions);
|
|
465
|
-
const allowedServices = normalizeLowerStringList(override.allowed_services);
|
|
466
|
-
const blockedServices = normalizeLowerStringList(override.blocked_services);
|
|
467
|
-
if (allowedCapabilities.length > 0) {
|
|
468
|
-
normalized.allowed_capabilities = allowedCapabilities;
|
|
469
|
-
}
|
|
470
|
-
if (blockedCapabilities.length > 0) {
|
|
471
|
-
normalized.blocked_capabilities = blockedCapabilities;
|
|
472
|
-
}
|
|
473
|
-
if (allowedSurfaces.length > 0) {
|
|
474
|
-
normalized.allowed_surfaces = allowedSurfaces;
|
|
475
|
-
}
|
|
476
|
-
if (blockedSurfaces.length > 0) {
|
|
477
|
-
normalized.blocked_surfaces = blockedSurfaces;
|
|
478
|
-
}
|
|
479
|
-
if (allowedCommands.length > 0) {
|
|
480
|
-
normalized.allowed_commands = allowedCommands;
|
|
481
|
-
}
|
|
482
|
-
if (blockedCommands.length > 0) {
|
|
483
|
-
normalized.blocked_commands = blockedCommands;
|
|
484
|
-
}
|
|
485
|
-
if (allowedActions.length > 0) {
|
|
486
|
-
normalized.allowed_actions = allowedActions;
|
|
487
|
-
}
|
|
488
|
-
if (blockedActions.length > 0) {
|
|
489
|
-
normalized.blocked_actions = blockedActions;
|
|
490
|
-
}
|
|
491
|
-
if (allowedServices.length > 0) {
|
|
492
|
-
normalized.allowed_services = allowedServices;
|
|
493
|
-
}
|
|
494
|
-
if (blockedServices.length > 0) {
|
|
495
|
-
normalized.blocked_services = blockedServices;
|
|
496
|
-
}
|
|
497
|
-
return normalized;
|
|
498
|
-
}
|
|
499
|
-
function normalizeExtensionPolicyOverrides(overrides) {
|
|
500
|
-
const dedupedByName = new Map();
|
|
501
|
-
for (const override of overrides ?? []) {
|
|
502
|
-
const normalized = normalizeExtensionPolicyOverride(override);
|
|
503
|
-
if (!normalized) {
|
|
504
|
-
continue;
|
|
505
|
-
}
|
|
506
|
-
dedupedByName.set(normalized.name, normalized);
|
|
507
|
-
}
|
|
508
|
-
return [...dedupedByName.values()].sort((left, right) => left.name.localeCompare(right.name));
|
|
509
|
-
}
|
|
510
|
-
function normalizePmMaxVersionExceededModeValue(value) {
|
|
511
|
-
return value === "block" || value === "warn" ? value : undefined;
|
|
512
|
-
}
|
|
513
|
-
/** Preserve a configured `pm_max_version_exceeded_mode` (string mode or per-layer override object) through settings normalization. Unset/invalid values are omitted so existing settings.json files round-trip byte-identically and the loader applies its safe default ("block"). */
|
|
514
|
-
function normalizePmMaxVersionExceededModeSetting(value) {
|
|
515
|
-
if (typeof value === "string") {
|
|
516
|
-
return normalizePmMaxVersionExceededModeValue(value);
|
|
517
|
-
}
|
|
518
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
519
|
-
const global = normalizePmMaxVersionExceededModeValue(value.global);
|
|
520
|
-
const project = normalizePmMaxVersionExceededModeValue(value.project);
|
|
521
|
-
if (global === undefined && project === undefined) {
|
|
522
|
-
return undefined;
|
|
523
|
-
}
|
|
524
|
-
return {
|
|
525
|
-
...(global !== undefined ? { global } : {}),
|
|
526
|
-
...(project !== undefined ? { project } : {}),
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
return undefined;
|
|
530
|
-
}
|
|
531
|
-
function normalizeExtensionPolicyList(policy, key) {
|
|
532
|
-
return normalizeLowerStringList(policy?.[key] ?? SETTINGS_DEFAULTS.extensions.policy[key]);
|
|
533
|
-
}
|
|
534
|
-
function normalizeExtensionPolicySettings(policy) {
|
|
535
|
-
const pmMaxVersionExceededMode = normalizePmMaxVersionExceededModeSetting(policy?.pm_max_version_exceeded_mode);
|
|
536
|
-
return {
|
|
537
|
-
mode: normalizeExtensionPolicyMode(policy?.mode),
|
|
538
|
-
trust_mode: normalizeExtensionTrustMode(policy?.trust_mode),
|
|
539
|
-
...(pmMaxVersionExceededMode !== undefined
|
|
540
|
-
? { pm_max_version_exceeded_mode: pmMaxVersionExceededMode }
|
|
541
|
-
: {}),
|
|
542
|
-
require_provenance: policy?.require_provenance === true,
|
|
543
|
-
trusted_extensions: normalizeExtensionPolicyList(policy, "trusted_extensions"),
|
|
544
|
-
default_sandbox_profile: normalizeExtensionSandboxProfile(policy?.default_sandbox_profile),
|
|
545
|
-
allowed_extensions: normalizeExtensionPolicyList(policy, "allowed_extensions"),
|
|
546
|
-
blocked_extensions: normalizeExtensionPolicyList(policy, "blocked_extensions"),
|
|
547
|
-
allowed_capabilities: normalizeExtensionPolicyList(policy, "allowed_capabilities"),
|
|
548
|
-
blocked_capabilities: normalizeExtensionPolicyList(policy, "blocked_capabilities"),
|
|
549
|
-
allowed_surfaces: normalizeExtensionPolicyList(policy, "allowed_surfaces"),
|
|
550
|
-
blocked_surfaces: normalizeExtensionPolicyList(policy, "blocked_surfaces"),
|
|
551
|
-
allowed_commands: normalizeExtensionPolicyList(policy, "allowed_commands"),
|
|
552
|
-
blocked_commands: normalizeExtensionPolicyList(policy, "blocked_commands"),
|
|
553
|
-
allowed_actions: normalizeExtensionPolicyList(policy, "allowed_actions"),
|
|
554
|
-
blocked_actions: normalizeExtensionPolicyList(policy, "blocked_actions"),
|
|
555
|
-
allowed_services: normalizeExtensionPolicyList(policy, "allowed_services"),
|
|
556
|
-
blocked_services: normalizeExtensionPolicyList(policy, "blocked_services"),
|
|
557
|
-
extension_overrides: normalizeExtensionPolicyOverrides(policy?.extension_overrides ??
|
|
558
|
-
SETTINGS_DEFAULTS.extensions.policy.extension_overrides),
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
function normalizeValidationMetadataRequiredFields(values) {
|
|
562
|
-
const normalized = [
|
|
563
|
-
...new Set((values ?? []).map((value) => value.trim().toLowerCase().replaceAll("-", "_"))),
|
|
564
|
-
]
|
|
565
|
-
.filter((value) => value.length > 0)
|
|
566
|
-
.sort((left, right) => left.localeCompare(right));
|
|
567
|
-
return normalized.filter((value) => [
|
|
568
|
-
"author",
|
|
569
|
-
"acceptance_criteria",
|
|
570
|
-
"estimated_minutes",
|
|
571
|
-
"close_reason",
|
|
572
|
-
"reviewer",
|
|
573
|
-
"risk",
|
|
574
|
-
"confidence",
|
|
575
|
-
"sprint",
|
|
576
|
-
"release",
|
|
577
|
-
].includes(value));
|
|
578
|
-
}
|
|
579
|
-
function normalizeValidationPatternList(values) {
|
|
580
|
-
return [
|
|
581
|
-
...new Set((values ?? [])
|
|
582
|
-
.map((value) => value.trim().toLowerCase())
|
|
583
|
-
.filter((value) => value.length > 0)),
|
|
584
|
-
].sort((left, right) => left.localeCompare(right));
|
|
585
|
-
}
|
|
586
|
-
function valueOrDefault(value, fallback) {
|
|
587
|
-
return value === undefined ? fallback : value;
|
|
588
|
-
}
|
|
589
|
-
function recordOrEmpty(value) {
|
|
590
|
-
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
591
|
-
? value
|
|
592
|
-
: {};
|
|
593
|
-
}
|
|
594
|
-
function arrayOrEmpty(value) {
|
|
595
|
-
return Array.isArray(value) ? value : [];
|
|
596
|
-
}
|
|
597
|
-
function buildValidationSettings(settings, defaults, governance) {
|
|
598
|
-
return {
|
|
599
|
-
...defaults.validation,
|
|
600
|
-
...settings.validation,
|
|
601
|
-
parent_reference: governance.parent_reference,
|
|
602
|
-
metadata_profile: governance.metadata_profile,
|
|
603
|
-
metadata_required_fields: normalizeValidationMetadataRequiredFields(settings.validation?.metadata_required_fields),
|
|
604
|
-
lifecycle_stale_blocker_reason_patterns: normalizeValidationPatternList(settings.validation?.lifecycle_stale_blocker_reason_patterns ??
|
|
605
|
-
defaults.validation.lifecycle_stale_blocker_reason_patterns),
|
|
606
|
-
lifecycle_closure_like_blocked_reason_patterns: normalizeValidationPatternList(settings.validation?.lifecycle_closure_like_blocked_reason_patterns ??
|
|
607
|
-
defaults.validation.lifecycle_closure_like_blocked_reason_patterns),
|
|
608
|
-
lifecycle_closure_like_resolution_patterns: normalizeValidationPatternList(settings.validation?.lifecycle_closure_like_resolution_patterns ??
|
|
609
|
-
defaults.validation.lifecycle_closure_like_resolution_patterns),
|
|
610
|
-
lifecycle_closure_like_actual_result_patterns: normalizeValidationPatternList(settings.validation?.lifecycle_closure_like_actual_result_patterns ??
|
|
611
|
-
defaults.validation.lifecycle_closure_like_actual_result_patterns),
|
|
612
|
-
estimate_defaults_by_type: normalizeEstimateDefaultOverrides(settings.validation?.estimate_defaults_by_type),
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
function buildTelemetrySettings(settings, defaults) {
|
|
616
|
-
return {
|
|
617
|
-
enabled: settings.telemetry?.enabled ?? defaults.telemetry.enabled,
|
|
618
|
-
first_run_prompt_completed: settings.telemetry?.first_run_prompt_completed ??
|
|
619
|
-
defaults.telemetry.first_run_prompt_completed,
|
|
620
|
-
capture_level: settings.telemetry?.capture_level ?? defaults.telemetry.capture_level,
|
|
621
|
-
endpoint: settings.telemetry?.endpoint ?? defaults.telemetry.endpoint,
|
|
622
|
-
installation_id: settings.telemetry?.installation_id ?? defaults.telemetry.installation_id,
|
|
623
|
-
retention_days: settings.telemetry?.retention_days ?? defaults.telemetry.retention_days,
|
|
624
|
-
};
|
|
625
|
-
}
|
|
626
|
-
function buildSearchSettings(settings, defaults) {
|
|
627
|
-
return {
|
|
628
|
-
...defaults.search,
|
|
629
|
-
...settings.search,
|
|
630
|
-
mutation_refresh_policy: normalizeSearchMutationRefreshPolicy(settings.search?.mutation_refresh_policy),
|
|
631
|
-
query_expansion: {
|
|
632
|
-
...defaults.search.query_expansion,
|
|
633
|
-
...settings.search?.query_expansion,
|
|
634
|
-
enabled: normalizeSearchQueryExpansionEnabled(settings.search?.query_expansion?.enabled),
|
|
635
|
-
provider: normalizeSearchQueryExpansionProvider(settings.search?.query_expansion?.provider),
|
|
636
|
-
},
|
|
637
|
-
rerank: {
|
|
638
|
-
...defaults.search.rerank,
|
|
639
|
-
...settings.search?.rerank,
|
|
640
|
-
enabled: normalizeSearchRerankEnabled(settings.search?.rerank?.enabled),
|
|
641
|
-
model: normalizeSearchRerankModel(settings.search?.rerank?.model),
|
|
642
|
-
top_k: normalizeSearchRerankTopK(settings.search?.rerank?.top_k),
|
|
643
|
-
},
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
function buildVectorStoreSettings(settings, defaults) {
|
|
647
|
-
return {
|
|
648
|
-
adapter: settings.vector_store.adapter ?? defaults.vector_store.adapter,
|
|
649
|
-
collection_name: normalizeVectorStoreCollectionName(settings.vector_store.collection_name),
|
|
650
|
-
qdrant: {
|
|
651
|
-
...defaults.vector_store.qdrant,
|
|
652
|
-
...settings.vector_store.qdrant,
|
|
653
|
-
},
|
|
654
|
-
lancedb: {
|
|
655
|
-
...defaults.vector_store.lancedb,
|
|
656
|
-
...settings.vector_store.lancedb,
|
|
657
|
-
},
|
|
658
|
-
};
|
|
659
|
-
}
|
|
660
|
-
function normalizeSettingsItemFormat(settings, defaults) {
|
|
661
|
-
if (settings.item_format === "json_markdown") {
|
|
662
|
-
return "toon";
|
|
663
|
-
}
|
|
664
|
-
return settings.item_format ?? defaults.item_format;
|
|
665
|
-
}
|
|
666
|
-
function buildContextSettings(settings, defaults) {
|
|
667
|
-
return {
|
|
668
|
-
default_depth: settings.context?.default_depth ?? defaults.context.default_depth,
|
|
669
|
-
activity_limit: settings.context?.activity_limit ?? defaults.context.activity_limit,
|
|
670
|
-
stale_threshold_days: settings.context?.stale_threshold_days ??
|
|
671
|
-
defaults.context.stale_threshold_days,
|
|
672
|
-
sections: {
|
|
673
|
-
...defaults.context.sections,
|
|
674
|
-
...settings.context?.sections,
|
|
675
|
-
},
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
function buildProviderSettings(settings, defaults) {
|
|
679
|
-
return {
|
|
680
|
-
openai: { ...defaults.providers.openai, ...settings.providers.openai },
|
|
681
|
-
ollama: { ...defaults.providers.ollama, ...settings.providers.ollama },
|
|
682
|
-
};
|
|
683
|
-
}
|
|
684
|
-
/** Implements normalize item type definitions for the public runtime surface of this module. */
|
|
685
|
-
export function normalizeItemTypeDefinitions(definitions) {
|
|
686
|
-
const normalized = (definitions ?? [])
|
|
687
|
-
.map((definition) => normalizeItemTypeDefinition(definition))
|
|
688
|
-
.filter((definition) => definition !== null);
|
|
689
|
-
const dedupedByName = new Map();
|
|
690
|
-
for (const definition of normalized) {
|
|
691
|
-
dedupedByName.set(definition.name.toLowerCase(), definition);
|
|
692
|
-
}
|
|
693
|
-
return [...dedupedByName.values()].sort((left, right) => left.name.localeCompare(right.name));
|
|
694
|
-
}
|
|
695
|
-
function mergeSettings(settings) {
|
|
696
|
-
const defaults = cloneDefaults();
|
|
697
|
-
const governance = resolveGovernanceKnobs({
|
|
698
|
-
governance: settings.governance ?? { preset: "default" },
|
|
699
|
-
});
|
|
700
|
-
return {
|
|
701
|
-
...defaults,
|
|
702
|
-
...settings,
|
|
703
|
-
item_format: normalizeSettingsItemFormat(settings, defaults),
|
|
704
|
-
locks: { ...defaults.locks, ...settings.locks },
|
|
705
|
-
ids: { ...defaults.ids, ...settings.ids },
|
|
706
|
-
agent_identity: structuredClone(settings.agent_identity ?? defaults.agent_identity),
|
|
707
|
-
mutation_guard: {
|
|
708
|
-
...defaults.mutation_guard,
|
|
709
|
-
...settings.mutation_guard,
|
|
710
|
-
},
|
|
711
|
-
checkpoints: { ...defaults.checkpoints, ...settings.checkpoints },
|
|
712
|
-
output: { ...defaults.output, ...settings.output },
|
|
713
|
-
ux: { ...defaults.ux, ...settings.ux },
|
|
714
|
-
history: {
|
|
715
|
-
...defaults.history,
|
|
716
|
-
...settings.history,
|
|
717
|
-
compact_policy: {
|
|
718
|
-
...defaults.history.compact_policy,
|
|
719
|
-
...settings.history?.compact_policy,
|
|
720
|
-
},
|
|
721
|
-
},
|
|
722
|
-
validation: buildValidationSettings(settings, defaults, governance),
|
|
723
|
-
governance,
|
|
724
|
-
workflow: {
|
|
725
|
-
definition_of_done: [
|
|
726
|
-
...(settings.workflow?.definition_of_done ??
|
|
727
|
-
defaults.workflow.definition_of_done),
|
|
728
|
-
],
|
|
729
|
-
},
|
|
730
|
-
testing: {
|
|
731
|
-
record_results_to_items: settings.testing?.record_results_to_items ??
|
|
732
|
-
defaults.testing.record_results_to_items,
|
|
733
|
-
allow_untrusted_linked_tests: settings.testing?.allow_untrusted_linked_tests ??
|
|
734
|
-
defaults.testing.allow_untrusted_linked_tests,
|
|
735
|
-
},
|
|
736
|
-
telemetry: buildTelemetrySettings(settings, defaults),
|
|
737
|
-
agent_guidance: normalizeAgentGuidanceSettings(settings.agent_guidance ?? defaults.agent_guidance),
|
|
738
|
-
item_types: {
|
|
739
|
-
definitions: normalizeItemTypeDefinitions(settings.item_types?.definitions),
|
|
740
|
-
},
|
|
741
|
-
schema: normalizeRuntimeSchemaSettings(settings.schema ?? defaults.schema),
|
|
742
|
-
context: buildContextSettings(settings, defaults),
|
|
743
|
-
extensions: {
|
|
744
|
-
enabled: [...settings.extensions.enabled],
|
|
745
|
-
disabled: [...settings.extensions.disabled],
|
|
746
|
-
policy: normalizeExtensionPolicySettings(settings.extensions.policy ?? defaults.extensions.policy),
|
|
747
|
-
},
|
|
748
|
-
search: buildSearchSettings(settings, defaults),
|
|
749
|
-
providers: buildProviderSettings(settings, defaults),
|
|
750
|
-
vector_store: buildVectorStoreSettings(settings, defaults),
|
|
751
|
-
};
|
|
752
|
-
}
|
|
753
|
-
function orderSerializedSettingsSections(ordered) {
|
|
754
|
-
ordered.agent_identity = orderObject(ordered.agent_identity, ["probes_enabled", "identity_vocabulary", "harness_signals"]);
|
|
755
|
-
const orderedAgentIdentity = ordered.agent_identity;
|
|
756
|
-
if (Object.hasOwn(orderedAgentIdentity, "identity_vocabulary")) {
|
|
757
|
-
orderedAgentIdentity.identity_vocabulary = orderObject(recordOrEmpty(orderedAgentIdentity.identity_vocabulary), ["version", "aliases"]);
|
|
758
|
-
}
|
|
759
|
-
ordered.agent_identity.harness_signals =
|
|
760
|
-
arrayOrEmpty(ordered.agent_identity.harness_signals).map((entry) => orderObject(recordOrEmpty(entry), [
|
|
761
|
-
"harness",
|
|
762
|
-
"environment_keys",
|
|
763
|
-
"model_environment_keys",
|
|
764
|
-
"session_environment_keys",
|
|
765
|
-
"provenance_environment_keys",
|
|
766
|
-
"provenance_resolvers",
|
|
767
|
-
"provenance_unavailable_dimensions",
|
|
768
|
-
"argv_markers",
|
|
769
|
-
"client_names",
|
|
770
|
-
]));
|
|
771
|
-
ordered.locks = orderObject(ordered.locks, [
|
|
772
|
-
"ttl_seconds",
|
|
773
|
-
"wait_ms",
|
|
774
|
-
]);
|
|
775
|
-
ordered.ids = orderObject(ordered.ids, [
|
|
776
|
-
"token_length",
|
|
777
|
-
]);
|
|
778
|
-
ordered.mutation_guard = orderObject(ordered.mutation_guard, ["require_attributed_author", "secret_guard", "stale_in_progress_hours"]);
|
|
779
|
-
ordered.checkpoints = orderObject(ordered.checkpoints, ["retention_days"]);
|
|
780
|
-
ordered.output = orderObject(ordered.output, [
|
|
781
|
-
"default_format",
|
|
782
|
-
]);
|
|
783
|
-
ordered.ux = orderObject(ordered.ux, [
|
|
784
|
-
"deprecation_hints",
|
|
785
|
-
]);
|
|
786
|
-
ordered.history = orderObject(ordered.history, [
|
|
787
|
-
"missing_stream",
|
|
788
|
-
"compact_policy",
|
|
789
|
-
]);
|
|
790
|
-
ordered.validation = orderObject(ordered.validation, [
|
|
791
|
-
"sprint_release_format",
|
|
792
|
-
"parent_reference",
|
|
793
|
-
"metadata_profile",
|
|
794
|
-
"metadata_required_fields",
|
|
795
|
-
"lifecycle_stale_blocker_reason_patterns",
|
|
796
|
-
"lifecycle_closure_like_blocked_reason_patterns",
|
|
797
|
-
"lifecycle_closure_like_resolution_patterns",
|
|
798
|
-
"lifecycle_closure_like_actual_result_patterns",
|
|
799
|
-
"estimate_defaults_by_type",
|
|
800
|
-
]);
|
|
801
|
-
ordered.governance = orderObject(ordered.governance, [
|
|
802
|
-
"preset",
|
|
803
|
-
"ownership_enforcement",
|
|
804
|
-
"create_mode_default",
|
|
805
|
-
"close_validation_default",
|
|
806
|
-
"require_close_reason",
|
|
807
|
-
"parent_reference",
|
|
808
|
-
"metadata_profile",
|
|
809
|
-
"force_required_for_stale_lock",
|
|
810
|
-
"create_default_type",
|
|
811
|
-
"workflow_enforcement",
|
|
812
|
-
"duplicate_detection_mode",
|
|
813
|
-
"duplicate_detection_threshold",
|
|
814
|
-
"duplicate_detection_limit",
|
|
815
|
-
]);
|
|
816
|
-
ordered.workflow = orderObject(ordered.workflow, [
|
|
817
|
-
"definition_of_done",
|
|
818
|
-
]);
|
|
819
|
-
ordered.testing = orderObject(ordered.testing, [
|
|
820
|
-
"record_results_to_items",
|
|
821
|
-
"allow_untrusted_linked_tests",
|
|
822
|
-
]);
|
|
823
|
-
ordered.telemetry = orderObject(ordered.telemetry, [
|
|
824
|
-
"enabled",
|
|
825
|
-
"first_run_prompt_completed",
|
|
826
|
-
"capture_level",
|
|
827
|
-
"endpoint",
|
|
828
|
-
"installation_id",
|
|
829
|
-
"retention_days",
|
|
830
|
-
]);
|
|
831
|
-
ordered.agent_guidance = orderObject(ordered.agent_guidance, [
|
|
832
|
-
"prompt_completed",
|
|
833
|
-
"declined",
|
|
834
|
-
"declined_at",
|
|
835
|
-
"template_version",
|
|
836
|
-
"last_checked_files",
|
|
837
|
-
]);
|
|
838
|
-
ordered.item_types = orderObject(ordered.item_types, ["definitions"]);
|
|
839
|
-
ordered.schema = orderObject(ordered.schema, [
|
|
840
|
-
"version",
|
|
841
|
-
"files",
|
|
842
|
-
"statuses",
|
|
843
|
-
"fields",
|
|
844
|
-
"workflow",
|
|
845
|
-
"type_workflows",
|
|
846
|
-
"unknown_field_policy",
|
|
847
|
-
]);
|
|
848
|
-
ordered.schema.files = orderObject(recordOrEmpty(ordered.schema.files), ["types", "statuses", "fields", "workflows"]);
|
|
849
|
-
ordered.schema.workflow = orderObject(recordOrEmpty(ordered.schema.workflow), [
|
|
850
|
-
"draft_status",
|
|
851
|
-
"open_status",
|
|
852
|
-
"in_progress_status",
|
|
853
|
-
"blocked_status",
|
|
854
|
-
"close_status",
|
|
855
|
-
"canceled_status",
|
|
856
|
-
]);
|
|
857
|
-
ordered.context = orderObject(ordered.context, [
|
|
858
|
-
"default_depth",
|
|
859
|
-
"activity_limit",
|
|
860
|
-
"stale_threshold_days",
|
|
861
|
-
"sections",
|
|
862
|
-
]);
|
|
863
|
-
ordered.context.sections = orderObject(recordOrEmpty(ordered.context.sections), [
|
|
864
|
-
"hierarchy",
|
|
865
|
-
"activity",
|
|
866
|
-
"progress",
|
|
867
|
-
"blockers",
|
|
868
|
-
"files",
|
|
869
|
-
"workload",
|
|
870
|
-
"staleness",
|
|
871
|
-
"tests",
|
|
872
|
-
]);
|
|
873
|
-
ordered.extensions = orderObject(ordered.extensions, ["enabled", "disabled", "policy"]);
|
|
874
|
-
ordered.extensions.policy = orderObject(recordOrEmpty(ordered.extensions.policy), [
|
|
875
|
-
"mode",
|
|
876
|
-
"trust_mode",
|
|
877
|
-
"pm_max_version_exceeded_mode",
|
|
878
|
-
"require_provenance",
|
|
879
|
-
"trusted_extensions",
|
|
880
|
-
"default_sandbox_profile",
|
|
881
|
-
"allowed_extensions",
|
|
882
|
-
"blocked_extensions",
|
|
883
|
-
"allowed_capabilities",
|
|
884
|
-
"blocked_capabilities",
|
|
885
|
-
"allowed_surfaces",
|
|
886
|
-
"blocked_surfaces",
|
|
887
|
-
"allowed_commands",
|
|
888
|
-
"blocked_commands",
|
|
889
|
-
"allowed_actions",
|
|
890
|
-
"blocked_actions",
|
|
891
|
-
"allowed_services",
|
|
892
|
-
"blocked_services",
|
|
893
|
-
"extension_overrides",
|
|
894
|
-
]);
|
|
895
|
-
ordered.extensions.policy.extension_overrides = arrayOrEmpty(ordered.extensions.policy.extension_overrides).map((entry) => orderObject(recordOrEmpty(entry), [
|
|
896
|
-
"name",
|
|
897
|
-
"disabled",
|
|
898
|
-
"require_trusted",
|
|
899
|
-
"require_provenance",
|
|
900
|
-
"sandbox_profile",
|
|
901
|
-
"allowed_capabilities",
|
|
902
|
-
"blocked_capabilities",
|
|
903
|
-
"allowed_surfaces",
|
|
904
|
-
"blocked_surfaces",
|
|
905
|
-
"allowed_commands",
|
|
906
|
-
"blocked_commands",
|
|
907
|
-
"allowed_actions",
|
|
908
|
-
"blocked_actions",
|
|
909
|
-
"allowed_services",
|
|
910
|
-
"blocked_services",
|
|
911
|
-
]));
|
|
912
|
-
ordered.search = orderObject(ordered.search, [
|
|
913
|
-
"score_threshold",
|
|
914
|
-
"hybrid_semantic_weight",
|
|
915
|
-
"max_results",
|
|
916
|
-
"embedding_model",
|
|
917
|
-
"embedding_corpus_max_characters",
|
|
918
|
-
"embedding_batch_size",
|
|
919
|
-
"embedding_timeout_ms",
|
|
920
|
-
"scanner_max_batch_retries",
|
|
921
|
-
"provider",
|
|
922
|
-
"mutation_refresh_policy",
|
|
923
|
-
"query_expansion",
|
|
924
|
-
"rerank",
|
|
925
|
-
]);
|
|
926
|
-
ordered.search.query_expansion = orderObject(recordOrEmpty(ordered.search.query_expansion), ["enabled", "provider"]);
|
|
927
|
-
ordered.search.rerank = orderObject(recordOrEmpty(ordered.search.rerank), ["enabled", "model", "top_k"]);
|
|
928
|
-
ordered.providers = orderObject(ordered.providers, ["openai", "ollama"]);
|
|
929
|
-
ordered.providers.openai = orderObject(recordOrEmpty(ordered.providers.openai), ["base_url", "api_key", "model"]);
|
|
930
|
-
ordered.providers.ollama = orderObject(recordOrEmpty(ordered.providers.ollama), ["base_url", "model"]);
|
|
931
|
-
ordered.vector_store = orderObject(ordered.vector_store, ["adapter", "collection_name", "qdrant", "lancedb"]);
|
|
932
|
-
ordered.vector_store.qdrant = orderObject(recordOrEmpty(ordered.vector_store.qdrant), ["url", "api_key"]);
|
|
933
|
-
ordered.vector_store.lancedb = orderObject(recordOrEmpty(ordered.vector_store.lancedb), ["path"]);
|
|
934
|
-
}
|
|
935
|
-
function buildSerializeBaseSettings(settings) {
|
|
936
|
-
return {
|
|
937
|
-
...settings,
|
|
938
|
-
locks: valueOrDefault(settings.locks, SETTINGS_DEFAULTS.locks),
|
|
939
|
-
ids: valueOrDefault(settings.ids, SETTINGS_DEFAULTS.ids),
|
|
940
|
-
agent_identity: valueOrDefault(settings.agent_identity, SETTINGS_DEFAULTS.agent_identity),
|
|
941
|
-
mutation_guard: valueOrDefault(settings.mutation_guard, SETTINGS_DEFAULTS.mutation_guard),
|
|
942
|
-
checkpoints: valueOrDefault(settings.checkpoints, SETTINGS_DEFAULTS.checkpoints),
|
|
943
|
-
output: valueOrDefault(settings.output, SETTINGS_DEFAULTS.output),
|
|
944
|
-
ux: valueOrDefault(settings.ux, SETTINGS_DEFAULTS.ux),
|
|
945
|
-
history: valueOrDefault(settings.history, SETTINGS_DEFAULTS.history),
|
|
946
|
-
validation: valueOrDefault(settings.validation, SETTINGS_DEFAULTS.validation),
|
|
947
|
-
workflow: valueOrDefault(settings.workflow, SETTINGS_DEFAULTS.workflow),
|
|
948
|
-
testing: valueOrDefault(settings.testing, SETTINGS_DEFAULTS.testing),
|
|
949
|
-
telemetry: valueOrDefault(settings.telemetry, SETTINGS_DEFAULTS.telemetry),
|
|
950
|
-
agent_guidance: valueOrDefault(settings.agent_guidance, SETTINGS_DEFAULTS.agent_guidance),
|
|
951
|
-
item_types: valueOrDefault(settings.item_types, SETTINGS_DEFAULTS.item_types),
|
|
952
|
-
schema: valueOrDefault(settings.schema, SETTINGS_DEFAULTS.schema),
|
|
953
|
-
context: valueOrDefault(settings.context, SETTINGS_DEFAULTS.context),
|
|
954
|
-
extensions: valueOrDefault(settings.extensions, SETTINGS_DEFAULTS.extensions),
|
|
955
|
-
search: valueOrDefault(settings.search, SETTINGS_DEFAULTS.search),
|
|
956
|
-
providers: valueOrDefault(settings.providers, SETTINGS_DEFAULTS.providers),
|
|
957
|
-
vector_store: valueOrDefault(settings.vector_store, SETTINGS_DEFAULTS.vector_store),
|
|
958
|
-
};
|
|
959
|
-
}
|
|
960
|
-
function buildSerializedValidationSettings(baseSettings, governance) {
|
|
961
|
-
return {
|
|
962
|
-
...baseSettings.validation,
|
|
963
|
-
parent_reference: governance.parent_reference,
|
|
964
|
-
metadata_profile: governance.metadata_profile,
|
|
965
|
-
metadata_required_fields: normalizeValidationMetadataRequiredFields(baseSettings.validation?.metadata_required_fields),
|
|
966
|
-
lifecycle_stale_blocker_reason_patterns: normalizeValidationPatternList(baseSettings.validation?.lifecycle_stale_blocker_reason_patterns ??
|
|
967
|
-
SETTINGS_DEFAULTS.validation.lifecycle_stale_blocker_reason_patterns),
|
|
968
|
-
lifecycle_closure_like_blocked_reason_patterns: normalizeValidationPatternList(baseSettings.validation
|
|
969
|
-
?.lifecycle_closure_like_blocked_reason_patterns ??
|
|
970
|
-
SETTINGS_DEFAULTS.validation
|
|
971
|
-
.lifecycle_closure_like_blocked_reason_patterns),
|
|
972
|
-
lifecycle_closure_like_resolution_patterns: normalizeValidationPatternList(baseSettings.validation?.lifecycle_closure_like_resolution_patterns ??
|
|
973
|
-
SETTINGS_DEFAULTS.validation.lifecycle_closure_like_resolution_patterns),
|
|
974
|
-
lifecycle_closure_like_actual_result_patterns: normalizeValidationPatternList(baseSettings.validation
|
|
975
|
-
?.lifecycle_closure_like_actual_result_patterns ??
|
|
976
|
-
SETTINGS_DEFAULTS.validation
|
|
977
|
-
.lifecycle_closure_like_actual_result_patterns),
|
|
978
|
-
estimate_defaults_by_type: normalizeEstimateDefaultOverrides(baseSettings.validation?.estimate_defaults_by_type),
|
|
979
|
-
};
|
|
980
|
-
}
|
|
981
|
-
function buildSerializedSearchSettings(baseSettings) {
|
|
982
|
-
return {
|
|
983
|
-
...SETTINGS_DEFAULTS.search,
|
|
984
|
-
...baseSettings.search,
|
|
985
|
-
mutation_refresh_policy: normalizeSearchMutationRefreshPolicy(baseSettings.search?.mutation_refresh_policy),
|
|
986
|
-
query_expansion: {
|
|
987
|
-
...SETTINGS_DEFAULTS.search.query_expansion,
|
|
988
|
-
...baseSettings.search?.query_expansion,
|
|
989
|
-
enabled: normalizeSearchQueryExpansionEnabled(baseSettings.search?.query_expansion?.enabled),
|
|
990
|
-
provider: normalizeSearchQueryExpansionProvider(baseSettings.search?.query_expansion?.provider),
|
|
991
|
-
},
|
|
992
|
-
rerank: {
|
|
993
|
-
...SETTINGS_DEFAULTS.search.rerank,
|
|
994
|
-
...baseSettings.search?.rerank,
|
|
995
|
-
enabled: normalizeSearchRerankEnabled(baseSettings.search?.rerank?.enabled),
|
|
996
|
-
model: normalizeSearchRerankModel(baseSettings.search?.rerank?.model),
|
|
997
|
-
top_k: normalizeSearchRerankTopK(baseSettings.search?.rerank?.top_k),
|
|
998
|
-
},
|
|
999
|
-
};
|
|
1000
|
-
}
|
|
1001
|
-
function buildSerializedContextSettings(baseSettings) {
|
|
1002
|
-
return {
|
|
1003
|
-
default_depth: baseSettings.context?.default_depth ??
|
|
1004
|
-
SETTINGS_DEFAULTS.context.default_depth,
|
|
1005
|
-
activity_limit: baseSettings.context?.activity_limit ??
|
|
1006
|
-
SETTINGS_DEFAULTS.context.activity_limit,
|
|
1007
|
-
stale_threshold_days: baseSettings.context?.stale_threshold_days ??
|
|
1008
|
-
SETTINGS_DEFAULTS.context.stale_threshold_days,
|
|
1009
|
-
sections: {
|
|
1010
|
-
...SETTINGS_DEFAULTS.context.sections,
|
|
1011
|
-
...baseSettings.context?.sections,
|
|
1012
|
-
},
|
|
1013
|
-
};
|
|
1014
|
-
}
|
|
1015
|
-
function buildSerializedVectorStoreSettings(baseSettings) {
|
|
1016
|
-
return {
|
|
1017
|
-
...baseSettings.vector_store,
|
|
1018
|
-
adapter: baseSettings.vector_store?.adapter ??
|
|
1019
|
-
SETTINGS_DEFAULTS.vector_store.adapter,
|
|
1020
|
-
collection_name: normalizeVectorStoreCollectionName(baseSettings.vector_store?.collection_name),
|
|
1021
|
-
qdrant: { ...baseSettings.vector_store?.qdrant },
|
|
1022
|
-
lancedb: { ...baseSettings.vector_store?.lancedb },
|
|
1023
|
-
};
|
|
1024
|
-
}
|
|
1025
|
-
function buildNormalizedSettingsForSerialization(baseSettings, governance, normalizedSchema, persistedFileBackedSections) {
|
|
1026
|
-
return {
|
|
1027
|
-
...baseSettings,
|
|
1028
|
-
item_format: "toon",
|
|
1029
|
-
validation: buildSerializedValidationSettings(baseSettings, governance),
|
|
1030
|
-
governance,
|
|
1031
|
-
agent_guidance: normalizeAgentGuidanceSettings(baseSettings.agent_guidance),
|
|
1032
|
-
item_types: {
|
|
1033
|
-
definitions: persistedFileBackedSections.item_type_definitions,
|
|
1034
|
-
},
|
|
1035
|
-
schema: {
|
|
1036
|
-
...normalizedSchema,
|
|
1037
|
-
statuses: persistedFileBackedSections.schema_statuses,
|
|
1038
|
-
fields: persistedFileBackedSections.schema_fields,
|
|
1039
|
-
type_workflows: persistedFileBackedSections.schema_type_workflows,
|
|
1040
|
-
},
|
|
1041
|
-
search: buildSerializedSearchSettings(baseSettings),
|
|
1042
|
-
context: buildSerializedContextSettings(baseSettings),
|
|
1043
|
-
extensions: {
|
|
1044
|
-
enabled: normalizeStringList(baseSettings.extensions?.enabled),
|
|
1045
|
-
disabled: normalizeStringList(baseSettings.extensions?.disabled),
|
|
1046
|
-
policy: normalizeExtensionPolicySettings(baseSettings.extensions?.policy),
|
|
1047
|
-
},
|
|
1048
|
-
vector_store: buildSerializedVectorStoreSettings(baseSettings),
|
|
1049
|
-
};
|
|
1050
|
-
}
|
|
1051
|
-
function applySettingsDelta(target, baseline, current) {
|
|
1052
|
-
const keys = new Set([...Object.keys(baseline), ...Object.keys(current)]);
|
|
1053
|
-
for (const key of keys) {
|
|
1054
|
-
const before = baseline[key];
|
|
1055
|
-
const after = current[key];
|
|
1056
|
-
if (stableValueEquals(before, after))
|
|
1057
|
-
continue;
|
|
1058
|
-
if (after === undefined) {
|
|
1059
|
-
delete target[key];
|
|
1060
|
-
continue;
|
|
1061
|
-
}
|
|
1062
|
-
if (typeof before === "object" &&
|
|
1063
|
-
before !== null &&
|
|
1064
|
-
!Array.isArray(before) &&
|
|
1065
|
-
typeof after === "object" &&
|
|
1066
|
-
after !== null &&
|
|
1067
|
-
!Array.isArray(after)) {
|
|
1068
|
-
const existing = target[key];
|
|
1069
|
-
const nestedTarget = typeof existing === "object" &&
|
|
1070
|
-
existing !== null &&
|
|
1071
|
-
!Array.isArray(existing)
|
|
1072
|
-
? existing
|
|
1073
|
-
: {};
|
|
1074
|
-
applySettingsDelta(nestedTarget, before, after);
|
|
1075
|
-
if (Object.keys(nestedTarget).length > 0)
|
|
1076
|
-
target[key] = nestedTarget;
|
|
1077
|
-
else
|
|
1078
|
-
delete target[key];
|
|
1079
|
-
continue;
|
|
1080
|
-
}
|
|
1081
|
-
target[key] = structuredClone(after);
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
const SETTINGS_TOP_LEVEL_KEY_ORDER = [
|
|
1085
|
-
"version",
|
|
1086
|
-
"id_prefix",
|
|
1087
|
-
"ids",
|
|
1088
|
-
"author_default",
|
|
1089
|
-
"agent_identity",
|
|
1090
|
-
"mutation_guard",
|
|
1091
|
-
"item_format",
|
|
1092
|
-
"locks",
|
|
1093
|
-
"checkpoints",
|
|
1094
|
-
"output",
|
|
1095
|
-
"ux",
|
|
1096
|
-
"history",
|
|
1097
|
-
"validation",
|
|
1098
|
-
"governance",
|
|
1099
|
-
"workflow",
|
|
1100
|
-
"testing",
|
|
1101
|
-
"telemetry",
|
|
1102
|
-
"agent_guidance",
|
|
1103
|
-
"item_types",
|
|
1104
|
-
"schema",
|
|
1105
|
-
"context",
|
|
1106
|
-
"extensions",
|
|
1107
|
-
"search",
|
|
1108
|
-
"providers",
|
|
1109
|
-
"vector_store",
|
|
1110
|
-
];
|
|
1111
|
-
function buildOrderedSettingsForSerialization(settings, persistSource) {
|
|
1112
|
-
const baseSettings = buildSerializeBaseSettings(settings);
|
|
1113
|
-
const governance = resolveGovernanceKnobs(baseSettings);
|
|
1114
|
-
const normalizedSchema = normalizeRuntimeSchemaSettings(baseSettings.schema);
|
|
1115
|
-
const persistedFileBackedSections = resolvePersistedFileBackedSchemaSections(baseSettings, persistSource);
|
|
1116
|
-
const normalizedSettings = buildNormalizedSettingsForSerialization(baseSettings, governance, normalizedSchema, persistedFileBackedSections);
|
|
1117
|
-
const ordered = orderObject({
|
|
1118
|
-
...normalizedSettings,
|
|
1119
|
-
governance: normalizeGovernanceForPersist(governance),
|
|
1120
|
-
}, SETTINGS_TOP_LEVEL_KEY_ORDER);
|
|
1121
|
-
orderSerializedSettingsSections(ordered);
|
|
1122
|
-
return ordered;
|
|
1123
|
-
}
|
|
1124
|
-
/** Implements serialize settings for the public runtime surface of this module. */
|
|
1125
|
-
export function serializeSettings(settings, options = {}) {
|
|
1126
|
-
const ordered = buildOrderedSettingsForSerialization(settings, options.persist_source);
|
|
1127
|
-
if (options.persist_source) {
|
|
1128
|
-
const baselineSettings = mergeSettings(options.persist_source.source_settings);
|
|
1129
|
-
baselineSettings.item_types = {
|
|
1130
|
-
definitions: structuredClone(options.persist_source.runtime_item_type_definitions),
|
|
1131
|
-
};
|
|
1132
|
-
baselineSettings.schema = {
|
|
1133
|
-
...baselineSettings.schema,
|
|
1134
|
-
statuses: structuredClone(options.persist_source.runtime_schema_statuses),
|
|
1135
|
-
fields: structuredClone(options.persist_source.runtime_schema_fields),
|
|
1136
|
-
type_workflows: structuredClone(options.persist_source.runtime_schema_type_workflows),
|
|
1137
|
-
};
|
|
1138
|
-
const baseline = buildOrderedSettingsForSerialization(baselineSettings, options.persist_source);
|
|
1139
|
-
const sparse = structuredClone(options.persist_source.source_settings);
|
|
1140
|
-
applySettingsDelta(sparse, baseline, ordered);
|
|
1141
|
-
return `${JSON.stringify(orderObject(sparse, SETTINGS_TOP_LEVEL_KEY_ORDER), null, 2)}\n`;
|
|
1142
|
-
}
|
|
1143
|
-
return `${JSON.stringify(ordered, null, 2)}\n`;
|
|
1144
|
-
}
|
|
1145
|
-
/** Implements read settings with metadata for the public runtime surface of this module. */
|
|
1146
|
-
export async function readSettingsWithMetadata(pmRoot) {
|
|
1147
|
-
const settingsPath = getSettingsPath(pmRoot);
|
|
1148
|
-
let trackedPathsForFailure = [settingsPath];
|
|
1149
|
-
await runActiveOnReadHooks({
|
|
1150
|
-
path: settingsPath,
|
|
1151
|
-
scope: "project",
|
|
1152
|
-
});
|
|
1153
|
-
const cachedResult = getSettingsReadCacheEntry(pmRoot);
|
|
1154
|
-
if (cachedResult) {
|
|
1155
|
-
const currentSignatures = await collectSettingsReadCacheSignatures(cachedResult.tracked_paths);
|
|
1156
|
-
if (settingsReadCacheSignaturesEqual(currentSignatures, cachedResult.signatures)) {
|
|
1157
|
-
return cloneSettingsReadResult(cachedResult.value);
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
const settingsOnlySignatures = await collectSettingsReadCacheSignatures([
|
|
1161
|
-
settingsPath,
|
|
1162
|
-
]);
|
|
1163
|
-
let raw;
|
|
1164
|
-
try {
|
|
1165
|
-
raw = await readFileIfExists(settingsPath);
|
|
1166
|
-
}
|
|
1167
|
-
catch {
|
|
1168
|
-
return buildFallbackSettingsReadResult("settings_read_fs_error");
|
|
1169
|
-
}
|
|
1170
|
-
if (raw === null) {
|
|
1171
|
-
const fallback = buildFallbackSettingsReadResult();
|
|
1172
|
-
await cacheSettingsReadResultIfStable(pmRoot, [settingsPath], fallback, settingsOnlySignatures, [settingsPath]);
|
|
1173
|
-
return fallback;
|
|
1174
|
-
}
|
|
1175
|
-
const settingsSignaturesAfterRead = await collectSettingsReadCacheSignatures([
|
|
1176
|
-
settingsPath,
|
|
1177
|
-
]);
|
|
1178
|
-
if (!settingsReadCacheSignaturesEqual(settingsOnlySignatures, settingsSignaturesAfterRead)) {
|
|
1179
|
-
clearSettingsReadCache(pmRoot);
|
|
1180
|
-
return readSettingsWithMetadata(pmRoot);
|
|
1181
|
-
}
|
|
1182
|
-
let parsed;
|
|
1183
|
-
try {
|
|
1184
|
-
parsed = JSON.parse(raw);
|
|
1185
|
-
}
|
|
1186
|
-
catch {
|
|
1187
|
-
const fallback = buildFallbackSettingsReadResult("settings_read_invalid_json");
|
|
1188
|
-
await cacheSettingsReadResultIfStable(pmRoot, [settingsPath], fallback, settingsSignaturesAfterRead, [settingsPath]);
|
|
1189
|
-
return fallback;
|
|
1190
|
-
}
|
|
1191
|
-
const validated = validateSettings(parsed);
|
|
1192
|
-
if (!validated.success) {
|
|
1193
|
-
const fallback = buildFallbackSettingsReadResult("settings_read_invalid_schema");
|
|
1194
|
-
await cacheSettingsReadResultIfStable(pmRoot, [settingsPath], fallback, settingsSignaturesAfterRead, [settingsPath]);
|
|
1195
|
-
return fallback;
|
|
1196
|
-
}
|
|
1197
|
-
try {
|
|
1198
|
-
const mergedSettings = mergeSettings(validated.data);
|
|
1199
|
-
const trackedPaths = resolveSettingsReadTrackedPaths(pmRoot, mergedSettings.schema, settingsPath);
|
|
1200
|
-
trackedPathsForFailure = trackedPaths;
|
|
1201
|
-
const signaturesBeforeSchemaLoad = await collectSettingsReadCacheSignatures(trackedPaths);
|
|
1202
|
-
const schemaScaffold = await ensureRuntimeSchemaFileScaffold(pmRoot, mergedSettings.schema);
|
|
1203
|
-
const loadedSchemaSections = await loadRuntimeSchemaFromOptionalFiles(pmRoot, mergedSettings.schema);
|
|
1204
|
-
const signaturesAfterSchemaLoad = await collectSettingsReadCacheSignatures(trackedPaths);
|
|
1205
|
-
const settings = {
|
|
1206
|
-
...mergedSettings,
|
|
1207
|
-
item_types: {
|
|
1208
|
-
definitions: normalizeItemTypeDefinitions([
|
|
1209
|
-
...mergedSettings.item_types.definitions,
|
|
1210
|
-
...arrayOrEmpty(loadedSchemaSections.type_definitions_from_file),
|
|
1211
|
-
]),
|
|
1212
|
-
},
|
|
1213
|
-
schema: loadedSchemaSections.schema,
|
|
1214
|
-
};
|
|
1215
|
-
attachSettingsPersistSourceSnapshot(settings, buildSettingsPersistSourceSnapshot(validated.data, settings));
|
|
1216
|
-
const result = {
|
|
1217
|
-
settings,
|
|
1218
|
-
metadata: {
|
|
1219
|
-
has_explicit_item_format: hasExplicitItemFormat(parsed),
|
|
1220
|
-
},
|
|
1221
|
-
warnings: [
|
|
1222
|
-
...(validated.data.item_format === "json_markdown"
|
|
1223
|
-
? ["settings_item_format_legacy_json_markdown_coerced_to_toon"]
|
|
1224
|
-
: []),
|
|
1225
|
-
...schemaScaffold.created_paths.map((createdPath) => `runtime_schema_bootstrap_created:${createdPath}`),
|
|
1226
|
-
...loadedSchemaSections.warnings,
|
|
1227
|
-
],
|
|
1228
|
-
};
|
|
1229
|
-
if (schemaScaffold.created_paths.length === 0) {
|
|
1230
|
-
if (!settingsReadCacheSignaturesEqual(signaturesBeforeSchemaLoad, signaturesAfterSchemaLoad)) {
|
|
1231
|
-
clearSettingsReadCache(pmRoot);
|
|
1232
|
-
}
|
|
1233
|
-
else {
|
|
1234
|
-
setSettingsReadCacheEntry(pmRoot, {
|
|
1235
|
-
tracked_paths: trackedPaths,
|
|
1236
|
-
signatures: signaturesAfterSchemaLoad,
|
|
1237
|
-
value: cloneSettingsReadResult(result),
|
|
1238
|
-
});
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
else {
|
|
1242
|
-
// Bootstrap warnings are intentionally one-shot and should not be replayed from cache.
|
|
1243
|
-
clearSettingsReadCache(pmRoot);
|
|
1244
|
-
}
|
|
1245
|
-
return result;
|
|
1246
|
-
}
|
|
1247
|
-
catch {
|
|
1248
|
-
const fallback = buildFallbackSettingsReadResult("settings_read_merge_failed");
|
|
1249
|
-
await cacheSettingsReadResultSafe(pmRoot, trackedPathsForFailure, fallback);
|
|
1250
|
-
return fallback;
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
/** Implements read settings for the public runtime surface of this module. */
|
|
1254
|
-
export async function readSettings(pmRoot) {
|
|
1255
|
-
return (await readSettingsWithMetadata(pmRoot)).settings;
|
|
1256
|
-
}
|
|
1257
|
-
/** Implements write settings for the public runtime surface of this module. */
|
|
1258
|
-
export async function writeSettings(pmRoot, settings, op = SETTINGS_WRITE_OP) {
|
|
1259
|
-
const settingsPath = getSettingsPath(pmRoot);
|
|
1260
|
-
const afterRaw = serializeSettings(settings, {
|
|
1261
|
-
persist_source: getSettingsPersistSourceSnapshot(settings),
|
|
1262
|
-
});
|
|
1263
|
-
try {
|
|
1264
|
-
await writeWorkspaceJsonWithHistory({
|
|
1265
|
-
pmRoot,
|
|
1266
|
-
filePath: settingsPath,
|
|
1267
|
-
raw: afterRaw,
|
|
1268
|
-
op,
|
|
1269
|
-
author: resolveAuthor(undefined, settings.author_default),
|
|
1270
|
-
lockTtlSeconds: settings.locks.ttl_seconds,
|
|
1271
|
-
lockWaitMs: settings.locks.wait_ms,
|
|
1272
|
-
recordCreation: false,
|
|
1273
|
-
});
|
|
1274
|
-
await runActiveOnWriteHooks({
|
|
1275
|
-
path: settingsPath,
|
|
1276
|
-
scope: "project",
|
|
1277
|
-
op,
|
|
1278
|
-
});
|
|
1279
|
-
}
|
|
1280
|
-
finally {
|
|
1281
|
-
clearSettingsReadCache(pmRoot);
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
/** Public contract for settings store test only, shared by SDK and presentation-layer consumers. */
|
|
1285
|
-
export const settingsStoreTestOnly = {
|
|
1286
|
-
applySettingsDelta,
|
|
1287
|
-
hasExplicitItemFormat,
|
|
1288
|
-
buildSettingsPersistSourceSnapshot,
|
|
1289
|
-
cacheSettingsReadResultIfStable,
|
|
1290
|
-
cacheSettingsReadResultSafe,
|
|
1291
|
-
mergeSettings,
|
|
1292
|
-
normalizeExtensionPolicySettings,
|
|
1293
|
-
normalizeExtensionPolicyOverride,
|
|
1294
|
-
normalizeExtensionPolicyOverrides,
|
|
1295
|
-
normalizeExtensionPolicyMode,
|
|
1296
|
-
normalizePmMaxVersionExceededModeSetting,
|
|
1297
|
-
normalizeExtensionSandboxProfile,
|
|
1298
|
-
normalizeExtensionTrustMode,
|
|
1299
|
-
normalizeLowerStringList,
|
|
1300
|
-
normalizeStringList,
|
|
1301
|
-
valueOrDefault,
|
|
1302
|
-
arrayOrEmpty,
|
|
1303
|
-
normalizeValidationPatternList,
|
|
1304
|
-
normalizeValidationMetadataRequiredFields,
|
|
1305
|
-
resolveSettingsReadTrackedPaths,
|
|
1306
|
-
resolvePersistedFileBackedSchemaSections,
|
|
1307
|
-
selectedSettingsReadCacheSignaturesEqual,
|
|
1308
|
-
};
|
|
1
|
+
!(function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9c6acf02-5259-51f7-bbda-f3967ed0ab74")}catch(e2){}})();import{validateSettings}from"./settings-validator.js";import{runActiveOnReadHooks,runActiveOnWriteHooks}from"../extensions/index.js";import{GOVERNANCE_PRESET_DEFAULTS,SETTINGS_DEFAULTS}from"../shared/constants.js";import{resolveAuthor}from"../shared/author.js";import{readFileIfExists}from"../fs/fs-utils.js";import{writeWorkspaceJsonWithHistory}from"../history/workspace-history.js";import{DEFAULT_RUNTIME_SCHEMA_FILE_PATHS,ensureRuntimeSchemaFileScaffold,filePathForSchemaSection,loadRuntimeSchemaFromOptionalFiles,normalizeRuntimeSchemaSettings}from"../schema/runtime-schema.js";import{getSettingsPath}from"./paths.js";import{orderObject,stableValueEquals}from"../shared/serialization.js";import{normalizeItemTypeDefinition}from"../item/item-type-definition.js";import{normalizeEstimateDefaultOverrides}from"../validate/estimate-defaults.js";import{clearSettingsReadCache,collectSettingsReadCacheSignatures,getSettingsReadCacheEntry,setSettingsReadCacheEntry,settingsReadCacheSignaturesEqual}from"./settings-read-cache.js";const SETTINGS_WRITE_OP="settings:write";const SETTINGS_PERSIST_SOURCE_SYMBOL=Symbol("pm.settings.persist_source");const MAX_VECTOR_STORE_COLLECTION_NAME_LENGTH=128;const DUPLICATE_DETECTION_MODES=new Set(["off","advisory","strict"]);function resolveGovernanceKnobsFromPreset(preset){return structuredClone(GOVERNANCE_PRESET_DEFAULTS[preset])}function normalizeGovernancePreset(value){if(value==="minimal"||value==="default"||value==="strict"||value==="custom"){return value}return SETTINGS_DEFAULTS.governance.preset}function withGovernanceExtras(base,governance){const createDefaultType=typeof governance.create_default_type==="string"?governance.create_default_type.trim():void 0;if(createDefaultType&&createDefaultType.length>0){base.create_default_type=createDefaultType}if(governance.workflow_enforcement==="off"||governance.workflow_enforcement==="warn"||governance.workflow_enforcement==="strict"){base.workflow_enforcement=governance.workflow_enforcement}if(governance.require_close_reason===false){base.require_close_reason=false}base.duplicate_detection_mode=governance.duplicate_detection_mode;base.duplicate_detection_threshold=governance.duplicate_detection_threshold;base.duplicate_detection_limit=governance.duplicate_detection_limit;return base}function normalizeGovernanceForPersist(governance){if(governance.preset==="custom"){return withGovernanceExtras({preset:"custom",ownership_enforcement:governance.ownership_enforcement,create_mode_default:governance.create_mode_default,close_validation_default:governance.close_validation_default,parent_reference:governance.parent_reference,metadata_profile:governance.metadata_profile,force_required_for_stale_lock:governance.force_required_for_stale_lock},governance)}return withGovernanceExtras({preset:governance.preset},governance)}function resolveGovernanceExtras(rawGovernance){const createDefaultType=typeof rawGovernance.create_default_type==="string"?rawGovernance.create_default_type.trim():void 0;const extras={};if(createDefaultType&&createDefaultType.length>0){extras.create_default_type=createDefaultType}if(rawGovernance.workflow_enforcement==="off"||rawGovernance.workflow_enforcement==="warn"||rawGovernance.workflow_enforcement==="strict"){extras.workflow_enforcement=rawGovernance.workflow_enforcement}if(typeof rawGovernance.require_close_reason==="boolean"){extras.require_close_reason=rawGovernance.require_close_reason}if(DUPLICATE_DETECTION_MODES.has(String(rawGovernance.duplicate_detection_mode))){extras.duplicate_detection_mode=rawGovernance.duplicate_detection_mode}const threshold=rawGovernance.duplicate_detection_threshold;if([typeof threshold==="number",Number.isFinite(threshold),Number(threshold)>=0,Number(threshold)<=1].every(Boolean)){extras.duplicate_detection_threshold=threshold}const limit=rawGovernance.duplicate_detection_limit;if([typeof limit==="number",Number.isSafeInteger(limit),Number(limit)>=0,Number(limit)<=20].every(Boolean)){extras.duplicate_detection_limit=limit}return extras}function resolveGovernanceKnobs(settings){const rawGovernance=settings.governance??{};const preset=normalizeGovernancePreset(rawGovernance.preset);const extras=resolveGovernanceExtras(rawGovernance);if(preset==="custom"){const baseline2=resolveGovernanceKnobsFromPreset("default");const requireCloseReason2=extras.require_close_reason??baseline2.require_close_reason;return{preset,ownership_enforcement:rawGovernance.ownership_enforcement??baseline2.ownership_enforcement,create_mode_default:rawGovernance.create_mode_default??baseline2.create_mode_default,close_validation_default:rawGovernance.close_validation_default??baseline2.close_validation_default,parent_reference:rawGovernance.parent_reference??baseline2.parent_reference,metadata_profile:rawGovernance.metadata_profile??baseline2.metadata_profile,force_required_for_stale_lock:rawGovernance.force_required_for_stale_lock??baseline2.force_required_for_stale_lock,...extras,require_close_reason:requireCloseReason2,duplicate_detection_mode:extras.duplicate_detection_mode??baseline2.duplicate_detection_mode,duplicate_detection_threshold:extras.duplicate_detection_threshold??baseline2.duplicate_detection_threshold,duplicate_detection_limit:extras.duplicate_detection_limit??baseline2.duplicate_detection_limit}}const baseline=resolveGovernanceKnobsFromPreset(preset);const requireCloseReason=extras.require_close_reason??baseline.require_close_reason;return{preset,...baseline,...extras,require_close_reason:requireCloseReason}}function cloneDefaults(){return structuredClone(SETTINGS_DEFAULTS)}function normalizeSearchMutationRefreshPolicy(value){if(value==="cache_only"||value==="semantic_configured"||value==="semantic_auto"){return value}return SETTINGS_DEFAULTS.search.mutation_refresh_policy}function normalizeSearchQueryExpansionEnabled(value){if(typeof value==="boolean"){return value}return SETTINGS_DEFAULTS.search.query_expansion.enabled}function normalizeSearchQueryExpansionProvider(value){if(typeof value!=="string"){return SETTINGS_DEFAULTS.search.query_expansion.provider}return value.trim()}function normalizeSearchRerankEnabled(value){if(typeof value==="boolean"){return value}return SETTINGS_DEFAULTS.search.rerank.enabled}function normalizeSearchRerankModel(value){if(typeof value!=="string"){return SETTINGS_DEFAULTS.search.rerank.model}return value.trim()}function normalizeSearchRerankTopK(value){if(typeof value==="number"&&Number.isFinite(value)&&Number.isInteger(value)&&value>0){return value}return SETTINGS_DEFAULTS.search.rerank.top_k}function normalizeVectorStoreCollectionName(value){if(typeof value!=="string"){return SETTINGS_DEFAULTS.vector_store.collection_name}const sanitized=value.trim().replaceAll(/[^a-zA-Z0-9_-]/g,"_");const truncated=sanitized.slice(0,MAX_VECTOR_STORE_COLLECTION_NAME_LENGTH);return truncated.length>0?truncated:SETTINGS_DEFAULTS.vector_store.collection_name}function cloneOptionalArray(value){return{present:Array.isArray(value),values:Array.isArray(value)?structuredClone(value):[]}}function buildSettingsPersistSourceSnapshot(parsedSettings,runtimeSettings){const sourceSchema=parsedSettings.schema;const sourceStatuses=cloneOptionalArray(sourceSchema?.statuses);const sourceFields=cloneOptionalArray(sourceSchema?.fields);const sourceTypeWorkflows=cloneOptionalArray(sourceSchema?.type_workflows);return{source_settings:structuredClone(parsedSettings),has_source_item_type_definitions:Array.isArray(parsedSettings.item_types?.definitions),source_item_type_definitions:normalizeItemTypeDefinitions(parsedSettings.item_types?.definitions),has_source_schema_statuses:sourceStatuses.present,source_schema_statuses:sourceStatuses.values,has_source_schema_fields:sourceFields.present,source_schema_fields:sourceFields.values,has_source_schema_type_workflows:sourceTypeWorkflows.present,source_schema_type_workflows:sourceTypeWorkflows.values,runtime_item_type_definitions:normalizeItemTypeDefinitions(runtimeSettings.item_types?.definitions),runtime_schema_statuses:structuredClone(runtimeSettings.schema.statuses),runtime_schema_fields:structuredClone(runtimeSettings.schema.fields),runtime_schema_type_workflows:structuredClone(runtimeSettings.schema.type_workflows??[])}}function attachSettingsPersistSourceSnapshot(settings,source){Object.defineProperty(settings,SETTINGS_PERSIST_SOURCE_SYMBOL,{value:source,writable:true,configurable:true,enumerable:false})}function getSettingsPersistSourceSnapshot(settings){const candidate=settings[SETTINGS_PERSIST_SOURCE_SYMBOL];if(!candidate||typeof candidate!=="object"){return void 0}return candidate}function persistSelectedItemFormat(settings){const source=getSettingsPersistSourceSnapshot(settings);if(source){const detachedSource=structuredClone(source);detachedSource.source_settings.item_format=settings.item_format;attachSettingsPersistSourceSnapshot(settings,detachedSource)}}function cloneSettingsReadResult(result){const clonedSettings=structuredClone(result.settings);const persistSource=getSettingsPersistSourceSnapshot(result.settings);if(persistSource){attachSettingsPersistSourceSnapshot(clonedSettings,persistSource)}return{settings:clonedSettings,metadata:{has_explicit_item_format:result.metadata.has_explicit_item_format},warnings:[...result.warnings]}}function resolveSettingsReadTrackedPaths(pmRoot,schema,settingsPath){const normalizedSchema=normalizeRuntimeSchemaSettings(schema);return[settingsPath,filePathForSchemaSection(pmRoot,normalizedSchema.files.types,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.types),filePathForSchemaSection(pmRoot,normalizedSchema.files.statuses,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.statuses),filePathForSchemaSection(pmRoot,normalizedSchema.files.fields,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.fields),filePathForSchemaSection(pmRoot,normalizedSchema.files.workflows,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.workflows)]}async function cacheSettingsReadResult(pmRoot,trackedPaths,result){const signatures=await collectSettingsReadCacheSignatures(trackedPaths);setSettingsReadCacheEntry(pmRoot,{tracked_paths:trackedPaths,signatures,value:cloneSettingsReadResult(result)})}async function cacheSettingsReadResultSafe(pmRoot,trackedPaths,result){try{await cacheSettingsReadResult(pmRoot,trackedPaths,result)}catch{clearSettingsReadCache(pmRoot)}}function findSettingsReadCacheSignature(signatures,targetPath){return signatures.find(signature=>signature.path===targetPath)}function selectedSettingsReadCacheSignaturesEqual(before,after,targetPaths){for(const targetPath of targetPaths){const beforeSignature=findSettingsReadCacheSignature(before,targetPath);const afterSignature=findSettingsReadCacheSignature(after,targetPath);if(!beforeSignature||!afterSignature||!settingsReadCacheSignaturesEqual([beforeSignature],[afterSignature])){return false}}return true}async function cacheSettingsReadResultIfStable(pmRoot,trackedPaths,result,stableSignatures,stablePaths){try{const currentSignatures=await collectSettingsReadCacheSignatures(trackedPaths);if(!selectedSettingsReadCacheSignaturesEqual(stableSignatures,currentSignatures,stablePaths)){clearSettingsReadCache(pmRoot);return}setSettingsReadCacheEntry(pmRoot,{tracked_paths:trackedPaths,signatures:currentSignatures,value:cloneSettingsReadResult(result)})}catch{clearSettingsReadCache(pmRoot)}}function resolvePersistedFileBackedSchemaSections(settings,source){const normalizedSchema=normalizeRuntimeSchemaSettings(settings.schema);const currentItemTypeDefinitions=normalizeItemTypeDefinitions(settings.item_types?.definitions);if(!source){return{item_type_definitions:currentItemTypeDefinitions,schema_statuses:normalizedSchema.statuses,schema_fields:normalizedSchema.fields,schema_type_workflows:normalizedSchema.type_workflows}}const currentTypeWorkflows=normalizedSchema.type_workflows??[];const itemTypeDefinitionsUnchanged=stableValueEquals(currentItemTypeDefinitions,source.runtime_item_type_definitions);const schemaStatusesUnchanged=stableValueEquals(normalizedSchema.statuses,source.runtime_schema_statuses);const schemaFieldsUnchanged=stableValueEquals(normalizedSchema.fields,source.runtime_schema_fields);const schemaTypeWorkflowsUnchanged=stableValueEquals(currentTypeWorkflows,source.runtime_schema_type_workflows);return{item_type_definitions:itemTypeDefinitionsUnchanged?source.has_source_item_type_definitions?normalizeItemTypeDefinitions(source.source_item_type_definitions):[]:currentItemTypeDefinitions,schema_statuses:schemaStatusesUnchanged?source.has_source_schema_statuses?structuredClone(source.source_schema_statuses):[]:normalizedSchema.statuses,schema_fields:schemaFieldsUnchanged?source.has_source_schema_fields?structuredClone(source.source_schema_fields):[]:normalizedSchema.fields,schema_type_workflows:schemaTypeWorkflowsUnchanged?source.has_source_schema_type_workflows?structuredClone(source.source_schema_type_workflows):void 0:normalizedSchema.type_workflows}}function buildFallbackSettingsReadResult(warning){return{settings:cloneDefaults(),metadata:{has_explicit_item_format:false},warnings:warning?[warning]:[]}}function hasExplicitItemFormat(raw){if(typeof raw!=="object"||raw===null||Array.isArray(raw)){return false}const itemFormat=raw.item_format;return itemFormat==="toon"||itemFormat==="json_markdown"}function normalizeStringList(values){return[...new Set((values??[]).map(value=>value.trim()).filter(value=>value.length>0))].sort((left,right)=>left.localeCompare(right))}function normalizeAgentGuidanceSettings(value){const defaults=SETTINGS_DEFAULTS.agent_guidance;const templateVersion=value?.template_version;return{prompt_completed:value?.prompt_completed===true,declined:value?.declined===true,declined_at:typeof value?.declined_at==="string"?value.declined_at:defaults.declined_at,template_version:typeof templateVersion==="number"&&Number.isInteger(templateVersion)&&templateVersion>0?templateVersion:defaults.template_version,last_checked_files:normalizeStringList(value?.last_checked_files??defaults.last_checked_files)}}function normalizeLowerStringList(values){return[...new Set((values??[]).map(value=>value.trim().toLowerCase()).filter(value=>value.length>0))].sort((left,right)=>left.localeCompare(right))}function normalizeExtensionPolicyMode(value){if(value==="off"||value==="warn"||value==="enforce"){return value}return SETTINGS_DEFAULTS.extensions.policy.mode}function normalizeExtensionTrustMode(value){if(value==="off"||value==="warn"||value==="enforce"){return value}return SETTINGS_DEFAULTS.extensions.policy.trust_mode}function normalizeExtensionSandboxProfile(value){if(value==="none"||value==="restricted"||value==="strict"){return value}return SETTINGS_DEFAULTS.extensions.policy.default_sandbox_profile}function normalizeExtensionPolicyOverride(override){const name=override.name.trim().toLowerCase();if(name.length===0){return null}const normalized={name};if(override.disabled===true){normalized.disabled=true}if(override.require_trusted===true){normalized.require_trusted=true}if(override.require_provenance===true){normalized.require_provenance=true}if(override.sandbox_profile!==void 0){normalized.sandbox_profile=normalizeExtensionSandboxProfile(override.sandbox_profile)}const allowedCapabilities=normalizeLowerStringList(override.allowed_capabilities);const blockedCapabilities=normalizeLowerStringList(override.blocked_capabilities);const allowedSurfaces=normalizeLowerStringList(override.allowed_surfaces);const blockedSurfaces=normalizeLowerStringList(override.blocked_surfaces);const allowedCommands=normalizeLowerStringList(override.allowed_commands);const blockedCommands=normalizeLowerStringList(override.blocked_commands);const allowedActions=normalizeLowerStringList(override.allowed_actions);const blockedActions=normalizeLowerStringList(override.blocked_actions);const allowedServices=normalizeLowerStringList(override.allowed_services);const blockedServices=normalizeLowerStringList(override.blocked_services);if(allowedCapabilities.length>0){normalized.allowed_capabilities=allowedCapabilities}if(blockedCapabilities.length>0){normalized.blocked_capabilities=blockedCapabilities}if(allowedSurfaces.length>0){normalized.allowed_surfaces=allowedSurfaces}if(blockedSurfaces.length>0){normalized.blocked_surfaces=blockedSurfaces}if(allowedCommands.length>0){normalized.allowed_commands=allowedCommands}if(blockedCommands.length>0){normalized.blocked_commands=blockedCommands}if(allowedActions.length>0){normalized.allowed_actions=allowedActions}if(blockedActions.length>0){normalized.blocked_actions=blockedActions}if(allowedServices.length>0){normalized.allowed_services=allowedServices}if(blockedServices.length>0){normalized.blocked_services=blockedServices}return normalized}function normalizeExtensionPolicyOverrides(overrides){const dedupedByName=new Map;for(const override of overrides??[]){const normalized=normalizeExtensionPolicyOverride(override);if(!normalized){continue}dedupedByName.set(normalized.name,normalized)}return[...dedupedByName.values()].sort((left,right)=>left.name.localeCompare(right.name))}function normalizePmMaxVersionExceededModeValue(value){return value==="block"||value==="warn"?value:void 0}function normalizePmMaxVersionExceededModeSetting(value){if(typeof value==="string"){return normalizePmMaxVersionExceededModeValue(value)}if(typeof value==="object"&&value!==null&&!Array.isArray(value)){const global2=normalizePmMaxVersionExceededModeValue(value.global);const project=normalizePmMaxVersionExceededModeValue(value.project);if(global2===void 0&&project===void 0){return void 0}return{...global2!==void 0?{global:global2}:{},...project!==void 0?{project}:{}}}return void 0}function normalizeExtensionPolicyList(policy,key){return normalizeLowerStringList(policy?.[key]??SETTINGS_DEFAULTS.extensions.policy[key])}function normalizeExtensionPolicySettings(policy){const pmMaxVersionExceededMode=normalizePmMaxVersionExceededModeSetting(policy?.pm_max_version_exceeded_mode);return{mode:normalizeExtensionPolicyMode(policy?.mode),trust_mode:normalizeExtensionTrustMode(policy?.trust_mode),...pmMaxVersionExceededMode!==void 0?{pm_max_version_exceeded_mode:pmMaxVersionExceededMode}:{},require_provenance:policy?.require_provenance===true,trusted_extensions:normalizeExtensionPolicyList(policy,"trusted_extensions"),default_sandbox_profile:normalizeExtensionSandboxProfile(policy?.default_sandbox_profile),allowed_extensions:normalizeExtensionPolicyList(policy,"allowed_extensions"),blocked_extensions:normalizeExtensionPolicyList(policy,"blocked_extensions"),allowed_capabilities:normalizeExtensionPolicyList(policy,"allowed_capabilities"),blocked_capabilities:normalizeExtensionPolicyList(policy,"blocked_capabilities"),allowed_surfaces:normalizeExtensionPolicyList(policy,"allowed_surfaces"),blocked_surfaces:normalizeExtensionPolicyList(policy,"blocked_surfaces"),allowed_commands:normalizeExtensionPolicyList(policy,"allowed_commands"),blocked_commands:normalizeExtensionPolicyList(policy,"blocked_commands"),allowed_actions:normalizeExtensionPolicyList(policy,"allowed_actions"),blocked_actions:normalizeExtensionPolicyList(policy,"blocked_actions"),allowed_services:normalizeExtensionPolicyList(policy,"allowed_services"),blocked_services:normalizeExtensionPolicyList(policy,"blocked_services"),extension_overrides:normalizeExtensionPolicyOverrides(policy?.extension_overrides??SETTINGS_DEFAULTS.extensions.policy.extension_overrides)}}function normalizeValidationMetadataRequiredFields(values){const normalized=[...new Set((values??[]).map(value=>value.trim().toLowerCase().replaceAll("-","_")))].filter(value=>value.length>0).sort((left,right)=>left.localeCompare(right));return normalized.filter(value=>["author","acceptance_criteria","estimated_minutes","close_reason","reviewer","risk","confidence","sprint","release"].includes(value))}function normalizeValidationPatternList(values){return[...new Set((values??[]).map(value=>value.trim().toLowerCase()).filter(value=>value.length>0))].sort((left,right)=>left.localeCompare(right))}function valueOrDefault(value,fallback){return value===void 0?fallback:value}function recordOrEmpty(value){return typeof value==="object"&&value!==null&&!Array.isArray(value)?value:{}}function arrayOrEmpty(value){return Array.isArray(value)?value:[]}function buildValidationSettings(settings,defaults,governance){return{...defaults.validation,...settings.validation,parent_reference:governance.parent_reference,metadata_profile:governance.metadata_profile,metadata_required_fields:normalizeValidationMetadataRequiredFields(settings.validation?.metadata_required_fields),lifecycle_stale_blocker_reason_patterns:normalizeValidationPatternList(settings.validation?.lifecycle_stale_blocker_reason_patterns??defaults.validation.lifecycle_stale_blocker_reason_patterns),lifecycle_closure_like_blocked_reason_patterns:normalizeValidationPatternList(settings.validation?.lifecycle_closure_like_blocked_reason_patterns??defaults.validation.lifecycle_closure_like_blocked_reason_patterns),lifecycle_closure_like_resolution_patterns:normalizeValidationPatternList(settings.validation?.lifecycle_closure_like_resolution_patterns??defaults.validation.lifecycle_closure_like_resolution_patterns),lifecycle_closure_like_actual_result_patterns:normalizeValidationPatternList(settings.validation?.lifecycle_closure_like_actual_result_patterns??defaults.validation.lifecycle_closure_like_actual_result_patterns),estimate_defaults_by_type:normalizeEstimateDefaultOverrides(settings.validation?.estimate_defaults_by_type)}}function buildTelemetrySettings(settings,defaults){return{enabled:settings.telemetry?.enabled??defaults.telemetry.enabled,first_run_prompt_completed:settings.telemetry?.first_run_prompt_completed??defaults.telemetry.first_run_prompt_completed,capture_level:settings.telemetry?.capture_level??defaults.telemetry.capture_level,endpoint:settings.telemetry?.endpoint??defaults.telemetry.endpoint,installation_id:settings.telemetry?.installation_id??defaults.telemetry.installation_id,retention_days:settings.telemetry?.retention_days??defaults.telemetry.retention_days}}function buildSearchSettings(settings,defaults){return{...defaults.search,...settings.search,mutation_refresh_policy:normalizeSearchMutationRefreshPolicy(settings.search?.mutation_refresh_policy),query_expansion:{...defaults.search.query_expansion,...settings.search?.query_expansion,enabled:normalizeSearchQueryExpansionEnabled(settings.search?.query_expansion?.enabled),provider:normalizeSearchQueryExpansionProvider(settings.search?.query_expansion?.provider)},rerank:{...defaults.search.rerank,...settings.search?.rerank,enabled:normalizeSearchRerankEnabled(settings.search?.rerank?.enabled),model:normalizeSearchRerankModel(settings.search?.rerank?.model),top_k:normalizeSearchRerankTopK(settings.search?.rerank?.top_k)}}}function buildVectorStoreSettings(settings,defaults){return{adapter:settings.vector_store.adapter??defaults.vector_store.adapter,collection_name:normalizeVectorStoreCollectionName(settings.vector_store.collection_name),qdrant:{...defaults.vector_store.qdrant,...settings.vector_store.qdrant},lancedb:{...defaults.vector_store.lancedb,...settings.vector_store.lancedb}}}function normalizeSettingsItemFormat(settings,defaults){if(settings.item_format==="json_markdown"){return"toon"}return settings.item_format??defaults.item_format}function buildContextSettings(settings,defaults){return{default_depth:settings.context?.default_depth??defaults.context.default_depth,activity_limit:settings.context?.activity_limit??defaults.context.activity_limit,stale_threshold_days:settings.context?.stale_threshold_days??defaults.context.stale_threshold_days,sections:{...defaults.context.sections,...settings.context?.sections}}}function buildProviderSettings(settings,defaults){return{openai:{...defaults.providers.openai,...settings.providers.openai},ollama:{...defaults.providers.ollama,...settings.providers.ollama}}}function normalizeItemTypeDefinitions(definitions){const normalized=(definitions??[]).map(definition=>normalizeItemTypeDefinition(definition)).filter(definition=>definition!==null);const dedupedByName=new Map;for(const definition of normalized){dedupedByName.set(definition.name.toLowerCase(),definition)}return[...dedupedByName.values()].sort((left,right)=>left.name.localeCompare(right.name))}function mergeSettings(settings){const defaults=cloneDefaults();const governance=resolveGovernanceKnobs({governance:settings.governance??{preset:"default"}});return{...defaults,...settings,item_format:normalizeSettingsItemFormat(settings,defaults),locks:{...defaults.locks,...settings.locks},ids:{...defaults.ids,...settings.ids},agent_identity:structuredClone(settings.agent_identity??defaults.agent_identity),mutation_guard:{...defaults.mutation_guard,...settings.mutation_guard},checkpoints:{...defaults.checkpoints,...settings.checkpoints},output:{...defaults.output,...settings.output},ux:{...defaults.ux,...settings.ux},history:{...defaults.history,...settings.history,compact_policy:{...defaults.history.compact_policy,...settings.history?.compact_policy}},validation:buildValidationSettings(settings,defaults,governance),governance,workflow:{definition_of_done:[...settings.workflow?.definition_of_done??defaults.workflow.definition_of_done]},testing:{record_results_to_items:settings.testing?.record_results_to_items??defaults.testing.record_results_to_items,allow_untrusted_linked_tests:settings.testing?.allow_untrusted_linked_tests??defaults.testing.allow_untrusted_linked_tests},telemetry:buildTelemetrySettings(settings,defaults),agent_guidance:normalizeAgentGuidanceSettings(settings.agent_guidance??defaults.agent_guidance),item_types:{definitions:normalizeItemTypeDefinitions(settings.item_types?.definitions)},schema:normalizeRuntimeSchemaSettings(settings.schema??defaults.schema),context:buildContextSettings(settings,defaults),extensions:{enabled:[...settings.extensions.enabled],disabled:[...settings.extensions.disabled],policy:normalizeExtensionPolicySettings(settings.extensions.policy??defaults.extensions.policy)},search:buildSearchSettings(settings,defaults),providers:buildProviderSettings(settings,defaults),vector_store:buildVectorStoreSettings(settings,defaults)}}function orderSerializedSettingsSections(ordered){ordered.agent_identity=orderObject(ordered.agent_identity,["probes_enabled","identity_vocabulary","harness_signals"]);const orderedAgentIdentity=ordered.agent_identity;if(Object.hasOwn(orderedAgentIdentity,"identity_vocabulary")){orderedAgentIdentity.identity_vocabulary=orderObject(recordOrEmpty(orderedAgentIdentity.identity_vocabulary),["version","aliases"])}ordered.agent_identity.harness_signals=arrayOrEmpty(ordered.agent_identity.harness_signals).map(entry=>orderObject(recordOrEmpty(entry),["harness","environment_keys","model_environment_keys","session_environment_keys","provenance_environment_keys","provenance_resolvers","provenance_unavailable_dimensions","argv_markers","client_names"]));ordered.locks=orderObject(ordered.locks,["ttl_seconds","wait_ms"]);ordered.ids=orderObject(ordered.ids,["token_length"]);ordered.mutation_guard=orderObject(ordered.mutation_guard,["require_attributed_author","secret_guard","stale_in_progress_hours"]);ordered.checkpoints=orderObject(ordered.checkpoints,["retention_days"]);ordered.output=orderObject(ordered.output,["default_format"]);ordered.ux=orderObject(ordered.ux,["deprecation_hints"]);ordered.history=orderObject(ordered.history,["missing_stream","compact_policy"]);ordered.validation=orderObject(ordered.validation,["sprint_release_format","parent_reference","metadata_profile","metadata_required_fields","lifecycle_stale_blocker_reason_patterns","lifecycle_closure_like_blocked_reason_patterns","lifecycle_closure_like_resolution_patterns","lifecycle_closure_like_actual_result_patterns","estimate_defaults_by_type"]);ordered.governance=orderObject(ordered.governance,["preset","ownership_enforcement","create_mode_default","close_validation_default","require_close_reason","parent_reference","metadata_profile","force_required_for_stale_lock","create_default_type","workflow_enforcement","duplicate_detection_mode","duplicate_detection_threshold","duplicate_detection_limit"]);ordered.workflow=orderObject(ordered.workflow,["definition_of_done"]);ordered.testing=orderObject(ordered.testing,["record_results_to_items","allow_untrusted_linked_tests"]);ordered.telemetry=orderObject(ordered.telemetry,["enabled","first_run_prompt_completed","capture_level","endpoint","installation_id","retention_days"]);ordered.agent_guidance=orderObject(ordered.agent_guidance,["prompt_completed","declined","declined_at","template_version","last_checked_files"]);ordered.item_types=orderObject(ordered.item_types,["definitions"]);ordered.schema=orderObject(ordered.schema,["version","files","statuses","fields","workflow","type_workflows","unknown_field_policy"]);ordered.schema.files=orderObject(recordOrEmpty(ordered.schema.files),["types","statuses","fields","workflows"]);ordered.schema.workflow=orderObject(recordOrEmpty(ordered.schema.workflow),["draft_status","open_status","in_progress_status","blocked_status","close_status","canceled_status"]);ordered.context=orderObject(ordered.context,["default_depth","activity_limit","stale_threshold_days","sections"]);ordered.context.sections=orderObject(recordOrEmpty(ordered.context.sections),["hierarchy","activity","progress","blockers","files","workload","staleness","tests"]);ordered.extensions=orderObject(ordered.extensions,["enabled","disabled","policy"]);ordered.extensions.policy=orderObject(recordOrEmpty(ordered.extensions.policy),["mode","trust_mode","pm_max_version_exceeded_mode","require_provenance","trusted_extensions","default_sandbox_profile","allowed_extensions","blocked_extensions","allowed_capabilities","blocked_capabilities","allowed_surfaces","blocked_surfaces","allowed_commands","blocked_commands","allowed_actions","blocked_actions","allowed_services","blocked_services","extension_overrides"]);ordered.extensions.policy.extension_overrides=arrayOrEmpty(ordered.extensions.policy.extension_overrides).map(entry=>orderObject(recordOrEmpty(entry),["name","disabled","require_trusted","require_provenance","sandbox_profile","allowed_capabilities","blocked_capabilities","allowed_surfaces","blocked_surfaces","allowed_commands","blocked_commands","allowed_actions","blocked_actions","allowed_services","blocked_services"]));ordered.search=orderObject(ordered.search,["score_threshold","hybrid_semantic_weight","max_results","embedding_model","embedding_corpus_max_characters","embedding_batch_size","embedding_timeout_ms","scanner_max_batch_retries","provider","mutation_refresh_policy","query_expansion","rerank"]);ordered.search.query_expansion=orderObject(recordOrEmpty(ordered.search.query_expansion),["enabled","provider"]);ordered.search.rerank=orderObject(recordOrEmpty(ordered.search.rerank),["enabled","model","top_k"]);ordered.providers=orderObject(ordered.providers,["openai","ollama"]);ordered.providers.openai=orderObject(recordOrEmpty(ordered.providers.openai),["base_url","api_key","model"]);ordered.providers.ollama=orderObject(recordOrEmpty(ordered.providers.ollama),["base_url","model"]);ordered.vector_store=orderObject(ordered.vector_store,["adapter","collection_name","qdrant","lancedb"]);ordered.vector_store.qdrant=orderObject(recordOrEmpty(ordered.vector_store.qdrant),["url","api_key"]);ordered.vector_store.lancedb=orderObject(recordOrEmpty(ordered.vector_store.lancedb),["path"])}function buildSerializeBaseSettings(settings){return{...settings,locks:valueOrDefault(settings.locks,SETTINGS_DEFAULTS.locks),ids:valueOrDefault(settings.ids,SETTINGS_DEFAULTS.ids),agent_identity:valueOrDefault(settings.agent_identity,SETTINGS_DEFAULTS.agent_identity),mutation_guard:valueOrDefault(settings.mutation_guard,SETTINGS_DEFAULTS.mutation_guard),checkpoints:valueOrDefault(settings.checkpoints,SETTINGS_DEFAULTS.checkpoints),output:valueOrDefault(settings.output,SETTINGS_DEFAULTS.output),ux:valueOrDefault(settings.ux,SETTINGS_DEFAULTS.ux),history:valueOrDefault(settings.history,SETTINGS_DEFAULTS.history),validation:valueOrDefault(settings.validation,SETTINGS_DEFAULTS.validation),workflow:valueOrDefault(settings.workflow,SETTINGS_DEFAULTS.workflow),testing:valueOrDefault(settings.testing,SETTINGS_DEFAULTS.testing),telemetry:valueOrDefault(settings.telemetry,SETTINGS_DEFAULTS.telemetry),agent_guidance:valueOrDefault(settings.agent_guidance,SETTINGS_DEFAULTS.agent_guidance),item_types:valueOrDefault(settings.item_types,SETTINGS_DEFAULTS.item_types),schema:valueOrDefault(settings.schema,SETTINGS_DEFAULTS.schema),context:valueOrDefault(settings.context,SETTINGS_DEFAULTS.context),extensions:valueOrDefault(settings.extensions,SETTINGS_DEFAULTS.extensions),search:valueOrDefault(settings.search,SETTINGS_DEFAULTS.search),providers:valueOrDefault(settings.providers,SETTINGS_DEFAULTS.providers),vector_store:valueOrDefault(settings.vector_store,SETTINGS_DEFAULTS.vector_store)}}function buildSerializedValidationSettings(baseSettings,governance){return{...baseSettings.validation,parent_reference:governance.parent_reference,metadata_profile:governance.metadata_profile,metadata_required_fields:normalizeValidationMetadataRequiredFields(baseSettings.validation?.metadata_required_fields),lifecycle_stale_blocker_reason_patterns:normalizeValidationPatternList(baseSettings.validation?.lifecycle_stale_blocker_reason_patterns??SETTINGS_DEFAULTS.validation.lifecycle_stale_blocker_reason_patterns),lifecycle_closure_like_blocked_reason_patterns:normalizeValidationPatternList(baseSettings.validation?.lifecycle_closure_like_blocked_reason_patterns??SETTINGS_DEFAULTS.validation.lifecycle_closure_like_blocked_reason_patterns),lifecycle_closure_like_resolution_patterns:normalizeValidationPatternList(baseSettings.validation?.lifecycle_closure_like_resolution_patterns??SETTINGS_DEFAULTS.validation.lifecycle_closure_like_resolution_patterns),lifecycle_closure_like_actual_result_patterns:normalizeValidationPatternList(baseSettings.validation?.lifecycle_closure_like_actual_result_patterns??SETTINGS_DEFAULTS.validation.lifecycle_closure_like_actual_result_patterns),estimate_defaults_by_type:normalizeEstimateDefaultOverrides(baseSettings.validation?.estimate_defaults_by_type)}}function buildSerializedSearchSettings(baseSettings){return{...SETTINGS_DEFAULTS.search,...baseSettings.search,mutation_refresh_policy:normalizeSearchMutationRefreshPolicy(baseSettings.search?.mutation_refresh_policy),query_expansion:{...SETTINGS_DEFAULTS.search.query_expansion,...baseSettings.search?.query_expansion,enabled:normalizeSearchQueryExpansionEnabled(baseSettings.search?.query_expansion?.enabled),provider:normalizeSearchQueryExpansionProvider(baseSettings.search?.query_expansion?.provider)},rerank:{...SETTINGS_DEFAULTS.search.rerank,...baseSettings.search?.rerank,enabled:normalizeSearchRerankEnabled(baseSettings.search?.rerank?.enabled),model:normalizeSearchRerankModel(baseSettings.search?.rerank?.model),top_k:normalizeSearchRerankTopK(baseSettings.search?.rerank?.top_k)}}}function buildSerializedContextSettings(baseSettings){return{default_depth:baseSettings.context?.default_depth??SETTINGS_DEFAULTS.context.default_depth,activity_limit:baseSettings.context?.activity_limit??SETTINGS_DEFAULTS.context.activity_limit,stale_threshold_days:baseSettings.context?.stale_threshold_days??SETTINGS_DEFAULTS.context.stale_threshold_days,sections:{...SETTINGS_DEFAULTS.context.sections,...baseSettings.context?.sections}}}function buildSerializedVectorStoreSettings(baseSettings){return{...baseSettings.vector_store,adapter:baseSettings.vector_store?.adapter??SETTINGS_DEFAULTS.vector_store.adapter,collection_name:normalizeVectorStoreCollectionName(baseSettings.vector_store?.collection_name),qdrant:{...baseSettings.vector_store?.qdrant},lancedb:{...baseSettings.vector_store?.lancedb}}}function buildNormalizedSettingsForSerialization(baseSettings,governance,normalizedSchema,persistedFileBackedSections){return{...baseSettings,item_format:"toon",validation:buildSerializedValidationSettings(baseSettings,governance),governance,agent_guidance:normalizeAgentGuidanceSettings(baseSettings.agent_guidance),item_types:{definitions:persistedFileBackedSections.item_type_definitions},schema:{...normalizedSchema,statuses:persistedFileBackedSections.schema_statuses,fields:persistedFileBackedSections.schema_fields,type_workflows:persistedFileBackedSections.schema_type_workflows},search:buildSerializedSearchSettings(baseSettings),context:buildSerializedContextSettings(baseSettings),extensions:{enabled:normalizeStringList(baseSettings.extensions?.enabled),disabled:normalizeStringList(baseSettings.extensions?.disabled),policy:normalizeExtensionPolicySettings(baseSettings.extensions?.policy)},vector_store:buildSerializedVectorStoreSettings(baseSettings)}}function applySettingsDelta(target,baseline,current){const keys=new Set([...Object.keys(baseline),...Object.keys(current)]);for(const key of keys){const before=baseline[key];const after=current[key];if(stableValueEquals(before,after))continue;if(after===void 0){delete target[key];continue}if(typeof before==="object"&&before!==null&&!Array.isArray(before)&&typeof after==="object"&&after!==null&&!Array.isArray(after)){const existing=target[key];const nestedTarget=typeof existing==="object"&&existing!==null&&!Array.isArray(existing)?existing:{};applySettingsDelta(nestedTarget,before,after);if(Object.keys(nestedTarget).length>0)target[key]=nestedTarget;else delete target[key];continue}target[key]=structuredClone(after)}}const SETTINGS_TOP_LEVEL_KEY_ORDER=["version","id_prefix","ids","author_default","agent_identity","mutation_guard","item_format","locks","checkpoints","output","ux","history","validation","governance","workflow","testing","telemetry","agent_guidance","item_types","schema","context","extensions","search","providers","vector_store"];function buildOrderedSettingsForSerialization(settings,persistSource){const baseSettings=buildSerializeBaseSettings(settings);const governance=resolveGovernanceKnobs(baseSettings);const normalizedSchema=normalizeRuntimeSchemaSettings(baseSettings.schema);const persistedFileBackedSections=resolvePersistedFileBackedSchemaSections(baseSettings,persistSource);const normalizedSettings=buildNormalizedSettingsForSerialization(baseSettings,governance,normalizedSchema,persistedFileBackedSections);const ordered=orderObject({...normalizedSettings,governance:normalizeGovernanceForPersist(governance)},SETTINGS_TOP_LEVEL_KEY_ORDER);orderSerializedSettingsSections(ordered);return ordered}function serializeSettings(settings,options={}){const ordered=buildOrderedSettingsForSerialization(settings,options.persist_source);if(options.persist_source){const baselineSettings=mergeSettings(options.persist_source.source_settings);baselineSettings.item_types={definitions:structuredClone(options.persist_source.runtime_item_type_definitions)};baselineSettings.schema={...baselineSettings.schema,statuses:structuredClone(options.persist_source.runtime_schema_statuses),fields:structuredClone(options.persist_source.runtime_schema_fields),type_workflows:structuredClone(options.persist_source.runtime_schema_type_workflows)};const baseline=buildOrderedSettingsForSerialization(baselineSettings,options.persist_source);const sparse=structuredClone(options.persist_source.source_settings);applySettingsDelta(sparse,baseline,ordered);return`${JSON.stringify(orderObject(sparse,SETTINGS_TOP_LEVEL_KEY_ORDER),null,2)}
|
|
2
|
+
`}return`${JSON.stringify(ordered,null,2)}
|
|
3
|
+
`}async function readSettingsWithMetadata(pmRoot){const settingsPath=getSettingsPath(pmRoot);let trackedPathsForFailure=[settingsPath];await runActiveOnReadHooks({path:settingsPath,scope:"project"});const cachedResult=getSettingsReadCacheEntry(pmRoot);if(cachedResult){const currentSignatures=await collectSettingsReadCacheSignatures(cachedResult.tracked_paths);if(settingsReadCacheSignaturesEqual(currentSignatures,cachedResult.signatures)){return cloneSettingsReadResult(cachedResult.value)}}const settingsOnlySignatures=await collectSettingsReadCacheSignatures([settingsPath]);let raw;try{raw=await readFileIfExists(settingsPath)}catch{return buildFallbackSettingsReadResult("settings_read_fs_error")}if(raw===null){const fallback=buildFallbackSettingsReadResult();await cacheSettingsReadResultIfStable(pmRoot,[settingsPath],fallback,settingsOnlySignatures,[settingsPath]);return fallback}const settingsSignaturesAfterRead=await collectSettingsReadCacheSignatures([settingsPath]);if(!settingsReadCacheSignaturesEqual(settingsOnlySignatures,settingsSignaturesAfterRead)){clearSettingsReadCache(pmRoot);return readSettingsWithMetadata(pmRoot)}let parsed;try{parsed=JSON.parse(raw)}catch{const fallback=buildFallbackSettingsReadResult("settings_read_invalid_json");await cacheSettingsReadResultIfStable(pmRoot,[settingsPath],fallback,settingsSignaturesAfterRead,[settingsPath]);return fallback}const validated=validateSettings(parsed);if(!validated.success){const fallback=buildFallbackSettingsReadResult("settings_read_invalid_schema");await cacheSettingsReadResultIfStable(pmRoot,[settingsPath],fallback,settingsSignaturesAfterRead,[settingsPath]);return fallback}try{const mergedSettings=mergeSettings(validated.data);const trackedPaths=resolveSettingsReadTrackedPaths(pmRoot,mergedSettings.schema,settingsPath);trackedPathsForFailure=trackedPaths;const signaturesBeforeSchemaLoad=await collectSettingsReadCacheSignatures(trackedPaths);const schemaScaffold=await ensureRuntimeSchemaFileScaffold(pmRoot,mergedSettings.schema);const loadedSchemaSections=await loadRuntimeSchemaFromOptionalFiles(pmRoot,mergedSettings.schema);const signaturesAfterSchemaLoad=await collectSettingsReadCacheSignatures(trackedPaths);const settings={...mergedSettings,item_types:{definitions:normalizeItemTypeDefinitions([...mergedSettings.item_types.definitions,...arrayOrEmpty(loadedSchemaSections.type_definitions_from_file)])},schema:loadedSchemaSections.schema};attachSettingsPersistSourceSnapshot(settings,buildSettingsPersistSourceSnapshot(validated.data,settings));const result={settings,metadata:{has_explicit_item_format:hasExplicitItemFormat(parsed)},warnings:[...validated.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[],...schemaScaffold.created_paths.map(createdPath=>`runtime_schema_bootstrap_created:${createdPath}`),...loadedSchemaSections.warnings]};if(schemaScaffold.created_paths.length===0){if(!settingsReadCacheSignaturesEqual(signaturesBeforeSchemaLoad,signaturesAfterSchemaLoad)){clearSettingsReadCache(pmRoot)}else{setSettingsReadCacheEntry(pmRoot,{tracked_paths:trackedPaths,signatures:signaturesAfterSchemaLoad,value:cloneSettingsReadResult(result)})}}else{clearSettingsReadCache(pmRoot)}return result}catch{const fallback=buildFallbackSettingsReadResult("settings_read_merge_failed");await cacheSettingsReadResultSafe(pmRoot,trackedPathsForFailure,fallback);return fallback}}async function readSettings(pmRoot){return(await readSettingsWithMetadata(pmRoot)).settings}async function writeSettings(pmRoot,settings,op=SETTINGS_WRITE_OP){const settingsPath=getSettingsPath(pmRoot);const afterRaw=serializeSettings(settings,{persist_source:getSettingsPersistSourceSnapshot(settings)});try{await writeWorkspaceJsonWithHistory({pmRoot,filePath:settingsPath,raw:afterRaw,op,author:resolveAuthor(void 0,settings.author_default),lockTtlSeconds:settings.locks.ttl_seconds,lockWaitMs:settings.locks.wait_ms,recordCreation:false});await runActiveOnWriteHooks({path:settingsPath,scope:"project",op})}finally{clearSettingsReadCache(pmRoot)}}const settingsStoreTestOnly={applySettingsDelta,hasExplicitItemFormat,buildSettingsPersistSourceSnapshot,cacheSettingsReadResultIfStable,cacheSettingsReadResultSafe,mergeSettings,normalizeExtensionPolicySettings,normalizeExtensionPolicyOverride,normalizeExtensionPolicyOverrides,normalizeExtensionPolicyMode,normalizePmMaxVersionExceededModeSetting,normalizeExtensionSandboxProfile,normalizeExtensionTrustMode,normalizeLowerStringList,normalizeStringList,valueOrDefault,arrayOrEmpty,normalizeValidationPatternList,normalizeValidationMetadataRequiredFields,resolveSettingsReadTrackedPaths,resolvePersistedFileBackedSchemaSections,selectedSettingsReadCacheSignaturesEqual};export{normalizeItemTypeDefinitions,persistSelectedItemFormat,readSettings,readSettingsWithMetadata,resolveGovernanceKnobs,serializeSettings,settingsStoreTestOnly,writeSettings};
|
|
1309
4
|
//# sourceMappingURL=settings.js.map
|
|
1310
|
-
//# debugId=5b95183e-9fd3-55cf-9059-8736f692e96e
|