@unbrained/pm-cli 2026.8.13 → 2026.8.14
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 +141 -112
- package/dist/cli/main.js +39 -3
- package/dist/cli-bundle/bundle-manifest.json +144 -176
- package/dist/cli-bundle/chunks/{chunk-DEDU3DG7.js → chunk-BBOFSVAK.js} +66 -65
- package/dist/cli-bundle/chunks/chunk-BFALV3YP.js +5 -0
- package/dist/cli-bundle/chunks/{chunk-Q47C67TQ.js → chunk-FIW4P64F.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QGTUPEU5.js → chunk-G5JUB66K.js} +41 -41
- package/dist/cli-bundle/chunks/{chunk-3ZMOWAFM.js → chunk-SBRKH6OR.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-TMJ7URWS.js +13 -0
- package/dist/cli-bundle/chunks/{chunk-F7FJYGK3.js → chunk-TXMEUUUY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YLBAPY22.js → chunk-XAVMOK6B.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TF3TPKPR.js → chunk-YAMTJL6Y.js} +33 -33
- package/dist/cli-bundle/chunks/{chunk-IMGIN7R6.js → chunk-YSVSMJ2B.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-4HIZ7EA3.js → register-list-query-T3EHHNNV.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-W64FZ5HN.js → register-mutation-E27WCLSZ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-C44ET7R5.js → register-operations-4R6I7CPY.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-634MFRXU.js → register-setup-3YXZ444E.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-OOYYKQWX.js → chunk-4DQ2YERC.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-F43TT2QQ.js +8 -0
- package/dist/cli-bundle/focused-chunks/{chunk-2RI2FESN.js → chunk-K7RWWOAG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-KFSZ3BP6.js +16 -0
- package/dist/cli-bundle/focused-chunks/{chunk-3DJSGWVB.js → chunk-KSEDUWVZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NFHFZH2Z.js → chunk-KYUQGTSB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-IIS2FRKL.js → chunk-LZ4MV3RH.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-PGXJQLCT.js +155 -0
- package/dist/cli-bundle/focused-chunks/{chunk-E3AVJ655.js → chunk-PPFGQDSI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-Q4YY3XNF.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-QK753U3U.js +46 -0
- package/dist/cli-bundle/focused-chunks/{chunk-QDZUABWL.js → chunk-QUMB2J27.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SM7MTG27.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-I75MANL7.js → chunk-WCVE2NIG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-XDNAW5OI.js +18 -0
- package/dist/cli-bundle/focused-chunks/{chunk-2JP7W7GO.js → chunk-YOOI3UZX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZM6TZVHC.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 +44 -41
- 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 +109 -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 +2 -2
- package/dist/core/history/drift-scan.d.ts +6 -0
- package/dist/core/history/drift-scan.js +74 -50
- package/dist/core/history/workspace-history.d.ts +59 -0
- package/dist/core/history/workspace-history.js +197 -10
- package/dist/core/output/output.js +12 -4
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +6 -1
- package/dist/sdk/cli-contracts/runtime-contracts.js +155 -60
- package/dist/sdk/cli-program.js +3 -3
- package/dist/sdk/context-relevance.js +12 -4
- package/dist/sdk/governance/assurance.js +4 -4
- package/dist/sdk/governance/health.js +15 -3
- package/dist/sdk/governance/validate-history-drift.d.ts +7 -0
- package/dist/sdk/governance/validate-history-drift.js +68 -0
- package/dist/sdk/governance/validate.js +4 -46
- package/dist/sdk/graph/assembly.d.ts +23 -0
- package/dist/sdk/graph/assembly.js +54 -2
- package/dist/sdk/graph/durable-cache.js +50 -20
- package/dist/sdk/graph/governance-contracts.d.ts +1 -1
- package/dist/sdk/graph/governance-contracts.js +4 -2
- package/dist/sdk/graph/governance.d.ts +21 -1
- package/dist/sdk/graph/governance.js +94 -32
- package/dist/sdk/graph/index.d.ts +2 -2
- package/dist/sdk/graph/index.js +4 -4
- package/dist/sdk/graph/mutation-advisory.js +15 -7
- package/dist/sdk/graph/remediation.js +12 -2
- package/dist/sdk/history-read.d.ts +8 -0
- package/dist/sdk/history-read.js +2 -2
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +3 -3
- package/dist/sdk/query/history.js +20 -3
- package/dist/sdk/read-output-budget.d.ts +2 -0
- package/dist/sdk/read-output-budget.js +12 -5
- package/dist/sdk/read-output-contracts.d.ts +61 -5
- package/dist/sdk/read-output-contracts.js +210 -28
- package/dist/sdk/read-output-rows.d.ts +11 -0
- package/dist/sdk/read-output-rows.js +47 -2
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +3 -3
- package/dist/sdk/runtime.js +5 -3
- package/docs/ASSURANCE.md +10 -1
- package/docs/COMMANDS.md +31 -2
- package/docs/READ_OUTPUT_CONTRACTS.md +44 -8
- package/docs/RELATIONSHIP_GRAPH.md +20 -5
- package/docs/SDK.md +12 -5
- package/docs/SDK_CONTEXT_INTEGRITY.md +32 -1
- package/docs/TESTING.md +23 -1
- package/docs/performance/sdk-entrypoint-import-costs.md +20 -13
- package/marketplace.json +2 -2
- package/package.json +6 -6
- package/packages/pm-beads/extensions/beads/index.ts +1 -0
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/extensions/calendar/index.ts +1 -0
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/extensions/digital-twin/index.ts +7 -0
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/extensions/governance-audit/index.ts +4 -0
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/extensions/guide-shell/index.ts +5 -0
- 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/extensions/linked-test-adapters/index.ts +6 -0
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/extensions/search-advanced/index.ts +2 -0
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/extensions/templates/index.ts +4 -0
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/extensions/todos/index.ts +2 -0
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/extensions/vcs/index.ts +7 -0
- 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/scripts/bundle-cli.mjs +17 -4
- package/sdk/public-surface.json +209 -29
- package/dist/cli-bundle/chunks/chunk-DL5M5J3V.js +0 -13
- package/dist/cli-bundle/chunks/chunk-HIUZVCMN.js +0 -5
- package/dist/cli-bundle/focused-chunks/chunk-27N23W6M.js +0 -31
- package/dist/cli-bundle/focused-chunks/chunk-3BNVU6LC.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-6MLIRBLV.js +0 -5
- package/dist/cli-bundle/focused-chunks/chunk-6XYLENDV.js +0 -155
- package/dist/cli-bundle/focused-chunks/chunk-CP4K4WFS.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-EBTNSFYE.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HC2OL2H2.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-OGC4XSBC.js +0 -17
- package/dist/cli-bundle/focused-chunks/chunk-PKPOZXLL.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-QQX5TDFT.js +0 -16
- package/dist/cli-bundle/focused-chunks/chunk-TEZIXMTH.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-WEH6NSL6.js +0 -18
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* surface without coupling package authors to command-specific option names.
|
|
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]="c78ba845-78ae-5b16-b486-c279f834d601")}catch(e){}}();
|
|
9
9
|
import { EXIT_CODE } from "../core/shared/constants.js";
|
|
10
10
|
import { PmCliError } from "../core/shared/errors.js";
|
|
11
|
-
import { compactReadOutputToBudget, updateReadOutputReceiptEstimate, } from "./read-output-budget.js";
|
|
11
|
+
import { compactReadOutputToBudget, estimateReadOutputTokens, updateReadOutputReceiptEstimate, } from "./read-output-budget.js";
|
|
12
|
+
import { resolvePmCommandOutputBudget } from "./cli-contracts/agent-output-contracts.js";
|
|
12
13
|
import { boundReadOutputRows, countReadOutputRows, mapReadOutputRows, readOutputRowPaths, } from "./read-output-rows.js";
|
|
13
14
|
import { applyReadOutputSessionReferences, attachReadOutputSessionReceipt, parseReadOutputSession, readOutputSessionRemainingTokens, } from "./read-output-session.js";
|
|
14
15
|
/** Stable output dimensions shared by every read surface. */
|
|
@@ -40,6 +41,8 @@ export const PM_READ_OUTPUT_SURFACES = [
|
|
|
40
41
|
"stats",
|
|
41
42
|
"aggregate",
|
|
42
43
|
"package-manage",
|
|
44
|
+
"comments-audit",
|
|
45
|
+
"assurance",
|
|
43
46
|
];
|
|
44
47
|
const READ_OUTPUT_PRECEDENCE = [
|
|
45
48
|
"canonical",
|
|
@@ -91,7 +94,7 @@ const LEGACY_FLAGS_BY_COMMAND = {
|
|
|
91
94
|
encoding: ["--format"],
|
|
92
95
|
},
|
|
93
96
|
health: {
|
|
94
|
-
include: ["--brief", "--check-only", "--full", "--summary"
|
|
97
|
+
include: ["--brief", "--check-only", "--full", "--summary"],
|
|
95
98
|
},
|
|
96
99
|
deps: {
|
|
97
100
|
include: ["--collapse", "--full", "--summary"],
|
|
@@ -113,7 +116,7 @@ const LEGACY_FLAGS_BY_COMMAND = {
|
|
|
113
116
|
amount: ["--limit", "--unbounded"],
|
|
114
117
|
encoding: ["--stream"],
|
|
115
118
|
},
|
|
116
|
-
validate: { include: ["--counts", "--full"
|
|
119
|
+
validate: { include: ["--counts", "--full"] },
|
|
117
120
|
events: {
|
|
118
121
|
include: ["--full"],
|
|
119
122
|
amount: ["--limit"],
|
|
@@ -129,17 +132,26 @@ const LEGACY_FLAGS_BY_COMMAND = {
|
|
|
129
132
|
stats: {},
|
|
130
133
|
aggregate: {},
|
|
131
134
|
"package-manage": {},
|
|
135
|
+
"comments-audit": {},
|
|
136
|
+
assurance: {},
|
|
132
137
|
};
|
|
133
|
-
const VALUE_BEARING_INCLUDE_ALIASES = new Set([
|
|
138
|
+
const VALUE_BEARING_INCLUDE_ALIASES = new Set([
|
|
139
|
+
"--collapse",
|
|
140
|
+
"--fields",
|
|
141
|
+
"--section",
|
|
142
|
+
]);
|
|
134
143
|
const BEHAVIOR_PRESERVING_MIGRATION_HINTS = Object.freeze({
|
|
135
144
|
"--after": "--after retains cursor-position semantics; use --output-limit <n> separately to bound returned rows.",
|
|
136
145
|
"--check-only": "--check-only retains health side-effect semantics; --output-include does not suppress vector refresh.",
|
|
146
|
+
"--collapse": "--collapse retains dependency grouping semantics; --output-include does not replace it.",
|
|
137
147
|
"--depth": "--depth retains traversal or detail-depth semantics; --output-limit does not replace it.",
|
|
138
148
|
"--follow": "--follow retains event-tail semantics; --output-format does not enable following.",
|
|
139
149
|
"--max-depth": "--max-depth retains graph traversal-depth semantics; --output-limit does not replace it.",
|
|
140
150
|
"--max-paths": "--max-paths retains graph path-search semantics; use --output-limit separately to bound returned rows.",
|
|
151
|
+
"--no-truncate": "--no-truncate is a compatibility alias; prefer --output-limit unbounded.",
|
|
141
152
|
"--offset": "--offset retains positional pagination semantics; use --output-limit separately to bound returned rows.",
|
|
142
153
|
"--stream": "--stream retains command streaming semantics; --output-format selects only static result encoding.",
|
|
154
|
+
"--unbounded": "--unbounded is a compatibility alias; prefer --output-limit unbounded.",
|
|
143
155
|
});
|
|
144
156
|
function flagSelector(flag) {
|
|
145
157
|
return flag.slice(2).replaceAll("-", "_");
|
|
@@ -170,6 +182,9 @@ function buildSurfaceContract(command) {
|
|
|
170
182
|
inapplicable_reason: null,
|
|
171
183
|
legacy_aliases: Object.freeze((legacy[dimension] ?? []).map((flag) => Object.freeze({
|
|
172
184
|
flag,
|
|
185
|
+
semantics: BEHAVIOR_PRESERVING_MIGRATION_HINTS[flag] === undefined
|
|
186
|
+
? "replacement"
|
|
187
|
+
: "behavior_preserving",
|
|
173
188
|
migration_hint: migrationHint(flag, dimension),
|
|
174
189
|
visibility: "hidden_alias",
|
|
175
190
|
}))),
|
|
@@ -242,8 +257,8 @@ const READ_OUTPUT_VALUE_VALIDATORS = [
|
|
|
242
257
|
},
|
|
243
258
|
{
|
|
244
259
|
keys: ["outputBudget", "output_budget"],
|
|
245
|
-
valid: (value) => positiveInteger(value) !== undefined,
|
|
246
|
-
message: "--output-budget must be a positive integer.",
|
|
260
|
+
valid: (value) => value === "unbounded" || positiveInteger(value) !== undefined,
|
|
261
|
+
message: "--output-budget must be a positive integer or unbounded.",
|
|
247
262
|
},
|
|
248
263
|
{
|
|
249
264
|
keys: ["outputFormat", "output_format"],
|
|
@@ -279,6 +294,68 @@ export function validateReadOutputOptions(command, options) {
|
|
|
279
294
|
}
|
|
280
295
|
}
|
|
281
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* Map every canonical `--output-include` token that names a projection mode
|
|
299
|
+
* rather than a row field onto the command-local option that mode already owns.
|
|
300
|
+
*
|
|
301
|
+
* The include dimension folds two kinds of legacy alias into one canonical
|
|
302
|
+
* spelling: value-bearing selectors (`--fields`, `--section`) that name row
|
|
303
|
+
* fields, and mode flags (`--brief`, `--full`, `--summary`, ...) that select a
|
|
304
|
+
* whole declared projection. Only the first kind can be honoured by projecting
|
|
305
|
+
* an already-computed result, so mode tokens have to reach the command itself.
|
|
306
|
+
*/
|
|
307
|
+
export function readOutputIncludeModeOptions(command) {
|
|
308
|
+
const surface = resolveReadOutputSurface(command);
|
|
309
|
+
if (!surface)
|
|
310
|
+
return new Map();
|
|
311
|
+
return new Map((LEGACY_FLAGS_BY_COMMAND[surface].include ?? [])
|
|
312
|
+
.filter((flag) => !VALUE_BEARING_INCLUDE_ALIASES.has(flag) &&
|
|
313
|
+
BEHAVIOR_PRESERVING_MIGRATION_HINTS[flag] === undefined)
|
|
314
|
+
.map((flag) => [flagSelector(flag), optionKey(flag)]));
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Translate canonical projection-mode tokens into the command-local options
|
|
318
|
+
* they alias, so the spelling the migration hints recommend is behaviour
|
|
319
|
+
* identical to the legacy flag it replaces, and return the field selectors that
|
|
320
|
+
* remain for post-execution projection.
|
|
321
|
+
*/
|
|
322
|
+
export function applyReadOutputIncludeModes(command, includeValue, commandOptions) {
|
|
323
|
+
const requested = stringList(includeValue) ?? [];
|
|
324
|
+
const modeOptions = readOutputIncludeModeOptions(command);
|
|
325
|
+
const selectors = [];
|
|
326
|
+
const modes = [];
|
|
327
|
+
for (const token of requested) {
|
|
328
|
+
const option = modeOptions.get(token);
|
|
329
|
+
if (option === undefined) {
|
|
330
|
+
selectors.push(token);
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
commandOptions[option] = true;
|
|
334
|
+
modes.push(token);
|
|
335
|
+
}
|
|
336
|
+
return { selectors, modes };
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Resolve canonical include modes against one combined options bag, rewriting
|
|
340
|
+
* the include value in place to the selectors that remain.
|
|
341
|
+
*
|
|
342
|
+
* Used by dispatch paths that carry command options and universal output
|
|
343
|
+
* controls in a single record, so an action honours a mode token exactly as the
|
|
344
|
+
* CLI does.
|
|
345
|
+
*/
|
|
346
|
+
export function normalizeReadOutputIncludeModeOptions(command, options) {
|
|
347
|
+
const include = options.outputInclude ?? options.output_include;
|
|
348
|
+
if (include === undefined)
|
|
349
|
+
return;
|
|
350
|
+
const { selectors, modes } = applyReadOutputIncludeModes(command, include, options);
|
|
351
|
+
if (modes.length === 0)
|
|
352
|
+
return;
|
|
353
|
+
const residual = selectors.length > 0 ? selectors.join(",") : undefined;
|
|
354
|
+
options.outputInclude = residual;
|
|
355
|
+
if (Object.hasOwn(options, "output_include")) {
|
|
356
|
+
options.output_include = residual;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
282
359
|
function optionKey(flag) {
|
|
283
360
|
return flag
|
|
284
361
|
.slice(2)
|
|
@@ -353,6 +430,9 @@ function resolveAmountValue(canonical, legacy) {
|
|
|
353
430
|
: { source: "legacy", value: legacyLimit };
|
|
354
431
|
}
|
|
355
432
|
function resolveCostValue(canonical, legacy) {
|
|
433
|
+
if (canonical === "unbounded") {
|
|
434
|
+
return { source: "canonical", value: "unbounded" };
|
|
435
|
+
}
|
|
356
436
|
const canonicalBudget = positiveInteger(canonical);
|
|
357
437
|
if (canonicalBudget !== undefined) {
|
|
358
438
|
return { source: "canonical", value: canonicalBudget };
|
|
@@ -404,12 +484,23 @@ export function resolveReadOutputDimensions(command, options) {
|
|
|
404
484
|
const alias = contract.dimensions[dimension].legacy_aliases.find((entry) => entry.flag === resolved.flag);
|
|
405
485
|
return [alias.migration_hint];
|
|
406
486
|
});
|
|
487
|
+
const encoding = resolveEncodingValue(options.outputFormat ?? options.output_format, legacyByDimension.encoding);
|
|
488
|
+
const explicitCost = resolveCostValue(options.outputBudget ?? options.output_budget, legacyByDimension.cost);
|
|
489
|
+
const budget = resolvePmCommandOutputBudget(command, {
|
|
490
|
+
generateFallback: true,
|
|
491
|
+
});
|
|
492
|
+
const resolvedOutputFormat = encoding?.value === "json" || options.resolvedOutputFormat === "json"
|
|
493
|
+
? "json"
|
|
494
|
+
: "toon";
|
|
407
495
|
return {
|
|
408
496
|
command: normalizedCommand,
|
|
409
497
|
include: resolveIncludeValue(options.outputInclude ?? options.output_include, legacyByDimension.include),
|
|
410
498
|
amount: resolveAmountValue(options.outputLimit ?? options.output_limit, legacyByDimension.amount),
|
|
411
|
-
cost:
|
|
412
|
-
|
|
499
|
+
cost: explicitCost ?? {
|
|
500
|
+
source: "default",
|
|
501
|
+
value: budget.default_max_estimated_tokens_by_format[resolvedOutputFormat],
|
|
502
|
+
},
|
|
503
|
+
encoding,
|
|
413
504
|
legacy_aliases_used: legacyAliasesUsed,
|
|
414
505
|
migration_hints: migrationHints,
|
|
415
506
|
precedence: READ_OUTPUT_PRECEDENCE,
|
|
@@ -525,6 +616,34 @@ function applyGetIncludeProjection(result, selectors) {
|
|
|
525
616
|
};
|
|
526
617
|
return projected;
|
|
527
618
|
}
|
|
619
|
+
/** Count row objects that still carry at least one field. */
|
|
620
|
+
function countPopulatedRows(result) {
|
|
621
|
+
let populated = 0;
|
|
622
|
+
mapReadOutputRows({ ...result }, (entry) => {
|
|
623
|
+
if (isRecord(entry) && Object.keys(entry).length > 0)
|
|
624
|
+
populated += 1;
|
|
625
|
+
return entry;
|
|
626
|
+
});
|
|
627
|
+
return populated;
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Refuse an include projection that strips every field from every row.
|
|
631
|
+
*
|
|
632
|
+
* Selectors that match no field are not a narrower answer, they are no answer:
|
|
633
|
+
* without this the surface returns the requested row count as empty objects and
|
|
634
|
+
* exits 0, so a mistyped or mode-shaped selector is indistinguishable from a
|
|
635
|
+
* workspace that genuinely holds nothing.
|
|
636
|
+
*/
|
|
637
|
+
function rejectEmptyIncludeProjection(command, original, shaped, selectors) {
|
|
638
|
+
if (countPopulatedRows(original) === 0 || countPopulatedRows(shaped) > 0) {
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
const modes = [...readOutputIncludeModeOptions(command).keys()];
|
|
642
|
+
const domain = modes.length > 0
|
|
643
|
+
? ` Declared ${command} projection modes: ${modes.join(", ")}.`
|
|
644
|
+
: ` The ${command} surface declares no projection modes; name row fields instead.`;
|
|
645
|
+
throw new PmCliError(`Unknown --output-include selector(s) for ${command}: ${selectors.join(", ")}. No selector matched any returned row field.${domain}`, EXIT_CODE.USAGE);
|
|
646
|
+
}
|
|
528
647
|
function applyIncludeProjection(command, result, selectors) {
|
|
529
648
|
if (command === "get") {
|
|
530
649
|
return applyGetIncludeProjection(result, selectors);
|
|
@@ -537,11 +656,10 @@ function applyIncludeProjection(command, result, selectors) {
|
|
|
537
656
|
!rows.some((rowPath) => selector.startsWith(`${rowPath}.`)));
|
|
538
657
|
if (rows.length > 0 && (!selectedRoot || qualifiedRowSelectors.length > 0)) {
|
|
539
658
|
const projected = { ...result };
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
: entry);
|
|
659
|
+
const rowSelectors = qualifiedRowSelectors.length > 0 ? qualifiedRowSelectors : selectors;
|
|
660
|
+
const shaped = mapReadOutputRows(projected, (entry) => isRecord(entry) ? projectRecordFields(entry, rowSelectors) : entry);
|
|
661
|
+
rejectEmptyIncludeProjection(command, result, shaped, rowSelectors);
|
|
662
|
+
return shaped;
|
|
545
663
|
}
|
|
546
664
|
return Object.fromEntries(Object.entries(result).filter(([key]) => selectors.some((selector) => selector.split(".")[0] === key) ||
|
|
547
665
|
ENVELOPE_KEYS.has(key)));
|
|
@@ -565,7 +683,8 @@ function applyAmountBound(result, amount) {
|
|
|
565
683
|
return bounded;
|
|
566
684
|
}
|
|
567
685
|
function requestedDimensions(resolved) {
|
|
568
|
-
return PM_READ_OUTPUT_DIMENSIONS.filter((dimension) => resolved[dimension] !== undefined
|
|
686
|
+
return PM_READ_OUTPUT_DIMENSIONS.filter((dimension) => resolved[dimension] !== undefined &&
|
|
687
|
+
resolved[dimension]?.source !== "default");
|
|
569
688
|
}
|
|
570
689
|
/** Stabilize the per-call and cross-call receipts in one complete envelope. */
|
|
571
690
|
function attachReadOutputSessionContracts(result, state, receipt) {
|
|
@@ -611,19 +730,34 @@ function projectReadOutputRows(result, resolved, session) {
|
|
|
611
730
|
/** Resolve the smallest binding per-call or remaining cross-call ceiling. */
|
|
612
731
|
function resolveBindingReadOutputBudget(resolved, session) {
|
|
613
732
|
const budgets = [
|
|
614
|
-
...(resolved.cost
|
|
733
|
+
...(resolved.cost !== undefined &&
|
|
734
|
+
resolved.cost.value !== "unbounded" &&
|
|
735
|
+
(resolved.cost.source === "canonical" || resolved.cost.source === "default")
|
|
736
|
+
? [{ source: resolved.cost.source, tokens: resolved.cost.value }]
|
|
737
|
+
: []),
|
|
615
738
|
...(session === undefined
|
|
616
739
|
? []
|
|
617
|
-
: [
|
|
740
|
+
: [
|
|
741
|
+
{
|
|
742
|
+
source: "session",
|
|
743
|
+
tokens: readOutputSessionRemainingTokens(session),
|
|
744
|
+
},
|
|
745
|
+
]),
|
|
618
746
|
];
|
|
619
|
-
return budgets.
|
|
747
|
+
return budgets.sort((left, right) => left.tokens - right.tokens)[0];
|
|
620
748
|
}
|
|
621
749
|
/** Build the smallest truthful omission envelope or reject an exhausted session. */
|
|
622
|
-
function omitReadOutputForBudget(resolved, requested, session,
|
|
750
|
+
function omitReadOutputForBudget(resolved, requested, session, bindingBudget, omittedResultEstimatedTokens) {
|
|
623
751
|
const minimalReceipt = {
|
|
624
752
|
contract_version: 1,
|
|
625
753
|
command: resolved.command,
|
|
626
754
|
requested_dimensions: requested,
|
|
755
|
+
...(bindingBudget.source === "default"
|
|
756
|
+
? {
|
|
757
|
+
budget_source: bindingBudget.source,
|
|
758
|
+
budget_tokens: bindingBudget.tokens,
|
|
759
|
+
}
|
|
760
|
+
: {}),
|
|
627
761
|
precedence: resolved.precedence,
|
|
628
762
|
legacy_aliases_used: [],
|
|
629
763
|
migration_hints: [],
|
|
@@ -632,6 +766,9 @@ function omitReadOutputForBudget(resolved, requested, session, budget) {
|
|
|
632
766
|
strings_compacted: false,
|
|
633
767
|
rows_compacted: false,
|
|
634
768
|
result_omitted: true,
|
|
769
|
+
...(session === undefined
|
|
770
|
+
? { omitted_result_estimated_tokens: omittedResultEstimatedTokens }
|
|
771
|
+
: {}),
|
|
635
772
|
};
|
|
636
773
|
const omitted = {
|
|
637
774
|
output_budget_exceeded: {
|
|
@@ -647,11 +784,48 @@ function omitReadOutputForBudget(resolved, requested, session, budget) {
|
|
|
647
784
|
if (session === undefined) {
|
|
648
785
|
updateReadOutputReceiptEstimate(boundedOmission, minimalReceipt);
|
|
649
786
|
}
|
|
650
|
-
if (session !== undefined &&
|
|
787
|
+
if (session !== undefined &&
|
|
788
|
+
minimalReceipt.estimated_tokens > bindingBudget.tokens) {
|
|
651
789
|
throw new PmCliError("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.", EXIT_CODE.USAGE);
|
|
652
790
|
}
|
|
653
791
|
return boundedOmission;
|
|
654
792
|
}
|
|
793
|
+
/** Decide whether shaping would add no value to an already-bounded result. */
|
|
794
|
+
function canReturnReadOutputUnchanged(resolved, requested, session, result) {
|
|
795
|
+
if (session !== undefined)
|
|
796
|
+
return false;
|
|
797
|
+
const canonicalRequestedCount = requested.filter((dimension) => resolved[dimension]?.source === "canonical").length;
|
|
798
|
+
if (resolved.cost?.value === "unbounded") {
|
|
799
|
+
return canonicalRequestedCount === 1;
|
|
800
|
+
}
|
|
801
|
+
if (resolved.cost?.source === "legacy" && canonicalRequestedCount === 0) {
|
|
802
|
+
return true;
|
|
803
|
+
}
|
|
804
|
+
return (canonicalRequestedCount === 0 &&
|
|
805
|
+
(resolved.cost === undefined ||
|
|
806
|
+
estimateReadOutputTokens(result) <= resolved.cost.value));
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Disclose a budget-driven row drop in the envelope that carries it.
|
|
810
|
+
*
|
|
811
|
+
* `has_more` and `truncated` say that rows were withheld but not why, by what,
|
|
812
|
+
* or how to get them: the row-compaction path emits no continuation cursor, so
|
|
813
|
+
* without this an explicitly requested unbounded read is silently downgraded and
|
|
814
|
+
* the only working recovery is never named.
|
|
815
|
+
*/
|
|
816
|
+
function attachReadOutputTruncationDisclosure(projected, resolved, receipt, bindingBudget) {
|
|
817
|
+
if (!receipt.rows_compacted)
|
|
818
|
+
return;
|
|
819
|
+
const overridden = resolved.amount?.value === "unbounded" ? ["amount"] : [];
|
|
820
|
+
projected.output_budget_truncation = {
|
|
821
|
+
reason: "output_budget_reached",
|
|
822
|
+
budget_source: bindingBudget.source,
|
|
823
|
+
budget_tokens: bindingBudget.tokens,
|
|
824
|
+
overridden_dimensions: overridden,
|
|
825
|
+
compacted_row_paths: receipt.compacted_row_paths,
|
|
826
|
+
restore_with: "Re-run with --output-budget unbounded for the complete result.",
|
|
827
|
+
};
|
|
828
|
+
}
|
|
655
829
|
/** Apply universal field, row, and token bounds and attach an exact receipt. */
|
|
656
830
|
export function applyReadOutputDimensions(command, options, result) {
|
|
657
831
|
const resolved = resolveReadOutputDimensions(command, options);
|
|
@@ -659,15 +833,21 @@ export function applyReadOutputDimensions(command, options, result) {
|
|
|
659
833
|
return result;
|
|
660
834
|
const session = parseReadOutputSession(options.outputSession ?? options.output_session);
|
|
661
835
|
const requested = requestedDimensions(resolved);
|
|
662
|
-
|
|
663
|
-
if (canonicalRequested.length === 0 && session === undefined) {
|
|
836
|
+
if (canReturnReadOutputUnchanged(resolved, requested, session, result)) {
|
|
664
837
|
return result;
|
|
665
838
|
}
|
|
839
|
+
const bindingBudget = resolveBindingReadOutputBudget(resolved, session);
|
|
666
840
|
let projected = projectReadOutputRows(result, resolved, session);
|
|
667
841
|
const receipt = {
|
|
668
842
|
contract_version: 1,
|
|
669
843
|
command: resolved.command,
|
|
670
844
|
requested_dimensions: requested,
|
|
845
|
+
...(bindingBudget?.source === "default"
|
|
846
|
+
? {
|
|
847
|
+
budget_source: bindingBudget.source,
|
|
848
|
+
budget_tokens: bindingBudget.tokens,
|
|
849
|
+
}
|
|
850
|
+
: {}),
|
|
671
851
|
precedence: resolved.precedence,
|
|
672
852
|
legacy_aliases_used: resolved.legacy_aliases_used,
|
|
673
853
|
migration_hints: resolved.migration_hints,
|
|
@@ -683,15 +863,17 @@ export function applyReadOutputDimensions(command, options, result) {
|
|
|
683
863
|
? projected
|
|
684
864
|
: attachReadOutputSessionContracts(projected, session, receipt);
|
|
685
865
|
updateReadOutputReceiptEstimate(projected, receipt);
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
projected = compactReadOutputToBudget(projected, receipt,
|
|
866
|
+
if (bindingBudget !== undefined &&
|
|
867
|
+
receipt.estimated_tokens > bindingBudget.tokens) {
|
|
868
|
+
projected = compactReadOutputToBudget(projected, receipt, bindingBudget.tokens);
|
|
869
|
+
attachReadOutputTruncationDisclosure(projected, resolved, receipt, bindingBudget);
|
|
689
870
|
if (session !== undefined) {
|
|
690
871
|
projected = attachReadOutputSessionContracts(projected, session, receipt);
|
|
691
872
|
}
|
|
692
873
|
}
|
|
693
|
-
if (
|
|
694
|
-
|
|
874
|
+
if (bindingBudget !== undefined &&
|
|
875
|
+
receipt.estimated_tokens > bindingBudget.tokens) {
|
|
876
|
+
return omitReadOutputForBudget(resolved, requested, session, bindingBudget, receipt.estimated_tokens);
|
|
695
877
|
}
|
|
696
878
|
return projected;
|
|
697
879
|
}
|
|
@@ -710,4 +892,4 @@ export function resolveReadOutputEncoding(command, options) {
|
|
|
710
892
|
: undefined;
|
|
711
893
|
}
|
|
712
894
|
//# sourceMappingURL=read-output-contracts.js.map
|
|
713
|
-
//# debugId=
|
|
895
|
+
//# debugId=c78ba845-78ae-5b16-b486-c279f834d601
|
|
@@ -15,6 +15,17 @@ export interface PmReadOutputRowCollection {
|
|
|
15
15
|
export declare function readOutputRowPaths(result: Record<string, unknown>): string[];
|
|
16
16
|
/** Resolve every declared row path that currently contains iterable rows. */
|
|
17
17
|
export declare function readOutputRowCollections(result: Record<string, unknown>): PmReadOutputRowCollection[];
|
|
18
|
+
/**
|
|
19
|
+
* Discover every collection the token-budget degradation ladder may reduce.
|
|
20
|
+
*
|
|
21
|
+
* Ordinary field and amount projections stay bound to declared row paths (or
|
|
22
|
+
* top-level array fallbacks), because a nested tag list is not an independent
|
|
23
|
+
* result row. Budget degradation has a different obligation: it must exhaust
|
|
24
|
+
* nested content collections before omitting the whole useful result. This
|
|
25
|
+
* census therefore adds nested arrays while excluding receipt/envelope metadata
|
|
26
|
+
* whose mutation would make the disclosure itself incomplete.
|
|
27
|
+
*/
|
|
28
|
+
export declare function readOutputBudgetCollections(result: Record<string, unknown>): PmReadOutputRowCollection[];
|
|
18
29
|
/** Count array entries and object-map values across declared row collections. */
|
|
19
30
|
export declare function countReadOutputRows(result: Record<string, unknown>): number;
|
|
20
31
|
/**
|
|
@@ -5,7 +5,20 @@
|
|
|
5
5
|
* envelopes, including dot-delimited nested paths used by graph projections.
|
|
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]="03e25a43-f05c-5bc6-a42a-140914e522d5")}catch(e){}}();
|
|
9
|
+
const BUDGET_METADATA_ROOT_KEYS = new Set([
|
|
10
|
+
"applied_bound",
|
|
11
|
+
"completeness",
|
|
12
|
+
"continuation_contract",
|
|
13
|
+
"filters",
|
|
14
|
+
"omission_receipt",
|
|
15
|
+
"output_budget_truncation",
|
|
16
|
+
"projection",
|
|
17
|
+
"read_output",
|
|
18
|
+
"read_session",
|
|
19
|
+
"row_contract",
|
|
20
|
+
"sorting",
|
|
21
|
+
]);
|
|
9
22
|
function isRecord(value) {
|
|
10
23
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
11
24
|
}
|
|
@@ -54,6 +67,38 @@ export function readOutputRowCollections(result) {
|
|
|
54
67
|
: [];
|
|
55
68
|
});
|
|
56
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Discover every collection the token-budget degradation ladder may reduce.
|
|
72
|
+
*
|
|
73
|
+
* Ordinary field and amount projections stay bound to declared row paths (or
|
|
74
|
+
* top-level array fallbacks), because a nested tag list is not an independent
|
|
75
|
+
* result row. Budget degradation has a different obligation: it must exhaust
|
|
76
|
+
* nested content collections before omitting the whole useful result. This
|
|
77
|
+
* census therefore adds nested arrays while excluding receipt/envelope metadata
|
|
78
|
+
* whose mutation would make the disclosure itself incomplete.
|
|
79
|
+
*/
|
|
80
|
+
export function readOutputBudgetCollections(result) {
|
|
81
|
+
const collections = readOutputRowCollections(result);
|
|
82
|
+
const declaredPaths = new Set(collections.map((collection) => collection.path));
|
|
83
|
+
const visit = (value, path) => {
|
|
84
|
+
if (Array.isArray(value)) {
|
|
85
|
+
if (!declaredPaths.has(path)) {
|
|
86
|
+
collections.push({ path, value });
|
|
87
|
+
}
|
|
88
|
+
value.forEach((entry, index) => visit(entry, `${path}.${index}`));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (!isRecord(value))
|
|
92
|
+
return;
|
|
93
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
94
|
+
if (path.length === 0 && BUDGET_METADATA_ROOT_KEYS.has(key))
|
|
95
|
+
continue;
|
|
96
|
+
visit(entry, path.length === 0 ? key : `${path}.${key}`);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
visit(result, "");
|
|
100
|
+
return collections;
|
|
101
|
+
}
|
|
57
102
|
/** Count array entries and object-map values across declared row collections. */
|
|
58
103
|
export function countReadOutputRows(result) {
|
|
59
104
|
return readOutputRowCollections(result).reduce((total, collection) => total +
|
|
@@ -97,4 +142,4 @@ export function boundReadOutputRows(result, amount) {
|
|
|
97
142
|
return { result: projected, truncated };
|
|
98
143
|
}
|
|
99
144
|
//# sourceMappingURL=read-output-rows.js.map
|
|
100
|
-
//# debugId=
|
|
145
|
+
//# debugId=03e25a43-f05c-5bc6-a42a-140914e522d5
|
|
@@ -18,7 +18,7 @@ export { type HistoryDiffValueEntry, computeHistoryDiff, patchPathToChangedField
|
|
|
18
18
|
export { enforceHistoryStreamPolicyForItem, enforceHistoryStreamPolicyForItems, } from "../core/history/history-stream-policy.js";
|
|
19
19
|
export { appendHistoryEntry, CURRENT_HISTORY_ITEM_HASH_VERSION, createHistoryEntry, hashDocument, hashDocumentForVersion, hashEmptyDocument, SUPPORTED_HISTORY_ITEM_HASH_VERSIONS, type HistoryItemHashVersion, } from "../core/history/history.js";
|
|
20
20
|
export { readHistoryEntries } from "../core/history/read.js";
|
|
21
|
-
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";
|
|
21
|
+
export { appendWorkspaceAuditEvent, appendWorkspaceHistoryChange, getWorkspaceHistoryPath, inspectWorkspaceHistoryState, mutateWorkspaceJsonWithHistory, reconcileWorkspaceJsonHistory, restoreWorkspaceJsonFromHistory, WORKSPACE_HISTORY_ID, writeWorkspaceJsonWithHistory, type WorkspaceAuditEventOptions, type WorkspaceHistoryChange, type WorkspaceHistoryStateAgreement, type WorkspaceJsonMutation, type WorkspaceJsonMutationOptions, type WorkspaceJsonReconciliationOptions, type WorkspaceJsonRestoreOptions, type WorkspaceJsonRestoreResult, type WorkspaceJsonWriteOptions, } from "../core/history/workspace-history.js";
|
|
22
22
|
export { normalizeReplayPatchOps, replayToCanonicalItemDocument, replayToItemDocument, toReplayDocument, verifyHistoryChain, verifyHistoryChainWithVersion, } 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";
|
|
@@ -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]="a678b9f8-ba36-5127-877f-96bb4acc38c5")}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 { createUnknownSubcommandError, } from "./agent/subcommand-recovery.js";
|
|
@@ -20,7 +20,7 @@ export { computeHistoryDiff, patchPathToChangedField, } from "../core/history/hi
|
|
|
20
20
|
export { enforceHistoryStreamPolicyForItem, enforceHistoryStreamPolicyForItems, } from "../core/history/history-stream-policy.js";
|
|
21
21
|
export { appendHistoryEntry, CURRENT_HISTORY_ITEM_HASH_VERSION, createHistoryEntry, hashDocument, hashDocumentForVersion, hashEmptyDocument, SUPPORTED_HISTORY_ITEM_HASH_VERSIONS, } from "../core/history/history.js";
|
|
22
22
|
export { readHistoryEntries } from "../core/history/read.js";
|
|
23
|
-
export { appendWorkspaceAuditEvent, appendWorkspaceHistoryChange, getWorkspaceHistoryPath, mutateWorkspaceJsonWithHistory, WORKSPACE_HISTORY_ID, writeWorkspaceJsonWithHistory, } from "../core/history/workspace-history.js";
|
|
23
|
+
export { appendWorkspaceAuditEvent, appendWorkspaceHistoryChange, getWorkspaceHistoryPath, inspectWorkspaceHistoryState, mutateWorkspaceJsonWithHistory, reconcileWorkspaceJsonHistory, restoreWorkspaceJsonFromHistory, WORKSPACE_HISTORY_ID, writeWorkspaceJsonWithHistory, } from "../core/history/workspace-history.js";
|
|
24
24
|
export { normalizeReplayPatchOps, replayToCanonicalItemDocument, replayToItemDocument, toReplayDocument, verifyHistoryChain, verifyHistoryChainWithVersion, } from "../core/history/replay.js";
|
|
25
25
|
export { resolveBodyFileContent } from "../core/io/body-file.js";
|
|
26
26
|
export { generateItemId, normalizeItemId, normalizeRawItemId, } from "../core/item/id.js";
|
|
@@ -81,4 +81,4 @@ export { maybeRunFirstUseTelemetryPrompt } from "../core/telemetry/consent.js";
|
|
|
81
81
|
export { deriveTelemetryCommandResolution, } from "../core/telemetry/observability.js";
|
|
82
82
|
export { emitTelemetryErrorEvent, finishTelemetryCommand, startTelemetryCommand, } from "../core/telemetry/runtime.js";
|
|
83
83
|
//# sourceMappingURL=runtime-primitives.js.map
|
|
84
|
-
//# debugId=
|
|
84
|
+
//# debugId=a678b9f8-ba36-5127-877f-96bb4acc38c5
|
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]="a387cd7a-cb16-5082-80e1-9632ebd02480")}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";
|
|
@@ -31,7 +31,7 @@ import { createExtensionCommandSdk } from "./extension-command-context.js";
|
|
|
31
31
|
import { createUnknownSubcommandError } from "./agent/subcommand-recovery.js";
|
|
32
32
|
import { applyContextIntentProjection, attachReadOutputContracts, } from "./context-intent-contracts.js";
|
|
33
33
|
import { runWithDiscoveredContextIntentContracts, } from "./context-intent-runtime.js";
|
|
34
|
-
import { validateReadOutputOptions, } from "./read-output-contracts.js";
|
|
34
|
+
import { normalizeReadOutputIncludeModeOptions, validateReadOutputOptions, } from "./read-output-contracts.js";
|
|
35
35
|
export { clearWorkspaceContractsCache } from "./workspace-contracts-cache.js";
|
|
36
36
|
import { normalizeActivityProjectionOptions, runActivity, } from "./query/activity.js";
|
|
37
37
|
import { runAssuranceDispatch } from "./governance/assurance-action.js";
|
|
@@ -1870,6 +1870,7 @@ export function analyzeSdkActionCoverage(actions = PM_TOOL_ACTIONS) {
|
|
|
1870
1870
|
async function dispatchAction(action, args, global, activeExtensions) {
|
|
1871
1871
|
const options = optionsWithAuthor(args, action);
|
|
1872
1872
|
validateReadOutputOptions(action, options);
|
|
1873
|
+
normalizeReadOutputIncludeModeOptions(action, options);
|
|
1873
1874
|
const ctx = {
|
|
1874
1875
|
action,
|
|
1875
1876
|
args,
|
|
@@ -1883,6 +1884,7 @@ async function dispatchAction(action, args, global, activeExtensions) {
|
|
|
1883
1884
|
const result = handler
|
|
1884
1885
|
? await handler(ctx)
|
|
1885
1886
|
: await dispatchActiveExtensionAction(action, args, options, global, activeExtensions);
|
|
1887
|
+
options.resolvedOutputFormat = "json";
|
|
1886
1888
|
return attachReadOutputContracts(action, options, result);
|
|
1887
1889
|
}
|
|
1888
1890
|
const actionRunnerTestHooks = {
|
|
@@ -1930,4 +1932,4 @@ async function loadWorkspaceExtensionRegistrations(pmRoot, settings, cwd) {
|
|
|
1930
1932
|
}
|
|
1931
1933
|
}
|
|
1932
1934
|
//# sourceMappingURL=runtime.js.map
|
|
1933
|
-
//# debugId=
|
|
1935
|
+
//# debugId=a387cd7a-cb16-5082-80e1-9632ebd02480
|
package/docs/ASSURANCE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Project Assurance Primitives
|
|
2
2
|
|
|
3
|
-
Tracker: [pm-2lex4r](../.agents/pm/features/pm-2lex4r.toon), [pm-lyfu7b](../.agents/pm/features/pm-lyfu7b.toon), [pm-wn6wot](../.agents/pm/features/pm-wn6wot.toon), [pm-91xeam](../.agents/pm/features/pm-91xeam.toon), [pm-uhv1m5](../.agents/pm/features/pm-uhv1m5.toon), [pm-m7bb7r](../.agents/pm/features/pm-m7bb7r.toon), [pm-py7qv2](../.agents/pm/issues/pm-py7qv2.toon), [pm-33mjrw](../.agents/pm/issues/pm-33mjrw.toon), [pm-q6n8sj](../.agents/pm/issues/pm-q6n8sj.toon)
|
|
3
|
+
Tracker: [pm-2lex4r](../.agents/pm/features/pm-2lex4r.toon), [pm-lyfu7b](../.agents/pm/features/pm-lyfu7b.toon), [pm-wn6wot](../.agents/pm/features/pm-wn6wot.toon), [pm-91xeam](../.agents/pm/features/pm-91xeam.toon), [pm-uhv1m5](../.agents/pm/features/pm-uhv1m5.toon), [pm-m7bb7r](../.agents/pm/features/pm-m7bb7r.toon), [pm-py7qv2](../.agents/pm/issues/pm-py7qv2.toon), [pm-33mjrw](../.agents/pm/issues/pm-33mjrw.toon), [pm-q6n8sj](../.agents/pm/issues/pm-q6n8sj.toon), [pm-h06944](../.agents/pm/issues/pm-h06944.toon), [pm-dwj33e](../.agents/pm/decisions/pm-dwj33e.toon)
|
|
4
4
|
|
|
5
5
|
## Agent Quick Context
|
|
6
6
|
|
|
@@ -12,6 +12,15 @@ Assurance turns project policy into three reusable SDK-owned declarations:
|
|
|
12
12
|
|
|
13
13
|
Declarations live in `.agents/pm/assurance.json`. Every registry mutation and non-dry gate verdict is appended through the verified workspace history stream; never edit either file directly.
|
|
14
14
|
|
|
15
|
+
`pm history _workspace --verify`, `pm validate`, and `pm health` verify both
|
|
16
|
+
the hash chain and replay-to-disk agreement for every governed singleton. A
|
|
17
|
+
valid chain paired with a different, missing, or unreadable singleton is still
|
|
18
|
+
drift. SDK hosts can inspect that state with `inspectWorkspaceHistoryState`,
|
|
19
|
+
adopt a reviewed out-of-band value only through
|
|
20
|
+
`reconcileWorkspaceJsonHistory` with a terminal authorizing Decision, or
|
|
21
|
+
replace it from a verified version with `restoreWorkspaceJsonFromHistory`.
|
|
22
|
+
Both recovery paths append forward; neither rewrites the existing stream.
|
|
23
|
+
|
|
15
24
|
## Why Assurance Exists
|
|
16
25
|
|
|
17
26
|
Project management is context management. A useful quality gate therefore needs more than a shell exit code: it must preserve what was measured, which population was judged, why a bound exists, who owns it, what changed the result, how expensive the evaluation was, and which immutable tree received the verdict.
|
package/docs/COMMANDS.md
CHANGED
|
@@ -21,7 +21,29 @@ pm contracts --command <command> --flags-only --json
|
|
|
21
21
|
|
|
22
22
|
Tracked documentation work: [pm-u9d0](../.agents/pm/epics/pm-u9d0.toon),
|
|
23
23
|
[pm-7nqo6b](../.agents/pm/issues/pm-7nqo6b.toon), and
|
|
24
|
-
[pm-j1r8gl](../.agents/pm/issues/pm-j1r8gl.toon).
|
|
24
|
+
[pm-j1r8gl](../.agents/pm/issues/pm-j1r8gl.toon). Universal command intent and
|
|
25
|
+
default output-budget enforcement are tracked by
|
|
26
|
+
[pm-5t33or](../.agents/pm/features/pm-5t33or.toon),
|
|
27
|
+
[pm-s2h0mq](../.agents/pm/issues/pm-s2h0mq.toon),
|
|
28
|
+
[pm-pmrae8](../.agents/pm/issues/pm-pmrae8.toon), and
|
|
29
|
+
[pm-7i97c3](../.agents/pm/issues/pm-7i97c3.toon).
|
|
30
|
+
|
|
31
|
+
### Universal read-output ceiling
|
|
32
|
+
|
|
33
|
+
Every SDK-backed read has a format-aware default token ceiling discovered from
|
|
34
|
+
`pm contracts`. Results already within that ceiling are returned unchanged, so
|
|
35
|
+
the default adds no receipt overhead to ordinary reads. An oversized result is
|
|
36
|
+
degraded deterministically through string compaction, row compaction, and a
|
|
37
|
+
truthful omission envelope; automatic degradation adds `read_output` with
|
|
38
|
+
`budget_source: default`, `budget_tokens`, the final estimate, and the applied
|
|
39
|
+
compaction flags.
|
|
40
|
+
|
|
41
|
+
Use `--output-budget <tokens>` to request a tighter per-call ceiling. Use
|
|
42
|
+
`--output-budget unbounded` only when the caller deliberately accepts the full
|
|
43
|
+
cost. This cost opt-out is distinct from command-local row controls such as
|
|
44
|
+
`activity --unbounded`, which disable a row limit but do not disable the shared
|
|
45
|
+
token ceiling. `--output-format json` and global `--json` select the declared
|
|
46
|
+
JSON ceiling; TOON uses the smaller default agent ceiling.
|
|
25
47
|
|
|
26
48
|
## Command Families
|
|
27
49
|
|
|
@@ -1161,7 +1183,14 @@ Extension policy tokens are explicitly scoped by
|
|
|
1161
1183
|
Project-governance setters use the separate `governance_contracts` value
|
|
1162
1184
|
domains; in particular, workflow enforcement is `off|warn|strict`, not the
|
|
1163
1185
|
extension policy token `enforce`.
|
|
1164
|
-
Use `pm contracts --summary --json` first when bootstrapping in a tight context
|
|
1186
|
+
Use `pm contracts --summary --json` first when bootstrapping in a tight context
|
|
1187
|
+
window. `command_summaries` contains exactly one row per advertised command
|
|
1188
|
+
path—including aliases and namespace children—with a meaningful intent plus
|
|
1189
|
+
`default_max_estimated_tokens` and the format-specific TOON/JSON ceilings.
|
|
1190
|
+
Package commands contribute their intent through command registration (falling
|
|
1191
|
+
back to the registered description), so agents never need a generic
|
|
1192
|
+
`Inspect flags.` placeholder. Request heavier command-specific flags or schemas
|
|
1193
|
+
only after selecting the exact path.
|
|
1165
1194
|
|
|
1166
1195
|
## Completion
|
|
1167
1196
|
|