@unbrained/pm-cli 2026.8.8 → 2026.8.10

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 (222) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +59 -0
  3. package/dist/cli/commander-usage.js +17 -12
  4. package/dist/cli/help-json-payload.js +51 -16
  5. package/dist/cli/main.js +7 -6
  6. package/dist/cli-bundle/bundle-manifest.json +162 -162
  7. package/dist/cli-bundle/chunks/chunk-2QYH4QMI.js +30 -0
  8. package/dist/cli-bundle/chunks/{chunk-2ZMXX3Q6.js → chunk-EBO7OUUE.js} +70 -70
  9. package/dist/cli-bundle/chunks/{chunk-NUXRRNAB.js → chunk-ETML5C6H.js} +48 -48
  10. package/dist/cli-bundle/chunks/chunk-JUDU4RO4.js +194 -0
  11. package/dist/cli-bundle/chunks/chunk-JZSNADRR.js +5 -0
  12. package/dist/cli-bundle/chunks/chunk-MENWVGJW.js +2 -0
  13. package/dist/cli-bundle/chunks/{chunk-ALDHXLPS.js → chunk-S4EITGLA.js} +2 -2
  14. package/dist/cli-bundle/chunks/chunk-TIGKWVLA.js +13 -0
  15. package/dist/cli-bundle/chunks/{chunk-CBLA33YK.js → chunk-TRWXF476.js} +2 -2
  16. package/dist/cli-bundle/chunks/chunk-TSLDTJLQ.js +2 -0
  17. package/dist/cli-bundle/chunks/{register-list-query-WFZAMJHZ.js → register-list-query-OJ6ZXKV4.js} +2 -2
  18. package/dist/cli-bundle/chunks/{register-mutation-SOKKOTHQ.js → register-mutation-DKI7QC7O.js} +2 -2
  19. package/dist/cli-bundle/chunks/register-operations-P5OGMT6I.js +2 -0
  20. package/dist/cli-bundle/chunks/{register-setup-2HL5ZHMK.js → register-setup-S3KT2LTH.js} +2 -2
  21. package/dist/cli-bundle/focused-chunks/{chunk-ANTMGYLI.js → chunk-2COZ67XT.js} +2 -2
  22. package/dist/cli-bundle/focused-chunks/chunk-2EXI2DKR.js +4 -0
  23. package/dist/cli-bundle/focused-chunks/{chunk-YSAHYUXX.js → chunk-34SX654S.js} +2 -2
  24. package/dist/cli-bundle/focused-chunks/chunk-36FTZ2NT.js +2 -0
  25. package/dist/cli-bundle/focused-chunks/chunk-3CQECMKR.js +16 -0
  26. package/dist/cli-bundle/focused-chunks/chunk-75774JWP.js +6 -0
  27. package/dist/cli-bundle/focused-chunks/chunk-7UN6BHHO.js +2 -0
  28. package/dist/cli-bundle/focused-chunks/{chunk-TCSAPH33.js → chunk-CHIBMEZR.js} +6 -6
  29. package/dist/cli-bundle/focused-chunks/chunk-DZGAHZZV.js +3 -0
  30. package/dist/cli-bundle/focused-chunks/chunk-FF4MNAYB.js +153 -0
  31. package/dist/cli-bundle/focused-chunks/chunk-GHTN2ILR.js +2 -0
  32. package/dist/cli-bundle/focused-chunks/chunk-I4YM2I7S.js +2 -0
  33. package/dist/cli-bundle/focused-chunks/chunk-IMDTEN7K.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/chunk-IW43E4XL.js +2 -0
  35. package/dist/cli-bundle/focused-chunks/chunk-JMVA4HKR.js +5 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-PL2EYDJK.js → chunk-KR5RVXLQ.js} +31 -29
  37. package/dist/cli-bundle/focused-chunks/chunk-KSNJG4KI.js +16 -0
  38. package/dist/cli-bundle/focused-chunks/chunk-M6RPIXKC.js +2 -0
  39. package/dist/cli-bundle/focused-chunks/chunk-MXYSIQ56.js +18 -0
  40. package/dist/cli-bundle/focused-chunks/chunk-RIIN5V4N.js +2 -0
  41. package/dist/cli-bundle/focused-chunks/chunk-RKWSCYYN.js +2 -0
  42. package/dist/cli-bundle/main.js +13 -13
  43. package/dist/cli-bundle/sdk-authoring.js +1 -1
  44. package/dist/cli-bundle/sdk-contracts.js +1 -1
  45. package/dist/cli-bundle/sdk-core.js +38 -38
  46. package/dist/cli-bundle/sdk-governance.js +1 -1
  47. package/dist/cli-bundle/sdk-graph.js +1 -1
  48. package/dist/cli-bundle/sdk-merge.js +1 -1
  49. package/dist/cli-bundle/sdk-query.js +1 -1
  50. package/dist/cli-bundle/sdk-runtime.js +1 -1
  51. package/dist/cli-bundle/sdk-testing.js +1 -1
  52. package/dist/cli-bundle/sdk.js +2 -2
  53. package/dist/core/diagnostics/remediation.js +19 -9
  54. package/dist/core/fs/fs-utils.d.ts +10 -0
  55. package/dist/core/fs/fs-utils.js +16 -4
  56. package/dist/core/history/history.js +13 -4
  57. package/dist/core/item/actionability.d.ts +7 -1
  58. package/dist/core/item/actionability.js +71 -15
  59. package/dist/core/item/item-format.js +3 -32
  60. package/dist/core/schema/fields-file.d.ts +1 -2
  61. package/dist/core/schema/fields-file.js +4 -11
  62. package/dist/core/schema/runtime-schema.js +3 -10
  63. package/dist/core/schema/status-defs-file.d.ts +1 -2
  64. package/dist/core/schema/status-defs-file.js +4 -32
  65. package/dist/core/schema/status-token.d.ts +2 -0
  66. package/dist/core/schema/status-token.js +32 -0
  67. package/dist/core/schema/type-workflows.d.ts +1 -2
  68. package/dist/core/schema/type-workflows.js +4 -11
  69. package/dist/core/shared/author.d.ts +25 -0
  70. package/dist/core/shared/author.js +128 -10
  71. package/dist/core/shared/errors.d.ts +4 -0
  72. package/dist/core/shared/errors.js +2 -2
  73. package/dist/core/shared/text-normalization.d.ts +1 -1
  74. package/dist/core/shared/text-normalization.js +2 -2
  75. package/dist/sdk/actionability.d.ts +1 -1
  76. package/dist/sdk/actionability.js +3 -3
  77. package/dist/sdk/agent/command-recovery.d.ts +4 -0
  78. package/dist/sdk/agent/command-recovery.js +52 -0
  79. package/dist/sdk/agent/command-suggestions.d.ts +4 -0
  80. package/dist/sdk/agent/command-suggestions.js +67 -0
  81. package/dist/sdk/agent/create-option-policy.d.ts +12 -0
  82. package/dist/sdk/agent/create-option-policy.js +32 -0
  83. package/dist/sdk/agent/item-addressing.d.ts +19 -0
  84. package/dist/sdk/agent/item-addressing.js +208 -0
  85. package/dist/sdk/cli-bootstrap.d.ts +1 -1
  86. package/dist/sdk/cli-bootstrap.js +20 -5
  87. package/dist/sdk/cli-contracts/commander-mutation-options.js +16 -4
  88. package/dist/sdk/cli-contracts/flag-contracts.js +62 -21
  89. package/dist/sdk/cli-contracts/registration-helpers.js +10 -2
  90. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +8 -0
  91. package/dist/sdk/cli-contracts/runtime-contracts.js +20 -3
  92. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +6 -0
  93. package/dist/sdk/cli-contracts/tool-option-contracts.js +4 -2
  94. package/dist/sdk/cli-contracts/tool-parameter-tables.js +19 -4
  95. package/dist/sdk/cli-contracts/tool-schema.js +17 -4
  96. package/dist/sdk/context-intent-runtime.js +8 -5
  97. package/dist/sdk/context-signal-store.d.ts +34 -0
  98. package/dist/sdk/context-signal-store.js +24 -2
  99. package/dist/sdk/core-governance.d.ts +1 -1
  100. package/dist/sdk/core-governance.js +3 -3
  101. package/dist/sdk/dependencies.d.ts +2 -0
  102. package/dist/sdk/dependencies.js +7 -6
  103. package/dist/sdk/dependency-flag-validation.d.ts +15 -1
  104. package/dist/sdk/dependency-flag-validation.js +54 -2
  105. package/dist/sdk/extension/bundled-catalog.js +19 -6
  106. package/dist/sdk/generated-error-code-catalog.js +110 -2
  107. package/dist/sdk/governance/health.js +38 -12
  108. package/dist/sdk/governance/provenance-health.d.ts +39 -0
  109. package/dist/sdk/governance/provenance-health.js +185 -0
  110. package/dist/sdk/governance/validate-item-reader.d.ts +13 -0
  111. package/dist/sdk/governance/validate-item-reader.js +18 -0
  112. package/dist/sdk/governance/validate.d.ts +2 -2
  113. package/dist/sdk/governance/validate.js +25 -11
  114. package/dist/sdk/governance.d.ts +1 -0
  115. package/dist/sdk/governance.js +3 -2
  116. package/dist/sdk/graph/assembly.d.ts +4 -0
  117. package/dist/sdk/graph/assembly.js +22 -2
  118. package/dist/sdk/graph/run.d.ts +2 -0
  119. package/dist/sdk/graph/run.js +3 -2
  120. package/dist/sdk/index.d.ts +4 -0
  121. package/dist/sdk/index.js +6 -2
  122. package/dist/sdk/lifecycle/close.js +27 -19
  123. package/dist/sdk/lifecycle/create.d.ts +2 -0
  124. package/dist/sdk/lifecycle/create.js +66 -19
  125. package/dist/sdk/lifecycle/plan.js +6 -3
  126. package/dist/sdk/lifecycle/update-many.js +39 -27
  127. package/dist/sdk/lifecycle/update.d.ts +6 -1
  128. package/dist/sdk/lifecycle/update.js +51 -28
  129. package/dist/sdk/merge/driver.d.ts +2 -1
  130. package/dist/sdk/merge/driver.js +7 -4
  131. package/dist/sdk/merge/index.d.ts +1 -1
  132. package/dist/sdk/merge/index.js +3 -3
  133. package/dist/sdk/merge/install.d.ts +4 -0
  134. package/dist/sdk/merge/install.js +29 -17
  135. package/dist/sdk/merge/receipts.d.ts +17 -1
  136. package/dist/sdk/merge/receipts.js +112 -20
  137. package/dist/sdk/merge/reconcile.js +21 -4
  138. package/dist/sdk/merge/three-way.d.ts +6 -2
  139. package/dist/sdk/merge/three-way.js +24 -10
  140. package/dist/sdk/output-projection.js +24 -4
  141. package/dist/sdk/query/context.d.ts +2 -0
  142. package/dist/sdk/query/context.js +7 -4
  143. package/dist/sdk/query/get.d.ts +11 -0
  144. package/dist/sdk/query/get.js +37 -3
  145. package/dist/sdk/query/light-metadata.d.ts +3 -0
  146. package/dist/sdk/query/light-metadata.js +19 -0
  147. package/dist/sdk/read-output-contracts.d.ts +1 -1
  148. package/dist/sdk/read-output-contracts.js +23 -4
  149. package/dist/sdk/relationship-kinds/contract.d.ts +48 -0
  150. package/dist/sdk/relationship-kinds/contract.js +22 -0
  151. package/dist/sdk/relationships.d.ts +6 -41
  152. package/dist/sdk/relationships.js +12 -126
  153. package/dist/sdk/runtime-primitives.d.ts +1 -1
  154. package/dist/sdk/runtime-primitives.js +3 -3
  155. package/dist/sdk/runtime.d.ts +4 -1
  156. package/dist/sdk/runtime.js +8 -3
  157. package/dist/sdk/schema-migration.js +7 -9
  158. package/dist/sdk/similarity-scoring.d.ts +1 -2
  159. package/dist/sdk/similarity-scoring.js +4 -16
  160. package/dist/sdk/similarity.d.ts +5 -0
  161. package/dist/sdk/similarity.js +40 -10
  162. package/dist/sdk/structured-mutations.js +5 -2
  163. package/dist/sdk/test/linked-command-detection.d.ts +2 -7
  164. package/dist/sdk/test/linked-command-detection.js +22 -9
  165. package/dist/sdk/workspace-snapshot.d.ts +4 -0
  166. package/dist/sdk/workspace-snapshot.js +24 -11
  167. package/docs/AGENT_GUIDE.md +5 -2
  168. package/docs/COMMANDS.md +27 -6
  169. package/docs/DEPENDENCY_KIND_CONTRACT.md +29 -0
  170. package/docs/ITEM_READ_PROJECTIONS.md +26 -0
  171. package/docs/MERGE_SAFETY.md +17 -8
  172. package/docs/README.md +2 -5
  173. package/docs/READ_OUTPUT_CONTRACTS.md +2 -2
  174. package/docs/RELATIONSHIP_GRAPH.md +1 -1
  175. package/docs/SDK.md +33 -8
  176. package/docs/SDK_AGENT_SESSION_CONTEXT.md +36 -2
  177. package/docs/SDK_CONTEXT.md +97 -0
  178. package/docs/SDK_CONTEXT_INTEGRITY.md +33 -3
  179. package/docs/SENTRY_CONTRACT_EPOCHS.md +20 -0
  180. package/docs/agent-task-token-baseline.json +2 -2
  181. package/marketplace.json +2 -2
  182. package/package.json +5 -4
  183. package/packages/pm-beads/package.json +1 -1
  184. package/packages/pm-calendar/package.json +1 -1
  185. package/packages/pm-command-kit/package.json +1 -1
  186. package/packages/pm-digital-twin/package.json +1 -1
  187. package/packages/pm-governance-audit/package.json +1 -1
  188. package/packages/pm-guide-shell/package.json +1 -1
  189. package/packages/pm-kanban/package.json +1 -1
  190. package/packages/pm-lifecycle-hooks/package.json +1 -1
  191. package/packages/pm-linked-test-adapters/package.json +1 -1
  192. package/packages/pm-search-advanced/package.json +1 -1
  193. package/packages/pm-templates/package.json +1 -1
  194. package/packages/pm-todos/package.json +1 -1
  195. package/packages/pm-vcs/package.json +1 -1
  196. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  197. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  198. package/sdk/public-surface.json +415 -43
  199. package/dist/cli-bundle/chunks/chunk-GKA54IJM.js +0 -5
  200. package/dist/cli-bundle/chunks/chunk-KRY7SRUO.js +0 -2
  201. package/dist/cli-bundle/chunks/chunk-MNJ4NNSY.js +0 -26
  202. package/dist/cli-bundle/chunks/chunk-OJPCFDDY.js +0 -13
  203. package/dist/cli-bundle/chunks/chunk-PFSD3DAN.js +0 -194
  204. package/dist/cli-bundle/chunks/chunk-SQ7QZFQ6.js +0 -2
  205. package/dist/cli-bundle/chunks/register-operations-5XQETS6E.js +0 -2
  206. package/dist/cli-bundle/focused-chunks/chunk-54EU2UVO.js +0 -2
  207. package/dist/cli-bundle/focused-chunks/chunk-5FLBTZJQ.js +0 -2
  208. package/dist/cli-bundle/focused-chunks/chunk-5GJ57YKN.js +0 -2
  209. package/dist/cli-bundle/focused-chunks/chunk-CMDS3KYT.js +0 -14
  210. package/dist/cli-bundle/focused-chunks/chunk-DMKOMTTY.js +0 -6
  211. package/dist/cli-bundle/focused-chunks/chunk-F5B3HBEZ.js +0 -5
  212. package/dist/cli-bundle/focused-chunks/chunk-FI6DWU2M.js +0 -2
  213. package/dist/cli-bundle/focused-chunks/chunk-FNOKJG6N.js +0 -16
  214. package/dist/cli-bundle/focused-chunks/chunk-FPDYXZBK.js +0 -4
  215. package/dist/cli-bundle/focused-chunks/chunk-GWI6YIKJ.js +0 -3
  216. package/dist/cli-bundle/focused-chunks/chunk-HCUC62AB.js +0 -2
  217. package/dist/cli-bundle/focused-chunks/chunk-HGNKPSCB.js +0 -153
  218. package/dist/cli-bundle/focused-chunks/chunk-IAS7PMLG.js +0 -2
  219. package/dist/cli-bundle/focused-chunks/chunk-SM2PJGP3.js +0 -2
  220. package/dist/cli-bundle/focused-chunks/chunk-U646T7Z6.js +0 -18
  221. package/dist/cli-bundle/focused-chunks/chunk-YKPE4PPY.js +0 -2
  222. package/dist/cli-bundle/focused-chunks/chunk-ZOLDTUU7.js +0 -2
