@unbrained/pm-cli 2026.8.9 → 2026.8.11

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 (249) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +142 -80
  3. package/dist/cli/commander-usage.js +94 -17
  4. package/dist/cli/error-guidance.d.ts +10 -0
  5. package/dist/cli/error-guidance.js +76 -25
  6. package/dist/cli/help-json-payload.js +51 -16
  7. package/dist/cli/main.js +11 -6
  8. package/dist/cli/register-assurance.d.ts +8 -0
  9. package/dist/cli/register-assurance.js +52 -0
  10. package/dist/cli/register-files-lookup.js +14 -3
  11. package/dist/cli/register-mutation.js +30 -9
  12. package/dist/cli/register-operations.js +16 -11
  13. package/dist/cli-bundle/bundle-manifest.json +163 -163
  14. package/dist/cli-bundle/chunks/{chunk-RJC7TPF4.js → chunk-2OOU2AFH.js} +2 -2
  15. package/dist/cli-bundle/chunks/chunk-2RA2YTHJ.js +33 -0
  16. package/dist/cli-bundle/chunks/chunk-A2SJGHSI.js +3 -0
  17. package/dist/cli-bundle/chunks/chunk-DSKYD4LG.js +13 -0
  18. package/dist/cli-bundle/chunks/chunk-HC3GM6YY.js +194 -0
  19. package/dist/cli-bundle/chunks/chunk-IUNRVDAI.js +2 -0
  20. package/dist/cli-bundle/chunks/chunk-W7CPZGSB.js +2 -0
  21. package/dist/cli-bundle/chunks/{chunk-YC3UF2IO.js → chunk-WMEZHCFI.js} +66 -60
  22. package/dist/cli-bundle/chunks/{chunk-GMX5YOI3.js → chunk-ZU34C3LH.js} +48 -48
  23. package/dist/cli-bundle/chunks/chunk-ZXOC6HG5.js +5 -0
  24. package/dist/cli-bundle/chunks/{register-list-query-BUE7PTCU.js → register-list-query-HAUXVUPY.js} +8 -8
  25. package/dist/cli-bundle/chunks/register-mutation-7Y5U7ABT.js +20 -0
  26. package/dist/cli-bundle/chunks/register-operations-EQX3DLAZ.js +2 -0
  27. package/dist/cli-bundle/chunks/{register-setup-UQDTNTLJ.js → register-setup-NOCOOWQY.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/{chunk-KNEHLPBF.js → chunk-23FTGO3W.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/{chunk-6DO4YQWZ.js → chunk-2DL3MRTD.js} +2 -2
  30. package/dist/cli-bundle/focused-chunks/chunk-3AYKXMYX.js +2 -0
  31. package/dist/cli-bundle/focused-chunks/chunk-4AHEC74N.js +2 -0
  32. package/dist/cli-bundle/focused-chunks/{chunk-MRWVJ3ZG.js → chunk-4H5IA6AV.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/chunk-4SV3ZKG3.js +16 -0
  34. package/dist/cli-bundle/focused-chunks/chunk-55BIB6DV.js +2 -0
  35. package/dist/cli-bundle/focused-chunks/chunk-6JW6Z2P5.js +8 -0
  36. package/dist/cli-bundle/focused-chunks/chunk-BKPIY34S.js +2 -0
  37. package/dist/cli-bundle/focused-chunks/chunk-D4PIWE6D.js +2 -0
  38. package/dist/cli-bundle/focused-chunks/chunk-DPO7TEFX.js +31 -0
  39. package/dist/cli-bundle/focused-chunks/{chunk-3WVHTUAW.js → chunk-E3KCL7AY.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/chunk-ERAAFLPS.js +153 -0
  41. package/dist/cli-bundle/focused-chunks/chunk-F6E4JZKG.js +2 -0
  42. package/dist/cli-bundle/focused-chunks/chunk-FPSYO5ZG.js +18 -0
  43. package/dist/cli-bundle/focused-chunks/{chunk-73FIJONU.js → chunk-J5EKAIVD.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/chunk-KDH5OX3D.js +4 -0
  45. package/dist/cli-bundle/focused-chunks/chunk-OJ3LVVIS.js +2 -0
  46. package/dist/cli-bundle/focused-chunks/chunk-TL5M2PAY.js +3 -0
  47. package/dist/cli-bundle/focused-chunks/chunk-UDAZWT25.js +6 -0
  48. package/dist/cli-bundle/focused-chunks/chunk-VABB4L5Y.js +17 -0
  49. package/dist/cli-bundle/main.js +13 -13
  50. package/dist/cli-bundle/sdk-authoring.js +1 -1
  51. package/dist/cli-bundle/sdk-contracts.js +1 -1
  52. package/dist/cli-bundle/sdk-core.js +41 -39
  53. package/dist/cli-bundle/sdk-governance.js +1 -1
  54. package/dist/cli-bundle/sdk-graph.js +1 -1
  55. package/dist/cli-bundle/sdk-merge.js +1 -1
  56. package/dist/cli-bundle/sdk-query.js +1 -1
  57. package/dist/cli-bundle/sdk-runtime.js +1 -1
  58. package/dist/cli-bundle/sdk-testing.js +1 -1
  59. package/dist/cli-bundle/sdk.js +2 -2
  60. package/dist/core/diagnostics/remediation.js +9 -9
  61. package/dist/core/fs/fs-utils.d.ts +10 -0
  62. package/dist/core/fs/fs-utils.js +16 -4
  63. package/dist/core/item/item-format.js +3 -32
  64. package/dist/core/schema/fields-file.d.ts +1 -2
  65. package/dist/core/schema/fields-file.js +4 -11
  66. package/dist/core/schema/runtime-schema.js +3 -10
  67. package/dist/core/schema/status-defs-file.d.ts +1 -2
  68. package/dist/core/schema/status-defs-file.js +4 -32
  69. package/dist/core/schema/status-token.d.ts +2 -0
  70. package/dist/core/schema/status-token.js +32 -0
  71. package/dist/core/schema/type-workflows.d.ts +1 -2
  72. package/dist/core/schema/type-workflows.js +4 -11
  73. package/dist/core/session/session-state.d.ts +47 -0
  74. package/dist/core/session/session-state.js +207 -6
  75. package/dist/core/shared/author.d.ts +8 -2
  76. package/dist/core/shared/author.js +85 -52
  77. package/dist/core/shared/errors.d.ts +12 -0
  78. package/dist/core/shared/errors.js +2 -2
  79. package/dist/core/shared/text-normalization.d.ts +1 -1
  80. package/dist/core/shared/text-normalization.js +2 -2
  81. package/dist/sdk/agent/command-recovery.d.ts +4 -0
  82. package/dist/sdk/agent/command-recovery.js +52 -0
  83. package/dist/sdk/agent/command-suggestions.d.ts +4 -0
  84. package/dist/sdk/agent/command-suggestions.js +67 -0
  85. package/dist/sdk/agent/create-option-policy.d.ts +12 -0
  86. package/dist/sdk/agent/create-option-policy.js +32 -0
  87. package/dist/sdk/agent/item-addressing.d.ts +19 -0
  88. package/dist/sdk/agent/item-addressing.js +208 -0
  89. package/dist/sdk/agent/refusal-reachability.d.ts +40 -0
  90. package/dist/sdk/agent/refusal-reachability.js +72 -0
  91. package/dist/sdk/agent/subcommand-recovery.d.ts +40 -0
  92. package/dist/sdk/agent/subcommand-recovery.js +84 -0
  93. package/dist/sdk/cli-bootstrap.d.ts +9 -1
  94. package/dist/sdk/cli-bootstrap.js +25 -10
  95. package/dist/sdk/cli-contracts/commander-mutation-options.js +16 -4
  96. package/dist/sdk/cli-contracts/completeness.js +13 -3
  97. package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
  98. package/dist/sdk/cli-contracts/enum-contracts.js +3 -2
  99. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  100. package/dist/sdk/cli-contracts/flag-contracts.js +77 -21
  101. package/dist/sdk/cli-contracts/registration-helpers.js +10 -2
  102. package/dist/sdk/cli-contracts/runtime-contracts.js +6 -3
  103. package/dist/sdk/cli-contracts/schemas/assurance-definition.d.ts +513 -0
  104. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +251 -0
  105. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +6 -0
  106. package/dist/sdk/cli-contracts/tool-option-contracts.js +4 -2
  107. package/dist/sdk/cli-contracts/tool-parameter-tables.js +96 -4
  108. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  109. package/dist/sdk/cli-contracts/tool-schema.js +49 -6
  110. package/dist/sdk/cli-contracts.d.ts +1 -1
  111. package/dist/sdk/cli-contracts.js +3 -3
  112. package/dist/sdk/completion.js +9 -3
  113. package/dist/sdk/config.js +9 -3
  114. package/dist/sdk/context/semantic-session-attribution.d.ts +32 -0
  115. package/dist/sdk/context/semantic-session-attribution.js +83 -0
  116. package/dist/sdk/context-intent-runtime.js +8 -5
  117. package/dist/sdk/context-signal-store.d.ts +34 -0
  118. package/dist/sdk/context-signal-store.js +24 -2
  119. package/dist/sdk/core-governance.d.ts +3 -1
  120. package/dist/sdk/core-governance.js +5 -3
  121. package/dist/sdk/core.d.ts +1 -1
  122. package/dist/sdk/core.js +2 -2
  123. package/dist/sdk/dependency-flag-validation.d.ts +15 -1
  124. package/dist/sdk/dependency-flag-validation.js +54 -2
  125. package/dist/sdk/error-code-catalog.d.ts +13 -0
  126. package/dist/sdk/error-code-catalog.js +35 -2
  127. package/dist/sdk/extension.js +18 -17
  128. package/dist/sdk/files.d.ts +11 -0
  129. package/dist/sdk/files.js +82 -24
  130. package/dist/sdk/generated-error-code-catalog.js +104 -13
  131. package/dist/sdk/governance/assurance-action-contracts.d.ts +7 -0
  132. package/dist/sdk/governance/assurance-action-contracts.js +5 -0
  133. package/dist/sdk/governance/assurance-action.d.ts +70 -0
  134. package/dist/sdk/governance/assurance-action.js +198 -0
  135. package/dist/sdk/governance/assurance-limits.d.ts +7 -0
  136. package/dist/sdk/governance/assurance-limits.js +11 -0
  137. package/dist/sdk/governance/assurance-runtime.d.ts +20 -0
  138. package/dist/sdk/governance/assurance-runtime.js +131 -0
  139. package/dist/sdk/governance/assurance.d.ts +432 -0
  140. package/dist/sdk/governance/assurance.js +689 -0
  141. package/dist/sdk/governance/health.js +14 -7
  142. package/dist/sdk/governance/provenance-health.d.ts +13 -0
  143. package/dist/sdk/governance/provenance-health.js +63 -17
  144. package/dist/sdk/governance/validate-item-reader.d.ts +13 -0
  145. package/dist/sdk/governance/validate-item-reader.js +18 -0
  146. package/dist/sdk/governance/validate.d.ts +2 -2
  147. package/dist/sdk/governance/validate.js +15 -6
  148. package/dist/sdk/graph/run.js +8 -3
  149. package/dist/sdk/index.d.ts +10 -1
  150. package/dist/sdk/index.js +12 -3
  151. package/dist/sdk/lifecycle/claim.js +18 -3
  152. package/dist/sdk/lifecycle/close.js +17 -14
  153. package/dist/sdk/lifecycle/create.d.ts +2 -0
  154. package/dist/sdk/lifecycle/create.js +62 -9
  155. package/dist/sdk/lifecycle/focus.js +13 -3
  156. package/dist/sdk/lifecycle/plan.js +8 -3
  157. package/dist/sdk/lifecycle/update-many.js +39 -27
  158. package/dist/sdk/lifecycle/update.d.ts +6 -1
  159. package/dist/sdk/lifecycle/update.js +47 -10
  160. package/dist/sdk/merge/index.d.ts +1 -1
  161. package/dist/sdk/merge/index.js +3 -3
  162. package/dist/sdk/merge/install.d.ts +4 -0
  163. package/dist/sdk/merge/install.js +28 -16
  164. package/dist/sdk/merge/receipts.d.ts +3 -0
  165. package/dist/sdk/merge/receipts.js +81 -17
  166. package/dist/sdk/output-projection.js +24 -4
  167. package/dist/sdk/provenance.d.ts +38 -0
  168. package/dist/sdk/provenance.js +64 -2
  169. package/dist/sdk/query/context.d.ts +2 -0
  170. package/dist/sdk/query/context.js +24 -10
  171. package/dist/sdk/query/light-metadata.d.ts +3 -0
  172. package/dist/sdk/query/light-metadata.js +19 -0
  173. package/dist/sdk/runtime-extended-actions.js +22 -5
  174. package/dist/sdk/runtime-primitives.d.ts +2 -0
  175. package/dist/sdk/runtime-primitives.js +4 -2
  176. package/dist/sdk/runtime.d.ts +8 -1
  177. package/dist/sdk/runtime.js +37 -28
  178. package/dist/sdk/schema-migration.js +7 -9
  179. package/dist/sdk/similarity-scoring.d.ts +1 -2
  180. package/dist/sdk/similarity-scoring.js +4 -16
  181. package/dist/sdk/telemetry.js +7 -4
  182. package/dist/sdk/traceability/runtime-files-lookup.d.ts +8 -0
  183. package/dist/sdk/traceability/runtime-files-lookup.js +33 -0
  184. package/dist/sdk/traceability/source-traceability.d.ts +102 -0
  185. package/dist/sdk/traceability/source-traceability.js +293 -0
  186. package/dist/sdk/workspace-snapshot.d.ts +4 -0
  187. package/dist/sdk/workspace-snapshot.js +24 -11
  188. package/dist/types.d.ts +8 -2
  189. package/dist/types.js +2 -2
  190. package/docs/AGENT_GUIDE.md +3 -1
  191. package/docs/ASSURANCE.md +132 -0
  192. package/docs/COMMANDS.md +8 -5
  193. package/docs/MERGE_SAFETY.md +7 -5
  194. package/docs/README.md +3 -5
  195. package/docs/READ_OUTPUT_CONTRACTS.md +2 -2
  196. package/docs/RELEASING.md +9 -5
  197. package/docs/SDK.md +44 -8
  198. package/docs/SDK_AGENT_SESSION_CONTEXT.md +43 -6
  199. package/docs/SDK_CONTEXT.md +97 -0
  200. package/docs/SDK_CONTEXT_INTEGRITY.md +18 -3
  201. package/docs/SDK_EVIDENCE_TRACEABILITY.md +39 -1
  202. package/docs/SDK_RUNTIME_BOUNDARIES.md +36 -1
  203. package/docs/TESTING.md +12 -9
  204. package/docs/agent-task-token-baseline.json +2 -2
  205. package/docs/generated/AGENT_COMMAND_SURFACE.md +1 -0
  206. package/marketplace.json +2 -2
  207. package/package.json +7 -6
  208. package/packages/pm-beads/package.json +1 -1
  209. package/packages/pm-calendar/package.json +1 -1
  210. package/packages/pm-command-kit/package.json +1 -1
  211. package/packages/pm-digital-twin/package.json +1 -1
  212. package/packages/pm-governance-audit/package.json +1 -1
  213. package/packages/pm-guide-shell/package.json +1 -1
  214. package/packages/pm-kanban/package.json +1 -1
  215. package/packages/pm-lifecycle-hooks/package.json +1 -1
  216. package/packages/pm-linked-test-adapters/package.json +1 -1
  217. package/packages/pm-search-advanced/package.json +1 -1
  218. package/packages/pm-templates/extensions/templates/index.ts +9 -3
  219. package/packages/pm-templates/package.json +1 -1
  220. package/packages/pm-todos/package.json +1 -1
  221. package/packages/pm-vcs/package.json +1 -1
  222. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  223. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  224. package/sdk/public-surface.json +1028 -48
  225. package/dist/cli-bundle/chunks/chunk-2DTCZXSD.js +0 -13
  226. package/dist/cli-bundle/chunks/chunk-5JO6R4BS.js +0 -3
  227. package/dist/cli-bundle/chunks/chunk-5KN4DZYV.js +0 -194
  228. package/dist/cli-bundle/chunks/chunk-EF43KODO.js +0 -2
  229. package/dist/cli-bundle/chunks/chunk-HUV2Z7IS.js +0 -28
  230. package/dist/cli-bundle/chunks/chunk-MHBVCUF2.js +0 -2
  231. package/dist/cli-bundle/chunks/chunk-PYO5GZU6.js +0 -5
  232. package/dist/cli-bundle/chunks/register-mutation-FC3XLVIK.js +0 -20
  233. package/dist/cli-bundle/chunks/register-operations-YH2WAOXU.js +0 -2
  234. package/dist/cli-bundle/focused-chunks/chunk-2VVP5RAA.js +0 -153
  235. package/dist/cli-bundle/focused-chunks/chunk-3GSFUDAI.js +0 -2
  236. package/dist/cli-bundle/focused-chunks/chunk-4H6MVCK3.js +0 -16
  237. package/dist/cli-bundle/focused-chunks/chunk-54TZJ4BM.js +0 -2
  238. package/dist/cli-bundle/focused-chunks/chunk-5NK5TJ5D.js +0 -2
  239. package/dist/cli-bundle/focused-chunks/chunk-C3GCHDSQ.js +0 -31
  240. package/dist/cli-bundle/focused-chunks/chunk-JGRSQZJT.js +0 -18
  241. package/dist/cli-bundle/focused-chunks/chunk-NL57J7BZ.js +0 -4
  242. package/dist/cli-bundle/focused-chunks/chunk-P6BBIQRG.js +0 -6
  243. package/dist/cli-bundle/focused-chunks/chunk-PZAGVQNN.js +0 -3
  244. package/dist/cli-bundle/focused-chunks/chunk-QDAO3XEK.js +0 -14
  245. package/dist/cli-bundle/focused-chunks/chunk-T4IGQCSY.js +0 -2
  246. package/dist/cli-bundle/focused-chunks/chunk-U46GQJNY.js +0 -2
  247. package/dist/cli-bundle/focused-chunks/chunk-VRXJSGIT.js +0 -8
  248. package/dist/cli-bundle/focused-chunks/chunk-XC2ZW3CJ.js +0 -2
  249. package/dist/cli-bundle/focused-chunks/chunk-ZG54B4XG.js +0 -2
@@ -4,13 +4,14 @@
4
4
  * Provides shared primitives and utilities for Author.
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]="a89b5501-1909-5ea8-b34b-8ca9b4bc5dd5")}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]="e0ab2d6f-0925-540d-8d24-a7f0687b4bf0")}catch(e){}}();
8
8
  import { AsyncLocalStorage } from "node:async_hooks";
