@unbrained/pm-cli 2026.8.13 → 2026.8.14

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 (136) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +141 -112
  3. package/dist/cli/main.js +39 -3
  4. package/dist/cli-bundle/bundle-manifest.json +144 -176
  5. package/dist/cli-bundle/chunks/{chunk-DEDU3DG7.js → chunk-BBOFSVAK.js} +66 -65
  6. package/dist/cli-bundle/chunks/chunk-BFALV3YP.js +5 -0
  7. package/dist/cli-bundle/chunks/{chunk-Q47C67TQ.js → chunk-FIW4P64F.js} +2 -2
  8. package/dist/cli-bundle/chunks/{chunk-QGTUPEU5.js → chunk-G5JUB66K.js} +41 -41
  9. package/dist/cli-bundle/chunks/{chunk-3ZMOWAFM.js → chunk-SBRKH6OR.js} +2 -2
  10. package/dist/cli-bundle/chunks/chunk-TMJ7URWS.js +13 -0
  11. package/dist/cli-bundle/chunks/{chunk-F7FJYGK3.js → chunk-TXMEUUUY.js} +2 -2
  12. package/dist/cli-bundle/chunks/{chunk-YLBAPY22.js → chunk-XAVMOK6B.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-TF3TPKPR.js → chunk-YAMTJL6Y.js} +33 -33
  14. package/dist/cli-bundle/chunks/{chunk-IMGIN7R6.js → chunk-YSVSMJ2B.js} +2 -2
  15. package/dist/cli-bundle/chunks/{register-list-query-4HIZ7EA3.js → register-list-query-T3EHHNNV.js} +2 -2
  16. package/dist/cli-bundle/chunks/{register-mutation-W64FZ5HN.js → register-mutation-E27WCLSZ.js} +2 -2
  17. package/dist/cli-bundle/chunks/{register-operations-C44ET7R5.js → register-operations-4R6I7CPY.js} +2 -2
  18. package/dist/cli-bundle/chunks/{register-setup-634MFRXU.js → register-setup-3YXZ444E.js} +2 -2
  19. package/dist/cli-bundle/focused-chunks/{chunk-OOYYKQWX.js → chunk-4DQ2YERC.js} +2 -2
  20. package/dist/cli-bundle/focused-chunks/chunk-F43TT2QQ.js +8 -0
  21. package/dist/cli-bundle/focused-chunks/{chunk-2RI2FESN.js → chunk-K7RWWOAG.js} +2 -2
  22. package/dist/cli-bundle/focused-chunks/chunk-KFSZ3BP6.js +16 -0
  23. package/dist/cli-bundle/focused-chunks/{chunk-3DJSGWVB.js → chunk-KSEDUWVZ.js} +2 -2
  24. package/dist/cli-bundle/focused-chunks/{chunk-NFHFZH2Z.js → chunk-KYUQGTSB.js} +2 -2
  25. package/dist/cli-bundle/focused-chunks/{chunk-IIS2FRKL.js → chunk-LZ4MV3RH.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/chunk-PGXJQLCT.js +155 -0
  27. package/dist/cli-bundle/focused-chunks/{chunk-E3AVJ655.js → chunk-PPFGQDSI.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/chunk-Q4YY3XNF.js +2 -0
  29. package/dist/cli-bundle/focused-chunks/chunk-QK753U3U.js +46 -0
  30. package/dist/cli-bundle/focused-chunks/{chunk-QDZUABWL.js → chunk-QUMB2J27.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/chunk-SM7MTG27.js +2 -0
  32. package/dist/cli-bundle/focused-chunks/{chunk-I75MANL7.js → chunk-WCVE2NIG.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/chunk-XDNAW5OI.js +18 -0
  34. package/dist/cli-bundle/focused-chunks/{chunk-2JP7W7GO.js → chunk-YOOI3UZX.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/chunk-ZM6TZVHC.js +2 -0
  36. package/dist/cli-bundle/main.js +13 -13
  37. package/dist/cli-bundle/sdk-authoring.js +1 -1
  38. package/dist/cli-bundle/sdk-contracts.js +1 -1
  39. package/dist/cli-bundle/sdk-core.js +44 -41
  40. package/dist/cli-bundle/sdk-governance.js +1 -1
  41. package/dist/cli-bundle/sdk-graph.js +1 -1
  42. package/dist/cli-bundle/sdk-merge.js +109 -1
  43. package/dist/cli-bundle/sdk-query.js +1 -1
  44. package/dist/cli-bundle/sdk-runtime.js +1 -1
  45. package/dist/cli-bundle/sdk-testing.js +1 -1
  46. package/dist/cli-bundle/sdk.js +2 -2
  47. package/dist/core/history/drift-scan.d.ts +6 -0
  48. package/dist/core/history/drift-scan.js +74 -50
  49. package/dist/core/history/workspace-history.d.ts +59 -0
  50. package/dist/core/history/workspace-history.js +197 -10
  51. package/dist/core/output/output.js +12 -4
  52. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +6 -1
  53. package/dist/sdk/cli-contracts/runtime-contracts.js +155 -60
  54. package/dist/sdk/cli-program.js +3 -3
  55. package/dist/sdk/context-relevance.js +12 -4
  56. package/dist/sdk/governance/assurance.js +4 -4
  57. package/dist/sdk/governance/health.js +15 -3
  58. package/dist/sdk/governance/validate-history-drift.d.ts +7 -0
  59. package/dist/sdk/governance/validate-history-drift.js +68 -0
  60. package/dist/sdk/governance/validate.js +4 -46
  61. package/dist/sdk/graph/assembly.d.ts +23 -0
  62. package/dist/sdk/graph/assembly.js +54 -2
  63. package/dist/sdk/graph/durable-cache.js +50 -20
  64. package/dist/sdk/graph/governance-contracts.d.ts +1 -1
  65. package/dist/sdk/graph/governance-contracts.js +4 -2
  66. package/dist/sdk/graph/governance.d.ts +21 -1
  67. package/dist/sdk/graph/governance.js +94 -32
  68. package/dist/sdk/graph/index.d.ts +2 -2
  69. package/dist/sdk/graph/index.js +4 -4
  70. package/dist/sdk/graph/mutation-advisory.js +15 -7
  71. package/dist/sdk/graph/remediation.js +12 -2
  72. package/dist/sdk/history-read.d.ts +8 -0
  73. package/dist/sdk/history-read.js +2 -2
  74. package/dist/sdk/index.d.ts +1 -1
  75. package/dist/sdk/index.js +3 -3
  76. package/dist/sdk/query/history.js +20 -3
  77. package/dist/sdk/read-output-budget.d.ts +2 -0
  78. package/dist/sdk/read-output-budget.js +12 -5
  79. package/dist/sdk/read-output-contracts.d.ts +61 -5
  80. package/dist/sdk/read-output-contracts.js +210 -28
  81. package/dist/sdk/read-output-rows.d.ts +11 -0
  82. package/dist/sdk/read-output-rows.js +47 -2
  83. package/dist/sdk/runtime-primitives.d.ts +1 -1
  84. package/dist/sdk/runtime-primitives.js +3 -3
  85. package/dist/sdk/runtime.js +5 -3
  86. package/docs/ASSURANCE.md +10 -1
  87. package/docs/COMMANDS.md +31 -2
  88. package/docs/READ_OUTPUT_CONTRACTS.md +44 -8
  89. package/docs/RELATIONSHIP_GRAPH.md +20 -5
  90. package/docs/SDK.md +12 -5
  91. package/docs/SDK_CONTEXT_INTEGRITY.md +32 -1
  92. package/docs/TESTING.md +23 -1
  93. package/docs/performance/sdk-entrypoint-import-costs.md +20 -13
  94. package/marketplace.json +2 -2
  95. package/package.json +6 -6
  96. package/packages/pm-beads/extensions/beads/index.ts +1 -0
  97. package/packages/pm-beads/package.json +1 -1
  98. package/packages/pm-calendar/extensions/calendar/index.ts +1 -0
  99. package/packages/pm-calendar/package.json +1 -1
  100. package/packages/pm-command-kit/package.json +1 -1
  101. package/packages/pm-digital-twin/extensions/digital-twin/index.ts +7 -0
  102. package/packages/pm-digital-twin/package.json +1 -1
  103. package/packages/pm-governance-audit/extensions/governance-audit/index.ts +4 -0
  104. package/packages/pm-governance-audit/package.json +1 -1
  105. package/packages/pm-guide-shell/extensions/guide-shell/index.ts +5 -0
  106. package/packages/pm-guide-shell/package.json +1 -1
  107. package/packages/pm-kanban/package.json +1 -1
  108. package/packages/pm-lifecycle-hooks/package.json +1 -1
  109. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/index.ts +6 -0
  110. package/packages/pm-linked-test-adapters/package.json +1 -1
  111. package/packages/pm-search-advanced/extensions/search-advanced/index.ts +2 -0
  112. package/packages/pm-search-advanced/package.json +1 -1
  113. package/packages/pm-templates/extensions/templates/index.ts +4 -0
  114. package/packages/pm-templates/package.json +1 -1
  115. package/packages/pm-todos/extensions/todos/index.ts +2 -0
  116. package/packages/pm-todos/package.json +1 -1
  117. package/packages/pm-vcs/extensions/vcs/index.ts +7 -0
  118. package/packages/pm-vcs/package.json +1 -1
  119. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  120. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  121. package/scripts/bundle-cli.mjs +17 -4
  122. package/sdk/public-surface.json +209 -29
  123. package/dist/cli-bundle/chunks/chunk-DL5M5J3V.js +0 -13
  124. package/dist/cli-bundle/chunks/chunk-HIUZVCMN.js +0 -5
  125. package/dist/cli-bundle/focused-chunks/chunk-27N23W6M.js +0 -31
  126. package/dist/cli-bundle/focused-chunks/chunk-3BNVU6LC.js +0 -8
  127. package/dist/cli-bundle/focused-chunks/chunk-6MLIRBLV.js +0 -5
  128. package/dist/cli-bundle/focused-chunks/chunk-6XYLENDV.js +0 -155
  129. package/dist/cli-bundle/focused-chunks/chunk-CP4K4WFS.js +0 -2
  130. package/dist/cli-bundle/focused-chunks/chunk-EBTNSFYE.js +0 -2
  131. package/dist/cli-bundle/focused-chunks/chunk-HC2OL2H2.js +0 -2
  132. package/dist/cli-bundle/focused-chunks/chunk-OGC4XSBC.js +0 -17
  133. package/dist/cli-bundle/focused-chunks/chunk-PKPOZXLL.js +0 -2
  134. package/dist/cli-bundle/focused-chunks/chunk-QQX5TDFT.js +0 -16
  135. package/dist/cli-bundle/focused-chunks/chunk-TEZIXMTH.js +0 -2
  136. package/dist/cli-bundle/focused-chunks/chunk-WEH6NSL6.js +0 -18
@@ -4,7 +4,7 @@
4
4
  * Implements the pm contracts command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="651d4904-cae5-503b-8418-93bc44a413ad")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c0995490-5838-5c91-af77-9ce387e41a1f")}catch(e){}}();
8
8
  import { EXIT_CODE, SETTINGS_DEFAULTS, PmCliError, activateExtensions, getActiveExtensionRegistrations, loadExtensions, pathExists, commandOptionFlagLabel, resolveCommandOptionPolicyState, resolveItemTypeRegistry, resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, getSettingsPath, resolvePmRoot, readSettings, } from "../runtime-primitives.js";
9
9
  import { buildMcpToolContracts, } from "../../mcp/tool-definitions.js";
10
10
  import { ACTIVITY_COMMANDER_STRING_OPTION_CONTRACTS, ACTIVITY_FLAG_CONTRACTS, AGGREGATE_FLAG_CONTRACTS, ASSURANCE_FLAG_CONTRACTS, APPEND_FLAG_CONTRACTS, CALENDAR_COMMANDER_STRING_OPTION_CONTRACTS, CALENDAR_FLAG_CONTRACTS, CLAIM_FLAG_CONTRACTS, CLOSE_TASK_FLAG_CONTRACTS, COMMENTS_FLAG_CONTRACTS, CLOSE_FLAG_CONTRACTS, CLOSE_MANY_FLAG_CONTRACTS, COMPLETION_FLAG_CONTRACTS, CONFIG_FLAG_CONTRACTS, CONTRACTS_FLAG_CONTRACTS, COPY_FLAG_CONTRACTS, CONTEXT_COMMANDER_STRING_OPTION_CONTRACTS, CONTEXT_FLAG_CONTRACTS, CREATE_COMMANDER_REPEATABLE_OPTION_CONTRACTS, CREATE_COMMANDER_STRING_OPTION_CONTRACTS, CREATE_FLAG_CONTRACTS, DELETE_FLAG_CONTRACTS, DEPS_FLAG_CONTRACTS, GRAPH_FLAG_CONTRACTS, DOCS_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_UNINSTALL_FLAG_CONTRACTS, FILES_FLAG_CONTRACTS, FOCUS_FLAG_CONTRACTS, GC_FLAG_CONTRACTS, GET_FLAG_CONTRACTS, GUIDE_FLAG_CONTRACTS, GLOBAL_FLAG_CONTRACTS, HEALTH_FLAG_CONTRACTS, HISTORY_FLAG_CONTRACTS, HISTORY_COMPACT_FLAG_CONTRACTS, HISTORY_REDACT_FLAG_CONTRACTS, HISTORY_REPAIR_FLAG_CONTRACTS, HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS, INSTALL_FLAG_CONTRACTS, INIT_FLAG_CONTRACTS, ITEM_COMPLETE_FLAG_CONTRACTS, ITEM_MUTATE_FLAG_CONTRACTS, LEARNINGS_FLAG_CONTRACTS, LIST_COMMANDER_STRING_OPTION_CONTRACTS, LIST_FILTER_FLAG_CONTRACTS, MERGE_FLAG_CONTRACTS, NOTES_FLAG_CONTRACTS, PACKAGE_FLAG_CONTRACTS, PACKAGE_INIT_FLAG_CONTRACTS, PM_EXTENSION_CAPABILITY_CONTRACTS, PM_EXTENSION_POLICY_MODE_CONTRACTS, PM_EXTENSION_POLICY_SURFACE_CONTRACTS, PM_EXTENSION_SANDBOX_PROFILE_CONTRACTS, PM_EXTENSION_SERVICE_NAME_CONTRACTS, PM_EXTENSION_TRUST_MODE_CONTRACTS, PM_OUTPUT_DEGRADATION_STEPS, PLAN_FLAG_CONTRACTS, PM_CORE_COMMAND_NAMES, PM_TOOL_ACTIONS, PM_TOOL_PARAMETERS_SCHEMA, REINDEX_FLAG_CONTRACTS, RELEASE_FLAG_CONTRACTS, RESTORE_FLAG_CONTRACTS, SCHEMA_FLAG_CONTRACTS, PROFILE_FLAG_CONTRACTS, SEARCH_COMMANDER_STRING_OPTION_CONTRACTS, EVAL_FLAG_CONTRACTS, WORKSPACE_FLAG_CONTRACTS, NEXT_FLAG_CONTRACTS, SEARCH_FLAG_CONTRACTS, STATS_FLAG_CONTRACTS, DUPLICATES_FLAG_CONTRACTS, START_TASK_FLAG_CONTRACTS, PAUSE_TASK_FLAG_CONTRACTS, TELEMETRY_FLAG_CONTRACTS, TEST_ALL_FLAG_CONTRACTS, TEST_FLAG_CONTRACTS, TEST_RUNS_FLAG_CONTRACTS, UPDATE_COMMANDER_REPEATABLE_OPTION_CONTRACTS, UPDATE_COMMANDER_STRING_OPTION_CONTRACTS, UPDATE_FLAG_CONTRACTS, UPDATE_MANY_FLAG_CONTRACTS, UPGRADE_FLAG_CONTRACTS, VALIDATE_FLAG_CONTRACTS, compactFlagAliasContracts, resolvePmCommandOutputBudget, } from "../cli-contracts.js";
@@ -224,19 +224,33 @@ const COMMAND_INTENTS = new Map([
224
224
  ["activity", "Read activity."],
225
225
  ["aggregate", "Group counts."],
226
226
  ["append", "Append body."],
227
+ ["assurance", "Evaluate assurance."],
228
+ ["beads", "Manage Beads interoperability."],
229
+ ["cal", "Manage calendar integration."],
230
+ ["calendar", "Manage calendar integration."],
231
+ ["changelog", "Generate changelog output."],
227
232
  ["claim", "Claim work."],
228
233
  ["close", "Close work."],
234
+ ["close-many", "Close matching work."],
235
+ ["close-task", "Close task work."],
236
+ ["command-kit", "Inspect command authoring primitives."],
229
237
  ["comments", "Manage comments."],
238
+ ["comments-audit", "Audit comment governance."],
230
239
  ["completion", "Generate shell completions."],
231
240
  ["config", "Manage settings."],
232
241
  ["context", "Build context."],
233
242
  ["contracts", "Inspect contracts."],
234
243
  ["copy", "Copy work."],
235
244
  ["create", "Create work."],
245
+ ["dedupe-audit", "Audit duplicate work."],
246
+ ["dedupe-merge", "Merge duplicate work."],
236
247
  ["delete", "Delete work."],
237
248
  ["deps", "Manage deps."],
238
249
  ["duplicates", "Find duplicate clusters."],
239
250
  ["docs", "Link docs."],
251
+ ["eval", "Run evaluations."],
252
+ ["event", "Manage events."],
253
+ ["events", "Read events."],
240
254
  ["files", "Link files."],
241
255
  ["focus", "Manage focus."],
242
256
  ["gc", "Clean caches."],
@@ -248,26 +262,53 @@ const COMMAND_INTENTS = new Map([
248
262
  ["history", "Inspect history."],
249
263
  ["init", "Initialize workspace."],
250
264
  ["install", "Install packages."],
265
+ ["item", "Mutate work through typed operations."],
251
266
  ["learnings", "Manage learnings."],
252
267
  ["list", "List work."],
268
+ ["list-all", "List work across every status."],
269
+ ["list-blocked", "List blocked work."],
270
+ ["list-canceled", "List canceled work."],
271
+ ["list-closed", "List closed work."],
272
+ ["list-draft", "List draft work."],
273
+ ["list-in-progress", "List in-progress work."],
274
+ ["list-open", "List open work."],
275
+ ["meet", "Record meeting context."],
276
+ ["merge", "Manage tracker merges."],
253
277
  ["next", "Pick next work."],
254
278
  ["notes", "Manage notes."],
279
+ ["normalize", "Normalize tracker data."],
255
280
  ["ops", "Run operations."],
256
281
  ["package", "Manage packages."],
282
+ ["packages", "Manage packages."],
283
+ ["pause-task", "Pause task work."],
257
284
  ["plan", "Manage plans."],
258
285
  ["profile", "Manage profiles."],
259
286
  ["reindex", "Refresh search index."],
260
287
  ["release", "Release claim."],
288
+ ["remind", "Manage reminders."],
261
289
  ["restore", "Restore history."],
262
290
  ["schema", "Customize schema."],
263
291
  ["search", "Search work."],
292
+ ["search-advanced", "Run advanced search."],
293
+ ["start-task", "Start task work."],
264
294
  ["stats", "Show stats."],
265
295
  ["telemetry", "Manage telemetry."],
296
+ ["templates", "Manage work templates."],
266
297
  ["test", "Run linked tests."],
298
+ ["test-all", "Run all linked tests."],
299
+ ["test-runs", "Inspect background test runs."],
300
+ ["todos", "Manage source-code todos."],
301
+ ["twin", "Manage repository twins."],
267
302
  ["update", "Update work."],
303
+ ["update-many", "Update matching work."],
268
304
  ["upgrade", "Upgrade packages."],
269
305
  ["validate", "Validate data."],
306
+ ["vcs", "Inspect version-control context."],
270
307
  ["workspace", "Manage portable workspace primitives."],
308
+ ["history-author-acknowledge", "Acknowledge reviewed history authors."],
309
+ ["history-compact", "Compact history."],
310
+ ["history-redact", "Redact sensitive history values."],
311
+ ["history-repair", "Repair history integrity."],
271
312
  ]);
272
313
  // Lifecycle subcommand flag contracts for `pm extension`. Only `init` differs
273
314
  // between extension and package: `pm package init` / `pm packages init`
@@ -701,29 +742,29 @@ function collectExtensionCommandContracts(runtimeProbe) {
701
742
  const contracts = [];
702
743
  for (const command of [...extensionCommands].sort((left, right) => left.localeCompare(right))) {
703
744
  const definition = definitionsByCommand.get(command);
704
- if (definition) {
705
- contracts.push({
706
- ...definition,
707
- flags: definition.flags.length > 0
708
- ? definition.flags
709
- : (flagsByCommand.get(command)?.flags ?? []),
710
- });
711
- continue;
712
- }
713
- contracts.push({
714
- command,
715
- action: normalizeActionNameFromCommand(command),
716
- source: null,
717
- description: null,
718
- intent: null,
719
- arguments: [],
720
- flags: flagsByCommand.get(command)?.flags ?? [],
721
- examples: [],
722
- failure_hints: [],
723
- });
745
+ contracts.push(buildCollectedExtensionCommandContract(command, definition, flagsByCommand.get(command)?.flags ?? []));
724
746
  }
725
747
  return contracts;
726
748
  }
749
+ function buildCollectedExtensionCommandContract(command, definition, registeredFlags) {
750
+ if (definition) {
751
+ return {
752
+ ...definition,
753
+ flags: definition.flags.length > 0 ? definition.flags : registeredFlags,
754
+ };
755
+ }
756
+ return {
757
+ command,
758
+ action: normalizeActionNameFromCommand(command),
759
+ source: null,
760
+ description: null,
761
+ intent: null,
762
+ arguments: [],
763
+ flags: registeredFlags,
764
+ examples: [],
765
+ failure_hints: [],
766
+ };
767
+ }
727
768
  function extensionSchemaPropertyNameFromFlag(flag) {
728
769
  const normalized = flag.flag.replace(/^-+/, "").trim();
729
770
  if (normalized.length === 0) {
@@ -1564,55 +1605,109 @@ function resolveContractsCommands(selection, actionContext) {
1564
1605
  function resolveOutputCommands(_selection, commands) {
1565
1606
  return commands;
1566
1607
  }
1567
- function summarizeCommandIntent(command) {
1568
- const rootCommand = command.split(" ")[0];
1569
- return (COMMAND_INTENTS.get(command) ??
1570
- COMMAND_INTENTS.get(rootCommand) ??
1571
- "Inspect flags.");
1572
- }
1573
1608
  function canonicalSummaryCommand(command) {
1574
1609
  const rootCommand = command.split(" ")[0];
1575
- if (rootCommand.startsWith("list-")) {
1610
+ if (rootCommand.startsWith("list-"))
1576
1611
  return "list";
1577
- }
1578
- if (rootCommand.startsWith("history-")) {
1612
+ if (rootCommand.startsWith("history-"))
1579
1613
  return "history";
1580
- }
1581
- if (rootCommand === "ctx") {
1582
- return "context";
1583
- }
1584
- if (rootCommand === "packages") {
1585
- return "package";
1586
- }
1587
1614
  return COMMAND_ALIAS_TO_CANONICAL.get(rootCommand) ?? rootCommand;
1588
1615
  }
1589
- function buildCommandSummarySurface(commands) {
1590
- const rootsByCanonical = new Map();
1591
- for (const command of commands) {
1592
- const root = command.split(" ")[0];
1593
- const canonical = canonicalSummaryCommand(root);
1594
- const roots = rootsByCanonical.get(canonical) ?? new Set();
1595
- roots.add(root);
1596
- rootsByCanonical.set(canonical, roots);
1616
+ const COMMAND_OPERATION_INTENTS = new Map([
1617
+ ["activate", "Activate"],
1618
+ ["adopt", "Adopt"],
1619
+ ["adopt-all", "Adopt all"],
1620
+ ["catalog", "Catalog"],
1621
+ ["complete", "Complete"],
1622
+ ["create", "Create"],
1623
+ ["deactivate", "Deactivate"],
1624
+ ["delete", "Delete"],
1625
+ ["describe", "Describe"],
1626
+ ["doctor", "Diagnose"],
1627
+ ["explore", "Explore"],
1628
+ ["init", "Initialize"],
1629
+ ["inspect", "Inspect"],
1630
+ ["install", "Install"],
1631
+ ["list", "List"],
1632
+ ["manage", "Manage"],
1633
+ ["migrate", "Migrate"],
1634
+ ["mutate", "Mutate"],
1635
+ ["reload", "Reload"],
1636
+ ["restore", "Restore"],
1637
+ ["run", "Run"],
1638
+ ["snapshot", "Manage snapshots for"],
1639
+ ["uninstall", "Uninstall"],
1640
+ ]);
1641
+ const COMMAND_INTENT_SUBJECT_OVERRIDES = new Map([
1642
+ ["extension adopt-all", "extensions"],
1643
+ ["package adopt-all", "packages"],
1644
+ ["workspace snapshot list", "workspace snapshots"],
1645
+ ]);
1646
+ function summarizeCommandIntent(command, extensionContracts) {
1647
+ const declared = COMMAND_INTENTS.get(command) ??
1648
+ (command.includes(" ")
1649
+ ? undefined
1650
+ : COMMAND_INTENTS.get(canonicalSummaryCommand(command)));
1651
+ if (declared !== undefined) {
1652
+ return { intent: declared, intent_source: "command" };
1653
+ }
1654
+ const extensionContract = extensionContracts.find((contract) => splitCommandPathAliases(contract.command).includes(command));
1655
+ if (extensionContract?.intent !== null &&
1656
+ extensionContract?.intent !== undefined) {
1657
+ return { intent: extensionContract.intent, intent_source: "command" };
1658
+ }
1659
+ if (extensionContract?.description !== null &&
1660
+ extensionContract?.description !== undefined) {
1661
+ return {
1662
+ intent: extensionContract.description,
1663
+ intent_source: "description",
1664
+ };
1597
1665
  }
1598
- const rootCommands = [...rootsByCanonical.keys()]
1666
+ const tokens = command.split(" ");
1667
+ const operation = tokens.at(-1);
1668
+ const subject = tokens.slice(0, -1).join(" ");
1669
+ const verb = COMMAND_OPERATION_INTENTS.get(operation);
1670
+ const intentSubject = COMMAND_INTENT_SUBJECT_OVERRIDES.get(command) ?? subject;
1671
+ return {
1672
+ intent: verb === undefined || subject.length === 0
1673
+ ? `Run ${command}.`
1674
+ : `${verb} ${intentSubject}.`,
1675
+ intent_source: "generated",
1676
+ };
1677
+ }
1678
+ function buildCommandSummarySurface(commands, extensionContracts = []) {
1679
+ return [...new Set(commands.map(normalizeCommandPath))]
1599
1680
  .filter((command) => command.length > 0)
1600
- .sort((left, right) => left.localeCompare(right));
1601
- return rootCommands.map((command) => {
1681
+ .sort((left, right) => left.localeCompare(right))
1682
+ .map((command) => {
1602
1683
  const budget = resolvePmCommandOutputBudget(command, {
1603
1684
  generateFallback: true,
1604
1685
  });
1605
- const availableFlags = new Set(resolveCoreCommandFlags(command).map((contract) => contract.flag));
1606
- const flags = (AGENT_BOOTSTRAP_FLAGS.get(command) ?? AGENT_BOUNDED_FLAG_PRIORITY).filter((flag) => availableFlags.has(flag));
1607
- const aliases = [...rootsByCanonical.get(command)]
1608
- .filter((root) => root !== command)
1609
- .sort((left, right) => left.localeCompare(right));
1686
+ const rootCommand = command.split(" ")[0];
1687
+ const canonicalRoot = COMMAND_ALIAS_TO_CANONICAL.get(rootCommand) ??
1688
+ (rootCommand.startsWith("list-")
1689
+ ? "list"
1690
+ : rootCommand.startsWith("history-")
1691
+ ? "history"
1692
+ : rootCommand);
1693
+ const availableFlags = new Set([
1694
+ ...resolveCoreCommandFlags(command).map((contract) => contract.flag),
1695
+ ...extensionContracts
1696
+ .filter((contract) => splitCommandPathAliases(contract.command).includes(command))
1697
+ .flatMap((contract) => contract.flags.map((flag) => flag.flag)),
1698
+ ]);
1699
+ const flags = (AGENT_BOOTSTRAP_FLAGS.get(command) ??
1700
+ AGENT_BOOTSTRAP_FLAGS.get(canonicalRoot) ??
1701
+ AGENT_BOUNDED_FLAG_PRIORITY).filter((flag) => availableFlags.has(flag));
1702
+ const intent = summarizeCommandIntent(command, extensionContracts);
1610
1703
  return {
1611
1704
  command,
1612
- ...(aliases.length > 0 ? { aliases } : {}),
1613
- intent: summarizeCommandIntent(command),
1705
+ ...intent,
1614
1706
  ...(flags.length > 0 ? { flags } : {}),
1615
1707
  default_max_estimated_tokens: budget.default_max_estimated_tokens,
1708
+ default_max_estimated_tokens_by_format: {
1709
+ ...budget.default_max_estimated_tokens_by_format,
1710
+ },
1616
1711
  };
1617
1712
  });
1618
1713
  }
@@ -1785,8 +1880,8 @@ function attachCommanderAliasContractsResult(result, selection) {
1785
1880
  result.commander_aliases_omitted_reason = "unfiltered_default_brief";
1786
1881
  }
1787
1882
  /** Attach the compact agent-facing command semantics shared by summary and full projections. */
1788
- function attachAgentCommandContractsResult(result, outputCommands) {
1789
- result.command_summaries = buildCommandSummarySurface(outputCommands);
1883
+ function attachAgentCommandContractsResult(result, outputCommands, extensionCommandContracts) {
1884
+ result.command_summaries = buildCommandSummarySurface(outputCommands, extensionCommandContracts);
1790
1885
  result.output_policy = {
1791
1886
  token_estimate: "ceil(utf8_bytes / 4)",
1792
1887
  degradation_ladder: [...PM_OUTPUT_DEGRADATION_STEPS],
@@ -1804,14 +1899,14 @@ export async function runContracts(options, global) {
1804
1899
  const commands = resolveContractsCommands(selection, actionContext);
1805
1900
  const outputCommands = resolveOutputCommands(selection, commands);
1806
1901
  const result = createContractsResult(selection, schemaContext, actionContext, outputCommands);
1902
+ const extensionCommandContracts = resolveExtensionCommandContracts(selection, runtime, outputCommands);
1807
1903
  if (selection.summary || selection.fullOutput) {
1808
- attachAgentCommandContractsResult(result, outputCommands);
1904
+ attachAgentCommandContractsResult(result, outputCommands, extensionCommandContracts);
1809
1905
  }
1810
1906
  if (selection.summary) {
1811
1907
  return result;
1812
1908
  }
1813
1909
  const commandAliases = buildCommandAliasSurface(commands);
1814
- const extensionCommandContracts = resolveExtensionCommandContracts(selection, runtime, outputCommands);
1815
1910
  if (!(selection.flagsOnly && !selection.fullOutput)) {
1816
1911
  attachRuntimeContractsResult(result, runtime);
1817
1912
  }
@@ -1872,4 +1967,4 @@ export const _testOnlyContractsCommand = {
1872
1967
  toRuntimeShortFlagToken,
1873
1968
  };
1874
1969
  //# sourceMappingURL=runtime-contracts.js.map
1875
- //# debugId=651d4904-cae5-503b-8418-93bc44a413ad
1970
+ //# debugId=c0995490-5838-5c91-af77-9ce387e41a1f
@@ -4,7 +4,7 @@
4
4
  * Builds the reusable Commander root that embeds pm's universal global contracts.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b799c7c2-21b8-5c19-8565-7166e6f06a90")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="304d0901-79d3-593d-a789-410e28d59948")}catch(e){}}();
8
8
  import { Command } from "commander";
9
9
  import { writeStdout } from "../core/output/output.js";
10
10
  /** Create a fresh pm root program suitable for one-shot CLI or embedded hosts. */
@@ -27,7 +27,7 @@ export function createPmCliProgram(version) {
27
27
  .option("--token-accounting", "Attach a bounded per-section token-cost receipt to command output")
28
28
  .option("--output-include <fields>", "Retain comma-separated fields or sections in read output")
29
29
  .option("--output-limit <count>", "Bound rows in read output")
30
- .option("--output-budget <tokens>", "Bound estimated tokens in read output")
30
+ .option("--output-budget <tokens|unbounded>", "Bound estimated tokens in read output or explicitly disable the default ceiling")
31
31
  .option("--output-format <toon|json>", "Select the read-output encoding")
32
32
  .option("--output-session <state>", "Carry a JSON session budget and served-item ledger across read calls")
33
33
  .option("--output-row-contract", "Include the machine-readable row selector and TOON encoding contract")
@@ -45,4 +45,4 @@ export function createPmCliProgram(version) {
45
45
  .exitOverride();
46
46
  }
47
47
  //# sourceMappingURL=cli-program.js.map
48
- //# debugId=b799c7c2-21b8-5c19-8565-7166e6f06a90
48
+ //# debugId=304d0901-79d3-593d-a789-410e28d59948
@@ -6,7 +6,7 @@
6
6
  * with core, extension, or project-specific feature stores.
7
7
  */
8
8
 
9
- !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]="1f898377-b606-5bfd-932d-6ce5f2f9c717")}catch(e){}}();
9
+ !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]="7eefe5f0-364d-559a-b365-0e7d539ee19e")}catch(e){}}();
10
10
  import { runActiveServiceOverride } from "../core/extensions/index.js";
11
11
  import { normalizeStatusForRegistry, normalizeStatusInput, } from "../core/item/status.js";
12
12
  import { compareTimestampStrings, resolveIsoOrRelative } from "../core/shared/time.js";
@@ -364,8 +364,16 @@ export async function runContextEvaluationScenario(scenario, reader) {
364
364
  throw new TypeError("Context evaluation scenarios require non-empty id and rationale values");
365
365
  }
366
366
  const result = scenario.surface === "context"
367
- ? await reader.context({ ...scenario.options, explainRanking: true })
368
- : await reader.next({ ...scenario.options, explainRanking: true });
367
+ ? await reader.context({
368
+ ...scenario.options,
369
+ explainRanking: true,
370
+ outputBudget: "unbounded",
371
+ })
372
+ : await reader.next({
373
+ ...scenario.options,
374
+ explainRanking: true,
375
+ outputBudget: "unbounded",
376
+ });
369
377
  const { rankedIds, attribution } = rankingPayloadForScenario(result, scenario.surface);
370
378
  const packet = { ...result, ranking: undefined };
371
379
  const actualTokens = estimateJsonTokens(packet);
@@ -422,4 +430,4 @@ export async function runContextEvaluationCorpus(scenarios, reader, thresholds)
422
430
  return summarizeContextEvaluationReports(reports, thresholds);
423
431
  }
424
432
  //# sourceMappingURL=context-relevance.js.map
425
- //# debugId=1f898377-b606-5bfd-932d-6ce5f2f9c717
433
+ //# debugId=7eefe5f0-364d-559a-b365-0e7d539ee19e
@@ -7,7 +7,7 @@
7
7
  * one deterministic SDK path.
8
8
  */
9
9
 
10
- !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]="e491ddd9-60e7-51fd-b0c7-4f6e86ee56f9")}catch(e){}}();
10
+ !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]="07889857-2176-5659-96f7-8f5591f4c692")}catch(e){}}();
11
11
  import { createHash } from "node:crypto";
12
12
  import path from "node:path";
13
13
  import { EXIT_CODE } from "../../core/shared/constants.js";
@@ -669,9 +669,9 @@ export async function evaluateAssuranceGate(gateId, document, context, options)
669
669
  validateAssuranceDocument(document);
670
670
  const gateDefinition = document.gates.find((entry) => entry.id === gateId);
671
671
  if (!gateDefinition)
672
- throw new TypeError(`assurance gate ${gateId} not found`);
672
+ throw new AssuranceEvaluationRefusalError(`assurance gate ${gateId} not found`);
673
673
  if (!gateDefinition.triggers.includes(options.trigger)) {
674
- throw new TypeError(`assurance gate ${gateId} does not declare trigger ${options.trigger}`);
674
+ throw new AssuranceEvaluationRefusalError(`assurance gate ${gateId} does not declare trigger ${options.trigger}`);
675
675
  }
676
676
  enforceGateProviderPolicy(gateDefinition, document, context, options.trigger);
677
677
  const assertions = await mapWithConcurrency(gateDefinition.assertion_ids, EVALUATION_CONCURRENCY, async (id) => {
@@ -940,4 +940,4 @@ export async function listAssuranceVerdicts(pmRoot, options = {}) {
940
940
  .slice(0, limit);
941
941
  }
942
942
  //# sourceMappingURL=assurance.js.map
943
- //# debugId=e491ddd9-60e7-51fd-b0c7-4f6e86ee56f9
943
+ //# debugId=07889857-2176-5659-96f7-8f5591f4c692
@@ -4,7 +4,7 @@
4
4
  * Implements the pm health command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5cee1eaa-73f3-5709-867f-a8d73081da8b")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="97fd3651-47de-5505-be2b-bc466313e91f")}catch(e){}}();
8
8
  import fs from "node:fs/promises";
9
9
  import path from "node:path";
10
10
  import { resolveItemTypeRegistry } from "../../core/item/type-registry.js";
@@ -917,6 +917,9 @@ const HEALTH_DETAIL_SUMMARIZERS = {
917
917
  unreadable_streams: summarizeStringList(details.unreadable_streams, limit),
918
918
  hash_mismatches: summarizeStringList(details.hash_mismatches, limit),
919
919
  chain_mismatches: summarizeStringList(details.chain_mismatches, limit),
920
+ workspace_state_mismatches: summarizeStringList(details.workspace_state_mismatches, limit),
921
+ workspace_state_missing: summarizeStringList(details.workspace_state_missing, limit),
922
+ workspace_state_unreadable: summarizeStringList(details.workspace_state_unreadable, limit),
920
923
  skipped: details.skipped,
921
924
  }),
922
925
  vectorization: (details, limit) => ({
@@ -1351,12 +1354,15 @@ async function buildLocksCheck(pmRoot) {
1351
1354
  }
1352
1355
  async function buildHistoryDriftCheck(pmRoot, items) {
1353
1356
  const cacheHitVerification = "metadata";
1354
- const { missingStreams, unreadableStreams, hashMismatches, chainMismatches, driftedItems, } = await scanHistoryDrift(pmRoot, items, { cacheHitVerification });
1357
+ const { missingStreams, unreadableStreams, hashMismatches, chainMismatches, driftedItems, workspaceStateMismatches, workspaceStateMissing, workspaceStateUnreadable, } = await scanHistoryDrift(pmRoot, items, { cacheHitVerification });
1355
1358
  const warnings = [
1356
1359
  ...missingStreams.map((id) => `history_drift_missing_stream:${id}`),
1357
1360
  ...unreadableStreams.map((id) => `history_drift_unreadable_stream:${id}`),
1358
1361
  ...hashMismatches.map((id) => `history_drift_hash_mismatch:${id}`),
1359
1362
  ...chainMismatches.map((id) => `history_drift_chain_mismatch:${id}`),
1363
+ ...workspaceStateMismatches.map((documentPath) => `history_drift_workspace_state_mismatch:${documentPath}`),
1364
+ ...workspaceStateMissing.map((documentPath) => `history_drift_workspace_state_missing:${documentPath}`),
1365
+ ...workspaceStateUnreadable.map((documentPath) => `history_drift_workspace_state_unreadable:${documentPath}`),
1360
1366
  ];
1361
1367
  return {
1362
1368
  check: {
@@ -1373,11 +1379,17 @@ async function buildHistoryDriftCheck(pmRoot, items) {
1373
1379
  unreadable_streams: unreadableStreams.length,
1374
1380
  hash_mismatches: hashMismatches.length,
1375
1381
  chain_mismatches: chainMismatches.length,
1382
+ workspace_state_mismatches: workspaceStateMismatches.length,
1383
+ workspace_state_missing: workspaceStateMissing.length,
1384
+ workspace_state_unreadable: workspaceStateUnreadable.length,
1376
1385
  },
1377
1386
  missing_streams: missingStreams,
1378
1387
  unreadable_streams: unreadableStreams,
1379
1388
  hash_mismatches: hashMismatches,
1380
1389
  chain_mismatches: chainMismatches,
1390
+ workspace_state_mismatches: workspaceStateMismatches,
1391
+ workspace_state_missing: workspaceStateMissing,
1392
+ workspace_state_unreadable: workspaceStateUnreadable,
1381
1393
  },
1382
1394
  },
1383
1395
  warnings,
@@ -2007,4 +2019,4 @@ export const _testOnlyHealthCommand = {
2007
2019
  warningCode,
2008
2020
  };
2009
2021
  //# sourceMappingURL=health.js.map
2010
- //# debugId=5cee1eaa-73f3-5709-867f-a8d73081da8b
2022
+ //# debugId=97fd3651-47de-5505-be2b-bc466313e91f
@@ -0,0 +1,7 @@
1
+ import type { ValidateCheck } from "./validate.js";
2
+ import type { ValidateItem } from "./validate-item-reader.js";
3
+ /** Build the validation warning and bounded evidence projection for history drift. */
4
+ export declare function buildValidateHistoryDriftCheck(pmRoot: string, items: ValidateItem[], verboseDiagnostics: boolean): Promise<{
5
+ check: ValidateCheck;
6
+ warnings: string[];
7
+ }>;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @module sdk/governance/validate-history-drift
3
+ *
4
+ * Projects append-only item and workspace singleton drift into the validation
5
+ * check contract without adding history-specific weight to the main validate
6
+ * orchestration module.
7
+ */
8
+
9
+ !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]="a1261d65-222c-5c6c-8634-a4413a91aba9")}catch(e){}}();
10
+ import { scanHistoryDrift } from "../../core/history/drift-scan.js";
11
+ const DEFAULT_DIAGNOSTIC_LIMIT = 5;
12
+ /** Build the validation warning and bounded evidence projection for history drift. */
13
+ export async function buildValidateHistoryDriftCheck(pmRoot, items, verboseDiagnostics) {
14
+ const drift = await scanHistoryDrift(pmRoot, items);
15
+ const warningCounts = [
16
+ ["validate_history_drift_missing_streams", drift.missingStreams.length],
17
+ ["validate_history_drift_unreadable_streams", drift.unreadableStreams.length],
18
+ ["validate_history_drift_hash_mismatches", drift.hashMismatches.length],
19
+ ["validate_history_drift_chain_mismatches", drift.chainMismatches.length],
20
+ [
21
+ "validate_history_drift_workspace_state_mismatches",
22
+ drift.workspaceStateMismatches.length,
23
+ ],
24
+ [
25
+ "validate_history_drift_workspace_state_missing",
26
+ drift.workspaceStateMissing.length,
27
+ ],
28
+ [
29
+ "validate_history_drift_workspace_state_unreadable",
30
+ drift.workspaceStateUnreadable.length,
31
+ ],
32
+ ];
33
+ const warnings = warningCounts
34
+ .filter(([, count]) => count > 0)
35
+ .map(([code, count]) => `${code}:${count}`);
36
+ const diagnosticLimit = verboseDiagnostics
37
+ ? Number.POSITIVE_INFINITY
38
+ : DEFAULT_DIAGNOSTIC_LIMIT;
39
+ const driftedItems = drift.driftedItems.slice(0, diagnosticLimit);
40
+ return {
41
+ check: {
42
+ name: "history_drift",
43
+ status: warnings.length === 0 ? "ok" : "warn",
44
+ ok: warnings.length === 0,
45
+ details: {
46
+ checked_items: items.length,
47
+ drifted_items_count: drift.driftedItems.length,
48
+ drifted_items: driftedItems,
49
+ drifted_items_truncated: driftedItems.length < drift.driftedItems.length,
50
+ counts: {
51
+ missing_streams: drift.missingStreams.length,
52
+ unreadable_streams: drift.unreadableStreams.length,
53
+ hash_mismatches: drift.hashMismatches.length,
54
+ chain_mismatches: drift.chainMismatches.length,
55
+ workspace_state_mismatches: drift.workspaceStateMismatches.length,
56
+ workspace_state_missing: drift.workspaceStateMissing.length,
57
+ workspace_state_unreadable: drift.workspaceStateUnreadable.length,
58
+ },
59
+ workspace_state_mismatches: drift.workspaceStateMismatches,
60
+ workspace_state_missing: drift.workspaceStateMissing,
61
+ workspace_state_unreadable: drift.workspaceStateUnreadable,
62
+ },
63
+ },
64
+ warnings,
65
+ };
66
+ }
67
+ //# sourceMappingURL=validate-history-drift.js.map
68
+ //# debugId=a1261d65-222c-5c6c-8634-a4413a91aba9
@@ -4,7 +4,7 @@
4
4
  * Implements the pm validate command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7dd04a2f-1798-5c16-8740-5b7094f81cc0")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7b47a375-e72c-5108-bd93-75dd8cf93218")}catch(e){}}();