@@ -4,7 +4,7 @@
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]="0139d8ef-d286-571f-89f8-7de2f8422f22")}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]="6c075a14-1a65-59c7-a9c6-af348e30f821")}catch(e){}}();
8
8
  import { AsyncLocalStorage } from "node:async_hooks";
9
9
  import { createHash } from "node:crypto";
10
10
  import fs from "node:fs";
@@ -31,13 +31,12 @@ export const BUILTIN_HARNESS_SIGNAL_DESCRIPTORS = [
31
31
  session_environment_keys: ["CLAUDE_CODE_SESSION_ID"],
32
32
  provenance_environment_keys: {
33
33
  effort: ["CLAUDE_EFFORT"],
34
- role: ["CLAUDE_CODE_CHILD_SESSION"],
35
34
  },
36
35
  provenance_resolvers: {
37
36
  model: "claude_session_file",
38
37
  version: "claude_session_file",
39
38
  },
40
- provenance_unavailable_dimensions: ["topic"],
39
+ provenance_unavailable_dimensions: ["role", "topic"],
41
40
  argv_markers: ["claude", "claude-code"],
42
41
  client_names: ["claude", "claude-code", "claude code"],
43
42
  },
@@ -192,6 +191,28 @@ function firstEnvironmentValue(env, keys) {
192
191
  return undefined;
193
192
  }
