Skip to content

Commit baf0b1b

Browse files
committed
feat(cli): bundle the official skill as part of the CLI
1 parent 39df6c6 commit baf0b1b

4 files changed

Lines changed: 36 additions & 5 deletions

File tree

‎apps/cli/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://json.schemastore.org/package.json",
33
"name": "@karakeep/cli",
4-
"version": "0.33.1",
4+
"version": "0.33.2",
55
"description": "Command Line Interface (CLI) for Karakeep",
66
"license": "GNU Affero General Public License version 3",
77
"type": "module",
@@ -29,7 +29,7 @@
2929
"tsx": "^4.8.1",
3030
"vite": "^7.0.6",
3131
"vite-tsconfig-paths": "^6.1.1",
32-
"zod": "^4.0.0"
32+
"zod": "^4.2.0"
3333
},
3434
"scripts": {
3535
"build": "vite build && chmod +x dist/index.mjs",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Command } from "@commander-js/extra-typings";
2+
import { readFileSync } from "node:fs";
3+
4+
declare const __KARAKEEP_SKILL_CONTENT__: string;
5+
6+
const skillContent =
7+
typeof __KARAKEEP_SKILL_CONTENT__ === "string"
8+
? __KARAKEEP_SKILL_CONTENT__
9+
: readFileSync(
10+
new URL("../../../../skills/SKILL.md", import.meta.url),
11+
"utf8",
12+
);
13+
14+
export const skillCmd = new Command()
15+
.name("skill")
16+
.description("prints the official Karakeep agent skill")
17+
.action(() => {
18+
process.stdout.write(skillContent);
19+
});

‎apps/cli/src/index.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { dumpCmd } from "@/commands/dump";
66
import { highlightsCmd } from "@/commands/highlights";
77
import { listsCmd } from "@/commands/lists";
88
import { migrateCmd } from "@/commands/migrate";
9+
import { skillCmd } from "@/commands/skill";
910
import { tagsCmd } from "@/commands/tags";
1011
import { whoamiCmd } from "@/commands/whoami";
1112
import { wipeCmd } from "@/commands/wipe";
@@ -41,10 +42,13 @@ function resolveGlobalOptions(opts: RawGlobalOptions) {
4142
};
4243
}
4344

44-
function isAuthCommand(command: { name(): string; parent?: unknown }) {
45+
function doesNotRequireAuthentication(command: {
46+
name(): string;
47+
parent?: unknown;
48+
}) {
4549
let current: { name(): string; parent?: unknown } | undefined = command;
4650
while (current) {
47-
if (current.name() === "auth") {
51+
if (current.name() === "auth" || current.name() === "skill") {
4852
return true;
4953
}
5054
current = current.parent as typeof current;
@@ -79,14 +83,15 @@ program.addCommand(authCmd);
7983
program.addCommand(bookmarkCmd);
8084
program.addCommand(highlightsCmd);
8185
program.addCommand(listsCmd);
86+
program.addCommand(skillCmd);
8287
program.addCommand(tagsCmd);
8388
program.addCommand(whoamiCmd);
8489
program.addCommand(migrateCmd);
8590
program.addCommand(wipeCmd);
8691
program.addCommand(dumpCmd);
8792

8893
program.hook("preAction", (_thisCommand, actionCommand) => {
89-
if (isAuthCommand(actionCommand)) {
94+
if (doesNotRequireAuthentication(actionCommand)) {
9095
return;
9196
}
9297

‎apps/cli/vite.config.mts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
// This file is shamelessly copied from immich's CLI vite config
22
// https://github.com/immich-app/immich/blob/main/cli/vite.config.ts
3+
import { readFileSync } from "node:fs";
34
import { defineConfig } from "vite";
45
import tsconfigPaths from "vite-tsconfig-paths";
56

7+
const skillContent = readFileSync(
8+
new URL("../../skills/SKILL.md", import.meta.url),
9+
"utf8",
10+
);
11+
612
export default defineConfig({
713
build: {
814
rollupOptions: {
@@ -24,6 +30,7 @@ export default defineConfig({
2430
},
2531
plugins: [tsconfigPaths({ skip: (dir) => dir === ".claude" })],
2632
define: {
33+
__KARAKEEP_SKILL_CONTENT__: JSON.stringify(skillContent),
2734
"import.meta.env.CLI_VERSION": JSON.stringify(
2835
process.env.npm_package_version,
2936
),

0 commit comments

Comments
 (0)