8
8
  import fs from "node:fs/promises";
9
9
  import { realpathSync } from "node:fs";
10
10
  import { execFile } from "node:child_process";
@@ -14,7 +14,6 @@ import { buildRemediationCommands } from "../../core/diagnostics/remediation.js"
14
14
  import { getActiveExtensionRegistrations } from "../../core/extensions/index.js";
15
15
  import { collectRegisteredItemFieldNames } from "../../core/extensions/item-fields.js";
16
16
  import { isFileMissingError, pathExists } from "../../core/fs/fs-utils.js";
17
- import { scanHistoryDrift } from "../../core/history/drift-scan.js";
18
17
  import { normalizeStatusInput } from "../../core/item/status.js";
19
18
  import { resolveItemTypeRegistry } from "../../core/item/type-registry.js";
20
19
  import { resolveRuntimeStatusRegistry, } from "../../core/schema/runtime-schema.js";
@@ -43,6 +42,7 @@ import { runDocs } from "../docs.js";
43
42
  import { runFiles } from "../files.js";
44
43
  import { extractReferencedPmItemIdsFromCommand } from "../test/linked-command-detection.js";
45
44
  import { readValidateItems, } from "./validate-item-reader.js";
45
+ import { buildValidateHistoryDriftCheck } from "./validate-history-drift.js";
46
46
  const FILE_SCAN_DIRECTORIES = ["src", "tests", "docs"];
