Move the extension from ~/.pi/agent/extensions/subagent into this repo and package it for pi install: - Sources under src/, entry exposed via the pi manifest in package.json - Host packages (@earendil-works/*, typebox) stay peer dependencies - Tests, TLA+ spec, and research notes move along unchanged in behavior - Gates (.pi/verify.json): typecheck, tests, tlc, smoke — all green - Install: pi install git:git.rwiesner.com/alex/pi-subagent or local path
21 lines
1.0 KiB
TypeScript
21 lines
1.0 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import fc from "fast-check";
|
|
import { truncateUtf8Head, truncateUtf8Tail } from "../src/output.ts";
|
|
|
|
test("UTF-8 truncation preserves exact prefixes/suffixes and valid boundaries", () => {
|
|
fc.assert(fc.property(fc.string({ unit: "grapheme" }), fc.integer({ min: 0, max: 128 }), (input, limit) => {
|
|
const head = truncateUtf8Head(input, limit);
|
|
assert.equal(input.startsWith(head.text), true);
|
|
assert.ok(Buffer.byteLength(head.text, "utf8") <= limit);
|
|
assert.equal(head.bytesOmitted, Buffer.byteLength(input, "utf8") - Buffer.byteLength(head.text, "utf8"));
|
|
assert.equal(head.truncated, head.bytesOmitted > 0);
|
|
|
|
const tail = truncateUtf8Tail(input, limit);
|
|
assert.equal(input.endsWith(tail.text), true);
|
|
assert.ok(Buffer.byteLength(tail.text, "utf8") <= limit);
|
|
assert.equal(tail.bytesOmitted, Buffer.byteLength(input, "utf8") - Buffer.byteLength(tail.text, "utf8"));
|
|
assert.equal(tail.truncated, tail.bytesOmitted > 0);
|
|
}), { numRuns: 500 });
|
|
});
|