d4faee3a1e
Branch-length batch covering tooling, the model layer, the Web App and the public surfaces. Highlights: - Changelog: a per-release `changelog/<version>/` tree, grouped by the surface each change touches, with a root CHANGELOG.md holding one line per release. - Dev startup: `scripts/dev-prebuild.mjs` serializes the skills+core prebuild behind a lock and keeps `pnpm install` current; `pnpm dev` runs server+web together. - AgentHub 0.3.3 -> 0.4.0: OmniMessage complete payloads carry one opaque `fidelity` object in place of item-level `signature`/`phase`, threaded verbatim through Trace, replay and resume; malformed classification adapted to the new error types. - Model layer: a model is always referenced by an explicit `(provider, model_id)` pair. The provider is never inferred, guessed or defaulted -- both the catalog inference and the unique-match config resolution are gone, and CLI, SDK, server routes and run_subagent all require the complete pair. Catalog gains the Qwen Token Plan, Qwen Pay-As-You-Go and Fireworks AI gateways, plus an expanded OpenRouter group. - Web App: catalog preset sync and per-group speed test on the Models page, positional slash commands, a markdown renderer, skill-library update reminders, and a vertically centred draft page whose upward menus size themselves to the room available. - Public surfaces: restructured READMEs, the penguin.ooo landing site and blog, refreshed benchmark results for both suites, and the demo videos playing on the landing page. Includes the fixes from a full review of the branch: 23 confirmed findings, among them a provider-inference bug that could send one vendor's API key to another vendor's endpoint, and an Escape handler that destroyed the composer's contents unrecoverably. Verified on the branch head: pnpm test (1127 passing, 7 packages), pnpm typecheck and pnpm format:check clean, Playwright e2e 14/14.
144 lines
6.0 KiB
TypeScript
144 lines
6.0 KiB
TypeScript
/**
|
|
* Built-in agent provisioning and skill library install policy: the sole built-in agent
|
|
* default_agent comes pre-installed with every skill in the library, an ordinary newly created
|
|
* agent starts with zero skills, and the default AGENTS.md is an empty file; provisionProjectAgents
|
|
* is idempotent and never overwrites existing config.
|
|
*/
|
|
import fs from "node:fs/promises";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
import { librarySkill, loadLibrarySkills } from "@prismshadow/penguin-skills";
|
|
import {
|
|
agentsMdPath,
|
|
assembleSystemPrompt,
|
|
BUILTIN_AGENT_IDS,
|
|
DEFAULT_AGENT_ID,
|
|
DEFAULT_PROJECT_ID,
|
|
listInstalledSkills,
|
|
loadOrInitAgentState,
|
|
provisionProjectAgents,
|
|
skillsDir,
|
|
} from "../src/state/index.js";
|
|
|
|
let tmpRoot: string;
|
|
let prevHome: string | undefined;
|
|
|
|
beforeEach(async () => {
|
|
prevHome = process.env.PENGUIN_HOME;
|
|
tmpRoot = await fs.mkdtemp(path.join(os.tmpdir(), "penguin-builtin-"));
|
|
process.env.PENGUIN_HOME = tmpRoot;
|
|
});
|
|
|
|
afterEach(async () => {
|
|
if (prevHome === undefined) {
|
|
delete process.env.PENGUIN_HOME;
|
|
} else {
|
|
process.env.PENGUIN_HOME = prevHome;
|
|
}
|
|
await fs.rm(tmpRoot, { recursive: true, force: true });
|
|
});
|
|
|
|
const skillMdPath = (agentId: string, skillName: string): string =>
|
|
path.join(skillsDir(tmpRoot, DEFAULT_PROJECT_ID, agentId), skillName, "SKILL.md");
|
|
|
|
describe("Skill installation policy", () => {
|
|
it("a plain new Agent preinstalls no Skills and AGENTS.md is an empty file (guidance lives in the template's Suggested workflows)", async () => {
|
|
const state = await loadOrInitAgentState({ agentId: "some_agent" });
|
|
expect(await listInstalledSkills(tmpRoot, DEFAULT_PROJECT_ID, "some_agent")).toEqual([]);
|
|
|
|
// The default AGENTS.md is empty: it carries no preset guidance (delegation and task
|
|
// conventions live in the default template's Suggested workflows section, and skill
|
|
// metadata is injected via {{SKILL_METADATA}}).
|
|
expect(state.agentsMd).toBe("");
|
|
const onDisk = await fs.readFile(
|
|
agentsMdPath(tmpRoot, DEFAULT_PROJECT_ID, "some_agent"),
|
|
"utf8",
|
|
);
|
|
expect(onDisk).toBe("");
|
|
});
|
|
|
|
it("a default_agent created directly without a preset (e.g. first CLI run) likewise preinstalls every Skill in the library", async () => {
|
|
await loadOrInitAgentState({ agentId: DEFAULT_AGENT_ID });
|
|
const names = (await listInstalledSkills(tmpRoot, DEFAULT_PROJECT_ID, DEFAULT_AGENT_ID)).map(
|
|
(s) => s.name,
|
|
);
|
|
expect(names).toEqual(loadLibrarySkills().map((s) => s.name));
|
|
});
|
|
});
|
|
|
|
describe("provisionProjectAgents", () => {
|
|
it("the only built-in Agent default_agent: installs every Skill in the library, AGENTS.md is empty", async () => {
|
|
const ids = await provisionProjectAgents();
|
|
expect(ids).toEqual([DEFAULT_AGENT_ID]);
|
|
expect(BUILTIN_AGENT_IDS).toEqual([DEFAULT_AGENT_ID]);
|
|
|
|
// name/description are written into system_config; AGENTS.md is an empty file.
|
|
const state = await loadOrInitAgentState({ agentId: DEFAULT_AGENT_ID });
|
|
expect(state.systemConfig.name).toBe("General Agent");
|
|
expect(state.systemConfig.description).toBeTruthy();
|
|
expect(state.agentsMd).toBe("");
|
|
|
|
const installed = await listInstalledSkills(tmpRoot, DEFAULT_PROJECT_ID, DEFAULT_AGENT_ID);
|
|
expect(installed.map((s) => s.name).sort()).toEqual(loadLibrarySkills().map((s) => s.name));
|
|
// On-disk content matches the library's SKILL.md verbatim (install copies the full text).
|
|
const sdkMd = await fs.readFile(skillMdPath(DEFAULT_AGENT_ID, "penguin-sdk"), "utf8");
|
|
expect(sdkMd).toBe(librarySkill("penguin-sdk")!.content);
|
|
});
|
|
|
|
it("provision is idempotent: running it again does not change the result", async () => {
|
|
await provisionProjectAgents();
|
|
const ids = await provisionProjectAgents();
|
|
expect(ids).toEqual([DEFAULT_AGENT_ID]);
|
|
const md = await fs.readFile(
|
|
agentsMdPath(tmpRoot, DEFAULT_PROJECT_ID, DEFAULT_AGENT_ID),
|
|
"utf8",
|
|
);
|
|
expect(md).toBe("");
|
|
const installed = await listInstalledSkills(tmpRoot, DEFAULT_PROJECT_ID, DEFAULT_AGENT_ID);
|
|
expect(installed.map((s) => s.name).sort()).toEqual(loadLibrarySkills().map((s) => s.name));
|
|
});
|
|
|
|
it("an existing Agent is not overwritten (the preset only applies at initialization)", async () => {
|
|
const custom = "# AGENTS.md\n\nContent the user edited themselves\n";
|
|
await loadOrInitAgentState({ agentId: DEFAULT_AGENT_ID });
|
|
await fs.writeFile(agentsMdPath(tmpRoot, DEFAULT_PROJECT_ID, DEFAULT_AGENT_ID), custom, "utf8");
|
|
|
|
await provisionProjectAgents();
|
|
|
|
const after = await fs.readFile(
|
|
agentsMdPath(tmpRoot, DEFAULT_PROJECT_ID, DEFAULT_AGENT_ID),
|
|
"utf8",
|
|
);
|
|
expect(after).toBe(custom);
|
|
});
|
|
});
|
|
|
|
describe("Project Dir / Agent ID placeholders", () => {
|
|
it("assembleSystemPrompt injects Project Dir and Agent ID (Skill lookup uses project-relative paths, no .penguin dependency)", async () => {
|
|
const state = await loadOrInitAgentState({ agentId: "env_agent" });
|
|
const prompt = assembleSystemPrompt(state, {
|
|
sessionId: "session-x",
|
|
cwd: "/tmp/ws",
|
|
agentId: "env_agent",
|
|
projectDir: "/tmp/proj",
|
|
provider: "deepseek",
|
|
modelId: "deepseek-v4-pro",
|
|
platform: "linux",
|
|
osVersion: "test",
|
|
date: "2026-07-08",
|
|
});
|
|
expect(prompt).toContain("Agent ID: env_agent");
|
|
expect(prompt).toContain("Project Dir: /tmp/proj");
|
|
expect(prompt).not.toContain("{{AGENT_ID}}");
|
|
expect(prompt).not.toContain("{{PROJECT_DIR}}");
|
|
// Skill execution conventions are built from project-relative paths (no longer reference .penguin).
|
|
expect(prompt).not.toContain(".penguin");
|
|
// Agent State, scratchpad and Skills are addressed under the Project's agents/ container.
|
|
expect(prompt).toContain("<project_dir>/agents/<agent_id>/agent_state/");
|
|
expect(prompt).toContain("<project_dir>/agents/<agent_id>/agent_state/skills/");
|
|
// The pre-agents/ layout (an agent directly under the Project dir) must never be handed to the model.
|
|
expect(prompt).not.toContain("<project_dir>/<agent_id>/");
|
|
});
|
|
});
|