47
47
  const FILE_SCAN_ROOT_FILES = [
48
48
  "README.md",
@@ -1767,48 +1767,6 @@ async function buildFilesCheck(items, workspaceRoot, pmRoot, fileScanMode, inclu
1767
1767
  };
1768
1768
  }
1769
1769
  /* c8 ignore stop */
1770
- /* c8 ignore start -- history-drift warning/count projection permutations are covered by drift integration tests */
1771
- async function buildHistoryDriftCheck(pmRoot, items, verboseDiagnostics) {
1772
- const { missingStreams, unreadableStreams, hashMismatches, chainMismatches, driftedItems, } = await scanHistoryDrift(pmRoot, items);
1773
- const warnings = [];
1774
- if (missingStreams.length > 0) {
1775
- warnings.push(`validate_history_drift_missing_streams:${missingStreams.length}`);
1776
- }
1777
- if (unreadableStreams.length > 0) {
1778
- warnings.push(`validate_history_drift_unreadable_streams:${unreadableStreams.length}`);
1779
- }
1780
- if (hashMismatches.length > 0) {
1781
- warnings.push(`validate_history_drift_hash_mismatches:${hashMismatches.length}`);
1782
- }
1783
- if (chainMismatches.length > 0) {
1784
- warnings.push(`validate_history_drift_chain_mismatches:${chainMismatches.length}`);
1785
- }
1786
- const diagnosticLimit = verboseDiagnostics
1787
- ? Number.POSITIVE_INFINITY
1788
- : DIAGNOSTIC_LIST_SUMMARY_LIMIT;
1789
- const summarizedDrifted = summarizeList(driftedItems, diagnosticLimit);
1790
- return {
1791
- check: {
1792
- name: "history_drift",
1793
- status: warnings.length === 0 ? "ok" : "warn",
1794
- ok: warnings.length === 0,
1795
- details: {
1796
- checked_items: items.length,
1797
- drifted_items_count: driftedItems.length,
1798
- drifted_items: summarizedDrifted.values,
1799
- drifted_items_truncated: summarizedDrifted.truncated,
1800
- counts: {
1801
- missing_streams: missingStreams.length,
1802
- unreadable_streams: unreadableStreams.length,
1803
- hash_mismatches: hashMismatches.length,
1804
- chain_mismatches: chainMismatches.length,
1805
- },
1806
- },
1807
- },
1808
- warnings,
1809
- };
1810
- }
1811
- /* c8 ignore stop */
1812
1770
  /* c8 ignore start -- command preview truncation formatting is covered by command-reference integration fixtures */
