@unbrained/pm-cli 2026.8.11 → 2026.8.13

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 (250) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +74 -21
  3. package/dist/cli/commander-usage.js +37 -11
  4. package/dist/cli/error-guidance.d.ts +2 -0
  5. package/dist/cli/error-guidance.js +82 -19
  6. package/dist/cli/main.js +35 -19
  7. package/dist/cli/register-annotations.js +56 -3
  8. package/dist/cli/register-assurance.js +28 -17
  9. package/dist/cli/register-list-query.js +10 -7
  10. package/dist/cli/register-operations.js +16 -6
  11. package/dist/cli-bundle/bundle-manifest.json +163 -163
  12. package/dist/cli-bundle/chunks/chunk-3ZMOWAFM.js +2 -0
  13. package/dist/cli-bundle/chunks/chunk-DEDU3DG7.js +196 -0
  14. package/dist/cli-bundle/chunks/chunk-DL5M5J3V.js +13 -0
  15. package/dist/cli-bundle/chunks/chunk-F7FJYGK3.js +8 -0
  16. package/dist/cli-bundle/chunks/chunk-HIUZVCMN.js +5 -0
  17. package/dist/cli-bundle/chunks/chunk-IMGIN7R6.js +2 -0
  18. package/dist/cli-bundle/chunks/{chunk-A2SJGHSI.js → chunk-Q47C67TQ.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-WMEZHCFI.js → chunk-QGTUPEU5.js} +62 -54
  20. package/dist/cli-bundle/chunks/chunk-TF3TPKPR.js +34 -0
  21. package/dist/cli-bundle/chunks/{chunk-ZU34C3LH.js → chunk-YLBAPY22.js} +50 -50
  22. package/dist/cli-bundle/chunks/register-list-query-4HIZ7EA3.js +10 -0
  23. package/dist/cli-bundle/chunks/register-mutation-W64FZ5HN.js +20 -0
  24. package/dist/cli-bundle/chunks/register-operations-C44ET7R5.js +2 -0
  25. package/dist/cli-bundle/chunks/{register-setup-NOCOOWQY.js → register-setup-634MFRXU.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/chunk-27N23W6M.js +31 -0
  27. package/dist/cli-bundle/focused-chunks/{chunk-4H5IA6AV.js → chunk-2JP7W7GO.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/chunk-2RI2FESN.js +4 -0
  29. package/dist/cli-bundle/focused-chunks/chunk-3BNVU6LC.js +8 -0
  30. package/dist/cli-bundle/focused-chunks/{chunk-2DL3MRTD.js → chunk-3DJSGWVB.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/chunk-6MLIRBLV.js +5 -0
  32. package/dist/cli-bundle/focused-chunks/chunk-6XYLENDV.js +155 -0
  33. package/dist/cli-bundle/focused-chunks/chunk-CP4K4WFS.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/{chunk-TL5M2PAY.js → chunk-E3AVJ655.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/chunk-EBTNSFYE.js +2 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-J5EKAIVD.js → chunk-HC2OL2H2.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-BKPIY34S.js → chunk-I75MANL7.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/chunk-IIS2FRKL.js +2 -0
  39. package/dist/cli-bundle/focused-chunks/chunk-NFHFZH2Z.js +2 -0
  40. package/dist/cli-bundle/focused-chunks/chunk-OGC4XSBC.js +17 -0
  41. package/dist/cli-bundle/focused-chunks/{chunk-UDAZWT25.js → chunk-OOYYKQWX.js} +4 -4
  42. package/dist/cli-bundle/focused-chunks/{chunk-23FTGO3W.js → chunk-PKPOZXLL.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/chunk-QDZUABWL.js +2 -0
  44. package/dist/cli-bundle/focused-chunks/chunk-QQX5TDFT.js +16 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-55BIB6DV.js → chunk-TEZIXMTH.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/chunk-WEH6NSL6.js +18 -0
  47. package/dist/cli-bundle/main.js +13 -13
  48. package/dist/cli-bundle/sdk-authoring.js +1 -1
  49. package/dist/cli-bundle/sdk-contracts.js +1 -1
  50. package/dist/cli-bundle/sdk-core.js +42 -41
  51. package/dist/cli-bundle/sdk-governance.js +1 -1
  52. package/dist/cli-bundle/sdk-graph.js +1 -1
  53. package/dist/cli-bundle/sdk-merge.js +1 -1
  54. package/dist/cli-bundle/sdk-query.js +1 -1
  55. package/dist/cli-bundle/sdk-runtime.js +1 -1
  56. package/dist/cli-bundle/sdk-testing.js +1 -1
  57. package/dist/cli-bundle/sdk.js +2 -2
  58. package/dist/core/checkpoint/checkpoint-gc.js +7 -12
  59. package/dist/core/extensions/activation-summary-markdown.js +5 -4
  60. package/dist/core/extensions/activation-summary.d.ts +2 -0
  61. package/dist/core/extensions/activation-summary.js +6 -2
  62. package/dist/core/extensions/capability-usage.d.ts +1 -1
  63. package/dist/core/extensions/capability-usage.js +4 -3
  64. package/dist/core/extensions/contribution-inventory.d.ts +1 -0
  65. package/dist/core/extensions/contribution-inventory.js +6 -2
  66. package/dist/core/extensions/extension-registries.js +3 -2
  67. package/dist/core/extensions/extension-types.d.ts +83 -1
  68. package/dist/core/extensions/extension-types.js +3 -2
  69. package/dist/core/extensions/loader.d.ts +2 -8
  70. package/dist/core/extensions/loader.js +53 -144
  71. package/dist/core/extensions/registration-values.d.ts +43 -0
  72. package/dist/core/extensions/registration-values.js +210 -0
  73. package/dist/core/extensions/reserved-host-flags.js +3 -2
  74. package/dist/core/extensions/runtime-registrations.d.ts +3 -1
  75. package/dist/core/extensions/runtime-registrations.js +12 -2
  76. package/dist/core/fs/fs-utils.d.ts +2 -0
  77. package/dist/core/fs/fs-utils.js +7 -3
  78. package/dist/core/history/drift-cache.js +4 -3
  79. package/dist/core/history/drift-scan.js +16 -17
  80. package/dist/core/history/history.d.ts +8 -0
  81. package/dist/core/history/history.js +57 -7
  82. package/dist/core/history/replay.d.ts +9 -1
  83. package/dist/core/history/replay.js +48 -13
  84. package/dist/core/lock/lock-gc.js +8 -13
  85. package/dist/core/lock/lock.js +5 -4
  86. package/dist/core/output/output.d.ts +2 -0
  87. package/dist/core/output/output.js +46 -14
  88. package/dist/core/search/vector-stores.js +6 -11
  89. package/dist/core/shared/command-types.d.ts +2 -0
  90. package/dist/core/shared/command-types.js +2 -2
  91. package/dist/core/shared/errors.d.ts +5 -0
  92. package/dist/core/shared/errors.js +2 -2
  93. package/dist/core/store/item-metadata-cache.d.ts +1 -1
  94. package/dist/core/store/item-metadata-cache.js +16 -9
  95. package/dist/core/telemetry/runtime.d.ts +6 -0
  96. package/dist/core/telemetry/runtime.js +101 -30
  97. package/dist/sdk/agent/command-recovery.d.ts +2 -0
  98. package/dist/sdk/agent/command-recovery.js +10 -2
  99. package/dist/sdk/annotations.js +4 -4
  100. package/dist/sdk/cli-bootstrap.d.ts +2 -0
  101. package/dist/sdk/cli-bootstrap.js +6 -2
  102. package/dist/sdk/cli-contracts/completeness.js +10 -3
  103. package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
  104. package/dist/sdk/cli-contracts/flag-contracts.js +9 -3
  105. package/dist/sdk/cli-contracts/registration-helpers.d.ts +20 -3
  106. package/dist/sdk/cli-contracts/registration-helpers.js +18 -12
  107. package/dist/sdk/cli-contracts/schemas/assurance-definition.d.ts +40 -6
  108. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +27 -3
  109. package/dist/sdk/cli-contracts/tool-option-contracts.js +3 -2
  110. package/dist/sdk/cli-contracts/tool-parameter-tables.js +55 -5
  111. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  112. package/dist/sdk/cli-contracts/tool-schema.js +22 -4
  113. package/dist/sdk/cli-program.js +3 -2
  114. package/dist/sdk/comments.js +4 -3
  115. package/dist/sdk/compile-cache.js +4 -3
  116. package/dist/sdk/completion.js +16 -7
  117. package/dist/sdk/compose.d.ts +3 -1
  118. package/dist/sdk/compose.js +16 -2
  119. package/dist/sdk/context-intent-contracts.js +45 -4
  120. package/dist/sdk/context-signal-store.js +4 -3
  121. package/dist/sdk/core.d.ts +1 -0
  122. package/dist/sdk/core.js +3 -2
  123. package/dist/sdk/extension/install-runtime.js +4 -4
  124. package/dist/sdk/extension/managed-state.js +4 -3
  125. package/dist/sdk/extension-contracts.d.ts +1 -1
  126. package/dist/sdk/flag-invocation-contracts.js +5 -6
  127. package/dist/sdk/generated/generated-error-code-catalog-part-1.d.ts +8 -0
  128. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1597 -0
  129. package/dist/sdk/generated/generated-error-code-catalog-part-2.d.ts +8 -0
  130. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1608 -0
  131. package/dist/sdk/generated-error-code-catalog.js +6 -3140
  132. package/dist/sdk/governance/assurance-action.d.ts +27 -3
  133. package/dist/sdk/governance/assurance-action.js +117 -31
  134. package/dist/sdk/governance/assurance-mutation-error.d.ts +14 -0
  135. package/dist/sdk/governance/assurance-mutation-error.js +58 -0
  136. package/dist/sdk/governance/assurance-presets.d.ts +54 -0
  137. package/dist/sdk/governance/assurance-presets.js +136 -0
  138. package/dist/sdk/governance/assurance-runtime.d.ts +4 -0
  139. package/dist/sdk/governance/assurance-runtime.js +118 -14
  140. package/dist/sdk/governance/assurance.d.ts +51 -6
  141. package/dist/sdk/governance/assurance.js +321 -67
  142. package/dist/sdk/governance/gc.js +5 -11
  143. package/dist/sdk/governance/health.d.ts +3 -1
  144. package/dist/sdk/governance/health.js +24 -7
  145. package/dist/sdk/governance/validate-item-reader.js +3 -3
  146. package/dist/sdk/governance/validate.d.ts +2 -0
  147. package/dist/sdk/governance/validate.js +15 -5
  148. package/dist/sdk/graph/durable-cache.d.ts +1 -1
  149. package/dist/sdk/graph/durable-cache.js +156 -29
  150. package/dist/sdk/graph/governance-contracts.d.ts +12 -0
  151. package/dist/sdk/graph/governance-contracts.js +27 -0
  152. package/dist/sdk/graph/governance.d.ts +44 -2
  153. package/dist/sdk/graph/governance.js +156 -12
  154. package/dist/sdk/guide.js +4 -4
  155. package/dist/sdk/index.d.ts +3 -2
  156. package/dist/sdk/index.js +5 -4
  157. package/dist/sdk/lifecycle/claim.js +10 -3
  158. package/dist/sdk/linked-artifacts.d.ts +2 -0
  159. package/dist/sdk/linked-artifacts.js +29 -4
  160. package/dist/sdk/merge/driver.d.ts +2 -2
  161. package/dist/sdk/merge/driver.js +3 -3
  162. package/dist/sdk/merge/install.js +5 -4
  163. package/dist/sdk/merge/receipts.d.ts +6 -4
  164. package/dist/sdk/merge/receipts.js +7 -5
  165. package/dist/sdk/merge/three-way.d.ts +2 -2
  166. package/dist/sdk/merge/three-way.js +3 -3
  167. package/dist/sdk/output-projection.d.ts +9 -1
  168. package/dist/sdk/output-projection.js +45 -9
  169. package/dist/sdk/query/activity.d.ts +49 -2
  170. package/dist/sdk/query/activity.js +185 -38
  171. package/dist/sdk/query/get.js +19 -2
  172. package/dist/sdk/read-output-contracts.d.ts +5 -1
  173. package/dist/sdk/read-output-contracts.js +17 -2
  174. package/dist/sdk/read-output-session.d.ts +2 -0
  175. package/dist/sdk/read-output-session.js +12 -5
  176. package/dist/sdk/relationship-history.js +5 -5
  177. package/dist/sdk/runtime-primitives.d.ts +3 -3
  178. package/dist/sdk/runtime-primitives.js +5 -5
  179. package/dist/sdk/runtime-stats-options.js +3 -2
  180. package/dist/sdk/runtime.js +5 -9
  181. package/dist/sdk/schema-migration.js +4 -4
  182. package/dist/sdk/stats.d.ts +36 -3
  183. package/dist/sdk/stats.js +55 -15
  184. package/dist/sdk/test/execution.d.ts +4 -0
  185. package/dist/sdk/test/execution.js +88 -23
  186. package/dist/sdk/workspace-memory.js +4 -4
  187. package/dist/sdk/workspace-snapshot.js +8 -14
  188. package/dist/sdk/workspace-transaction-gc.js +4 -9
  189. package/dist/sdk/workspace-transaction.js +4 -4
  190. package/dist/sdk/workspace.js +4 -3
  191. package/dist/types.d.ts +2 -0
  192. package/dist/types.js +2 -2
  193. package/docs/ASSURANCE.md +170 -14
  194. package/docs/COMMANDS.md +29 -8
  195. package/docs/CONFIGURATION.md +9 -0
  196. package/docs/DEPENDENCY_KIND_CONTRACT.md +10 -8
  197. package/docs/EXTENSIONS.md +11 -12
  198. package/docs/MERGE_SAFETY.md +3 -1
  199. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +26 -13
  200. package/docs/README.md +2 -0
  201. package/docs/READ_OUTPUT_CONTRACTS.md +17 -2
  202. package/docs/RELATIONSHIP_GRAPH.md +15 -0
  203. package/docs/SDK.md +17 -3
  204. package/docs/SDK_AGENT_SESSION_CONTEXT.md +12 -1
  205. package/docs/SDK_CONTEXT_EVIDENCE_CONTRACTS.md +53 -0
  206. package/docs/SDK_CONTEXT_INTEGRITY.md +28 -1
  207. package/docs/TESTING.md +24 -15
  208. package/docs/TRUSTWORTHY_CONTEXT_EVIDENCE.md +106 -0
  209. package/docs/performance/sdk-entrypoint-import-costs.md +6 -2
  210. package/marketplace.json +2 -2
  211. package/package.json +6 -6
  212. package/packages/pm-beads/package.json +1 -1
  213. package/packages/pm-calendar/package.json +1 -1
  214. package/packages/pm-command-kit/package.json +1 -1
  215. package/packages/pm-digital-twin/package.json +1 -1
  216. package/packages/pm-governance-audit/package.json +1 -1
  217. package/packages/pm-guide-shell/package.json +1 -1
  218. package/packages/pm-kanban/package.json +1 -1
  219. package/packages/pm-lifecycle-hooks/package.json +1 -1
  220. package/packages/pm-linked-test-adapters/package.json +1 -1
  221. package/packages/pm-search-advanced/package.json +1 -1
  222. package/packages/pm-templates/package.json +1 -1
  223. package/packages/pm-todos/package.json +1 -1
  224. package/packages/pm-vcs/package.json +1 -1
  225. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  226. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  227. package/sdk/public-surface.json +384 -83
  228. package/dist/cli-bundle/chunks/chunk-2OOU2AFH.js +0 -8
  229. package/dist/cli-bundle/chunks/chunk-2RA2YTHJ.js +0 -33
  230. package/dist/cli-bundle/chunks/chunk-DSKYD4LG.js +0 -13
  231. package/dist/cli-bundle/chunks/chunk-HC3GM6YY.js +0 -194
  232. package/dist/cli-bundle/chunks/chunk-IUNRVDAI.js +0 -2
  233. package/dist/cli-bundle/chunks/chunk-W7CPZGSB.js +0 -2
  234. package/dist/cli-bundle/chunks/chunk-ZXOC6HG5.js +0 -5
  235. package/dist/cli-bundle/chunks/register-list-query-HAUXVUPY.js +0 -10
  236. package/dist/cli-bundle/chunks/register-mutation-7Y5U7ABT.js +0 -20
  237. package/dist/cli-bundle/chunks/register-operations-EQX3DLAZ.js +0 -2
  238. package/dist/cli-bundle/focused-chunks/chunk-3AYKXMYX.js +0 -2
  239. package/dist/cli-bundle/focused-chunks/chunk-4AHEC74N.js +0 -2
  240. package/dist/cli-bundle/focused-chunks/chunk-4SV3ZKG3.js +0 -16
  241. package/dist/cli-bundle/focused-chunks/chunk-6JW6Z2P5.js +0 -8
  242. package/dist/cli-bundle/focused-chunks/chunk-D4PIWE6D.js +0 -2
  243. package/dist/cli-bundle/focused-chunks/chunk-DPO7TEFX.js +0 -31
  244. package/dist/cli-bundle/focused-chunks/chunk-E3KCL7AY.js +0 -5
  245. package/dist/cli-bundle/focused-chunks/chunk-ERAAFLPS.js +0 -153
  246. package/dist/cli-bundle/focused-chunks/chunk-F6E4JZKG.js +0 -2
  247. package/dist/cli-bundle/focused-chunks/chunk-FPSYO5ZG.js +0 -18
  248. package/dist/cli-bundle/focused-chunks/chunk-KDH5OX3D.js +0 -4
  249. package/dist/cli-bundle/focused-chunks/chunk-OJ3LVVIS.js +0 -2
  250. package/dist/cli-bundle/focused-chunks/chunk-VABB4L5Y.js +0 -17
@@ -7,7 +7,7 @@
7
7
  * value for the coordinator that performed the merge.
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]="59863597-bf57-5d96-9cba-983443e5b209")}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]="7b87b458-164a-5332-8803-6b0695481644")}catch(e){}}();
11
11
  import { execFile } from "node:child_process";
