feat(core): reserved-port and API-key guardrails in the default system prompt (#24)

Co-authored-by: Alice <alice@prismshadow.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
authored and GitHub committed 2026-07-22 22:04:30 +08:00
1 parent 849f2fa6d2
commit c9cd1f9dc5
10 files changed
+47 -5

No files matched your search

+16
View File
@@ -315,6 +315,22 @@ describe("assembleSystemPrompt", () => {
expect(prompt).not.toContain(DATE_PLACEHOLDER);
});
it("default prompt carries the port and API-key guardrails", async () => {
const state = await loadOrInitAgentState();
const prompt = assembleSystemPrompt(state);
// Ports: never kill listeners or take PenguinHarness service ports; numbers are deliberately not listed.
expect(prompt).toContain("pick another free port");
expect(prompt).toContain("PenguinHarness service port");
expect(prompt).not.toContain("7364");
// Auth/key failures: retry at most once (Constraints), then stop and ask the user to update
// the key outside the chat (Stop rules) — no CLI commands, no secret values in the conversation.
expect(prompt).toContain("retry at most once");
expect(prompt).toContain("stop calling tools");
expect(prompt).toContain("never be pasted into the conversation");
expect(prompt).toContain("next conversation");
expect(prompt).not.toContain("penguin config vault set");
});
it("replaces AGENTS.md and specific Session environment fields at template locations", () => {
const state = {
root: tmpRoot,