1813
1771
  function summarizeCommandReferenceRow(ownerId, referencedId, command) {
1814
1772
  const normalizedCommand = command.trim().replaceAll(/\s+/g, " ");
@@ -2195,7 +2153,7 @@ async function executeRequestedValidateChecks(params) {
2195
2153
  recordValidateCheck(state, buildCommandReferencesCheck(params.items, params.settings.id_prefix, fullDiagnostics), fixHintsEnabled);
2196
2154
  }
2197
2155
  if (params.requestedChecks.has("history_drift")) {
2198
- recordValidateCheck(state, await buildHistoryDriftCheck(params.pmRoot, params.items, fullDiagnostics), fixHintsEnabled);
2156
+ recordValidateCheck(state, await buildValidateHistoryDriftCheck(params.pmRoot, params.items, fullDiagnostics), fixHintsEnabled);
2199
2157
  }
2200
2158
  if (params.requestedChecks.has("format_version")) {
2201
2159
  recordValidateCheck(state, buildFormatVersionCheck(params.items, fullDiagnostics), fixHintsEnabled);
@@ -2356,4 +2314,4 @@ export async function runValidate(options, global, services = {}) {
2356
2314
  }
2357
2315
  /* c8 ignore stop */
2358
2316
  //# sourceMappingURL=validate.js.map
2359
- //# debugId=7dd04a2f-1798-5c16-8740-5b7094f81cc0
2317
+ //# debugId=7b47a375-e72c-5108-bd93-75dd8cf93218