@unbrained/pm-cli 2026.9.18 → 2026.9.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +20 -0
  3. package/dist/cli/invocation-profile.d.ts +26 -0
  4. package/dist/cli/invocation-profile.js +3 -0
  5. package/dist/cli-bundle/bundle-manifest.json +148 -148
  6. package/dist/cli-bundle/chunks/{chunk-GRFRKHFC.js → chunk-7CN53F4S.js} +2 -2
  7. package/dist/cli-bundle/chunks/{chunk-X2EVS624.js → chunk-AACGU5IA.js} +2 -2
  8. package/dist/cli-bundle/chunks/{chunk-AOD5WE6U.js → chunk-CCLWCESZ.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-WD7BQXA7.js → chunk-J7NP7QLW.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-T4J2X3RK.js → chunk-K4VAU4HU.js} +2 -2
  11. package/dist/cli-bundle/chunks/chunk-KHN4NMKT.js +238 -0
  12. package/dist/cli-bundle/chunks/{chunk-CA5DRNGA.js → chunk-KYG2QKNY.js} +28 -28
  13. package/dist/cli-bundle/chunks/{chunk-WUDF7HWM.js → chunk-OQS2Y6VN.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-XFGWFVR3.js → chunk-QA4GUEKJ.js} +20 -20
  15. package/dist/cli-bundle/chunks/chunk-QTHR3LXF.js +20 -0
  16. package/dist/cli-bundle/chunks/{chunk-FZZVWWQP.js → chunk-RVMDPIGD.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-Y2OK7IAD.js → chunk-WASMH647.js} +2 -2
  18. package/dist/cli-bundle/chunks/{register-list-query-43EQISX7.js → register-list-query-RMZNHSII.js} +2 -2
  19. package/dist/cli-bundle/chunks/{register-mutation-TSZNAKEU.js → register-mutation-HJGSGX3H.js} +2 -2
  20. package/dist/cli-bundle/chunks/{register-operations-KFZIKATY.js → register-operations-LBEMFUMM.js} +2 -2
  21. package/dist/cli-bundle/chunks/{register-setup-KTJ4ZE65.js → register-setup-MU557JAA.js} +2 -2
  22. package/dist/cli-bundle/focused-chunks/{chunk-QVVOXVYI.js → chunk-5SZ4JSPZ.js} +2 -2
  23. package/dist/cli-bundle/focused-chunks/{chunk-PNCUNPSA.js → chunk-7Y7PAC56.js} +2 -2
  24. package/dist/cli-bundle/focused-chunks/{chunk-YJYSFWSW.js → chunk-ARK4FIO4.js} +2 -2
  25. package/dist/cli-bundle/focused-chunks/{chunk-C6SH62BX.js → chunk-CJ4QA4RW.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/{chunk-ZDX2BCOT.js → chunk-I32L3FWW.js} +2 -2
  27. package/dist/cli-bundle/focused-chunks/{chunk-GEFWBVPQ.js → chunk-I4WDON3K.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/{chunk-246P5AK7.js → chunk-IKPR4VVN.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/chunk-J3GN4SQT.js +2 -0
  30. package/dist/cli-bundle/focused-chunks/{chunk-LG3SYXBX.js → chunk-OOZHQFBF.js} +9 -9
  31. package/dist/cli-bundle/focused-chunks/{chunk-BVOQRMHF.js → chunk-P4BA7OX7.js} +27 -26
  32. package/dist/cli-bundle/focused-chunks/{chunk-7D6M45AN.js → chunk-QL4MO5M2.js} +9 -9
  33. package/dist/cli-bundle/focused-chunks/chunk-TDHVROGL.js +3 -0
  34. package/dist/cli-bundle/focused-chunks/chunk-V3YMNAO7.js +2 -0
  35. package/dist/cli-bundle/focused-chunks/chunk-YDFEWXXZ.js +59 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-MMX7BQLH.js → chunk-ZDBKYZFE.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-7UZHYT5B.js → chunk-ZI2YBJFH.js} +2 -2
  38. package/dist/cli-bundle/main.js +2 -2
  39. package/dist/cli-bundle/sdk-authoring.js +1 -1
  40. package/dist/cli-bundle/sdk-contracts.js +2 -2
  41. package/dist/cli-bundle/sdk-core.js +2 -2
  42. package/dist/cli-bundle/sdk-governance.js +1 -1
  43. package/dist/cli-bundle/sdk-graph.js +1 -1
  44. package/dist/cli-bundle/sdk-merge.js +41 -41
  45. package/dist/cli-bundle/sdk-query.js +1 -1
  46. package/dist/cli-bundle/sdk-runtime.js +1 -1
  47. package/dist/cli-bundle/sdk-testing.js +1 -1
  48. package/dist/cli-bundle/sdk.js +8 -8
  49. package/dist/cli.js +1 -1
  50. package/dist/core/checkpoint/mutation-checkpoint.d.ts +1 -1
  51. package/dist/core/checkpoint/mutation-checkpoint.js +2 -2
  52. package/dist/core/fs/atomic-create.d.ts +7 -0
  53. package/dist/core/fs/atomic-create.js +2 -0
  54. package/dist/core/history/history.js +1 -1
  55. package/dist/core/schema/runtime-schema.d.ts +1 -1
  56. package/dist/core/schema/runtime-schema.js +2 -2
  57. package/dist/core/session/session-state.js +1 -1
  58. package/dist/core/store/settings-concurrency.d.ts +7 -0
  59. package/dist/core/store/settings-concurrency.js +2 -0
  60. package/dist/core/store/settings.d.ts +8 -1
  61. package/dist/core/store/settings.js +3 -2
  62. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  63. package/dist/sdk/contracts.d.ts +1 -0
  64. package/dist/sdk/contracts.js +1 -1
  65. package/dist/sdk/extension/install-runtime.d.ts +1 -1
  66. package/dist/sdk/extension/install-runtime.js +2 -2
  67. package/dist/sdk/governance/health.js +1 -1
  68. package/dist/sdk/governance/provenance-health.d.ts +27 -0
  69. package/dist/sdk/governance/provenance-health.js +1 -1
  70. package/dist/sdk/graph/index.d.ts +1 -0
  71. package/dist/sdk/graph/index.js +1 -1
  72. package/dist/sdk/graph/query-contracts.d.ts +18 -0
  73. package/dist/sdk/graph/query-contracts.js +2 -0
  74. package/dist/sdk/graph/run.d.ts +2 -0
  75. package/dist/sdk/graph/run.js +1 -1
  76. package/dist/sdk/graph/traversal.js +1 -1
  77. package/dist/sdk/lifecycle-policy.js +1 -1
  78. package/dist/sdk/public-surface.json +1 -1
  79. package/docs/MCP_OPTION_CONFORMANCE.md +41 -0
  80. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +18 -2
  81. package/docs/PERFORMANCE.md +37 -0
  82. package/docs/SDK_AGENT_SESSION_CONTEXT.md +28 -4
  83. package/docs/SDK_LIFECYCLE.md +16 -2
  84. package/docs/WORKSPACE_CONCURRENCY.md +67 -0
  85. package/marketplace.json +2 -2
  86. package/package.json +2 -2
  87. package/packages/pm-beads/package.json +1 -1
  88. package/packages/pm-calendar/package.json +1 -1
  89. package/packages/pm-command-kit/package.json +1 -1
  90. package/packages/pm-digital-twin/package.json +1 -1
  91. package/packages/pm-governance-audit/package.json +1 -1
  92. package/packages/pm-guide-shell/package.json +1 -1
  93. package/packages/pm-kanban/package.json +1 -1
  94. package/packages/pm-lifecycle-hooks/package.json +1 -1
  95. package/packages/pm-linked-test-adapters/package.json +1 -1
  96. package/packages/pm-search-advanced/package.json +1 -1
  97. package/packages/pm-templates/package.json +1 -1
  98. package/packages/pm-todos/package.json +1 -1
  99. package/packages/pm-vcs/package.json +1 -1
  100. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  101. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  102. package/dist/cli-bundle/chunks/chunk-CI2JCBN2.js +0 -237
  103. package/dist/cli-bundle/chunks/chunk-IPR2ICDO.js +0 -20
  104. package/dist/cli-bundle/focused-chunks/chunk-HRANNGHM.js +0 -2
  105. package/dist/cli-bundle/focused-chunks/chunk-LI6IGGB3.js +0 -2
  106. package/dist/cli-bundle/focused-chunks/chunk-QKG7JD34.js +0 -3
  107. package/dist/cli-bundle/focused-chunks/chunk-QYQFBJXD.js +0 -59
@@ -1,4 +1,5 @@
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]="665677ea-4d55-5858-8b21-6dee20bfd46b")}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 normalizeSearchDefaultMode(value){if(value==="auto"||value==="keyword"||value==="semantic"||value==="hybrid"){return value}return"auto"}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,default_mode:normalizeSearchDefaultMode(settings.search?.default_mode),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","default_mode","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,default_mode:normalizeSearchDefaultMode(baseSettings.search?.default_mode),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)}
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]="ab36ba69-e783-50dc-9db3-761cb228db10")}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{mutateWorkspaceJsonWithHistory}from"../history/workspace-history.js";import{reconcileSettingsSnapshot}from"./settings-concurrency.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 normalizeSearchDefaultMode(value){if(value==="auto"||value==="keyword"||value==="semantic"||value==="hybrid"){return value}return"auto"}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{persisted_settings:structuredClone(parsedSettings),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,default_mode:normalizeSearchDefaultMode(settings.search?.default_mode),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","default_mode","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,default_mode:normalizeSearchDefaultMode(baseSettings.search?.default_mode),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
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};
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 source=getSettingsPersistSourceSnapshot(settings);const afterRaw=serializeSettings(settings,{persist_source:source});const proposed=JSON.parse(afterRaw);try{await mutateWorkspaceJsonWithHistory({pmRoot,filePath:settingsPath,mutate:beforeRaw=>({raw:source?`${JSON.stringify(orderObject(reconcileSettingsSnapshot(source.persisted_settings,proposed,beforeRaw===null?null:JSON.parse(beforeRaw)),SETTINGS_TOP_LEVEL_KEY_ORDER),null,2)}
4
+ `:afterRaw,result:void 0}),op,author:resolveAuthor(void 0,settings.author_default),lockTtlSeconds:settings.locks.ttl_seconds,lockWaitMs:settings.locks.wait_ms,recordCreation:false});if(source){attachSettingsPersistSourceSnapshot(settings,{...source,persisted_settings:structuredClone(proposed)})}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};
4
5
  //# sourceMappingURL=settings.js.map
