mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-29 19:01:44 +00:00
fix(ci): align skills api drift and tui keybindings
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", signal);
|
||||
mockGenerateSummary(testMessages, testModel, 1000, "test-api-key", undefined, signal);
|
||||
|
||||
const runSummaryRetry = (options: Parameters<typeof retryAsync>[1]) =>
|
||||
retryAsync(() => invokeGenerateSummary(), options);
|
||||
|
||||
@@ -208,22 +208,6 @@ export function isOversizedForSummary(msg: AgentMessage, contextWindow: number):
|
||||
return tokens > contextWindow * 0.5;
|
||||
}
|
||||
|
||||
function withSummaryHeaders(
|
||||
model: NonNullable<ExtensionContext["model"]>,
|
||||
headers?: Record<string, string>,
|
||||
): NonNullable<ExtensionContext["model"]> {
|
||||
if (!headers || Object.keys(headers).length === 0) {
|
||||
return model;
|
||||
}
|
||||
return {
|
||||
...model,
|
||||
headers: {
|
||||
...model.headers,
|
||||
...headers,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async function summarizeChunks(params: {
|
||||
messages: AgentMessage[];
|
||||
model: NonNullable<ExtensionContext["model"]>;
|
||||
@@ -248,15 +232,22 @@ async function summarizeChunks(params: {
|
||||
params.customInstructions,
|
||||
params.summarizationInstructions,
|
||||
);
|
||||
const model = withSummaryHeaders(params.model, params.headers);
|
||||
const headers =
|
||||
params.headers || params.model.headers
|
||||
? {
|
||||
...params.model.headers,
|
||||
...params.headers,
|
||||
}
|
||||
: undefined;
|
||||
for (const chunk of chunks) {
|
||||
summary = await retryAsync(
|
||||
() =>
|
||||
generateSummary(
|
||||
chunk,
|
||||
model,
|
||||
params.model,
|
||||
params.reserveTokens,
|
||||
params.apiKey,
|
||||
headers,
|
||||
params.signal,
|
||||
effectiveInstructions,
|
||||
summary,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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";
|
||||
@@ -60,7 +61,10 @@ function buildEntry(name: string): SkillEntry {
|
||||
description: `${name} test skill`,
|
||||
filePath: path.join(skillDir, "SKILL.md"),
|
||||
baseDir: skillDir,
|
||||
source: "openclaw-workspace",
|
||||
sourceInfo: createSyntheticSourceInfo(path.join(skillDir, "SKILL.md"), {
|
||||
source: "openclaw-workspace",
|
||||
baseDir: skillDir,
|
||||
}),
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
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";
|
||||
@@ -17,7 +18,10 @@ describe("buildWorkspaceSkillStatus", () => {
|
||||
description: "test",
|
||||
filePath: "/tmp/os-scoped",
|
||||
baseDir: "/tmp",
|
||||
source: "test",
|
||||
sourceInfo: createSyntheticSourceInfo("/tmp/os-scoped", {
|
||||
source: "test",
|
||||
baseDir: "/tmp",
|
||||
}),
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
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";
|
||||
@@ -24,7 +25,10 @@ function makeEntry(params: {
|
||||
description: `desc:${params.name}`,
|
||||
filePath: `/tmp/${params.name}/SKILL.md`,
|
||||
baseDir: `/tmp/${params.name}`,
|
||||
source: params.source ?? "openclaw-workspace",
|
||||
sourceInfo: createSyntheticSourceInfo(`/tmp/${params.name}/SKILL.md`, {
|
||||
source: params.source ?? "openclaw-workspace",
|
||||
baseDir: `/tmp/${params.name}`,
|
||||
}),
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
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";
|
||||
@@ -17,7 +18,10 @@ describe("resolveSkillsPromptForRun", () => {
|
||||
description: "Demo",
|
||||
filePath: "/app/skills/demo-skill/SKILL.md",
|
||||
baseDir: "/app/skills/demo-skill",
|
||||
source: "openclaw-bundled",
|
||||
sourceInfo: createSyntheticSourceInfo("/app/skills/demo-skill/SKILL.md", {
|
||||
source: "openclaw-bundled",
|
||||
baseDir: "/app/skills/demo-skill",
|
||||
}),
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import os from "node:os";
|
||||
import { formatSkillsForPrompt, type Skill } from "@mariozechner/pi-coding-agent";
|
||||
import {
|
||||
createSyntheticSourceInfo,
|
||||
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";
|
||||
@@ -15,7 +19,10 @@ function makeSkill(name: string, desc = "A skill", filePath = `/skills/${name}/S
|
||||
description: desc,
|
||||
filePath,
|
||||
baseDir: `/skills/${name}`,
|
||||
source: "workspace",
|
||||
sourceInfo: createSyntheticSourceInfo(filePath, {
|
||||
source: "workspace",
|
||||
baseDir: `/skills/${name}`,
|
||||
}),
|
||||
disableModelInvocation: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Skill } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
export function resolveSkillSource(skill: Skill): string {
|
||||
return skill.source ?? "unknown";
|
||||
return skill.sourceInfo.source ?? "unknown";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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";
|
||||
@@ -38,7 +39,10 @@ describe("skills-cli (e2e)", () => {
|
||||
description: "Capture UI screenshots",
|
||||
filePath: path.join(baseDir, "SKILL.md"),
|
||||
baseDir,
|
||||
source: "openclaw-bundled",
|
||||
sourceInfo: createSyntheticSourceInfo(path.join(baseDir, "SKILL.md"), {
|
||||
source: "openclaw-bundled",
|
||||
baseDir,
|
||||
}),
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Component } from "@mariozechner/pi-tui";
|
||||
import {
|
||||
getEditorKeybindings,
|
||||
getKeybindings,
|
||||
Input,
|
||||
matchesKey,
|
||||
type SelectItem,
|
||||
@@ -110,8 +110,8 @@ export class FilterableSelectList implements Component {
|
||||
}
|
||||
|
||||
// Escape: clear filter or cancel
|
||||
const keybindings = getEditorKeybindings();
|
||||
if (keybindings.matches(keyData, "selectCancel")) {
|
||||
const keybindings = getKeybindings();
|
||||
if (keybindings.matches(keyData, "tui.select.cancel")) {
|
||||
if (this.filterText) {
|
||||
this.filterText = "";
|
||||
this.input.setValue("");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
type Component,
|
||||
getEditorKeybindings,
|
||||
getKeybindings,
|
||||
Input,
|
||||
isKeyRelease,
|
||||
matchesKey,
|
||||
@@ -362,8 +362,8 @@ export class SearchableSelectList implements Component {
|
||||
return;
|
||||
}
|
||||
|
||||
const keybindings = getEditorKeybindings();
|
||||
if (keybindings.matches(keyData, "selectCancel")) {
|
||||
const keybindings = getKeybindings();
|
||||
if (keybindings.matches(keyData, "tui.select.cancel")) {
|
||||
if (this.onCancel) {
|
||||
this.onCancel();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user