@unbrained/pm-cli 2026.8.5 → 2026.8.7
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 +2 -2
- package/CHANGELOG.md +44 -0
- package/dist/cli/main.js +14 -37
- package/dist/cli/register-operations.js +11 -2
- package/dist/cli/register-setup.d.ts +1 -1
- package/dist/cli/register-setup.js +46 -20
- package/dist/cli/stats-analytics-json.d.ts +9 -0
- package/dist/cli/stats-analytics-json.js +69 -0
- package/dist/cli-bundle/bundle-manifest.json +403 -403
- package/dist/cli-bundle/chunks/append-7BXBFDGD.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-PMXJEU3F.js → chunk-2AXF3VSK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MHK6LIWE.js → chunk-2XS43CCV.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-3A6KWB72.js +8 -0
- package/dist/cli-bundle/chunks/chunk-3ISTDB42.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-45G53IU4.js → chunk-4MTI7XOV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7C4PTJG6.js → chunk-6BX5UDCN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4YUBDMQM.js → chunk-6QPO7KLR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HWRRMBJO.js → chunk-7MXHZHSQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3FTILRJ2.js → chunk-7ZPMJW4U.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-2WFXWAYX.js → chunk-AGYNSNCI.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-B4H7FEFH.js +5 -0
- package/dist/cli-bundle/chunks/{chunk-43HQQI6S.js → chunk-B4KLBBMN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VCKLFEUN.js → chunk-CALJHNBL.js} +12 -12
- package/dist/cli-bundle/chunks/{chunk-CSI3WS5I.js → chunk-CFIGP5LY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-V3EUXXOF.js → chunk-CS6MRHG7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YSO3YFZ4.js → chunk-CUGNQQKH.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-D4FPS43D.js +164 -0
- package/dist/cli-bundle/chunks/{chunk-BXQLRKWF.js → chunk-H5Y5YE6A.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-54FNT7U2.js → chunk-H5Y6UV6E.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UP7DTVMD.js → chunk-H7KGWPDF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-E2RKBKWB.js → chunk-HFSD77TQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-V3774P7D.js → chunk-HX2GTA6L.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UZBWIUYD.js → chunk-J2IEKAVR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HNFD72UK.js → chunk-K44PYFXH.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5ZBOIPGP.js → chunk-K4KGEEBT.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-KFLK5TRH.js +21 -0
- package/dist/cli-bundle/chunks/{chunk-OMXVBQ2N.js → chunk-KL6IEBV2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7A5OT5J2.js → chunk-KWQZDZSS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-M72BKL5Q.js → chunk-KZ4X3DGU.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-LD77HJMQ.js +13 -0
- package/dist/cli-bundle/chunks/{chunk-VN5VITU3.js → chunk-ME2JJ4LA.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-NFLJ3FHD.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-A62CYISG.js → chunk-NG6OXIBR.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-42E7YPLG.js → chunk-NYIGHWQY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RKAVWO3O.js → chunk-NZ75GNSA.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DXDREUXT.js → chunk-PCJWJNC2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZYHOB3SN.js → chunk-PD3225AM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OTHLDSFP.js → chunk-PDEGKG7P.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-PIE5HBNA.js +2 -0
- package/dist/cli-bundle/chunks/chunk-PW2H7YJR.js +56 -0
- package/dist/cli-bundle/chunks/{chunk-L3AZOELJ.js → chunk-TPKN3S7S.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LKDGK44W.js → chunk-TPXAXTCO.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-UFWUJO4V.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-R546TPDE.js → chunk-UQLZQVFW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BPELKUQD.js → chunk-VT3Z5G7D.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-WOD3WWUN.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-4VN6GS4U.js → chunk-WSJEIGJF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UN66FZRO.js → chunk-WYNUU7ZW.js} +49 -46
- package/dist/cli-bundle/chunks/{chunk-NY4T3JWN.js → chunk-YGPNCCXZ.js} +2 -2
- package/dist/cli-bundle/chunks/close-CMY3BAUG.js +2 -0
- package/dist/cli-bundle/chunks/close-many-SA4XZCTK.js +2 -0
- package/dist/cli-bundle/chunks/comments-EZ556ZD3.js +2 -0
- package/dist/cli-bundle/chunks/copy-ZSGPA52X.js +2 -0
- package/dist/cli-bundle/chunks/{create-XLKTXTUF.js → create-I5DVV4YG.js} +2 -2
- package/dist/cli-bundle/chunks/delete-RL3JACSW.js +2 -0
- package/dist/cli-bundle/chunks/{deps-ITTY3GIC.js → deps-S7UBCECS.js} +2 -2
- package/dist/cli-bundle/chunks/{docs-W4OSRTYR.js → docs-ZZNVBBYO.js} +2 -2
- package/dist/cli-bundle/chunks/{files-EOK4AZI4.js → files-27C337VT.js} +2 -2
- package/dist/cli-bundle/chunks/focus-5Z2SG7LU.js +2 -0
- package/dist/cli-bundle/chunks/{history-compact-7UGTMLL3.js → history-compact-HJQK67CZ.js} +2 -2
- package/dist/cli-bundle/chunks/{history-redact-4DZRMD6Z.js → history-redact-PWC6PDWA.js} +2 -2
- package/dist/cli-bundle/chunks/{history-repair-UPOSZW5R.js → history-repair-N3CY4WBF.js} +2 -2
- package/dist/cli-bundle/chunks/{learnings-GMRNCBS3.js → learnings-4FH23XDT.js} +2 -2
- package/dist/cli-bundle/chunks/{profile-2MUUMHRE.js → profile-5Y5XXH5N.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-LR3SQ5ZF.js → register-list-query-FJZCJ67O.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-SUOHFVWM.js → register-mutation-YGYPW3BL.js} +3 -3
- package/dist/cli-bundle/chunks/register-operations-WMDSUMQF.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-DL7FFABC.js +2 -0
- package/dist/cli-bundle/chunks/restore-6KYBV5BY.js +2 -0
- package/dist/cli-bundle/chunks/{schema-FJ4EA3XF.js → schema-EQGKBYXJ.js} +2 -2
- package/dist/cli-bundle/chunks/update-QVTYOD6I.js +2 -0
- package/dist/cli-bundle/chunks/update-many-DJSBU525.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-MJ7HWSFK.js → chunk-2ECLECMK.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-A7BJ5SS6.js → chunk-3K4XV2BF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PIMMYG7Q.js → chunk-4EX25PXM.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-4VJQTS3P.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-73JUDYXT.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-WVIVUWVL.js → chunk-CIXVQPB7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-DLTS3IHM.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-FGKY4MBE.js → chunk-DQ6FKGL3.js} +10 -10
- package/dist/cli-bundle/focused-chunks/{chunk-QVHKCI4T.js → chunk-HNL6IFGS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-JLG2C4EQ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-G6ETT4QK.js → chunk-MHMTKV5V.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7J5TUBUJ.js → chunk-MOTJFQ3F.js} +22 -22
- package/dist/cli-bundle/focused-chunks/{chunk-UIL2M2NA.js → chunk-NBJKQP4S.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RUR5I3TK.js → chunk-QHRTT7WT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-B7LJWAZE.js → chunk-R2LEMEV5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SV3O7TSH.js → chunk-RPNYG5MO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-RW5IYD4J.js +4 -0
- package/dist/cli-bundle/focused-chunks/chunk-TIKDBG4D.js +29 -0
- package/dist/cli-bundle/focused-chunks/{chunk-IPWSFADF.js → chunk-VZFU2R4M.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-WEM2E2PE.js → chunk-YZEZAPJK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZJIMJHDB.js +2 -0
- package/dist/cli-bundle/main.js +13 -13
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +29 -28
- 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 +1 -1
- 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 +1 -1
- package/dist/core/extensions/activation-summary.d.ts +4 -0
- package/dist/core/extensions/activation-summary.js +5 -2
- package/dist/core/extensions/contribution-inventory.d.ts +1 -0
- package/dist/core/extensions/contribution-inventory.js +35 -2
- package/dist/core/extensions/extension-hook-runtime.js +5 -3
- package/dist/core/extensions/extension-types.d.ts +18 -1
- package/dist/core/extensions/extension-types.js +2 -2
- package/dist/core/extensions/loader.js +5 -13
- package/dist/core/extensions/preflight-ownership.d.ts +5 -0
- package/dist/core/extensions/preflight-ownership.js +42 -0
- package/dist/core/extensions/reserved-host-flags.js +3 -2
- package/dist/core/history/workspace-history.d.ts +22 -2
- package/dist/core/history/workspace-history.js +60 -36
- package/dist/core/output/output.d.ts +2 -0
- package/dist/core/output/output.js +3 -2
- package/dist/core/shared/command-types.d.ts +2 -0
- package/dist/core/shared/command-types.js +2 -2
- package/dist/mcp/tool-definitions.js +6 -2
- package/dist/sdk/author-attribution.js +23 -7
- package/dist/sdk/cli-bootstrap.d.ts +2 -0
- package/dist/sdk/cli-bootstrap.js +7 -2
- package/dist/sdk/cli-contracts/completeness.js +51 -4
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +9 -2
- package/dist/sdk/cli-contracts/registration-helpers.js +3 -2
- package/dist/sdk/cli-contracts/runtime-contracts.js +16 -9
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +116 -10
- package/dist/sdk/cli-contracts/tool-schema.js +18 -2
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +3 -3
- package/dist/sdk/cli-program.js +3 -2
- package/dist/sdk/completion.js +5 -2
- package/dist/sdk/compose.d.ts +2 -2
- package/dist/sdk/compose.js +7 -2
- package/dist/sdk/contracts.d.ts +1 -0
- package/dist/sdk/contracts.js +2 -2
- package/dist/sdk/core.d.ts +3 -1
- package/dist/sdk/core.js +4 -3
- package/dist/sdk/define.d.ts +3 -1
- package/dist/sdk/define.js +3 -8
- package/dist/sdk/extension/install-sources.d.ts +43 -5
- package/dist/sdk/extension/install-sources.js +36 -2
- package/dist/sdk/extension/migrations.d.ts +114 -0
- package/dist/sdk/extension/migrations.js +175 -0
- package/dist/sdk/extension/scaffold.js +14 -9
- package/dist/sdk/extension/source-resolution.d.ts +50 -0
- package/dist/sdk/extension/source-resolution.js +66 -0
- package/dist/sdk/extension.d.ts +5 -1
- package/dist/sdk/extension.js +31 -35
- package/dist/sdk/generated-error-code-catalog.js +112 -2
- package/dist/sdk/governance/health.js +11 -2
- package/dist/sdk/history-analytics.d.ts +141 -0
- package/dist/sdk/history-analytics.js +283 -0
- package/dist/sdk/improvement-ledger-validation.d.ts +3 -0
- package/dist/sdk/improvement-ledger-validation.js +63 -0
- package/dist/sdk/improvement-ledger.d.ts +139 -0
- package/dist/sdk/improvement-ledger.js +261 -0
- package/dist/sdk/index.d.ts +11 -3
- package/dist/sdk/index.js +12 -4
- package/dist/sdk/lifecycle/plan.js +6 -3
- package/dist/sdk/merge/install.js +10 -2
- package/dist/sdk/package-migrations.d.ts +10 -0
- package/dist/sdk/package-migrations.js +21 -0
- package/dist/sdk/read-output-budget.js +24 -22
- package/dist/sdk/read-output-contracts.d.ts +10 -2
- package/dist/sdk/read-output-contracts.js +124 -65
- package/dist/sdk/read-output-rows.d.ts +29 -0
- package/dist/sdk/read-output-rows.js +100 -0
- package/dist/sdk/read-output-session.d.ts +69 -0
- package/dist/sdk/read-output-session.js +200 -0
- package/dist/sdk/runtime-input.d.ts +2 -0
- package/dist/sdk/runtime-input.js +14 -2
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +3 -3
- package/dist/sdk/runtime-stats-options.d.ts +9 -0
- package/dist/sdk/runtime-stats-options.js +38 -0
- package/dist/sdk/runtime.d.ts +3 -0
- package/dist/sdk/runtime.js +10 -27
- package/dist/sdk/stats.d.ts +40 -0
- package/dist/sdk/stats.js +112 -29
- package/docs/COMMANDS.md +9 -0
- package/docs/EXTENSIONS.md +2 -2
- package/docs/EXTENSION_LIFECYCLE.md +46 -0
- package/docs/IMPROVEMENT_ANALYTICS.md +103 -0
- package/docs/OUTPUT_PROJECTION_CONTRACTS.md +5 -5
- package/docs/README.md +2 -0
- package/docs/READ_OUTPUT_CONTRACTS.md +60 -1
- package/docs/RELEASING.md +33 -20
- package/docs/SDK.md +31 -3
- package/marketplace.json +2 -2
- package/package.json +5 -5
- 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-codex/.codex-plugin/plugin.json +1 -1
- package/sdk/public-surface.json +566 -815
- package/dist/cli-bundle/chunks/append-VXXGOXSG.js +0 -2
- package/dist/cli-bundle/chunks/chunk-6MSQJOTG.js +0 -13
- package/dist/cli-bundle/chunks/chunk-EGJ4JTUG.js +0 -55
- package/dist/cli-bundle/chunks/chunk-FPBQHMFT.js +0 -8
- package/dist/cli-bundle/chunks/chunk-GE4KCSZP.js +0 -164
- package/dist/cli-bundle/chunks/chunk-LN2WFEU4.js +0 -2
- package/dist/cli-bundle/chunks/chunk-OPVH7SKD.js +0 -8
- package/dist/cli-bundle/chunks/chunk-Q35VBGOQ.js +0 -5
- package/dist/cli-bundle/chunks/chunk-SSF4PIUR.js +0 -2
- package/dist/cli-bundle/chunks/chunk-WRL4KNDL.js +0 -20
- package/dist/cli-bundle/chunks/chunk-XCEZYMNI.js +0 -2
- package/dist/cli-bundle/chunks/chunk-YEWNL576.js +0 -2
- package/dist/cli-bundle/chunks/close-VZ3OQPN5.js +0 -2
- package/dist/cli-bundle/chunks/close-many-SB4TI27P.js +0 -2
- package/dist/cli-bundle/chunks/comments-BIF3Q4KY.js +0 -2
- package/dist/cli-bundle/chunks/copy-6AI5Z57X.js +0 -2
- package/dist/cli-bundle/chunks/delete-ZY2VHQTP.js +0 -2
- package/dist/cli-bundle/chunks/focus-DLBNWL7L.js +0 -2
- package/dist/cli-bundle/chunks/register-operations-ARRRKOVN.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-O6AYP6NP.js +0 -2
- package/dist/cli-bundle/chunks/restore-ZVCVHTB5.js +0 -2
- package/dist/cli-bundle/chunks/update-YHV52CSS.js +0 -2
- package/dist/cli-bundle/chunks/update-many-M6YHVNXM.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-BIMTMOS7.js +0 -4
- package/dist/cli-bundle/focused-chunks/chunk-GJ2TG2CW.js +0 -28
- package/dist/cli-bundle/focused-chunks/chunk-N5XU5UVK.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-PG2RIZBX.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-VLYOEYML.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-W7BJEWHX.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-Y4LDYLLT.js +0 -2
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/read-output-session
|
|
3
|
+
*
|
|
4
|
+
* Implements a stateless, caller-carried session ledger for cross-call output
|
|
5
|
+
* budgets and resolvable references to item facts served by earlier reads.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="04ad0d11-1fb7-5eb4-8ff0-d81a7090c4ff")}catch(e){}}();
|
|
9
|
+
import { EXIT_CODE } from "../core/shared/constants.js";
|
|
10
|
+
import { PmCliError } from "../core/shared/errors.js";
|
|
11
|
+
import { mapReadOutputRows, readOutputRowCollections, } from "./read-output-rows.js";
|
|
12
|
+
/** Smallest session ceiling that can carry a useful result and both receipts. */
|
|
13
|
+
export const PM_READ_OUTPUT_SESSION_MIN_TOKENS = 256;
|
|
14
|
+
/** Maximum caller-carried served-item identities accepted in one session state. */
|
|
15
|
+
export const PM_READ_OUTPUT_SESSION_MAX_SEEN_ITEM_IDS = 10_000;
|
|
16
|
+
const SESSION_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u;
|
|
17
|
+
const ITEM_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
|
|
18
|
+
const SESSION_KEYS = new Set([
|
|
19
|
+
"version",
|
|
20
|
+
"id",
|
|
21
|
+
"token_budget",
|
|
22
|
+
"spent_tokens",
|
|
23
|
+
"seen_item_ids",
|
|
24
|
+
]);
|
|
25
|
+
const SESSION_FIELD_VALIDATIONS = [
|
|
26
|
+
{
|
|
27
|
+
valid: (state) => state.version === 1,
|
|
28
|
+
reason: "version must equal 1.",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
valid: (state) => typeof state.id === "string" && SESSION_ID_PATTERN.test(state.id),
|
|
32
|
+
reason: "id must be 1-64 portable identifier characters.",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
valid: (state) => Number.isSafeInteger(state.token_budget) &&
|
|
36
|
+
state.token_budget >= PM_READ_OUTPUT_SESSION_MIN_TOKENS,
|
|
37
|
+
reason: `token_budget must be a safe integer of at least ${PM_READ_OUTPUT_SESSION_MIN_TOKENS}.`,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
valid: (state) => Number.isSafeInteger(state.spent_tokens) &&
|
|
41
|
+
state.spent_tokens >= 0 &&
|
|
42
|
+
state.spent_tokens <= state.token_budget,
|
|
43
|
+
reason: "spent_tokens must be a non-negative safe integer no larger than token_budget.",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
valid: (state) => Array.isArray(state.seen_item_ids) &&
|
|
47
|
+
state.seen_item_ids.length <=
|
|
48
|
+
PM_READ_OUTPUT_SESSION_MAX_SEEN_ITEM_IDS &&
|
|
49
|
+
state.seen_item_ids.every((id) => typeof id === "string" && ITEM_ID_PATTERN.test(id)),
|
|
50
|
+
reason: `seen_item_ids must contain at most ${PM_READ_OUTPUT_SESSION_MAX_SEEN_ITEM_IDS} portable item identifiers.`,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
function isRecord(value) {
|
|
54
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
55
|
+
}
|
|
56
|
+
/** Throw one stable usage refusal for a malformed caller-carried session. */
|
|
57
|
+
function invalidSession(reason) {
|
|
58
|
+
throw new PmCliError(`--output-session ${reason}`, EXIT_CODE.USAGE, {
|
|
59
|
+
code: "invalid_read_output_session",
|
|
60
|
+
field: "outputSession",
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** Parse and strictly validate a JSON string or typed session-state object. */
|
|
64
|
+
export function parseReadOutputSession(value) {
|
|
65
|
+
if (value === undefined)
|
|
66
|
+
return undefined;
|
|
67
|
+
let parsed = value;
|
|
68
|
+
if (typeof value === "string") {
|
|
69
|
+
try {
|
|
70
|
+
parsed = JSON.parse(value);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
invalidSession("must be a valid JSON object.");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (!isRecord(parsed))
|
|
77
|
+
invalidSession("must be a JSON object.");
|
|
78
|
+
const unknownKeys = Object.keys(parsed).filter((key) => !SESSION_KEYS.has(key));
|
|
79
|
+
if (unknownKeys.length > 0) {
|
|
80
|
+
invalidSession(`contains unknown field "${unknownKeys.sort()[0]}".`);
|
|
81
|
+
}
|
|
82
|
+
const invalidField = SESSION_FIELD_VALIDATIONS.find((validation) => !validation.valid(parsed));
|
|
83
|
+
if (invalidField !== undefined)
|
|
84
|
+
invalidSession(invalidField.reason);
|
|
85
|
+
const seenItemIds = [...new Set(parsed.seen_item_ids)].sort();
|
|
86
|
+
return {
|
|
87
|
+
version: 1,
|
|
88
|
+
id: parsed.id,
|
|
89
|
+
token_budget: parsed.token_budget,
|
|
90
|
+
spent_tokens: parsed.spent_tokens,
|
|
91
|
+
seen_item_ids: seenItemIds,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/** Resolve an item identity from built-in list rows and nested search hits. */
|
|
95
|
+
function itemIdFromRow(row) {
|
|
96
|
+
if (!isRecord(row))
|
|
97
|
+
return undefined;
|
|
98
|
+
if (typeof row.id === "string")
|
|
99
|
+
return row.id;
|
|
100
|
+
if (typeof row.item_id === "string")
|
|
101
|
+
return row.item_id;
|
|
102
|
+
return isRecord(row.item) && typeof row.item.id === "string"
|
|
103
|
+
? row.item.id
|
|
104
|
+
: undefined;
|
|
105
|
+
}
|
|
106
|
+
/** Summarize delivered item facts and compact references across row paths. */
|
|
107
|
+
function summarizeReadOutputSessionRows(result) {
|
|
108
|
+
const deliveredIds = new Set();
|
|
109
|
+
let suppressedRepeatCount = 0;
|
|
110
|
+
for (const collection of readOutputRowCollections(result)) {
|
|
111
|
+
const rows = Array.isArray(collection.value)
|
|
112
|
+
? collection.value
|
|
113
|
+
: Object.values(collection.value);
|
|
114
|
+
for (const row of rows) {
|
|
115
|
+
if (!isRecord(row))
|
|
116
|
+
continue;
|
|
117
|
+
if (typeof row.context_ref === "string") {
|
|
118
|
+
suppressedRepeatCount += 1;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const itemId = itemIdFromRow(row);
|
|
122
|
+
if (itemId !== undefined)
|
|
123
|
+
deliveredIds.add(itemId);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return { deliveredIds, suppressedRepeatCount };
|
|
127
|
+
}
|
|
128
|
+
/** Replace previously served item rows with compact, resolvable references. */
|
|
129
|
+
export function applyReadOutputSessionReferences(result, state) {
|
|
130
|
+
const seen = new Set(state.seen_item_ids);
|
|
131
|
+
return mapReadOutputRows(result, (row) => {
|
|
132
|
+
const itemId = itemIdFromRow(row);
|
|
133
|
+
return itemId !== undefined && seen.has(itemId)
|
|
134
|
+
? {
|
|
135
|
+
id: itemId,
|
|
136
|
+
context_ref: `session:${state.id}:${itemId}`,
|
|
137
|
+
}
|
|
138
|
+
: row;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/** Attach a fixed-point session receipt and return the exact charged tokens. */
|
|
142
|
+
export function attachReadOutputSessionReceipt(result, state) {
|
|
143
|
+
const { deliveredIds, suppressedRepeatCount } = summarizeReadOutputSessionRows(result);
|
|
144
|
+
const nextSeen = [
|
|
145
|
+
...new Set([...state.seen_item_ids, ...deliveredIds]),
|
|
146
|
+
].sort();
|
|
147
|
+
const receipt = {
|
|
148
|
+
contract_version: 1,
|
|
149
|
+
id: state.id,
|
|
150
|
+
measurement_scope: "complete_read_envelope",
|
|
151
|
+
estimator: "ceil(utf8_bytes / 4)",
|
|
152
|
+
token_budget: state.token_budget,
|
|
153
|
+
spent_before_tokens: state.spent_tokens,
|
|
154
|
+
spent_this_call_tokens: 0,
|
|
155
|
+
charged_this_call_tokens: 0,
|
|
156
|
+
spent_total_tokens: state.spent_tokens,
|
|
157
|
+
remaining_tokens: state.token_budget - state.spent_tokens,
|
|
158
|
+
exhausted: false,
|
|
159
|
+
seen_before_count: state.seen_item_ids.length,
|
|
160
|
+
new_item_count: deliveredIds.size,
|
|
161
|
+
suppressed_repeat_count: suppressedRepeatCount,
|
|
162
|
+
reference_format: "session:<session-id>:<item-id>",
|
|
163
|
+
restore_reference_with: "pm get <item-id> --brief",
|
|
164
|
+
next_state: {
|
|
165
|
+
version: 1,
|
|
166
|
+
id: state.id,
|
|
167
|
+
token_budget: state.token_budget,
|
|
168
|
+
spent_tokens: state.spent_tokens,
|
|
169
|
+
seen_item_ids: nextSeen,
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
const withReceipt = { ...result, read_session: receipt };
|
|
173
|
+
const applyEstimate = (estimate) => {
|
|
174
|
+
receipt.spent_this_call_tokens = estimate;
|
|
175
|
+
receipt.charged_this_call_tokens = Math.min(state.token_budget - state.spent_tokens, estimate);
|
|
176
|
+
receipt.spent_total_tokens = Math.min(state.token_budget, state.spent_tokens + receipt.charged_this_call_tokens);
|
|
177
|
+
receipt.remaining_tokens = Math.max(0, state.token_budget - receipt.spent_total_tokens);
|
|
178
|
+
receipt.exhausted =
|
|
179
|
+
receipt.remaining_tokens < PM_READ_OUTPUT_SESSION_MIN_TOKENS;
|
|
180
|
+
receipt.next_state.spent_tokens = receipt.spent_total_tokens;
|
|
181
|
+
};
|
|
182
|
+
let estimate = 0;
|
|
183
|
+
let highestMeasuredEstimate = 0;
|
|
184
|
+
for (let iteration = 0; iteration < 8; iteration += 1) {
|
|
185
|
+
applyEstimate(estimate);
|
|
186
|
+
const measured = Math.ceil(Buffer.byteLength(JSON.stringify(withReceipt), "utf8") / 4);
|
|
187
|
+
if (measured === estimate)
|
|
188
|
+
return withReceipt;
|
|
189
|
+
highestMeasuredEstimate = Math.max(highestMeasuredEstimate, measured);
|
|
190
|
+
estimate = measured;
|
|
191
|
+
}
|
|
192
|
+
applyEstimate(highestMeasuredEstimate);
|
|
193
|
+
return withReceipt;
|
|
194
|
+
}
|
|
195
|
+
/** Return the unspent group budget available to the current invocation. */
|
|
196
|
+
export function readOutputSessionRemainingTokens(state) {
|
|
197
|
+
return Math.max(0, state.token_budget - state.spent_tokens);
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=read-output-session.js.map
|
|
200
|
+
//# debugId=04ad0d11-1fb7-5eb4-8ff0-d81a7090c4ff
|
|
@@ -13,6 +13,8 @@ export declare function readRuntimeScalarStringAllowBlank(args: Record<string, u
|
|
|
13
13
|
export declare function isRuntimeRecord(value: unknown): value is Record<string, unknown>;
|
|
14
14
|
/** Parse an integer-valued MCP option while retaining a caller-specific label. */
|
|
15
15
|
export declare function parseRuntimeInteger(value: unknown, label: string): number | undefined;
|
|
16
|
+
/** Resolve a numeric-or-string limit from top-level and nested action inputs. */
|
|
17
|
+
export declare function resolveRuntimeLimit(args: Record<string, unknown>, options: Record<string, unknown>): number | string | undefined;
|
|
16
18
|
/** Fixed SDK-runtime global options derived from one untyped action payload. */
|
|
17
19
|
export declare function actionGlobalOptions(args: Record<string, unknown>): GlobalOptions;
|
|
18
20
|
/** Reconcile MCP array/scalar option spellings with CLI flag expectations. */
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* primitives are shared by native action dispatchers and MCP-specific adapters.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
8
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="bcda2578-3b01-5e64-9d53-cd32c0f927b8")}catch(e){}}();
|
|
9
9
|
import { EXIT_CODE } from "../core/shared/constants.js";
|
|
10
10
|
import { PmCliError } from "../core/shared/errors.js";
|
|
11
11
|
import { asRecordClone } from "../core/shared/primitives.js";
|
|
@@ -59,6 +59,16 @@ export function parseRuntimeInteger(value, label) {
|
|
|
59
59
|
}
|
|
60
60
|
return undefined;
|
|
61
61
|
}
|
|
62
|
+
/** Resolve a numeric-or-string limit from top-level and nested action inputs. */
|
|
63
|
+
export function resolveRuntimeLimit(args, options) {
|
|
64
|
+
if (typeof args.limit === "number" && Number.isFinite(args.limit)) {
|
|
65
|
+
return args.limit;
|
|
66
|
+
}
|
|
67
|
+
if (typeof options.limit === "number" && Number.isFinite(options.limit)) {
|
|
68
|
+
return options.limit;
|
|
69
|
+
}
|
|
70
|
+
return (readRuntimeString(args, "limit") ?? readRuntimeString(options, "limit"));
|
|
71
|
+
}
|
|
62
72
|
/** Fixed SDK-runtime global options derived from one untyped action payload. */
|
|
63
73
|
export function actionGlobalOptions(args) {
|
|
64
74
|
const outputFormat = readRuntimeString(args, "outputFormat");
|
|
@@ -72,6 +82,7 @@ export function actionGlobalOptions(args) {
|
|
|
72
82
|
outputInclude: readRuntimeString(args, "outputInclude"),
|
|
73
83
|
outputLimit: readRuntimeScalarString(args, "outputLimit"),
|
|
74
84
|
outputBudget: readRuntimeScalarString(args, "outputBudget"),
|
|
85
|
+
outputSession: readRuntimeString(args, "outputSession"),
|
|
75
86
|
outputFormat: outputFormat === "json" || outputFormat === "toon"
|
|
76
87
|
? outputFormat
|
|
77
88
|
: undefined,
|
|
@@ -155,6 +166,7 @@ const UNIVERSAL_READ_OUTPUT_OPTION_KEYS = [
|
|
|
155
166
|
"outputLimit",
|
|
156
167
|
"outputBudget",
|
|
157
168
|
"outputFormat",
|
|
169
|
+
"outputSession",
|
|
158
170
|
];
|
|
159
171
|
/** Reconcile MCP array/scalar option spellings with CLI flag expectations. */
|
|
160
172
|
export function normalizeMcpOptionsArrays(options, action) {
|
|
@@ -489,4 +501,4 @@ export function updateManyOptionsFromFlat(options) {
|
|
|
489
501
|
};
|
|
490
502
|
}
|
|
491
503
|
//# sourceMappingURL=runtime-input.js.map
|
|
492
|
-
//# debugId=
|
|
504
|
+
//# debugId=bcda2578-3b01-5e64-9d53-cd32c0f927b8
|
|
@@ -16,7 +16,7 @@ export { pathExists, readFileIfExists, removeFileIfExists, writeFileAtomic, } fr
|
|
|
16
16
|
export { type HistoryDiffValueEntry, computeHistoryDiff, patchPathToChangedField, } from "../core/history/history-diff.js";
|
|
17
17
|
export { enforceHistoryStreamPolicyForItem, enforceHistoryStreamPolicyForItems, } from "../core/history/history-stream-policy.js";
|
|
18
18
|
export { appendHistoryEntry, createHistoryEntry, hashDocument, hashEmptyDocument, } from "../core/history/history.js";
|
|
19
|
-
export { appendWorkspaceAuditEvent, appendWorkspaceHistoryChange, getWorkspaceHistoryPath, WORKSPACE_HISTORY_ID, writeWorkspaceJsonWithHistory, type WorkspaceAuditEventOptions, type WorkspaceHistoryChange, type WorkspaceJsonWriteOptions, } from "../core/history/workspace-history.js";
|
|
19
|
+
export { appendWorkspaceAuditEvent, appendWorkspaceHistoryChange, getWorkspaceHistoryPath, mutateWorkspaceJsonWithHistory, WORKSPACE_HISTORY_ID, writeWorkspaceJsonWithHistory, type WorkspaceAuditEventOptions, type WorkspaceHistoryChange, type WorkspaceJsonMutation, type WorkspaceJsonMutationOptions, type WorkspaceJsonWriteOptions, } from "../core/history/workspace-history.js";
|
|
20
20
|
export { normalizeReplayPatchOps, replayToCanonicalItemDocument, replayToItemDocument, toReplayDocument, verifyHistoryChain, } from "../core/history/replay.js";
|
|
21
21
|
export { resolveBodyFileContent } from "../core/io/body-file.js";
|
|
22
22
|
export { generateItemId, normalizeItemId, normalizeRawItemId, } from "../core/item/id.js";
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* prefer the typed operations exported by the main SDK barrel.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
10
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="febc7f96-1757-5c07-8d99-ed5fce742afa")}catch(e){}}();
|
|
11
11
|
export { createCheckpointId, loadMutationCheckpoint, restoreCheckpointItems, writeMutationCheckpoint, } from "../core/checkpoint/mutation-checkpoint.js";
|
|
12
12
|
export { flattenFlagListValue, resolveFlagValueKind, } from "../core/extensions/flag-value-types.js";
|
|
13
13
|
export { activateExtensions, clearActiveExtensionHooks, consumeAfterCommandAffectedItems, createCoreCommandHookContext, createEmptyExtensionRegistrationRegistry, discoverExtensions, getActiveCommandResult, getActiveExtensionRegistrations, loadExtensions, projectAfterCommandItemSnapshot, recordAfterCommandAffectedItem, resetActiveExtensionRuntimeState, runActiveCommandHandler, runActiveBeforeMutationHooks, runActiveOnIndexHooks, runActiveOnReadHooks, runActiveOnWriteHooks, runActiveParserOverride, runActivePreflightOverride, runActiveServiceOverride, runAfterCommandHooks, runBeforeCommandHooks, setActiveCommandContext, setActiveCommandResult, setActiveExtensionCommands, setActiveExtensionHooks, setActiveExtensionParsers, setActiveExtensionPreflight, setActiveExtensionRegistrations, setActiveExtensionRenderers, setActiveExtensionServices, } from "../core/extensions/index.js";
|
|
@@ -18,7 +18,7 @@ export { pathExists, readFileIfExists, removeFileIfExists, writeFileAtomic, } fr
|
|
|
18
18
|
export { computeHistoryDiff, patchPathToChangedField, } from "../core/history/history-diff.js";
|
|
19
19
|
export { enforceHistoryStreamPolicyForItem, enforceHistoryStreamPolicyForItems, } from "../core/history/history-stream-policy.js";
|
|
20
20
|
export { appendHistoryEntry, createHistoryEntry, hashDocument, hashEmptyDocument, } from "../core/history/history.js";
|
|
21
|
-
export { appendWorkspaceAuditEvent, appendWorkspaceHistoryChange, getWorkspaceHistoryPath, WORKSPACE_HISTORY_ID, writeWorkspaceJsonWithHistory, } from "../core/history/workspace-history.js";
|
|
21
|
+
export { appendWorkspaceAuditEvent, appendWorkspaceHistoryChange, getWorkspaceHistoryPath, mutateWorkspaceJsonWithHistory, WORKSPACE_HISTORY_ID, writeWorkspaceJsonWithHistory, } from "../core/history/workspace-history.js";
|
|
22
22
|
export { normalizeReplayPatchOps, replayToCanonicalItemDocument, replayToItemDocument, toReplayDocument, verifyHistoryChain, } from "../core/history/replay.js";
|
|
23
23
|
export { resolveBodyFileContent } from "../core/io/body-file.js";
|
|
24
24
|
export { generateItemId, normalizeItemId, normalizeRawItemId, } from "../core/item/id.js";
|
|
@@ -79,4 +79,4 @@ export { maybeRunFirstUseTelemetryPrompt } from "../core/telemetry/consent.js";
|
|
|
79
79
|
export { deriveTelemetryCommandResolution, } from "../core/telemetry/observability.js";
|
|
80
80
|
export { emitTelemetryErrorEvent, finishTelemetryCommand, startTelemetryCommand, } from "../core/telemetry/runtime.js";
|
|
81
81
|
//# sourceMappingURL=runtime-primitives.js.map
|
|
82
|
-
//# debugId=
|
|
82
|
+
//# debugId=febc7f96-1757-5c07-8d99-ed5fce742afa
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/runtime-stats-options
|
|
3
|
+
*
|
|
4
|
+
* Maps the flat SDK/MCP action transport into the typed stats command options
|
|
5
|
+
* shared by the CLI and direct SDK surfaces.
|
|
6
|
+
*/
|
|
7
|
+
import type { StatsCommandOptions } from "./stats.js";
|
|
8
|
+
/** Convert a flat runtime option bag into the canonical typed stats payload. */
|
|
9
|
+
export declare function statsCommandOptionsFromRuntime(options: Record<string, unknown>): StatsCommandOptions;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="dbabff08-1bb7-539b-b1c1-c10584aa0a67")}catch(e){}}();
|
|
3
|
+
import { readRuntimeString, readRuntimeStringArray } from "./runtime-input.js";
|
|
4
|
+
/** Convert a flat runtime option bag into the canonical typed stats payload. */
|
|
5
|
+
export function statsCommandOptionsFromRuntime(options) {
|
|
6
|
+
return {
|
|
7
|
+
storage: options.storage === true,
|
|
8
|
+
metadataCoverage: options.metadataCoverage === true,
|
|
9
|
+
fieldUtilization: options.fieldUtilization === true,
|
|
10
|
+
byAssignee: options.byAssignee === true,
|
|
11
|
+
byTag: options.byTag === true,
|
|
12
|
+
byPriority: options.byPriority === true,
|
|
13
|
+
tagPrefix: typeof options.tagPrefix === "string" ? options.tagPrefix : undefined,
|
|
14
|
+
measurements: options.measurements === true,
|
|
15
|
+
metric: readRuntimeString(options, "metric"),
|
|
16
|
+
measurementLimit: typeof options.measurementLimit === "number"
|
|
17
|
+
? options.measurementLimit
|
|
18
|
+
: undefined,
|
|
19
|
+
observe: readRuntimeStringArray(options.observe),
|
|
20
|
+
direction: typeof options.improvementDirection === "string"
|
|
21
|
+
? options.improvementDirection
|
|
22
|
+
: undefined,
|
|
23
|
+
measurementSource: readRuntimeString(options, "measurementSource"),
|
|
24
|
+
measurementItem: readRuntimeString(options, "measurementItem"),
|
|
25
|
+
measurementRevision: readRuntimeString(options, "measurementRevision"),
|
|
26
|
+
author: readRuntimeString(options, "author"),
|
|
27
|
+
message: readRuntimeString(options, "message"),
|
|
28
|
+
provenanceCoverage: options.provenanceCoverage === true,
|
|
29
|
+
fleetAttribution: options.fleetAttribution === true,
|
|
30
|
+
since: readRuntimeString(options, "since"),
|
|
31
|
+
eventLimit: typeof options.eventLimit === "number" ? options.eventLimit : undefined,
|
|
32
|
+
minimumSample: typeof options.minimumSample === "number"
|
|
33
|
+
? options.minimumSample
|
|
34
|
+
: undefined,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=runtime-stats-options.js.map
|
|
38
|
+
//# debugId=dbabff08-1bb7-539b-b1c1-c10584aa0a67
|
package/dist/sdk/runtime.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { EXIT_CODE } from "../core/shared/constants.js";
|
|
|
10
10
|
export type { WorkspaceExtensionCommandContract, WorkspaceFieldContract, } from "./workspace-contracts.js";
|
|
11
11
|
import { type PmReadOutputOptions, type PmReadOutputResultFor } from "./read-output-contracts.js";
|
|
12
12
|
export type { PmReadOutputBudgetExceeded, PmReadOutputOptions, PmReadOutputResult, PmReadOutputResultFor, PmReadOutputSurfaceContract, } from "./read-output-contracts.js";
|
|
13
|
+
export type { PmReadOutputSessionReceipt, PmReadOutputSessionState } from "./read-output-session.js";
|
|
13
14
|
export type { PmContextIntentContract } from "./context-intent-contracts.js";
|
|
14
15
|
export type { PmErrorCodeContract } from "./error-code-catalog.js";
|
|
15
16
|
export { clearWorkspaceContractsCache } from "./workspace-contracts-cache.js";
|
|
@@ -336,6 +337,8 @@ export declare class PmClient {
|
|
|
336
337
|
packageActivate(target: string, options?: PackageCommandOptions): Promise<PackageCommandResult>;
|
|
337
338
|
/** Disable an installed package using the same action as `pm package deactivate`. */
|
|
338
339
|
packageDeactivate(target: string, options?: PackageCommandOptions): Promise<PackageCommandResult>;
|
|
340
|
+
/** Plan or apply active package migrations with durable workspace receipts. */
|
|
341
|
+
packageMigrate(options?: PackageCommandOptions): Promise<PackageCommandResult>;
|
|
339
342
|
/** Upgrade the pm CLI and/or managed packages through the public SDK dispatcher. */
|
|
340
343
|
upgrade(target?: string, options?: UpgradeCommandOptions): Promise<UpgradeResult>;
|
|
341
344
|
}
|
package/dist/sdk/runtime.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Defines public SDK APIs and package-author helpers for Runtime.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
7
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="42339e0d-ca3c-505f-8b98-acec81158b6e")}catch(e){}}();
|
|
8
8
|
export { PM_GITIGNORE_END, PM_GITIGNORE_START, ensurePmGitignore, getPmGitignoreBlock, } from "./workspace.js";
|
|
9
9
|
export { SEARCH_EXTENSION_FLAG_DEFINITIONS } from "./extension-contracts.js";
|
|
10
10
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -64,7 +64,7 @@ import { acknowledgeUnknownAuthorHistoryEvents, } from "./author-attribution.js"
|
|
|
64
64
|
import { runProfileApply, runProfileLint, runProfileList, runProfileShow, } from "./profile.js";
|
|
65
65
|
import { runHistoryRedact, } from "./history-redact.js";
|
|
66
66
|
import { runMcpHistoryCompactAction, runMcpHistoryRepairAction, } from "./history-mcp.js";
|
|
67
|
-
import { actionGlobalOptions as globalOptions, closeManyOptionsFromFlat, extensionOptionsFromArgs, graphOptionsFromFlat, mutationListOptions, normalizeActionName, normalizeCommandPath, normalizeMcpOptionsArrays, normalizeMcpUpdateOptions, optionsWithAuthor, parseRuntimeInteger as parseMcpInteger, readRuntimeScalarString as readScalarString, readRuntimeScalarStringAllowBlank as readScalarStringAllowBlank, readRuntimeString as readString, readRuntimeStringArray as readStringArray, updateManyOptionsFromFlat, withAddNoteOption, withFilesDiscoveryOptions, withMutationCompaction, } from "./runtime-input.js";
|
|
67
|
+
import { actionGlobalOptions as globalOptions, closeManyOptionsFromFlat, extensionOptionsFromArgs, graphOptionsFromFlat, mutationListOptions, normalizeActionName, normalizeCommandPath, normalizeMcpOptionsArrays, normalizeMcpUpdateOptions, optionsWithAuthor, parseRuntimeInteger as parseMcpInteger, readRuntimeScalarString as readScalarString, readRuntimeScalarStringAllowBlank as readScalarStringAllowBlank, readRuntimeString as readString, readRuntimeStringArray as readStringArray, resolveRuntimeLimit, updateManyOptionsFromFlat, withAddNoteOption, withFilesDiscoveryOptions, withMutationCompaction, } from "./runtime-input.js";
|
|
68
68
|
import { runDeps } from "./dependencies.js";
|
|
69
69
|
import { runDocs } from "./docs.js";
|
|
70
70
|
import { runGraph, } from "./graph/run.js";
|
|
@@ -73,6 +73,7 @@ import { runContracts, } from "./cli-contracts/runtime-contracts.js";
|
|
|
73
73
|
import { runList } from "./query/list.js";
|
|
74
74
|
import { runSearch, } from "./query/search.js";
|
|
75
75
|
import { runStats, } from "./stats.js";
|
|
76
|
+
import { statsCommandOptionsFromRuntime } from "./runtime-stats-options.js";
|
|
76
77
|
import { runDuplicates, } from "./duplicates.js";
|
|
77
78
|
import { runTelemetry } from "./telemetry.js";
|
|
78
79
|
import { runTest } from "./test/execution.js";
|
|
@@ -669,6 +670,10 @@ export class PmClient {
|
|
|
669
670
|
packageDeactivate(target, options = {}) {
|
|
670
671
|
return this.runTyped("package-deactivate", { target, options });
|
|
671
672
|
}
|
|
673
|
+
/** Plan or apply active package migrations with durable workspace receipts. */
|
|
674
|
+
packageMigrate(options = {}) {
|
|
675
|
+
return this.package(undefined, { ...options, migrate: true });
|
|
676
|
+
}
|
|
672
677
|
/** Upgrade the pm CLI and/or managed packages through the public SDK dispatcher. */
|
|
673
678
|
upgrade(target, options = {}) {
|
|
674
679
|
return this.runTyped("upgrade", {
|
|
@@ -1420,18 +1425,9 @@ function runMcpTelemetryAction(ctx) {
|
|
|
1420
1425
|
return runTelemetry({
|
|
1421
1426
|
subcommand: readString(ctx.args, "subcommand") ??
|
|
1422
1427
|
readString(ctx.options, "subcommand"),
|
|
1423
|
-
limit:
|
|
1428
|
+
limit: resolveRuntimeLimit(ctx.args, ctx.options),
|
|
1424
1429
|
}, ctx.global);
|
|
1425
1430
|
}
|
|
1426
|
-
function resolveMcpTelemetryLimit(args, options) {
|
|
1427
|
-
if (typeof args.limit === "number" && Number.isFinite(args.limit)) {
|
|
1428
|
-
return args.limit;
|
|
1429
|
-
}
|
|
1430
|
-
if (typeof options.limit === "number" && Number.isFinite(options.limit)) {
|
|
1431
|
-
return options.limit;
|
|
1432
|
-
}
|
|
1433
|
-
return readString(args, "limit") ?? readString(options, "limit");
|
|
1434
|
-
}
|
|
1435
1431
|
function runMcpHealthAction(ctx) {
|
|
1436
1432
|
const healthOptions = { ...ctx.options };
|
|
1437
1433
|
if (healthOptions.brief === undefined &&
|
|
@@ -1666,19 +1662,6 @@ function runMcpProfileAction(ctx) {
|
|
|
1666
1662
|
}
|
|
1667
1663
|
return handler();
|
|
1668
1664
|
}
|
|
1669
|
-
function runMcpStatsAction(ctx) {
|
|
1670
|
-
return runStats(ctx.global, {
|
|
1671
|
-
storage: ctx.options.storage === true,
|
|
1672
|
-
metadataCoverage: ctx.options.metadataCoverage === true,
|
|
1673
|
-
fieldUtilization: ctx.options.fieldUtilization === true,
|
|
1674
|
-
byAssignee: ctx.options.byAssignee === true,
|
|
1675
|
-
byTag: ctx.options.byTag === true,
|
|
1676
|
-
byPriority: ctx.options.byPriority === true,
|
|
1677
|
-
tagPrefix: typeof ctx.options.tagPrefix === "string"
|
|
1678
|
-
? ctx.options.tagPrefix
|
|
1679
|
-
: undefined,
|
|
1680
|
-
});
|
|
1681
|
-
}
|
|
1682
1665
|
async function runMcpAppendAction(ctx) {
|
|
1683
1666
|
const { changedFields, idOnly, runnerOptions } = withMutationCompaction(ctx.args, ctx.options);
|
|
1684
1667
|
return projectMutationResult(await runAppend(requireMcpItemId(ctx, runnerOptions), runnerOptions, ctx.global), {
|
|
@@ -1871,7 +1854,7 @@ const SDK_ACTION_HANDLERS = {
|
|
|
1871
1854
|
plan: runMcpPlanAction,
|
|
1872
1855
|
schema: runMcpSchemaAction,
|
|
1873
1856
|
profile: runMcpProfileAction,
|
|
1874
|
-
stats:
|
|
1857
|
+
stats: (ctx) => runStats(ctx.global, statsCommandOptionsFromRuntime(ctx.options)),
|
|
1875
1858
|
append: runMcpAppendAction,
|
|
1876
1859
|
"update-many": runMcpUpdateManyAction,
|
|
1877
1860
|
"close-many": runMcpCloseManyAction,
|
|
@@ -1958,4 +1941,4 @@ async function loadWorkspaceExtensionRegistrations(pmRoot, settings, cwd) {
|
|
|
1958
1941
|
}
|
|
1959
1942
|
}
|
|
1960
1943
|
//# sourceMappingURL=runtime.js.map
|
|
1961
|
-
//# debugId=
|
|
1944
|
+
//# debugId=42339e0d-ca3c-505f-8b98-acec81158b6e
|
package/dist/sdk/stats.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { type GroupedBreakdown, type MetadataCoverageReport } from "../core/gove
|
|
|
3
3
|
import { type HistoryStorageStats } from "../core/history/history-storage-stats.js";
|
|
4
4
|
import type { GlobalOptions } from "../core/shared/command-types.js";
|
|
5
5
|
import type { ItemStatus, ItemType } from "../types/index.js";
|
|
6
|
+
import { type ImprovementDirection, type ImprovementLedgerResult, type RecordImprovementObservationResult } from "./improvement-ledger.js";
|
|
7
|
+
import { type FleetAttributionAnalytics, type ProvenanceCoverageAnalytics } from "./history-analytics.js";
|
|
6
8
|
/** Documents the stats command options payload exchanged by command, SDK, and package integrations. */
|
|
7
9
|
export interface StatsCommandOptions {
|
|
8
10
|
/** Include aggregate per-stream history storage metrics (sizes, depth, oldest/newest). */
|
|
@@ -19,6 +21,36 @@ export interface StatsCommandOptions {
|
|
|
19
21
|
tagPrefix?: string;
|
|
20
22
|
/** Include a content-field utilization breakdown (notes/learnings/files/docs/tests/comments/deps/body usage rates). */
|
|
21
23
|
fieldUtilization?: boolean;
|
|
24
|
+
/** Include the audited improvement observation ledger and derived trends. */
|
|
25
|
+
measurements?: boolean;
|
|
26
|
+
/** Exact improvement metric filter used with --measurements. */
|
|
27
|
+
metric?: string;
|
|
28
|
+
/** Maximum newest improvement observations returned. */
|
|
29
|
+
measurementLimit?: number;
|
|
30
|
+
/** Repeatable name=value[,unit=...][,threshold=...] observations to append. */
|
|
31
|
+
observe?: string[];
|
|
32
|
+
/** Improvement direction applied to newly recorded observations. */
|
|
33
|
+
direction?: ImprovementDirection;
|
|
34
|
+
/** Producing gate or instrument associated with new observations. */
|
|
35
|
+
measurementSource?: string;
|
|
36
|
+
/** Tracked owner associated with new observations. */
|
|
37
|
+
measurementItem?: string;
|
|
38
|
+
/** Explicit source revision for new observations. */
|
|
39
|
+
measurementRevision?: string;
|
|
40
|
+
/** Intentional mutation author override. */
|
|
41
|
+
author?: string;
|
|
42
|
+
/** Human-readable observation audit rationale. */
|
|
43
|
+
message?: string;
|
|
44
|
+
/** Include live declared-versus-observed provenance coverage. */
|
|
45
|
+
provenanceCoverage?: boolean;
|
|
46
|
+
/** Include immutable-history fleet outcome attribution. */
|
|
47
|
+
fleetAttribution?: boolean;
|
|
48
|
+
/** Inclusive history analytics lower bound or negative duration. */
|
|
49
|
+
since?: string;
|
|
50
|
+
/** Maximum immutable events consumed by each analytics projection. */
|
|
51
|
+
eventLimit?: number;
|
|
52
|
+
/** Minimum close or explicit-value denominator required for rates. */
|
|
53
|
+
minimumSample?: number;
|
|
22
54
|
}
|
|
23
55
|
/** Documents the stats result payload exchanged by command, SDK, and package integrations. */
|
|
24
56
|
export interface StatsResult {
|
|
@@ -44,6 +76,14 @@ export interface StatsResult {
|
|
|
44
76
|
storage?: HistoryStorageStats;
|
|
45
77
|
/** Present only with --field-utilization: content-field utilization rates across all items. */
|
|
46
78
|
field_utilization?: ContentFieldUtilizationReport;
|
|
79
|
+
/** Audited improvement observations and baseline-to-latest trends. */
|
|
80
|
+
improvement_ledger?: ImprovementLedgerResult;
|
|
81
|
+
/** Receipts for observations appended by this invocation. */
|
|
82
|
+
recorded_observations?: RecordImprovementObservationResult[];
|
|
83
|
+
/** Live provenance coverage over a bounded immutable-history window. */
|
|
84
|
+
provenance_coverage?: ProvenanceCoverageAnalytics;
|
|
85
|
+
/** Bounded fleet attribution derived from immutable history. */
|
|
86
|
+
fleet_attribution?: FleetAttributionAnalytics;
|
|
47
87
|
/** ISO 8601 timestamp recording when generated occurred. */
|
|
48
88
|
generated_at: string;
|
|
49
89
|
}
|