12
12
  import { randomUUID } from "node:crypto";
13
13
  import { readdir, readFile } from "node:fs/promises";
@@ -58,7 +58,7 @@ export function summarizeMergeReceipt(receipt) {
58
58
  conflict_fields: receipt.decisions.map((decision) => decision.field),
59
59
  fields_from_theirs: receipt.fields_from_theirs,
60
60
  union_fields: receipt.union_fields,
61
- preferred: receipt.preferred,
61
+ requested_preference: receipt.requested_preference ?? receipt.preferred ?? "ours",
62
62
  conflict_resolution: receipt.conflict_resolution,
63
63
  decisions: receipt.decisions.map((decision) => ({
64
64
  field: decision.field,
@@ -99,7 +99,7 @@ export async function writeMergeReceipt(params) {
99
99
  id: randomUUID(),
100
100
  item_path: itemPath.replaceAll("\\", "/"),
101
101
  item_id: itemId,
102
- preferred: params.preferred,
102
+ requested_preference: params.preferred,
103
103
  conflict_resolution: params.conflictResolution ?? "preferred_side",
104
104
  fields_from_theirs: [...params.fieldsFromTheirs],
105
105
  union_fields: [...params.unionFields],
@@ -147,8 +147,10 @@ async function readReceiptsFromDirectory(directory, options) {
147
147
  continue;
148
148
  try {
149
149
  const parsed = JSON.parse(await readFile(path.join(directory, name), "utf8"));
150
+ const { preferred: legacyPreference, ...receiptWithoutLegacyKey } = parsed;
150
151
  const normalizedReceipt = {
151
- ...parsed,
152
+ ...receiptWithoutLegacyKey,
153
+ requested_preference: parsed.requested_preference ?? legacyPreference ?? "ours",
152
154
  conflict_resolution: parsed.conflict_resolution ?? "preferred_side",
153
155
  };
154
156
  if (normalizedReceipt.version === 1 &&
@@ -218,4 +220,4 @@ export async function runMergeReceiptReport(options) {
218
220
  };
219
221
  }
220
222
  //# sourceMappingURL=receipts.js.map
221
- //# debugId=59863597-bf57-5d96-9cba-983443e5b209
223
+ //# debugId=7b87b458-164a-5332-8803-6b0695481644
@@ -98,8 +98,8 @@ export interface ItemDocumentMergeResult {
98
98
  union_fields: string[];
99
99
  /** Scalar conflict decisions; callers choose a privacy-appropriate persistence boundary. */
100
100
  conflict_decisions: ItemMergeConflictDecision[];
101
- /** Which side unresolvable conflicts were resolved toward. */
102
- preferred: MergePreferredSide;
101
+ /** Side requested by the caller; stable-value decisions can retain either side. */
102
+ requested_preference: MergePreferredSide;
103
103
  /** Scalar-conflict selection contract used for this merge. */
104
104
  conflict_resolution: "preferred_side" | "stable_value_order";
105
105
  }
@@ -9,7 +9,7 @@
9
9
  * definition for multi-branch agent workflows.
10
10
  */
11
11
 
12
- !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]="f6f04eec-0698-5e5b-a40e-de3a4be89f95")}catch(e){}}();
12
+ !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]="3c9d6924-ae7c-57c3-a346-1e2189c532fa")}catch(e){}}();
13
13
  import { historyEntriesToRaw, reanchorHistoryEntries, } from "../../core/history/replay.js";
