@unbrained/pm-cli 2026.8.6 → 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 +30 -0
- package/dist/cli/main.js +4 -2
- package/dist/cli/register-operations.js +11 -2
- 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 +397 -397
- package/dist/cli-bundle/chunks/append-7BXBFDGD.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-TPKDJ5WL.js → chunk-2AXF3VSK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-R6RKEYYW.js → chunk-2XS43CCV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-T45OHXDW.js → chunk-3A6KWB72.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-3ISTDB42.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-SXECIECW.js → chunk-4MTI7XOV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MCS73BKB.js → chunk-6BX5UDCN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-A3XQ7VPU.js → chunk-6QPO7KLR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BP6EMEDP.js → chunk-7MXHZHSQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GU3TSEHD.js → chunk-7ZPMJW4U.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-343QETLI.js → chunk-AGYNSNCI.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-B4H7FEFH.js +5 -0
- package/dist/cli-bundle/chunks/{chunk-CA3BURYF.js → chunk-B4KLBBMN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3ZJRFYY2.js → chunk-CALJHNBL.js} +12 -12
- package/dist/cli-bundle/chunks/{chunk-M357ZCOR.js → chunk-CFIGP5LY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-SVV3DQES.js → chunk-CS6MRHG7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DWOAOZHZ.js → chunk-CUGNQQKH.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-D4FPS43D.js +164 -0
- package/dist/cli-bundle/chunks/{chunk-L6LGKJX3.js → chunk-H5Y5YE6A.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5PBP2ZP3.js → chunk-H5Y6UV6E.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QJ7C3JIW.js → chunk-H7KGWPDF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-D7I3TUGV.js → chunk-HFSD77TQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-AOBDLU4T.js → chunk-HX2GTA6L.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4AVFKHHC.js → chunk-J2IEKAVR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OXY3SJ3N.js → chunk-K44PYFXH.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-M4VEE3FK.js → chunk-K4KGEEBT.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-KFLK5TRH.js +21 -0
- package/dist/cli-bundle/chunks/{chunk-FDBRXV25.js → chunk-KL6IEBV2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JQ4NZ5EB.js → chunk-KWQZDZSS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UVVXHGYS.js → chunk-KZ4X3DGU.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-LD77HJMQ.js +13 -0
- package/dist/cli-bundle/chunks/{chunk-AYRUGRNS.js → chunk-ME2JJ4LA.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-NFLJ3FHD.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-MDTH7SAE.js → chunk-NG6OXIBR.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-R6LSRGPS.js → chunk-NYIGHWQY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3KFVGGRE.js → chunk-NZ75GNSA.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q3VOP62W.js → chunk-PCJWJNC2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-C3YABSJK.js → chunk-PD3225AM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JFZIS6JF.js → chunk-PDEGKG7P.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-PIE5HBNA.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-SD3YXU2U.js → chunk-PW2H7YJR.js} +20 -20
- package/dist/cli-bundle/chunks/{chunk-PECV7L5T.js → chunk-TPKN3S7S.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-F4NREH3G.js → chunk-TPXAXTCO.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-UFWUJO4V.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-WSI5KZQJ.js → chunk-UQLZQVFW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4OVGQW22.js → chunk-VT3Z5G7D.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RUAU5OSH.js → chunk-WOD3WWUN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DQGJ2RWT.js → chunk-WSJEIGJF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RAFUN7IX.js → chunk-WYNUU7ZW.js} +49 -46
- package/dist/cli-bundle/chunks/{chunk-5ZKQPA44.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-TG67IVFI.js → create-I5DVV4YG.js} +2 -2
- package/dist/cli-bundle/chunks/delete-RL3JACSW.js +2 -0
- package/dist/cli-bundle/chunks/{deps-AJUGP2OH.js → deps-S7UBCECS.js} +2 -2
- package/dist/cli-bundle/chunks/{docs-QOCLDRKJ.js → docs-ZZNVBBYO.js} +2 -2
- package/dist/cli-bundle/chunks/{files-3ST5TY64.js → files-27C337VT.js} +2 -2
- package/dist/cli-bundle/chunks/focus-5Z2SG7LU.js +2 -0
- package/dist/cli-bundle/chunks/{history-compact-7BJFML4S.js → history-compact-HJQK67CZ.js} +2 -2
- package/dist/cli-bundle/chunks/{history-redact-WJN3HYXR.js → history-redact-PWC6PDWA.js} +2 -2
- package/dist/cli-bundle/chunks/{history-repair-XDNZUB7F.js → history-repair-N3CY4WBF.js} +2 -2
- package/dist/cli-bundle/chunks/{learnings-SZMUPVNA.js → learnings-4FH23XDT.js} +2 -2
- package/dist/cli-bundle/chunks/{profile-KL53JIAC.js → profile-5Y5XXH5N.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-QH7ONPKU.js → register-list-query-FJZCJ67O.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-OCRQNZK4.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-QWBQ6HBS.js → register-setup-DL7FFABC.js} +2 -2
- package/dist/cli-bundle/chunks/restore-6KYBV5BY.js +2 -0
- package/dist/cli-bundle/chunks/{schema-QJ27OTRV.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-MBBMTDD3.js → chunk-2ECLECMK.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-CL3NB7VW.js → chunk-3K4XV2BF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ME4XVOBJ.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-GSW2Y7VZ.js → chunk-CIXVQPB7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7YTZ7A4E.js → chunk-DLTS3IHM.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YHDCGUIW.js → chunk-DQ6FKGL3.js} +10 -10
- package/dist/cli-bundle/focused-chunks/{chunk-YLPZHWX7.js → chunk-HNL6IFGS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-JLG2C4EQ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-6KDHXURF.js → chunk-MHMTKV5V.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-GEYU23YS.js → chunk-MOTJFQ3F.js} +22 -22
- package/dist/cli-bundle/focused-chunks/{chunk-EYO4F74Z.js → chunk-NBJKQP4S.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-XNVXIQ4B.js → chunk-QHRTT7WT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-27DK4A5O.js → chunk-R2LEMEV5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-4JC3AOGS.js → chunk-RPNYG5MO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-EAXXF2HW.js → chunk-RW5IYD4J.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-TQMFQYXR.js → chunk-TIKDBG4D.js} +16 -16
- package/dist/cli-bundle/focused-chunks/{chunk-N7QN3NE6.js → chunk-VZFU2R4M.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-GIERI4YU.js → chunk-YZEZAPJK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZJIMJHDB.js +2 -0
- package/dist/cli-bundle/main.js +2 -2
- 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/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.js +3 -2
- package/dist/sdk/cli-contracts/registration-helpers.js +3 -2
- package/dist/sdk/cli-contracts/runtime-contracts.js +14 -8
- 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-program.js +3 -2
- package/dist/sdk/completion.js +5 -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/extension.js +9 -11
- package/dist/sdk/generated-error-code-catalog.js +112 -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 +6 -2
- package/dist/sdk/index.js +8 -4
- package/dist/sdk/lifecycle/plan.js +6 -3
- package/dist/sdk/merge/install.js +10 -2
- 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 +1 -0
- package/dist/sdk/runtime.js +6 -27
- package/dist/sdk/stats.d.ts +40 -0
- package/dist/sdk/stats.js +112 -29
- package/docs/IMPROVEMENT_ANALYTICS.md +103 -0
- package/docs/OUTPUT_PROJECTION_CONTRACTS.md +5 -5
- package/docs/README.md +1 -0
- package/docs/READ_OUTPUT_CONTRACTS.md +60 -1
- package/marketplace.json +2 -2
- package/package.json +3 -3
- 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 +374 -821
- package/dist/cli-bundle/chunks/append-XAJ5Z4XS.js +0 -2
- package/dist/cli-bundle/chunks/chunk-AJE3AHPD.js +0 -8
- package/dist/cli-bundle/chunks/chunk-E7BFPLUZ.js +0 -5
- package/dist/cli-bundle/chunks/chunk-HS7OVAUN.js +0 -164
- package/dist/cli-bundle/chunks/chunk-SV3YQ4RY.js +0 -2
- package/dist/cli-bundle/chunks/chunk-V663653R.js +0 -20
- package/dist/cli-bundle/chunks/chunk-XPOQQJTX.js +0 -13
- package/dist/cli-bundle/chunks/chunk-YCCDXBNU.js +0 -2
- package/dist/cli-bundle/chunks/chunk-ZFBWCKYF.js +0 -2
- package/dist/cli-bundle/chunks/close-DI66JMSB.js +0 -2
- package/dist/cli-bundle/chunks/close-many-VFKT6U3O.js +0 -2
- package/dist/cli-bundle/chunks/comments-E73HIEZJ.js +0 -2
- package/dist/cli-bundle/chunks/copy-WBYVLCPC.js +0 -2
- package/dist/cli-bundle/chunks/delete-6XKUVVQN.js +0 -2
- package/dist/cli-bundle/chunks/focus-R2AWS63Y.js +0 -2
- package/dist/cli-bundle/chunks/register-operations-HIBJXRGB.js +0 -2
- package/dist/cli-bundle/chunks/restore-FXA5QPM7.js +0 -2
- package/dist/cli-bundle/chunks/update-7GBO4SXG.js +0 -2
- package/dist/cli-bundle/chunks/update-many-VF6ZKQUO.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-74CWP3A4.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-7AZDTGPA.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-LKQXXO62.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-QL5H3AQH.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";
|
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";
|
|
@@ -1424,18 +1425,9 @@ function runMcpTelemetryAction(ctx) {
|
|
|
1424
1425
|
return runTelemetry({
|
|
1425
1426
|
subcommand: readString(ctx.args, "subcommand") ??
|
|
1426
1427
|
readString(ctx.options, "subcommand"),
|
|
1427
|
-
limit:
|
|
1428
|
+
limit: resolveRuntimeLimit(ctx.args, ctx.options),
|
|
1428
1429
|
}, ctx.global);
|
|
1429
1430
|
}
|
|
1430
|
-
function resolveMcpTelemetryLimit(args, options) {
|
|
1431
|
-
if (typeof args.limit === "number" && Number.isFinite(args.limit)) {
|
|
1432
|
-
return args.limit;
|
|
1433
|
-
}
|
|
1434
|
-
if (typeof options.limit === "number" && Number.isFinite(options.limit)) {
|
|
1435
|
-
return options.limit;
|
|
1436
|
-
}
|
|
1437
|
-
return readString(args, "limit") ?? readString(options, "limit");
|
|
1438
|
-
}
|
|
1439
1431
|
function runMcpHealthAction(ctx) {
|
|
1440
1432
|
const healthOptions = { ...ctx.options };
|
|
1441
1433
|
if (healthOptions.brief === undefined &&
|
|
@@ -1670,19 +1662,6 @@ function runMcpProfileAction(ctx) {
|
|
|
1670
1662
|
}
|
|
1671
1663
|
return handler();
|
|
1672
1664
|
}
|
|
1673
|
-
function runMcpStatsAction(ctx) {
|
|
1674
|
-
return runStats(ctx.global, {
|
|
1675
|
-
storage: ctx.options.storage === true,
|
|
1676
|
-
metadataCoverage: ctx.options.metadataCoverage === true,
|
|
1677
|
-
fieldUtilization: ctx.options.fieldUtilization === true,
|
|
1678
|
-
byAssignee: ctx.options.byAssignee === true,
|
|
1679
|
-
byTag: ctx.options.byTag === true,
|
|
1680
|
-
byPriority: ctx.options.byPriority === true,
|
|
1681
|
-
tagPrefix: typeof ctx.options.tagPrefix === "string"
|
|
1682
|
-
? ctx.options.tagPrefix
|
|
1683
|
-
: undefined,
|
|
1684
|
-
});
|
|
1685
|
-
}
|
|
1686
1665
|
async function runMcpAppendAction(ctx) {
|
|
1687
1666
|
const { changedFields, idOnly, runnerOptions } = withMutationCompaction(ctx.args, ctx.options);
|
|
1688
1667
|
return projectMutationResult(await runAppend(requireMcpItemId(ctx, runnerOptions), runnerOptions, ctx.global), {
|
|
@@ -1875,7 +1854,7 @@ const SDK_ACTION_HANDLERS = {
|
|
|
1875
1854
|
plan: runMcpPlanAction,
|
|
1876
1855
|
schema: runMcpSchemaAction,
|
|
1877
1856
|
profile: runMcpProfileAction,
|
|
1878
|
-
stats:
|
|
1857
|
+
stats: (ctx) => runStats(ctx.global, statsCommandOptionsFromRuntime(ctx.options)),
|
|
1879
1858
|
append: runMcpAppendAction,
|
|
1880
1859
|
"update-many": runMcpUpdateManyAction,
|
|
1881
1860
|
"close-many": runMcpCloseManyAction,
|
|
@@ -1962,4 +1941,4 @@ async function loadWorkspaceExtensionRegistrations(pmRoot, settings, cwd) {
|
|
|
1962
1941
|
}
|
|
1963
1942
|
}
|
|
1964
1943
|
//# sourceMappingURL=runtime.js.map
|
|
1965
|
-
//# 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
|
}
|