Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

feat(cli): bundle the official skill as part of the CLI

Mohamed Bassembaf0b1bbe3a6
diff --git a/apps/cli/package.json b/apps/cli/package.json
index b7f9ac82..f97567d9 100644
--- a/apps/cli/package.json
+++ b/apps/cli/package.json
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@karakeep/cli",
- "version": "0.33.1",
+ "version": "0.33.2",
"description": "Command Line Interface (CLI) for Karakeep",
"license": "GNU Affero General Public License version 3",
"type": "module",
@@ -29,7 +29,7 @@
"tsx": "^4.8.1",
"vite": "^7.0.6",
"vite-tsconfig-paths": "^6.1.1",
- "zod": "^4.0.0"
+ "zod": "^4.2.0"
},
"scripts": {
"build": "vite build && chmod +x dist/index.mjs",
diff --git a/apps/cli/src/commands/skill.ts b/apps/cli/src/commands/skill.ts
new file mode 100644
index 00000000..94ed6d0d
--- /dev/null
+++ b/apps/cli/src/commands/skill.ts
@@ -0,0 +1,19 @@
+import { Command } from "@commander-js/extra-typings";
+import { readFileSync } from "node:fs";
+
+declare const __KARAKEEP_SKILL_CONTENT__: string;
+
+const skillContent =
+ typeof __KARAKEEP_SKILL_CONTENT__ === "string"
+ ? __KARAKEEP_SKILL_CONTENT__
+ : readFileSync(
+ new URL("../../../../skills/SKILL.md", import.meta.url),
+ "utf8",
+ );
+
+export const skillCmd = new Command()
+ .name("skill")
+ .description("prints the official Karakeep agent skill")
+ .action(() => {
+ process.stdout.write(skillContent);
+ });
diff --git a/apps/cli/src/index.ts b/apps/cli/src/index.ts
index 10b2ef41..e82a21fd 100644
--- a/apps/cli/src/index.ts
+++ b/apps/cli/src/index.ts
@@ -6,6 +6,7 @@ import { dumpCmd } from "@/commands/dump";
import { highlightsCmd } from "@/commands/highlights";
import { listsCmd } from "@/commands/lists";
import { migrateCmd } from "@/commands/migrate";
+import { skillCmd } from "@/commands/skill";
import { tagsCmd } from "@/commands/tags";
import { whoamiCmd } from "@/commands/whoami";
import { wipeCmd } from "@/commands/wipe";
@@ -41,10 +42,13 @@ function resolveGlobalOptions(opts: RawGlobalOptions) {
};
}
-function isAuthCommand(command: { name(): string; parent?: unknown }) {
+function doesNotRequireAuthentication(command: {
+ name(): string;
+ parent?: unknown;
+}) {
let current: { name(): string; parent?: unknown } | undefined = command;
while (current) {
- if (current.name() === "auth") {
+ if (current.name() === "auth" || current.name() === "skill") {
return true;
}
current = current.parent as typeof current;
@@ -79,6 +83,7 @@ program.addCommand(authCmd);
program.addCommand(bookmarkCmd);
program.addCommand(highlightsCmd);
program.addCommand(listsCmd);
+program.addCommand(skillCmd);
program.addCommand(tagsCmd);
program.addCommand(whoamiCmd);
program.addCommand(migrateCmd);
@@ -86,7 +91,7 @@ program.addCommand(wipeCmd);
program.addCommand(dumpCmd);
program.hook("preAction", (_thisCommand, actionCommand) => {
- if (isAuthCommand(actionCommand)) {
+ if (doesNotRequireAuthentication(actionCommand)) {
return;
}
diff --git a/apps/cli/vite.config.mts b/apps/cli/vite.config.mts
index 400e41f4..5408aaea 100644
--- a/apps/cli/vite.config.mts
+++ b/apps/cli/vite.config.mts
@@ -1,8 +1,14 @@
// This file is shamelessly copied from immich's CLI vite config
// https://github.com/immich-app/immich/blob/main/cli/vite.config.ts
+import { readFileSync } from "node:fs";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
+const skillContent = readFileSync(
+ new URL("../../skills/SKILL.md", import.meta.url),
+ "utf8",
+);
+
export default defineConfig({
build: {
rollupOptions: {
@@ -24,6 +30,7 @@ export default defineConfig({
},
plugins: [tsconfigPaths({ skip: (dir) => dir === ".claude" })],
define: {
+ __KARAKEEP_SKILL_CONTENT__: JSON.stringify(skillContent),
"import.meta.env.CLI_VERSION": JSON.stringify(
process.env.npm_package_version,
),