14
14
  import { canonicalDocument, parseItemDocument, serializeItemDocument, } from "../../core/item/item-format.js";
15
15
  import { EXIT_CODE } from "../../core/shared/constants.js";
@@ -468,7 +468,7 @@ export function mergeItemDocuments(baseRaw, oursRaw, theirsRaw, options = {}) {
468
468
  fields_from_theirs: fieldsFromTheirs,
469
469
  union_fields: unionFields,
470
470
  conflict_decisions: conflictDecisions,
471
- preferred,
471
+ requested_preference: preferred,
472
472
  conflict_resolution: conflictResolution,
473
473
  };
474
474
  }
@@ -625,4 +625,4 @@ export function mergeJsonDocuments(baseRaw, oursRaw, theirsRaw, options = {}) {
625
625
  };
626
626
  }
627
627
  //# sourceMappingURL=three-way.js.map
628
- //# debugId=f6f04eec-0698-5e5b-a40e-de3a4be89f95
628
+ //# debugId=3c9d6924-ae7c-57c3-a346-1e2189c532fa
@@ -23,6 +23,8 @@ export interface OutputProjectionDeclaration {
23
23
  /** Names of declared groups present in this result. */
24
24
  included_field_groups: string[];
25
25
  }
26
+ /** Register non-serialized materiality evidence used to keep omission receipts token-proportional. */
27
+ export declare function registerOutputMaterialFieldGroups(result: object, fieldGroups: readonly string[]): void;
26
28
  /** Machine-readable location and field-projection support for read-result rows. */
