Initialize repository with harness code and assets
Initial import of all source code, config, and README assets: the packages workspace (cli, core, server, web, docs, landing, skills), build scripts, tooling config, and CI workflows. Includes the data-layout revision made on this branch: the local data root defaults to ~/.penguin/data (PENGUIN_HOME still overrides; the installer keeps its binaries in ~/.penguin), and every Agent lives under <project>/agents/<agent>/ — path helpers, the three agent-enumeration scans, the system prompt, built-in Skills, tests and docs all follow the new layout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ihk8iQuo3kv2aPjAYEPuR
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Content integrity: the sidebar (DOCS_NAV) and the content/ directory must agree —
|
||||
* every navigated slug has both zh and en files with a frontmatter title, and every
|
||||
* content file belongs to the navigation (an orphan file would be unreachable).
|
||||
* Reads the files via fs so the check runs under plain node (no Vite glob).
|
||||
*/
|
||||
import { readdirSync, readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { DOCS_NAV, DOC_SLUGS } from "../src/lib/nav";
|
||||
import { parseFrontmatter } from "../src/lib/frontmatter";
|
||||
|
||||
const contentDir = join(__dirname, "..", "content");
|
||||
const files = readdirSync(contentDir).filter((f) => f.endsWith(".md"));
|
||||
|
||||
describe("docs navigation / content integrity", () => {
|
||||
it("has unique slugs in DOCS_NAV", () => {
|
||||
expect(new Set(DOC_SLUGS).size).toBe(DOC_SLUGS.length);
|
||||
expect(DOCS_NAV.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("provides zh and en files with a title for every navigated slug", () => {
|
||||
for (const slug of DOC_SLUGS) {
|
||||
for (const lang of ["zh", "en"] as const) {
|
||||
const name = `${slug}.${lang}.md`;
|
||||
expect(files, `missing content file ${name}`).toContain(name);
|
||||
const { meta, body } = parseFrontmatter(readFileSync(join(contentDir, name), "utf8"));
|
||||
expect(meta.title, `missing title in ${name}`).toBeTruthy();
|
||||
expect(body.length, `empty body in ${name}`).toBeGreaterThan(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("has no content file outside the navigation", () => {
|
||||
for (const file of files) {
|
||||
const slug = /^(.+)\.(zh|en)\.md$/.exec(file)?.[1];
|
||||
expect(slug, `unparsable content file name ${file}`).toBeTruthy();
|
||||
expect(DOC_SLUGS, `orphan content file ${file}`).toContain(slug!);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { parseFrontmatter } from "../src/lib/frontmatter";
|
||||
|
||||
describe("parseFrontmatter", () => {
|
||||
it("parses a leading key/value block and trims the body", () => {
|
||||
const { meta, body } = parseFrontmatter(
|
||||
'---\ntitle: "OmniMessage"\ndescription: one protocol: three jobs\n---\n\nBody text\n',
|
||||
);
|
||||
expect(meta.title).toBe("OmniMessage");
|
||||
expect(meta.description).toBe("one protocol: three jobs");
|
||||
expect(body).toBe("Body text");
|
||||
});
|
||||
|
||||
it("returns the whole input as body when there is no frontmatter", () => {
|
||||
const { meta, body } = parseFrontmatter("# Just markdown\n");
|
||||
expect(meta).toEqual({});
|
||||
expect(body).toBe("# Just markdown");
|
||||
});
|
||||
|
||||
it("normalizes CRLF line endings", () => {
|
||||
const { meta, body } = parseFrontmatter("---\r\ntitle: X\r\n---\r\nbody\r\n");
|
||||
expect(meta.title).toBe("X");
|
||||
expect(body).toBe("body");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Docs ↔ skill-library sync: the Skills doc pages must mention every Skill that
|
||||
* actually ships in packages/skills (the library directory is the source of truth —
|
||||
* the same files loadLibrarySkills() reads). Derived, not hardcoded, so adding a
|
||||
* Skill without documenting it fails here instead of silently drifting.
|
||||
*/
|
||||
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const skillsRoot = join(__dirname, "..", "..", "skills", "skills");
|
||||
const contentDir = join(__dirname, "..", "content");
|
||||
|
||||
const librarySkills = readdirSync(skillsRoot, { withFileTypes: true })
|
||||
.filter((entry) => entry.isDirectory() && existsSync(join(skillsRoot, entry.name, "SKILL.md")))
|
||||
.map((entry) => entry.name)
|
||||
.sort();
|
||||
|
||||
describe("docs ↔ skill library sync", () => {
|
||||
it("found the skill library", () => {
|
||||
expect(librarySkills.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
for (const lang of ["zh", "en"] as const) {
|
||||
it(`skills.${lang}.md mentions every library Skill`, () => {
|
||||
const page = readFileSync(join(contentDir, `skills.${lang}.md`), "utf8");
|
||||
const missing = librarySkills.filter((name) => !page.includes(`\`${name}\``));
|
||||
expect(missing, `undocumented skills in skills.${lang}.md`).toEqual([]);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { extractToc, slugifyHeading } from "../src/lib/toc";
|
||||
|
||||
describe("slugifyHeading", () => {
|
||||
it("lowercases latin, hyphenates spaces, keeps CJK", () => {
|
||||
expect(slugifyHeading("Agent Loop")).toBe("agent-loop");
|
||||
expect(slugifyHeading("消息信封")).toBe("消息信封");
|
||||
expect(slugifyHeading("Tool Calls (streaming)")).toBe("tool-calls-streaming");
|
||||
});
|
||||
});
|
||||
|
||||
describe("extractToc", () => {
|
||||
it("collects ##/### headings and skips fenced code blocks", () => {
|
||||
const body = [
|
||||
"## Envelope",
|
||||
"```ts",
|
||||
"## not a heading",
|
||||
"```",
|
||||
"### Payload kinds",
|
||||
"#### too deep",
|
||||
].join("\n");
|
||||
expect(extractToc(body)).toEqual([
|
||||
{ id: "envelope", text: "Envelope", depth: 2 },
|
||||
{ id: "payload-kinds", text: "Payload kinds", depth: 3 },
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user