fix(skills): keep ClawHub search results on one line (#111441)

This commit is contained in:
mushuiyu886
2026-07-20 10:18:54 +08:00
committed by GitHub
parent c5bc6c3d2d
commit a20e08a56e
2 changed files with 29 additions and 4 deletions
+18
View File
@@ -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
View File
@@ -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));