27
29
  export interface ReadRowContract {
28
30
  /** Canonical read command that owns the result. */
@@ -35,6 +37,8 @@ export interface ReadRowContract {
35
37
  fields: "supported" | "unsupported";
36
38
  /** Universal jq expression that iterates every declared collection path. */
37
39
  jq_selector?: string;
40
+ /** TOON row encoding selected whenever every row is a flat object with one shared key set. */
41
+ toon_encoding?: "tabular_when_uniform";
38
42
  }
39
43
  /** Universal selector for results carrying a {@link ReadRowContract}. */
40
44
  export declare const PM_READ_ROW_JQ_SELECTOR = ".row_contract.row_keys[] as $key | getpath($key | split(\".\")) | if type == \"array\" then .[] else if type == \"object\" then to_entries[] else empty end end";
@@ -61,7 +65,7 @@ export declare const PM_READ_ROW_CONTRACTS: {
61
65
  readonly fields: "supported";
62
66
  };
63
67
  readonly activity: {
64
- readonly row_keys: readonly ["compact_activity", "provenance_activity", "activity"];
68
+ readonly row_keys: readonly ["activity_digest", "compact_activity", "provenance_activity", "activity"];
65
69
  readonly fields: "unsupported";
66
70
  };
67
71
  readonly history: {
@@ -131,6 +135,10 @@ export declare const PM_MODE_PAIRED_OUTPUT_PROJECTION_CONTRACTS: readonly [{
131
135
  readonly command: "activity";
132
136
  readonly complete_mode: "full";
133
137
  readonly omissions_by_mode: {
138
+ readonly digest: readonly [{
139
+ readonly name: "event_rows";
140
+ readonly restore_with: "--raw";
141
+ }];
134
142
  readonly compact: readonly [{
135
143
  readonly name: "provenance";
136
144
  readonly restore_with: "--full";
@@ -4,9 +4,14 @@
4
4
  * Declares machine-readable field-group omissions for bounded command results.
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]="630b48a7-aa38-529c-a272-14b7c748101c")}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]="d059aa19-3822-5ff4-b4be-e2be8f537d1e")}catch(e){}}();
8
8
  import { EXIT_CODE } from "../core/shared/constants.js";
9
9
  import { PmCliError } from "../core/shared/errors.js";
10
+ const MATERIAL_FIELD_GROUPS_BY_RESULT = new WeakMap();
11
+ /** Register non-serialized materiality evidence used to keep omission receipts token-proportional. */
12
+ export function registerOutputMaterialFieldGroups(result, fieldGroups) {
13
+ MATERIAL_FIELD_GROUPS_BY_RESULT.set(result, new Set(fieldGroups));
14
+ }
10
15
  /** Universal selector for results carrying a {@link ReadRowContract}. */
11
16
  export const PM_READ_ROW_JQ_SELECTOR = '.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end';
12
17
  /** Static row declarations shared by CLI, SDK, MCP, and package consumers. */
@@ -26,7 +31,12 @@ export const PM_READ_ROW_CONTRACTS = {
26
31
  },
27
32
  search: { row_keys: ["items"], fields: "supported" },
