@unbrained/pm-cli 2026.11.23 → 2026.11.25
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.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli/error-guidance.js +5 -5
- package/dist/cli/main.js +5 -5
- package/dist/cli/register-annotations.js +1 -1
- package/dist/cli/runtime/invocation-options.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-4FZH5BTV.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-YYT3MIRF.js → chunk-6OIHST4I.js} +1 -1
- package/dist/cli-bundle/chunks/chunk-7EPYCU7U.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-AEOHUSUI.js → chunk-BVJMVU4Z.js} +68 -68
- package/dist/cli-bundle/chunks/{chunk-2UQU7HRR.js → chunk-C4KIZQHW.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-CNUFU454.js +113 -0
- package/dist/cli-bundle/chunks/chunk-CONBVY2O.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-BSRIVYTM.js → chunk-CZEMEPPQ.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-DF6A7C32.js +2 -0
- package/dist/cli-bundle/chunks/chunk-FHLOGAGA.js +8 -0
- package/dist/cli-bundle/chunks/chunk-FVY7U3SU.js +125 -0
- package/dist/cli-bundle/chunks/{chunk-F2Z6XLZB.js → chunk-GBVF2ZB3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-GZI7ZAB7.js +2 -0
- package/dist/cli-bundle/chunks/chunk-HZZLSBIJ.js +2 -0
- package/dist/cli-bundle/chunks/chunk-K34FR5CO.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-D6PDUKUG.js → chunk-KHFUHGL3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-L6VS7F3R.js +2 -0
- package/dist/cli-bundle/chunks/chunk-LOX3VY4T.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-H7JEXRIN.js → chunk-LPW7S5KA.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5DUP4AZA.js → chunk-MGJMQSN4.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-OS5W4ZG2.js +31 -0
- package/dist/cli-bundle/chunks/{chunk-O7JHS64G.js → chunk-OWK2JL4I.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-SCIPT7WF.js +2 -0
- package/dist/cli-bundle/chunks/chunk-SX76UGEY.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-CFWLQFJM.js → chunk-VA4T37Q4.js} +50 -51
- package/dist/cli-bundle/chunks/chunk-WQOEVGLQ.js +2 -0
- package/dist/cli-bundle/chunks/chunk-XHCIOLJP.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-J2PDAVBC.js → chunk-XKWJONAO.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-YIGBEY7K.js +2 -0
- package/dist/cli-bundle/chunks/chunk-ZBOQEZ2H.js +33 -0
- package/dist/cli-bundle/chunks/chunk-ZLICQPRG.js +3 -0
- package/dist/cli-bundle/chunks/field-option-collisions-QE65APSD.js +2 -0
- package/dist/cli-bundle/chunks/{indexed-receipt-blobs-BPYKN5Q7.js → indexed-receipt-blobs-H3MMNXXG.js} +2 -2
- package/dist/cli-bundle/{focused-chunks/item-revision-YDACCDVY.js → chunks/item-revision-INDHJV6X.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-LCKK4XXB.js +2 -0
- package/dist/cli-bundle/chunks/mutation-actor-KU7BMLUN.js +2 -0
- package/dist/cli-bundle/chunks/mutation-admission-3OMCTQD4.js +2 -0
- package/dist/cli-bundle/chunks/{register-list-query-L4IBU64P.js → register-list-query-3GV3LBOT.js} +2 -2
- package/dist/cli-bundle/chunks/register-mutation-GZLF47SX.js +21 -0
- package/dist/cli-bundle/chunks/register-operations-PBJZGCAL.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-ZLJEF6NZ.js +2 -0
- package/dist/cli-bundle/chunks/runtime-schema-Y4SHTEXL.js +2 -0
- package/dist/cli-bundle/chunks/{settlement-hook-6MR32OOC.js → settlement-hook-ESAAEBRM.js} +2 -2
- package/dist/cli-bundle/chunks/stage-3WIZBD4N.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-3Y5PTQ2F.js +27 -0
- package/dist/cli-bundle/focused-chunks/{chunk-Y2ESLKCF.js → chunk-4LQL4EO6.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-RIE3SJSE.js → chunk-4SX2BN4V.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ZHWPCVQL.js → chunk-5RBC4WSE.js} +39 -39
- package/dist/cli-bundle/focused-chunks/chunk-7SSGTGZO.js +91 -0
- package/dist/cli-bundle/focused-chunks/chunk-A4R57E4K.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-BOIMP2AR.js +5 -0
- package/dist/cli-bundle/focused-chunks/chunk-BYQK5DGH.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-C3FEDTSD.js +44 -0
- package/dist/cli-bundle/focused-chunks/chunk-IAOKVKWW.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-JOKRDFMQ.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-MB56Y4M6.js +8 -0
- package/dist/cli-bundle/focused-chunks/{chunk-A6VEMCRR.js → chunk-NGFDPEP7.js} +1 -1
- package/dist/cli-bundle/focused-chunks/chunk-OCKKIECS.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-PKX2EHE3.js +26 -0
- package/dist/cli-bundle/focused-chunks/chunk-SXC2EO3E.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-TQIKDFOD.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-TRL4JDWX.js +8 -0
- package/dist/cli-bundle/focused-chunks/{chunk-IROZDIDX.js → chunk-UWWAVXG4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-VMYVN36N.js +13 -0
- package/dist/cli-bundle/focused-chunks/chunk-VU2PH4PF.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-WL2R7T5G.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-WVA5KOXF.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-QQIIMMFU.js → chunk-X4EWD6TL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-XKLBTDJ7.js +100 -0
- package/dist/cli-bundle/focused-chunks/chunk-YYEWIKNI.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-ZLRRII55.js +2 -0
- package/dist/cli-bundle/focused-chunks/field-option-collisions-5ROXGUME.js +2 -0
- package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-EGEJMG3G.js → indexed-receipt-blobs-PG2VJ3MB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-revision-KYMSQVZE.js +2 -0
- package/dist/cli-bundle/focused-chunks/item-transaction-I4HLVHEJ.js +2 -0
- package/dist/cli-bundle/focused-chunks/mutation-actor-GGOQKAE6.js +2 -0
- package/dist/cli-bundle/focused-chunks/mutation-admission-OS36ZCMH.js +2 -0
- package/dist/cli-bundle/focused-chunks/runtime-schema-YXPYDD2C.js +2 -0
- package/dist/cli-bundle/focused-chunks/{settlement-hook-FMLGKG7J.js → settlement-hook-4MGRERCT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/stage-4ZFWJUKO.js +2 -0
- package/dist/cli-bundle/main.js +26 -26
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +4 -4
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +63 -63
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +12 -12
- package/dist/core/profile/profile-lint.d.ts +1 -1
- package/dist/core/profile/profile-lint.js +1 -1
- package/dist/core/schema/fields-file.js +2 -2
- package/dist/core/schema/runtime-field-values.js +1 -1
- package/dist/core/schema/runtime-schema.d.ts +2 -0
- package/dist/core/schema/runtime-schema.js +1 -1
- package/dist/core/shared/command-line.d.ts +54 -4
- package/dist/core/shared/command-line.js +1 -1
- package/dist/core/shared/errors.d.ts +9 -0
- package/dist/core/shared/secret-rules.js +5 -5
- package/dist/core/shared/url-credentials.d.ts +16 -3
- package/dist/core/shared/url-credentials.js +1 -1
- package/dist/core/store/item-store.d.ts +26 -4
- package/dist/core/store/item-store.js +1 -1
- package/dist/sdk/command-line.d.ts +1 -1
- package/dist/sdk/command-line.js +1 -1
- package/dist/sdk/context-intent-contracts.js +1 -1
- package/dist/sdk/extension/command-options.d.ts +26 -1
- package/dist/sdk/extension/command-options.js +1 -1
- package/dist/sdk/extension-command-context.js +2 -2
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/governance/tracked-runtime-cache.js +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/lifecycle/claim.d.ts +21 -1
- package/dist/sdk/lifecycle/claim.js +1 -1
- package/dist/sdk/lifecycle/task-composition.js +1 -1
- package/dist/sdk/ownership-source.d.ts +15 -1
- package/dist/sdk/ownership-source.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/read-output-contracts.d.ts +11 -0
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/schema/field-flag-spelling.d.ts +22 -0
- package/dist/sdk/schema/field-flag-spelling.js +2 -0
- package/dist/sdk/schema/field-option-collisions.js +1 -1
- package/docs/AGENT_GUIDE.md +2 -2
- package/docs/COMMANDS.md +1 -1
- package/docs/CONFIGURATION.md +1 -0
- package/docs/EXTENSIONS.md +1 -1
- package/docs/MUTATION_INTEGRITY.md +97 -8
- package/docs/READ_OUTPUT_CONTRACTS.md +2 -0
- package/docs/SDK.md +60 -4
- package/docs/SDK_AUDITED_MUTATIONS.md +11 -0
- package/docs/WORKSPACE_POSITION_AND_LIFECYCLE.md +17 -4
- package/marketplace.json +1 -1
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-5WZZ5XEN.js +0 -3
- package/dist/cli-bundle/chunks/chunk-6MYJLOSG.js +0 -2
- package/dist/cli-bundle/chunks/chunk-ENKXRSFZ.js +0 -31
- package/dist/cli-bundle/chunks/chunk-FJOEL75F.js +0 -2
- package/dist/cli-bundle/chunks/chunk-GDXCAC52.js +0 -2
- package/dist/cli-bundle/chunks/chunk-KE7HMBEW.js +0 -2
- package/dist/cli-bundle/chunks/chunk-KZHIBEJL.js +0 -33
- package/dist/cli-bundle/chunks/chunk-NGJ5ERBF.js +0 -115
- package/dist/cli-bundle/chunks/chunk-NQ54T7T2.js +0 -2
- package/dist/cli-bundle/chunks/chunk-OKEZF7HU.js +0 -2
- package/dist/cli-bundle/chunks/chunk-OKIKF4FD.js +0 -2
- package/dist/cli-bundle/chunks/chunk-OPJF254V.js +0 -9
- package/dist/cli-bundle/chunks/chunk-RWA5YZ5X.js +0 -2
- package/dist/cli-bundle/chunks/chunk-S32NGRQM.js +0 -2
- package/dist/cli-bundle/chunks/chunk-TZY5MVJF.js +0 -125
- package/dist/cli-bundle/chunks/chunk-ZPS4B6SI.js +0 -8
- package/dist/cli-bundle/chunks/item-revision-FMD4KWBB.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-SEHTH7N2.js +0 -2
- package/dist/cli-bundle/chunks/mutation-actor-SFGYIRPW.js +0 -2
- package/dist/cli-bundle/chunks/mutation-admission-57LBSKQI.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-6NUOPHZ3.js +0 -21
- package/dist/cli-bundle/chunks/register-operations-JGYVORNN.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-C44SIXEH.js +0 -2
- package/dist/cli-bundle/chunks/stage-PQ7AB63N.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-6LKTEKHS.js +0 -6
- package/dist/cli-bundle/focused-chunks/chunk-6LPXMFLM.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HMDQDRV2.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-I66IKYKP.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-IR2J3NOT.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-ITKDHSBR.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-LQYYPXUK.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-NQTEE66P.js +0 -13
- package/dist/cli-bundle/focused-chunks/chunk-O7Z73ALG.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-OTMMOKPM.js +0 -91
- package/dist/cli-bundle/focused-chunks/chunk-OXOCZJC6.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-QLAHEDT6.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-TD544C74.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-UFTUNBMY.js +0 -27
- package/dist/cli-bundle/focused-chunks/chunk-XRS3VNC6.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-XYPEZGTR.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-YSJKQLFR.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-Z2X7HH3C.js +0 -102
- package/dist/cli-bundle/focused-chunks/item-transaction-UKEQCTKB.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-actor-AS465LRX.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-E5UHJZFE.js +0 -2
- package/dist/cli-bundle/focused-chunks/stage-36J7YLGI.js +0 -2
|
@@ -236,10 +236,21 @@ export declare const PM_READ_OUTPUT_COMPOSITION_OPTION_FLAGS:readonly["--output-
|
|
|
236
236
|
export declare const PM_READ_OUTPUT_SURFACE_CONTRACTS:readonly PmReadOutputSurfaceContract[];
|
|
237
237
|
/** Resolve a command or list/context alias to its canonical read-output surface. */
|
|
238
238
|
export declare function resolveReadOutputSurface(command:string,options?:Record<string,unknown>):PmReadOutputSurface|undefined;
|
|
239
|
+
/** Stable code of the refusal for universal output controls given to a command that is not a read surface (pm-gh1769). */
|
|
240
|
+
export declare const READ_OUTPUT_SURFACE_UNSUPPORTED_CODE="read_output_surface_unsupported";
|
|
239
241
|
/** Stable code of the refusal for a hybrid read-and-mutate command given universal output controls (pm-rrwh2o). */
|
|
240
242
|
export declare const READ_OUTPUT_MUTATION_CONFLICT_CODE="read_output_mutation_conflict";
|
|
241
243
|
/** CLI flags of the universal output controls that shape a read, which a mutation retry must drop. */
|
|
242
244
|
export declare const READ_OUTPUT_SHAPING_CONTROL_FLAGS:readonly string[];
|
|
245
|
+
/**
|
|
246
|
+
* Expose positional annotation text as the `add` mutation key that read-output
|
|
247
|
+
* validation checks, so `pm learnings <id> "text" --output-budget 1` is refused
|
|
248
|
+
* before it writes, as `--add` already is, instead of appending and then
|
|
249
|
+
* failing the output budget. CLI dispatch and the extension test harness both
|
|
250
|
+
* apply it (pm-gh1769), so a package that handles an annotation command sees
|
|
251
|
+
* the native refusal in its tests.
|
|
252
|
+
*/
|
|
253
|
+
export declare function annotationPositionalMutationOptions(commandPath:string,processedArgs:readonly unknown[]):{add?:string;};
|
|
243
254
|
/** Reject malformed or mutation-scoped universal output controls before command execution. */
|
|
244
255
|
export declare function validateReadOutputOptions(command:string,options:Record<string,unknown>):void;
|
|
245
256
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{READ_OUTPUT_DIMENSION_FLAGS as ht,READ_OUTPUT_COMPOSITION_FLAGS as yt,PM_READ_OUTPUT_SURFACES as wt}from"./read-output/options.js";import{resolvePmHistoryOperation as Rt}from"./cli-contracts/command-aliases.js";import{resolveExtensionOutputCommand as bt}from"./read-output/extension.js";import{BEHAVIOR_PRESERVING_MIGRATION_HINTS as L,LEGACY_FLAGS_BY_COMMAND as At,VALUE_BEARING_INCLUDE_ALIASES as Ct,flagSelector as G,optionKey as kt,readOutputIncludeModeOptionsForSurface as $,resolveNativeReadOutputSurface as Et}from"./read-output/surfaces.js";import{EXIT_CODE as w}from"../core/shared/constants.js";import{PmCliError as R}from"../core/shared/errors.js";import{compactReadOutputToBudget as St,estimateReadOutputTokens as Tt,readOutputMeasurementFormat as q,projectReadOutputItemToBrief as xt,preserveReadOutputRowContract as E,mirrorReadOutputReceiptEstimate as It,resolveReadOutputPassHooks as V,resolveReadOutputRecoveryBudget as jt,updateReadOutputReceiptEstimate as S}from"./read-output-budget.js";import{resolveReadOutputRecoveryBudget as Xe}from"./read-output-budget.js";import{resolvePmCommandOutputBudget as vt}from"./cli-contracts/agent-output-contracts.js";import{boundReadOutputRows as Pt,countReadOutputRows as z,mapReadOutputRows as K,readOutputBudgetCollections as H,readOutputContinuationRowCollections as v,readOutputRowPaths as Ut,readOutputRowCollections as Nt,refreshReadOutputDeliveredCounts as P}from"./read-output-rows.js";import{applyReadOutputContinuation as Mt,decodeReadOutputContinuationCursor as Dt,encodeReadOutputContinuationCursor as Bt,prioritizeAssuranceAssertions as Ft,readOutputCollectionFingerprint as Lt,refreshReadOutputDeliveredRowCounters as Gt}from"./read-output/continuation.js";import{PM_READ_OUTPUT_TAIL_RETENTION_POLICIES as T,readOutputRetainsTail as x}from"./read-output/tail-retention.js";import{decodeReadOutputContinuationCursor as tn,encodeReadOutputContinuationCursor as en,PM_READ_OUTPUT_CONTINUATION_FINGERPRINT_POLICIES as nn,readOutputCollectionFingerprint as on}from"./read-output/continuation.js";import{PM_READ_OUTPUT_TAIL_RETENTION_POLICIES as rn,readOutputRetainsTail as sn}from"./read-output/tail-retention.js";import{applyReadOutputSessionReferences as $t,attachReadOutputSessionReceipt as Y,parseReadOutputSession as U,readOutputSessionRemainingTokens as qt}from"./read-output-session.js";import{decodeQueryCursorEnvelope as Vt,encodeQueryCursor as zt}from"./pagination.js";import{READ_OUTPUT_INVOCATION_PROVENANCE as N}from"./read-output/provenance.js";const b=["include","amount","cost","encoding"];import{PM_READ_OUTPUT_SURFACES as cn}from"./read-output/options.js";const W=["canonical","legacy","intent","default"],C=ht,$e=Object.freeze(b.map(t=>C[t])),qe=yt;function Kt(t,e){const n=L[t];if(n!==void 0)return n;const o=e==="include"?Ct.has(t)?"<csv>":G(t):e==="amount"?"<n>":e==="cost"?"<tokens>":"<toon|json>";return`${t} is a compatibility alias; prefer ${C[e]} ${o}.`}function J(t){const e=At[t]??{},n=Object.freeze(Object.fromEntries(b.map(o=>[o,Object.freeze({dimension:o,canonical_option:C[o],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((e[o]??[]).map(u=>Object.freeze({flag:u,semantics:L[u]===void 0?"replacement":"behavior_preserving",migration_hint:Kt(u,o),visibility:"hidden_alias"})))})])));return Object.freeze({command:t,dimensions:n,precedence:W,budget_retention_policy:t==="assurance"?"verdict_priority":Object.hasOwn(T,t)?"ordered_suffix":"ordered_prefix",projection_modes:Object.freeze([...$(t).keys()])})}const Ht=Object.freeze(wt.map(J)),Yt=new Map(Ht.map(t=>[t.command,t]));function I(t,e={}){const n=Rt(t.trim().toLowerCase()),o=bt(n);return o!==void 0?o.read_output===void 0?void 0:`extension:${o.command}`:Et(n,e)}const Wt=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],Q={comments:["add","body","comment","text","stdin","file","edit","delete"],notes:["add","note","text","addJson","stdin","file","edit","delete"],learnings:["add","learning","text","stdin","file","edit","delete"],files:["add","addGlob","remove","migrate","apply","note"],docs:["add","addGlob","remove","migrate","note"],"package-catalog":["activate","adopt","adoptAll","deactivate","doctor","init","install","manage","migrate","reload","scaffold","uninstall"]};function Jt(t){return Wt.some(e=>e!=="outputFormat"&&e!=="output_format"&&t[e]!==void 0)}const Qt=[{keys:["outputInclude","output_include"],valid:t=>k(t)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:t=>t==="unbounded"||A(t)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:t=>t==="unbounded"||A(t)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputSession","output_session"],valid:t=>(U(t),!0),message:"--output-session must be a valid session-state object."},{keys:["outputCursor","output_cursor"],valid:t=>typeof t=="string"&&t.trim().length>0,message:"--output-cursor requires a non-empty continuation cursor."}],Ve="read_output_mutation_conflict",X=[{flag:"--output-include",keys:["outputInclude","output_include"]},{flag:"--output-limit",keys:["outputLimit","output_limit"]},{flag:"--output-budget",keys:["outputBudget","output_budget"]},{flag:"--output-session",keys:["outputSession","output_session"]},{flag:"--output-cursor",keys:["outputCursor","output_cursor"]},{flag:"--output-row-contract",keys:["outputRowContract","output_row_contract"]}],ze=X.map(({flag:t})=>t);function Xt(t,e,n){const o=X.filter(({keys:s})=>s.some(d=>e[d]!==void 0)),u=o.map(({flag:s})=>s),i=o.flatMap(({keys:s})=>s.filter(d=>e[d]!==void 0)),r=u.join(", ");return new R(`Universal output controls (${r}) cannot be combined with a ${t} mutation; nothing was written.`,w.USAGE,{code:"read_output_mutation_conflict",field:u[0],details:{surface:t,output_controls:u,output_option_keys:i,mutation_options:[...n]},required:`Retry the ${t} mutation without ${r}. To bound or page the result, read it with those controls in a separate call after the write.`,why:"Universal output controls shape a read. A mutation returns its own bounded receipt, so the controls have nothing to shape and the write is refused before it runs.",examples:[...Zt[t]]})}const Zt={comments:['pm comments <id> --add "<text>"',"pm comments <id> --output-limit 5"],notes:['pm notes <id> --add "<text>"',"pm notes <id> --output-limit 5"],learnings:['pm learnings <id> --add "<text>"',"pm learnings <id> --output-limit 5"],files:["pm files <id> --add path=<path>","pm files <id> --output-limit 5"],docs:["pm docs <id> --add path=<path>","pm docs <id> --output-limit 5"],"package-catalog":["pm package install <source> --project","pm package catalog --output-limit 5"]};function Ke(t,e){const n=e.outputFormat??e.output_format;if(n!==void 0&&n!=="json"&&n!=="toon")throw new R("--output-format must be toon or json.",w.USAGE);if(!Jt(e))return;const o=I(t,e);if(!o)throw new R(`Universal output controls apply only to read commands; ${t||"this command"} is not a read surface.`,w.USAGE);if(Object.hasOwn(Q,o)){const u=o,i=Q[u].filter(r=>e[r]!==void 0&&e[r]!==!1);if(i.length>0)throw Xt(u,e,i)}for(const u of Qt){const i=u.keys.map(r=>e[r]).find(r=>r!==void 0);if(i!==void 0&&!u.valid(i))throw new R(u.message,w.USAGE)}}function Z(t){const e=I(t);return e?$(e):new Map}function te(t,e,n){const o=k(e)??[],u=Z(t),i=[],r=[],s=n,d=s[N],f=new Set(d?.canonical_include_modes??[]),l=new Set(d?.explicit_legacy_aliases??[]);for(const c of o){const _=u.get(c);if(_===void 0){i.push(c);continue}const O=`--${c.replaceAll("_","-")}`;D(M(n,O))&&l.add(O),n[_]=!0,r.push(c),f.add(c)}const a=I(t)==="get"?i.filter(c=>c!=="item"):[],p=a.length>0;return p&&(n.fields=[...new Set([...k(n.fields)??[],...a])].join(","),f.add("fields")),(r.length>0||p)&&(s[N]={canonical_include_modes:[...f],explicit_legacy_aliases:[...l],...d?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:r}}function He(t,e){const n=e.outputInclude??e.output_include;if(n===void 0)return;const{selectors:o,modes:u}=te(t,n,e);if(u.length===0)return;const i=o.length>0?o.join(","):void 0;e.outputInclude=i,Object.hasOwn(e,"output_include")&&(e.output_include=i)}function M(t,e){const n=kt(e);if(Object.hasOwn(t,n))return t[n];const o=e.slice(2).replaceAll("-","_");if(Object.hasOwn(t,o))return t[o];if(e==="--no-truncate"&&t.truncate===!1)return!0}function D(t){return t!==void 0&&t!==!1&&t!==null}function k(t){const n=(Array.isArray(t)?t:[t]).flatMap(o=>typeof o=="string"?o.split(","):[]).map(o=>o.trim()).filter(Boolean);return n.length>0?[...new Set(n)]:void 0}function A(t){const e=typeof t=="number"?t:typeof t=="string"&&/^\d+$/u.test(t.trim())?Number(t):Number.NaN;return Number.isSafeInteger(e)&&e>0?e:void 0}function ee(t,e,n,o){for(const u of t.legacy_aliases){if(o(u.flag))continue;const i=M(e,u.flag),r={value:i,flag:u.flag};if(D(i)&&n(r))return r}}function tt(t,e){const n=k(t);if(n)return{source:"canonical",value:n};if(e)return{source:"legacy",value:k(e.value)??[G(e.flag)]}}function et(t,e){if(t==="unbounded")return{source:"canonical",value:"unbounded"};const n=A(t);if(n!==void 0)return{source:"canonical",value:n};if(!e)return;if(e.flag==="--no-truncate"||e.flag==="--unbounded")return{source:"legacy",value:"unbounded"};const o=A(e.value);return o===void 0?void 0:{source:"legacy",value:o}}function nt(t,e){if(t==="unbounded")return{source:"canonical",value:"unbounded"};const n=A(t);if(n!==void 0)return{source:"canonical",value:n};if(!e)return;const o=A(e.value);return o===void 0?void 0:{source:"legacy",value:o}}function ot(t,e){if(t==="json"||t==="toon")return{source:"canonical",value:t};if(e)return e.flag==="--stream"||e.flag==="--follow"?{source:"legacy",value:"stream"}:e.value==="json"||e.value==="toon"?{source:"legacy",value:e.value}:void 0}function ut(t,e,n){if(!t)return!1;const o=new Set(t.explicit_legacy_aliases);if(t.cli_invocation_observed===!0||t.sdk_invocation_observed===!0)return!o.has(n);const u=new Set(t.canonical_include_modes.map(i=>`--${i.replaceAll("_","-")}`));return e==="include"&&u.has(n)&&!o.has(n)}function ne(t,e,n,o){return t.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||D(M(o,"--no-truncate"))&&!ut(n,"amount","--no-truncate")||e.amount?.flag==="--no-truncate"||e.include?.flag==="--full"||n?.canonical_include_modes.includes("full")===!0}function oe(t,e){return b.flatMap(n=>t[n]?.source==="canonical"||n==="include"&&(e?.canonical_include_modes.length??0)>0?[C[n]]:[])}function it(t,e){const n=I(t,e);if(!n)return;const o=Yt.get(n)??J(n),u=e[N],i={include:g=>tt(void 0,g),amount:g=>et(void 0,g),cost:g=>nt(void 0,g),encoding:g=>ot(void 0,g)},r=Object.fromEntries(b.map(g=>[g,ee(o.dimensions[g],e,y=>i[g](y)!==void 0,y=>ut(u,g,y))])),s=b.flatMap(g=>{const y=r[g];return y?[y.flag]:[]}),d=b.flatMap(g=>{const y=r[g];return y?[o.dimensions[g].legacy_aliases.find(Ot=>Ot.flag===y.flag).migration_hint]:[]}),f=ot(e.outputFormat??e.output_format,r.encoding),l=tt(e.outputInclude??e.output_include,r.include),a=et(e.outputLimit??e.output_limit,r.amount),p=nt(e.outputBudget??e.output_budget,r.cost),c=ne(t,r,u,e),_=vt(t,{generateFallback:!0}),O=f?.value==="json"||e.resolvedOutputFormat==="json"?"json":"toon",h=p??(c?{source:"intent",value:"unbounded"}:{source:"default",value:_.default_max_estimated_tokens_by_format[O]});return{command:n,include:l,amount:a,cost:h,encoding:f,canonical_options_used:oe({include:l,amount:a,cost:h,encoding:f},u),legacy_aliases_used:s,migration_hints:d,precedence:W}}function m(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}const B=new Set(["applied_bound","applied_limit","completeness","continuation_kind","continuation_path","continuation_contract","count","filters","has_more","next_cursor","now","omission_receipt","projection","budget_retention_policy","row_contract","sorting","total","truncated"]),ue=["collection_counts","notes_count","tests_count"];function rt(t,e){const n=new Set(e.map(o=>o.split(".")[0]));return Object.fromEntries(Object.entries(t).filter(([o])=>n.has(o)))}function ie(t){const e=m(t.item)?t.item:{},n=[...new Set([...Object.keys(e),...ue.filter(u=>Object.hasOwn(e,u))])].sort((u,i)=>u.localeCompare(i)),o=Object.keys(t).filter(u=>u!=="item"&&u!=="read_output"&&!B.has(u)).sort((u,i)=>u.localeCompare(i));return{item:e,itemFields:n,sections:o,valid:[...n,"item",...n.map(u=>`item.${u}`),...o]}}function re(t,e){const n=ie(t),o=e.filter(a=>!n.valid.includes(a));if(o.length>0)throw new R(`Unknown --output-include selector(s) for get: ${o.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,w.USAGE);const u=e.includes("item"),i=e.flatMap(a=>a.startsWith("item.")?[a.slice(5)]:n.itemFields.includes(a)?[a]:[]).filter((a,p,c)=>c.indexOf(a)===p);if(u&&i.length>0)throw new R("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",w.USAGE);const r=new Set(e.filter(a=>n.sections.includes(a))),s=Object.fromEntries(Object.entries(t).filter(([a])=>B.has(a)||r.has(a)));u?s.item=n.item:i.length>0&&(s.item=rt(n.item,i));const d=[...u?[]:i.length>0?n.itemFields.filter(a=>!i.includes(a)).map(a=>({name:`item.${a}`,restore_with:`--output-include item.${a}`})):[{name:"item",restore_with:"--output-include item"}],...n.sections.filter(a=>!r.has(a)).map(a=>({name:a,restore_with:`--output-include ${a}`}))],l=[...m(s.omission_receipt)&&Array.isArray(s.omission_receipt.omitted_field_groups)?s.omission_receipt.omitted_field_groups:[],...d];return s.omission_receipt={has_omissions:l.length>0,omitted_field_group_count:l.length,omitted_field_groups:l},s}function st(t){let e=0;return K({...t},n=>(m(n)&&Object.keys(n).length>0&&(e+=1),n)),e}function se(t,e,n,o){if(st(e)===0||st(n)>0)return;const u=[...Z(t).keys()],i=u.length>0?` Declared ${t} projection modes: ${u.join(", ")}.`:` The ${t} surface declares no projection modes; name row fields instead.`;throw new R(`Unknown --output-include selector(s) for ${t}: ${o.join(", ")}. No selector matched any returned row field.${i}`,w.USAGE)}function ae(t,e,n){if(t==="get")return re(e,n);const o=Ut(e),u=n.flatMap(r=>o.flatMap(s=>r.startsWith(`${s}.`)?[r.slice(s.length+1)]:[])),i=n.some(r=>Object.hasOwn(e,r.split(".")[0])&&!o.some(s=>r.startsWith(`${s}.`)));if(o.length>0&&(!i||u.length>0)){const r={...e},s=u.length>0?u:n,d=K(r,f=>m(f)?rt(f,s):f);return se(t,e,d,s),d}return Object.fromEntries(Object.entries(e).filter(([r])=>n.some(s=>s.split(".")[0]===r)||B.has(r)))}function ce(t,e,n,o){if(e==="unbounded")return t;const{result:u,truncated:i}=Pt(t,e,r=>x(n,r));if(!i)return u;if(u.has_more=!0,u.truncated=!0,pt(u,n,[...o.entries()].flatMap(([r,s])=>s.rows>e?[{path:r,total_rows:s.totalRows}]:[])),typeof u.count=="number"){const r=m(u.projection)?u.projection.row_key:void 0;u.count=typeof r=="string"&&Array.isArray(u[r])?u[r].length:z(u)}return typeof u.returned_count=="number"&&(u.returned_count=z(u)),u.applied_bound={kind:"output_limit",source:"explicit",value:e},u}function de(t){return b.filter(e=>t[e]!==void 0&&t[e]?.source!=="default"||t.canonical_options_used.includes(C[e]))}function j(t,e,n,o){let u=Y(t,e,o);E(t,u);for(let i=0;i<8;i+=1){const r=n.estimated_tokens,s=u.read_session.spent_this_call_tokens;S(u,n,o);const d=u;u=Y(u,e,o),E(d,u);const f=u.read_session.spent_this_call_tokens;if(n.estimated_tokens===r&&f===s)return u}return u}function le(t,e){if(!m(t.read_output))return t;const n=q(e),o=t.read_output,u=U(e.outputSession??e.output_session);return u===void 0?(S(t,o,n),t):j(t,u,o,n)}function at(t,e){if(t!=="validate")return e;const n=m(e.projection)?e.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(a=>m(a)&&a.name==="diagnostic_rows"))return e;const u=[...new Set(H(e).map(({path:a})=>a).filter(a=>/^checks\.\d+\.details\./u.test(a)))],i=u.filter(a=>!u.some(p=>p!==a&&a.startsWith(`${p}.`)));if(i.length===0)return e;const r=m(e.row_contract)?e.row_contract:{},s=Array.isArray(r.row_keys)?r.row_keys.filter(a=>typeof a=="string"):[],d=Array.isArray(r.continuation_row_keys)?r.continuation_row_keys.filter(a=>typeof a=="string"):[],f=s.length>0?s:i,l=[...new Set(i)];return JSON.stringify(f)===JSON.stringify(s)&&JSON.stringify(l)===JSON.stringify(d)?e:{...e,row_contract:{...r,row_keys:f,continuation_row_keys:l,jq_selector:typeof r.jq_selector=="string"?r.jq_selector:".checks[].details"}}}function fe(t,e){return t.include?.source==="canonical"&&!F(e)}function ct(t,e){let n={...t};return fe(e,t)&&(n=ae(e.command,n,e.include.value)),e.command==="assurance"?Ft(n):n}function pe(t,e){const n=V(e)?.continuationBinding;if(n===void 0)return;const o=ct(at(t.command,n),t);return new Map(v(o).filter(u=>!x(t.command,u.path)).map(u=>[u.path,u]))}function _e(t,e,n,o,u){let i=ct(t,e);P(i,t);const r=pe(e,u);if(i=Mt(i,e.command,o,r),e.command==="history"&&o){const f=["compact_history","provenance_history","history","diff"];if(i=Object.fromEntries(Object.entries(i).filter(([l])=>!f.includes(l)||l===o.path)),m(i.projection)&&(i.projection={...i.projection,row_key:o.path}),m(i.row_contract)){const l=i.row_contract;i.row_contract={...l,row_keys:[o.path],...Array.isArray(l.continuation_row_keys)?{continuation_row_keys:[o.path]}:{}}}i.count=Object.keys(i[o.path]).length}const s=t.count_only===!0?{...i,count_only:!0,count:t.count}:i,d=be(i,t,e.command,o,u,r);return e.amount?.source==="canonical"&&(i=ce(i,e.amount.value,e.command,d.collectionsBeforeBudget),d.cursorContinuesExistingPage&&mt(i,d.originalItems,d.cursorSource,!0,d.originalItemOffset)),P(i,s),_t(i,e.command,d),{projected:n===void 0?i:$t(i,n),continuationState:d}}function me(t,e){return[...t.cost!==void 0&&t.cost.value!=="unbounded"&&(t.cost.source==="canonical"||t.cost.source==="default"||t.command==="context"&&t.cost.source==="legacy")?[{source:t.cost.source,tokens:t.cost.value}]:[],...e===void 0?[]:[{source:"session",tokens:qt(e)}]].sort((o,u)=>o.tokens-u.tokens)[0]}function dt(t){const e=t.canonical_options_used;return e&&e.length>0?{canonical_options_used:e}:{}}function lt(t,e){return m(t.context_intent)&&t.context_intent.command==="context"&&t.context_intent.token_budget===e&&t.context_intent.within_budget===!0}function ge(t,e,n){return t.command!=="next"||(e.tokenBudget??e.token_budget)===void 0?!1:!(m(n.context_intent)&&n.context_intent.command==="next"&&n.context_intent.within_budget===!0)}function ft(t,e={}){return t?.source==="default"||t?.source==="legacy"&&!lt(e,t.tokens)?{budget_source:t.source,budget_tokens:t.tokens}:{}}function Oe(t,e,n,o,u,i){const r={contract_version:1,command:t.command,requested_dimensions:e,...ft(o),precedence:t.precedence,...dt(t),legacy_aliases_used:[],migration_hints:[],estimated_tokens:0,within_budget:!1,strings_compacted:!1,rows_compacted:!1,result_omitted:!0,...n===void 0?{omitted_result_estimated_tokens:u}:{}},s={output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},read_output:r},d=n===void 0?s:j(s,n,r,i);if(n===void 0&&S(d,r,i),n!==void 0&&r.estimated_tokens>o.tokens)throw new R("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",w.USAGE);return d}function he(t,e,n){return t.command==="context"&&t.cost?.source==="legacy"&&!lt(n,t.cost.value)||ge(t,e,n)||e.outputRowContract===!0||e.output_row_contract===!0||t.canonical_options_used.includes("--output-include")||t.command==="list"&&t.canonical_options_used.length>0&&t.include?.value.includes("full")===!0}function ye(t,e,n,o,u){if(e!==void 0||F(n)||he(t,u,n))return!1;if(t.amount?.source==="canonical"&&t.amount.value!=="unbounded"){const i=t.amount.value;if(Nt(n).some(({value:r})=>(Array.isArray(r)?r.length:Object.keys(r).length)>i))return!1}return t.cost===void 0||t.cost.value==="unbounded"||t.cost.source==="legacy"&&t.command!=="context"||Tt(u.outputRowContract===!1?Object.fromEntries(Object.entries(n).filter(([i])=>i!=="row_contract")):n,o)<=t.cost.value}function pt(t,e,n){const o=Object.hasOwn(T,e)?T[e]:void 0,u=n.find(i=>o?.paths.includes(i.path));o!==void 0&&u!==void 0&&typeof t[o.total_key]!="number"&&(t[o.total_key]=u.total_rows)}function _t(t,e,n){const o=T[e]?.paths[0];o!==void 0&&Gt(t,e,n.producer,n.collectionsBeforeBudget.get(o)?.rows)}function we(t,e,n,o){const u=n.backward?n.rows-o:n.baseOffset+o;return{path:e,cursor:Bt({command:t,path:e,offset:u,total_rows:n.totalRows,fingerprint:n.fingerprint,...n.backward?{direction:"backward"}:{}}),retained_rows:o,remaining_rows:n.backward?u:n.totalRows-u,total_rows:n.totalRows}}function Re(t,e,n,o,u,i,r){if(!n.rows_compacted)return;const s=e.amount?.value==="unbounded"?["amount"]:[],d=new Map(v(t).map(_=>[_.path,Array.isArray(_.value)?_.value.length:Object.keys(_.value).length])),f=[...r.entries()].flatMap(([_,O])=>{const h=d.get(_);return h>=O.rows?[]:[we(e.command,_,O,h)]}),l=f[0];pt(t,e.command,f);const a=l?"; page --output-cursor":"",p=o.source==="session"?`Truncated by the remaining ${o.tokens}-token session budget; start a new output session with a larger token_budget${a}.`:`${o.tokens}-token: raise --output-budget${a}`;n.migration_hints=[p,...e.migration_hints];const c=jt({effective_budget_tokens:o.tokens,measured_result_tokens:i});l&&!u&&(typeof t.next_cursor!="string"||t.continuation_kind==="output_cursor")&&(t.next_cursor=l.cursor),t.continuation_kind=u?"producer_cursor":l?"output_cursor":"none",t.output_budget_truncation={reason:"output_budget_reached",budget_source:o.source,budget_tokens:o.tokens,overridden_dimensions:s,compacted_row_paths:n.compacted_row_paths,continuation_cursor_rebased:u,continuation_available:f.length>0,recovery_budget_multiplier:l?1:c.recovery_budget_multiplier,continuations:f,restore_with:l?"recovery":`Retry with --output-budget ${c.output_budget} because no declared row collection can be continued.`,recovery:l?{cursor:l.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:`--output-budget ${c.output_budget}`,sdk:{outputBudget:c.output_budget},mcp:{outputBudget:c.output_budget}}}}function mt(t,e,n,o,u){if(typeof n!="string"||!Array.isArray(t.items))return!1;const i=t.items.length,r=e.length;if(i===0||i>=r)return!1;let s;try{s=Vt(n)}catch{return!1}const d=s.after_index;if(d===void 0)return!1;const f=e[i-1];if(Object.prototype.toString.call(f)!=="[object Object]")return!1;const l=Reflect.get(f,"id");if(typeof l!="string"||l.length===0)return!1;const a=o?d-(r-i):d+u+i;return a<0?!1:(t.next_cursor=zt(s.fingerprint,l,a,s.snapshot),!0)}function gt(t){return Array.isArray(t)?t.length:Object.keys(t).length}function be(t,e,n,o,u,i){const r=new Map(v(t).map(f=>{const l=gt(f.value),a=o?.path===f.path,p=x(n,f.path),c=i?.get(f.path)??f;let _;return[f.path,{rows:l,totalRows:a?o.total_rows:gt(c.value),baseOffset:a&&!p?o.offset:0,backward:p,get fingerprint(){return _??=a?o.fingerprint:Lt(f.path,c.value,n),_}}]})),s=typeof t.next_cursor=="string",d=o?.path==="items"?o.offset:0;return{collectionsBeforeBudget:r,originalItems:Array.isArray(e.items)?d>0?e.items.slice(d):e.items:[],originalItemOffset:d,cursorContinuesExistingPage:s,cursorSource:s?t.next_cursor:u.after,producer:e}}function Ae(t,e,n,o,u,i,r,s,d,f){const l={...e,count_only:n},a=o.command==="assurance"&&Array.isArray(t.assertions)?t.assertions.filter(c=>m(c)&&c.verdict!=="pass").length:0,p=new Map;if(a>0&&p.set("assertions",a),o.command==="history"&&Array.isArray(t.diff))for(const c of H(t))c.path.startsWith("diff.")&&p.set(c.path,Object.keys(c.value).length);return St(t,u,i.tokens,p,f,c=>{P(c,l),_t(c,o.command,s);const _=mt(c,s.originalItems,s.cursorSource,s.cursorContinuesExistingPage,s.originalItemOffset);if(Re(c,o,u,i,_,d,s.collectionsBeforeBudget),o.command==="history"&&m(c.projection)){c.has_more=typeof c.next_cursor=="string"||c.applied_bound?.kind==="output_limit";const O=c.projection.row_key;typeof O=="string"&&Array.isArray(c[O])&&(c.count=c[O].length)}r!==void 0&&Object.assign(c,j(c,r,u,f))},o.command==="history"&&Array.isArray(t.diff),c=>x(o.command,c),o.command)}function Ye(t,e,n){const o=it(t,e);if(!o)return n;const u=q(e),i=U(e.outputSession??e.output_session),r=e.outputCursor??e.output_cursor,s=typeof r=="string"?Dt(r):void 0,d=de(o),f=at(o.command,n);if(s===void 0&&ye(o,i,f,u,e))return f;const l=me(o,i),a=_e(f,o,i,s,e);let p=a.projected;E(p,p,e.outputRowContract===!1);const c=F(p),_={contract_version:1,command:o.command,requested_dimensions:d,...ft(l,p),precedence:o.precedence,...dt(o),legacy_aliases_used:o.legacy_aliases_used,migration_hints:o.migration_hints,estimated_tokens:0,within_budget:!c,strings_compacted:!1,rows_compacted:!1,result_omitted:c};p.read_output=_;const O=V(e)?.mirrorEstimate;if(O!==void 0&&It(_,O),p=i===void 0?p:j(p,i,_,u),S(p,_,u),l!==void 0&&_.estimated_tokens>l.tokens){const h=xt(o.command,e,p);h!==void 0&&(_.applied_depth="brief",_.degradation_reason="output_budget_reached",E(p,h),p=le(h,e)),_.estimated_tokens>l.tokens&&(p=Ae(p,p,f.count_only===!0,o,_,l,i,a.continuationState,_.estimated_tokens,u))}return l!==void 0&&_.estimated_tokens>l.tokens?Oe(o,d,i,l,_.estimated_tokens,u):p}function Ce(t){return m(t)&&m(t.context_intent)&&t.context_intent.result_omitted===!0}function F(t){return ke(t)||Ce(t)}function ke(t){return m(t)&&m(t.output_budget_exceeded)&&t.output_budget_exceeded.omitted_result===!0&&t.output_budget_exceeded.reason==="requested_budget_infeasible"}function We(t,e){const n=e.outputFormat??e.output_format;if(n==="json"||n==="toon")return n;const o=it(t,e)?.encoding;return o?.value==="json"||o?.value==="toon"?o.value:void 0}export{qe as PM_READ_OUTPUT_COMPOSITION_OPTION_FLAGS,nn as PM_READ_OUTPUT_CONTINUATION_FINGERPRINT_POLICIES,b as PM_READ_OUTPUT_DIMENSIONS,$e as PM_READ_OUTPUT_OPTION_FLAGS,cn as PM_READ_OUTPUT_SURFACES,Ht as PM_READ_OUTPUT_SURFACE_CONTRACTS,rn as PM_READ_OUTPUT_TAIL_RETENTION_POLICIES,Ve as READ_OUTPUT_MUTATION_CONFLICT_CODE,ze as READ_OUTPUT_SHAPING_CONTROL_FLAGS,Ye as applyReadOutputDimensions,te as applyReadOutputIncludeModes,tn as decodeReadOutputContinuationCursor,en as encodeReadOutputContinuationCursor,ke as isReadOutputBudgetExceeded,F as isReadResultOmittedForBudget,He as normalizeReadOutputIncludeModeOptions,on as readOutputCollectionFingerprint,Z as readOutputIncludeModeOptions,sn as readOutputRetainsTail,it as resolveReadOutputDimensions,We as resolveReadOutputEncoding,Xe as resolveReadOutputRecoveryBudget,I as resolveReadOutputSurface,le as stabilizeReadOutputReceiptEstimates,Ke as validateReadOutputOptions};
|
|
1
|
+
import{READ_OUTPUT_DIMENSION_FLAGS as yt,READ_OUTPUT_COMPOSITION_FLAGS as wt,PM_READ_OUTPUT_SURFACES as Rt}from"./read-output/options.js";import{resolvePmHistoryOperation as bt}from"./cli-contracts/command-aliases.js";import{resolveExtensionOutputCommand as At}from"./read-output/extension.js";import{BEHAVIOR_PRESERVING_MIGRATION_HINTS as L,LEGACY_FLAGS_BY_COMMAND as Ct,VALUE_BEARING_INCLUDE_ALIASES as Et,flagSelector as G,optionKey as kt,readOutputIncludeModeOptionsForSurface as $,resolveNativeReadOutputSurface as Tt}from"./read-output/surfaces.js";import{EXIT_CODE as w}from"../core/shared/constants.js";import{PmCliError as R}from"../core/shared/errors.js";import{compactReadOutputToBudget as St,estimateReadOutputTokens as xt,readOutputMeasurementFormat as q,projectReadOutputItemToBrief as It,preserveReadOutputRowContract as k,mirrorReadOutputReceiptEstimate as jt,resolveReadOutputPassHooks as V,resolveReadOutputRecoveryBudget as vt,updateReadOutputReceiptEstimate as T}from"./read-output-budget.js";import{resolveReadOutputRecoveryBudget as en}from"./read-output-budget.js";import{resolvePmCommandOutputBudget as Ut}from"./cli-contracts/agent-output-contracts.js";import{boundReadOutputRows as Pt,countReadOutputRows as z,mapReadOutputRows as K,readOutputBudgetCollections as H,readOutputContinuationRowCollections as v,readOutputRowPaths as Nt,readOutputRowCollections as Mt,refreshReadOutputDeliveredCounts as U}from"./read-output-rows.js";import{applyReadOutputContinuation as Dt,decodeReadOutputContinuationCursor as Ft,encodeReadOutputContinuationCursor as Bt,prioritizeAssuranceAssertions as Lt,readOutputCollectionFingerprint as Gt,refreshReadOutputDeliveredRowCounters as $t}from"./read-output/continuation.js";import{PM_READ_OUTPUT_TAIL_RETENTION_POLICIES as S,readOutputRetainsTail as x}from"./read-output/tail-retention.js";import{decodeReadOutputContinuationCursor as on,encodeReadOutputContinuationCursor as un,PM_READ_OUTPUT_CONTINUATION_FINGERPRINT_POLICIES as rn,readOutputCollectionFingerprint as sn}from"./read-output/continuation.js";import{PM_READ_OUTPUT_TAIL_RETENTION_POLICIES as cn,readOutputRetainsTail as dn}from"./read-output/tail-retention.js";import{applyReadOutputSessionReferences as qt,attachReadOutputSessionReceipt as Y,parseReadOutputSession as P,readOutputSessionRemainingTokens as Vt}from"./read-output-session.js";import{decodeQueryCursorEnvelope as zt,encodeQueryCursor as Kt}from"./pagination.js";import{READ_OUTPUT_INVOCATION_PROVENANCE as N}from"./read-output/provenance.js";const b=["include","amount","cost","encoding"];import{PM_READ_OUTPUT_SURFACES as fn}from"./read-output/options.js";const W=["canonical","legacy","intent","default"],C=yt,qe=Object.freeze(b.map(t=>C[t])),Ve=wt;function Ht(t,e){const n=L[t];if(n!==void 0)return n;const o=e==="include"?Et.has(t)?"<csv>":G(t):e==="amount"?"<n>":e==="cost"?"<tokens>":"<toon|json>";return`${t} is a compatibility alias; prefer ${C[e]} ${o}.`}function J(t){const e=Ct[t]??{},n=Object.freeze(Object.fromEntries(b.map(o=>[o,Object.freeze({dimension:o,canonical_option:C[o],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((e[o]??[]).map(u=>Object.freeze({flag:u,semantics:L[u]===void 0?"replacement":"behavior_preserving",migration_hint:Ht(u,o),visibility:"hidden_alias"})))})])));return Object.freeze({command:t,dimensions:n,precedence:W,budget_retention_policy:t==="assurance"?"verdict_priority":Object.hasOwn(S,t)?"ordered_suffix":"ordered_prefix",projection_modes:Object.freeze([...$(t).keys()])})}const Yt=Object.freeze(Rt.map(J)),Wt=new Map(Yt.map(t=>[t.command,t]));function I(t,e={}){const n=bt(t.trim().toLowerCase()),o=At(n);return o!==void 0?o.read_output===void 0?void 0:`extension:${o.command}`:Tt(n,e)}const X=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],Q={comments:["add","body","comment","text","stdin","file","edit","delete"],notes:["add","note","text","addJson","stdin","file","edit","delete"],learnings:["add","learning","text","stdin","file","edit","delete"],files:["add","addGlob","remove","migrate","apply","note"],docs:["add","addGlob","remove","migrate","note"],"package-catalog":["activate","adopt","adoptAll","deactivate","doctor","init","install","manage","migrate","reload","scaffold","uninstall"]};function Jt(t){return X.some(e=>e!=="outputFormat"&&e!=="output_format"&&t[e]!==void 0)}const Xt=[{keys:["outputInclude","output_include"],valid:t=>E(t)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:t=>t==="unbounded"||A(t)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:t=>t==="unbounded"||A(t)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputSession","output_session"],valid:t=>(P(t),!0),message:"--output-session must be a valid session-state object."},{keys:["outputCursor","output_cursor"],valid:t=>typeof t=="string"&&t.trim().length>0,message:"--output-cursor requires a non-empty continuation cursor."}],ze="read_output_surface_unsupported",Ke="read_output_mutation_conflict",Z=[{flag:"--output-include",keys:["outputInclude","output_include"]},{flag:"--output-limit",keys:["outputLimit","output_limit"]},{flag:"--output-budget",keys:["outputBudget","output_budget"]},{flag:"--output-session",keys:["outputSession","output_session"]},{flag:"--output-cursor",keys:["outputCursor","output_cursor"]},{flag:"--output-row-contract",keys:["outputRowContract","output_row_contract"]}],He=Z.map(({flag:t})=>t);function Qt(t,e,n){const o=Z.filter(({keys:s})=>s.some(d=>e[d]!==void 0)),u=o.map(({flag:s})=>s),i=o.flatMap(({keys:s})=>s.filter(d=>e[d]!==void 0)),r=u.join(", ");return new R(`Universal output controls (${r}) cannot be combined with a ${t} mutation; nothing was written.`,w.USAGE,{code:"read_output_mutation_conflict",field:u[0],details:{surface:t,output_controls:u,output_option_keys:i,mutation_options:[...n]},required:`Retry the ${t} mutation without ${r}. To bound or page the result, read it with those controls in a separate call after the write.`,why:"Universal output controls shape a read. A mutation returns its own bounded receipt, so the controls have nothing to shape and the write is refused before it runs.",examples:[...Zt[t]]})}const Zt={comments:['pm comments <id> --add "<text>"',"pm comments <id> --output-limit 5"],notes:['pm notes <id> --add "<text>"',"pm notes <id> --output-limit 5"],learnings:['pm learnings <id> --add "<text>"',"pm learnings <id> --output-limit 5"],files:["pm files <id> --add path=<path>","pm files <id> --output-limit 5"],docs:["pm docs <id> --add path=<path>","pm docs <id> --output-limit 5"],"package-catalog":["pm package install <source> --project","pm package catalog --output-limit 5"]},te=new Set(["comments","notes","learnings"]);function Ye(t,e){const n=e[1];return te.has(t)&&typeof n=="string"?{add:n}:{}}function We(t,e){const n=e.outputFormat??e.output_format;if(n!==void 0&&n!=="json"&&n!=="toon")throw new R("--output-format must be toon or json.",w.USAGE);if(!Jt(e))return;const o=I(t,e);if(!o){const u=X.filter(i=>e[i]!==void 0);throw new R(`Universal output controls apply only to read commands; ${t||"this command"} is not a read surface.`,w.USAGE,{code:"read_output_surface_unsupported",details:{command:t||null,output_option_keys:u},required:"Drop the universal output controls, or run a read command. An extension command accepts them only when it declares read_output.",why:"Universal output controls shape a read's rows; a command that is not a read surface has no rows for them to bound, page or project."})}if(Object.hasOwn(Q,o)){const u=o,i=Q[u].filter(r=>e[r]!==void 0&&e[r]!==!1);if(i.length>0)throw Qt(u,e,i)}for(const u of Xt){const i=u.keys.map(r=>e[r]).find(r=>r!==void 0);if(i!==void 0&&!u.valid(i))throw new R(u.message,w.USAGE)}}function tt(t){const e=I(t);return e?$(e):new Map}function ee(t,e,n){const o=E(e)??[],u=tt(t),i=[],r=[],s=n,d=s[N],f=new Set(d?.canonical_include_modes??[]),l=new Set(d?.explicit_legacy_aliases??[]);for(const c of o){const _=u.get(c);if(_===void 0){i.push(c);continue}const O=`--${c.replaceAll("_","-")}`;D(M(n,O))&&l.add(O),n[_]=!0,r.push(c),f.add(c)}const a=I(t)==="get"?i.filter(c=>c!=="item"):[],p=a.length>0;return p&&(n.fields=[...new Set([...E(n.fields)??[],...a])].join(","),f.add("fields")),(r.length>0||p)&&(s[N]={canonical_include_modes:[...f],explicit_legacy_aliases:[...l],...d?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:r}}function Je(t,e){const n=e.outputInclude??e.output_include;if(n===void 0)return;const{selectors:o,modes:u}=ee(t,n,e);if(u.length===0)return;const i=o.length>0?o.join(","):void 0;e.outputInclude=i,Object.hasOwn(e,"output_include")&&(e.output_include=i)}function M(t,e){const n=kt(e);if(Object.hasOwn(t,n))return t[n];const o=e.slice(2).replaceAll("-","_");if(Object.hasOwn(t,o))return t[o];if(e==="--no-truncate"&&t.truncate===!1)return!0}function D(t){return t!==void 0&&t!==!1&&t!==null}function E(t){const n=(Array.isArray(t)?t:[t]).flatMap(o=>typeof o=="string"?o.split(","):[]).map(o=>o.trim()).filter(Boolean);return n.length>0?[...new Set(n)]:void 0}function A(t){const e=typeof t=="number"?t:typeof t=="string"&&/^\d+$/u.test(t.trim())?Number(t):Number.NaN;return Number.isSafeInteger(e)&&e>0?e:void 0}function ne(t,e,n,o){for(const u of t.legacy_aliases){if(o(u.flag))continue;const i=M(e,u.flag),r={value:i,flag:u.flag};if(D(i)&&n(r))return r}}function et(t,e){const n=E(t);if(n)return{source:"canonical",value:n};if(e)return{source:"legacy",value:E(e.value)??[G(e.flag)]}}function nt(t,e){if(t==="unbounded")return{source:"canonical",value:"unbounded"};const n=A(t);if(n!==void 0)return{source:"canonical",value:n};if(!e)return;if(e.flag==="--no-truncate"||e.flag==="--unbounded")return{source:"legacy",value:"unbounded"};const o=A(e.value);return o===void 0?void 0:{source:"legacy",value:o}}function ot(t,e){if(t==="unbounded")return{source:"canonical",value:"unbounded"};const n=A(t);if(n!==void 0)return{source:"canonical",value:n};if(!e)return;const o=A(e.value);return o===void 0?void 0:{source:"legacy",value:o}}function ut(t,e){if(t==="json"||t==="toon")return{source:"canonical",value:t};if(e)return e.flag==="--stream"||e.flag==="--follow"?{source:"legacy",value:"stream"}:e.value==="json"||e.value==="toon"?{source:"legacy",value:e.value}:void 0}function it(t,e,n){if(!t)return!1;const o=new Set(t.explicit_legacy_aliases);if(t.cli_invocation_observed===!0||t.sdk_invocation_observed===!0)return!o.has(n);const u=new Set(t.canonical_include_modes.map(i=>`--${i.replaceAll("_","-")}`));return e==="include"&&u.has(n)&&!o.has(n)}function oe(t,e,n,o){return t.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||D(M(o,"--no-truncate"))&&!it(n,"amount","--no-truncate")||e.amount?.flag==="--no-truncate"||e.include?.flag==="--full"||n?.canonical_include_modes.includes("full")===!0}function ue(t,e){return b.flatMap(n=>t[n]?.source==="canonical"||n==="include"&&(e?.canonical_include_modes.length??0)>0?[C[n]]:[])}function rt(t,e){const n=I(t,e);if(!n)return;const o=Wt.get(n)??J(n),u=e[N],i={include:g=>et(void 0,g),amount:g=>nt(void 0,g),cost:g=>ot(void 0,g),encoding:g=>ut(void 0,g)},r=Object.fromEntries(b.map(g=>[g,ne(o.dimensions[g],e,y=>i[g](y)!==void 0,y=>it(u,g,y))])),s=b.flatMap(g=>{const y=r[g];return y?[y.flag]:[]}),d=b.flatMap(g=>{const y=r[g];return y?[o.dimensions[g].legacy_aliases.find(ht=>ht.flag===y.flag).migration_hint]:[]}),f=ut(e.outputFormat??e.output_format,r.encoding),l=et(e.outputInclude??e.output_include,r.include),a=nt(e.outputLimit??e.output_limit,r.amount),p=ot(e.outputBudget??e.output_budget,r.cost),c=oe(t,r,u,e),_=Ut(t,{generateFallback:!0}),O=f?.value==="json"||e.resolvedOutputFormat==="json"?"json":"toon",h=p??(c?{source:"intent",value:"unbounded"}:{source:"default",value:_.default_max_estimated_tokens_by_format[O]});return{command:n,include:l,amount:a,cost:h,encoding:f,canonical_options_used:ue({include:l,amount:a,cost:h,encoding:f},u),legacy_aliases_used:s,migration_hints:d,precedence:W}}function m(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}const F=new Set(["applied_bound","applied_limit","completeness","continuation_kind","continuation_path","continuation_contract","count","filters","has_more","next_cursor","now","omission_receipt","projection","budget_retention_policy","row_contract","sorting","total","truncated"]),ie=["collection_counts","notes_count","tests_count"];function st(t,e){const n=new Set(e.map(o=>o.split(".")[0]));return Object.fromEntries(Object.entries(t).filter(([o])=>n.has(o)))}function re(t){const e=m(t.item)?t.item:{},n=[...new Set([...Object.keys(e),...ie.filter(u=>Object.hasOwn(e,u))])].sort((u,i)=>u.localeCompare(i)),o=Object.keys(t).filter(u=>u!=="item"&&u!=="read_output"&&!F.has(u)).sort((u,i)=>u.localeCompare(i));return{item:e,itemFields:n,sections:o,valid:[...n,"item",...n.map(u=>`item.${u}`),...o]}}function se(t,e){const n=re(t),o=e.filter(a=>!n.valid.includes(a));if(o.length>0)throw new R(`Unknown --output-include selector(s) for get: ${o.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,w.USAGE);const u=e.includes("item"),i=e.flatMap(a=>a.startsWith("item.")?[a.slice(5)]:n.itemFields.includes(a)?[a]:[]).filter((a,p,c)=>c.indexOf(a)===p);if(u&&i.length>0)throw new R("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",w.USAGE);const r=new Set(e.filter(a=>n.sections.includes(a))),s=Object.fromEntries(Object.entries(t).filter(([a])=>F.has(a)||r.has(a)));u?s.item=n.item:i.length>0&&(s.item=st(n.item,i));const d=[...u?[]:i.length>0?n.itemFields.filter(a=>!i.includes(a)).map(a=>({name:`item.${a}`,restore_with:`--output-include item.${a}`})):[{name:"item",restore_with:"--output-include item"}],...n.sections.filter(a=>!r.has(a)).map(a=>({name:a,restore_with:`--output-include ${a}`}))],l=[...m(s.omission_receipt)&&Array.isArray(s.omission_receipt.omitted_field_groups)?s.omission_receipt.omitted_field_groups:[],...d];return s.omission_receipt={has_omissions:l.length>0,omitted_field_group_count:l.length,omitted_field_groups:l},s}function at(t){let e=0;return K({...t},n=>(m(n)&&Object.keys(n).length>0&&(e+=1),n)),e}function ae(t,e,n,o){if(at(e)===0||at(n)>0)return;const u=[...tt(t).keys()],i=u.length>0?` Declared ${t} projection modes: ${u.join(", ")}.`:` The ${t} surface declares no projection modes; name row fields instead.`;throw new R(`Unknown --output-include selector(s) for ${t}: ${o.join(", ")}. No selector matched any returned row field.${i}`,w.USAGE)}function ce(t,e,n){if(t==="get")return se(e,n);const o=Nt(e),u=n.flatMap(r=>o.flatMap(s=>r.startsWith(`${s}.`)?[r.slice(s.length+1)]:[])),i=n.some(r=>Object.hasOwn(e,r.split(".")[0])&&!o.some(s=>r.startsWith(`${s}.`)));if(o.length>0&&(!i||u.length>0)){const r={...e},s=u.length>0?u:n,d=K(r,f=>m(f)?st(f,s):f);return ae(t,e,d,s),d}return Object.fromEntries(Object.entries(e).filter(([r])=>n.some(s=>s.split(".")[0]===r)||F.has(r)))}function de(t,e,n,o){if(e==="unbounded")return t;const{result:u,truncated:i}=Pt(t,e,r=>x(n,r));if(!i)return u;if(u.has_more=!0,u.truncated=!0,_t(u,n,[...o.entries()].flatMap(([r,s])=>s.rows>e?[{path:r,total_rows:s.totalRows}]:[])),typeof u.count=="number"){const r=m(u.projection)?u.projection.row_key:void 0;u.count=typeof r=="string"&&Array.isArray(u[r])?u[r].length:z(u)}return typeof u.returned_count=="number"&&(u.returned_count=z(u)),u.applied_bound={kind:"output_limit",source:"explicit",value:e},u}function le(t){return b.filter(e=>t[e]!==void 0&&t[e]?.source!=="default"||t.canonical_options_used.includes(C[e]))}function j(t,e,n,o){let u=Y(t,e,o);k(t,u);for(let i=0;i<8;i+=1){const r=n.estimated_tokens,s=u.read_session.spent_this_call_tokens;T(u,n,o);const d=u;u=Y(u,e,o),k(d,u);const f=u.read_session.spent_this_call_tokens;if(n.estimated_tokens===r&&f===s)return u}return u}function fe(t,e){if(!m(t.read_output))return t;const n=q(e),o=t.read_output,u=P(e.outputSession??e.output_session);return u===void 0?(T(t,o,n),t):j(t,u,o,n)}function ct(t,e){if(t!=="validate")return e;const n=m(e.projection)?e.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(a=>m(a)&&a.name==="diagnostic_rows"))return e;const u=[...new Set(H(e).map(({path:a})=>a).filter(a=>/^checks\.\d+\.details\./u.test(a)))],i=u.filter(a=>!u.some(p=>p!==a&&a.startsWith(`${p}.`)));if(i.length===0)return e;const r=m(e.row_contract)?e.row_contract:{},s=Array.isArray(r.row_keys)?r.row_keys.filter(a=>typeof a=="string"):[],d=Array.isArray(r.continuation_row_keys)?r.continuation_row_keys.filter(a=>typeof a=="string"):[],f=s.length>0?s:i,l=[...new Set(i)];return JSON.stringify(f)===JSON.stringify(s)&&JSON.stringify(l)===JSON.stringify(d)?e:{...e,row_contract:{...r,row_keys:f,continuation_row_keys:l,jq_selector:typeof r.jq_selector=="string"?r.jq_selector:".checks[].details"}}}function pe(t,e){return t.include?.source==="canonical"&&!B(e)}function dt(t,e){let n={...t};return pe(e,t)&&(n=ce(e.command,n,e.include.value)),e.command==="assurance"?Lt(n):n}function _e(t,e){const n=V(e)?.continuationBinding;if(n===void 0)return;const o=dt(ct(t.command,n),t);return new Map(v(o).filter(u=>!x(t.command,u.path)).map(u=>[u.path,u]))}function me(t,e,n,o,u){let i=dt(t,e);U(i,t);const r=_e(e,u);if(i=Dt(i,e.command,o,r),e.command==="history"&&o){const f=["compact_history","provenance_history","history","diff"];if(i=Object.fromEntries(Object.entries(i).filter(([l])=>!f.includes(l)||l===o.path)),m(i.projection)&&(i.projection={...i.projection,row_key:o.path}),m(i.row_contract)){const l=i.row_contract;i.row_contract={...l,row_keys:[o.path],...Array.isArray(l.continuation_row_keys)?{continuation_row_keys:[o.path]}:{}}}i.count=Object.keys(i[o.path]).length}const s=t.count_only===!0?{...i,count_only:!0,count:t.count}:i,d=Ae(i,t,e.command,o,u,r);return e.amount?.source==="canonical"&&(i=de(i,e.amount.value,e.command,d.collectionsBeforeBudget),d.cursorContinuesExistingPage&>(i,d.originalItems,d.cursorSource,!0,d.originalItemOffset)),U(i,s),mt(i,e.command,d),{projected:n===void 0?i:qt(i,n),continuationState:d}}function ge(t,e){return[...t.cost!==void 0&&t.cost.value!=="unbounded"&&(t.cost.source==="canonical"||t.cost.source==="default"||t.command==="context"&&t.cost.source==="legacy")?[{source:t.cost.source,tokens:t.cost.value}]:[],...e===void 0?[]:[{source:"session",tokens:Vt(e)}]].sort((o,u)=>o.tokens-u.tokens)[0]}function lt(t){const e=t.canonical_options_used;return e&&e.length>0?{canonical_options_used:e}:{}}function ft(t,e){return m(t.context_intent)&&t.context_intent.command==="context"&&t.context_intent.token_budget===e&&t.context_intent.within_budget===!0}function Oe(t,e,n){return t.command!=="next"||(e.tokenBudget??e.token_budget)===void 0?!1:!(m(n.context_intent)&&n.context_intent.command==="next"&&n.context_intent.within_budget===!0)}function pt(t,e={}){return t?.source==="default"||t?.source==="legacy"&&!ft(e,t.tokens)?{budget_source:t.source,budget_tokens:t.tokens}:{}}function he(t,e,n,o,u,i){const r={contract_version:1,command:t.command,requested_dimensions:e,...pt(o),precedence:t.precedence,...lt(t),legacy_aliases_used:[],migration_hints:[],estimated_tokens:0,within_budget:!1,strings_compacted:!1,rows_compacted:!1,result_omitted:!0,...n===void 0?{omitted_result_estimated_tokens:u}:{}},s={output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},read_output:r},d=n===void 0?s:j(s,n,r,i);if(n===void 0&&T(d,r,i),n!==void 0&&r.estimated_tokens>o.tokens)throw new R("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",w.USAGE);return d}function ye(t,e,n){return t.command==="context"&&t.cost?.source==="legacy"&&!ft(n,t.cost.value)||Oe(t,e,n)||e.outputRowContract===!0||e.output_row_contract===!0||t.canonical_options_used.includes("--output-include")||t.command==="list"&&t.canonical_options_used.length>0&&t.include?.value.includes("full")===!0}function we(t,e,n,o,u){if(e!==void 0||B(n)||ye(t,u,n))return!1;if(t.amount?.source==="canonical"&&t.amount.value!=="unbounded"){const i=t.amount.value;if(Mt(n).some(({value:r})=>(Array.isArray(r)?r.length:Object.keys(r).length)>i))return!1}return t.cost===void 0||t.cost.value==="unbounded"||t.cost.source==="legacy"&&t.command!=="context"||xt(u.outputRowContract===!1?Object.fromEntries(Object.entries(n).filter(([i])=>i!=="row_contract")):n,o)<=t.cost.value}function _t(t,e,n){const o=Object.hasOwn(S,e)?S[e]:void 0,u=n.find(i=>o?.paths.includes(i.path));o!==void 0&&u!==void 0&&typeof t[o.total_key]!="number"&&(t[o.total_key]=u.total_rows)}function mt(t,e,n){const o=S[e]?.paths[0];o!==void 0&&$t(t,e,n.producer,n.collectionsBeforeBudget.get(o)?.rows)}function Re(t,e,n,o){const u=n.backward?n.rows-o:n.baseOffset+o;return{path:e,cursor:Bt({command:t,path:e,offset:u,total_rows:n.totalRows,fingerprint:n.fingerprint,...n.backward?{direction:"backward"}:{}}),retained_rows:o,remaining_rows:n.backward?u:n.totalRows-u,total_rows:n.totalRows}}function be(t,e,n,o,u,i,r){if(!n.rows_compacted)return;const s=e.amount?.value==="unbounded"?["amount"]:[],d=new Map(v(t).map(_=>[_.path,Array.isArray(_.value)?_.value.length:Object.keys(_.value).length])),f=[...r.entries()].flatMap(([_,O])=>{const h=d.get(_);return h>=O.rows?[]:[Re(e.command,_,O,h)]}),l=f[0];_t(t,e.command,f);const a=l?"; page --output-cursor":"",p=o.source==="session"?`Truncated by the remaining ${o.tokens}-token session budget; start a new output session with a larger token_budget${a}.`:`${o.tokens}-token: raise --output-budget${a}`;n.migration_hints=[p,...e.migration_hints];const c=vt({effective_budget_tokens:o.tokens,measured_result_tokens:i});l&&!u&&(typeof t.next_cursor!="string"||t.continuation_kind==="output_cursor")&&(t.next_cursor=l.cursor),t.continuation_kind=u?"producer_cursor":l?"output_cursor":"none",t.output_budget_truncation={reason:"output_budget_reached",budget_source:o.source,budget_tokens:o.tokens,overridden_dimensions:s,compacted_row_paths:n.compacted_row_paths,continuation_cursor_rebased:u,continuation_available:f.length>0,recovery_budget_multiplier:l?1:c.recovery_budget_multiplier,continuations:f,restore_with:l?"recovery":`Retry with --output-budget ${c.output_budget} because no declared row collection can be continued.`,recovery:l?{cursor:l.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:`--output-budget ${c.output_budget}`,sdk:{outputBudget:c.output_budget},mcp:{outputBudget:c.output_budget}}}}function gt(t,e,n,o,u){if(typeof n!="string"||!Array.isArray(t.items))return!1;const i=t.items.length,r=e.length;if(i===0||i>=r)return!1;let s;try{s=zt(n)}catch{return!1}const d=s.after_index;if(d===void 0)return!1;const f=e[i-1];if(Object.prototype.toString.call(f)!=="[object Object]")return!1;const l=Reflect.get(f,"id");if(typeof l!="string"||l.length===0)return!1;const a=o?d-(r-i):d+u+i;return a<0?!1:(t.next_cursor=Kt(s.fingerprint,l,a,s.snapshot),!0)}function Ot(t){return Array.isArray(t)?t.length:Object.keys(t).length}function Ae(t,e,n,o,u,i){const r=new Map(v(t).map(f=>{const l=Ot(f.value),a=o?.path===f.path,p=x(n,f.path),c=i?.get(f.path)??f;let _;return[f.path,{rows:l,totalRows:a?o.total_rows:Ot(c.value),baseOffset:a&&!p?o.offset:0,backward:p,get fingerprint(){return _??=a?o.fingerprint:Gt(f.path,c.value,n),_}}]})),s=typeof t.next_cursor=="string",d=o?.path==="items"?o.offset:0;return{collectionsBeforeBudget:r,originalItems:Array.isArray(e.items)?d>0?e.items.slice(d):e.items:[],originalItemOffset:d,cursorContinuesExistingPage:s,cursorSource:s?t.next_cursor:u.after,producer:e}}function Ce(t,e,n,o,u,i,r,s,d,f){const l={...e,count_only:n},a=o.command==="assurance"&&Array.isArray(t.assertions)?t.assertions.filter(c=>m(c)&&c.verdict!=="pass").length:0,p=new Map;if(a>0&&p.set("assertions",a),o.command==="history"&&Array.isArray(t.diff))for(const c of H(t))c.path.startsWith("diff.")&&p.set(c.path,Object.keys(c.value).length);return St(t,u,i.tokens,p,f,c=>{U(c,l),mt(c,o.command,s);const _=gt(c,s.originalItems,s.cursorSource,s.cursorContinuesExistingPage,s.originalItemOffset);if(be(c,o,u,i,_,d,s.collectionsBeforeBudget),o.command==="history"&&m(c.projection)){c.has_more=typeof c.next_cursor=="string"||c.applied_bound?.kind==="output_limit";const O=c.projection.row_key;typeof O=="string"&&Array.isArray(c[O])&&(c.count=c[O].length)}r!==void 0&&Object.assign(c,j(c,r,u,f))},o.command==="history"&&Array.isArray(t.diff),c=>x(o.command,c),o.command)}function Xe(t,e,n){const o=rt(t,e);if(!o)return n;const u=q(e),i=P(e.outputSession??e.output_session),r=e.outputCursor??e.output_cursor,s=typeof r=="string"?Ft(r):void 0,d=le(o),f=ct(o.command,n);if(s===void 0&&we(o,i,f,u,e))return f;const l=ge(o,i),a=me(f,o,i,s,e);let p=a.projected;k(p,p,e.outputRowContract===!1);const c=B(p),_={contract_version:1,command:o.command,requested_dimensions:d,...pt(l,p),precedence:o.precedence,...lt(o),legacy_aliases_used:o.legacy_aliases_used,migration_hints:o.migration_hints,estimated_tokens:0,within_budget:!c,strings_compacted:!1,rows_compacted:!1,result_omitted:c};p.read_output=_;const O=V(e)?.mirrorEstimate;if(O!==void 0&&jt(_,O),p=i===void 0?p:j(p,i,_,u),T(p,_,u),l!==void 0&&_.estimated_tokens>l.tokens){const h=It(o.command,e,p);h!==void 0&&(_.applied_depth="brief",_.degradation_reason="output_budget_reached",k(p,h),p=fe(h,e)),_.estimated_tokens>l.tokens&&(p=Ce(p,p,f.count_only===!0,o,_,l,i,a.continuationState,_.estimated_tokens,u))}return l!==void 0&&_.estimated_tokens>l.tokens?he(o,d,i,l,_.estimated_tokens,u):p}function Ee(t){return m(t)&&m(t.context_intent)&&t.context_intent.result_omitted===!0}function B(t){return ke(t)||Ee(t)}function ke(t){return m(t)&&m(t.output_budget_exceeded)&&t.output_budget_exceeded.omitted_result===!0&&t.output_budget_exceeded.reason==="requested_budget_infeasible"}function Qe(t,e){const n=e.outputFormat??e.output_format;if(n==="json"||n==="toon")return n;const o=rt(t,e)?.encoding;return o?.value==="json"||o?.value==="toon"?o.value:void 0}export{Ve as PM_READ_OUTPUT_COMPOSITION_OPTION_FLAGS,rn as PM_READ_OUTPUT_CONTINUATION_FINGERPRINT_POLICIES,b as PM_READ_OUTPUT_DIMENSIONS,qe as PM_READ_OUTPUT_OPTION_FLAGS,fn as PM_READ_OUTPUT_SURFACES,Yt as PM_READ_OUTPUT_SURFACE_CONTRACTS,cn as PM_READ_OUTPUT_TAIL_RETENTION_POLICIES,Ke as READ_OUTPUT_MUTATION_CONFLICT_CODE,He as READ_OUTPUT_SHAPING_CONTROL_FLAGS,ze as READ_OUTPUT_SURFACE_UNSUPPORTED_CODE,Ye as annotationPositionalMutationOptions,Xe as applyReadOutputDimensions,ee as applyReadOutputIncludeModes,on as decodeReadOutputContinuationCursor,un as encodeReadOutputContinuationCursor,ke as isReadOutputBudgetExceeded,B as isReadResultOmittedForBudget,Je as normalizeReadOutputIncludeModeOptions,sn as readOutputCollectionFingerprint,tt as readOutputIncludeModeOptions,dn as readOutputRetainsTail,rt as resolveReadOutputDimensions,Qe as resolveReadOutputEncoding,en as resolveReadOutputRecoveryBudget,I as resolveReadOutputSurface,fe as stabilizeReadOutputReceiptEstimates,We as validateReadOutputOptions};
|
|
2
2
|
//# sourceMappingURL=read-output-contracts.js.map
|
|
@@ -14,4 +14,4 @@ export{parseExtensionLongFlagToken,resolveExtensionLongFlagName,type ExtensionLo
|
|
|
14
14
|
* configured target, camelized key, CLI flag and aliases in that order.
|
|
15
15
|
* Preserves explicit false and null values; returns undefined when none match.
|
|
16
16
|
*/
|
|
17
|
-
export{readRuntimeFieldOptionValue}from "../core/schema/runtime-field-values.js";export{type RuntimeFieldCommand,type RuntimeFieldRegistry,type RuntimeStatusRegistry,normalizeStatusInputWithRegistry,resolveItemTypesFilePath,resolveRuntimeFieldRegistry,resolveRuntimeStatusRegistry,statusIsTerminal,}from "../core/schema/runtime-schema.js";export{type NormalizedTypeWorkflow,describeAllowedTransitions,evaluateTransition,resolveTypeWorkflows,}from "../core/schema/type-workflows.js";export{REINDEX_LOCK_ID,shouldRunSearchRefreshInForeground,}from "../core/search/background-refresh.js";export{readVectorizationStatusLedger,refreshSearchArtifactsForMutation,writeVectorizationStatusLedger,}from "../core/search/cache.js";export{buildSearchCorpus,buildSemanticCorpusInput,resolveSearchCorpusFields,resolveSemanticCorpusCharacterLimit,}from "../core/search/corpus.js";export{executeEmbeddingBatchesWithRetry,type EmbeddingBatchReceipt,type EmbeddingBatchExecutionOptions,type EmbeddingBatchExecutionResult,type EmbeddingBatchProgressEvent,}from "../core/search/embedding-batches.js";export{resolveEmbeddingProviders}from "../core/search/providers.js";export{resolveSettingsWithSemanticRuntimeDefaults}from "../core/search/semantic-defaults.js";export{executeVectorDelete,executeVectorReset,executeVectorUpsert,resolveVectorStores,}from "../core/search/vector-stores.js";export{type VectorizationEmbeddingIdentity,type VectorizationEmbeddingMetadata,buildVectorizationEmbeddingIdentity,buildVectorizationEmbeddingMetadata,hasVectorizationEmbeddingIdentityChanged,hasVectorizationVectorDimensionChanged,inferConsistentVectorDimension,}from "../core/search/vectorization-metadata.js";export{sentryCaptureCliError,sentryDiscardCommandSpan,sentryFinishCommandSpan,sentryFlush,sentryLogCliUsageError,sentrySetCommandContext,sentryStartCommandSpan,}from "../core/sentry/helpers.js";export{ensureSentryInit,ensureSentryCommandTracing}from "../core/sentry/instrument.js";export{clearFocusedItem,getFocusedItem,setFocusedItem,}from "../core/session/session-state.js";export{readAuthorEnvironment,diagnoseAgentIdentity,resolveAuthor,resolveClaimPrincipal,runWithHarnessDetectionSignals,runWithWorkspaceHarnessSignalDescriptors,BUILTIN_AGENT_PROVENANCE_ADAPTERS,listAgentProvenanceAdapters,normalizeAgentProvenanceAdapterValue,registerAgentProvenanceAdapters,type AgentProvenanceAdapter,type AgentClientInfo,writeAuthorEnvironment,}from "../core/shared/author.js";export{agentSessionEnvironment,boundAgentEpisodeIdentity,runWithAgentSessionContext,resolveAgentSessionContextFromSignals,type AgentEpisodeIdentity,type AgentSessionContext,}from "../core/shared/agent-session-context.js";export{evaluateMutationGuard,isMutationAction,listMutationActions,scanMutationSecrets,type EvaluateMutationGuardOptions,type MutationGuardResult,type MutationGuardSettings,type SecretGuardFinding,type SecretGuardMode,type SecretNormalizationKind,}from "./mutation-guard.js";export{jaccardSimilarity,normalizeSimilarityText,scoreItemSimilarity,tokenizeSimilarityText,type ItemSimilarityScore,}from "./similarity-scoring.js";export{inspectStaleInProgressItems,scanStaleInProgressItems,type InspectStaleInProgressOptions,type StaleInProgressItem,type StaleInProgressScan,}from "./governance/stale-work.js";export type{GlobalOptions}from "../core/shared/command-types.js";export{CREATE_DIRECT_CLOSE_REASON_DEFAULT,EXIT_CODE,ITEM_METADATA_KEY_ORDER,SETTINGS_DEFAULTS,TYPE_TO_FOLDER,type TelemetryErrorCategory,resolveTelemetryErrorCategory,}from "../core/shared/constants.js";export{PmCliError,type PmCliErrorContext,type PmCliErrorRecoveryPayload,}from "../core/shared/errors.js";export{decodeHtmlEntitiesInOptions}from "../core/shared/html-entity-decode.js";export{createLazyModule}from "../core/shared/lazy-module.js";export{levenshteinDistanceWithinLimit}from "../core/shared/levenshtein.js";export{isPureSnakeCaseAlias}from "../core/shared/option-alias-visibility.js";export{asRecordClone,asRecordOrNull,toErrorMessage,toNonEmptyStringOrUndefined,}from "../core/shared/primitives.js";export{createSerialQueue}from "../core/shared/serial-queue.js";export{stableStringify,stableValueEquals,}from "../core/shared/serialization.js";export{splitCommaList}from "../core/shared/split-comma-list.js";export{compareTimestampStrings,nowIso,resolveIsoOrRelative,}from "../core/shared/time.js";export{migrateItemFilesToFormat}from "../core/store/item-format-migration.js";export{type CachedDocumentCandidate,listAllDocumentCandidatesCached,}from "../core/store/item-metadata-cache.js";export{buildItemNotFoundError,createMutationGuardSdk,deleteItem,listAllItemMetadata,listAllItemMetadataLight,locateItem,mutateItem,mutateItemWithHistoryContext,readLocatedItem,type ItemMutationCallback,type ItemMutationLocation,}from "../core/store/item-store.js";export{isTerminalPlanMode,shouldCompletePlanOnClose,}from "../core/item/plan-lifecycle.js";export{getHistoryPath,getItemPath,getSettingsPath,resolveGlobalPmRoot,resolveImplicitPmRoot,resolvePmRoot,resolveWorkspaceRoot,}from "../core/store/paths.js";export{isSettingsReadFallback,persistSelectedItemFormat,readSettings,readSettingsWithMetadata,runWithConfigurationOnlySettings,writeSettings,type WriteSettingsOptions,}from "../core/store/settings.js";export{readSettingsSection,settingsSectionRevision,writeSettingsSection,type ReadSettingsSectionOptions,type SettingsSectionReadResult,type SettingsSectionValidator,type SettingsSectionWriteResult,type WriteSettingsSectionOptions,}from "../core/store/settings-sections.js";export{maybeRunFirstUseTelemetryPrompt}from "../core/telemetry/consent.js";export{type TelemetryCommandResolution,type TelemetryResolutionStage,deriveTelemetryCommandResolution,}from "../core/telemetry/observability.js";export{type ActiveTelemetryCommand,type TelemetryCommandOutcome,emitTelemetryErrorEvent,finishTelemetryCommand,startTelemetryCommand,}from "../core/telemetry/runtime.js";export{resolveTelemetrySourceAttribution}from "../core/telemetry/policy.js";
|
|
17
|
+
export{readRuntimeFieldOptionValue}from "../core/schema/runtime-field-values.js";export{type RuntimeFieldCommand,type RuntimeFieldRegistry,type RuntimeStatusRegistry,normalizeStatusInputWithRegistry,resolveItemTypesFilePath,resolveRuntimeFieldRegistry,resolveRuntimeStatusRegistry,statusIsTerminal,}from "../core/schema/runtime-schema.js";export{type NormalizedTypeWorkflow,describeAllowedTransitions,evaluateTransition,resolveTypeWorkflows,}from "../core/schema/type-workflows.js";export{REINDEX_LOCK_ID,shouldRunSearchRefreshInForeground,}from "../core/search/background-refresh.js";export{readVectorizationStatusLedger,refreshSearchArtifactsForMutation,writeVectorizationStatusLedger,}from "../core/search/cache.js";export{buildSearchCorpus,buildSemanticCorpusInput,resolveSearchCorpusFields,resolveSemanticCorpusCharacterLimit,}from "../core/search/corpus.js";export{executeEmbeddingBatchesWithRetry,type EmbeddingBatchReceipt,type EmbeddingBatchExecutionOptions,type EmbeddingBatchExecutionResult,type EmbeddingBatchProgressEvent,}from "../core/search/embedding-batches.js";export{resolveEmbeddingProviders}from "../core/search/providers.js";export{resolveSettingsWithSemanticRuntimeDefaults}from "../core/search/semantic-defaults.js";export{executeVectorDelete,executeVectorReset,executeVectorUpsert,resolveVectorStores,}from "../core/search/vector-stores.js";export{type VectorizationEmbeddingIdentity,type VectorizationEmbeddingMetadata,buildVectorizationEmbeddingIdentity,buildVectorizationEmbeddingMetadata,hasVectorizationEmbeddingIdentityChanged,hasVectorizationVectorDimensionChanged,inferConsistentVectorDimension,}from "../core/search/vectorization-metadata.js";export{sentryCaptureCliError,sentryDiscardCommandSpan,sentryFinishCommandSpan,sentryFlush,sentryLogCliUsageError,sentrySetCommandContext,sentryStartCommandSpan,}from "../core/sentry/helpers.js";export{ensureSentryInit,ensureSentryCommandTracing}from "../core/sentry/instrument.js";export{clearFocusedItem,getFocusedItem,setFocusedItem,}from "../core/session/session-state.js";export{readAuthorEnvironment,diagnoseAgentIdentity,resolveAuthor,resolveClaimPrincipal,runWithHarnessDetectionSignals,runWithWorkspaceHarnessSignalDescriptors,BUILTIN_AGENT_PROVENANCE_ADAPTERS,listAgentProvenanceAdapters,normalizeAgentProvenanceAdapterValue,registerAgentProvenanceAdapters,type AgentProvenanceAdapter,type AgentClientInfo,writeAuthorEnvironment,}from "../core/shared/author.js";export{agentSessionEnvironment,boundAgentEpisodeIdentity,runWithAgentSessionContext,resolveAgentSessionContextFromSignals,type AgentEpisodeIdentity,type AgentSessionContext,}from "../core/shared/agent-session-context.js";export{evaluateMutationGuard,isMutationAction,listMutationActions,scanMutationSecrets,type EvaluateMutationGuardOptions,type MutationGuardResult,type MutationGuardSettings,type SecretGuardFinding,type SecretGuardMode,type SecretNormalizationKind,}from "./mutation-guard.js";export{jaccardSimilarity,normalizeSimilarityText,scoreItemSimilarity,tokenizeSimilarityText,type ItemSimilarityScore,}from "./similarity-scoring.js";export{inspectStaleInProgressItems,scanStaleInProgressItems,type InspectStaleInProgressOptions,type StaleInProgressItem,type StaleInProgressScan,}from "./governance/stale-work.js";export type{GlobalOptions}from "../core/shared/command-types.js";export{CREATE_DIRECT_CLOSE_REASON_DEFAULT,EXIT_CODE,ITEM_METADATA_KEY_ORDER,SETTINGS_DEFAULTS,TYPE_TO_FOLDER,type TelemetryErrorCategory,resolveTelemetryErrorCategory,}from "../core/shared/constants.js";export{PmCliError,type PmCliErrorContext,type PmCliErrorRecoveryPayload,}from "../core/shared/errors.js";export{decodeHtmlEntitiesInOptions}from "../core/shared/html-entity-decode.js";export{createLazyModule}from "../core/shared/lazy-module.js";export{levenshteinDistanceWithinLimit}from "../core/shared/levenshtein.js";export{isPureSnakeCaseAlias}from "../core/shared/option-alias-visibility.js";export{asRecordClone,asRecordOrNull,toErrorMessage,toNonEmptyStringOrUndefined,}from "../core/shared/primitives.js";export{createSerialQueue}from "../core/shared/serial-queue.js";export{stableStringify,stableValueEquals,}from "../core/shared/serialization.js";export{splitCommaList}from "../core/shared/split-comma-list.js";export{compareTimestampStrings,nowIso,resolveIsoOrRelative,}from "../core/shared/time.js";export{migrateItemFilesToFormat}from "../core/store/item-format-migration.js";export{type CachedDocumentCandidate,listAllDocumentCandidatesCached,}from "../core/store/item-metadata-cache.js";export{buildItemNotFoundError,createMutationGuardSdk,deleteItem,listAllItemMetadata,listAllItemMetadataLight,locateItem,mutateItem,mutateItemWithHistoryContext,readLocatedItem,type CallerClaimScope,type ItemMutationCallback,type ItemMutationLocation,}from "../core/store/item-store.js";export{isTerminalPlanMode,shouldCompletePlanOnClose,}from "../core/item/plan-lifecycle.js";export{getHistoryPath,getItemPath,getSettingsPath,resolveGlobalPmRoot,resolveImplicitPmRoot,resolvePmRoot,resolveWorkspaceRoot,}from "../core/store/paths.js";export{isSettingsReadFallback,persistSelectedItemFormat,readSettings,readSettingsWithMetadata,runWithConfigurationOnlySettings,writeSettings,type WriteSettingsOptions,}from "../core/store/settings.js";export{readSettingsSection,settingsSectionRevision,writeSettingsSection,type ReadSettingsSectionOptions,type SettingsSectionReadResult,type SettingsSectionValidator,type SettingsSectionWriteResult,type WriteSettingsSectionOptions,}from "../core/store/settings-sections.js";export{maybeRunFirstUseTelemetryPrompt}from "../core/telemetry/consent.js";export{type TelemetryCommandResolution,type TelemetryResolutionStage,deriveTelemetryCommandResolution,}from "../core/telemetry/observability.js";export{type ActiveTelemetryCommand,type TelemetryCommandOutcome,emitTelemetryErrorEvent,finishTelemetryCommand,startTelemetryCommand,}from "../core/telemetry/runtime.js";export{resolveTelemetrySourceAttribution}from "../core/telemetry/policy.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Whether a stored custom field flag or alias is exactly one option
|
|
3
|
+
* spelling (pm-8patuh). Dependency-free, because CLI registration consults it
|
|
4
|
+
* on every invocation that registers runtime field options.
|
|
5
|
+
*/
|
|
6
|
+
/** A stored token with exactly one leading dash is a short flag (`-x`); stored long flags carry no dashes. */
|
|
7
|
+
export declare function isShortFieldFlagSpelling(token:string):boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Why a stored flag or alias token is not exactly one option spelling, or
|
|
10
|
+
* `undefined` when it is. Tokens are stored without their leading `--`; a
|
|
11
|
+
* token with one leading dash registers as a short flag, which the parser
|
|
12
|
+
* accepts only as one dash and one character. A token the parser would split
|
|
13
|
+
* (`full|detail`) registers a second option or fails the command before it
|
|
14
|
+
* starts.
|
|
15
|
+
*/
|
|
16
|
+
export declare function describeFieldFlagSpellingDefect(token:string):string|undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the CLI registers a stored field flag or alias as an option: it is
|
|
19
|
+
* one option spelling and not the implicit help option. Registration and
|
|
20
|
+
* recovery routes share this, so a retry never names a skipped spelling.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isRegistrableFieldFlagSpelling(token:string):boolean;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function a(n){const e=n.trim();return e.startsWith("-")&&!e.startsWith("--")}const r=/[\s|,=<>[\]]/u;function i(n){const e=n.trim();if(a(e))return e.length===2&&!r.test(e[1])?void 0:"is not a short flag: a short flag is one dash and one character";const s=e.replace(/^--/u,"");if(s.length===0)return"is empty";if(s.startsWith("-"))return"starts with three dashes";if(s.endsWith("-")||s.includes("--"))return"has an empty segment between hyphens, which the option parser cannot turn into an option key";const t=r.exec(s)?.[0];if(t!==void 0)return/\s/u.test(t)?"contains whitespace, which the option parser reads as a break between two flags":`contains ${JSON.stringify(t)}, which the option parser reads as ${t==="|"||t===","?"a break between two flags":t==="="?"the start of an attached value":"a value placeholder"}`}const o=new Set(["-h","help"]);function h(n){const e=n.trim();return i(e)===void 0&&!o.has(e.replace(/^--/u,""))}export{i as describeFieldFlagSpellingDefect,h as isRegistrableFieldFlagSpelling,a as isShortFieldFlagSpelling};
|
|
2
|
+
//# sourceMappingURL=field-flag-spelling.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{GLOBAL_FLAG_CONTRACTS as
|
|
1
|
+
import{GLOBAL_FLAG_CONTRACTS as y,resolveSubcommandFlagContractsForCommand as k}from"../cli-contracts/flag-contracts.js";import{BUILTIN_FIELD_KEYS as w}from"../../core/schema/fields-file.js";import{EXIT_CODE as d,ITEM_METADATA_KEY_ORDER as A}from"../../core/shared/constants.js";import{PmCliError as m}from"../../core/shared/errors.js";import{commanderOptionAttribute as F,resolveCandidateOptionKeys as C}from"../../core/schema/runtime-field-values.js";import{normalizeCliToken as S,resolveRuntimeFieldRegistry as p}from"../../core/schema/runtime-schema.js";import{describeFieldFlagSpellingDefect as v,isShortFieldFlagSpelling as s}from"./field-flag-spelling.js";function g(e){return e.trim().toLowerCase().replace(/^-+/u,"")}function _(e){const o=g(e),i=C({key:o,cli_flag:o,cli_aliases:[]});return[...new Set([...i,F(o)])]}const E=new Set(A.filter(e=>!w.has(e))),O={flag:"--help",short:"-h"},h=new Map;function x(e){let o=h.get(e);if(o===void 0){const i=new Map,n=new Map;for(const l of[...k(e),...y,O]){for(const a of[l.flag,...l.aliases??[]].flatMap(_))i.has(a)||i.set(a,l.flag);l.short!==void 0&&!n.has(l.short)&&n.set(l.short,l.flag)}o={long:i,short:n},h.set(e,o)}return o}function $(e,o){return s(e)?o.short.get(e.trim()):_(e).map(i=>o.long.get(i)).find(i=>i!==void 0)}function r(e){const o=[];for(const i of e){const n=[...new Set([i.cli_flag,...i.cli_aliases,i.key].map(l=>s(l)?l.trim():g(l)))];for(const l of i.commands)o.push(...b(i.key,n,l.replaceAll("_","-")))}return o.sort((i,n)=>i.field.localeCompare(n.field)||i.command.localeCompare(n.command)||i.option.localeCompare(n.option))}function b(e,o,i){const n=x(i),l=new Map;for(const a of o){if(E.has(e)&&a.replaceAll("-","_")===e)continue;const t=$(a,n);t===void 0||l.has(t)||l.set(t,{field:e,command:i,field_flag:s(a)?a:`--${a.replaceAll("_","-")}`,option:t})}return[...l.values()]}function T(e){return r([{key:e.key,cli_flag:e.cliFlag??e.key.replaceAll("_","-"),cli_aliases:e.cliAliases,commands:e.commands}])}function c(e){return e.flatMap(o=>[...new Set([o.cli_flag,...o.cli_aliases])].flatMap(i=>{const n=v(i);return n===void 0?[]:[{field:o.key,spelling:i,reason:n}]}))}function D(e){return c([{key:e.key,cli_flag:e.cliFlag??e.key.replaceAll("_","-"),cli_aliases:e.cliAliases}])}function I(e){return`${JSON.stringify(e.spelling)} ${e.reason}`}function M(e){return`${e.field_flag} shadows built-in ${e.option} on pm ${e.command}`}function U(e,o){const i=p(e).definitions,n=r(i),l=c(i),a=l.length===0?{details:{},warnings:[]}:{details:{schema_field_flag_invalid_count:l.length,schema_field_flag_invalid:l.slice(0,o),schema_field_flag_invalid_truncated:l.length>o,schema_field_flag_invalid_fix_hint:"Re-register the field with one flag and one spelling per alias: pm schema add-field <key> --cli-flag <flag> --alias <alias>. A short alias is one dash and one character. Edit a field defined inline in settings.json there."},warnings:[`validate_schema_field_flag_invalid:${l.length}`]};return n.length===0?a:{details:{...a.details,schema_field_option_collision_count:n.length,schema_field_option_collisions:n.slice(0,o),schema_field_option_collisions_truncated:n.length>o,schema_field_option_collision_fix_hint:"Rename a file-backed field without losing item values: pm schema rename-field <key> --to <new-key>. For a colliding flag, alias or command list, re-register the same key: pm schema add-field <key> --cli-flag <flag> --commands <commands>. Edit a field defined inline in settings.json there."},warnings:[...a.warnings,`validate_schema_field_option_collision:${n.length}`]}}function Y(e){f(e.key,D(e)),u(e.key,e.commands,T(e))}function q(e){const o=[e.cli_flag,...Array.isArray(e.cli_aliases)?e.cli_aliases:[]].filter(n=>typeof n=="string");f(e.key,o.filter(n=>S(n).length===0).map(n=>({field:e.key,spelling:n,reason:"is empty"})));const i=p({fields:[e]}).definitions;f(e.key,c(i)),u(e.key,i.flatMap(n=>n.commands),r(i))}function f(e,o){if(o.length!==0)throw new m(`Cannot define custom field "${e}": flag ${o.map(I).join("; ")}. The command it is registered for could not register it as one option.`,d.USAGE,{code:"schema_field_flag_invalid",field:e,flag:o[0].spelling,required:"Each custom field flag and alias must be one option spelling: a long name without spaces, pipes, commas, '=' or brackets, or a short flag of one dash and one character.",nextSteps:[`Pass one spelling per --alias, for example pm schema add-field ${e} --alias <first> --alias <second>.`]})}function u(e,o,i){if(i.length===0)return;const n={key:e,commands:o},l=new Set(i.map(t=>t.command)),a=n.commands.filter(t=>!l.has(t.replaceAll("_","-")));throw new m(`Cannot define custom field "${n.key}": ${i.map(M).join("; ")}. The built-in option would stop working for that command.`,d.USAGE,{code:"schema_field_option_collision",field:n.key,flag:i[0].option,required:"A custom field's key, flag and aliases must differ from every built-in option of each command it is registered for.",nextSteps:[`Rename the field with a project-specific prefix, for example pm schema add-field project_${n.key}.`,...a.length>0?[`Or register "${n.key}" only where its option is free: --commands ${a.join(",")}.`]:[]]})}export{q as assertFieldDefinitionOptionsAvailable,Y as assertFieldOptionsAvailable,I as describeFieldFlagSpellingDefectLine,M as describeFieldOptionCollision,D as resolveAddFieldFlagSpellingDefects,T as resolveAddFieldOptionCollisions,c as resolveFieldFlagSpellingDefects,r as resolveFieldOptionCollisions,U as scanFieldOptionCollisions};
|
|
2
2
|
//# sourceMappingURL=field-option-collisions.js.map
|
package/docs/AGENT_GUIDE.md
CHANGED
|
@@ -194,10 +194,10 @@ Use the canonical [guide topic map](README.md#guide-topic-map) when local in-CLI
|
|
|
194
194
|
- Claim before heavy edits.
|
|
195
195
|
- `pm claim <id>` is an atomic test-and-set. A non-terminal item already held by a different principal refuses with `already_claimed_by` and names the holder in typed fields (`claimed_by`, `claim_source`, `claimed_at`); the same principal re-claiming is a no-op.
|
|
196
196
|
- Pass `--if-available` to treat a held item as a skip (`skipped: true`, exit 0) instead of a failure, for example when several agents pull from one queue. The terminal check runs first, so a terminal item still refuses without `--force` even when `--if-available` is set.
|
|
197
|
-
- The refusal also carries `claim_activity`: the holder's `claim_age_hours`, `last_activity_at` (the newer of the item's `updated_at` and its latest substantive history entry: a restore writes an older `updated_at` and counts, a compaction baseline counts with the newest work it pruned, and maintenance such as the `history-compact` audit entry does not), `idle_hours`, and the `stale_policy` it was judged against (`mutation_guard.stale_in_progress_hours`, default 72, with `stale` and `eligible_at`). `pm next` reports `claimed_at`, `idle_hours` and `stale` on each `held_by_others` row.
|
|
197
|
+
- The refusal also carries `claim_activity`: the holder's `claim_age_hours`, `last_activity_at` (the newer of the item's `updated_at` and its latest substantive history entry: a restore writes an older `updated_at` and counts, a compaction baseline counts with the newest work it pruned, and maintenance such as the `history-compact` audit entry does not), `idle_hours`, the holder's activity `state`, and the `stale_policy` it was judged against (`mutation_guard.stale_in_progress_hours`, default 72, with `stale` and `eligible_at`). `state` is `stale` or `active` when the recorded activity can be judged, and `unknown` when the history is unreadable (`history_unreadable`), cannot prove idleness (`unproven_activity`), or records no valid activity time; text refusals then print `activity unknown` with the cause instead of calling the holder active ([GH-1774](https://github.com/unbraind/pm-cli/issues/1774)). `pm next` reports `claimed_at`, `idle_hours` and `stale` on each `held_by_others` row.
|
|
198
198
|
- Pass `--takeover-stale` to take over a claim whose holder has recorded nothing for at least that threshold. An active or too-recent claim refuses with `stale_claim_takeover_refused`, writes nothing, and names when it becomes eligible. The decision is made under the item lock, which serializes it with the holder's mutations: a renewal recorded before the takeover takes the lock is seen and refuses the takeover, and one that arrives after it lands on the new holder's claim. A history stream that exists but cannot be read is never judged stale: the refusal is still `stale_claim_takeover_refused`, with `claim_activity.history_unreadable: true` as its evidence. The takeover anchors on the holder's own claim record, so it also refuses when that record is missing or was folded into a compaction baseline, or when a salvage, repair, redaction, merge reconcile or workspace restore after the claim discarded or rewrote records (`claim_activity.unproven_activity`). The holder can release such an item, or a coordinated `--force` can take it. A permitted takeover records `previous_holder`, `new_holder`, `last_activity_at`, `idle_hours`, `threshold_hours` and the policy in the claim history entry's `context.stale_claim_takeover`, and returns the same receipt as `takeover`. Combined with `--if-available`, an active claim is skipped instead of refused. It cannot be combined with `--force` or `--next`.
|
|
199
199
|
- Use `--force` only for a coordinated takeover of another owner's claim; it is also required to claim terminal items, and to override stale locks when the `governance.force_required_for_stale_lock` policy is enabled (the `minimal` and custom governance presets can disable it). Never force a takeover without explicit approval.
|
|
200
|
-
- Release when pausing, handing off, or after close.
|
|
200
|
+
- Release when pausing, handing off, or after close. A close already ends the holder's claim, so the release after it changes nothing. If another principal claims the item between your close and your release, your release leaves that claim in place under every ownership policy, `--force` included. It writes nothing and reports `release_claim_ended_by_close:<id>:<holder>` ([GH-1774](https://github.com/unbraind/pm-cli/issues/1774)). The protection relies on the item's history proving that a close ended your claim. If `pm history-compact` has folded your claim and the close into a baseline, or the stream cannot be replayed, the ownership policy applies as for any other non-holder release. The new holder releases its own claim. A `--handoff` or `--pause` release in that state is refused with `release_claim_ended_by_close` before any write, because it would move another holder's work. A pause's status write is bound to the item state the pause judged: if a claim, close or reopen lands in between, the write refuses with `pause_item_changed` and nothing changes.
|
|
201
201
|
|
|
202
202
|
### Implementation-to-verification handoff
|
|
203
203
|
|
package/docs/COMMANDS.md
CHANGED
|
@@ -1688,7 +1688,7 @@ pm create Spike "Investigate retry backoff"
|
|
|
1688
1688
|
- `add-status <id>` writes a custom lifecycle status (idempotent UPSERT keyed on the normalized id; re-adding sets `replaced: true`). Roles are validated against the runtime status roles: `draft`, `active`, `blocked`, `terminal`, `terminal_done`, `terminal_canceled`, `default_open`, `default_close`, `default_cancel`.
|
|
1689
1689
|
- `remove-status <id>` removes a custom status. The six built-in statuses (`open`, `in_progress`, `blocked`, `closed`, `canceled`, `draft`) are refused. It WARNS (non-blocking) with `items_using_status:<N>` when items currently use that status.
|
|
1690
1690
|
- Built-in types (Chore, Decision, Epic, Event, Feature, Issue, Meeting, Milestone, Plan, Reminder, Task) are reserved and cannot be redefined or removed.
|
|
1691
|
-
- `add-field <key>` registers a custom metadata field in `.agents/pm/schema/fields.json` (shape: `{ "fields": [RuntimeFieldDefinition...] }`). Each custom field dynamically registers a CLI flag on create/update (and any other commands you list) so projects can capture typed project-specific metadata without hand-editing JSON. It is an idempotent UPSERT keyed on the normalized key, and refuses keys that shadow a built-in field. It also refuses a field whose key, flag or alias equals a built-in option of a command it is registered for (`schema_field_option_collision`, exit 2): the parser keeps one option per name, so `pm schema add-field full --commands create,list` would make `pm list --full` read as a field filter. Names are compared as the option keys a value is read under, so punctuation counts as a word break (`token.budget` equals `--token-budget`). The refusal names each shadowed option per command and, when some requested commands are free, the narrower `--commands` list. `severity` is the one built-in a field may redefine. `pm profile apply` and `pm schema rename-field` (for the target name, dry run included) refuse the same way, `pm profile lint` reports `field_option_collision`, and `pm validate --check-metadata` reports fields already stored as `validate_schema_field_option_collision:<n>` with rows under `schema_field_option_collisions` ([pm-pta8um](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-pta8um.toon); repository-only tracker record excluded from npm). `list-fields` / `show-field <key>` inspect registered fields; `remove-field <key>` drops one and WARNS (non-blocking) with `items_using_field:<N>` when items still carry a value. See [CONFIGURATION.md](CONFIGURATION.md) for the full `schema/fields.json` format.
|
|
1691
|
+
- `add-field <key>` registers a custom metadata field in `.agents/pm/schema/fields.json` (shape: `{ "fields": [RuntimeFieldDefinition...] }`). Each custom field dynamically registers a CLI flag on create/update (and any other commands you list) so projects can capture typed project-specific metadata without hand-editing JSON. It is an idempotent UPSERT keyed on the normalized key, and refuses keys that shadow a built-in field. It also refuses a field whose key, flag or alias equals a built-in option of a command it is registered for (`schema_field_option_collision`, exit 2): the parser keeps one option per name, so `pm schema add-field full --commands create,list` would make `pm list --full` read as a field filter. Names are compared as the option keys a value is read under, so punctuation counts as a word break (`token.budget` equals `--token-budget`). The refusal names each shadowed option per command and, when some requested commands are free, the narrower `--commands` list. `severity` is the one built-in a field may redefine. `pm profile apply` and `pm schema rename-field` (for the target name, dry run included) refuse the same way, `pm profile lint` reports `field_option_collision`, and `pm validate --check-metadata` reports fields already stored as `validate_schema_field_option_collision:<n>` with rows under `schema_field_option_collisions` ([pm-pta8um](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-pta8um.toon); repository-only tracker record excluded from npm). Each flag and alias must also be one option spelling: a long name without spaces, pipes, commas, `=` or brackets, or a short flag of one dash and one character. A spelling the parser would split (`--alias 'full|deep'` registers a second `--full`) or a malformed short flag (`-xy`) is refused with `schema_field_flag_invalid` (exit 2) by `add-field`, `profile apply` and `rename-field`; `pm profile lint` reports `field_flag_invalid`. A short spelling is compared with the command's own short flags (`-p` is `--priority` on create and update), and `-h`/`--help` are reserved on every command. `pm validate --check-metadata` reports stored spellings as `validate_schema_field_flag_invalid:<n>` with rows under `schema_field_flag_invalid` (a stored definition the registry drops entirely, such as an empty flag, is not reported yet: [pm-x9r2h3](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-x9r2h3.toon), repository tracker record excluded from npm), and the CLI skips such a spelling when it registers field options, so a stored definition can no longer stop a command from starting or take over help; an SDK caller checks one spelling with `describeFieldFlagSpellingDefect` from `@unbrained/pm-cli/sdk`, which returns the reason or `undefined` ([pm-8patuh](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-8patuh.toon); repository tracker record, excluded from npm). `list-fields` / `show-field <key>` inspect registered fields; `remove-field <key>` drops one and WARNS (non-blocking) with `items_using_field:<N>` when items still carry a value. See [CONFIGURATION.md](CONFIGURATION.md) for the full `schema/fields.json` format.
|
|
1692
1692
|
- `apply-preset <agile|ops|research>` batch-registers a domain type preset into an already-initialized project (the same vocabulary `pm init --type-preset` seeds); it is idempotent (re-running reports `replaced` entries) and shares its definitions with init.
|
|
1693
1693
|
- `add-type --infer` scans existing item titles for stable `PREFIX-`/`PREFIX:` conventions and proposes them as custom types. It previews candidates by default (dry-run); pass `--apply` to register the non-shadowing candidates and `--min-count <n>` to tune the per-prefix threshold (default 10). Candidates whose name resolves to a built-in type are reported and skipped.
|
|
1694
1694
|
- `rename-type`, `rename-field`, and `remap-status` are lossless migration verbs. The runtime derives a deterministic workspace-and-request-bound migration id for resumable retries; `--migration-id` remains an optional authoritative override for external orchestration. Start with `--dry-run --json` to inspect the derived id, fingerprint, affected count, and ordered per-item changes without persisting a plan. Execution stages the target definition, writes immutable history on every affected item and the workspace stream, then retires the source. A field rename refuses any item that already has the target key; `--type <Type>` optionally restricts a field rename.
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -245,6 +245,7 @@ underscore aliases remain accepted for compatibility.
|
|
|
245
245
|
| `PM_OLLAMA_MODEL` | choose default Ollama embedding model |
|
|
246
246
|
| `PM_DISABLE_OLLAMA_AUTO_DEFAULTS` | disable implicit Ollama search defaults |
|
|
247
247
|
| `PM_CONTEXT_USAGE_DISABLED` | set to `1` to disable the derived context/next usage-feedback ledger with zero filesystem reads or writes |
|
|
248
|
+
| `PM_COMMAND_SHELL` | shell the pm commands printed in recovery guidance (`suggested_retry`, `restore_with`, next steps) are quoted for: `posix` (also `sh`, `bash`, `zsh`), `cmd` (also `cmd.exe`) or `powershell` (also `pwsh`), case-insensitive. Default: `cmd` on Windows, `posix` elsewhere; an empty or unrecognized value keeps the default. In the `cmd` form, an argument that contains `%` or `"` has every cmd.exe metacharacter caret-escaped and a caret after each `%`, so cmd.exe cannot expand `%VAR%` or split the line at `&`. That holds as long as no environment variable is defined whose name starts with `^`, and while delayed expansion (`cmd /v:on`) stays off, its default. cmd.exe ends a command at a line break, which no quoting carries, so the cmd form renders each line break inside an argument as a space. npm's `pm.cmd` launcher parses its arguments a second time, so an argument holding `"` together with `^`, `&`, `\|`, `<` or `>` needs the native entry point (`node <install>/dist/cli.js`) or PowerShell's `pm.ps1`. The `powershell` form uses single-quoted literals, so `$`, `$(...)`, backticks and `%` never expand. Arguments then reach the native command exactly under PowerShell 7.3 or later in its default argument-passing mode. Windows PowerShell 5.1, and `$PSNativeCommandArgumentPassing = 'Legacy'`, drop empty arguments and mangle embedded double quotes. The `posix` form single-quotes an argument that holds `!`, which interactive bash and zsh would history-expand inside double quotes, and quotes a token that starts with `=`, which zsh expands to a command path ([GH-1774](https://github.com/unbraind/pm-cli/issues/1774)) |
|
|
248
249
|
| `PM_EXTENSION_UPDATE_CHECK_TIMEOUT_MS` | budget of each managed-package update lookup (`npm view` or `git ls-remote`) in integer milliseconds; default `10000`, clamped to `1000`–`25000`; `pm package manage --fix-managed-state` keeps the default because it looks up under the extension state lock. A lookup that runs out reports `npm_registry_lookup_timed_out` or `github_remote_lookup_timed_out` with `update_check_timeout_ms` |
|
|
249
250
|
|
|
250
251
|
For command-level tracker targeting, prefer `--pm-path <tracker-root>`. The old
|
package/docs/EXTENSIONS.md
CHANGED
|
@@ -306,7 +306,7 @@ Use the public SDK barrel. Do not deep-import from `src/core` or `dist/core`.
|
|
|
306
306
|
- `api.extension` is a read-only identity (`name`, `layer`, `version`, `capabilities`, `pm_min_version?`, `pm_max_version?`, `source_package?`) for self-identifying logs and version gating without re-reading the manifest.
|
|
307
307
|
- `api.registerCommand(definition)` adds package-owned commands; `read_output` opts readers into the [SDK output contract](SDK.md#minimal-command-extension).
|
|
308
308
|
- `api.registerFlags(command, flags)` adds runtime command flags. A flag may declare `value_type` (canonical; the legacy `type` alias is honored only when `value_type` is absent), `list: true` to accumulate repeated/comma-joined values like core `--tags`, a `default` applied when the flag is omitted, and `value_validation: "strict"` to refuse malformed `number`/`boolean` tokens before the handler runs (the default `"coerce"` forwards the raw token). The handler reads each flag from `context.options` under its camel-case handler key (`--status-filter` → `statusFilter`), published as `sdk_option` by `pm contracts --command <command> --flags-only --json`; CLI, `PmClient.run`, MCP, and `runRegisteredCommandForTest` all deliver that key with the same defaults and coercion, and host flags such as `--json`, `--author`, and `--pm-path` arrive in `context.global` and are listed as `inherited_flags`. On the CLI, a command that declares flags refuses any other option with `unknown_option` before the handler runs (a command that declares none still receives undeclared options for now, see pm-4of199 in the SDK guide), and two spellings of one flag with different values (`--status-filter open -s closed`) are refused with `extension_option_spelling_conflict`, so declare every option a handler reads. See [Handler keys and ownership](SDK.md#handler-keys-and-ownership).
|
|
309
|
-
- `api.registerItemFields(fields)` adds custom metadata fields. Agents can set declared fields with repeatable `pm create --field name=value` and `pm update <id> --field name=value`; undeclared names are rejected. Extension declarations are matched first; a name that no active extension declares but the project schema does (for example `gate_evidence`) is refused with `project_schema_field_requires_declared_flag`, which names a CLI flag and an SDK option that each set only that field (each is omitted when every spelling is shared with another declared field or with an option of the command itself) and, on the CLI, an executable `suggested_retry_args` that rewrites only that assignment. The guidance follows the invoking scope (a bulk `update-many` row is routed under `update_many`, not `update`), and when the same invocation already sets that field through a declared flag, alias or option, no route or retry is offered, because the retry would carry two values for one field ([pm-wftvem](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-wftvem.toon); tracker record excluded from npm); reserved core keys keep `core_item_field_requires_dedicated_flag`. `SchemaFieldDefinition.type` is the same closed union used by `pm schema add-field`: `string | number | boolean | string_array | array | object`. Unsupported values fail at compile time for TypeScript authors and at activation for JavaScript packages, with a did-you-mean hint on typos. `string_array` is the repeatable string collection; `array` and `object` require JSON containers. Active fields support `get`, `list` and `search` projections with `--fields name` or `--fields item.name`, preserving declared value types through `PmClient` and CLI reads. Disabled packages do not contribute selectors. Tracked by [pm-gh1571](../.agents/pm/issues/pm-gh1571.toon).
|
|
309
|
+
- `api.registerItemFields(fields)` adds custom metadata fields. Agents can set declared fields with repeatable `pm create --field name=value` and `pm update <id> --field name=value`; undeclared names are rejected. Extension declarations are matched first; a name that no active extension declares but the project schema does (for example `gate_evidence`) is refused with `project_schema_field_requires_declared_flag`, which names a CLI flag and an SDK option that each set only that field (each is omitted when every spelling is shared with another declared field or with an option of the command itself) and, on the CLI, an executable `suggested_retry_args` that rewrites only that assignment. The guidance follows the invoking scope (a bulk `update-many` row is routed under `update_many`, not `update`), and when the same invocation already sets that field through a declared flag, alias or option, no route or retry is offered, because the retry would carry two values for one field ([pm-wftvem](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-wftvem.toon); tracker record excluded from npm); reserved core keys keep `core_item_field_requires_dedicated_flag`. `SchemaFieldDefinition.type` is the same closed union used by `pm schema add-field`: `string | number | boolean | string_array | array | object`. Unsupported values fail at compile time for TypeScript authors and at activation for JavaScript packages, with a did-you-mean hint on typos. `string_array` is the repeatable string collection; `array` and `object` require JSON containers. Active fields support `get`, `list` and `search` projections with `--fields name` or `--fields item.name`, preserving declared value types through `PmClient` and CLI reads. Disabled packages do not contribute selectors. Tracked by [pm-gh1571](../.agents/pm/issues/pm-gh1571.toon). Item fields an extension registers are set through the repeatable `--field name=value` assignment, not through a per-field option, so a name such as `full` or `limit` leaves `pm list --full`, `pm list --limit` and `pm search --full` working as before; the built-in option collision check that `pm schema add-field` applies does not apply to them. Such a name still meets the projection-mode vocabulary of `--output-include` (`full` there selects the full projection), so select it with `--fields <name>` ([pm-3s4jwl](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-3s4jwl.toon); tracker record excluded from npm).
|
|
310
310
|
- Custom fields whose camel-case option name is already owned by a canonical MCP input remain usable through `options.<name>`, but authoring surfaces report the collision instead of allowing silent top-level shadowing. `pm schema add-field`, `pm profile lint`, and `pm package doctor` name the field, canonical `mcp_tool_input` owner, and nested recovery path. SDK authors can preflight the same rule with `resolvePmToolCustomFieldCollision`. A separate, stricter rule covers CLI options: a field whose key, flag or alias equals a built-in option of a command it is registered for is refused by `pm schema add-field` and `pm profile apply` with `schema_field_option_collision`, because the built-in option would stop working there; give profile fields a project-specific prefix or list only commands where the name is free.
|
|
311
311
|
- `api.registerItemTypes(types)` adds custom item types.
|
|
312
312
|
- `api.registerRelationshipKinds(definitions)` adds validated graph semantics. Definitions declare direction, inverse spelling, ordering/precedence, hierarchy, cardinality, lifecycle, aliases, payload schema, compatibility version, and self-edge policy. Active definitions govern CLI, MCP, and SDK dependency mutation admission as well as workspace graph assembly; mutation aliases are stored canonically. Requires the `schema` capability and is governed by the `schema.relationshipkinds` policy surface. See [relationship mutation admission](RELATIONSHIP_GRAPH.md#contract), tracked by [pm-7dsolo](../.agents/pm/issues/pm-7dsolo.toon).
|
|
@@ -333,13 +333,63 @@ its quoted text, at a shell control operator or redirection (`|`, `&`, `;`,
|
|
|
333
333
|
quoted text those characters are data, and any other parenthesis or brace is
|
|
334
334
|
literal data. A quoted value under a quoted key did as well when structure
|
|
335
335
|
and then the next member or element follows, as in compact JSON (`{"password":"$DB_PASSWORD","other":…}`,
|
|
336
|
-
`[{"password":"$DB_PASSWORD"},{"other":…}]`).
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
336
|
+
`[{"password":"$DB_PASSWORD"},{"other":…}]`). An unquoted value did too when
|
|
337
|
+
the quote after it closes the string the value sits in and a word end follows
|
|
338
|
+
that quote: whitespace, the end of the text, or structure, optional blanks
|
|
339
|
+
and then a line break, the end of the text, or the next member or element
|
|
340
|
+
(`{"cmd":"password=$DB_PASSWORD"}`, `["password=$DB_PASSWORD"], "next"`,
|
|
341
|
+
`Use "password: $DB_PASSWORD" in config`). Any other text after it (`$PW:…`,
|
|
342
|
+
`$PW[…`, `$PW,"…"`, `"$PW""…"`) belongs to the same word, and so does any
|
|
343
|
+
other quote after an unquoted value, which may open a concatenated piece
|
|
344
|
+
(`$PW""…`, `$PW" spaced literal"`), or a quote no string opened (a YAML plain
|
|
345
|
+
scalar ending in `"`). In those cases the value keeps its `$NAME` text
|
|
346
|
+
literal.
|
|
347
|
+
|
|
348
|
+
A value that sits in a string ends at that string's closing quote
|
|
349
|
+
([pm-gh1775](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-gh1775.toon);
|
|
350
|
+
tracker record excluded from npm). A payload string such as
|
|
351
|
+
`{"title":"api_key: ${API_KEY}","updated":"…"}` holds an assignment inside the
|
|
352
|
+
title string. The two key-named rules find the string a value sits in with
|
|
353
|
+
one linear lexical pass over the text: a quote opens a string of its kind
|
|
354
|
+
when none is open and closes the open string of its kind, a quote of the
|
|
355
|
+
other kind inside a string is data, a quote right after a letter, digit or
|
|
356
|
+
underscore never opens one (a prose apostrophe such as `customer's`, or a
|
|
357
|
+
unit mark), a backslash escapes the next character, and a line feed or
|
|
358
|
+
carriage return ends every string (U+2028 and U+2029 are data inside a JSON
|
|
359
|
+
string). When that string's closing quote lies inside the captured value,
|
|
360
|
+
after its first character, or directly after it, and a word end as above
|
|
361
|
+
follows the quote, the value ends there. After a closing quote, an unquoted
|
|
362
|
+
YAML flow key (`{title: "…", updated: ok}`) is a word end too, and so is the
|
|
363
|
+
end of an XML tag (`"/>`, `">`) when the string is an attribute value (its
|
|
364
|
+
quote follows `=` and optional blanks inside an open start tag such as
|
|
365
|
+
`<setting value=`), and blanks after its structure are padding however
|
|
366
|
+
many there are. A quote at the value's first character is never a cut point,
|
|
367
|
+
because after a stray apostrophe it may be the value's own opening quote, and
|
|
368
|
+
neither is a quote inside the capture that a blank follows, which can only be
|
|
369
|
+
data of the value's own quoted text (`"devs' portal"`, `${PW:-" … "}`). So `","` and the next member are
|
|
370
|
+
never read as quoted pieces concatenated to the value, however long the next
|
|
371
|
+
member is, and the scan resumes at the closing quote, so keys in the later
|
|
372
|
+
members are still scanned. The bare reference is then judged as a whole value
|
|
373
|
+
and stays clean under every credential key, while a literal attached to it
|
|
374
|
+
inside the string (`${EMPTY}…`, `${KEY:-…}`) and a credential member next to it
|
|
375
|
+
are still reported. A value that sits in no string keeps its own quoted
|
|
376
|
+
pieces (`password="$PW","…"`, a YAML single-quoted scalar whose doubled
|
|
377
|
+
quotes are data), and a closing quote that another quote or a word follows
|
|
378
|
+
(`echo "api_key=${EMPTY}""…"`) continues the shell word, as before.
|
|
379
|
+
|
|
380
|
+
A whole Windows variable (`%DB_PASSWORD%`) is a placeholder for every
|
|
381
|
+
key-named rule. `cmd.exe` reads `set NAME=value` to the end of the line, so an
|
|
382
|
+
unquoted text value is whole only when nothing but blanks follows it on its
|
|
383
|
+
line or when it ends at the string it sits in; a decoded literal and an
|
|
384
|
+
element body are whole by construction, and a quoted value is whole when the
|
|
385
|
+
end of its line follows its closing quote, or, for a structured value (a
|
|
386
|
+
quoted key's, an array element, or a value after a `:` separator),
|
|
387
|
+
structure (`,` `;` `)` `}` `]`) does, because a `set` line or any other `=`
|
|
388
|
+
assignment keeps whatever follows its quote. So under a password key a dotenv or `set` line whose percent reference more
|
|
389
|
+
words follow is still reported; under a credential key a literal attached to
|
|
390
|
+
the reference (`%API_KEY%…`) is reported, while words after a blank are judged
|
|
391
|
+
as their own word.
|
|
392
|
+
|
|
343
393
|
A credential-key value led by a lowercase `$name` keeps the reference-free
|
|
344
394
|
reading, in which a `$`-led literal is a placeholder. Any other `$` text is literal, so a
|
|
345
395
|
credential that merely contains `$`, after other characters or escaped as
|
|
@@ -533,7 +583,46 @@ combine:
|
|
|
533
583
|
object is redacted before its envelope, its diagnostic budget and its
|
|
534
584
|
output accounting exist, so receipts measure the delivered bytes. Values a
|
|
535
585
|
producer echoed from the raw invocation pass the token rule (argv-token
|
|
536
|
-
fields) or the word rule (free text).
|
|
586
|
+
fields) or the word rule (free text). Before the word rule runs, a URL
|
|
587
|
+
whose userinfo holds whitespace is joined into one word
|
|
588
|
+
([pm-gh1773](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-gh1773.toon);
|
|
589
|
+
tracker record excluded from npm). A word opens one at the last `:` that
|
|
590
|
+
authority slashes (any number) follow, so a compact JSON field name before
|
|
591
|
+
the URL is skipped and a URL nested in another one's query is judged; a
|
|
592
|
+
one-letter scheme is a Windows drive (`C:/Temp`), never a URL. When a quote,
|
|
593
|
+
backtick, angle bracket, parenthesis or square bracket directly precedes the
|
|
594
|
+
scheme (a Markdown link destination), its closing delimiter ends the URL (a
|
|
595
|
+
parenthesis or bracket only at the end of a word, so one inside a password is
|
|
596
|
+
data); any other quote is data. The authority after the slashes must hold no path, no closing
|
|
597
|
+
delimiter and no bracketed IPv6 host, and, up to a query or fragment, it
|
|
598
|
+
either holds a `:` and is no dotted or `localhost` `host:port`
|
|
599
|
+
(`https://user:pass`, `https://ci:123456`, `https://ci:pa%40ss`), or holds no
|
|
600
|
+
`:`, `@` or `%40` (`https://service`, `https://jane.doe`: a spaced username,
|
|
601
|
+
whose password colon must come in a later word, with text after it or a tab
|
|
602
|
+
or line break after it, and never as a clock time such as `09:30`, while a
|
|
603
|
+
numeric username part such as `123:pass` counts; a colon directly before the
|
|
604
|
+
`@` is an empty password; a colon
|
|
605
|
+
that a space follows counts only when the separator's host goes on into a
|
|
606
|
+
path, as a URL's does and an email address's never does, or when the quote
|
|
607
|
+
that opened the URL closes it there). A word
|
|
608
|
+
that ends with its slashes continues into the next word, since URL parsers
|
|
609
|
+
drop a tab or line break there. The
|
|
610
|
+
opening word is joined, across any whitespace, through the later word that
|
|
611
|
+
holds the last `@` or `%40` starting within 16 words and 512 characters, as a
|
|
612
|
+
parser takes the authority's last `@`; a word that starts another URL (its
|
|
613
|
+
scheme opens the word, so a redirect inside a query does not), or holds the
|
|
614
|
+
URL's closing delimiter, or, for a WHATWG special scheme (`http`, `https`,
|
|
615
|
+
`ws`, `wss`, `ftp`, `file`), a path, query or fragment delimiter, before any
|
|
616
|
+
separator, ends the search; such a delimiter in the opening word's authority
|
|
617
|
+
means no later word can hold its userinfo. Any other scheme reads userinfo
|
|
618
|
+
across slashes, query and fragment marks, as OpenSSH reads `ssh://a/b@host`
|
|
619
|
+
as user `a/b`. The joined span is redacted exactly as the same
|
|
620
|
+
URL without blanks. So stored text a refusal echoes, such as a blocker title
|
|
621
|
+
holding `https://user:pass words%40host/path`, loses its whole userinfo,
|
|
622
|
+
while `https://host.example:8080 … @bob`, `https://host and ping @bob`,
|
|
623
|
+
`https://host.example?t=12:30 … me@x` and `"https://host" … support: me@x`
|
|
624
|
+
stay intact. A
|
|
625
|
+
producer may also split a value at
|
|
537
626
|
whitespace or a comma, truncate it, re-case it or escape it before echoing
|
|
538
627
|
it. The CLI therefore registers each secret for the running invocation:
|
|
539
628
|
the password, or the whole userinfo of a bare token. The registration also
|
|
@@ -362,6 +362,8 @@ String compaction shortens an explanatory string longer than 240 UTF-16 code uni
|
|
|
362
362
|
|
|
363
363
|
When rows are dropped to satisfy a ceiling, the result also carries `output_budget_truncation`, naming the binding budget and its source, any explicitly requested dimension the budget overrode, every compacted collection path, and executable CLI/SDK/MCP recovery options — a default ceiling can override an explicit `--output-limit unbounded`, and that override is reported rather than silent. If a producer supplied an opaque item-page cursor, compaction rebases it to the last row actually returned and reports `continuation_cursor_rebased: true`; following the cursor therefore cannot skip rows removed from the middle of a producer page. If no useful content can fit, `PmReadOutputBudgetExceeded` provides a discriminated omission result, a compact `{ outputBudget: "unbounded" }` recovery object, and `omitted_result_estimated_tokens`, the last useful-result estimate before omission; use `isReadOutputBudgetExceeded` before accessing result-specific fields. The encoding control `--output-format <toon|json>` also applies to mutation envelopes, including the mutation modes of `comments`, `notes`, `files`, and `docs`. Other universal read controls remain rejected before mutation execution. `--json` remains supported.
|
|
364
364
|
|
|
365
|
+
A command that is not a read surface refuses every universal output control that shapes a read (`--output-include`, `--output-limit`, `--output-budget`, `--output-session`, `--output-cursor`, `--output-row-contract`) with `read_output_surface_unsupported` (exit 2) before it runs; a renderer-only `--output-format toon|json` stays accepted: "Universal output controls apply only to read commands; <command> is not a read surface." `details.output_option_keys` names the control keys the caller supplied. An extension command is a read surface only when it declares `read_output`. The CLI, `PmClient.run` and the extension test harness apply the same check, and `READ_OUTPUT_SURFACE_UNSUPPORTED_CODE` is exported ([pm-gh1769](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-gh1769.toon); tracker record excluded from npm).
|
|
366
|
+
|
|
365
367
|
That rejection is typed ([pm-rrwh2o](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-rrwh2o.toon); tracker record excluded from npm). A `comments`, `notes`, `learnings`, `files`, `docs` or package-catalog mutation given `--output-include`, `--output-limit`, `--output-budget`, `--output-session`, `--output-cursor` or `--output-row-contract` exits 2 with `read_output_mutation_conflict` before anything is written. `details.output_controls` names the offending flags, `details.output_option_keys` names the option keys the SDK or MCP caller supplied, and `details.mutation_options` names the mutation that made the call a write. The CLI recovery's `suggested_retry_args` is the caller's own invocation without those controls and their values; tracker scope, operands and every other option stay where they were. The CLI withholds `suggested_retry_args` when it cannot rebuild the invocation safely: an option whose value arity is undeclared, a control that took a flag-like token as its value, a control right after a value-taking option, a tracker selection that cannot be bound, an enclosing SDK revision scope whose guards never reached argv, or a token that may carry URL credentials, meaning any token with both an `@` and a `:` (a package source such as `https://user:token@host/pkg.tgz`), so the recovery never repeats a secret in another field. That check is deliberately conservative: a scoped package name beside a colon also gets no retry. The refusal then still names the controls, and the caller rebuilds the retry from its own arguments. SDK and MCP callers drop the named keys. To bound or page the collection, read it with the controls in a separate call after the write. `READ_OUTPUT_MUTATION_CONFLICT_CODE` and `READ_OUTPUT_SHAPING_CONTROL_FLAGS` are exported for package authors.
|
|
366
368
|
|
|
367
369
|
Cursor recovery carries the opaque value once in `recovery.cursor` and declares
|
package/docs/SDK.md
CHANGED
|
@@ -3145,6 +3145,19 @@ mutation-receipt projection, command-result overrides, suppressed host
|
|
|
3145
3145
|
output, `output_format` services and encoding resolution apply as they do
|
|
3146
3146
|
natively, so a package test fails exactly where the native CLI would
|
|
3147
3147
|
([pm-gh1729](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-gh1729.toon),
|
|
3148
|
+
tracker record excluded from npm). Before the handler runs, and before
|
|
3149
|
+
extension flags are normalized as native dispatch orders it, the harness also
|
|
3150
|
+
applies the native admission of universal output controls, read from
|
|
3151
|
+
`global` and from `options`, in any spelling a caller uses for a declared or
|
|
3152
|
+
host key: a command without `read_output` given a control that shapes a read
|
|
3153
|
+
is refused with `read_output_surface_unsupported` (exit 2, the native
|
|
3154
|
+
message) while a renderer-only `outputFormat` stays accepted, a malformed
|
|
3155
|
+
value such as `outputFormat: "yaml"` is refused, and a
|
|
3156
|
+
native hybrid surface an extension extends refuses a mutation combined with
|
|
3157
|
+
them as `read_output_mutation_conflict`, positional annotation text
|
|
3158
|
+
(`args: ["pm-x", "text"]` on `comments`, `notes` or `learnings`) included. A registry built by hand instead of
|
|
3159
|
+
through `activateExtensionForTest` carries no declarations and is not checked
|
|
3160
|
+
([pm-gh1769](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-gh1769.toon),
|
|
3148
3161
|
tracker record excluded from npm). Avoid
|
|
3149
3162
|
reserved metadata and prototype property names. The declaration promises a
|
|
3150
3163
|
read-only handler; writers and undeclared commands keep refusing read controls,
|
|
@@ -3480,7 +3493,13 @@ directly. An
|
|
|
3480
3493
|
extension action also keeps the caller's values as given: the native
|
|
3481
3494
|
`tags`-to-CSV and `dep`-to-array rewrites of core commands do not apply to it.
|
|
3482
3495
|
On the CLI, each bare occurrence of a repeatable boolean switch reaches the
|
|
3483
|
-
handler as `true` (`--many --many` is `[true, true]`)
|
|
3496
|
+
handler as `true` (`--many --many` is `[true, true]`), and bare and attached
|
|
3497
|
+
occurrences keep their argv order: `--many=false --many` is `[false, true]` and
|
|
3498
|
+
`--many --many=false` is `[true, false]`. The order comes from the same argv
|
|
3499
|
+
scan that resolves spelling conflicts, so a token another option consumed as
|
|
3500
|
+
its value (`--from-tracker --many`) is not a switch occurrence
|
|
3501
|
+
([pm-g2zzus](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-g2zzus.toon),
|
|
3502
|
+
tracker record excluded from npm). A direct caller's negated
|
|
3484
3503
|
spelling of a declared boolean (`no-many`, `--no-many`) inverts token by token
|
|
3485
3504
|
and is then judged exactly as the canonical spelling: on a `list` boolean,
|
|
3486
3505
|
`{ "no-many": "true,false" }` is `{ many: [false, true] }`, a blank segment is
|
|
@@ -3649,15 +3668,52 @@ Apply `redactUrlCredentialsInToken(token)` to each argv token. Apply
|
|
|
3649
3668
|
`redactUrlCredentialsInText(text)` to free text. Both replace the span between
|
|
3650
3669
|
a token's first `:` and its last `@` with `URL_CREDENTIAL_PLACEHOLDER`
|
|
3651
3670
|
(`[redacted]`). The token rule is complete for every spelling a URL parser
|
|
3652
|
-
normalizes, and it is idempotent. The text rule
|
|
3653
|
-
words
|
|
3654
|
-
|
|
3671
|
+
normalizes, and it is idempotent. The text rule judges whitespace-delimited
|
|
3672
|
+
words. It first joins a URL whose authority opens with a `user:` prefix, or
|
|
3673
|
+
with a single-label username, across whitespace through the word that holds
|
|
3674
|
+
its last `@` or `%40`
|
|
3675
|
+
([pm-gh1773](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-gh1773.toon);
|
|
3676
|
+
tracker record excluded from npm), so `https://user:pass words@host` is
|
|
3677
|
+
redacted in free text. A whitespace-bearing bare token (`https://my token@host`)
|
|
3678
|
+
or a separator beyond 16 words or 512 characters is still complete only when you
|
|
3679
|
+
redact the original token before interpolating it into text. A quote that a
|
|
3680
|
+
rendering dialect escaped inside a URL (PowerShell `''`, POSIX `'\''`, a
|
|
3681
|
+
backslash-escaped `\"` or cmd's `\^"`) never ends that URL. Do not echo a
|
|
3655
3682
|
value you extracted from a raw token, such as a parsed password or a
|
|
3656
3683
|
fragment cut at a delimiter. Build diagnostics from redacted tokens, or omit
|
|
3657
3684
|
the extracted value. When a retry
|
|
3658
3685
|
would lose credentials this way, withhold the retry instead of emitting one
|
|
3659
3686
|
that runs a different command.
|
|
3660
3687
|
|
|
3688
|
+
Render a recovery command from tokens with `renderPmCommand(argv)` or quote
|
|
3689
|
+
one token with `quoteCommandArg(token)`, never by hand
|
|
3690
|
+
([pm-kjoudp](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-kjoudp.toon);
|
|
3691
|
+
tracker record excluded from npm). Both quote for the shell
|
|
3692
|
+
`resolveCommandShellDialect()` declares: `PM_COMMAND_SHELL` (`posix`, `cmd`
|
|
3693
|
+
or `powershell`), otherwise `cmd` on Windows and `posix` elsewhere. Pass a
|
|
3694
|
+
`CommandShellDialect` as the third argument to render for one shell
|
|
3695
|
+
explicitly. `quoteCmdCommandArg` caret-escapes an argument that holds `%` or
|
|
3696
|
+
`"`, so cmd.exe can neither expand `%VAR%` nor split the line.
|
|
3697
|
+
`quotePowerShellCommandArg` emits a single-quoted literal, and
|
|
3698
|
+
`quotePosixCommandArg` single-quotes an argument that holds `!`. The
|
|
3699
|
+
redaction rules above recognize a credential in every one of these
|
|
3700
|
+
spellings, also when the rendered command is embedded in a JSON string.
|
|
3701
|
+
|
|
3702
|
+
`callerClaimEndedByClose(pmRoot, storageId, callerPrincipal)` reports whether
|
|
3703
|
+
the caller's latest claim on an item was ended by a close. A package
|
|
3704
|
+
mutation that should act only on the caller's own claim passes a
|
|
3705
|
+
`CallerClaimScope` as `callerClaimScope` to `mutateItem`. When that resolves
|
|
3706
|
+
true under the item lock, the assignee-conflict policy and `--force` do not
|
|
3707
|
+
apply. The callback then receives `callerClaimScoped: true` and must leave
|
|
3708
|
+
the holder's ownership unchanged. A scoped mutation that changes nothing
|
|
3709
|
+
writes nothing, not even implicit deferral cleanup. `pm release` uses this,
|
|
3710
|
+
so a close's holder never clears a later holder's claim and a status-changing
|
|
3711
|
+
release in that state is refused. The scope holds only while the item's
|
|
3712
|
+
history can prove that a close ended the caller's claim. After
|
|
3713
|
+
`history-compact` folds the claim and the close into a baseline, or when the
|
|
3714
|
+
stream cannot be replayed, the ownership policy applies
|
|
3715
|
+
([GH-1774](https://github.com/unbraind/pm-cli/issues/1774)).
|
|
3716
|
+
|
|
3661
3717
|
`resolveLifecycleVerbRecovery(verb, availablePaths)` returns explicit argument
|
|
3662
3718
|
templates and next steps for unsupported `block` and `unblock` verbs. It checks
|
|
3663
3719
|
the SDK's update flag contracts and declines installed verbs, unknown paths,
|