194
193
  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
+ if (dimension === "role") {
204
+ const command = argv
205
+ .slice(0, 8)
206
+ .map((token) => token.trim().toLowerCase())
207
+ .find((token) => ["claim", "create", "update", "close", "release", "review"].includes(token));
208
+ if (command === "review")
209
+ return "reviewer";
210
+ if (command)
211
+ return "implementer";
212
+ }
213
+ return undefined;
214
+ }
215
+ function provenanceFlagValue(argv, dimension) {
195
216
  const acceptedFlags = dimension === "model"
196
217
  ? ["--model", "--agent-model"]
197
218
  : [`--agent-${dimension}`];
@@ -208,6 +229,24 @@ function provenanceFromArgv(argv, dimension) {
208
229
  }
209
230
  return undefined;
210
231
  }
232
+ const AGENT_ROLE_VALUES = new Set([
233
+ "implementation",
234
+ "implementer",
235
+ "investigator",
236
+ "orchestrator",
237
+ "planner",
238
+ "release-operator",
239
+ "reviewer",
240
+ ]);
241
+ function normalizeProvenanceValue(dimension, value) {
242
+ if (dimension !== "role" || value === undefined)
243
+ return value;
244
+ const normalized = value
245
+ .trim()
246
+ .toLowerCase()
247
+ .replaceAll(/[_\s]+/gu, "-");
248
+ return AGENT_ROLE_VALUES.has(normalized) ? normalized : undefined;
249
+ }
211
250
  function boundedProvenanceValue(provenance, dimension) {
212
251
  return nonBlank(provenance?.[dimension])?.slice(0, 256);
213
252
  }