9
9
  import { createHash } from "node:crypto";
10
10
  import fs from "node:fs";
11
11
  import os from "node:os";
12
12
  import path from "node:path";
13
13
  import { resolveAgentSessionContextFromSignals, } from "./agent-session-context.js";
14
+ import { readAgentSemanticAttributionSync, } from "../session/session-state.js";
14
15
  /** Stable built-in provenance dimensions understood by the default runtime. */
15
16
  export const AGENT_PROVENANCE_DIMENSIONS = [
16
17
  "model",
@@ -191,15 +192,6 @@ function firstEnvironmentValue(env, keys) {
191
192
  return undefined;
192
193
  }
193
194
  function provenanceFromArgv(argv, dimension) {
194
- const flaggedValue = provenanceFlagValue(argv, dimension);
195
- if (flaggedValue !== undefined)
196
- return flaggedValue;
197
- if (dimension === "topic") {
198
- return argv
199
- .slice(0, 16)
200
- .map((token) => token.trim())
201
- .find((token) => /^pm-[a-z0-9][a-z0-9-]{2,63}$/u.test(token));
202
- }
203
195
  if (dimension === "role") {
204
196
  const command = argv
205
197
  .slice(0, 8)
@@ -241,7 +233,10 @@ const AGENT_ROLE_VALUES = new Set([
241
233
  function normalizeProvenanceValue(dimension, value) {
242
234
  if (dimension !== "role" || value === undefined)
243
235
  return value;
244
- const normalized = value.trim().toLowerCase().replaceAll(/[_\s]+/gu, "-");
236
+ const normalized = value
237
+ .trim()
238
+ .toLowerCase()
239
+ .replaceAll(/[_\s]+/gu, "-");
245
240
  return AGENT_ROLE_VALUES.has(normalized) ? normalized : undefined;
246
241
  }
247
242
  function boundedProvenanceValue(provenance, dimension) {
@@ -310,13 +305,23 @@ function resolveProvenanceProbe(dimension, signals, env, descriptor) {
310
305
  }
311
306
  if (resolver === "ai_agent_version") {
312
307
  const value = nonBlank(env.AI_AGENT);
313
- if (!value)
308
+ if (!value ||
309
+ !descriptor ||
310
+ !literalSignalMatches(value, descriptor.harness)) {
314
311
  return undefined;
312
+ }
315
313
  const match = /(?:^|[@/\s])v?(\d+\.\d+(?:\.\d+)?(?:[-+][A-Za-z0-9.-]+)?)$/u.exec(value);
316
314
  return match?.[1]?.slice(0, 256);
317
315
  }
318
316
  return undefined;
319
317
  }
318
+ function provenanceResolverHasInput(resolver, descriptor, env) {
319
+ if (resolver === "ai_agent_version") {
320
+ const value = nonBlank(env.AI_AGENT);
321
+ return (value !== undefined && literalSignalMatches(value, descriptor.harness));
322
+ }
323
+ return nonBlank(env.CLAUDE_CODE_SESSION_ID) !== undefined;
324
+ }
320
325
  function effectiveHarnessDetectionSignals(signals) {
321
326
  if (signals)
322
327
  return signals;
@@ -334,7 +339,31 @@ function descriptorMatchesSignals(descriptor, env, labels, clientName) {
334
339
  const clientMatch = descriptor.client_names.some((name) => clientName === name || literalSignalMatches(clientName, name));
335
340
  return environmentMatch || argvMatch || clientMatch;
336
341
  }
337
- function resolveAgentProvenanceObservation(dimension, signals, env, descriptor, sessionContext) {
342
+ function inferredProvenanceObservation(dimension, semanticAttribution) {
343
+ if (!semanticAttribution)
344
+ return undefined;
345
+ let value;
346
+ if (dimension === "topic")
347
+ value = semanticAttribution.topic;
348
+ if (dimension === "role")
349
+ value = semanticAttribution.role;
350
+ if (!value)
351
+ return undefined;
352
+ return {
353
+ value,
354
+ source: "inferred",
355
+ confidence: semanticAttribution.confidence,
356
+ rule_version: semanticAttribution.rule_version,
357
+ evidence: semanticAttribution.evidence,
358
+ };
359
+ }
360
+ function firstProvenanceObservation(candidates) {
361
+ const observed = candidates.find(([value]) => value !== undefined);
362
+ return observed?.[0]
363
+ ? { value: observed[0], source: observed[1] }
364
+ : undefined;
365
+ }
366
+ function resolveAgentProvenanceObservation(dimension, signals, env, descriptor, sessionContext, semanticAttribution) {
338
367
  const overrideKey = `PM_AGENT_${dimension.toUpperCase().replaceAll("-", "_")}`;
339
368
  const hostResolvedDimensions = new Set([
340
369
  ...AGENT_PROVENANCE_DIMENSIONS,
@@ -342,9 +371,11 @@ function resolveAgentProvenanceObservation(dimension, signals, env, descriptor,
342
371
  ]);
343
372
  let overrideValue;
344
373
  let argvValue;
374
+ let argvFlagValue;
345
375
  if (hostResolvedDimensions.has(dimension)) {
346
376
  overrideValue = normalizeProvenanceValue(dimension, nonBlank(env[overrideKey])?.slice(0, 256));
347
- argvValue = provenanceFromArgv(signals.argv ?? [], dimension);
377
+ argvFlagValue = normalizeProvenanceValue(dimension, provenanceFlagValue(signals.argv ?? [], dimension));
378
+ argvValue = normalizeProvenanceValue(dimension, provenanceFromArgv(signals.argv ?? [], dimension));
348
379
  }
349
380
  const environmentKeysByDimension = {
350
381
  ...descriptor?.provenance_environment_keys,
@@ -354,31 +385,33 @@ function resolveAgentProvenanceObservation(dimension, signals, env, descriptor,
354
385
  ...signals.client_info?.provenance,
355
386
  model: signals.client_info?.model,
356
387
  };
357
- const values = [
358
- overrideValue,
359
- boundedProvenanceValue(sessionContext?.provenance, dimension),
360
- normalizeProvenanceValue(dimension, firstEnvironmentValue(env, environmentKeysByDimension[dimension])),
361
- normalizeProvenanceValue(dimension, boundedProvenanceValue(clientProvenance, dimension)),
362
- normalizeProvenanceValue(dimension, boundedProvenanceValue(signals.provenance, dimension)),
363
- normalizeProvenanceValue(dimension, argvValue),
364
- resolveProvenanceProbe(dimension, signals, env, descriptor),
365
- ];
366
- const sources = [
367
- "override",
368
- "session",
369
- "environment",
370
- "mcp_client",
371
- "host",
372
- "argv",
373
- "probe",
374
- ];
375
- const candidates = sources.map((source, index) => ({
376
- value: values[index],
377
- source,
378
- }));
379
- return candidates.find((candidate) => candidate.value !== undefined);
388
+ const sessionValue = boundedProvenanceValue(sessionContext?.provenance, dimension);
389
+ const environmentValue = normalizeProvenanceValue(dimension, firstEnvironmentValue(env, environmentKeysByDimension[dimension]));
390
+ const clientValue = normalizeProvenanceValue(dimension, boundedProvenanceValue(clientProvenance, dimension));
391
+ const hostValue = normalizeProvenanceValue(dimension, boundedProvenanceValue(signals.provenance, dimension));
392
+ const probeValue = resolveProvenanceProbe(dimension, signals, env, descriptor);
393
+ const observed = firstProvenanceObservation([
394
+ [overrideValue, "override"],
395
+ [sessionValue, "session"],
396
+ [argvFlagValue, "argv"],
397
+ [environmentValue, "environment"],
398
+ [clientValue, "mcp_client"],
399
+ [hostValue, "host"],
400
+ [probeValue, "probe"],
401
+ ]);
402
+ return (observed ??
403
+ inferredProvenanceObservation(dimension, semanticAttribution) ??
404
+ (argvValue ? { value: argvValue, source: "argv" } : undefined));
380
405
  }
381
- function resolveAgentProvenance(signals, env, descriptor, sessionContext) {
406
+ function resolveAgentInstance(harness, session) {
407
+ if (!harness || !session)
408
+ return undefined;
409
+ return createHash("sha256")
410
+ .update(`pm-agent-instance:v1\0${harness}\0${session}`)
411
+ .digest("hex")
412
+ .slice(0, 24);
413
+ }
414
+ function resolveAgentProvenance(signals, env, descriptor, sessionContext, semanticAttribution) {
382
415
  const descriptorDimensions = Object.keys(descriptor?.provenance_environment_keys ?? {});
383
416
  const dimensions = new Set([
384
417
  ...AGENT_PROVENANCE_DIMENSIONS,
@@ -390,7 +423,7 @@ function resolveAgentProvenance(signals, env, descriptor, sessionContext) {
390
423
  ]);
391
424
  const observations = {};
392
425
  for (const dimension of dimensions) {
393
- const observed = resolveAgentProvenanceObservation(dimension, signals, env, descriptor, sessionContext);
426
+ const observed = resolveAgentProvenanceObservation(dimension, signals, env, descriptor, sessionContext, semanticAttribution);
394
427
  if (observed) {
395
428
  observations[dimension] = observed;
396
429
  }
@@ -482,18 +515,18 @@ export function detectAgentIdentity(signals) {
482
515
  const clientName = effectiveSignals.client_info?.name.trim().toLowerCase() ?? "";
483
516
  const descriptor = descriptors.find((candidate) => descriptorMatchesSignals(candidate, env, labels, clientName));
484
517
  const sessionContext = resolveAgentSessionContextFromSignals(effectiveSignals, env);
485
- const provenance = resolveAgentProvenance(effectiveSignals, env, descriptor, sessionContext);
486
- const modelCandidate = provenance.model;
487
518
  const session = [
488
519
  firstEnvironmentValue(env, descriptor?.session_environment_keys),
489
520
  nonBlank(effectiveSignals.client_info?.session)?.slice(0, 256),
490
521
  ].find((candidate) => candidate !== undefined);
491
- const instance = descriptor?.harness && session
492
- ? createHash("sha256")
493
- .update(`pm-agent-instance:v1\0${descriptor.harness}\0${session}`)
494
- .digest("hex")
495
- .slice(0, 24)
496
- : undefined;
522
+ const instance = resolveAgentInstance(descriptor?.harness, session);
523
+ const semanticAttribution = readAgentSemanticAttributionSync({
524
+ cwd: effectiveSignals.cwd ?? process.cwd(),
525
+ env,
526
+ key: instance,
527
+ });
528
+ const provenance = resolveAgentProvenance(effectiveSignals, env, descriptor, sessionContext, semanticAttribution);
529
+ const modelCandidate = provenance.model;
497
530
  const entries = [
498
531
  ["harness", descriptor?.harness],
499
532
  ["model", modelCandidate?.value],
@@ -522,9 +555,7 @@ function resolveProvenanceOutcome(dimension, identity, descriptor, env, probesEn
522
555
  };
523
556
  }
524
557
  if (resolver) {
525
- const resolverHasInput = resolver === "ai_agent_version"
526
- ? nonBlank(env.AI_AGENT) !== undefined
527
- : nonBlank(env.CLAUDE_CODE_SESSION_ID) !== undefined;
558
+ const resolverHasInput = provenanceResolverHasInput(resolver, descriptor, env);
528
559
  const status = resolverHasInput && probesEnabled ? "failed" : "unavailable";
529
560
  const reason = !resolverHasInput
530
561
  ? "harness_unavailable"
@@ -534,7 +565,9 @@ function resolveProvenanceOutcome(dimension, identity, descriptor, env, probesEn
534
565
  return { status, reason, resolver, rule_version: "v1" };
535
566
  }
536
567
  return {
537
- status: "unavailable",
568
+ status: descriptor?.provenance_unavailable_dimensions.includes(dimension)
569
+ ? "unavailable"
570
+ : "not_configured",
538
571
  reason: descriptor?.provenance_unavailable_dimensions.includes(dimension)
539
572
  ? "harness_unavailable"
540
573
  : "resolver_not_configured",
@@ -680,4 +713,4 @@ export function resolveAuthor(candidate, fallback) {
680
713
  return identity.author;
681
714
  }
682
715
  //# sourceMappingURL=author.js.map
683
- //# debugId=a89b5501-1909-5ea8-b34b-8ca9b4bc5dd5
716
+ //# debugId=e0ab2d6f-0925-540d-8d24-a7f0687b4bf0
@@ -19,6 +19,14 @@ export interface PmCliErrorRecoveryPayload {
19
19
  missing_required_fields?: string[];
20
20
  /** Value that configures or reports suggested flags for this contract. */
21
21
  suggested_flags?: string[];
22
+ /** Complete allowed value set for a refused positional or enum token. */
23
+ allowed_values?: string[];
24
+ /** Ranked command paths that accept an option rejected on the attempted path. */
25
+ candidate_commands?: string[];
26
+ /** Complete number of accepting command paths before the recovery ceiling. */
27
+ candidate_commands_total?: number;
28
+ /** Whether additional accepting command paths were omitted from this payload. */
29
+ candidate_commands_truncated?: boolean;
22
30
  /** Value that configures or reports suggested retry for this contract. */
23
31
  suggested_retry?: string;
24
32
  /** Elapsed time in milliseconds for retry after. */
@@ -60,6 +68,10 @@ export interface PmCliErrorContext {
60
68
  examples?: string[];
61
69
  /** Value that configures or reports next steps for this contract. */
62
70
  nextSteps?: string[];
71
+ /** Exact selectors that could not be matched by a lossless removal. */
72
+ unmatched?: string[];
73
+ /** Local dependency targets that could not be resolved before mutation. */
74
+ unresolved_targets?: string[];
63
75
  /** Available history bounds for a failed point-in-time read or restore target. */
64
76
  valid_range?: {
65
77
  /** Earliest available one-based version, or null for an empty stream. */
@@ -1,6 +1,6 @@
1
1
  /** Implements the exported pm cli error runtime abstraction for core/shared/errors.ts. */
2
2
 
3
- !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]="c2c9251e-86bf-5a92-acdb-581e59d269d8")}catch(e){}}();
3
+ !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]="df6f6758-f972-5bf4-aaa8-b16dd9a247f3")}catch(e){}}();
4
4
  export class PmCliError extends Error {
5
5
  /** Value that configures or reports exit code for this contract. */
6
6
  exitCode;
@@ -18,4 +18,4 @@ export class PmCliError extends Error {
18
18
  }
19
19
  }
20
20
  //# sourceMappingURL=errors.js.map
21
- //# debugId=c2c9251e-86bf-5a92-acdb-581e59d269d8
21
+ //# debugId=df6f6758-f972-5bf4-aaa8-b16dd9a247f3
@@ -8,4 +8,4 @@ export declare function normalizeLowercaseWhitespace(value: string): string;
8
8
  /** Implements tokenize alpha numeric for the public runtime surface of this module. */
9
9
  export declare function tokenizeAlphaNumeric(value: string): string[];
10
10
  /** Implements jaccard similarity for the public runtime surface of this module. */
11
- export declare function jaccardSimilarity(leftTokens: string[], rightTokens: string[]): number;
11
+ export declare function jaccardSimilarity(leftTokens: readonly string[], rightTokens: readonly string[]): number;
@@ -5,7 +5,7 @@
5
5
  */
6
6
  /** Normalizes text to lowercase whitespace-collapsed form for stable matching and comparison. */
7
7
 
8
- !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]="7288620a-5aa7-50f9-a271-45b2722a4887")}catch(e){}}();
8
+ !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]="3ad30a32-0f83-5473-b0a3-349e271d8378")}catch(e){}}();
9
9
  export function normalizeLowercaseWhitespace(value) {
10
10
  return value.trim().toLowerCase().replace(/\s+/g, " ");
11
11
  }
@@ -36,4 +36,4 @@ export function jaccardSimilarity(leftTokens, rightTokens) {
36
36
  return intersection / union;
37
37
  }
38
38
  //# sourceMappingURL=text-normalization.js.map
39
- //# debugId=7288620a-5aa7-50f9-a271-45b2722a4887
39
+ //# debugId=3ad30a32-0f83-5473-b0a3-349e271d8378
@@ -0,0 +1,4 @@
1
+ /** Resolve the truthful placeholder for a missing flag from its contract. */
2
+ export declare function resolveMissingOptionPlaceholder(commandName: string, missingLabel: string): string | null | undefined;
3
+ /** Preserve an attempted argv vector and insert each missing option before `--`. */
4
+ export declare function renderMissingOptionRetry(invocationArgv: string[], commandName: string, missingLabels: string[]): string | undefined;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @module sdk/command-recovery
3
+ *
4
+ * Builds executable recovery commands from tokenized argv and declared CLI
5
+ * flag domains. Display labels are normalized back to real flag tokens and
6
+ * supplied arguments are preserved byte-for-token.
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]="ab87f46c-c9b4-51d1-a712-fbce7c79fca9")}catch(e){}}();
10
+ import { renderPmCommand } from "../command-line.js";
11
+ import { resolveSubcommandFlagContractsForCommand } from "../cli-contracts.js";
12
+ function normalizeMissingFlag(label) {
13
+ const match = label.trim().match(/--[a-z0-9][a-z0-9_-]*/i);
14
+ return match?.[0]?.replaceAll("_", "-").toLowerCase();
15
+ }
16
+ /** Resolve the truthful placeholder for a missing flag from its contract. */
17
+ export function resolveMissingOptionPlaceholder(commandName, missingLabel) {
18
+ const flag = normalizeMissingFlag(missingLabel);
19
+ if (!flag)
20
+ return undefined;
21
+ const contract = resolveSubcommandFlagContractsForCommand(commandName).find((entry) => entry.flag === flag || entry.aliases?.includes(flag));
22
+ if (!contract)
23
+ return "<value>";
24
+ if (contract.value_type === "boolean") {
25
+ return null;
26
+ }
27
+ return `<${contract.value_name ?? "value"}>`;
28
+ }
29
+ /** Preserve an attempted argv vector and insert each missing option before `--`. */
30
+ export function renderMissingOptionRetry(invocationArgv, commandName, missingLabels) {
31
+ const retry = [...invocationArgv];
32
+ const terminatorIndex = retry.indexOf("--");
33
+ let insertionIndex = terminatorIndex < 0 ? retry.length : terminatorIndex;
34
+ for (const label of missingLabels) {
35
+ const flag = normalizeMissingFlag(label);
36
+ if (!flag ||
37
+ retry
38
+ .slice(0, insertionIndex)
39
+ .some((token) => token === flag || token.startsWith(`${flag}=`))) {
40
+ continue;
41
+ }
42
+ const placeholder = resolveMissingOptionPlaceholder(commandName, flag);
43
+ const recoveredOption = placeholder ? [flag, placeholder] : [flag];
44
+ retry.splice(insertionIndex, 0, ...recoveredOption);
45
+ insertionIndex += recoveredOption.length;
46
+ }
47
+ return retry.length === invocationArgv.length
48
+ ? undefined
49
+ : renderPmCommand(retry);
50
+ }
51
+ //# sourceMappingURL=command-recovery.js.map
52
+ //# debugId=ab87f46c-c9b4-51d1-a712-fbce7c79fca9
@@ -0,0 +1,4 @@
1
+ /** Score one command path for a guessed command token; lower is better. */
2
+ export declare function scoreCommandPathMatch(commandPath: string, queryToken: string): number;
3
+ /** Rank available command paths for one guessed token. */
4
+ export declare function rankCommandPaths(commandPaths: string[], queryToken: string): string[];
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @module sdk/command-suggestions
3
+ *
4
+ * Provides deterministic, agent-oriented command suggestion ranking. Semantic
5
+ * verb aliases rank first, bounded edit distance second, and substring matches
6
+ * last so `log` never prefers `catalog` over item history commands.
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]="71e5a870-f62f-5252-b4e9-e1a42e36009f")}catch(e){}}();
10
+ import { levenshteinDistanceWithinLimit } from "../../core/shared/levenshtein.js";
11
+ const COMMAND_SYNONYMS = {
12
+ add: ["create", "append"],
13
+ fetch: ["get"],
14
+ inspect: ["get", "health"],
15
+ log: ["history", "comments", "notes"],
16
+ ls: ["list"],
17
+ pause: ["release"],
18
+ read: ["get"],
19
+ remove: ["delete"],
20
+ rm: ["delete"],
21
+ show: ["get"],
22
+ };
23
+ /** Score one command path for a guessed command token; lower is better. */
24
+ export function scoreCommandPathMatch(commandPath, queryToken) {
25
+ const normalizedPath = commandPath.trim().toLowerCase();
26
+ const normalizedToken = queryToken.trim().toLowerCase();
27
+ if (normalizedToken.length === 0)
28
+ return Number.POSITIVE_INFINITY;
29
+ const segments = normalizedPath.split(" ");
30
+ const semanticIndex = COMMAND_SYNONYMS[normalizedToken]?.indexOf(normalizedPath);
31
+ if (semanticIndex !== undefined && semanticIndex >= 0)
32
+ return semanticIndex;
33
+ if (normalizedPath === normalizedToken)
34
+ return 10;
35
+ if (segments.includes(normalizedToken))
36
+ return 11;
37
+ if (segments.some((segment) => segment.startsWith(normalizedToken)))
38
+ return 12;
39
+ const maxDistance = normalizedToken.length >= 5 ? 2 : 1;
40
+ let bestDistance = Number.POSITIVE_INFINITY;
41
+ for (const segment of segments) {
42
+ const distance = levenshteinDistanceWithinLimit(segment, normalizedToken, maxDistance);
43
+ if (distance !== null)
44
+ bestDistance = Math.min(bestDistance, distance);
45
+ }
46
+ if (Number.isFinite(bestDistance))
47
+ return 20 + bestDistance;
48
+ if (normalizedPath.includes(normalizedToken))
49
+ return 30;
50
+ return Number.POSITIVE_INFINITY;
51
+ }
52
+ /** Rank available command paths for one guessed token. */
53
+ export function rankCommandPaths(commandPaths, queryToken) {
54
+ return commandPaths
55
+ .map((path) => ({ path, score: scoreCommandPathMatch(path, queryToken) }))
56
+ .filter((entry) => Number.isFinite(entry.score))
57
+ .sort((left, right) => {
58
+ if (left.score !== right.score)
59
+ return left.score - right.score;
60
+ if (left.path === right.path)
61
+ return 0;
62
+ return left.path < right.path ? -1 : 1;
63
+ })
64
+ .map((entry) => entry.path);
65
+ }
66
+ //# sourceMappingURL=command-suggestions.js.map
67
+ //# debugId=71e5a870-f62f-5252-b4e9-e1a42e36009f
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @module sdk/create-option-policy
3
+ *
4
+ * Defines explicit-empty assertions for repeatable create options. A strict
5
+ * schema can require that an agent considers a collection without forcing it
6
+ * to invent an entry: the corresponding `--clear-*` flag is an auditable,
7
+ * truthful answer that the collection is intentionally empty.
8
+ */
9
+ /** Return the explicit-empty flag for a repeatable create option. */
10
+ export declare function resolveCreateExplicitEmptyFlag(optionKey: string): string | undefined;
11
+ /** Return whether a create option can be satisfied by an explicit empty set. */
12
+ export declare function supportsCreateExplicitEmpty(optionKey: string): boolean;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @module sdk/create-option-policy
3
+ *
4
+ * Defines explicit-empty assertions for repeatable create options. A strict
5
+ * schema can require that an agent considers a collection without forcing it
6
+ * to invent an entry: the corresponding `--clear-*` flag is an auditable,
7
+ * truthful answer that the collection is intentionally empty.
8
+ */
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]="002f45a2-edc3-5aa0-9af8-d9b1dfecc097")}catch(e){}}();
11
+ const CREATE_REPEATABLE_CLEAR_FLAGS = {
12
+ comment: "--clear-comments",
13
+ dep: "--clear-deps",
14
+ doc: "--clear-docs",
15
+ event: "--clear-events",
16
+ file: "--clear-files",
17
+ learning: "--clear-learnings",
18
+ note: "--clear-notes",
19
+ reminder: "--clear-reminders",
20
+ test: "--clear-tests",
21
+ typeOption: "--clear-type-options",
22
+ };
23
+ /** Return the explicit-empty flag for a repeatable create option. */
24
+ export function resolveCreateExplicitEmptyFlag(optionKey) {
25
+ return CREATE_REPEATABLE_CLEAR_FLAGS[optionKey];
26
+ }
27
+ /** Return whether a create option can be satisfied by an explicit empty set. */
28
+ export function supportsCreateExplicitEmpty(optionKey) {
29
+ return resolveCreateExplicitEmptyFlag(optionKey) !== undefined;
30
+ }
31
+ //# sourceMappingURL=create-option-policy.js.map
32
+ //# debugId=002f45a2-edc3-5aa0-9af8-d9b1dfecc097
@@ -0,0 +1,19 @@
1
+ /** Result of normalizing one item-addressed invocation. */
2
+ export interface ItemAddressInvocationResult {
3
+ /** Canonical argv with an `--id` value moved into positional-id location. */
4
+ argv: string[];
5
+ /** Whether argv changed. */
6
+ changed: boolean;
7
+ /** Whether both positional and named item ids were supplied. */
8
+ conflict: boolean;
9
+ /** Resolved named item id when one was present. */
10
+ itemId?: string;
11
+ }
12
+ /** Return whether a command participates in the shared item-id alias contract. */
13
+ export declare function supportsItemIdAlias(commandName: string | undefined): boolean;
14
+ /**
15
+ * Normalize `pm <command> --id <value>` to the command's positional id form.
16
+ * The transformation is lossless for every other argument and reports a
17
+ * conflict instead of guessing when both forms are present.
18
+ */
19
+ export declare function normalizeItemAddressInvocation(argv: string[]): ItemAddressInvocationResult;