28
33
  activity: {
29
- row_keys: ["compact_activity", "provenance_activity", "activity"],
34
+ row_keys: [
35
+ "activity_digest",
36
+ "compact_activity",
37
+ "provenance_activity",
38
+ "activity",
39
+ ],
30
40
  fields: "unsupported",
31
41
  },
32
42
  history: {
@@ -58,6 +68,12 @@ export const PM_MODE_PAIRED_OUTPUT_PROJECTION_CONTRACTS = [
58
68
  command: "activity",
59
69
  complete_mode: "full",
60
70
  omissions_by_mode: {
71
+ digest: [
72
+ {
73
+ name: "event_rows",
74
+ restore_with: "--raw",
75
+ },
76
+ ],
61
77
  compact: [
62
78
  {
63
79
  name: "provenance",
@@ -139,16 +155,23 @@ const CONTEXT_FIELD_GROUPS = [
139
155
  function isRecord(value) {
140
156
  return typeof value === "object" && value !== null && !Array.isArray(value);
141
157
  }
158
+ const READ_ROW_TOON_ENCODINGS = new Set([
159
+ undefined,
160
+ "tabular_when_uniform",
161
+ ]);
162
+ const READ_ROW_KINDS = new Set(["collection", "none"]);
163
+ const READ_ROW_FIELD_MODES = new Set(["supported", "unsupported"]);
142
164
  /** Return whether an unknown value is a structurally valid row declaration. */
143
165
  export function isReadRowContract(value) {
144
166
  return (isRecord(value) &&
145
167
  typeof value.command === "string" &&
146
168
  value.command.trim().length > 0 &&
147
- (value.row_kind === "collection" || value.row_kind === "none") &&
169
+ READ_ROW_KINDS.has(value.row_kind) &&
148
170
  Array.isArray(value.row_keys) &&
149
171
  value.row_keys.every((key) => typeof key === "string" && key.length > 0) &&
150
172
  new Set(value.row_keys).size === value.row_keys.length &&
151
- (value.fields === "supported" || value.fields === "unsupported") &&
173
+ READ_ROW_FIELD_MODES.has(value.fields) &&
174
+ READ_ROW_TOON_ENCODINGS.has(value.toon_encoding) &&
152
175
  (value.row_kind === "collection"
153
176
  ? value.row_keys.length > 0 &&
154
177
  typeof value.jq_selector === "string" &&
@@ -183,7 +206,12 @@ const READ_RESULT_SENTINEL_KEYS = {
183
206
  "held_by_others",
184
207
  ],
185
208
  search: ["items", "projection"],
186
- activity: ["compact_activity", "provenance_activity", "activity"],
209
+ activity: [
210
+ "activity_digest",
211
+ "compact_activity",
212
+ "provenance_activity",
213
+ "activity",
214
+ ],
187
215
  history: ["compact_history", "provenance_history", "history"],
188
216
  deps: ["tree", "graph", "projection"],
189
217
  health: ["checks"],
@@ -220,6 +248,7 @@ export function resolveReadRowContract(command, result) {
220
248
  ...(activeRowKeys.length > 0
221
249
  ? { jq_selector: PM_READ_ROW_JQ_SELECTOR }
222
250
  : {}),
251
+ toon_encoding: "tabular_when_uniform",
223
252
  };
224
253
  }
225
254
  const declaration = PM_READ_ROW_CONTRACTS[rootCommand];
@@ -243,6 +272,7 @@ export function resolveReadRowContract(command, result) {
243
272
  ...(rowKeys.length > 0
244
273
  ? { jq_selector: PM_READ_ROW_JQ_SELECTOR }
245
274
  : {}),
275
+ toon_encoding: "tabular_when_uniform",
246
276
  };
247
277
  })();
248
278
  }
@@ -301,11 +331,17 @@ function resolveGetReceipt(result) {
301
331
  "linked",
302
332
  "schedule",
303
333
  ];
304
- const groups = ["body", ...itemGroups, ...resultGroups.slice(1)].map((name) => ({
334
+ const materialGroups = MATERIAL_FIELD_GROUPS_BY_RESULT.get(result);
335
+ const ownerFor = (name) => itemGroups.includes(name) || name === "body" ? item : result;
336
+ const groups = ["body", ...itemGroups, ...resultGroups.slice(1)]
337
+ .filter((name) => materialGroups === undefined ||
338
+ materialGroups.has(name) ||
339
+ Object.hasOwn(ownerFor(name), name))
340
+ .map((name) => ({
305
341
  name,
306
342
  restore_with: `--fields ${name}`,
307
343
  }));
308
- return createOutputOmissionReceipt(groups, new Set(groups.flatMap(({ name }) => !Object.hasOwn(itemGroups.includes(name) ? item : result, name)
344
+ return createOutputOmissionReceipt(groups, new Set(groups.flatMap(({ name }) => !Object.hasOwn(ownerFor(name), name)
309
345
  ? []
310
346
  : [name])));
311
347
  }
@@ -361,6 +397,7 @@ export function attachOutputOmissionReceipt(command, result) {
361
397
  if (command === undefined || !isRecord(result)) {
362
398
  return result;
363
399
  }
400
+ const receipt = resolveOutputOmissionReceipt(command, result);
364
401
  const declaredRowContract = result.row_contract;
365
402
  const rowContract = isReadRowContract(declaredRowContract)
366
403
  ? declaredRowContract
@@ -372,10 +409,9 @@ export function attachOutputOmissionReceipt(command, result) {
372
409
  : result;
373
410
  if (isRecord(disclosedResult.omission_receipt))
374
411
  return disclosedResult;
375
- const receipt = resolveOutputOmissionReceipt(command, disclosedResult);
376
412
  return receipt === undefined
377
413
  ? disclosedResult
378
414
  : { ...disclosedResult, omission_receipt: receipt };
379
415
  }
380
416
  //# sourceMappingURL=output-projection.js.map
381
- //# debugId=630b48a7-aa38-529c-a272-14b7c748101c
417
+ //# debugId=d059aa19-3822-5ff4-b4be-e2be8f537d1e
@@ -18,6 +18,8 @@ export interface ActivityCommandOptions {
18
18
  limit?: string;
19
19
  /** Value that configures or reports compact for this contract. */
20
20
  compact?: boolean;
21
+ /** Return the legacy per-event stream instead of the item-centric digest. */
22
+ raw?: boolean;
21
23
  /** Explicitly disables the default activity bound. */
22
24
  unbounded?: boolean;
23
25
  /** Return patch-free provenance rows. */
@@ -31,6 +33,10 @@ export interface ActivityCommandOptions {
31
33
  /** Exact provenance dimension predicates (`dimension=value`). */
32
34
  provenanceFilter?: string | readonly string[];
33
35
  }
36
+ /** Normalize raw and full aliases into one explicit activity row projection. */
37
+ export declare function normalizeActivityProjectionOptions(options: ActivityCommandOptions & {
38
+ full?: unknown;
39
+ }): ActivityCommandOptions;
34
40
  /** Documents the activity entry payload exchanged by command, SDK, and package integrations. */
35
41
  export interface ActivityEntry extends HistoryEntry {
36
42
  /** Stable identifier used to reference this record across commands and storage. */
@@ -49,8 +55,29 @@ export interface CompactActivityEntry {
49
55
  /** Value that configures or reports msg for this contract. */
50
56
  msg?: string;
51
57
  }
58
+ /** One item-centric summary of every matching immutable event for that item. */
59
+ export interface ActivityDigestEntry {
60
+ /** Stable item identifier. */
61
+ id: string;
62
+ /** Current item type from the light metadata join. */
63
+ type: string;
64
+ /** Current lifecycle status from the light metadata join. */
65
+ status: string;
66
+ /** Current item title, bounded for predictable context cost. */
67
+ title: string;
68
+ /** Matching immutable events folded into this row. */
69
+ event_count: number;
70
+ /** Oldest matching event timestamp. */
71
+ first_ts: string;
72
+ /** Newest matching event timestamp. */
73
+ last_ts: string;
74
+ /** Bounded operation histogram encoded as comma-separated op:count pairs. */
75
+ operations: string;
76
+ }
52
77
  /** Documents the activity result payload exchanged by command, SDK, and package integrations. */
53
78
  export interface ActivityResult {
79
+ /** Default item-centric workspace activity rows. */
80
+ activity_digest?: ActivityDigestEntry[];
54
81
  /** Value that configures or reports activity for this contract. */
55
82
  activity?: ActivityEntry[];
56
83
  /** Value that configures or reports compact activity for this contract. */
@@ -62,9 +89,9 @@ export interface ActivityResult {
62
89
  /** Explicit active row projection. */
63
90
  projection: {
64
91
  /** Stable projection mode. */
65
- mode: "compact" | "provenance" | "full";
92
+ mode: "digest" | "compact" | "provenance" | "full";
66
93
  /** Active row collection key. */
67
- row_key: "compact_activity" | "provenance_activity" | "activity";
94
+ row_key: "activity_digest" | "compact_activity" | "provenance_activity" | "activity";
68
95
  };
69
96
  /** Constant-size disclosure of field groups withheld by the active mode. */
70
97
  omission_receipt: OutputOmissionReceipt;
@@ -84,9 +111,25 @@ export interface ActivityResult {
84
111
  source: "default" | "explicit";
85
112
  value: number | null;
86
113
  };
114
+ /** Constant-size description of the selected time window and matching corpus. */
115
+ activity_summary?: {
116
+ window: {
117
+ from: string | null;
118
+ to: string | null;
119
+ };
120
+ event_count: number;
121
+ item_count: number;
122
+ author_count: number;
123
+ operation_counts: Record<string, number>;
124
+ };
87
125
  /** Constant-size provenance completeness metrics. */
88
126
  provenance_summary?: HistoryProvenanceSummary;
89
127
  }
128
+ interface ActivityItemMetadata {
129
+ title: string;
130
+ type: string;
131
+ status: string;
132
+ }
90
133
  declare function parseNonEmptyFilter(raw: string | undefined, flagLabel: string): string | undefined;
91
134
  declare function parseRangeBound(raw: string | undefined, nowValue: string, fieldLabel: string): string | undefined;
92
135
  declare function includeByTimeWindow(entry: ActivityEntry, from: string | undefined, to: string | undefined): boolean;
@@ -95,6 +138,8 @@ declare function readActivityString(value: unknown, fallback?: string): string;
95
138
  declare function normalizeActivityEntry(id: string, entry: HistoryEntry): ActivityEntry;
96
139
  declare function sortActivity(entries: ActivityEntry[]): ActivityEntry[];
97
140
  declare function listHistoryFiles(historyDir: string): Promise<string[]>;
141
+ declare function buildActivityDigest(activity: readonly ActivityEntry[], itemsById: ReadonlyMap<string, ActivityItemMetadata>): ActivityDigestEntry[];
142
+ declare function activityOperationCounts(activity: readonly Pick<ActivityEntry, "op">[]): Record<string, number>;
98
143
  /** Public contract for test only, shared by SDK and presentation-layer consumers. */
99
144
  export declare const _testOnly: {
100
145
  parseNonEmptyFilter: typeof parseNonEmptyFilter;
@@ -105,6 +150,8 @@ export declare const _testOnly: {
105
150
  normalizeActivityEntry: typeof normalizeActivityEntry;
106
151
  sortActivity: typeof sortActivity;
107
152
  listHistoryFiles: typeof listHistoryFiles;
153
+ buildActivityDigest: typeof buildActivityDigest;
154
+ activityOperationCounts: typeof activityOperationCounts;
108
155
  };
109
156
  /** Implements run activity for the public runtime surface of this module. */
110
157
  export declare function runActivity(options: ActivityCommandOptions, global: GlobalOptions): Promise<ActivityResult>;
@@ -4,7 +4,8 @@
4
4
  * Implements the pm activity 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]="a7efa5e0-5610-51ca-8288-4f5410dbcf51")}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]="49304d18-d722-5413-8e4d-4f2c3df4a1ca")}catch(e){}}();
8
+ import { isFileMissingError } from "../../core/fs/fs-utils.js";
8
9
  import fs from "node:fs/promises";
9
10
  import path from "node:path";
10
11
  import { getActiveExtensionRegistrations, runActiveOnReadHooks, pathExists, enforceHistoryStreamPolicyForItems, resolveItemTypeRegistry, EXIT_CODE, PmCliError, compareTimestampStrings, nowIso, resolveIsoOrRelative, listAllItemMetadataLight, getSettingsPath, resolvePmRoot, readSettings, } from "../runtime-primitives.js";
@@ -14,6 +15,27 @@ import { resolveModePairedOutputOmissionReceipt, } from "../output-projection.js
14
15
  import { compileHistoryProvenanceMatcher, projectHistoryProvenance, resolveHistoryProvenanceDimensions, summarizeHistoryProvenance, } from "../history-provenance.js";
15
16
  const DEFAULT_COMPACT_ACTIVITY_LIMIT = 20;
16
17
  const DEFAULT_FULL_ACTIVITY_LIMIT = 5;
18
+ const DEFAULT_DIGEST_ACTIVITY_LIMIT = 15;
19
+ const DEFAULT_DIGEST_WINDOW = "-24h";
20
+ /** Normalize raw and full aliases into one explicit activity row projection. */
21
+ export function normalizeActivityProjectionOptions(options) {
22
+ const normalized = { ...options };
23
+ if (normalized.full === true) {
24
+ normalized.raw = true;
25
+ normalized.compact = false;
26
+ }
27
+ else if (normalized.raw === true && normalized.compact === undefined) {
28
+ normalized.compact = true;
29
+ }
30
+ delete normalized.full;
31
+ return normalized;
32
+ }
33
+ const ACTIVITY_ROW_KEY_BY_MODE = {
34
+ digest: "activity_digest",
35
+ compact: "compact_activity",
36
+ provenance: "provenance_activity",
37
+ full: "activity",
38
+ };
17
39
  function parseNonEmptyFilter(raw, flagLabel) {
18
40
  if (raw === undefined)
19
41
  return undefined;
@@ -86,16 +108,42 @@ async function listHistoryFiles(historyDir) {
86
108
  }
87
109
  catch (error) {
88
110
  // Activity should degrade gracefully when optional history storage is absent.
89
- if (error.code === "ENOENT") {
111
+ if (isFileMissingError(error)) {
90
112
  return [];
91
113
  }
92
114
  throw error;
93
115
  }
94
116
  }
95
- function resolveActivityFilters(options) {
117
+ function resolveActivityProjectionMode(options) {
118
+ if (options.raw !== true &&
119
+ options.compact !== true &&
120
+ options.provenance !== true) {
121
+ return "digest";
122
+ }
123
+ if (options.provenance === true)
124
+ return "provenance";
125
+ if (options.compact === true ||
126
+ (options.raw === true && options.compact !== false)) {
127
+ return "compact";
128
+ }
129
+ return "full";
130
+ }
131
+ function resolveActivityLimit(options, explicitLimit, projectionMode) {
132
+ if (options.unbounded === true)
133
+ return undefined;
134
+ if (explicitLimit !== undefined)
135
+ return explicitLimit;
136
+ if (projectionMode === "digest")
137
+ return DEFAULT_DIGEST_ACTIVITY_LIMIT;
138
+ if (projectionMode === "compact")
139
+ return DEFAULT_COMPACT_ACTIVITY_LIMIT;
140
+ return DEFAULT_FULL_ACTIVITY_LIMIT;
141
+ }
142
+ function resolveActivityFilters(options, projectionMode) {
96
143
  const nowValue = nowIso();
97
- const from = parseRangeBound(options.from, nowValue, "--from");
98
- const to = parseRangeBound(options.to, nowValue, "--to");
144
+ const digest = projectionMode === "digest";
145
+ const to = parseRangeBound(options.to ?? (digest ? nowValue : undefined), nowValue, "--to");
146
+ const from = parseRangeBound(options.from ?? (digest ? DEFAULT_DIGEST_WINDOW : undefined), options.from === undefined && digest ? to : nowValue, "--from");
99
147
  if (from && to && compareTimestampStrings(from, to) >= 0) {
100
148
  throw new PmCliError("Activity --from must be before --to", EXIT_CODE.USAGE);
101
149
  }
@@ -109,12 +157,7 @@ function resolveActivityFilters(options) {
109
157
  author: parseNonEmptyFilter(options.author, "Activity --author"),
110
158
  from,
111
159
  to,
112
- limit: options.unbounded === true
113
- ? undefined
114
- : (explicitLimit ??
115
- (options.compact === true
116
- ? DEFAULT_COMPACT_ACTIVITY_LIMIT
117
- : DEFAULT_FULL_ACTIVITY_LIMIT)),
160
+ limit: resolveActivityLimit(options, explicitLimit, projectionMode),
118
161
  limitSource: options.unbounded === true || explicitLimit !== undefined
119
162
  ? "explicit"
120
163
  : "default",
@@ -147,7 +190,13 @@ async function prepareActivityHistoryRead(context) {
147
190
  path: historyDir,
148
191
  scope: "project",
149
192
  });
150
- return historyDir;
193
+ return {
194
+ historyDir,
195
+ itemsById: new Map(items.map((item) => [
196
+ item.id,
197
+ { title: item.title, type: item.type, status: item.status },
198
+ ])),
199
+ };
151
200
  }
152
201
  function includeActivityEntry(entry, candidate, filters) {
153
202
  // Preserve legacy filter semantics: op/author filters compare the raw
@@ -186,6 +235,105 @@ function formatCompactActivity(activity) {
186
235
  ...(entry.message ? { msg: entry.message } : {}),
187
236
  }));
188
237
  }
238
+ function boundedOperationSummary(counts) {
239
+ const ordered = [...counts.entries()].sort(([leftOp, leftCount], [rightOp, rightCount]) => rightCount - leftCount || leftOp.localeCompare(rightOp));
240
+ const visible = ordered.slice(0, 4).map(([op, count]) => `${op}:${count}`);
241
+ if (ordered.length > visible.length) {
242
+ visible.push(`+${ordered.length - visible.length}`);
243
+ }
244
+ return visible.join(",");
245
+ }
246
+ function buildActivityDigest(activity, itemsById) {
247
+ const grouped = new Map();
248
+ for (const entry of activity) {
249
+ const current = grouped.get(entry.id);
250
+ if (current === undefined) {
251
+ grouped.set(entry.id, {
252
+ firstTs: entry.ts,
253
+ lastTs: entry.ts,
254
+ eventCount: 1,
255
+ operations: new Map([[entry.op, 1]]),
256
+ });
257
+ continue;
258
+ }
259
+ current.eventCount += 1;
260
+ if (compareTimestampStrings(entry.ts, current.firstTs) < 0) {
261
+ current.firstTs = entry.ts;
262
+ }
263
+ if (compareTimestampStrings(entry.ts, current.lastTs) > 0) {
264
+ current.lastTs = entry.ts;
265
+ }
266
+ current.operations.set(entry.op, (current.operations.get(entry.op) ?? 0) + 1);
267
+ }
268
+ return [...grouped.entries()]
269
+ .map(([id, summary]) => {
270
+ const item = itemsById.get(id);
271
+ return {
272
+ id,
273
+ type: item?.type ?? "unknown",
274
+ status: item?.status ?? "unknown",
275
+ title: (item?.title ?? "(item metadata unavailable)").slice(0, 160),
276
+ event_count: summary.eventCount,
277
+ first_ts: summary.firstTs,
278
+ last_ts: summary.lastTs,
279
+ operations: boundedOperationSummary(summary.operations),
280
+ };
281
+ })
282
+ .sort((left, right) => compareTimestampStrings(right.last_ts, left.last_ts) ||
283
+ left.id.localeCompare(right.id));
284
+ }
285
+ function activityOperationCounts(activity) {
286
+ const counts = new Map();
287
+ for (const entry of activity) {
288
+ counts.set(entry.op, (counts.get(entry.op) ?? 0) + 1);
289
+ }
290
+ const ordered = [...counts.entries()].sort((left, right) => right[1] - left[1] || left[0].localeCompare(right[0]));
291
+ const visible = ordered.slice(0, 8);
292
+ if (visible.length < ordered.length) {
293
+ visible.push([
294
+ `+${String(ordered.length - visible.length)}`,
295
+ ordered
296
+ .slice(visible.length)
297
+ .reduce((total, [, count]) => total + count, 0),
298
+ ]);
299
+ }
300
+ return Object.fromEntries(visible);
301
+ }
302
+ function projectActivityRows(projectionMode, matchingActivity, limit, itemsById, projectProvenance) {
303
+ if (projectionMode === "digest") {
304
+ const matchingDigest = buildActivityDigest(matchingActivity, itemsById);
305
+ const activityDigest = limitEntries(matchingDigest, limit);
306
+ return {
307
+ rows: { activity_digest: activityDigest },
308
+ compact: false,
309
+ totalRows: matchingDigest.length,
310
+ returnedRows: activityDigest.length,
311
+ };
312
+ }
313
+ const activity = limitEntries(matchingActivity, limit);
314
+ if (projectionMode === "compact") {
315
+ return {
316
+ rows: { compact_activity: formatCompactActivity(activity) },
317
+ compact: true,
318
+ totalRows: matchingActivity.length,
319
+ returnedRows: activity.length,
320
+ };
321
+ }
322
+ if (projectionMode === "provenance") {
323
+ return {
324
+ rows: { provenance_activity: activity.map(projectProvenance) },
325
+ compact: false,
326
+ totalRows: matchingActivity.length,
327
+ returnedRows: activity.length,
328
+ };
329
+ }
330
+ return {
331
+ rows: { activity },
332
+ compact: false,
333
+ totalRows: matchingActivity.length,
334
+ returnedRows: activity.length,
335
+ };
336
+ }
189
337
  /** Public contract for test only, shared by SDK and presentation-layer consumers. */
190
338
  export const _testOnly = {
191
339
  parseNonEmptyFilter,
@@ -196,12 +344,15 @@ export const _testOnly = {
196
344
  normalizeActivityEntry,
197
345
  sortActivity,
198
346
  listHistoryFiles,
347
+ buildActivityDigest,
348
+ activityOperationCounts,
199
349
  };
200
350
  /** Implements run activity for the public runtime surface of this module. */
201
351
  export async function runActivity(options, global) {
202
352
  const context = await resolveActivityRuntimeContext(global);
203
- const filters = resolveActivityFilters(options);
204
- const historyDir = await prepareActivityHistoryRead(context);
353
+ const projectionMode = resolveActivityProjectionMode(options);
354
+ const filters = resolveActivityFilters(options, projectionMode);
355
+ const prepared = await prepareActivityHistoryRead(context);
205
356
  const provenanceDimensions = resolveHistoryProvenanceDimensions(context.settings.agent_identity.harness_signals);
206
357
  const vocabulary = context.settings.agent_identity.identity_vocabulary;
207
358
  const matchesProvenance = compileHistoryProvenanceMatcher({
@@ -209,37 +360,33 @@ export async function runActivity(options, global) {
209
360
  agentInstance: filters.agentInstance,
210
361
  provenance: filters.provenance,
211
362
  }, vocabulary, provenanceDimensions);
212
- const matchingActivity = sortActivity(await collectActivityEntries(historyDir, filters)).filter(matchesProvenance);
213
- const activity = limitEntries(matchingActivity, filters.limit);
214
- const compact = options.compact === true;
215
- const compactActivity = compact ? formatCompactActivity(activity) : undefined;
216
- const provenanceActivity = options.provenance === true
217
- ? activity.map((entry) => projectHistoryProvenance(entry, vocabulary, { itemId: entry.id }))
218
- : undefined;
219
- const omittedCount = matchingActivity.length - activity.length;
220
- const projectionMode = options.provenance === true ? "provenance" : compact ? "compact" : "full";
221
- const rowProjection = {
222
- compact: { compact_activity: compactActivity },
223
- provenance: { provenance_activity: provenanceActivity },
224
- full: { activity },
225
- }[projectionMode];
363
+ const matchingActivity = sortActivity(await collectActivityEntries(prepared.historyDir, filters)).filter(matchesProvenance);
364
+ const projected = projectActivityRows(projectionMode, matchingActivity, filters.limit, prepared.itemsById, (entry) => projectHistoryProvenance(entry, vocabulary, { itemId: entry.id }));
365
+ const omittedCount = projected.totalRows - projected.returnedRows;
226
366
  return {
227
- ...rowProjection,
228
- compact,
367
+ ...projected.rows,
368
+ compact: projected.compact,
229
369
  projection: {
230
370
  mode: projectionMode,
231
- row_key: projectionMode === "compact"
232
- ? "compact_activity"
233
- : projectionMode === "provenance"
234
- ? "provenance_activity"
235
- : "activity",
371
+ row_key: ACTIVITY_ROW_KEY_BY_MODE[projectionMode],
236
372
  },
237
373
  omission_receipt: resolveModePairedOutputOmissionReceipt("activity", projectionMode),
238
- count: activity.length,
239
- total_count: matchingActivity.length,
374
+ count: projected.returnedRows,
375
+ total_count: projected.totalRows,
240
376
  limit: filters.limit ?? null,
241
377
  omitted_count: omittedCount,
242
378
  has_more: omittedCount > 0,
379
+ ...(projectionMode === "digest"
380
+ ? {
381
+ activity_summary: {
382
+ window: { from: filters.from, to: filters.to },
383
+ event_count: matchingActivity.length,
384
+ item_count: projected.totalRows,
385
+ author_count: new Set(matchingActivity.map((entry) => entry.author)).size,
386
+ operation_counts: activityOperationCounts(matchingActivity),
387
+ },
388
+ }
389
+ : {}),
243
390
  ...(options.provenanceSummary === true
244
391
  ? {
245
392
  provenance_summary: summarizeHistoryProvenance(matchingActivity, vocabulary, provenanceDimensions),
@@ -253,4 +400,4 @@ export async function runActivity(options, global) {
253
400
  };
254
401
  }
255
402
  //# sourceMappingURL=activity.js.map
256
- //# debugId=a7efa5e0-5610-51ca-8288-4f5410dbcf51
403
+ //# debugId=49304d18-d722-5413-8e4d-4f2c3df4a1ca