diff --git a/README.md b/README.md index 2b54158..9f494ef 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Skills Vault -***[汉语](./README.zh.md)*** +**_[汉语](./README.zh.md)_** The CLI for backing up and restoring [Agent Skills](https://agentskills.io). diff --git a/README.zh.md b/README.zh.md index 7418c3f..0c67805 100644 --- a/README.zh.md +++ b/README.zh.md @@ -1,6 +1,6 @@ # Skills Vault -***[English](./README.md)*** +**_[English](./README.md)_** 用于备份和恢复 [Agent Skills](https://agentskills.io) 的 CLI。 diff --git a/src/commands/restore.ts b/src/commands/restore.ts index 634705d..7e84cc3 100644 --- a/src/commands/restore.ts +++ b/src/commands/restore.ts @@ -278,12 +278,16 @@ async function runRestoreFromManifest( appendLine(`[dry-run] ${preview}`); } - return { - exitCode: 0, - stdout: streamOutput ? (streamedOutput ? "\n" : "") : page(lines.join("\n")), - stderr: "", - payload: { - manifestPath, + return { + exitCode: 0, + stdout: streamOutput + ? streamedOutput + ? "\n" + : "" + : page(lines.join("\n")), + stderr: "", + payload: { + manifestPath, projectScope, dryRun: true, sourceCount: entries.length, @@ -413,7 +417,11 @@ async function runRestoreFromManifest( ) { return { exitCode: 1, - stdout: streamOutput ? (streamedOutput ? "\n" : "") : page(lines.join("\n")), + stdout: streamOutput + ? streamedOutput + ? "\n" + : "" + : page(lines.join("\n")), stderr: page( formatGlobalSkillStateMismatch(globalSkillStateDiff) .map((line) => errorMessage(line)) @@ -429,7 +437,11 @@ async function runRestoreFromManifest( ); return { exitCode: 0, - stdout: streamOutput ? (streamedOutput ? "\n" : "") : page(lines.join("\n")), + stdout: streamOutput + ? streamedOutput + ? "\n" + : "" + : page(lines.join("\n")), stderr: "", payload: { manifestPath, @@ -500,14 +512,13 @@ async function runRestoreFromManifest( const message = error instanceof Error ? error.message : String(error); return { exitCode: 1, - stdout: - streamOutput - ? streamedOutput - ? "\n" - : "" - : lines.length > 0 - ? page(lines.join("\n")) - : "", + stdout: streamOutput + ? streamedOutput + ? "\n" + : "" + : lines.length > 0 + ? page(lines.join("\n")) + : "", stderr: page([...errors, errorMessage(message)].join("\n")), errorCode: resolveRestoreErrorCode(message), }; @@ -528,18 +539,19 @@ async function runRestoreFromManifest( ), ); errors.push( - errorMessage(`Completed restore with ${failures.length} source failure(s).`), + errorMessage( + `Completed restore with ${failures.length} source failure(s).`, + ), ); return { exitCode: 0, - stdout: - streamOutput - ? streamedOutput - ? "\n" - : "" - : lines.length > 0 - ? page(lines.join("\n")) - : "", + stdout: streamOutput + ? streamedOutput + ? "\n" + : "" + : lines.length > 0 + ? page(lines.join("\n")) + : "", stderr: page(errors.join("\n")), payload: { manifestPath, @@ -563,14 +575,13 @@ async function runRestoreFromManifest( ) { return { exitCode: 1, - stdout: - streamOutput - ? streamedOutput - ? "\n" - : "" - : lines.length > 0 - ? page(lines.join("\n")) - : "", + stdout: streamOutput + ? streamedOutput + ? "\n" + : "" + : lines.length > 0 + ? page(lines.join("\n")) + : "", stderr: page( formatGlobalSkillStateMismatch(globalSkillStateDiff) .map((line) => errorMessage(line)) @@ -591,14 +602,13 @@ async function runRestoreFromManifest( ); return { exitCode: 0, - stdout: - streamOutput - ? streamedOutput - ? "\n" - : "" - : lines.length > 0 - ? page(lines.join("\n")) - : "", + stdout: streamOutput + ? streamedOutput + ? "\n" + : "" + : lines.length > 0 + ? page(lines.join("\n")) + : "", stderr: errors.length > 0 ? page(errors.join("\n")) : "", payload: { manifestPath, diff --git a/src/internal/cli/theme.ts b/src/internal/cli/theme.ts index 03a5ed6..1d56d4d 100644 --- a/src/internal/cli/theme.ts +++ b/src/internal/cli/theme.ts @@ -86,15 +86,17 @@ export function commandErrorPage( usage: string, example: string, ): string { - return page([ - `${errorBadge("ERROR")} ${red(message)}`, - "", - dim(" Usage:"), - ` ${usage}`, - "", - dim(" Example:"), - ` ${example}`, - ].join("\n")); + return page( + [ + `${errorBadge("ERROR")} ${red(message)}`, + "", + dim(" Usage:"), + ` ${usage}`, + "", + dim(" Example:"), + ` ${example}`, + ].join("\n"), + ); } export function infoLine(text: string): string { diff --git a/test/backup.test.ts b/test/backup.test.ts index eb8e771..767b118 100644 --- a/test/backup.test.ts +++ b/test/backup.test.ts @@ -192,9 +192,11 @@ test("shows help before project-scope validation", async () => { expect(plainStdout).toContain( "\n\nExplore the open-source repo at https://github.com/xixu-me/skills-vault", ); - expect(plainStdout.endsWith( - "Explore the open-source repo at https://github.com/xixu-me/skills-vault\n\n", - )).toBe(true); + expect( + plainStdout.endsWith( + "Explore the open-source repo at https://github.com/xixu-me/skills-vault\n\n", + ), + ).toBe(true); expect(result.stdout).toContain( "Explore the open-source repo at https://github.com/xixu-me/skills-vault", ); diff --git a/test/cli.test.ts b/test/cli.test.ts index c67fcc3..d4f06b5 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -82,9 +82,11 @@ test("prints top-level help", async () => { expect(plainStdout).toContain( "\n\nExplore the open-source repo at https://github.com/xixu-me/skills-vault", ); - expect(plainStdout.endsWith( - "Explore the open-source repo at https://github.com/xixu-me/skills-vault\n\n", - )).toBe(true); + expect( + plainStdout.endsWith( + "Explore the open-source repo at https://github.com/xixu-me/skills-vault\n\n", + ), + ).toBe(true); expect(result.stdout).toContain( "Explore the open-source repo at https://github.com/xixu-me/skills-vault", ); @@ -176,7 +178,9 @@ test("uses process argv when invoked like the CLI", async () => { expect(plainStdout).toContain( "The CLI for backing up and restoring Agent Skills", ); - expect(plainStdout).toContain("Explore the open-source repo at https://github.com/xixu-me/skills-vault"); + expect(plainStdout).toContain( + "Explore the open-source repo at https://github.com/xixu-me/skills-vault", + ); expect(plainStdout).not.toContain("try:"); expect(stdoutText).toContain("\x1b[38;5;102m"); expect(stdoutText).toContain("\x1b[38;5;145m"); @@ -205,9 +209,11 @@ test("shows a landing page when no command is provided", async () => { expect(plainStdout).toContain( "\n\nExplore the open-source repo at https://github.com/xixu-me/skills-vault", ); - expect(plainStdout.endsWith( - "Explore the open-source repo at https://github.com/xixu-me/skills-vault\n\n", - )).toBe(true); + expect( + plainStdout.endsWith( + "Explore the open-source repo at https://github.com/xixu-me/skills-vault\n\n", + ), + ).toBe(true); expect(result.stdout).toContain("\x1b[38;5;102m"); expect(result.stdout).toContain("\x1b[38;5;145m"); expect(result.stdout).not.toContain("\x1b[36m"); diff --git a/test/completion.test.ts b/test/completion.test.ts index f2937aa..472f90c 100644 --- a/test/completion.test.ts +++ b/test/completion.test.ts @@ -17,9 +17,11 @@ test("shows completion help text", async () => { expect(plainStdout).toContain( "\n\nExplore the open-source repo at https://github.com/xixu-me/skills-vault", ); - expect(plainStdout.endsWith( - "Explore the open-source repo at https://github.com/xixu-me/skills-vault\n\n", - )).toBe(true); + expect( + plainStdout.endsWith( + "Explore the open-source repo at https://github.com/xixu-me/skills-vault\n\n", + ), + ).toBe(true); expect(result.stdout).toContain( "Explore the open-source repo at https://github.com/xixu-me/skills-vault", ); diff --git a/test/doctor.test.ts b/test/doctor.test.ts index 672da63..643865b 100644 --- a/test/doctor.test.ts +++ b/test/doctor.test.ts @@ -18,9 +18,11 @@ test("shows doctor help text", async () => { expect(plainStdout).toContain( "\n\nExplore the open-source repo at https://github.com/xixu-me/skills-vault", ); - expect(plainStdout.endsWith( - "Explore the open-source repo at https://github.com/xixu-me/skills-vault\n\n", - )).toBe(true); + expect( + plainStdout.endsWith( + "Explore the open-source repo at https://github.com/xixu-me/skills-vault\n\n", + ), + ).toBe(true); expect(result.stdout).toContain( "Explore the open-source repo at https://github.com/xixu-me/skills-vault", ); diff --git a/test/restore.test.ts b/test/restore.test.ts index 7a956af..e22d979 100644 --- a/test/restore.test.ts +++ b/test/restore.test.ts @@ -35,9 +35,11 @@ test("shows restore help text", async () => { expect(plainStdout).toContain( "\n\nExplore the open-source repo at https://github.com/xixu-me/skills-vault", ); - expect(plainStdout.endsWith( - "Explore the open-source repo at https://github.com/xixu-me/skills-vault\n\n", - )).toBe(true); + expect( + plainStdout.endsWith( + "Explore the open-source repo at https://github.com/xixu-me/skills-vault\n\n", + ), + ).toBe(true); expect(result.stdout).toContain( `Global restore verifies ${defaultGlobalSkillsPath} against ${defaultGlobalLockFilePath}`, );