pm-context 2026.10.23 → 2026.10.24
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/README.md +44 -2
- package/dist/context-receipts.d.ts +9 -2
- package/dist/context-receipts.d.ts.map +1 -1
- package/dist/context-receipts.js +14 -9
- package/dist/context-receipts.js.map +1 -1
- package/dist/evidence-packing.d.ts +68 -0
- package/dist/evidence-packing.d.ts.map +1 -0
- package/dist/evidence-packing.js +146 -0
- package/dist/evidence-packing.js.map +1 -0
- package/dist/file-focus.d.ts.map +1 -1
- package/dist/file-focus.js +1 -0
- package/dist/file-focus.js.map +1 -1
- package/dist/index.d.ts +13 -71
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +60 -92
- package/dist/index.js.map +1 -1
- package/dist/witnesses.d.ts +56 -0
- package/dist/witnesses.d.ts.map +1 -0
- package/dist/witnesses.js +121 -0
- package/dist/witnesses.js.map +1 -0
- package/manifest.json +2 -2
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
export { packCriterionEvidence, encodeEvidencePack, parseEvidencePacket, readEvidencePacket, EvidencePackingError } from "./evidence-packing.ts";
|
|
2
|
+
export type { EvidenceBinding, EvidenceCriterion, EvidencePacket, EvidencePack, EvidencePackOptions, CriterionCoverage, PackedEvidence } from "./evidence-packing.ts";
|
|
3
|
+
export { checkContextWitnesses, encodeWitnessReport, parseWitnessPacket, readWitnessPacket, WitnessError } from "./witnesses.ts";
|
|
4
|
+
export type { ClaimCitation, ContextClaim, ContextWitness, WitnessPacket, WitnessReport } from "./witnesses.ts";
|
|
1
5
|
export { createFreshnessReader, encodeFreshness, FRESHNESS_LIMITS, FreshnessError, parseFreshnessPacket, readFreshnessFile, readFreshnessJson, recordFreshness, resumeFreshness } from "./freshness.ts";
|
|
2
6
|
export type { FreshnessManifest, FreshnessPacket, FreshnessReader, FreshnessResult, FreshnessSection, FreshnessSource } from "./freshness.ts";
|
|
3
7
|
import type { FileFocus } from "./file-focus.ts";
|
|
4
8
|
import type { ExtensionApi, RuntimeStatusRegistry, RelationshipKindRegistry } from "@unbrained/pm-cli/sdk";
|
|
5
|
-
import {
|
|
6
|
-
import type {
|
|
9
|
+
import { listAllComplete } from "@unbrained/pm-cli/sdk/core";
|
|
10
|
+
import type { PmCompleteListResult } from "@unbrained/pm-cli/sdk";
|
|
7
11
|
import type { ContextRelevanceReport } from "@unbrained/pm-cli/sdk/query";
|
|
8
12
|
/** Stable failure categories reported by context command handlers. */
|
|
9
13
|
export declare const EXIT_CODE: {
|
|
@@ -286,76 +290,14 @@ export declare function renderAgentHandoff(pack: ContextPack, options?: {
|
|
|
286
290
|
relationshipRegistry?: RelationshipKindRegistry;
|
|
287
291
|
}): string;
|
|
288
292
|
/**
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
* envelope the CLI serializes for `list-all --json`), but the declared
|
|
293
|
-
* `ListResult` type does not carry it — this local view reads it without
|
|
294
|
-
* weakening the SDK type.
|
|
295
|
-
*/
|
|
296
|
-
interface ListOmissionReceipt {
|
|
297
|
-
/** True when field groups were dropped from the projection. */
|
|
298
|
-
has_omissions?: boolean;
|
|
299
|
-
/** Count of dropped groups. */
|
|
300
|
-
omitted_field_group_count?: number;
|
|
301
|
-
/** Names of the dropped groups. */
|
|
302
|
-
omitted_field_groups?: string[];
|
|
303
|
-
}
|
|
304
|
-
/** A list result widened only by the runtime-present omission receipt. */
|
|
305
|
-
type ListResultWithReceipt = ListResult & {
|
|
306
|
-
omission_receipt?: ListOmissionReceipt;
|
|
307
|
-
};
|
|
308
|
-
/**
|
|
309
|
-
* Refuse an incomplete SDK `list-all` result instead of consuming it.
|
|
310
|
-
*
|
|
311
|
-
* Reading `.items` without consulting the result's completeness receipt is how
|
|
312
|
-
* this package once built a context pack from 10 of 682 workspace items and
|
|
313
|
-
* reported success: pm 2026.8.14 defaulted the list to a truncated answer and
|
|
314
|
-
* nothing here checked. Any one of four independent signals means the rows in
|
|
315
|
-
* `items` are NOT the whole workspace, so this throws (never returns a partial
|
|
316
|
-
* list, never logs and continues) naming the signal that tripped plus the
|
|
317
|
-
* `count`/`total` figures:
|
|
318
|
-
*
|
|
319
|
-
* - `truncated === true` — the row list was cut short (output budget, limit);
|
|
320
|
-
* - `has_more === true` — rows exist past the returned cursor boundary;
|
|
321
|
-
* - `completeness.status !== "complete"` — items/directories were unreadable
|
|
322
|
-
* ("partial") or the corpus was never scanned ("unchecked"); either way the
|
|
323
|
-
* answer is not attested complete;
|
|
324
|
-
* - `omission_receipt.has_omissions === true` — field groups were dropped from
|
|
325
|
-
* the projection, so rows are present but degraded.
|
|
326
|
-
*
|
|
327
|
-
* Thrown errors are {@link CommandError} so the command runtime turns them into
|
|
328
|
-
* a clean nonzero exit. Paging is deliberately NOT attempted: a context pack
|
|
329
|
-
* silently built from a partial page is the failure mode this guard exists to
|
|
330
|
-
* prevent, so refusing loudly is simpler and safer.
|
|
331
|
-
*
|
|
332
|
-
* @param result - SDK list result (a result missing its receipt trips the
|
|
333
|
-
* completeness signal: an unverifiable answer is not complete).
|
|
334
|
-
* @throws {@link CommandError} naming the first tripped signal and the counts.
|
|
335
|
-
*/
|
|
336
|
-
export declare function assertListResultComplete(result: ListResultWithReceipt): void;
|
|
337
|
-
/** Injectable seam over the SDK list action {@link readPmItems} uses. */
|
|
338
|
-
export type PmListAction = typeof pmList;
|
|
339
|
-
/**
|
|
340
|
-
* Read every pm item (full metadata + body) in-process through the SDK.
|
|
341
|
-
*
|
|
342
|
-
* Replaces the previous `spawnSync("pm", ["list-all", "--json", "--include-body"])`
|
|
343
|
-
* shell-out with the typed {@link list} action from `@unbrained/pm-cli/sdk/core`.
|
|
344
|
-
* `list-all` is the SDK alias for `list` with `excludeTerminal: false`; passing
|
|
345
|
-
* `full: true` + `includeBody: true` reproduces the full-metadata-with-body
|
|
346
|
-
* projection the shell-out parsed. `noTruncate: true` deliberately overrides any
|
|
347
|
-
* truncating limit and `strictRead: true` makes unreadable corpus entries a hard
|
|
348
|
-
* SDK error, and the returned receipt is STILL verified by
|
|
349
|
-
* {@link assertListResultComplete} — the 2026.8.14 truncated-default regression
|
|
350
|
-
* is exactly the silently-partial read this package refuses to reintroduce, so
|
|
351
|
-
* the guard does not trust the request options alone. Being an in-process SDK
|
|
352
|
-
* action (no child process), there is no spawn stdout buffer to size here; the
|
|
353
|
-
* completeness receipt is the over-run guard.
|
|
354
|
-
*
|
|
355
|
-
* @param pmRoot - Tracker storage root to read.
|
|
356
|
-
* @param list - Injectable SDK list action (tests substitute a canned real
|
|
357
|
-
* result); defaults to the real {@link pmList}.
|
|
293
|
+
* Re-certify the full SDK envelope and require its producer's certificate.
|
|
294
|
+
* The SDK owns corpus and output invariants; this consumer also refuses a
|
|
295
|
+
* missing or inconsistent producer certificate before constructing a pack.
|
|
358
296
|
*/
|
|
297
|
+
export declare function assertListResultComplete(result: unknown): asserts result is PmCompleteListResult;
|
|
298
|
+
/** Injectable complete-read boundary; receipt tests derive inputs from real trackers. */
|
|
299
|
+
export type PmListAction = typeof listAllComplete;
|
|
300
|
+
/** Read all types and lifecycle states without extension side effects, preserving SDK refusals. */
|
|
359
301
|
export declare function readPmItems(pmRoot: string, list?: PmListAction): Promise<PmItem[]>;
|
|
360
302
|
/** Rank options forwarded to the SDK relevance engine. */
|
|
361
303
|
export interface SdkRankOptions {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACjJ,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,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IACtC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,4EAA4E;AAC5E,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,aAAa,EAAE,cAAc,CAAC;IAC9B,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,cAAc,GAAG,oBAAoB,CAc3G;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,CA+B/G;AAoiBD,+FAA+F;;;;;kBAK/E,YAAY"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import { packCriterionEvidence, encodeEvidencePack, readEvidencePacket, EvidencePackingError } from "./evidence-packing.js";
|
|
2
|
+
export { packCriterionEvidence, encodeEvidencePack, parseEvidencePacket, readEvidencePacket, EvidencePackingError } from "./evidence-packing.js";
|
|
1
3
|
import { createFreshnessReader, encodeFreshness, FreshnessError, parseFreshnessPacket, readFreshnessJson, recordFreshness, resumeFreshness } from "./freshness.js";
|
|
4
|
+
import { checkContextWitnesses, encodeWitnessReport, readWitnessPacket, WitnessError } from "./witnesses.js";
|
|
5
|
+
export { checkContextWitnesses, encodeWitnessReport, parseWitnessPacket, readWitnessPacket, WitnessError } from "./witnesses.js";
|
|
2
6
|
export { createFreshnessReader, encodeFreshness, FRESHNESS_LIMITS, FreshnessError, parseFreshnessPacket, readFreshnessFile, readFreshnessJson, recordFreshness, resumeFreshness } from "./freshness.js";
|
|
3
7
|
import { buildSincePack, encodeSincePack } from "./since.js";
|
|
4
8
|
import { writeFileSync } from "node:fs";
|
|
9
|
+
import { isDeepStrictEqual } from "node:util";
|
|
5
10
|
import { resolveFileFocus, matchFileFocus, rankFileFocus, renderFileFocus, readFileFocusItems } from "./file-focus.js";
|
|
6
11
|
import { createRelationshipKindRegistry, readSettings, resolveRuntimeStatusRegistry, resolveWorkspaceRelationshipKindRegistry, } from "@unbrained/pm-cli/sdk";
|
|
7
|
-
import {
|
|
8
|
-
import { buildItemContextRelevanceCandidates, defaultScoreContextCandidates, packContextCandidates, recordContextUsageServing, } from "@unbrained/pm-cli/sdk/query";
|
|
12
|
+
import { listAllComplete } from "@unbrained/pm-cli/sdk/core";
|
|
13
|
+
import { buildItemContextRelevanceCandidates, certifyCompleteListResult, PmCompleteListValidationError, defaultScoreContextCandidates, packContextCandidates, recordContextUsageServing, } from "@unbrained/pm-cli/sdk/query";
|
|
9
14
|
import { DEFAULT_REPORT_LIMIT, renderUsageReport, reportContextUsage, resolveSince } from "./context-usage.js";
|
|
10
15
|
import { readContextUsageAffinity } from "@unbrained/pm-cli/sdk/query";
|
|
11
16
|
import { recordReceiptUsage, reportContextReceipts, renderReceiptReport, serveContextReceipt } from "./context-receipts.js";
|
|
@@ -733,97 +738,23 @@ export function renderAgentHandoff(pack, options = {}) {
|
|
|
733
738
|
return output;
|
|
734
739
|
}
|
|
735
740
|
/**
|
|
736
|
-
*
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
* this package once built a context pack from 10 of 682 workspace items and
|
|
740
|
-
* reported success: pm 2026.8.14 defaulted the list to a truncated answer and
|
|
741
|
-
* nothing here checked. Any one of four independent signals means the rows in
|
|
742
|
-
* `items` are NOT the whole workspace, so this throws (never returns a partial
|
|
743
|
-
* list, never logs and continues) naming the signal that tripped plus the
|
|
744
|
-
* `count`/`total` figures:
|
|
745
|
-
*
|
|
746
|
-
* - `truncated === true` — the row list was cut short (output budget, limit);
|
|
747
|
-
* - `has_more === true` — rows exist past the returned cursor boundary;
|
|
748
|
-
* - `completeness.status !== "complete"` — items/directories were unreadable
|
|
749
|
-
* ("partial") or the corpus was never scanned ("unchecked"); either way the
|
|
750
|
-
* answer is not attested complete;
|
|
751
|
-
* - `omission_receipt.has_omissions === true` — field groups were dropped from
|
|
752
|
-
* the projection, so rows are present but degraded.
|
|
753
|
-
*
|
|
754
|
-
* Thrown errors are {@link CommandError} so the command runtime turns them into
|
|
755
|
-
* a clean nonzero exit. Paging is deliberately NOT attempted: a context pack
|
|
756
|
-
* silently built from a partial page is the failure mode this guard exists to
|
|
757
|
-
* prevent, so refusing loudly is simpler and safer.
|
|
758
|
-
*
|
|
759
|
-
* @param result - SDK list result (a result missing its receipt trips the
|
|
760
|
-
* completeness signal: an unverifiable answer is not complete).
|
|
761
|
-
* @throws {@link CommandError} naming the first tripped signal and the counts.
|
|
741
|
+
* Re-certify the full SDK envelope and require its producer's certificate.
|
|
742
|
+
* The SDK owns corpus and output invariants; this consumer also refuses a
|
|
743
|
+
* missing or inconsistent producer certificate before constructing a pack.
|
|
762
744
|
*/
|
|
763
745
|
export function assertListResultComplete(result) {
|
|
764
|
-
const
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
+ "The item list was cut short (output budget or limit); a context pack "
|
|
770
|
-
+ "built from it would silently miss items. Narrow the operation or "
|
|
771
|
-
+ "raise the output budget, then retry.");
|
|
772
|
-
}
|
|
773
|
-
if (result.has_more === true) {
|
|
774
|
-
throw new CommandError(`Refusing incomplete pm list-all result: has_more=true (${counts}). `
|
|
775
|
-
+ "Rows exist beyond the returned page; packing the page as the whole "
|
|
776
|
-
+ "workspace would silently drop them.");
|
|
777
|
-
}
|
|
778
|
-
if (result.completeness?.status !== "complete") {
|
|
779
|
-
const status = result.completeness?.status === undefined
|
|
780
|
-
? "(missing)"
|
|
781
|
-
: JSON.stringify(result.completeness.status);
|
|
782
|
-
const unreadable = `unreadable_item_count=${result.completeness?.unreadable_item_count ?? 0}`
|
|
783
|
-
+ `, unreadable_directory_count=${result.completeness?.unreadable_directory_count ?? 0}`;
|
|
784
|
-
throw new CommandError(`Refusing incomplete pm list-all result: completeness.status=${status} `
|
|
785
|
-
+ `(${unreadable}; ${counts}). The workspace corpus behind this list was `
|
|
786
|
-
+ "not attested completely read, so the rows are not the whole workspace.");
|
|
787
|
-
}
|
|
788
|
-
const omission = result.omission_receipt;
|
|
789
|
-
if (omission?.has_omissions === true) {
|
|
790
|
-
const groups = omission.omitted_field_groups ?? [];
|
|
791
|
-
throw new CommandError(`Refusing incomplete pm list-all result: omission_receipt.has_omissions=true `
|
|
792
|
-
+ `(omitted_field_groups: ${groups.length ? groups.join(", ") : "(none listed)"}; ${counts}). `
|
|
793
|
-
+ "Field groups were dropped from the projection, so the rows are present "
|
|
794
|
-
+ "but degraded; re-read without the field-omitting options.");
|
|
746
|
+
const certified = certifyCompleteListResult(result);
|
|
747
|
+
if (!isDeepStrictEqual(result.complete_list, certified.complete_list)) {
|
|
748
|
+
throw new PmCompleteListValidationError([{
|
|
749
|
+
code: "invalid_envelope", message: "Context input requires a matching complete_list certificate from listAllComplete.",
|
|
750
|
+
}]);
|
|
795
751
|
}
|
|
796
752
|
}
|
|
797
|
-
/**
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
* Replaces the previous `spawnSync("pm", ["list-all", "--json", "--include-body"])`
|
|
801
|
-
* shell-out with the typed {@link list} action from `@unbrained/pm-cli/sdk/core`.
|
|
802
|
-
* `list-all` is the SDK alias for `list` with `excludeTerminal: false`; passing
|
|
803
|
-
* `full: true` + `includeBody: true` reproduces the full-metadata-with-body
|
|
804
|
-
* projection the shell-out parsed. `noTruncate: true` deliberately overrides any
|
|
805
|
-
* truncating limit and `strictRead: true` makes unreadable corpus entries a hard
|
|
806
|
-
* SDK error, and the returned receipt is STILL verified by
|
|
807
|
-
* {@link assertListResultComplete} — the 2026.8.14 truncated-default regression
|
|
808
|
-
* is exactly the silently-partial read this package refuses to reintroduce, so
|
|
809
|
-
* the guard does not trust the request options alone. Being an in-process SDK
|
|
810
|
-
* action (no child process), there is no spawn stdout buffer to size here; the
|
|
811
|
-
* completeness receipt is the over-run guard.
|
|
812
|
-
*
|
|
813
|
-
* @param pmRoot - Tracker storage root to read.
|
|
814
|
-
* @param list - Injectable SDK list action (tests substitute a canned real
|
|
815
|
-
* result); defaults to the real {@link pmList}.
|
|
816
|
-
*/
|
|
817
|
-
export async function readPmItems(pmRoot, list = pmList) {
|
|
818
|
-
let result;
|
|
819
|
-
try {
|
|
820
|
-
result = await list({ full: true, includeBody: true, excludeTerminal: false, noTruncate: true, strictRead: true }, { pmRoot });
|
|
821
|
-
}
|
|
822
|
-
catch (err) {
|
|
823
|
-
throw new CommandError(`Could not read pm items via SDK list: ${err instanceof Error ? err.message : String(err)}`);
|
|
824
|
-
}
|
|
753
|
+
/** Read all types and lifecycle states without extension side effects, preserving SDK refusals. */
|
|
754
|
+
export async function readPmItems(pmRoot, list = listAllComplete) {
|
|
755
|
+
const result = await list({ includeBody: true }, { pmRoot, noExtensions: true });
|
|
825
756
|
assertListResultComplete(result);
|
|
826
|
-
return result.items
|
|
757
|
+
return result.items;
|
|
827
758
|
}
|
|
828
759
|
/** Per-item token estimate for one character of text (rough 4 chars/token). */
|
|
829
760
|
const TOKENS_PER_CHAR = 0.25;
|
|
@@ -1112,7 +1043,7 @@ async function recordPackServing(ctx, focus, neighbors) {
|
|
|
1112
1043
|
*/
|
|
1113
1044
|
async function measureContextOutput(ctx, pack, output, format, command, compress, outputPath) {
|
|
1114
1045
|
try {
|
|
1115
|
-
const measured = serveContextReceipt(ctx.pm_root, output, format === "json" ? "json" : "text", {
|
|
1046
|
+
const measured = await serveContextReceipt(ctx.pm_root, output, format === "json" ? "json" : "text", {
|
|
1116
1047
|
item_ids: [...pack.items, ...pack.neighbors].map((item) => item.id),
|
|
1117
1048
|
files: pack.links.filter((link) => link.kind === "file"),
|
|
1118
1049
|
}, {
|
|
@@ -1303,6 +1234,43 @@ function setupCommands(api) {
|
|
|
1303
1234
|
return renderedCommandResult(output);
|
|
1304
1235
|
},
|
|
1305
1236
|
});
|
|
1237
|
+
api.registerCommand({
|
|
1238
|
+
name: "context-evidence",
|
|
1239
|
+
description: "Pack explicit criterion evidence with exact coverage lost at a byte budget.",
|
|
1240
|
+
flags: [
|
|
1241
|
+
{ long: "--packet", value_name: "file", description: "JSON acceptance criteria and tracker field bindings", type: "string" },
|
|
1242
|
+
{ long: "--format", value_name: "format", description: "toon (default) or json", type: "string" },
|
|
1243
|
+
{ long: "--byte-budget", value_name: "n", description: "Complete-output UTF-8 byte ceiling (default 4000)", type: "string" },
|
|
1244
|
+
],
|
|
1245
|
+
async run(ctx) {
|
|
1246
|
+
const path = stringOption(ctx.options, "packet");
|
|
1247
|
+
const format = stringOption(ctx.options, "format") ?? (ctx.global.json ? "json" : "toon");
|
|
1248
|
+
if (!path || (format !== "json" && format !== "toon") || ctx.args.length)
|
|
1249
|
+
throw new EvidencePackingError("INVALID_ARGUMENT", "Supply --packet JSON with --format json or toon; no positional arguments are accepted.");
|
|
1250
|
+
const pack = await packCriterionEvidence(readEvidencePacket(path), createFreshnessReader(ctx.pm_root, "."), {
|
|
1251
|
+
format, byteBudget: Number(stringOption(ctx.options, "byte-budget", "byteBudget") ?? "4000"),
|
|
1252
|
+
});
|
|
1253
|
+
return renderedCommandResult(encodeEvidencePack(pack, format));
|
|
1254
|
+
},
|
|
1255
|
+
});
|
|
1256
|
+
api.registerCommand({
|
|
1257
|
+
name: "context-witnesses",
|
|
1258
|
+
description: "Find the smallest cited contradiction among declared packet assertions without editing sources.",
|
|
1259
|
+
flags: [
|
|
1260
|
+
{ long: "--packet", value_name: "file", description: "JSON packet of cited co-current claims", type: "string" },
|
|
1261
|
+
{ long: "--format", value_name: "format", description: "toon (default) or json", type: "string" },
|
|
1262
|
+
{ long: "--byte-budget", value_name: "n", description: "Complete-output UTF-8 byte ceiling (default 4000)", type: "string" },
|
|
1263
|
+
],
|
|
1264
|
+
async run(ctx) {
|
|
1265
|
+
const path = stringOption(ctx.options, "packet");
|
|
1266
|
+
const format = stringOption(ctx.options, "format") ?? (ctx.global.json ? "json" : "toon");
|
|
1267
|
+
if (!path || (format !== "json" && format !== "toon") || ctx.args.length)
|
|
1268
|
+
throw new WitnessError("INVALID_ARGUMENT", "Supply --packet JSON with --format json or toon; no positional arguments are accepted.");
|
|
1269
|
+
const budget = Number(stringOption(ctx.options, "byte-budget", "byteBudget") ?? "4000");
|
|
1270
|
+
const report = checkContextWitnesses(readWitnessPacket(path));
|
|
1271
|
+
return renderedCommandResult(encodeWitnessReport(report, format, budget));
|
|
1272
|
+
},
|
|
1273
|
+
});
|
|
1306
1274
|
for (const action of ["record", "resume"]) {
|
|
1307
1275
|
api.registerCommand({
|
|
1308
1276
|
name: `context-freshness ${action}`,
|
|
@@ -1517,7 +1485,7 @@ function setupCommands(api) {
|
|
|
1517
1485
|
if (!receiptId)
|
|
1518
1486
|
throw new CommandError("Usage evidence requires --receipt", EXIT_CODE.USAGE);
|
|
1519
1487
|
try {
|
|
1520
|
-
recordReceiptUsage(ctx.pm_root, { receipt_id: receiptId, session, citations, touched_items: touchedItems, edited_files: editedFiles });
|
|
1488
|
+
await recordReceiptUsage(ctx.pm_root, { receipt_id: receiptId, session, citations, touched_items: touchedItems, edited_files: editedFiles });
|
|
1521
1489
|
}
|
|
1522
1490
|
catch (error) {
|
|
1523
1491
|
throw new CommandError(error instanceof Error ? error.message : String(error), EXIT_CODE.USAGE);
|
|
@@ -1558,13 +1526,13 @@ function setupCommands(api) {
|
|
|
1558
1526
|
/** Register context commands and renderers with checked host behavior and package metadata. */
|
|
1559
1527
|
export default {
|
|
1560
1528
|
name: "pm-context",
|
|
1561
|
-
version: "2026.10.
|
|
1529
|
+
version: "2026.10.24",
|
|
1562
1530
|
description: "Generate deterministic pm context packs for agent handoffs, reviews, and status briefs",
|
|
1563
1531
|
activate(api) {
|
|
1564
1532
|
setupCommands(api);
|
|
1565
1533
|
if (typeof api.registerRenderer === "function") {
|
|
1566
1534
|
const rendererOwnership = {
|
|
1567
|
-
commands: ["context-pack", "context-pack since", "context-handoff", "context-usage", "context-freshness record", "context-freshness resume"],
|
|
1535
|
+
commands: ["context-pack", "context-pack since", "context-handoff", "context-usage", "context-freshness record", "context-freshness resume", "context-witnesses", "context-evidence"],
|
|
1568
1536
|
resultDiscriminator: isRenderedCommandResult,
|
|
1569
1537
|
};
|
|
1570
1538
|
api.registerRenderer("toon", renderCommandResult, rendererOwnership);
|