43 lines
2.2 KiB
TypeScript
43 lines
2.2 KiB
TypeScript
// PEP-192/306: память самой FORGE (.peppa/memory/) — файл на задачу, каждый в своём пределе,
|
||
// без повторов внутри файла; старого общего файла нет (его правили все ветки разом).
|
||
import assert from "node:assert/strict";
|
||
import { existsSync } from "node:fs";
|
||
import { fileURLToPath } from "node:url";
|
||
import { describe, test } from "node:test";
|
||
import { MEMORY_SECTIONS, memoryMaxChars, memorySources, memoryTaskMaxChars } from "@peppa/core";
|
||
|
||
const root = fileURLToPath(new URL("../../../", import.meta.url));
|
||
const sources = memorySources(root);
|
||
const norm = (s: string) => s.toLowerCase().replace(/\s+/g, " ").trim();
|
||
|
||
describe("память проекта FORGE", () => {
|
||
test("Старый файл вернулся: .peppa/memory.md нет", () => {
|
||
assert.equal(existsSync(`${root}.peppa/memory.md`), false, ".peppa/memory.md снова в репозитории — перенеси пункты: peppa memory split");
|
||
});
|
||
|
||
test("Память в пределе: файл задачи и общий файл", () => {
|
||
assert.ok(sources.length > 0, "память FORGE не найдена");
|
||
for (const s of sources) {
|
||
const max = s.key ? memoryTaskMaxChars() : memoryMaxChars();
|
||
assert.ok(s.text.length <= max, `${s.path}: ${s.text.length} из ${max} символов — ужми`);
|
||
}
|
||
});
|
||
|
||
test("Память без дублей: пункт не повторяется внутри файла", () => {
|
||
for (const s of sources) {
|
||
const items = s.text.split("\n").filter((l) => l.startsWith("- ")).map(norm);
|
||
const dup = items.filter((l, i) => items.indexOf(l) !== i);
|
||
assert.deepEqual(dup, [], `повторы в ${s.path} (часто — после мержа main)`);
|
||
}
|
||
});
|
||
|
||
test("Память по разделам: раздел встречается в файле не больше одного раза", () => {
|
||
for (const s of sources) {
|
||
for (const sec of MEMORY_SECTIONS) {
|
||
const n = s.text.split("\n").filter((l) => l.trim() === `## ${sec}`).length;
|
||
assert.ok(n <= 1, `${s.path}: раздел «${sec}» — ${n}`);
|
||
}
|
||
}
|
||
});
|
||
});
|