@@ -274,13 +313,23 @@ function resolveProvenanceProbe(dimension, signals, env, descriptor) {
274
313
  }
275
314
  if (resolver === "ai_agent_version") {
276
315
  const value = nonBlank(env.AI_AGENT);
277
- if (!value)
316
+ if (!value ||
317
+ !descriptor ||
318
+ !literalSignalMatches(value, descriptor.harness)) {
278
319
  return undefined;
320
+ }
279
321
  const match = /(?:^|[@/\s])v?(\d+\.\d+(?:\.\d+)?(?:[-+][A-Za-z0-9.-]+)?)$/u.exec(value);
280
322
  return match?.[1]?.slice(0, 256);
281
323
  }
282
324
  return undefined;
283
325
  }
326
+ function provenanceResolverHasInput(resolver, descriptor, env) {
327
+ if (resolver === "ai_agent_version") {
328
+ const value = nonBlank(env.AI_AGENT);
329
+ return (value !== undefined && literalSignalMatches(value, descriptor.harness));
330
+ }
331
+ return nonBlank(env.CLAUDE_CODE_SESSION_ID) !== undefined;
332
+ }
284
333
  function effectiveHarnessDetectionSignals(signals) {
285
334
  if (signals)
286
335
  return signals;
@@ -307,7 +356,7 @@ function resolveAgentProvenanceObservation(dimension, signals, env, descriptor,
307
356
  let overrideValue;
308
357
  let argvValue;
309
358
  if (hostResolvedDimensions.has(dimension)) {
310
- overrideValue = nonBlank(env[overrideKey])?.slice(0, 256);
359
+ overrideValue = normalizeProvenanceValue(dimension, nonBlank(env[overrideKey])?.slice(0, 256));
311
360
  argvValue = provenanceFromArgv(signals.argv ?? [], dimension);
312
361
  }
313
362
  const environmentKeysByDimension = {
@@ -321,10 +370,10 @@ function resolveAgentProvenanceObservation(dimension, signals, env, descriptor,
321
370
  const values = [
322
371
  overrideValue,
323
372
  boundedProvenanceValue(sessionContext?.provenance, dimension),
324
- firstEnvironmentValue(env, environmentKeysByDimension[dimension]),
325
- boundedProvenanceValue(clientProvenance, dimension),
326
- boundedProvenanceValue(signals.provenance, dimension),
327
- argvValue,
373
+ normalizeProvenanceValue(dimension, firstEnvironmentValue(env, environmentKeysByDimension[dimension])),
374
+ normalizeProvenanceValue(dimension, boundedProvenanceValue(clientProvenance, dimension)),
375
+ normalizeProvenanceValue(dimension, boundedProvenanceValue(signals.provenance, dimension)),
376
+ normalizeProvenanceValue(dimension, argvValue),
328
377
  resolveProvenanceProbe(dimension, signals, env, descriptor),
329
378
  ];
330
379
  const sources = [
@@ -469,6 +518,75 @@ export function detectAgentIdentity(signals) {
469
518
  ];
470
519
  return Object.fromEntries(entries.filter((entry) => entry[1] !== undefined));
471
520
  }
521
+ function resolveProvenanceOutcome(dimension, identity, descriptor, env, probesEnabled, invalidValue) {
522
+ const resolver = descriptor?.provenance_resolvers[dimension];
523
+ if (identity.provenance?.[dimension]) {
524
+ return {
525
+ status: "resolved",
526
+ ...(resolver ? { resolver } : {}),
527
+ rule_version: "v1",
528
+ };
529
+ }
530
+ if (invalidValue) {
531
+ return {
532
+ status: "unavailable",
533
+ reason: "invalid_value",
534
+ rule_version: "v1",
535
+ };
536
+ }
537
+ if (resolver) {
538
+ const resolverHasInput = provenanceResolverHasInput(resolver, descriptor, env);
539
+ const status = resolverHasInput && probesEnabled ? "failed" : "unavailable";
540
+ const reason = !resolverHasInput
541
+ ? "harness_unavailable"
542
+ : probesEnabled
543
+ ? "resolver_failed"
544
+ : "probes_disabled";
545
+ return { status, reason, resolver, rule_version: "v1" };
546
+ }
547
+ return {
548
+ status: descriptor?.provenance_unavailable_dimensions.includes(dimension)
549
+ ? "unavailable"
550
+ : "not_configured",
551
+ reason: descriptor?.provenance_unavailable_dimensions.includes(dimension)
552
+ ? "harness_unavailable"
553
+ : "resolver_not_configured",
554
+ rule_version: "v1",
555
+ };
556
+ }
557
+ /**
558
+ * Diagnose provenance without exposing environment values, paths, or probe data.
559
+ *
560
+ * This additive SDK contract keeps legacy `detectAgentIdentity` projections
561
+ * stable while giving health checks and history writers explicit absence states.
562
+ */
563
+ export function diagnoseAgentIdentity(signals) {
564
+ const effectiveSignals = effectiveHarnessDetectionSignals(signals);
565
+ const identity = detectAgentIdentity(effectiveSignals);
566
+ const descriptor = currentHarnessSignalDescriptors(effectiveSignals.descriptors).find((candidate) => candidate.harness === identity.harness);
567
+ const env = effectiveSignals.env ?? {};
568
+ const probesEnabled = effectiveSignals.probes_enabled !== false &&
569
+ workspaceHarnessSignalsStorage.getStore()?.probesEnabled !== false &&
570
+ !["0", "false", "off"].includes(nonBlank(env.PM_AGENT_PROBES)?.toLowerCase() ?? "");
571
+ const sessionContext = resolveAgentSessionContextFromSignals(effectiveSignals, env);
572
+ const invalidRoleValue = [
573
+ env.PM_AGENT_ROLE,
574
+ sessionContext.provenance?.role,
575
+ firstEnvironmentValue(env, descriptor?.provenance_environment_keys.role),
576
+ effectiveSignals.client_info?.provenance?.role,
577
+ effectiveSignals.provenance?.role,
578
+ provenanceFlagValue(effectiveSignals.argv ?? [], "role"),
579
+ ].some((candidate) => {
580
+ const value = nonBlank(candidate)?.slice(0, 256);
581
+ return (value !== undefined &&
582
+ normalizeProvenanceValue("role", value) === undefined);
583
+ });
584
+ const outcomes = Object.fromEntries(AGENT_PROVENANCE_DIMENSIONS.map((dimension) => [
585
+ dimension,
586
+ resolveProvenanceOutcome(dimension, identity, descriptor, env, probesEnabled, dimension === "role" && invalidRoleValue),
587
+ ]));
588
+ return { ...identity, provenance_outcomes: outcomes };
589
+ }
472
590
  /** Reads the invocation-wide author override through the canonical environment seam. */
473
591
  export function readAuthorEnvironment() {
474
592
  return process.env.PM_AUTHOR;
@@ -575,4 +693,4 @@ export function resolveAuthor(candidate, fallback) {
575
693
  return identity.author;
576
694
  }
577
695
  //# sourceMappingURL=author.js.map
578
- //# debugId=0139d8ef-d286-571f-89f8-7de2f8422f22
696
+ //# debugId=6c075a14-1a65-59c7-a9c6-af348e30f821
@@ -60,6 +60,10 @@ export interface PmCliErrorContext {
60
60
  examples?: string[];
61
61
  /** Value that configures or reports next steps for this contract. */
62
62
  nextSteps?: string[];
63
+ /** Exact selectors that could not be matched by a lossless removal. */
64
+ unmatched?: string[];
65
+ /** Local dependency targets that could not be resolved before mutation. */
66
+ unresolved_targets?: string[];
63
67
  /** Available history bounds for a failed point-in-time read or restore target. */
64
68
  valid_range?: {
65
69
  /** 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]="31191ce6-fb17-5b76-aa3d-3c3773cd85e0")}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=31191ce6-fb17-5b76-aa3d-3c3773cd85e0
@@ -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
@@ -7,4 +7,4 @@
7
7
  * blocker or ready-work classifications without storage or rendering side
8
8
  * effects.
9
9
  */
10
- export { collectBlockedByIds, collectDependencyBlockedIds, computeActionabilityReport, resolveItemBlockers, type ActionabilityReport, type ActionableEntry, type ResolvedBlocker, } from "../core/item/actionability.js";
10
+ export { ACTIONABILITY_ORDERING_KINDS, collectBlockedByIds, collectBlockedByIdsFromCorpus, collectDependencyBlockedIds, computeActionabilityReport, indexBlockedByIds, resolveItemBlockers, type ActionabilityReport, type ActionableEntry, type ResolvedBlocker, } from "../core/item/actionability.js";
@@ -8,7 +8,7 @@
8
8
  * effects.
9
9
  */
10
10
 
11
- !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]="9184e723-8269-5e45-8c6a-52fd02da60e6")}catch(e){}}();
12
- export { collectBlockedByIds, collectDependencyBlockedIds, computeActionabilityReport, resolveItemBlockers, } from "../core/item/actionability.js";
11
+ !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]="cc271a73-9767-54bb-a142-d4d4569e3c6a")}catch(e){}}();
12
+ export { ACTIONABILITY_ORDERING_KINDS, collectBlockedByIds, collectBlockedByIdsFromCorpus, collectDependencyBlockedIds, computeActionabilityReport, indexBlockedByIds, resolveItemBlockers, } from "../core/item/actionability.js";
13
13
  //# sourceMappingURL=actionability.js.map
14
- //# debugId=9184e723-8269-5e45-8c6a-52fd02da60e6
14
+ //# debugId=cc271a73-9767-54bb-a142-d4d4569e3c6a
@@ -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;