@@ -1,2 +1,2 @@
1
- !(function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b649c6ff-2a51-564c-a4e7-beca2b6e193f")}catch(e2){}})();import{resolvePmHistoryOperation}from"./command-aliases.js";import{normalizeUniqueStringList}from"./string-lists.js";import{RESERVED_EXTENSION_HOST_FLAGS}from"../../core/extensions/reserved-host-flags.js";import{PM_POSITIONAL_ACTION_CONTRACTS}from"./grammar-contracts.js";function normalizeFlagAliasKey(flag){if(!flag.startsWith("--")){return flag}return`--${flag.slice(2).replaceAll("_","-")}`}function withFlagAliasMetadata(flagContracts){const aliasesByCanonical=new Map;for(const contract of flagContracts){const canonical=normalizeFlagAliasKey(contract.flag);const bucket=aliasesByCanonical.get(canonical)??new Set;if(contract.flag!==canonical){bucket.add(contract.flag)}for(const alias of contract.aliases??[]){if(alias!==canonical){bucket.add(alias)}}aliasesByCanonical.set(canonical,bucket)}return flagContracts.map(contract=>{const canonical=normalizeFlagAliasKey(contract.flag);if(contract.flag!==canonical){return contract}const aliases=normalizeUniqueStringList([...contract.aliases??[],...aliasesByCanonical.get(canonical)]).filter(alias=>alias!==canonical);if(aliases.length===0){return contract}return{...contract,aliases}})}function compactFlagAliasContracts(flagContracts){const withAliases=withFlagAliasMetadata(flagContracts);const canonicalFlags=new Set(withAliases.map(contract=>contract.flag));return withAliases.filter(contract=>{const canonical=normalizeFlagAliasKey(contract.flag);return contract.flag===canonical||!canonicalFlags.has(canonical)})}const SUBCOMMAND_GLOBAL_FLAG_CONTRACTS=RESERVED_EXTENSION_HOST_FLAGS.map(definition=>({flag:definition.flag,reservation_scope:"inherited",...definition.aliases?{aliases:[...definition.aliases]}:{},...definition.value_name?{value_name:definition.value_name}:{}}));const GLOBAL_FLAG_CONTRACTS=[...SUBCOMMAND_GLOBAL_FLAG_CONTRACTS,{flag:"--version",value_type:"boolean",reservation_scope:"root_only"},{flag:"--all",value_type:"boolean",reservation_scope:"root_only",description:"Expand root help to every command."},{flag:"--explain",value_type:"boolean",reservation_scope:"root_only",description:"Expand root help with command guidance."}];const GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS=[{flag:"--filter-reviewer-missing"},{flag:"--filter-risk-missing"},{flag:"--filter-confidence-missing"},{flag:"--filter-sprint-missing"},{flag:"--filter-release-missing"},{flag:"--has-notes"},{flag:"--no-notes"},{flag:"--has-learnings"},{flag:"--no-learnings"},{flag:"--has-files"},{flag:"--no-files"},{flag:"--filter-files-missing"},{flag:"--has-docs"},{flag:"--no-docs"},{flag:"--filter-docs-missing"},{flag:"--has-tests"},{flag:"--no-tests"},{flag:"--has-comments"},{flag:"--no-comments"},{flag:"--has-deps"},{flag:"--no-deps"},{flag:"--has-body"},{flag:"--empty-body"},{flag:"--has-linked-command"},{flag:"--no-linked-command"}];const MANY_GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS=[{flag:"--filter-reviewer-missing"},{flag:"--filter-risk-missing"},{flag:"--filter-confidence-missing"},{flag:"--filter-sprint-missing"},{flag:"--filter-release-missing"},{flag:"--filter-has-notes"},{flag:"--filter-no-notes"},{flag:"--filter-has-learnings"},{flag:"--filter-no-learnings"},{flag:"--filter-has-files"},{flag:"--filter-no-files"},{flag:"--filter-has-docs"},{flag:"--filter-no-docs"},{flag:"--filter-has-tests"},{flag:"--filter-no-tests"},{flag:"--filter-has-comments"},{flag:"--filter-no-comments"},{flag:"--filter-has-deps"},{flag:"--filter-no-deps"},{flag:"--filter-has-body"},{flag:"--filter-empty-body"},{flag:"--filter-has-linked-command"},{flag:"--filter-no-linked-command"},{flag:"--ids",list:true},{flag:"--limit"},{flag:"--offset"}];const LIST_FILTER_FLAG_CONTRACTS=withCursorSemantics([{flag:"--for",value_name:"intent"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--status",list:true},{flag:"--all",value_type:"boolean"},{flag:"--type",list:true},{flag:"--tag",aliases:["--tags"],list:true},{flag:"--priority",list:true},{flag:"--deadline-before"},{flag:"--deadline-after"},{flag:"--today"},{flag:"--recent"},{flag:"--updated-after"},{flag:"--updated-before"},{flag:"--created-after"},{flag:"--created-before"},{flag:"--ids",list:true},{flag:"--assignee",list:true},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--parent"},{flag:"--sprint",list:true},{flag:"--release",list:true},{flag:"--filter-ac-missing"},{flag:"--filter-estimates-missing",aliases:["--filter-estimate-missing"]},{flag:"--filter-resolution-missing"},{flag:"--filter-metadata-missing"},...GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS,{flag:"--limit"},{flag:"--offset"},{flag:"--after"},{flag:"--no-truncate"},{flag:"--compact"},{flag:"--brief"},{flag:"--full"},{flag:"--fields",list:true},{flag:"--sort"},{flag:"--order"},{flag:"--tree"},{flag:"--tree-depth"},{flag:"--tree_depth"},{flag:"--include-body"},{flag:"--strict-read"},{flag:"--format"},{flag:"--stream"}],new Set(["--limit","--token-budget","--offset","--after","--no-truncate","--compact","--brief","--full","--fields","--include-body","--strict-read"]));const AGGREGATE_FLAG_CONTRACTS=[{flag:"--group-by",list:true},{flag:"--set-mode"},{flag:"--limit"},{flag:"--after"},{flag:"--count"},{flag:"--completion"},{flag:"--sum"},{flag:"--avg"},{flag:"--include-unparented"},{flag:"--include_unparented"},{flag:"--status",list:true},{flag:"--type",list:true},{flag:"--tag",list:true},{flag:"--priority",list:true},{flag:"--deadline-before"},{flag:"--deadline-after"},{flag:"--assignee",list:true},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--parent"},{flag:"--sprint",list:true},{flag:"--release",list:true}];const COMMENTS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--comment","--body","--text"]},{flag:"--stdin"},{flag:"--file"},{flag:"--edit"},{flag:"--delete"},{flag:"--limit"},{flag:"--full-history"},{flag:"--if-absent",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];function withCursorSemantics(contracts,presentationFlags){return contracts.map(contract=>presentationFlags.has(contract.flag)?{...contract,cursor_semantics:"presentation"}:contract)}const NOTES_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--note","--text"]},{flag:"--add-json"},{flag:"--stdin"},{flag:"--file"},{flag:"--edit"},{flag:"--delete"},{flag:"--limit"},{flag:"--since"},{flag:"--event-type"},{flag:"--include-meta"},{flag:"--full-history"},{flag:"--if-absent",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const LEARNINGS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--learning","--text"]},{flag:"--stdin"},{flag:"--file"},{flag:"--edit"},{flag:"--delete"},{flag:"--limit"},{flag:"--full-history"},{flag:"--if-absent",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const FILES_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add"},{flag:"--add-glob"},{flag:"--remove"},{flag:"--migrate"},{flag:"--note"},{flag:"--list"},{flag:"--append-stable"},{flag:"--validate-paths"},{flag:"--scope"},{flag:"--limit"},{flag:"--offset"},{flag:"--no-truncate"},{flag:"--strict-read"},{flag:"--explain"},{flag:"--lines",value_name:"start:end"},{flag:"--decision-depth",value_name:"n",value_type:"number"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const DOCS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add"},{flag:"--add-glob"},{flag:"--remove"},{flag:"--migrate"},{flag:"--note"},{flag:"--list"},{flag:"--validate-paths"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const HISTORY_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--limit"},{flag:"--compact"},{flag:"--full"},{flag:"--provenance"},{flag:"--provenance-summary"},{flag:"--harness",repeatable:true},{flag:"--agent-instance",repeatable:true},{flag:"--provenance-filter",repeatable:true},{flag:"--diff"},{flag:"--field"},{flag:"--verify"},{flag:"--strict-exit"},{flag:"--fail-on-warn"},{flag:"--format"}];const MERGE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--message"},{flag:"--force"},{flag:"--include-reconciled"},{flag:"--output"},{flag:"--item-path"},{flag:"--prefer"}];const HISTORY_REDACT_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--literal"},{flag:"--regex"},{flag:"--replacement"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const HISTORY_REPAIR_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--all"},{flag:"--dry-run"},{flag:"--normalize-provenance"},{flag:"--salvage-tail",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS=[{flag:"--event",repeatable:true},{flag:"--all-actionable"},{flag:"--dry-run"},{flag:"--plan-fingerprint"},{flag:"--limit",value_type:"number"},{flag:"--attributed-author",aliases:["--attributed_author"]},{flag:"--reviewer"},{flag:"--reason"}];const HISTORY_COMPACT_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--before"},{flag:"--ids",list:true},{flag:"--all-over",value_type:"number"},{flag:"--closed"},{flag:"--all-streams"},{flag:"--min-entries",value_type:"number"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const HISTORY_ATTEST_FLAG_CONTRACTS=[{flag:"--verify",value_name:"file",value_type:"string"},{flag:"--output",value_name:"file",value_type:"string"},{flag:"--hash-algorithm",value_name:"name",value_type:"string"}];const SCHEMA_FLAG_CONTRACTS=[{flag:"--definition",value_name:"json"},{flag:"--policy",value_name:"id"},{flag:"--message",value_name:"value"},{flag:"--description"},{flag:"--default-status",aliases:["--default_status"]},{flag:"--folder"},{flag:"--alias"},{flag:"--role"},{flag:"--order"},{flag:"--type"},{flag:"--commands"},{flag:"--cli-flag"},{flag:"--required"},{flag:"--required-on-create"},{flag:"--no-allow-unset"},{flag:"--required-types"},{flag:"--infer"},{flag:"--min-count"},{flag:"--apply",value_type:"boolean"},{flag:"--to"},{flag:"--migration-id",aliases:["--migration_id"]},{flag:"--dry-run"},{flag:"--author"},{flag:"--force"}];const PROFILE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--author"},{flag:"--force"}];const PLAN_FLAG_CONTRACTS=[{flag:"--title"},{flag:"--description"},{flag:"--scope"},{flag:"--parent"},{flag:"--related"},{flag:"--blocks"},{flag:"--blocked-by",aliases:["--blocked_by"]},{flag:"--harness"},{flag:"--mode"},{flag:"--resume-context",aliases:["--resume_context"]},{flag:"--tags",aliases:["--tag"],list:true},{flag:"--priority"},{flag:"--status",short:"-s"},{flag:"--create-mode",aliases:["--create_mode"]},{flag:"--deadline"},{flag:"--estimate",aliases:["--estimated-minutes","--estimated_minutes"]},{flag:"--acceptance-criteria",aliases:["--acceptance_criteria","--ac"],repeatable:true},{flag:"--definition-of-ready",aliases:["--definition_of_ready"]},{flag:"--order"},{flag:"--rank"},{flag:"--goal"},{flag:"--objective"},{flag:"--value"},{flag:"--impact"},{flag:"--outcome"},{flag:"--why-now",aliases:["--why_now"]},{flag:"--assignee"},{flag:"--reviewer"},{flag:"--risk"},{flag:"--confidence"},{flag:"--sprint"},{flag:"--release"},{flag:"--blocked-reason",aliases:["--blocked_reason"]},{flag:"--unblock-note",aliases:["--unblock_note"]},{flag:"--reporter"},{flag:"--severity"},{flag:"--environment"},{flag:"--repro-steps",aliases:["--repro_steps"]},{flag:"--resolution"},{flag:"--expected-result",aliases:["--expected_result","--expected"]},{flag:"--actual-result",aliases:["--actual_result","--actual"]},{flag:"--affected-version",aliases:["--affected_version"]},{flag:"--fixed-version",aliases:["--fixed_version"]},{flag:"--component"},{flag:"--regression"},{flag:"--customer-impact",aliases:["--customer_impact"]},{flag:"--comment",repeatable:true},{flag:"--note",repeatable:true},{flag:"--learning",repeatable:true},{flag:"--reminder",repeatable:true},{flag:"--event",repeatable:true},{flag:"--type-option",aliases:["--type_option"],repeatable:true},{flag:"--body"},{flag:"--claim"},{flag:"--from-search",aliases:["--from_search"]},{flag:"--template"},{flag:"--step-title",aliases:["--step_title"]},{flag:"--step"},{flag:"--step-body",aliases:["--step_body"]},{flag:"--step-owner",aliases:["--step_owner"]},{flag:"--step-status",aliases:["--step_status"]},{flag:"--step-evidence",aliases:["--step_evidence"]},{flag:"--step-blocked-reason",aliases:["--step_blocked_reason"]},{flag:"--step-replacement",aliases:["--step_replacement"]},{flag:"--depends-on",aliases:["--depends_on"]},{flag:"--link"},{flag:"--link-kind",aliases:["--link_kind"]},{flag:"--link-note",aliases:["--link_note"]},{flag:"--promote-to-item-dep",aliases:["--promote_to_item_dep"]},{flag:"--allow-multiple-active",aliases:["--allow_multiple_active"]},{flag:"--file"},{flag:"--test"},{flag:"--doc"},{flag:"--decision-text",aliases:["--decision_text","--decision"]},{flag:"--decision-rationale",aliases:["--decision_rationale"]},{flag:"--decision-evidence",aliases:["--decision_evidence"]},{flag:"--discovery-text",aliases:["--discovery_text","--discovery"]},{flag:"--validation-text",aliases:["--validation_text","--validation"]},{flag:"--validation-command",aliases:["--validation_command"]},{flag:"--validation-expected",aliases:["--validation_expected"]},{flag:"--depth"},{flag:"--field"},{flag:"--fields",list:true},{flag:"--steps"},{flag:"--materialize-type",aliases:["--materialize_type"]},{flag:"--materialize-parent",aliases:["--materialize_parent"]},{flag:"--materialize-tags",aliases:["--materialize_tags"]},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const INIT_FLAG_CONTRACTS=[{flag:"--id-prefix",aliases:["--prefix"]},{flag:"--preset"},{flag:"--type-preset"},{flag:"--defaults",short:"-y",aliases:["--yes"]},{flag:"--author"},{flag:"--agent-guidance"},{flag:"--with-packages"},{flag:"--no-merge-fence"},{flag:"--workspace"},{flag:"--force"},{flag:"--verbose"}];const CONFIG_FLAG_CONTRACTS=[{flag:"--value",value_name:"value"},{flag:"--criterion"},{flag:"--clear-criteria"},{flag:"--format"},{flag:"--policy"},{flag:"--default-depth"},{flag:"--activity-limit"},{flag:"--stale-threshold-days"},{flag:"--section-hierarchy"},{flag:"--section-activity"},{flag:"--section-progress"},{flag:"--section-blockers"},{flag:"--section-files"},{flag:"--section-workload"},{flag:"--section-staleness"},{flag:"--section-tests"}];const EXTENSION_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--init"},{flag:"--scaffold"},{flag:"--capability"},{flag:"--install"},{flag:"--uninstall"},{flag:"--explore"},{flag:"--list"},{flag:"--manage"},{flag:"--describe"},{flag:"--markdown"},{flag:"--output"},{flag:"--reload"},{flag:"--watch"},{flag:"--doctor"},{flag:"--catalog"},{flag:"--adopt"},{flag:"--adopt-all"},{flag:"--activate"},{flag:"--deactivate"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"},{flag:"--detail"},{flag:"--trace"},{flag:"--runtime-probe"},{flag:"--fix-managed-state"},{flag:"--isolated"},{flag:"--ignore-global"},{flag:"--strict-exit"},{flag:"--fail-on-warn"}];const EXTENSION_SCOPE_FLAG_CONTRACTS=[{flag:"--project"},{flag:"--local"},{flag:"--global"}];const EXTENSION_INIT_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--capability"}];const PACKAGE_FLAG_CONTRACTS=[...EXTENSION_FLAG_CONTRACTS,{flag:"--declarative"}];const PACKAGE_INIT_FLAG_CONTRACTS=[...EXTENSION_INIT_FLAG_CONTRACTS,{flag:"--declarative"}];const EXTENSION_INSTALL_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"}];const EXTENSION_UNINSTALL_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS;const EXTENSION_EXPLORE_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS;const EXTENSION_DESCRIBE_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--markdown"},{flag:"--output"}];const EXTENSION_ADOPT_ALL_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS;const EXTENSION_ACTIVATE_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS;const EXTENSION_DEACTIVATE_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS;const EXTENSION_MIGRATE_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--dry-run"}];const EXTENSION_MANAGE_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--runtime-probe"},{flag:"--fix-managed-state"}];const EXTENSION_RELOAD_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--watch"}];const EXTENSION_DOCTOR_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--detail"},{flag:"--trace"},{flag:"--fix-managed-state"},{flag:"--isolated"},{flag:"--ignore-global"},{flag:"--strict-exit"},{flag:"--fail-on-warn"}];const EXTENSION_CATALOG_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--fields",list:true}];const EXTENSION_ADOPT_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--gh"},{flag:"--github"},{flag:"--ref"}];const INSTALL_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"}];const UPGRADE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--cli-only"},{flag:"--packages-only"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--repair"},{flag:"--tag"},{flag:"--package-name"}];const REINDEX_FLAG_CONTRACTS=[{flag:"--mode"},{flag:"--progress"}];const CLOSE_FLAG_CONTRACTS=[{flag:"--release-assignment",value_type:"boolean"},{flag:"--id",value_name:"item-id"},{flag:"--reason",value_name:"value"},{flag:"--close-reason",value_name:"value"},{flag:"--completed-at",value_name:"value"},{flag:"--duplicate-of",value_name:"value"},{flag:"--author",value_name:"value"},{flag:"--message",value_name:"value"},{flag:"--validate-close",value_name:"off|warn|strict"},{flag:"--resolution",value_name:"value"},{flag:"--expected-result",aliases:["--expected_result","--expected"],value_name:"value"},{flag:"--actual-result",aliases:["--actual_result","--actual"],value_name:"value"},{flag:"--force",value_type:"boolean"}];const CLOSE_MANY_FLAG_CONTRACTS=[{flag:"--filter-status",list:true},{flag:"--filter-type"},{flag:"--filter-tag"},{flag:"--filter-priority"},{flag:"--filter-deadline-before"},{flag:"--filter-deadline-after"},{flag:"--filter-updated-after"},{flag:"--filter-updated-before"},{flag:"--filter-created-after"},{flag:"--filter-created-before"},{flag:"--filter-assignee"},{flag:"--filter-assignee-filter"},{flag:"--filter-assignee_filter"},{flag:"--filter-parent"},{flag:"--filter-sprint"},{flag:"--filter-release"},...MANY_GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS,{flag:"--reason"},{flag:"--completed-at"},{flag:"--resolution"},{flag:"--expected-result",aliases:["--expected_result","--expected"]},{flag:"--actual-result",aliases:["--actual_result","--actual"]},{flag:"--validate-close"},{flag:"--author"},{flag:"--message"},{flag:"--force"},{flag:"--dry-run"},{flag:"--rollback"},{flag:"--no-checkpoint"}];const APPEND_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--body",short:"-b"},{flag:"--text"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const CLAIM_FLAG_CONTRACTS=[{flag:"--start",value_type:"boolean"},{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"},{flag:"--if-available"},{flag:"--next"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--assignee-filter"},{flag:"--parent"},{flag:"--sprint"},{flag:"--release"},{flag:"--max-attempts"},{flag:"--include-decisions"},{flag:"--include-gates"},{flag:"--include-containers"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--explain-ranking",aliases:["--explain_ranking"]}];const RESTORE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const DELETE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const RELEASE_FLAG_CONTRACTS=[{flag:"--pause",value_type:"boolean"},{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"}];const START_TASK_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"}];const PAUSE_TASK_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"}];const CLOSE_TASK_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--validate-close",value_name:"off|warn|strict"},{flag:"--force"}];const SCHEDULING_SHORTCUT_COMMON_FLAG_CONTRACTS=[{flag:"--parent"},{flag:"--allow-missing-parent"},{flag:"--tags"},{flag:"--priority"},{flag:"--body"},{flag:"--description"},{flag:"--author"},{flag:"--message"}];const MEET_FLAG_CONTRACTS=[{flag:"--start"},{flag:"--duration"},{flag:"--end"},{flag:"--location"},{flag:"--timezone"},{flag:"--all-day"},...SCHEDULING_SHORTCUT_COMMON_FLAG_CONTRACTS];const EVENT_FLAG_CONTRACTS=MEET_FLAG_CONTRACTS;const REMIND_FLAG_CONTRACTS=[{flag:"--at"},{flag:"--text"},...SCHEDULING_SHORTCUT_COMMON_FLAG_CONTRACTS];const TEST_FLAG_CONTRACTS=[{flag:"--list"},{flag:"--id",value_name:"item-id"},{flag:"--add"},{flag:"--add-json"},{flag:"--remove"},{flag:"--remove-index",repeatable:true},{flag:"--run"},{flag:"--match"},{flag:"--only-index"},{flag:"--only-last"},{flag:"--background"},{flag:"--timeout"},{flag:"--progress"},{flag:"--env-set"},{flag:"--env-clear"},{flag:"--shared-host-safe"},{flag:"--pm-context"},{flag:"--override-linked-pm-context"},{flag:"--workspace-context"},{flag:"--override-linked-workspace-context"},{flag:"--allow-untrusted-linked-tests"},{flag:"--acknowledge-linked-tests"},{flag:"--fail-on-context-mismatch"},{flag:"--fail-on-skipped"},{flag:"--fail-on-empty-test-run"},{flag:"--require-assertions-for-pm"},{flag:"--check-context"},{flag:"--auto-pm-context"},{flag:"--measure",list:true},{flag:"--metric-below"},{flag:"--metric-diff"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const TEST_ALL_FLAG_CONTRACTS=[{flag:"--status"},{flag:"--limit"},{flag:"--offset"},{flag:"--background"},{flag:"--timeout"},{flag:"--progress"},{flag:"--env-set"},{flag:"--env-clear"},{flag:"--shared-host-safe"},{flag:"--pm-context"},{flag:"--override-linked-pm-context"},{flag:"--workspace-context"},{flag:"--override-linked-workspace-context"},{flag:"--allow-untrusted-linked-tests"},{flag:"--fail-on-context-mismatch"},{flag:"--fail-on-skipped"},{flag:"--fail-on-empty-test-run"},{flag:"--require-assertions-for-pm"},{flag:"--check-context"},{flag:"--auto-pm-context"}];const TELEMETRY_FLAG_CONTRACTS=[{flag:"--limit"}];const TEST_RUNS_FLAG_CONTRACTS=[{flag:"--status"},{flag:"--limit"},{flag:"--stream"},{flag:"--tail"},{flag:"--force"},{flag:"--author"}];const GC_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--scope"}];const STATS_FLAG_CONTRACTS=[{flag:"--include-empty"},{flag:"--storage"},{flag:"--metadata-coverage"},{flag:"--field-utilization"},{flag:"--by-assignee"},{flag:"--by-tag"},{flag:"--by-priority"},{flag:"--tag-prefix"},{flag:"--analytics"}];const DUPLICATES_FLAG_CONTRACTS=[{flag:"--exhaustive",value_type:"boolean"},{flag:"--status",repeatable:true,list:true},{flag:"--since"},{flag:"--threshold"},{flag:"--limit"}];const HEALTH_FLAG_CONTRACTS=[{flag:"--strict-directories"},{flag:"--require-merge-drivers"},{flag:"--strict-exit"},{flag:"--fail-on-warn"},{flag:"--check-only"},{flag:"--check-telemetry"},{flag:"--no-refresh"},{flag:"--refresh-vectors"},{flag:"--verbose-stale-items"},{flag:"--verbose-author-events"},{flag:"--brief"},{flag:"--summary"},{flag:"--skip-vectors"},{flag:"--skip-integrity"},{flag:"--skip-drift"},{flag:"--full"}];const VALIDATE_FLAG_CONTRACTS=[{flag:"--check-completeness",value_type:"boolean"},{flag:"--check-metadata"},{flag:"--metadata-profile"},{flag:"--check-resolution"},{flag:"--check-lifecycle"},{flag:"--check-stale-blockers"},{flag:"--dependency-cycle-severity"},{flag:"--parent-cycle-severity"},{flag:"--check-files"},{flag:"--scan-mode"},{flag:"--include-pm-internals"},{flag:"--verbose-file-lists"},{flag:"--verbose-diagnostics"},{flag:"--all-affected-ids"},{flag:"--strict-exit"},{flag:"--fail-on-warn"},{flag:"--fix-hints"},{flag:"--auto-fix"},{flag:"--dry-run"},{flag:"--fix-scope"},{flag:"--prune-missing"},{flag:"--check-history-drift"},{flag:"--check-command-references"},{flag:"--check-storage-integrity"},{flag:"--counts"},{flag:"--full"}];const ASSURANCE_FLAG_CONTRACTS=[{flag:"--definition",value_name:"json"},{flag:"--trigger",value_name:"value"},{flag:"--tree",value_name:"value"},{flag:"--gate",value_name:"id"},{flag:"--limit",value_name:"number"},{flag:"--dry-run"},{flag:"--author",value_name:"value"},{flag:"--message",value_name:"value"},{flag:"--owner",value_name:"item-id"},{flag:"--apply",value_type:"boolean"},{flag:"--enforcement",value_name:"level"}];const ITEM_OWNERSHIP_AND_ISSUE_FLAG_CONTRACTS=[{flag:"--assignee"},{flag:"--parent"},{flag:"--allow-missing-parent"},{flag:"--allow-unresolved-deps"},{flag:"--reviewer"},{flag:"--risk"},{flag:"--confidence"},{flag:"--sprint"},{flag:"--release"},{flag:"--blocked-by"},{flag:"--blocked-reason"},{flag:"--unblock-note"},{flag:"--reporter"},{flag:"--severity"},{flag:"--environment"},{flag:"--repro-steps"},{flag:"--resolution"},{flag:"--expected-result"},{flag:"--actual-result"},{flag:"--affected-version"},{flag:"--fixed-version"}];const ITEM_PORTFOLIO_FLAG_CONTRACTS=[{flag:"--component"},{flag:"--regression"},{flag:"--customer-impact"},{flag:"--customer_impact"},{flag:"--definition-of-ready"},{flag:"--definition_of_ready"},{flag:"--order"},{flag:"--rank"},{flag:"--goal"},{flag:"--objective"},{flag:"--value"},{flag:"--impact"},{flag:"--outcome"},{flag:"--why-now"},{flag:"--why_now"}];const ITEM_CONTENT_METADATA_FLAG_CONTRACTS=[{short:"-p",flag:"--priority"},{flag:"--type"},{flag:"--tags",aliases:["--tag"],list:true},{flag:"--add-tags",aliases:["--add_tags"]},{flag:"--remove-tags",aliases:["--remove_tags"]},{flag:"--deadline"},{flag:"--estimate"},{flag:"--estimated-minutes"},{flag:"--estimated_minutes"},{flag:"--acceptance-criteria"},{flag:"--acceptance_criteria"},{flag:"--ac"},{flag:"--add-ac",aliases:["--add_ac"]},{flag:"--remove-ac",aliases:["--remove_ac"]}];const CREATE_FLAG_CONTRACTS=[{flag:"--stdin-json"},{short:"-t",flag:"--title"},{flag:"--id"},{short:"-d",flag:"--description"},{flag:"--type"},{flag:"--template"},{flag:"--create-mode"},{flag:"--create_mode"},{flag:"--schedule-preset"},{flag:"--schedule_preset"},{short:"-s",flag:"--status"},{flag:"--close-reason"},{flag:"--close_reason"},{flag:"--completed-at"},{flag:"--completed_at"},{short:"-p",flag:"--priority"},{flag:"--tags",aliases:["--tag"],list:true},{flag:"--add-tags",aliases:["--add_tags"]},{short:"-b",flag:"--body"},{flag:"--body-file"},{flag:"--deadline"},{flag:"--estimate"},{flag:"--estimated-minutes"},{flag:"--estimated_minutes"},{flag:"--acceptance-criteria"},{flag:"--acceptance_criteria"},{flag:"--ac"},{flag:"--author"},{flag:"--message"},...ITEM_OWNERSHIP_AND_ISSUE_FLAG_CONTRACTS,...ITEM_PORTFOLIO_FLAG_CONTRACTS,{flag:"--blocked_by"},{flag:"--blocked_reason"},{flag:"--unblock_note"},{flag:"--repro_steps"},{flag:"--expected_result"},{flag:"--actual_result"},{flag:"--expected"},{flag:"--actual"},{flag:"--affected_version"},{flag:"--fixed_version"},{flag:"--dep"},{flag:"--type-option"},{flag:"--type_option"},{flag:"--field"},{flag:"--reminder"},{flag:"--event"},{flag:"--comment"},{flag:"--note"},{flag:"--learning"},{flag:"--file",aliases:["--linked-file"]},{flag:"--test",aliases:["--linked-test"]},{flag:"--doc"},{flag:"--unset"},{flag:"--clear-deps"},{flag:"--clear-comments"},{flag:"--clear-notes"},{flag:"--clear-learnings"},{flag:"--clear-files"},{flag:"--clear-tests"},{flag:"--clear-docs"},{flag:"--clear-reminders"},{flag:"--clear-events"},{flag:"--clear-type-options"},{flag:"--allow-duplicate",value_type:"boolean"}];const ITEM_MUTATE_FLAG_CONTRACTS=[{flag:"--transaction-id",value_name:"value"},{flag:"--stdin-json"},{flag:"--dry-run"},{flag:"--create-compensation",value_name:"mode"},{flag:"--lock-ttl-seconds",value_name:"n"},{flag:"--lock-wait-ms",value_name:"n"},{flag:"--author",value_name:"value"}];const ITEM_COMPLETE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--transaction-id",value_name:"value",required:true},{flag:"--reason",value_name:"value"},{flag:"--file",value_name:"value",repeatable:true},{flag:"--doc",value_name:"value",repeatable:true},{flag:"--test",value_name:"value",repeatable:true},{flag:"--comment",value_name:"value",repeatable:true},{flag:"--note",value_name:"value",repeatable:true},{flag:"--learning",value_name:"value",repeatable:true},{flag:"--resolution",value_name:"value"},{flag:"--expected-result",value_name:"value"},{flag:"--actual-result",value_name:"value"},{flag:"--completed-at",value_name:"value"},{flag:"--validate-close",value_name:"off|warn|strict"},{flag:"--lock-ttl-seconds",value_name:"n"},{flag:"--lock-wait-ms",value_name:"n"},{flag:"--dry-run"},{flag:"--force"},{flag:"--author",value_name:"value"}];const ITEM_REOPEN_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--status",value_name:"open|in_progress"},{flag:"--message",value_name:"value"},{flag:"--force"},{flag:"--author",value_name:"value"}];const COPY_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--title",value_name:"value"},{flag:"--author",value_name:"value"},{flag:"--message",value_name:"value"},{flag:"--allow-duplicate",value_type:"boolean"}];const FOCUS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--clear"}];const UPDATE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--stdin-json"},{short:"-t",flag:"--title"},{short:"-d",flag:"--description"},{short:"-b",flag:"--body"},{flag:"--body-file"},{short:"-s",flag:"--status"},{flag:"--close-reason"},{flag:"--close_reason"},{flag:"--completed-at"},...ITEM_CONTENT_METADATA_FLAG_CONTRACTS,...ITEM_OWNERSHIP_AND_ISSUE_FLAG_CONTRACTS,{flag:"--fixed_version"},...ITEM_PORTFOLIO_FLAG_CONTRACTS,{flag:"--author"},{flag:"--message"},{flag:"--blocked_by"},{flag:"--blocked_reason"},{flag:"--unblock_note"},{flag:"--repro_steps"},{flag:"--expected_result"},{flag:"--actual_result"},{flag:"--expected"},{flag:"--actual"},{flag:"--affected_version"},{flag:"--dep"},{flag:"--dep-remove"},{flag:"--dep_remove"},{flag:"--replace-deps"},{flag:"--replace-tests"},{flag:"--replace-files"},{flag:"--replace-docs"},{flag:"--comment"},{flag:"--note"},{flag:"--learning"},{flag:"--file",aliases:["--linked-file"]},{flag:"--test",aliases:["--linked-test"]},{flag:"--doc"},{flag:"--reminder"},{flag:"--event"},{flag:"--type-option"},{flag:"--type_option"},{flag:"--field"},{flag:"--unset"},{flag:"--clear-deps"},{flag:"--clear-comments"},{flag:"--clear-notes"},{flag:"--clear-learnings"},{flag:"--clear-files"},{flag:"--clear-tests"},{flag:"--clear-docs"},{flag:"--clear-reminders"},{flag:"--clear-events"},{flag:"--clear-type-options"},{flag:"--force"}];const UPDATE_MANY_FLAG_CONTRACTS=[{flag:"--status",short:"-s"},{flag:"--assignee"},{flag:"--parent"},{flag:"--blocked-by",aliases:["--blocked_by"]},{flag:"--blocked-reason",aliases:["--blocked_reason"]},{flag:"--unblock-note",aliases:["--unblock_note"]},{flag:"--filter-status",list:true},{flag:"--filter-type",list:true},{flag:"--filter-tag",list:true},{flag:"--filter-priority",list:true},{flag:"--filter-deadline-before"},{flag:"--filter-deadline-after"},{flag:"--filter-updated-after"},{flag:"--filter-updated-before"},{flag:"--filter-created-after"},{flag:"--filter-created-before"},{flag:"--filter-assignee",list:true},{flag:"--filter-assignee-filter"},{flag:"--filter-assignee_filter"},{flag:"--filter-parent"},{flag:"--filter-sprint",list:true},{flag:"--filter-release",list:true},{flag:"--filter-ac-missing"},{flag:"--filter-estimates-missing",aliases:["--filter-estimate-missing"]},{flag:"--filter-resolution-missing"},{flag:"--filter-metadata-missing"},...MANY_GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS,{flag:"--dry-run"},{flag:"--rollback"},{flag:"--no-checkpoint"},{short:"-t",flag:"--title"},{short:"-d",flag:"--description"},{short:"-b",flag:"--body"},...ITEM_CONTENT_METADATA_FLAG_CONTRACTS,{flag:"--definition-of-ready"},{flag:"--definition_of_ready"},{flag:"--order"},{flag:"--rank"},{flag:"--goal"},{flag:"--objective"},{flag:"--value"},{flag:"--impact"},{flag:"--outcome"},{flag:"--why-now"},{flag:"--why_now"},{flag:"--reviewer"},{flag:"--risk"},{flag:"--confidence"},{flag:"--sprint"},{flag:"--release"},{flag:"--reporter"},{flag:"--severity"},{flag:"--environment"},{flag:"--repro-steps"},{flag:"--repro_steps"},{flag:"--resolution"},{flag:"--expected-result"},{flag:"--expected_result"},{flag:"--expected"},{flag:"--actual-result"},{flag:"--actual_result"},{flag:"--actual"},{flag:"--affected-version"},{flag:"--affected_version"},{flag:"--fixed-version"},{flag:"--fixed_version"},{flag:"--component"},{flag:"--regression"},{flag:"--customer-impact"},{flag:"--customer_impact"},{flag:"--allow-unresolved-deps"},{flag:"--dep"},{flag:"--dep-remove"},{flag:"--dep_remove"},{flag:"--replace-deps"},{flag:"--replace-tests"},{flag:"--replace-files"},{flag:"--replace-docs"},{flag:"--comment"},{flag:"--note"},{flag:"--learning"},{flag:"--file"},{flag:"--test"},{flag:"--doc"},{flag:"--reminder"},{flag:"--event"},{flag:"--type-option"},{flag:"--type_option"},{flag:"--unset"},{flag:"--clear-deps"},{flag:"--clear-comments"},{flag:"--clear-notes"},{flag:"--clear-learnings"},{flag:"--clear-files"},{flag:"--clear-tests"},{flag:"--clear-docs"},{flag:"--clear-reminders"},{flag:"--clear-events"},{flag:"--clear-type-options"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const CALENDAR_FLAG_CONTRACTS=[{flag:"--view"},{flag:"--date"},{flag:"--from"},{flag:"--to"},{flag:"--past"},{flag:"--full-period"},{flag:"--full_period"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--status"},{flag:"--assignee"},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--sprint"},{flag:"--release"},{flag:"--include"},{flag:"--recurrence-lookahead-days"},{flag:"--recurrence-lookback-days"},{flag:"--occurrence-limit"},{flag:"--limit"},{flag:"--format"}];const ACTIVITY_FLAG_CONTRACTS=[{flag:"--id"},{flag:"--op"},{flag:"--author"},{flag:"--from"},{flag:"--to"},{flag:"--limit"},{flag:"--unbounded"},{flag:"--compact"},{flag:"--raw"},{flag:"--full"},{flag:"--provenance"},{flag:"--provenance-summary"},{flag:"--harness",repeatable:true},{flag:"--agent-instance",repeatable:true},{flag:"--provenance-filter",repeatable:true},{flag:"--stream"}];const EVENTS_FLAG_CONTRACTS=[{flag:"--since"},{flag:"--type",repeatable:true},{flag:"--author",repeatable:true},{flag:"--item",repeatable:true},{flag:"--limit",value_type:"number"},{flag:"--cursor-mode",value_name:"batch|row"},{flag:"--full"},{flag:"--provenance"},{flag:"--provenance-summary"},{flag:"--harness",repeatable:true},{flag:"--agent-instance",repeatable:true},{flag:"--provenance-filter",repeatable:true},{flag:"--follow"},{flag:"--interval-ms",value_type:"number"}];const CONTEXT_FLAG_CONTRACTS=withCursorSemantics([{flag:"--for",value_name:"intent"},{flag:"--date"},{flag:"--from"},{flag:"--to"},{flag:"--past"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--assignee"},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--sprint"},{flag:"--release"},{flag:"--parent"},{flag:"--limit",aliases:["--max-items"]},{flag:"--after"},{flag:"--format"},{flag:"--depth"},{flag:"--fields",list:true},{flag:"--section"},{flag:"--activity-limit"},{flag:"--stale-threshold"},{flag:"--explain-ranking"},{flag:"--explain_ranking"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--no-extension-health"},{flag:"--no-tags"}],new Set(["--limit","--after","--format","--fields","--section","--activity-limit","--stale-threshold","--explain-ranking","--explain_ranking","--no-extension-health","--no-tags"]));const GET_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--for",value_name:"intent"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--depth"},{flag:"--full",value_type:"boolean"},{flag:"--fields",list:true},{flag:"--at"},{flag:"--tree"},{flag:"--tree-depth"},{flag:"--tree_depth"},{flag:"--format"}];const GUIDE_FLAG_CONTRACTS=[{flag:"--list"},{flag:"--format"},{flag:"--depth"}];const DEPS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--format"},{flag:"--max-depth"},{flag:"--collapse"},{flag:"--summary"},{flag:"--full"},{flag:"--node-limit"},{flag:"--edge-limit"},{flag:"--token-budget"},{flag:"--cursor"},{flag:"--direction"},{flag:"--kind",list:true}];const GRAPH_FLAG_CONTRACTS=[{flag:"--kind",list:true},{flag:"--max-depth"},{flag:"--limit"},{flag:"--after"},{flag:"--direction"},{flag:"--max-paths"},{flag:"--sample"},{flag:"--exempt-isolate",list:true},{flag:"--exempt-isolate-type",list:true},{flag:"--save-baseline"},{flag:"--rebuild"},{flag:"--clear"},{flag:"--summary"},{flag:"--full"}];const EVAL_FLAG_CONTRACTS=[{flag:"--mode"},{flag:"--k"},{flag:"--fail-under"},{flag:"--queries"},{flag:"--format"}];const WORKSPACE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--force"},{flag:"--author"},{flag:"--message"}];const WORKSPACE_POSITION_FLAG_CONTRACTS=[];const NEXT_FLAG_CONTRACTS=[{flag:"--include-decisions"},{flag:"--include-gates"},{flag:"--include-containers"},{flag:"--for",value_name:"intent"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--assignee"},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--sprint"},{flag:"--release"},{flag:"--parent"},{flag:"--limit"},{flag:"--blocked-limit"},{flag:"--blocked_limit"},{flag:"--ready-only"},{flag:"--ready_only"},{flag:"--format"},{flag:"--explain-ranking"},{flag:"--explain_ranking"},{flag:"--token-budget",aliases:["--token_budget"]}];const SEARCH_FLAG_CONTRACTS=withCursorSemantics([{flag:"--for",value_name:"intent"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--mode"},{flag:"--semantic"},{flag:"--hybrid"},{flag:"--match-mode"},{flag:"--min-score"},{flag:"--count"},{flag:"--semantic-weight"},{flag:"--include-linked"},{flag:"--title-exact"},{flag:"--phrase-exact"},{flag:"--highlight"},{flag:"--compact"},{flag:"--full"},{flag:"--fields",list:true},{flag:"--format"},{flag:"--limit"},{flag:"--after"},{flag:"--status",list:true},{flag:"--type",list:true},{flag:"--tag",aliases:["--tags"],list:true},{flag:"--priority",list:true},{flag:"--deadline-before"},{flag:"--deadline-after"},{flag:"--updated-after"},{flag:"--updated-before"},{flag:"--created-after"},{flag:"--created-before"},{flag:"--assignee",list:true},{flag:"--sprint",list:true},{flag:"--release",list:true},{flag:"--parent"},...GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS],new Set(["--highlight","--compact","--full","--fields","--format","--limit","--token-budget","--after"]));const CONTRACTS_FLAG_CONTRACTS=[{flag:"--action"},{flag:"--command"},{flag:"--summary"},{flag:"--schema-only"},{flag:"--flags-only"},{flag:"--availability-only"},{flag:"--runtime-only"},{flag:"--active-only"},{flag:"--full"}];const COMPLETION_FLAG_CONTRACTS=[{flag:"--eager-tags"}];function toUniqueFlagContracts(contracts){const seen=new Set;const unique=[];for(const contract of contracts){const aliasKey=(contract.aliases??[]).join(",");const key=`${contract.flag}|${contract.short??""}|${aliasKey}`;if(seen.has(key)){continue}seen.add(key);unique.push(contract)}return unique}function withSubcommandGlobalFlags(contracts){const byCanonicalFlag=new Map;for(const contract of[...SUBCOMMAND_GLOBAL_FLAG_CONTRACTS,...contracts]){const canonicalFlag=normalizeFlagAliasKey(contract.flag);const prior=byCanonicalFlag.get(canonicalFlag);const{aliases:declaredAliases,...contractWithoutAliases}=contract;const aliases=normalizeUniqueStringList([...declaredAliases??[],...contract.flag===canonicalFlag?[]:[contract.flag]]).filter(alias=>alias!==canonicalFlag);const normalizedContract={...contractWithoutAliases,flag:canonicalFlag,...aliases.length>0?{aliases}:{}};const mergedAliases=normalizeUniqueStringList([...prior?.aliases??[],...normalizedContract.aliases??[]]);byCanonicalFlag.set(canonicalFlag,prior===void 0?normalizedContract:{...prior,...normalizedContract,...mergedAliases.length>0?{aliases:mergedAliases}:{}})}return withFlagAliasMetadata([...byCanonicalFlag.values()])}const FIXED_STATUS_LIST_COMMAND_ALIASES=["list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled"];const FIXED_STATUS_LIST_FLAG_CONTRACTS=LIST_FILTER_FLAG_CONTRACTS.filter(contract=>contract.flag!=="--status"&&contract.flag!=="--all");function indexCliFlagContracts(contracts){const index=new Map;for(const contract of contracts){for(const spelling of[contract.flag,...contract.aliases??[]]){const matches=index.get(spelling)??[];matches.push(contract);index.set(spelling,matches)}}return index}const PLAN_FLAG_CONTRACT_INDEX=indexCliFlagContracts(PLAN_FLAG_CONTRACTS);const ASSURANCE_FLAG_CONTRACT_INDEX=indexCliFlagContracts(ASSURANCE_FLAG_CONTRACTS);const POSITIONAL_ACTION_FLAG_INDEX_BY_PARENT=new Map([["assurance",ASSURANCE_FLAG_CONTRACT_INDEX],["plan",PLAN_FLAG_CONTRACT_INDEX],["workspace",indexCliFlagContracts(WORKSPACE_POSITION_FLAG_CONTRACTS)],["workspace snapshot",indexCliFlagContracts(WORKSPACE_FLAG_CONTRACTS)]]);function resolvePmPositionalActionFlagContracts(actions=PM_POSITIONAL_ACTION_CONTRACTS){return actions.map(({command,parent,accepted_flags:acceptedFlags})=>{const parentFlagIndex=POSITIONAL_ACTION_FLAG_INDEX_BY_PARENT.get(parent);if(!parentFlagIndex){throw new Error(`Positional action ${command} has no flag-contract index for ${parent}.`)}const selected=acceptedFlags.map(acceptedFlag=>{const matches=parentFlagIndex.get(acceptedFlag)??[];if(matches.length!==1){throw new Error(`Positional action ${command} accepted flag ${acceptedFlag} does not resolve to exactly one ${parent} flag contract.`)}return matches[0]});return[command,selected]})}const PM_POSITIONAL_ACTION_FLAG_CONTRACTS=resolvePmPositionalActionFlagContracts();const SUBCOMMAND_FLAG_CONTRACTS_BY_COMMAND=new Map([["list",LIST_FILTER_FLAG_CONTRACTS],["list-all",LIST_FILTER_FLAG_CONTRACTS],...FIXED_STATUS_LIST_COMMAND_ALIASES.map(command=>[command,FIXED_STATUS_LIST_FLAG_CONTRACTS]),["templates",CREATE_FLAG_CONTRACTS],["cal",CALENDAR_FLAG_CONTRACTS],["ctx",CONTEXT_FLAG_CONTRACTS],["test-runs-worker",[]],["init",INIT_FLAG_CONTRACTS],["config",CONFIG_FLAG_CONTRACTS],["extension",EXTENSION_FLAG_CONTRACTS],["package",PACKAGE_FLAG_CONTRACTS],["packages",PACKAGE_FLAG_CONTRACTS],["install",INSTALL_FLAG_CONTRACTS],["upgrade",UPGRADE_FLAG_CONTRACTS],["create",CREATE_FLAG_CONTRACTS],["item",[]],["item mutate",ITEM_MUTATE_FLAG_CONTRACTS],["item complete",ITEM_COMPLETE_FLAG_CONTRACTS],["item reopen",ITEM_REOPEN_FLAG_CONTRACTS],["copy",COPY_FLAG_CONTRACTS],["focus",FOCUS_FLAG_CONTRACTS],["aggregate",AGGREGATE_FLAG_CONTRACTS],["calendar",CALENDAR_FLAG_CONTRACTS],["context",CONTEXT_FLAG_CONTRACTS],["get",GET_FLAG_CONTRACTS],["guide",GUIDE_FLAG_CONTRACTS],["search",SEARCH_FLAG_CONTRACTS],["next",NEXT_FLAG_CONTRACTS],["eval",EVAL_FLAG_CONTRACTS],["workspace",WORKSPACE_FLAG_CONTRACTS],["workspace position",WORKSPACE_POSITION_FLAG_CONTRACTS],["workspace snapshot",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot create",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot list",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot inspect",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot restore",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot delete",WORKSPACE_FLAG_CONTRACTS],["history",HISTORY_FLAG_CONTRACTS],["history-redact",HISTORY_REDACT_FLAG_CONTRACTS],["history-repair",HISTORY_REPAIR_FLAG_CONTRACTS],["history-author-acknowledge",HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS],["history-compact",HISTORY_COMPACT_FLAG_CONTRACTS],["history-attest",HISTORY_ATTEST_FLAG_CONTRACTS],["merge",MERGE_FLAG_CONTRACTS],["schema",SCHEMA_FLAG_CONTRACTS],["profile",PROFILE_FLAG_CONTRACTS],["plan",PLAN_FLAG_CONTRACTS],["activity",ACTIVITY_FLAG_CONTRACTS],["events",EVENTS_FLAG_CONTRACTS],["restore",RESTORE_FLAG_CONTRACTS],["update",UPDATE_FLAG_CONTRACTS],["update-many",UPDATE_MANY_FLAG_CONTRACTS],["close",CLOSE_FLAG_CONTRACTS],["close-many",CLOSE_MANY_FLAG_CONTRACTS],["delete",DELETE_FLAG_CONTRACTS],["append",APPEND_FLAG_CONTRACTS],["comments",COMMENTS_FLAG_CONTRACTS],["notes",NOTES_FLAG_CONTRACTS],["learnings",LEARNINGS_FLAG_CONTRACTS],["files",FILES_FLAG_CONTRACTS],["docs",DOCS_FLAG_CONTRACTS],["deps",DEPS_FLAG_CONTRACTS],["graph",GRAPH_FLAG_CONTRACTS],["test",TEST_FLAG_CONTRACTS],["test-all",TEST_ALL_FLAG_CONTRACTS],["telemetry",TELEMETRY_FLAG_CONTRACTS],["health",HEALTH_FLAG_CONTRACTS],["assurance",ASSURANCE_FLAG_CONTRACTS],...PM_POSITIONAL_ACTION_FLAG_CONTRACTS,["validate",VALIDATE_FLAG_CONTRACTS],["gc",GC_FLAG_CONTRACTS],["stats",STATS_FLAG_CONTRACTS],["duplicates",DUPLICATES_FLAG_CONTRACTS],["contracts",CONTRACTS_FLAG_CONTRACTS],["completion",COMPLETION_FLAG_CONTRACTS],["claim",CLAIM_FLAG_CONTRACTS],["release",RELEASE_FLAG_CONTRACTS],["start-task",START_TASK_FLAG_CONTRACTS],["pause-task",PAUSE_TASK_FLAG_CONTRACTS],["close-task",CLOSE_TASK_FLAG_CONTRACTS],["meet",MEET_FLAG_CONTRACTS],["event",EVENT_FLAG_CONTRACTS],["remind",REMIND_FLAG_CONTRACTS]]);const EXTENSION_LIFECYCLE_FLAG_CONTRACTS_BY_SUBCOMMAND=new Map([["install",EXTENSION_INSTALL_FLAG_CONTRACTS],["uninstall",EXTENSION_UNINSTALL_FLAG_CONTRACTS],["explore",EXTENSION_EXPLORE_FLAG_CONTRACTS],["manage",EXTENSION_MANAGE_FLAG_CONTRACTS],["describe",EXTENSION_DESCRIBE_FLAG_CONTRACTS],["reload",EXTENSION_RELOAD_FLAG_CONTRACTS],["doctor",EXTENSION_DOCTOR_FLAG_CONTRACTS],["catalog",EXTENSION_CATALOG_FLAG_CONTRACTS],["list",EXTENSION_CATALOG_FLAG_CONTRACTS],["adopt",EXTENSION_ADOPT_FLAG_CONTRACTS],["adopt-all",EXTENSION_ADOPT_ALL_FLAG_CONTRACTS],["activate",EXTENSION_ACTIVATE_FLAG_CONTRACTS],["deactivate",EXTENSION_DEACTIVATE_FLAG_CONTRACTS],["migrate",EXTENSION_MIGRATE_FLAG_CONTRACTS]]);function normalizeCommandNameForContracts(commandName){if(typeof commandName!=="string"){return""}return resolvePmHistoryOperation(commandName.trim().toLowerCase())}function hasSubcommandFlagContractsForCommand(commandName){const normalized=normalizeCommandNameForContracts(commandName);if(SUBCOMMAND_FLAG_CONTRACTS_BY_COMMAND.has(normalized)){return true}const[rootCommand,lifecycleSubcommand,...extraParts]=normalized.split(/\s+/);return(rootCommand==="extension"||rootCommand==="package"||rootCommand==="packages")&&lifecycleSubcommand!==void 0&&extraParts.length===0&&(lifecycleSubcommand==="init"||lifecycleSubcommand==="scaffold"||EXTENSION_LIFECYCLE_FLAG_CONTRACTS_BY_SUBCOMMAND.has(lifecycleSubcommand))}function resolveExtensionLifecycleFlagContracts(rootCommand,lifecycleSubcommand){if(lifecycleSubcommand==="init"||lifecycleSubcommand==="scaffold"){return rootCommand==="extension"?EXTENSION_INIT_FLAG_CONTRACTS:PACKAGE_INIT_FLAG_CONTRACTS}return EXTENSION_LIFECYCLE_FLAG_CONTRACTS_BY_SUBCOMMAND.get(lifecycleSubcommand)??[]}function resolveSubcommandFlagContractsForCommand(commandName){const normalized=normalizeCommandNameForContracts(commandName);if(normalized.length===0){return withSubcommandGlobalFlags([])}const[rootCommand,lifecycleSubcommand,...extraParts]=normalized.split(/\s+/);if((rootCommand==="extension"||rootCommand==="package"||rootCommand==="packages")&&lifecycleSubcommand!==void 0&&extraParts.length===0){if((rootCommand==="package"||rootCommand==="packages")&&lifecycleSubcommand==="upgrade"){return withSubcommandGlobalFlags(UPGRADE_FLAG_CONTRACTS)}return withSubcommandGlobalFlags(resolveExtensionLifecycleFlagContracts(rootCommand,lifecycleSubcommand))}const contracts=SUBCOMMAND_FLAG_CONTRACTS_BY_COMMAND.get(normalized)??[];return withSubcommandGlobalFlags(contracts)}function toCompletionFlagString(flagContracts,includeGlobal=true){const aliasAwareContracts=withFlagAliasMetadata(flagContracts);const scoped=aliasAwareContracts.flatMap(entry=>[entry.short,entry.flag,...entry.aliases??[]]).filter(value=>Boolean(value));const all=includeGlobal?[...scoped,...SUBCOMMAND_GLOBAL_FLAG_CONTRACTS.flatMap(entry=>[entry.short,entry.flag,...entry.aliases??[]]).filter(value=>Boolean(value))]:scoped;return normalizeUniqueStringList(all).join(" ")}export{ACTIVITY_FLAG_CONTRACTS,AGGREGATE_FLAG_CONTRACTS,APPEND_FLAG_CONTRACTS,ASSURANCE_FLAG_CONTRACTS,CALENDAR_FLAG_CONTRACTS,CLAIM_FLAG_CONTRACTS,CLOSE_FLAG_CONTRACTS,CLOSE_MANY_FLAG_CONTRACTS,CLOSE_TASK_FLAG_CONTRACTS,COMMENTS_FLAG_CONTRACTS,COMPLETION_FLAG_CONTRACTS,CONFIG_FLAG_CONTRACTS,CONTEXT_FLAG_CONTRACTS,CONTRACTS_FLAG_CONTRACTS,COPY_FLAG_CONTRACTS,CREATE_FLAG_CONTRACTS,DELETE_FLAG_CONTRACTS,DEPS_FLAG_CONTRACTS,DOCS_FLAG_CONTRACTS,DUPLICATES_FLAG_CONTRACTS,EVAL_FLAG_CONTRACTS,EVENTS_FLAG_CONTRACTS,EVENT_FLAG_CONTRACTS,EXTENSION_ACTIVATE_FLAG_CONTRACTS,EXTENSION_ADOPT_ALL_FLAG_CONTRACTS,EXTENSION_ADOPT_FLAG_CONTRACTS,EXTENSION_CATALOG_FLAG_CONTRACTS,EXTENSION_DEACTIVATE_FLAG_CONTRACTS,EXTENSION_DESCRIBE_FLAG_CONTRACTS,EXTENSION_DOCTOR_FLAG_CONTRACTS,EXTENSION_EXPLORE_FLAG_CONTRACTS,EXTENSION_FLAG_CONTRACTS,EXTENSION_INIT_FLAG_CONTRACTS,EXTENSION_INSTALL_FLAG_CONTRACTS,EXTENSION_MANAGE_FLAG_CONTRACTS,EXTENSION_MIGRATE_FLAG_CONTRACTS,EXTENSION_RELOAD_FLAG_CONTRACTS,EXTENSION_SCOPE_FLAG_CONTRACTS,EXTENSION_UNINSTALL_FLAG_CONTRACTS,FILES_FLAG_CONTRACTS,FOCUS_FLAG_CONTRACTS,GC_FLAG_CONTRACTS,GET_FLAG_CONTRACTS,GLOBAL_FLAG_CONTRACTS,GRAPH_FLAG_CONTRACTS,GUIDE_FLAG_CONTRACTS,HEALTH_FLAG_CONTRACTS,HISTORY_ATTEST_FLAG_CONTRACTS,HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS,HISTORY_COMPACT_FLAG_CONTRACTS,HISTORY_FLAG_CONTRACTS,HISTORY_REDACT_FLAG_CONTRACTS,HISTORY_REPAIR_FLAG_CONTRACTS,INIT_FLAG_CONTRACTS,INSTALL_FLAG_CONTRACTS,ITEM_COMPLETE_FLAG_CONTRACTS,ITEM_MUTATE_FLAG_CONTRACTS,ITEM_REOPEN_FLAG_CONTRACTS,LEARNINGS_FLAG_CONTRACTS,LIST_FILTER_FLAG_CONTRACTS,MEET_FLAG_CONTRACTS,MERGE_FLAG_CONTRACTS,NEXT_FLAG_CONTRACTS,NOTES_FLAG_CONTRACTS,PACKAGE_FLAG_CONTRACTS,PACKAGE_INIT_FLAG_CONTRACTS,PAUSE_TASK_FLAG_CONTRACTS,PLAN_FLAG_CONTRACTS,PM_POSITIONAL_ACTION_FLAG_CONTRACTS,PROFILE_FLAG_CONTRACTS,REINDEX_FLAG_CONTRACTS,RELEASE_FLAG_CONTRACTS,REMIND_FLAG_CONTRACTS,RESTORE_FLAG_CONTRACTS,SCHEMA_FLAG_CONTRACTS,SEARCH_FLAG_CONTRACTS,START_TASK_FLAG_CONTRACTS,STATS_FLAG_CONTRACTS,SUBCOMMAND_GLOBAL_FLAG_CONTRACTS,TELEMETRY_FLAG_CONTRACTS,TEST_ALL_FLAG_CONTRACTS,TEST_FLAG_CONTRACTS,TEST_RUNS_FLAG_CONTRACTS,UPDATE_FLAG_CONTRACTS,UPDATE_MANY_FLAG_CONTRACTS,UPGRADE_FLAG_CONTRACTS,VALIDATE_FLAG_CONTRACTS,WORKSPACE_FLAG_CONTRACTS,WORKSPACE_POSITION_FLAG_CONTRACTS,compactFlagAliasContracts,hasSubcommandFlagContractsForCommand,resolvePmPositionalActionFlagContracts,resolveSubcommandFlagContractsForCommand,toCompletionFlagString,toUniqueFlagContracts,withFlagAliasMetadata};
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]="4c3fb594-00bc-5625-aeaa-692e7ac01437")}catch(e2){}})();import{resolvePmHistoryOperation}from"./command-aliases.js";import{normalizeUniqueStringList}from"./string-lists.js";import{GRAPH_QUERY_DEFAULTS}from"../graph/query-contracts.js";import{RESERVED_EXTENSION_HOST_FLAGS}from"../../core/extensions/reserved-host-flags.js";import{PM_POSITIONAL_ACTION_CONTRACTS}from"./grammar-contracts.js";function normalizeFlagAliasKey(flag){if(!flag.startsWith("--")){return flag}return`--${flag.slice(2).replaceAll("_","-")}`}function withFlagAliasMetadata(flagContracts){const aliasesByCanonical=new Map;for(const contract of flagContracts){const canonical=normalizeFlagAliasKey(contract.flag);const bucket=aliasesByCanonical.get(canonical)??new Set;if(contract.flag!==canonical){bucket.add(contract.flag)}for(const alias of contract.aliases??[]){if(alias!==canonical){bucket.add(alias)}}aliasesByCanonical.set(canonical,bucket)}return flagContracts.map(contract=>{const canonical=normalizeFlagAliasKey(contract.flag);if(contract.flag!==canonical){return contract}const aliases=normalizeUniqueStringList([...contract.aliases??[],...aliasesByCanonical.get(canonical)]).filter(alias=>alias!==canonical);if(aliases.length===0){return contract}return{...contract,aliases}})}function compactFlagAliasContracts(flagContracts){const withAliases=withFlagAliasMetadata(flagContracts);const canonicalFlags=new Set(withAliases.map(contract=>contract.flag));return withAliases.filter(contract=>{const canonical=normalizeFlagAliasKey(contract.flag);return contract.flag===canonical||!canonicalFlags.has(canonical)})}const SUBCOMMAND_GLOBAL_FLAG_CONTRACTS=RESERVED_EXTENSION_HOST_FLAGS.map(definition=>({flag:definition.flag,reservation_scope:"inherited",...definition.aliases?{aliases:[...definition.aliases]}:{},...definition.value_name?{value_name:definition.value_name}:{}}));const GLOBAL_FLAG_CONTRACTS=[...SUBCOMMAND_GLOBAL_FLAG_CONTRACTS,{flag:"--version",value_type:"boolean",reservation_scope:"root_only"},{flag:"--all",value_type:"boolean",reservation_scope:"root_only",description:"Expand root help to every command."},{flag:"--explain",value_type:"boolean",reservation_scope:"root_only",description:"Expand root help with command guidance."}];const GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS=[{flag:"--filter-reviewer-missing"},{flag:"--filter-risk-missing"},{flag:"--filter-confidence-missing"},{flag:"--filter-sprint-missing"},{flag:"--filter-release-missing"},{flag:"--has-notes"},{flag:"--no-notes"},{flag:"--has-learnings"},{flag:"--no-learnings"},{flag:"--has-files"},{flag:"--no-files"},{flag:"--filter-files-missing"},{flag:"--has-docs"},{flag:"--no-docs"},{flag:"--filter-docs-missing"},{flag:"--has-tests"},{flag:"--no-tests"},{flag:"--has-comments"},{flag:"--no-comments"},{flag:"--has-deps"},{flag:"--no-deps"},{flag:"--has-body"},{flag:"--empty-body"},{flag:"--has-linked-command"},{flag:"--no-linked-command"}];const MANY_GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS=[{flag:"--filter-reviewer-missing"},{flag:"--filter-risk-missing"},{flag:"--filter-confidence-missing"},{flag:"--filter-sprint-missing"},{flag:"--filter-release-missing"},{flag:"--filter-has-notes"},{flag:"--filter-no-notes"},{flag:"--filter-has-learnings"},{flag:"--filter-no-learnings"},{flag:"--filter-has-files"},{flag:"--filter-no-files"},{flag:"--filter-has-docs"},{flag:"--filter-no-docs"},{flag:"--filter-has-tests"},{flag:"--filter-no-tests"},{flag:"--filter-has-comments"},{flag:"--filter-no-comments"},{flag:"--filter-has-deps"},{flag:"--filter-no-deps"},{flag:"--filter-has-body"},{flag:"--filter-empty-body"},{flag:"--filter-has-linked-command"},{flag:"--filter-no-linked-command"},{flag:"--ids",list:true},{flag:"--limit"},{flag:"--offset"}];const LIST_FILTER_FLAG_CONTRACTS=withCursorSemantics([{flag:"--for",value_name:"intent"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--status",list:true},{flag:"--all",value_type:"boolean"},{flag:"--type",list:true},{flag:"--tag",aliases:["--tags"],list:true},{flag:"--priority",list:true},{flag:"--deadline-before"},{flag:"--deadline-after"},{flag:"--today"},{flag:"--recent"},{flag:"--updated-after"},{flag:"--updated-before"},{flag:"--created-after"},{flag:"--created-before"},{flag:"--ids",list:true},{flag:"--assignee",list:true},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--parent"},{flag:"--sprint",list:true},{flag:"--release",list:true},{flag:"--filter-ac-missing"},{flag:"--filter-estimates-missing",aliases:["--filter-estimate-missing"]},{flag:"--filter-resolution-missing"},{flag:"--filter-metadata-missing"},...GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS,{flag:"--limit"},{flag:"--offset"},{flag:"--after"},{flag:"--no-truncate"},{flag:"--compact"},{flag:"--brief"},{flag:"--full"},{flag:"--fields",list:true},{flag:"--sort"},{flag:"--order"},{flag:"--tree"},{flag:"--tree-depth"},{flag:"--tree_depth"},{flag:"--include-body"},{flag:"--strict-read"},{flag:"--format"},{flag:"--stream"}],new Set(["--limit","--token-budget","--offset","--after","--no-truncate","--compact","--brief","--full","--fields","--include-body","--strict-read"]));const AGGREGATE_FLAG_CONTRACTS=[{flag:"--group-by",list:true},{flag:"--set-mode"},{flag:"--limit"},{flag:"--after"},{flag:"--count"},{flag:"--completion"},{flag:"--sum"},{flag:"--avg"},{flag:"--include-unparented"},{flag:"--include_unparented"},{flag:"--status",list:true},{flag:"--type",list:true},{flag:"--tag",list:true},{flag:"--priority",list:true},{flag:"--deadline-before"},{flag:"--deadline-after"},{flag:"--assignee",list:true},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--parent"},{flag:"--sprint",list:true},{flag:"--release",list:true}];const COMMENTS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--comment","--body","--text"]},{flag:"--stdin"},{flag:"--file"},{flag:"--edit"},{flag:"--delete"},{flag:"--limit"},{flag:"--full-history"},{flag:"--if-absent",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];function withCursorSemantics(contracts,presentationFlags){return contracts.map(contract=>presentationFlags.has(contract.flag)?{...contract,cursor_semantics:"presentation"}:contract)}const NOTES_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--note","--text"]},{flag:"--add-json"},{flag:"--stdin"},{flag:"--file"},{flag:"--edit"},{flag:"--delete"},{flag:"--limit"},{flag:"--since"},{flag:"--event-type"},{flag:"--include-meta"},{flag:"--full-history"},{flag:"--if-absent",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const LEARNINGS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--learning","--text"]},{flag:"--stdin"},{flag:"--file"},{flag:"--edit"},{flag:"--delete"},{flag:"--limit"},{flag:"--full-history"},{flag:"--if-absent",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const FILES_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add"},{flag:"--add-glob"},{flag:"--remove"},{flag:"--migrate"},{flag:"--note"},{flag:"--list"},{flag:"--append-stable"},{flag:"--validate-paths"},{flag:"--scope"},{flag:"--limit"},{flag:"--offset"},{flag:"--no-truncate"},{flag:"--strict-read"},{flag:"--explain"},{flag:"--lines",value_name:"start:end"},{flag:"--decision-depth",value_name:"n",value_type:"number"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const DOCS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add"},{flag:"--add-glob"},{flag:"--remove"},{flag:"--migrate"},{flag:"--note"},{flag:"--list"},{flag:"--validate-paths"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const HISTORY_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--limit"},{flag:"--compact"},{flag:"--full"},{flag:"--provenance"},{flag:"--provenance-summary"},{flag:"--harness",repeatable:true},{flag:"--agent-instance",repeatable:true},{flag:"--provenance-filter",repeatable:true},{flag:"--diff"},{flag:"--field"},{flag:"--verify"},{flag:"--strict-exit"},{flag:"--fail-on-warn"},{flag:"--format"}];const MERGE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--message"},{flag:"--force"},{flag:"--include-reconciled"},{flag:"--output"},{flag:"--item-path"},{flag:"--prefer"}];const HISTORY_REDACT_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--literal"},{flag:"--regex"},{flag:"--replacement"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const HISTORY_REPAIR_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--all"},{flag:"--dry-run"},{flag:"--normalize-provenance"},{flag:"--salvage-tail",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS=[{flag:"--event",repeatable:true},{flag:"--all-actionable"},{flag:"--dry-run"},{flag:"--plan-fingerprint"},{flag:"--limit",value_type:"number"},{flag:"--attributed-author",aliases:["--attributed_author"]},{flag:"--reviewer"},{flag:"--reason"}];const HISTORY_COMPACT_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--before"},{flag:"--ids",list:true},{flag:"--all-over",value_type:"number"},{flag:"--closed"},{flag:"--all-streams"},{flag:"--min-entries",value_type:"number"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const HISTORY_ATTEST_FLAG_CONTRACTS=[{flag:"--verify",value_name:"file",value_type:"string"},{flag:"--output",value_name:"file",value_type:"string"},{flag:"--hash-algorithm",value_name:"name",value_type:"string"}];const SCHEMA_FLAG_CONTRACTS=[{flag:"--definition",value_name:"json"},{flag:"--policy",value_name:"id"},{flag:"--message",value_name:"value"},{flag:"--description"},{flag:"--default-status",aliases:["--default_status"]},{flag:"--folder"},{flag:"--alias"},{flag:"--role"},{flag:"--order"},{flag:"--type"},{flag:"--commands"},{flag:"--cli-flag"},{flag:"--required"},{flag:"--required-on-create"},{flag:"--no-allow-unset"},{flag:"--required-types"},{flag:"--infer"},{flag:"--min-count"},{flag:"--apply",value_type:"boolean"},{flag:"--to"},{flag:"--migration-id",aliases:["--migration_id"]},{flag:"--dry-run"},{flag:"--author"},{flag:"--force"}];const PROFILE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--author"},{flag:"--force"}];const PLAN_FLAG_CONTRACTS=[{flag:"--title"},{flag:"--description"},{flag:"--scope"},{flag:"--parent"},{flag:"--related"},{flag:"--blocks"},{flag:"--blocked-by",aliases:["--blocked_by"]},{flag:"--harness"},{flag:"--mode"},{flag:"--resume-context",aliases:["--resume_context"]},{flag:"--tags",aliases:["--tag"],list:true},{flag:"--priority"},{flag:"--status",short:"-s"},{flag:"--create-mode",aliases:["--create_mode"]},{flag:"--deadline"},{flag:"--estimate",aliases:["--estimated-minutes","--estimated_minutes"]},{flag:"--acceptance-criteria",aliases:["--acceptance_criteria","--ac"],repeatable:true},{flag:"--definition-of-ready",aliases:["--definition_of_ready"]},{flag:"--order"},{flag:"--rank"},{flag:"--goal"},{flag:"--objective"},{flag:"--value"},{flag:"--impact"},{flag:"--outcome"},{flag:"--why-now",aliases:["--why_now"]},{flag:"--assignee"},{flag:"--reviewer"},{flag:"--risk"},{flag:"--confidence"},{flag:"--sprint"},{flag:"--release"},{flag:"--blocked-reason",aliases:["--blocked_reason"]},{flag:"--unblock-note",aliases:["--unblock_note"]},{flag:"--reporter"},{flag:"--severity"},{flag:"--environment"},{flag:"--repro-steps",aliases:["--repro_steps"]},{flag:"--resolution"},{flag:"--expected-result",aliases:["--expected_result","--expected"]},{flag:"--actual-result",aliases:["--actual_result","--actual"]},{flag:"--affected-version",aliases:["--affected_version"]},{flag:"--fixed-version",aliases:["--fixed_version"]},{flag:"--component"},{flag:"--regression"},{flag:"--customer-impact",aliases:["--customer_impact"]},{flag:"--comment",repeatable:true},{flag:"--note",repeatable:true},{flag:"--learning",repeatable:true},{flag:"--reminder",repeatable:true},{flag:"--event",repeatable:true},{flag:"--type-option",aliases:["--type_option"],repeatable:true},{flag:"--body"},{flag:"--claim"},{flag:"--from-search",aliases:["--from_search"]},{flag:"--template"},{flag:"--step-title",aliases:["--step_title"]},{flag:"--step"},{flag:"--step-body",aliases:["--step_body"]},{flag:"--step-owner",aliases:["--step_owner"]},{flag:"--step-status",aliases:["--step_status"]},{flag:"--step-evidence",aliases:["--step_evidence"]},{flag:"--step-blocked-reason",aliases:["--step_blocked_reason"]},{flag:"--step-replacement",aliases:["--step_replacement"]},{flag:"--depends-on",aliases:["--depends_on"]},{flag:"--link"},{flag:"--link-kind",aliases:["--link_kind"]},{flag:"--link-note",aliases:["--link_note"]},{flag:"--promote-to-item-dep",aliases:["--promote_to_item_dep"]},{flag:"--allow-multiple-active",aliases:["--allow_multiple_active"]},{flag:"--file"},{flag:"--test"},{flag:"--doc"},{flag:"--decision-text",aliases:["--decision_text","--decision"]},{flag:"--decision-rationale",aliases:["--decision_rationale"]},{flag:"--decision-evidence",aliases:["--decision_evidence"]},{flag:"--discovery-text",aliases:["--discovery_text","--discovery"]},{flag:"--validation-text",aliases:["--validation_text","--validation"]},{flag:"--validation-command",aliases:["--validation_command"]},{flag:"--validation-expected",aliases:["--validation_expected"]},{flag:"--depth"},{flag:"--field"},{flag:"--fields",list:true},{flag:"--steps"},{flag:"--materialize-type",aliases:["--materialize_type"]},{flag:"--materialize-parent",aliases:["--materialize_parent"]},{flag:"--materialize-tags",aliases:["--materialize_tags"]},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const INIT_FLAG_CONTRACTS=[{flag:"--id-prefix",aliases:["--prefix"]},{flag:"--preset"},{flag:"--type-preset"},{flag:"--defaults",short:"-y",aliases:["--yes"]},{flag:"--author"},{flag:"--agent-guidance"},{flag:"--with-packages"},{flag:"--no-merge-fence"},{flag:"--workspace"},{flag:"--force"},{flag:"--verbose"}];const CONFIG_FLAG_CONTRACTS=[{flag:"--value",value_name:"value"},{flag:"--criterion"},{flag:"--clear-criteria"},{flag:"--format"},{flag:"--policy"},{flag:"--default-depth"},{flag:"--activity-limit"},{flag:"--stale-threshold-days"},{flag:"--section-hierarchy"},{flag:"--section-activity"},{flag:"--section-progress"},{flag:"--section-blockers"},{flag:"--section-files"},{flag:"--section-workload"},{flag:"--section-staleness"},{flag:"--section-tests"}];const EXTENSION_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--init"},{flag:"--scaffold"},{flag:"--capability"},{flag:"--install"},{flag:"--uninstall"},{flag:"--explore"},{flag:"--list"},{flag:"--manage"},{flag:"--describe"},{flag:"--markdown"},{flag:"--output"},{flag:"--reload"},{flag:"--watch"},{flag:"--doctor"},{flag:"--catalog"},{flag:"--adopt"},{flag:"--adopt-all"},{flag:"--activate"},{flag:"--deactivate"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"},{flag:"--detail"},{flag:"--trace"},{flag:"--runtime-probe"},{flag:"--fix-managed-state"},{flag:"--isolated"},{flag:"--ignore-global"},{flag:"--strict-exit"},{flag:"--fail-on-warn"}];const EXTENSION_SCOPE_FLAG_CONTRACTS=[{flag:"--project"},{flag:"--local"},{flag:"--global"}];const EXTENSION_INIT_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--capability"}];const PACKAGE_FLAG_CONTRACTS=[...EXTENSION_FLAG_CONTRACTS,{flag:"--declarative"}];const PACKAGE_INIT_FLAG_CONTRACTS=[...EXTENSION_INIT_FLAG_CONTRACTS,{flag:"--declarative"}];const EXTENSION_INSTALL_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"}];const EXTENSION_UNINSTALL_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS;const EXTENSION_EXPLORE_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS;const EXTENSION_DESCRIBE_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--markdown"},{flag:"--output"}];const EXTENSION_ADOPT_ALL_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS;const EXTENSION_ACTIVATE_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS;const EXTENSION_DEACTIVATE_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS;const EXTENSION_MIGRATE_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--dry-run"}];const EXTENSION_MANAGE_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--runtime-probe"},{flag:"--fix-managed-state"}];const EXTENSION_RELOAD_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--watch"}];const EXTENSION_DOCTOR_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--detail"},{flag:"--trace"},{flag:"--fix-managed-state"},{flag:"--isolated"},{flag:"--ignore-global"},{flag:"--strict-exit"},{flag:"--fail-on-warn"}];const EXTENSION_CATALOG_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--fields",list:true}];const EXTENSION_ADOPT_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--gh"},{flag:"--github"},{flag:"--ref"}];const INSTALL_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"}];const UPGRADE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--cli-only"},{flag:"--packages-only"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--repair"},{flag:"--tag"},{flag:"--package-name"}];const REINDEX_FLAG_CONTRACTS=[{flag:"--mode"},{flag:"--progress"}];const CLOSE_FLAG_CONTRACTS=[{flag:"--release-assignment",value_type:"boolean"},{flag:"--id",value_name:"item-id"},{flag:"--reason",value_name:"value"},{flag:"--close-reason",value_name:"value"},{flag:"--completed-at",value_name:"value"},{flag:"--duplicate-of",value_name:"value"},{flag:"--author",value_name:"value"},{flag:"--message",value_name:"value"},{flag:"--validate-close",value_name:"off|warn|strict"},{flag:"--resolution",value_name:"value"},{flag:"--expected-result",aliases:["--expected_result","--expected"],value_name:"value"},{flag:"--actual-result",aliases:["--actual_result","--actual"],value_name:"value"},{flag:"--force",value_type:"boolean"}];const CLOSE_MANY_FLAG_CONTRACTS=[{flag:"--filter-status",list:true},{flag:"--filter-type"},{flag:"--filter-tag"},{flag:"--filter-priority"},{flag:"--filter-deadline-before"},{flag:"--filter-deadline-after"},{flag:"--filter-updated-after"},{flag:"--filter-updated-before"},{flag:"--filter-created-after"},{flag:"--filter-created-before"},{flag:"--filter-assignee"},{flag:"--filter-assignee-filter"},{flag:"--filter-assignee_filter"},{flag:"--filter-parent"},{flag:"--filter-sprint"},{flag:"--filter-release"},...MANY_GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS,{flag:"--reason"},{flag:"--completed-at"},{flag:"--resolution"},{flag:"--expected-result",aliases:["--expected_result","--expected"]},{flag:"--actual-result",aliases:["--actual_result","--actual"]},{flag:"--validate-close"},{flag:"--author"},{flag:"--message"},{flag:"--force"},{flag:"--dry-run"},{flag:"--rollback"},{flag:"--no-checkpoint"}];const APPEND_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--body",short:"-b"},{flag:"--text"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const CLAIM_FLAG_CONTRACTS=[{flag:"--start",value_type:"boolean"},{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"},{flag:"--if-available"},{flag:"--next"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--assignee-filter"},{flag:"--parent"},{flag:"--sprint"},{flag:"--release"},{flag:"--max-attempts"},{flag:"--include-decisions"},{flag:"--include-gates"},{flag:"--include-containers"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--explain-ranking",aliases:["--explain_ranking"]}];const RESTORE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const DELETE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const RELEASE_FLAG_CONTRACTS=[{flag:"--pause",value_type:"boolean"},{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"}];const START_TASK_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"}];const PAUSE_TASK_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"}];const CLOSE_TASK_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--validate-close",value_name:"off|warn|strict"},{flag:"--force"}];const SCHEDULING_SHORTCUT_COMMON_FLAG_CONTRACTS=[{flag:"--parent"},{flag:"--allow-missing-parent"},{flag:"--tags"},{flag:"--priority"},{flag:"--body"},{flag:"--description"},{flag:"--author"},{flag:"--message"}];const MEET_FLAG_CONTRACTS=[{flag:"--start"},{flag:"--duration"},{flag:"--end"},{flag:"--location"},{flag:"--timezone"},{flag:"--all-day"},...SCHEDULING_SHORTCUT_COMMON_FLAG_CONTRACTS];const EVENT_FLAG_CONTRACTS=MEET_FLAG_CONTRACTS;const REMIND_FLAG_CONTRACTS=[{flag:"--at"},{flag:"--text"},...SCHEDULING_SHORTCUT_COMMON_FLAG_CONTRACTS];const TEST_FLAG_CONTRACTS=[{flag:"--list"},{flag:"--id",value_name:"item-id"},{flag:"--add"},{flag:"--add-json"},{flag:"--remove"},{flag:"--remove-index",repeatable:true},{flag:"--run"},{flag:"--match"},{flag:"--only-index"},{flag:"--only-last"},{flag:"--background"},{flag:"--timeout"},{flag:"--progress"},{flag:"--env-set"},{flag:"--env-clear"},{flag:"--shared-host-safe"},{flag:"--pm-context"},{flag:"--override-linked-pm-context"},{flag:"--workspace-context"},{flag:"--override-linked-workspace-context"},{flag:"--allow-untrusted-linked-tests"},{flag:"--acknowledge-linked-tests"},{flag:"--fail-on-context-mismatch"},{flag:"--fail-on-skipped"},{flag:"--fail-on-empty-test-run"},{flag:"--require-assertions-for-pm"},{flag:"--check-context"},{flag:"--auto-pm-context"},{flag:"--measure",list:true},{flag:"--metric-below"},{flag:"--metric-diff"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const TEST_ALL_FLAG_CONTRACTS=[{flag:"--status"},{flag:"--limit"},{flag:"--offset"},{flag:"--background"},{flag:"--timeout"},{flag:"--progress"},{flag:"--env-set"},{flag:"--env-clear"},{flag:"--shared-host-safe"},{flag:"--pm-context"},{flag:"--override-linked-pm-context"},{flag:"--workspace-context"},{flag:"--override-linked-workspace-context"},{flag:"--allow-untrusted-linked-tests"},{flag:"--fail-on-context-mismatch"},{flag:"--fail-on-skipped"},{flag:"--fail-on-empty-test-run"},{flag:"--require-assertions-for-pm"},{flag:"--check-context"},{flag:"--auto-pm-context"}];const TELEMETRY_FLAG_CONTRACTS=[{flag:"--limit"}];const TEST_RUNS_FLAG_CONTRACTS=[{flag:"--status"},{flag:"--limit"},{flag:"--stream"},{flag:"--tail"},{flag:"--force"},{flag:"--author"}];const GC_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--scope"}];const STATS_FLAG_CONTRACTS=[{flag:"--include-empty"},{flag:"--storage"},{flag:"--metadata-coverage"},{flag:"--field-utilization"},{flag:"--by-assignee"},{flag:"--by-tag"},{flag:"--by-priority"},{flag:"--tag-prefix"},{flag:"--analytics"}];const DUPLICATES_FLAG_CONTRACTS=[{flag:"--exhaustive",value_type:"boolean"},{flag:"--status",repeatable:true,list:true},{flag:"--since"},{flag:"--threshold"},{flag:"--limit"}];const HEALTH_FLAG_CONTRACTS=[{flag:"--strict-directories"},{flag:"--require-merge-drivers"},{flag:"--strict-exit"},{flag:"--fail-on-warn"},{flag:"--check-only"},{flag:"--check-telemetry"},{flag:"--no-refresh"},{flag:"--refresh-vectors"},{flag:"--verbose-stale-items"},{flag:"--verbose-author-events"},{flag:"--brief"},{flag:"--summary"},{flag:"--skip-vectors"},{flag:"--skip-integrity"},{flag:"--skip-drift"},{flag:"--full"}];const VALIDATE_FLAG_CONTRACTS=[{flag:"--check-completeness",value_type:"boolean"},{flag:"--check-metadata"},{flag:"--metadata-profile"},{flag:"--check-resolution"},{flag:"--check-lifecycle"},{flag:"--check-stale-blockers"},{flag:"--dependency-cycle-severity"},{flag:"--parent-cycle-severity"},{flag:"--check-files"},{flag:"--scan-mode"},{flag:"--include-pm-internals"},{flag:"--verbose-file-lists"},{flag:"--verbose-diagnostics"},{flag:"--all-affected-ids"},{flag:"--strict-exit"},{flag:"--fail-on-warn"},{flag:"--fix-hints"},{flag:"--auto-fix"},{flag:"--dry-run"},{flag:"--fix-scope"},{flag:"--prune-missing"},{flag:"--check-history-drift"},{flag:"--check-command-references"},{flag:"--check-storage-integrity"},{flag:"--counts"},{flag:"--full"}];const ASSURANCE_FLAG_CONTRACTS=[{flag:"--definition",value_name:"json"},{flag:"--trigger",value_name:"value"},{flag:"--tree",value_name:"value"},{flag:"--gate",value_name:"id"},{flag:"--limit",value_name:"number"},{flag:"--dry-run"},{flag:"--author",value_name:"value"},{flag:"--message",value_name:"value"},{flag:"--owner",value_name:"item-id"},{flag:"--apply",value_type:"boolean"},{flag:"--enforcement",value_name:"level"}];const ITEM_OWNERSHIP_AND_ISSUE_FLAG_CONTRACTS=[{flag:"--assignee"},{flag:"--parent"},{flag:"--allow-missing-parent"},{flag:"--allow-unresolved-deps"},{flag:"--reviewer"},{flag:"--risk"},{flag:"--confidence"},{flag:"--sprint"},{flag:"--release"},{flag:"--blocked-by"},{flag:"--blocked-reason"},{flag:"--unblock-note"},{flag:"--reporter"},{flag:"--severity"},{flag:"--environment"},{flag:"--repro-steps"},{flag:"--resolution"},{flag:"--expected-result"},{flag:"--actual-result"},{flag:"--affected-version"},{flag:"--fixed-version"}];const ITEM_PORTFOLIO_FLAG_CONTRACTS=[{flag:"--component"},{flag:"--regression"},{flag:"--customer-impact"},{flag:"--customer_impact"},{flag:"--definition-of-ready"},{flag:"--definition_of_ready"},{flag:"--order"},{flag:"--rank"},{flag:"--goal"},{flag:"--objective"},{flag:"--value"},{flag:"--impact"},{flag:"--outcome"},{flag:"--why-now"},{flag:"--why_now"}];const ITEM_CONTENT_METADATA_FLAG_CONTRACTS=[{short:"-p",flag:"--priority"},{flag:"--type"},{flag:"--tags",aliases:["--tag"],list:true},{flag:"--add-tags",aliases:["--add_tags"]},{flag:"--remove-tags",aliases:["--remove_tags"]},{flag:"--deadline"},{flag:"--estimate"},{flag:"--estimated-minutes"},{flag:"--estimated_minutes"},{flag:"--acceptance-criteria"},{flag:"--acceptance_criteria"},{flag:"--ac"},{flag:"--add-ac",aliases:["--add_ac"]},{flag:"--remove-ac",aliases:["--remove_ac"]}];const CREATE_FLAG_CONTRACTS=[{flag:"--stdin-json"},{short:"-t",flag:"--title"},{flag:"--id"},{short:"-d",flag:"--description"},{flag:"--type"},{flag:"--template"},{flag:"--create-mode"},{flag:"--create_mode"},{flag:"--schedule-preset"},{flag:"--schedule_preset"},{short:"-s",flag:"--status"},{flag:"--close-reason"},{flag:"--close_reason"},{flag:"--completed-at"},{flag:"--completed_at"},{short:"-p",flag:"--priority"},{flag:"--tags",aliases:["--tag"],list:true},{flag:"--add-tags",aliases:["--add_tags"]},{short:"-b",flag:"--body"},{flag:"--body-file"},{flag:"--deadline"},{flag:"--estimate"},{flag:"--estimated-minutes"},{flag:"--estimated_minutes"},{flag:"--acceptance-criteria"},{flag:"--acceptance_criteria"},{flag:"--ac"},{flag:"--author"},{flag:"--message"},...ITEM_OWNERSHIP_AND_ISSUE_FLAG_CONTRACTS,...ITEM_PORTFOLIO_FLAG_CONTRACTS,{flag:"--blocked_by"},{flag:"--blocked_reason"},{flag:"--unblock_note"},{flag:"--repro_steps"},{flag:"--expected_result"},{flag:"--actual_result"},{flag:"--expected"},{flag:"--actual"},{flag:"--affected_version"},{flag:"--fixed_version"},{flag:"--dep"},{flag:"--type-option"},{flag:"--type_option"},{flag:"--field"},{flag:"--reminder"},{flag:"--event"},{flag:"--comment"},{flag:"--note"},{flag:"--learning"},{flag:"--file",aliases:["--linked-file"]},{flag:"--test",aliases:["--linked-test"]},{flag:"--doc"},{flag:"--unset"},{flag:"--clear-deps"},{flag:"--clear-comments"},{flag:"--clear-notes"},{flag:"--clear-learnings"},{flag:"--clear-files"},{flag:"--clear-tests"},{flag:"--clear-docs"},{flag:"--clear-reminders"},{flag:"--clear-events"},{flag:"--clear-type-options"},{flag:"--allow-duplicate",value_type:"boolean"}];const ITEM_MUTATE_FLAG_CONTRACTS=[{flag:"--transaction-id",value_name:"value"},{flag:"--stdin-json"},{flag:"--dry-run"},{flag:"--create-compensation",value_name:"mode"},{flag:"--lock-ttl-seconds",value_name:"n"},{flag:"--lock-wait-ms",value_name:"n"},{flag:"--author",value_name:"value"}];const ITEM_COMPLETE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--transaction-id",value_name:"value",required:true},{flag:"--reason",value_name:"value"},{flag:"--file",value_name:"value",repeatable:true},{flag:"--doc",value_name:"value",repeatable:true},{flag:"--test",value_name:"value",repeatable:true},{flag:"--comment",value_name:"value",repeatable:true},{flag:"--note",value_name:"value",repeatable:true},{flag:"--learning",value_name:"value",repeatable:true},{flag:"--resolution",value_name:"value"},{flag:"--expected-result",value_name:"value"},{flag:"--actual-result",value_name:"value"},{flag:"--completed-at",value_name:"value"},{flag:"--validate-close",value_name:"off|warn|strict"},{flag:"--lock-ttl-seconds",value_name:"n"},{flag:"--lock-wait-ms",value_name:"n"},{flag:"--dry-run"},{flag:"--force"},{flag:"--author",value_name:"value"}];const ITEM_REOPEN_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--status",value_name:"open|in_progress"},{flag:"--message",value_name:"value"},{flag:"--force"},{flag:"--author",value_name:"value"}];const COPY_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--title",value_name:"value"},{flag:"--author",value_name:"value"},{flag:"--message",value_name:"value"},{flag:"--allow-duplicate",value_type:"boolean"}];const FOCUS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--clear"}];const UPDATE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--stdin-json"},{short:"-t",flag:"--title"},{short:"-d",flag:"--description"},{short:"-b",flag:"--body"},{flag:"--body-file"},{short:"-s",flag:"--status"},{flag:"--close-reason"},{flag:"--close_reason"},{flag:"--completed-at"},...ITEM_CONTENT_METADATA_FLAG_CONTRACTS,...ITEM_OWNERSHIP_AND_ISSUE_FLAG_CONTRACTS,{flag:"--fixed_version"},...ITEM_PORTFOLIO_FLAG_CONTRACTS,{flag:"--author"},{flag:"--message"},{flag:"--blocked_by"},{flag:"--blocked_reason"},{flag:"--unblock_note"},{flag:"--repro_steps"},{flag:"--expected_result"},{flag:"--actual_result"},{flag:"--expected"},{flag:"--actual"},{flag:"--affected_version"},{flag:"--dep"},{flag:"--dep-remove"},{flag:"--dep_remove"},{flag:"--replace-deps"},{flag:"--replace-tests"},{flag:"--replace-files"},{flag:"--replace-docs"},{flag:"--comment"},{flag:"--note"},{flag:"--learning"},{flag:"--file",aliases:["--linked-file"]},{flag:"--test",aliases:["--linked-test"]},{flag:"--doc"},{flag:"--reminder"},{flag:"--event"},{flag:"--type-option"},{flag:"--type_option"},{flag:"--field"},{flag:"--unset"},{flag:"--clear-deps"},{flag:"--clear-comments"},{flag:"--clear-notes"},{flag:"--clear-learnings"},{flag:"--clear-files"},{flag:"--clear-tests"},{flag:"--clear-docs"},{flag:"--clear-reminders"},{flag:"--clear-events"},{flag:"--clear-type-options"},{flag:"--force"}];const UPDATE_MANY_FLAG_CONTRACTS=[{flag:"--status",short:"-s"},{flag:"--assignee"},{flag:"--parent"},{flag:"--blocked-by",aliases:["--blocked_by"]},{flag:"--blocked-reason",aliases:["--blocked_reason"]},{flag:"--unblock-note",aliases:["--unblock_note"]},{flag:"--filter-status",list:true},{flag:"--filter-type",list:true},{flag:"--filter-tag",list:true},{flag:"--filter-priority",list:true},{flag:"--filter-deadline-before"},{flag:"--filter-deadline-after"},{flag:"--filter-updated-after"},{flag:"--filter-updated-before"},{flag:"--filter-created-after"},{flag:"--filter-created-before"},{flag:"--filter-assignee",list:true},{flag:"--filter-assignee-filter"},{flag:"--filter-assignee_filter"},{flag:"--filter-parent"},{flag:"--filter-sprint",list:true},{flag:"--filter-release",list:true},{flag:"--filter-ac-missing"},{flag:"--filter-estimates-missing",aliases:["--filter-estimate-missing"]},{flag:"--filter-resolution-missing"},{flag:"--filter-metadata-missing"},...MANY_GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS,{flag:"--dry-run"},{flag:"--rollback"},{flag:"--no-checkpoint"},{short:"-t",flag:"--title"},{short:"-d",flag:"--description"},{short:"-b",flag:"--body"},...ITEM_CONTENT_METADATA_FLAG_CONTRACTS,{flag:"--definition-of-ready"},{flag:"--definition_of_ready"},{flag:"--order"},{flag:"--rank"},{flag:"--goal"},{flag:"--objective"},{flag:"--value"},{flag:"--impact"},{flag:"--outcome"},{flag:"--why-now"},{flag:"--why_now"},{flag:"--reviewer"},{flag:"--risk"},{flag:"--confidence"},{flag:"--sprint"},{flag:"--release"},{flag:"--reporter"},{flag:"--severity"},{flag:"--environment"},{flag:"--repro-steps"},{flag:"--repro_steps"},{flag:"--resolution"},{flag:"--expected-result"},{flag:"--expected_result"},{flag:"--expected"},{flag:"--actual-result"},{flag:"--actual_result"},{flag:"--actual"},{flag:"--affected-version"},{flag:"--affected_version"},{flag:"--fixed-version"},{flag:"--fixed_version"},{flag:"--component"},{flag:"--regression"},{flag:"--customer-impact"},{flag:"--customer_impact"},{flag:"--allow-unresolved-deps"},{flag:"--dep"},{flag:"--dep-remove"},{flag:"--dep_remove"},{flag:"--replace-deps"},{flag:"--replace-tests"},{flag:"--replace-files"},{flag:"--replace-docs"},{flag:"--comment"},{flag:"--note"},{flag:"--learning"},{flag:"--file"},{flag:"--test"},{flag:"--doc"},{flag:"--reminder"},{flag:"--event"},{flag:"--type-option"},{flag:"--type_option"},{flag:"--unset"},{flag:"--clear-deps"},{flag:"--clear-comments"},{flag:"--clear-notes"},{flag:"--clear-learnings"},{flag:"--clear-files"},{flag:"--clear-tests"},{flag:"--clear-docs"},{flag:"--clear-reminders"},{flag:"--clear-events"},{flag:"--clear-type-options"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];const CALENDAR_FLAG_CONTRACTS=[{flag:"--view"},{flag:"--date"},{flag:"--from"},{flag:"--to"},{flag:"--past"},{flag:"--full-period"},{flag:"--full_period"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--status"},{flag:"--assignee"},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--sprint"},{flag:"--release"},{flag:"--include"},{flag:"--recurrence-lookahead-days"},{flag:"--recurrence-lookback-days"},{flag:"--occurrence-limit"},{flag:"--limit"},{flag:"--format"}];const ACTIVITY_FLAG_CONTRACTS=[{flag:"--id"},{flag:"--op"},{flag:"--author"},{flag:"--from"},{flag:"--to"},{flag:"--limit"},{flag:"--unbounded"},{flag:"--compact"},{flag:"--raw"},{flag:"--full"},{flag:"--provenance"},{flag:"--provenance-summary"},{flag:"--harness",repeatable:true},{flag:"--agent-instance",repeatable:true},{flag:"--provenance-filter",repeatable:true},{flag:"--stream"}];const EVENTS_FLAG_CONTRACTS=[{flag:"--since"},{flag:"--type",repeatable:true},{flag:"--author",repeatable:true},{flag:"--item",repeatable:true},{flag:"--limit",value_type:"number"},{flag:"--cursor-mode",value_name:"batch|row"},{flag:"--full"},{flag:"--provenance"},{flag:"--provenance-summary"},{flag:"--harness",repeatable:true},{flag:"--agent-instance",repeatable:true},{flag:"--provenance-filter",repeatable:true},{flag:"--follow"},{flag:"--interval-ms",value_type:"number"}];const CONTEXT_FLAG_CONTRACTS=withCursorSemantics([{flag:"--for",value_name:"intent"},{flag:"--date"},{flag:"--from"},{flag:"--to"},{flag:"--past"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--assignee"},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--sprint"},{flag:"--release"},{flag:"--parent"},{flag:"--limit",aliases:["--max-items"]},{flag:"--after"},{flag:"--format"},{flag:"--depth"},{flag:"--fields",list:true},{flag:"--section"},{flag:"--activity-limit"},{flag:"--stale-threshold"},{flag:"--explain-ranking"},{flag:"--explain_ranking"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--no-extension-health"},{flag:"--no-tags"}],new Set(["--limit","--after","--format","--fields","--section","--activity-limit","--stale-threshold","--explain-ranking","--explain_ranking","--no-extension-health","--no-tags"]));const GET_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--for",value_name:"intent"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--depth"},{flag:"--full",value_type:"boolean"},{flag:"--fields",list:true},{flag:"--at"},{flag:"--tree"},{flag:"--tree-depth"},{flag:"--tree_depth"},{flag:"--format"}];const GUIDE_FLAG_CONTRACTS=[{flag:"--list"},{flag:"--format"},{flag:"--depth"}];const DEPS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--format"},{flag:"--max-depth"},{flag:"--collapse"},{flag:"--summary"},{flag:"--full"},{flag:"--node-limit"},{flag:"--edge-limit"},{flag:"--token-budget"},{flag:"--cursor"},{flag:"--direction"},{flag:"--kind",list:true}];const GRAPH_FLAG_CONTRACTS=[{flag:"--kind",list:true},{flag:"--max-depth",description:`Maximum traversal depth; paths default to ${GRAPH_QUERY_DEFAULTS.path_depth}.`},{flag:"--limit",description:`Maximum rows per collection; default ${GRAPH_QUERY_DEFAULTS.rows}. Use --full to remove the row cap.`},{flag:"--after"},{flag:"--direction"},{flag:"--max-paths",description:`Maximum enumerated paths; default ${GRAPH_QUERY_DEFAULTS.paths}.`},{flag:"--sample",description:`Maximum evidence examples per audit finding; default ${GRAPH_QUERY_DEFAULTS.samples}.`},{flag:"--exempt-isolate",list:true},{flag:"--exempt-isolate-type",list:true},{flag:"--save-baseline"},{flag:"--rebuild"},{flag:"--clear"},{flag:"--summary"},{flag:"--full"}];const EVAL_FLAG_CONTRACTS=[{flag:"--mode"},{flag:"--k"},{flag:"--fail-under"},{flag:"--queries"},{flag:"--format"}];const WORKSPACE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--force"},{flag:"--author"},{flag:"--message"}];const WORKSPACE_POSITION_FLAG_CONTRACTS=[];const NEXT_FLAG_CONTRACTS=[{flag:"--include-decisions"},{flag:"--include-gates"},{flag:"--include-containers"},{flag:"--for",value_name:"intent"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--assignee"},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--sprint"},{flag:"--release"},{flag:"--parent"},{flag:"--limit"},{flag:"--blocked-limit"},{flag:"--blocked_limit"},{flag:"--ready-only"},{flag:"--ready_only"},{flag:"--format"},{flag:"--explain-ranking"},{flag:"--explain_ranking"},{flag:"--token-budget",aliases:["--token_budget"]}];const SEARCH_FLAG_CONTRACTS=withCursorSemantics([{flag:"--for",value_name:"intent"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--mode"},{flag:"--semantic"},{flag:"--hybrid"},{flag:"--match-mode"},{flag:"--min-score"},{flag:"--count"},{flag:"--semantic-weight"},{flag:"--include-linked"},{flag:"--title-exact"},{flag:"--phrase-exact"},{flag:"--highlight"},{flag:"--compact"},{flag:"--full"},{flag:"--fields",list:true},{flag:"--format"},{flag:"--limit"},{flag:"--after"},{flag:"--status",list:true},{flag:"--type",list:true},{flag:"--tag",aliases:["--tags"],list:true},{flag:"--priority",list:true},{flag:"--deadline-before"},{flag:"--deadline-after"},{flag:"--updated-after"},{flag:"--updated-before"},{flag:"--created-after"},{flag:"--created-before"},{flag:"--assignee",list:true},{flag:"--sprint",list:true},{flag:"--release",list:true},{flag:"--parent"},...GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS],new Set(["--highlight","--compact","--full","--fields","--format","--limit","--token-budget","--after"]));const CONTRACTS_FLAG_CONTRACTS=[{flag:"--action"},{flag:"--command"},{flag:"--summary"},{flag:"--schema-only"},{flag:"--flags-only"},{flag:"--availability-only"},{flag:"--runtime-only"},{flag:"--active-only"},{flag:"--full"}];const COMPLETION_FLAG_CONTRACTS=[{flag:"--eager-tags"}];function toUniqueFlagContracts(contracts){const seen=new Set;const unique=[];for(const contract of contracts){const aliasKey=(contract.aliases??[]).join(",");const key=`${contract.flag}|${contract.short??""}|${aliasKey}`;if(seen.has(key)){continue}seen.add(key);unique.push(contract)}return unique}function withSubcommandGlobalFlags(contracts){const byCanonicalFlag=new Map;for(const contract of[...SUBCOMMAND_GLOBAL_FLAG_CONTRACTS,...contracts]){const canonicalFlag=normalizeFlagAliasKey(contract.flag);const prior=byCanonicalFlag.get(canonicalFlag);const{aliases:declaredAliases,...contractWithoutAliases}=contract;const aliases=normalizeUniqueStringList([...declaredAliases??[],...contract.flag===canonicalFlag?[]:[contract.flag]]).filter(alias=>alias!==canonicalFlag);const normalizedContract={...contractWithoutAliases,flag:canonicalFlag,...aliases.length>0?{aliases}:{}};const mergedAliases=normalizeUniqueStringList([...prior?.aliases??[],...normalizedContract.aliases??[]]);byCanonicalFlag.set(canonicalFlag,prior===void 0?normalizedContract:{...prior,...normalizedContract,...mergedAliases.length>0?{aliases:mergedAliases}:{}})}return withFlagAliasMetadata([...byCanonicalFlag.values()])}const FIXED_STATUS_LIST_COMMAND_ALIASES=["list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled"];const FIXED_STATUS_LIST_FLAG_CONTRACTS=LIST_FILTER_FLAG_CONTRACTS.filter(contract=>contract.flag!=="--status"&&contract.flag!=="--all");function indexCliFlagContracts(contracts){const index=new Map;for(const contract of contracts){for(const spelling of[contract.flag,...contract.aliases??[]]){const matches=index.get(spelling)??[];matches.push(contract);index.set(spelling,matches)}}return index}const PLAN_FLAG_CONTRACT_INDEX=indexCliFlagContracts(PLAN_FLAG_CONTRACTS);const ASSURANCE_FLAG_CONTRACT_INDEX=indexCliFlagContracts(ASSURANCE_FLAG_CONTRACTS);const POSITIONAL_ACTION_FLAG_INDEX_BY_PARENT=new Map([["assurance",ASSURANCE_FLAG_CONTRACT_INDEX],["plan",PLAN_FLAG_CONTRACT_INDEX],["workspace",indexCliFlagContracts(WORKSPACE_POSITION_FLAG_CONTRACTS)],["workspace snapshot",indexCliFlagContracts(WORKSPACE_FLAG_CONTRACTS)]]);function resolvePmPositionalActionFlagContracts(actions=PM_POSITIONAL_ACTION_CONTRACTS){return actions.map(({command,parent,accepted_flags:acceptedFlags})=>{const parentFlagIndex=POSITIONAL_ACTION_FLAG_INDEX_BY_PARENT.get(parent);if(!parentFlagIndex){throw new Error(`Positional action ${command} has no flag-contract index for ${parent}.`)}const selected=acceptedFlags.map(acceptedFlag=>{const matches=parentFlagIndex.get(acceptedFlag)??[];if(matches.length!==1){throw new Error(`Positional action ${command} accepted flag ${acceptedFlag} does not resolve to exactly one ${parent} flag contract.`)}return matches[0]});return[command,selected]})}const PM_POSITIONAL_ACTION_FLAG_CONTRACTS=resolvePmPositionalActionFlagContracts();const SUBCOMMAND_FLAG_CONTRACTS_BY_COMMAND=new Map([["list",LIST_FILTER_FLAG_CONTRACTS],["list-all",LIST_FILTER_FLAG_CONTRACTS],...FIXED_STATUS_LIST_COMMAND_ALIASES.map(command=>[command,FIXED_STATUS_LIST_FLAG_CONTRACTS]),["templates",CREATE_FLAG_CONTRACTS],["cal",CALENDAR_FLAG_CONTRACTS],["ctx",CONTEXT_FLAG_CONTRACTS],["test-runs-worker",[]],["init",INIT_FLAG_CONTRACTS],["config",CONFIG_FLAG_CONTRACTS],["extension",EXTENSION_FLAG_CONTRACTS],["package",PACKAGE_FLAG_CONTRACTS],["packages",PACKAGE_FLAG_CONTRACTS],["install",INSTALL_FLAG_CONTRACTS],["upgrade",UPGRADE_FLAG_CONTRACTS],["create",CREATE_FLAG_CONTRACTS],["item",[]],["item mutate",ITEM_MUTATE_FLAG_CONTRACTS],["item complete",ITEM_COMPLETE_FLAG_CONTRACTS],["item reopen",ITEM_REOPEN_FLAG_CONTRACTS],["copy",COPY_FLAG_CONTRACTS],["focus",FOCUS_FLAG_CONTRACTS],["aggregate",AGGREGATE_FLAG_CONTRACTS],["calendar",CALENDAR_FLAG_CONTRACTS],["context",CONTEXT_FLAG_CONTRACTS],["get",GET_FLAG_CONTRACTS],["guide",GUIDE_FLAG_CONTRACTS],["search",SEARCH_FLAG_CONTRACTS],["next",NEXT_FLAG_CONTRACTS],["eval",EVAL_FLAG_CONTRACTS],["workspace",WORKSPACE_FLAG_CONTRACTS],["workspace position",WORKSPACE_POSITION_FLAG_CONTRACTS],["workspace snapshot",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot create",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot list",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot inspect",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot restore",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot delete",WORKSPACE_FLAG_CONTRACTS],["history",HISTORY_FLAG_CONTRACTS],["history-redact",HISTORY_REDACT_FLAG_CONTRACTS],["history-repair",HISTORY_REPAIR_FLAG_CONTRACTS],["history-author-acknowledge",HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS],["history-compact",HISTORY_COMPACT_FLAG_CONTRACTS],["history-attest",HISTORY_ATTEST_FLAG_CONTRACTS],["merge",MERGE_FLAG_CONTRACTS],["schema",SCHEMA_FLAG_CONTRACTS],["profile",PROFILE_FLAG_CONTRACTS],["plan",PLAN_FLAG_CONTRACTS],["activity",ACTIVITY_FLAG_CONTRACTS],["events",EVENTS_FLAG_CONTRACTS],["restore",RESTORE_FLAG_CONTRACTS],["update",UPDATE_FLAG_CONTRACTS],["update-many",UPDATE_MANY_FLAG_CONTRACTS],["close",CLOSE_FLAG_CONTRACTS],["close-many",CLOSE_MANY_FLAG_CONTRACTS],["delete",DELETE_FLAG_CONTRACTS],["append",APPEND_FLAG_CONTRACTS],["comments",COMMENTS_FLAG_CONTRACTS],["notes",NOTES_FLAG_CONTRACTS],["learnings",LEARNINGS_FLAG_CONTRACTS],["files",FILES_FLAG_CONTRACTS],["docs",DOCS_FLAG_CONTRACTS],["deps",DEPS_FLAG_CONTRACTS],["graph",GRAPH_FLAG_CONTRACTS],["test",TEST_FLAG_CONTRACTS],["test-all",TEST_ALL_FLAG_CONTRACTS],["telemetry",TELEMETRY_FLAG_CONTRACTS],["health",HEALTH_FLAG_CONTRACTS],["assurance",ASSURANCE_FLAG_CONTRACTS],...PM_POSITIONAL_ACTION_FLAG_CONTRACTS,["validate",VALIDATE_FLAG_CONTRACTS],["gc",GC_FLAG_CONTRACTS],["stats",STATS_FLAG_CONTRACTS],["duplicates",DUPLICATES_FLAG_CONTRACTS],["contracts",CONTRACTS_FLAG_CONTRACTS],["completion",COMPLETION_FLAG_CONTRACTS],["claim",CLAIM_FLAG_CONTRACTS],["release",RELEASE_FLAG_CONTRACTS],["start-task",START_TASK_FLAG_CONTRACTS],["pause-task",PAUSE_TASK_FLAG_CONTRACTS],["close-task",CLOSE_TASK_FLAG_CONTRACTS],["meet",MEET_FLAG_CONTRACTS],["event",EVENT_FLAG_CONTRACTS],["remind",REMIND_FLAG_CONTRACTS]]);const EXTENSION_LIFECYCLE_FLAG_CONTRACTS_BY_SUBCOMMAND=new Map([["install",EXTENSION_INSTALL_FLAG_CONTRACTS],["uninstall",EXTENSION_UNINSTALL_FLAG_CONTRACTS],["explore",EXTENSION_EXPLORE_FLAG_CONTRACTS],["manage",EXTENSION_MANAGE_FLAG_CONTRACTS],["describe",EXTENSION_DESCRIBE_FLAG_CONTRACTS],["reload",EXTENSION_RELOAD_FLAG_CONTRACTS],["doctor",EXTENSION_DOCTOR_FLAG_CONTRACTS],["catalog",EXTENSION_CATALOG_FLAG_CONTRACTS],["list",EXTENSION_CATALOG_FLAG_CONTRACTS],["adopt",EXTENSION_ADOPT_FLAG_CONTRACTS],["adopt-all",EXTENSION_ADOPT_ALL_FLAG_CONTRACTS],["activate",EXTENSION_ACTIVATE_FLAG_CONTRACTS],["deactivate",EXTENSION_DEACTIVATE_FLAG_CONTRACTS],["migrate",EXTENSION_MIGRATE_FLAG_CONTRACTS]]);function normalizeCommandNameForContracts(commandName){if(typeof commandName!=="string"){return""}return resolvePmHistoryOperation(commandName.trim().toLowerCase())}function hasSubcommandFlagContractsForCommand(commandName){const normalized=normalizeCommandNameForContracts(commandName);if(SUBCOMMAND_FLAG_CONTRACTS_BY_COMMAND.has(normalized)){return true}const[rootCommand,lifecycleSubcommand,...extraParts]=normalized.split(/\s+/);return(rootCommand==="extension"||rootCommand==="package"||rootCommand==="packages")&&lifecycleSubcommand!==void 0&&extraParts.length===0&&(lifecycleSubcommand==="init"||lifecycleSubcommand==="scaffold"||EXTENSION_LIFECYCLE_FLAG_CONTRACTS_BY_SUBCOMMAND.has(lifecycleSubcommand))}function resolveExtensionLifecycleFlagContracts(rootCommand,lifecycleSubcommand){if(lifecycleSubcommand==="init"||lifecycleSubcommand==="scaffold"){return rootCommand==="extension"?EXTENSION_INIT_FLAG_CONTRACTS:PACKAGE_INIT_FLAG_CONTRACTS}return EXTENSION_LIFECYCLE_FLAG_CONTRACTS_BY_SUBCOMMAND.get(lifecycleSubcommand)??[]}function resolveSubcommandFlagContractsForCommand(commandName){const normalized=normalizeCommandNameForContracts(commandName);if(normalized.length===0){return withSubcommandGlobalFlags([])}const[rootCommand,lifecycleSubcommand,...extraParts]=normalized.split(/\s+/);if((rootCommand==="extension"||rootCommand==="package"||rootCommand==="packages")&&lifecycleSubcommand!==void 0&&extraParts.length===0){if((rootCommand==="package"||rootCommand==="packages")&&lifecycleSubcommand==="upgrade"){return withSubcommandGlobalFlags(UPGRADE_FLAG_CONTRACTS)}return withSubcommandGlobalFlags(resolveExtensionLifecycleFlagContracts(rootCommand,lifecycleSubcommand))}const contracts=SUBCOMMAND_FLAG_CONTRACTS_BY_COMMAND.get(normalized)??[];return withSubcommandGlobalFlags(contracts)}function toCompletionFlagString(flagContracts,includeGlobal=true){const aliasAwareContracts=withFlagAliasMetadata(flagContracts);const scoped=aliasAwareContracts.flatMap(entry=>[entry.short,entry.flag,...entry.aliases??[]]).filter(value=>Boolean(value));const all=includeGlobal?[...scoped,...SUBCOMMAND_GLOBAL_FLAG_CONTRACTS.flatMap(entry=>[entry.short,entry.flag,...entry.aliases??[]]).filter(value=>Boolean(value))]:scoped;return normalizeUniqueStringList(all).join(" ")}export{ACTIVITY_FLAG_CONTRACTS,AGGREGATE_FLAG_CONTRACTS,APPEND_FLAG_CONTRACTS,ASSURANCE_FLAG_CONTRACTS,CALENDAR_FLAG_CONTRACTS,CLAIM_FLAG_CONTRACTS,CLOSE_FLAG_CONTRACTS,CLOSE_MANY_FLAG_CONTRACTS,CLOSE_TASK_FLAG_CONTRACTS,COMMENTS_FLAG_CONTRACTS,COMPLETION_FLAG_CONTRACTS,CONFIG_FLAG_CONTRACTS,CONTEXT_FLAG_CONTRACTS,CONTRACTS_FLAG_CONTRACTS,COPY_FLAG_CONTRACTS,CREATE_FLAG_CONTRACTS,DELETE_FLAG_CONTRACTS,DEPS_FLAG_CONTRACTS,DOCS_FLAG_CONTRACTS,DUPLICATES_FLAG_CONTRACTS,EVAL_FLAG_CONTRACTS,EVENTS_FLAG_CONTRACTS,EVENT_FLAG_CONTRACTS,EXTENSION_ACTIVATE_FLAG_CONTRACTS,EXTENSION_ADOPT_ALL_FLAG_CONTRACTS,EXTENSION_ADOPT_FLAG_CONTRACTS,EXTENSION_CATALOG_FLAG_CONTRACTS,EXTENSION_DEACTIVATE_FLAG_CONTRACTS,EXTENSION_DESCRIBE_FLAG_CONTRACTS,EXTENSION_DOCTOR_FLAG_CONTRACTS,EXTENSION_EXPLORE_FLAG_CONTRACTS,EXTENSION_FLAG_CONTRACTS,EXTENSION_INIT_FLAG_CONTRACTS,EXTENSION_INSTALL_FLAG_CONTRACTS,EXTENSION_MANAGE_FLAG_CONTRACTS,EXTENSION_MIGRATE_FLAG_CONTRACTS,EXTENSION_RELOAD_FLAG_CONTRACTS,EXTENSION_SCOPE_FLAG_CONTRACTS,EXTENSION_UNINSTALL_FLAG_CONTRACTS,FILES_FLAG_CONTRACTS,FOCUS_FLAG_CONTRACTS,GC_FLAG_CONTRACTS,GET_FLAG_CONTRACTS,GLOBAL_FLAG_CONTRACTS,GRAPH_FLAG_CONTRACTS,GUIDE_FLAG_CONTRACTS,HEALTH_FLAG_CONTRACTS,HISTORY_ATTEST_FLAG_CONTRACTS,HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS,HISTORY_COMPACT_FLAG_CONTRACTS,HISTORY_FLAG_CONTRACTS,HISTORY_REDACT_FLAG_CONTRACTS,HISTORY_REPAIR_FLAG_CONTRACTS,INIT_FLAG_CONTRACTS,INSTALL_FLAG_CONTRACTS,ITEM_COMPLETE_FLAG_CONTRACTS,ITEM_MUTATE_FLAG_CONTRACTS,ITEM_REOPEN_FLAG_CONTRACTS,LEARNINGS_FLAG_CONTRACTS,LIST_FILTER_FLAG_CONTRACTS,MEET_FLAG_CONTRACTS,MERGE_FLAG_CONTRACTS,NEXT_FLAG_CONTRACTS,NOTES_FLAG_CONTRACTS,PACKAGE_FLAG_CONTRACTS,PACKAGE_INIT_FLAG_CONTRACTS,PAUSE_TASK_FLAG_CONTRACTS,PLAN_FLAG_CONTRACTS,PM_POSITIONAL_ACTION_FLAG_CONTRACTS,PROFILE_FLAG_CONTRACTS,REINDEX_FLAG_CONTRACTS,RELEASE_FLAG_CONTRACTS,REMIND_FLAG_CONTRACTS,RESTORE_FLAG_CONTRACTS,SCHEMA_FLAG_CONTRACTS,SEARCH_FLAG_CONTRACTS,START_TASK_FLAG_CONTRACTS,STATS_FLAG_CONTRACTS,SUBCOMMAND_GLOBAL_FLAG_CONTRACTS,TELEMETRY_FLAG_CONTRACTS,TEST_ALL_FLAG_CONTRACTS,TEST_FLAG_CONTRACTS,TEST_RUNS_FLAG_CONTRACTS,UPDATE_FLAG_CONTRACTS,UPDATE_MANY_FLAG_CONTRACTS,UPGRADE_FLAG_CONTRACTS,VALIDATE_FLAG_CONTRACTS,WORKSPACE_FLAG_CONTRACTS,WORKSPACE_POSITION_FLAG_CONTRACTS,compactFlagAliasContracts,hasSubcommandFlagContractsForCommand,resolvePmPositionalActionFlagContracts,resolveSubcommandFlagContractsForCommand,toCompletionFlagString,toUniqueFlagContracts,withFlagAliasMetadata};
2
2
  //# sourceMappingURL=flag-contracts.js.map
@@ -4,6 +4,7 @@
4
4
  * Exposes command and action contract data without loading SDK runtime code.
5
5
  */
6
6
  export * from "./cli-contracts.js";
7
+ export * from "./graph/query-contracts.js";
7
8
  export * from "./cli-contracts/grammar-contracts.js";
8
9
  export * from "./cli-contracts/command-exit-contracts.js";
9
10
  export * from "./context-intent-contracts.js";
@@ -1,2 +1,2 @@
1
- !(function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3aa255ff-062b-5d25-9589-20b2911e86f9")}catch(e2){}})();export*from"./cli-contracts.js";export*from"./cli-contracts/grammar-contracts.js";export*from"./cli-contracts/command-exit-contracts.js";export*from"./context-intent-contracts.js";export*from"./error-code-catalog.js";export*from"./generated-error-code-catalog.js";export*from"./flag-invocation-contracts.js";export*from"./cli-contracts/flag-lexicon-contracts.js";export*from"./output-token-accounting.js";export*from"./output-contracts.js";export*from"./agent/task-transcript-contracts.js";export*from"./read-output-contracts.js";export*from"./history/attestation-contract.js";export*from"../core/history/operation-contract.js";export*from"./agent/refusal-closure.js";export*from"./agent/closed-domain-contracts.js";export*from"./agent/tracker-preflight-contracts.js";
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]="0aafe4f4-d636-597e-b594-c0a32ebced38")}catch(e2){}})();export*from"./cli-contracts.js";export*from"./graph/query-contracts.js";export*from"./cli-contracts/grammar-contracts.js";export*from"./cli-contracts/command-exit-contracts.js";export*from"./context-intent-contracts.js";export*from"./error-code-catalog.js";export*from"./generated-error-code-catalog.js";export*from"./flag-invocation-contracts.js";export*from"./cli-contracts/flag-lexicon-contracts.js";export*from"./output-token-accounting.js";export*from"./output-contracts.js";export*from"./agent/task-transcript-contracts.js";export*from"./read-output-contracts.js";export*from"./history/attestation-contract.js";export*from"../core/history/operation-contract.js";export*from"./agent/refusal-closure.js";export*from"./agent/closed-domain-contracts.js";export*from"./agent/tracker-preflight-contracts.js";
2
2
  //# sourceMappingURL=contracts.js.map
@@ -32,5 +32,5 @@ export declare const resolveCanonicalExtensionInstallDestination: (destinationDi
32
32
  export declare const copyExtensionDirectoryWithoutSelfNesting: (sourceDirectory: string, destinationDirectory: string, copyDirectory: typeof fs.cp, temporaryDirectory?: string) => Promise<void>;
33
33
  /** Copy one extension directory with bounded transient-race retries. */
34
34
  export declare const copyExtensionDirectoryForInstall: (sourceDirectory: string, destinationDirectory: string, copyDirectory?: typeof fs.cp) => Promise<void>;
35
- /** Run one operation under an owner-bound extension install lock and heartbeat lease. */
35
+ /** Hold an owner-bound install lease and translate host faults from acquisition through operation and cleanup. */
36
36
  export declare const withExtensionInstallLock: <T>(settingsRoot: string, destinationDirectoryName: string, run: () => Promise<T>, options?: ExtensionInstallLockOptions) => Promise<T>;