feat: complete evidence restructuring worktree

This commit is contained in:
Codex
2026-08-26 11:39:02 +02:00
parent a54d4769dd
commit 38f02cfd08
56 changed files with 1981 additions and 1801 deletions
@@ -1,6 +1,5 @@
const test = require("node:test");
const assert = require("node:assert");
const crypto = require("node:crypto");
const cp = require("node:child_process");
const fs = require("node:fs");
const { createRequire } = require("node:module");
@@ -125,17 +124,26 @@ function stripDescriptions(value, insideProperties = false) {
return value;
}
test("the injected skill stays byte-identical during extraction", () => {
test("before_agent_start injects the canonical skill byte-for-byte", async () => {
const harnessRoot = path.resolve(__dirname, "..", "..", "..", "..");
const digest = (relativePath) => crypto
.createHash("sha256")
.update(fs.readFileSync(path.join(harnessRoot, relativePath)))
.digest("hex");
assert.equal(
digest(path.join(".pi", "skills", "tht-sessione", "SKILL.md")),
"626a794071c095a4f20fffabb3bab901f05c101590adbdc58e45adfae56f3219",
const canonicalSkill = fs.readFileSync(
path.join(harnessRoot, ".pi", "skills", "tht-sessione", "SKILL.md"),
"utf8",
);
const { pi } = createFakePi();
installGate(pi);
await pi.emit("input", { source: "rpc", text: '/nuova-domanda "x"' });
const injected = await pi.emit("before_agent_start", { systemPrompt: "BASE" });
const systemPrompt = injected?.systemPrompt ?? "";
const opening = "<tht-sessione-skill>\n";
const closing = "\n</tht-sessione-skill>";
const start = systemPrompt.indexOf(opening);
const end = systemPrompt.indexOf(closing, start + opening.length);
assert.notEqual(start, -1);
assert.notEqual(end, -1);
assert.equal(systemPrompt.slice(start + opening.length, end), canonicalSkill);
});
test("F1 persists a concrete clarification directly from the select widget", async () => {