mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-20 21:23:23 +00:00
test: debrand plumbing labels and restore skill compat
This commit is contained in:
@@ -56,7 +56,7 @@ describe("compaction retry integration", () => {
|
||||
} as unknown as NonNullable<ExtensionContext["model"]>;
|
||||
|
||||
const invokeGenerateSummary = (signal = new AbortController().signal) =>
|
||||
mockGenerateSummary(testMessages, testModel, 1000, "test-api-key", undefined, signal);
|
||||
mockGenerateSummary(testMessages, testModel, 1000, "test-api-key", signal);
|
||||
|
||||
const runSummaryRetry = (options: Parameters<typeof retryAsync>[1]) =>
|
||||
retryAsync(() => invokeGenerateSummary(), options);
|
||||
|
||||
@@ -257,7 +257,6 @@ async function summarizeChunks(params: {
|
||||
model,
|
||||
params.reserveTokens,
|
||||
params.apiKey,
|
||||
params.headers,
|
||||
params.signal,
|
||||
effectiveInstructions,
|
||||
summary,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { createSyntheticSourceInfo } from "@mariozechner/pi-coding-agent";
|
||||
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { installDownloadSpec } from "./skills-install-download.js";
|
||||
import { setTempStateDir } from "./skills-install.download-test-utils.js";
|
||||
@@ -61,9 +60,7 @@ function buildEntry(name: string): SkillEntry {
|
||||
description: `${name} test skill`,
|
||||
filePath: path.join(skillDir, "SKILL.md"),
|
||||
baseDir: skillDir,
|
||||
sourceInfo: createSyntheticSourceInfo(path.join(skillDir, "SKILL.md"), {
|
||||
source: "openclaw-workspace",
|
||||
}),
|
||||
source: "openclaw-workspace",
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createSyntheticSourceInfo } from "@mariozechner/pi-coding-agent";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildWorkspaceSkillStatus } from "./skills-status.js";
|
||||
import type { SkillEntry } from "./skills/types.js";
|
||||
@@ -18,7 +17,7 @@ describe("buildWorkspaceSkillStatus", () => {
|
||||
description: "test",
|
||||
filePath: "/tmp/os-scoped",
|
||||
baseDir: "/tmp",
|
||||
sourceInfo: createSyntheticSourceInfo("/tmp/os-scoped", { source: "test" }),
|
||||
source: "test",
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createSyntheticSourceInfo } from "@mariozechner/pi-coding-agent";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { withEnv } from "../test-utils/env.js";
|
||||
import { buildWorkspaceSkillStatus } from "./skills-status.js";
|
||||
@@ -25,9 +24,7 @@ function makeEntry(params: {
|
||||
description: `desc:${params.name}`,
|
||||
filePath: `/tmp/${params.name}/SKILL.md`,
|
||||
baseDir: `/tmp/${params.name}`,
|
||||
sourceInfo: createSyntheticSourceInfo(`/tmp/${params.name}/SKILL.md`, {
|
||||
source: params.source ?? "openclaw-workspace",
|
||||
}),
|
||||
source: params.source ?? "openclaw-workspace",
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createSyntheticSourceInfo } from "@mariozechner/pi-coding-agent";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveSkillsPromptForRun } from "./skills.js";
|
||||
import type { SkillEntry } from "./skills/types.js";
|
||||
@@ -18,9 +17,7 @@ describe("resolveSkillsPromptForRun", () => {
|
||||
description: "Demo",
|
||||
filePath: "/app/skills/demo-skill/SKILL.md",
|
||||
baseDir: "/app/skills/demo-skill",
|
||||
sourceInfo: createSyntheticSourceInfo("/app/skills/demo-skill/SKILL.md", {
|
||||
source: "openclaw-bundled",
|
||||
}),
|
||||
source: "openclaw-bundled",
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import os from "node:os";
|
||||
import {
|
||||
createSyntheticSourceInfo,
|
||||
formatSkillsForPrompt,
|
||||
type Skill,
|
||||
} from "@mariozechner/pi-coding-agent";
|
||||
import { formatSkillsForPrompt, type Skill } from "@mariozechner/pi-coding-agent";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import type { SkillEntry } from "./types.js";
|
||||
@@ -19,7 +15,7 @@ function makeSkill(name: string, desc = "A skill", filePath = `/skills/${name}/S
|
||||
description: desc,
|
||||
filePath,
|
||||
baseDir: `/skills/${name}`,
|
||||
sourceInfo: createSyntheticSourceInfo(filePath, { source: "workspace" }),
|
||||
source: "workspace",
|
||||
disableModelInvocation: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Skill } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
export function resolveSkillSource(skill: Skill): string {
|
||||
return skill.sourceInfo?.source ?? "unknown";
|
||||
return skill.source ?? "unknown";
|
||||
}
|
||||
|
||||
@@ -105,10 +105,10 @@ describe("summarizeMapping", () => {
|
||||
exit: vi.fn(),
|
||||
};
|
||||
|
||||
summarizeMapping("discord allowlist", ["a", "b", "c", "d", "e", "f", "g"], ["x", "y"], runtime);
|
||||
summarizeMapping("demo allowlist", ["a", "b", "c", "d", "e", "f", "g"], ["x", "y"], runtime);
|
||||
|
||||
expect(runtime.log).toHaveBeenCalledWith(
|
||||
"discord allowlist resolved: a, b, c, d, e, f (+1)\ndiscord allowlist unresolved: x, y",
|
||||
"demo allowlist resolved: a, b, c, d, e, f (+1)\ndemo allowlist unresolved: x, y",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -119,7 +119,7 @@ describe("summarizeMapping", () => {
|
||||
exit: vi.fn(),
|
||||
};
|
||||
|
||||
summarizeMapping("discord allowlist", [], [], runtime);
|
||||
summarizeMapping("demo allowlist", [], [], runtime);
|
||||
|
||||
expect(runtime.log).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -5,11 +5,11 @@ describe("resolveMessageSecretScope", () => {
|
||||
it("prefers explicit channel/account inputs", () => {
|
||||
expect(
|
||||
resolveMessageSecretScope({
|
||||
channel: "Discord",
|
||||
channel: "Signal",
|
||||
accountId: "Ops",
|
||||
}),
|
||||
).toEqual({
|
||||
channel: "discord",
|
||||
channel: "signal",
|
||||
accountId: "ops",
|
||||
});
|
||||
});
|
||||
@@ -17,27 +17,27 @@ describe("resolveMessageSecretScope", () => {
|
||||
it("infers channel from a prefixed target", () => {
|
||||
expect(
|
||||
resolveMessageSecretScope({
|
||||
target: "telegram:12345",
|
||||
target: "signal:12345",
|
||||
}),
|
||||
).toEqual({
|
||||
channel: "telegram",
|
||||
channel: "signal",
|
||||
});
|
||||
});
|
||||
|
||||
it("infers a shared channel from target arrays", () => {
|
||||
expect(
|
||||
resolveMessageSecretScope({
|
||||
targets: ["discord:one", "discord:two"],
|
||||
targets: ["signal:one", "signal:two"],
|
||||
}),
|
||||
).toEqual({
|
||||
channel: "discord",
|
||||
channel: "signal",
|
||||
});
|
||||
});
|
||||
|
||||
it("does not infer a channel when target arrays mix channels", () => {
|
||||
expect(
|
||||
resolveMessageSecretScope({
|
||||
targets: ["discord:one", "slack:two"],
|
||||
targets: ["signal:one", "imessage:two"],
|
||||
}),
|
||||
).toEqual({});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { createSyntheticSourceInfo } from "@mariozechner/pi-coding-agent";
|
||||
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
||||
import { buildWorkspaceSkillStatus } from "../agents/skills-status.js";
|
||||
import type { SkillEntry } from "../agents/skills.js";
|
||||
@@ -39,9 +38,7 @@ describe("skills-cli (e2e)", () => {
|
||||
description: "Capture UI screenshots",
|
||||
filePath: path.join(baseDir, "SKILL.md"),
|
||||
baseDir,
|
||||
sourceInfo: createSyntheticSourceInfo(path.join(baseDir, "SKILL.md"), {
|
||||
source: "openclaw-bundled",
|
||||
}),
|
||||
source: "openclaw-bundled",
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
||||
@@ -54,12 +54,12 @@ describe("diagnostic session state pruning", () => {
|
||||
it("reuses keyed session state when later looked up by sessionId", () => {
|
||||
const keyed = getDiagnosticSessionState({
|
||||
sessionId: "s1",
|
||||
sessionKey: "agent:main:discord:channel:c1",
|
||||
sessionKey: "agent:main:demo-channel:channel:c1",
|
||||
});
|
||||
const bySessionId = getDiagnosticSessionState({ sessionId: "s1" });
|
||||
|
||||
expect(bySessionId).toBe(keyed);
|
||||
expect(bySessionId.sessionKey).toBe("agent:main:discord:channel:c1");
|
||||
expect(bySessionId.sessionKey).toBe("agent:main:demo-channel:channel:c1");
|
||||
expect(getDiagnosticSessionStateCountForTest()).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user