mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
fix(skills): keep ClawHub search results on one line (#111441)
This commit is contained in:
@@ -394,6 +394,24 @@ describe("skills cli commands", () => {
|
||||
expect(runtimeLogs).toEqual(["legacy-calendar Legacy Calendar"]);
|
||||
});
|
||||
|
||||
it("keeps multiline ClawHub search metadata on one terminal line", async () => {
|
||||
searchSkillsFromClawHubMock.mockResolvedValue([
|
||||
{
|
||||
slug: "oauth-helper",
|
||||
ownerHandle: "demo-owner",
|
||||
displayName: "Oauth\nHelper",
|
||||
summary:
|
||||
"Automate OAuth login flows.\nSupports multiple providers.\n\nFeatures:\n- Confirm before authorizing",
|
||||
},
|
||||
]);
|
||||
|
||||
await runCommand(["skills", "search", "oauth-helper"]);
|
||||
|
||||
expect(runtimeLogs).toEqual([
|
||||
"@demo-owner/oauth-helper Oauth Helper Automate OAuth login flows. Supports multiple providers. Features: - Confirm before authorizing",
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps ClawHub skill search JSON output unchanged", async () => {
|
||||
const results = [
|
||||
{
|
||||
|
||||
+11
-4
@@ -5,6 +5,7 @@ import {
|
||||
GATEWAY_CLIENT_MODES,
|
||||
GATEWAY_CLIENT_NAMES,
|
||||
} from "../../packages/gateway-protocol/src/client-info.js";
|
||||
import { sanitizeForLog } from "../../packages/terminal-core/src/ansi.js";
|
||||
import { formatDocsLink } from "../../packages/terminal-core/src/links.js";
|
||||
import { theme } from "../../packages/terminal-core/src/theme.js";
|
||||
import {
|
||||
@@ -95,6 +96,10 @@ function formatSkillWarning(message: string): string {
|
||||
return message.includes("╭─") ? message : theme.warn(message);
|
||||
}
|
||||
|
||||
function formatClawHubSearchText(value: string): string {
|
||||
return sanitizeForLog(value.replace(/\s+/gu, " ")).trim();
|
||||
}
|
||||
|
||||
function isClawHubSkillBlockedCliFailure(result: { code?: string; warning?: string }): boolean {
|
||||
return (
|
||||
result.code === CLAWHUB_TRUST_ERROR_CODE.CLAWHUB_DOWNLOAD_BLOCKED &&
|
||||
@@ -431,10 +436,12 @@ export function registerSkillsCli(program: Command) {
|
||||
}
|
||||
for (const entry of results) {
|
||||
const ownerHandle = normalizeOptionalString(entry.ownerHandle);
|
||||
const skillRef = ownerHandle ? `@${ownerHandle}/${entry.slug}` : entry.slug;
|
||||
const version = entry.version ? ` v${entry.version}` : "";
|
||||
const summary = entry.summary ? ` ${entry.summary}` : "";
|
||||
defaultRuntime.log(`${skillRef}${version} ${entry.displayName}${summary}`);
|
||||
const slug = formatClawHubSearchText(entry.slug);
|
||||
const skillRef = ownerHandle ? `@${formatClawHubSearchText(ownerHandle)}/${slug}` : slug;
|
||||
const version = entry.version ? ` v${formatClawHubSearchText(entry.version)}` : "";
|
||||
const summary = entry.summary ? ` ${formatClawHubSearchText(entry.summary)}` : "";
|
||||
const displayName = formatClawHubSearchText(entry.displayName);
|
||||
defaultRuntime.log(`${skillRef}${version} ${displayName}${summary}`);
|
||||
}
|
||||
} catch (err) {
|
||||
defaultRuntime.error(String(err));
|
||||
|
||||
Reference in New Issue
Block a user