pi-midcompact 0.5.2 → 0.6.0

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/src/projection.ts CHANGED
@@ -17,7 +17,7 @@ export function summaryMessage(block: CompressionBlock, timestamp = Date.now()):
17
17
  block.summary,
18
18
  "",
19
19
  `Original block: ${block.id}`,
20
- `Use midcompact(action=\"recall\", ref=\"${block.id}\") if exact details are needed.`,
20
+ `Use midcompact(request={action:\"recall\", ref:\"${block.id}\"}) if exact details are needed.`,
21
21
  ].join("\n"),
22
22
  display: true,
23
23
  details: {
@@ -74,8 +74,8 @@ export function replacementMetrics(block: CompressionBlock): ContentMetrics {
74
74
  * Factual replacement content chars for a range, given its topic and summary.
75
75
  * Computed from the actual summary message wrapper text that projection emits.
76
76
  */
77
- export function replacementContentChars(summary: string, topic?: string): number {
78
- const block: CompressionBlock = {
77
+ function draftReplacementBlock(summary: string, topic?: string): CompressionBlock {
78
+ return {
79
79
  id: "draft",
80
80
  summary,
81
81
  topic,
@@ -89,7 +89,16 @@ export function replacementContentChars(summary: string, topic?: string): number
89
89
  originalApproxTokens: 0,
90
90
  compressedApproxTokens: 0,
91
91
  };
92
- return replacementMetrics(block).contentChars;
92
+ }
93
+
94
+ /** Render the exact replacement content used for draft display estimates. */
95
+ export function replacementContentText(summary: string, topic?: string): string {
96
+ const content = summaryMessage(draftReplacementBlock(summary, topic)).content;
97
+ return typeof content === "string" ? content : "";
98
+ }
99
+
100
+ export function replacementContentChars(summary: string, topic?: string): number {
101
+ return replacementMetrics(draftReplacementBlock(summary, topic)).contentChars;
93
102
  }
94
103
 
95
104
  /** @deprecated legacy heuristic; kept only for old approximate-token field compat. */