@2kw/ai 6.1.0 → 6.2.0-dev.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,6 +20,29 @@ export function makeConversationsCommand() {
20
20
  formatDetail(data, command);
21
21
  });
22
22
  });
23
+ cmd
24
+ .command("list")
25
+ .description("List conversations, most recently active first")
26
+ .option("--agent-id <id>", "Only conversations bound to this agent")
27
+ .option("--scope <scope>", "mine (default) or org; org needs MEMBER or above", "mine")
28
+ .option("--page <n>", "Page number, starting at 0", "0")
29
+ .option("--size <n>", "Page size, 1 to 100", "30")
30
+ .action(async (opts, command) => {
31
+ await runAction(command, async () => {
32
+ const client = getClient(command);
33
+ const { data } = await client.GET("/v1/conversations", {
34
+ params: {
35
+ query: {
36
+ agent_id: opts.agentId,
37
+ scope: opts.scope,
38
+ page: Number(opts.page),
39
+ size: Number(opts.size),
40
+ },
41
+ },
42
+ });
43
+ formatDetail(data, command);
44
+ });
45
+ });
23
46
  cmd
24
47
  .command("get")
25
48
  .description("Retrieve a conversation by id")
@@ -0,0 +1,4 @@
1
+ import { Command } from "commander";
2
+ /** Install, sync and detach Claude Code plugins (#640). */
3
+ export declare function makePluginsCommand(): Command;
4
+ //# sourceMappingURL=plugins.d.ts.map
@@ -0,0 +1,88 @@
1
+ import { Command, Option } from "commander";
2
+ import { getClient, runAction } from "../lib/client.js";
3
+ import { formatPage, formatDetail, formatSuccess } from "../lib/output.js";
4
+ import { addPaginationOptions, paginationParams } from "../lib/pagination.js";
5
+ const REF_POLICY_HELP = "track:<branch-or-tag> to follow it, pin:<sha> to freeze";
6
+ /** Install, sync and detach Claude Code plugins (#640). */
7
+ export function makePluginsCommand() {
8
+ const cmd = new Command("plugins").description("Manage Claude Code plugins imported from git");
9
+ const list = new Command("list").description("List installed plugins");
10
+ addPaginationOptions(list);
11
+ list.addOption(new Option("--status <status>", "Filter by status").choices(["ACTIVE", "DISABLED"]));
12
+ list.action(async (opts, command) => {
13
+ await runAction(command, async () => {
14
+ const client = getClient(command);
15
+ const { data } = await client.GET("/v1/plugins", {
16
+ params: { query: { status: opts.status, ...paginationParams(opts) } },
17
+ });
18
+ formatPage(data, command, ["id", "name", "gitUrl", "refPolicy", "status", "lastSyncedSha"]);
19
+ });
20
+ });
21
+ cmd.addCommand(list);
22
+ cmd
23
+ .command("get")
24
+ .description("Get an installed plugin, including its last sync report")
25
+ .argument("<id>", "Plugin ID")
26
+ .action(async (id, _opts, command) => {
27
+ await runAction(command, async () => {
28
+ const client = getClient(command);
29
+ const { data } = await client.GET("/v1/plugins/{id}", { params: { path: { id } } });
30
+ formatDetail(data, command);
31
+ });
32
+ });
33
+ cmd
34
+ .command("install")
35
+ .description("Install a plugin from a git repository and run its first sync (admin)")
36
+ .argument("<git-url>", "https remote of a repository in Claude Code plugin layout")
37
+ .option("-n, --name <name>", "Org-local name (default: the manifest name, slugified)")
38
+ .option("--ref-policy <policy>", REF_POLICY_HELP)
39
+ .action(async (gitUrl, opts, command) => {
40
+ await runAction(command, async () => {
41
+ const client = getClient(command);
42
+ const { data } = await client.POST("/v1/plugins", {
43
+ body: { gitUrl, name: opts.name, refPolicy: opts.refPolicy },
44
+ });
45
+ formatDetail(data, command);
46
+ });
47
+ });
48
+ cmd
49
+ .command("update")
50
+ .description("Change a plugin's ref policy or status (admin)")
51
+ .argument("<id>", "Plugin ID")
52
+ .option("--ref-policy <policy>", REF_POLICY_HELP)
53
+ .addOption(new Option("--status <status>", "ACTIVE or DISABLED").choices(["ACTIVE", "DISABLED"]))
54
+ .action(async (id, opts, command) => {
55
+ await runAction(command, async () => {
56
+ const client = getClient(command);
57
+ const { data } = await client.PATCH("/v1/plugins/{id}", {
58
+ params: { path: { id } },
59
+ body: { refPolicy: opts.refPolicy, status: opts.status },
60
+ });
61
+ formatDetail(data, command);
62
+ });
63
+ });
64
+ cmd
65
+ .command("sync")
66
+ .description("Sync a plugin now; unchanged is a no-op (admin)")
67
+ .argument("<id>", "Plugin ID")
68
+ .action(async (id, _opts, command) => {
69
+ await runAction(command, async () => {
70
+ const client = getClient(command);
71
+ const { data } = await client.POST("/v1/plugins/{id}/sync", { params: { path: { id } } });
72
+ formatDetail(data, command);
73
+ });
74
+ });
75
+ cmd
76
+ .command("delete")
77
+ .description("Detach a plugin; imported skills stay (admin)")
78
+ .argument("<id>", "Plugin ID")
79
+ .action(async (id, _opts, command) => {
80
+ await runAction(command, async () => {
81
+ const client = getClient(command);
82
+ await client.DELETE("/v1/plugins/{id}", { params: { path: { id } } });
83
+ formatSuccess(`Plugin ${id} detached`, command);
84
+ });
85
+ });
86
+ return cmd;
87
+ }
88
+ //# sourceMappingURL=plugins.js.map
@@ -0,0 +1,4 @@
1
+ import { Command } from "commander";
2
+ /** Manage skill labels (#642). */
3
+ export declare function makeSkillLabelsCommand(): Command;
4
+ //# sourceMappingURL=skill-labels.d.ts.map
@@ -0,0 +1,64 @@
1
+ import { Command } from "commander";
2
+ import { getClient, runAction } from "../lib/client.js";
3
+ import { formatList, formatDetail, formatSuccess } from "../lib/output.js";
4
+ /** Manage skill labels (#642). */
5
+ export function makeSkillLabelsCommand() {
6
+ const cmd = new Command("labels").description("Manage skill labels");
7
+ cmd
8
+ .command("list")
9
+ .description("List labels for a skill")
10
+ .argument("<id>", "Skill ID")
11
+ .action(async (id, _opts, command) => {
12
+ await runAction(command, async () => {
13
+ const client = getClient(command);
14
+ const { data } = await client.GET("/v1/skills/{id}/labels", { params: { path: { id } } });
15
+ formatList(data, command, ["name", "skillVersionId", "versionNumber"]);
16
+ });
17
+ });
18
+ cmd
19
+ .command("create")
20
+ .description("Create a label for a skill version")
21
+ .argument("<id>", "Skill ID")
22
+ .argument("<name>", "Label name")
23
+ .requiredOption("--version-id <id>", "Skill version ID to label")
24
+ .action(async (id, name, opts, command) => {
25
+ await runAction(command, async () => {
26
+ const client = getClient(command);
27
+ const { data } = await client.POST("/v1/skills/{id}/labels", {
28
+ params: { path: { id } },
29
+ body: { name, skillVersionId: opts.versionId },
30
+ });
31
+ formatDetail(data, command);
32
+ });
33
+ });
34
+ cmd
35
+ .command("update")
36
+ .description("Update a label to point to a different version")
37
+ .argument("<id>", "Skill ID")
38
+ .argument("<name>", "Label name")
39
+ .requiredOption("--version-id <id>", "New skill version ID")
40
+ .action(async (id, name, opts, command) => {
41
+ await runAction(command, async () => {
42
+ const client = getClient(command);
43
+ const { data } = await client.PUT("/v1/skills/{id}/labels/{name}", {
44
+ params: { path: { id, name } },
45
+ body: { skillVersionId: opts.versionId },
46
+ });
47
+ formatDetail(data, command);
48
+ });
49
+ });
50
+ cmd
51
+ .command("delete")
52
+ .description("Delete a skill label")
53
+ .argument("<id>", "Skill ID")
54
+ .argument("<name>", "Label name")
55
+ .action(async (id, name, _opts, command) => {
56
+ await runAction(command, async () => {
57
+ const client = getClient(command);
58
+ await client.DELETE("/v1/skills/{id}/labels/{name}", { params: { path: { id, name } } });
59
+ formatSuccess(`Label "${name}" deleted.`, command);
60
+ });
61
+ });
62
+ return cmd;
63
+ }
64
+ //# sourceMappingURL=skill-labels.js.map
@@ -0,0 +1,4 @@
1
+ import { Command } from "commander";
2
+ /** Manage skill versions (#642). */
3
+ export declare function makeSkillVersionsCommand(): Command;
4
+ //# sourceMappingURL=skill-versions.d.ts.map
@@ -0,0 +1,53 @@
1
+ import { Command } from "commander";
2
+ import { readFileSync } from "node:fs";
3
+ import { getClient, runAction } from "../lib/client.js";
4
+ import { formatPage, formatDetail } from "../lib/output.js";
5
+ import { addPaginationOptions, paginationParams } from "../lib/pagination.js";
6
+ /** Manage skill versions (#642). */
7
+ export function makeSkillVersionsCommand() {
8
+ const cmd = new Command("versions").description("Manage skill versions");
9
+ const list = new Command("list").description("List versions of a skill").argument("<id>", "Skill ID");
10
+ addPaginationOptions(list);
11
+ list.action(async (id, opts, command) => {
12
+ await runAction(command, async () => {
13
+ const client = getClient(command);
14
+ const { data } = await client.GET("/v1/skills/{id}/versions", {
15
+ params: { path: { id }, query: paginationParams(opts) },
16
+ });
17
+ formatPage(data, command, ["id", "versionNumber", "description", "contentHash"]);
18
+ });
19
+ });
20
+ cmd.addCommand(list);
21
+ cmd
22
+ .command("get")
23
+ .description("Get a specific skill version")
24
+ .argument("<id>", "Skill ID")
25
+ .argument("<versionNumber>", "Version number")
26
+ .action(async (id, versionNumber, _opts, command) => {
27
+ await runAction(command, async () => {
28
+ const client = getClient(command);
29
+ const { data } = await client.GET("/v1/skills/{id}/versions/{versionNumber}", {
30
+ params: { path: { id, versionNumber: Number(versionNumber) } },
31
+ });
32
+ formatDetail(data, command);
33
+ });
34
+ });
35
+ cmd
36
+ .command("create")
37
+ .description("Create a skill version from a markdown body file")
38
+ .argument("<id>", "Skill ID")
39
+ .requiredOption("--description <text>", "Version description")
40
+ .requiredOption("--body-file <path>", "Markdown body file")
41
+ .action(async (id, opts, command) => {
42
+ await runAction(command, async () => {
43
+ const client = getClient(command);
44
+ const { data } = await client.POST("/v1/skills/{id}/versions", {
45
+ params: { path: { id } },
46
+ body: { description: opts.description, body: readFileSync(opts.bodyFile, "utf-8") },
47
+ });
48
+ formatDetail(data, command);
49
+ });
50
+ });
51
+ return cmd;
52
+ }
53
+ //# sourceMappingURL=skill-versions.js.map
@@ -0,0 +1,4 @@
1
+ import { Command } from "commander";
2
+ /** Manage skills, versions and labels (#642). */
3
+ export declare function makeSkillsCommand(): Command;
4
+ //# sourceMappingURL=skills.d.ts.map
@@ -0,0 +1,161 @@
1
+ import { Command, Option } from "commander";
2
+ import { statSync, writeFileSync } from "node:fs";
3
+ import { basename, extname } from "node:path";
4
+ import { getClient, resolveAuthHeader, runAction } from "../lib/client.js";
5
+ import { resolveConfig } from "../lib/config.js";
6
+ import { BackboneApiError } from "../lib/errors.js";
7
+ import { fileToBlob } from "../lib/multipart.js";
8
+ import { formatPage, formatDetail, formatSuccess, withSpinner } from "../lib/output.js";
9
+ import { addPaginationOptions, paginationParams } from "../lib/pagination.js";
10
+ import { makeSkillVersionsCommand } from "./skill-versions.js";
11
+ import { makeSkillLabelsCommand } from "./skill-labels.js";
12
+ async function checkResponse(res) {
13
+ if (res.ok)
14
+ return;
15
+ const body = await res.json().catch(() => ({}));
16
+ throw new BackboneApiError({
17
+ status: body.status ?? res.status,
18
+ error: body.title ?? body.error ?? res.statusText,
19
+ message: body.detail ?? body.message ?? `HTTP ${res.status}: ${res.statusText}`,
20
+ timestamp: body.timestamp ?? new Date().toISOString(),
21
+ });
22
+ }
23
+ /** Manage skills, versions and labels (#642). */
24
+ export function makeSkillsCommand() {
25
+ const cmd = new Command("skills").description("Manage skills");
26
+ const list = new Command("list").description("List skills");
27
+ addPaginationOptions(list);
28
+ list.option("-s, --search <term>", "Filter by name");
29
+ list.addOption(new Option("--status <status>", "Filter by status").choices(["ACTIVE", "ARCHIVED"]));
30
+ list.action(async (opts, command) => {
31
+ await runAction(command, async () => {
32
+ const client = getClient(command);
33
+ const { data } = await client.GET("/v1/skills", {
34
+ params: { query: { search: opts.search, status: opts.status, ...paginationParams(opts) } },
35
+ });
36
+ formatPage(data, command, ["id", "name", "status", "latestVersionNumber"]);
37
+ });
38
+ });
39
+ cmd.addCommand(list);
40
+ cmd
41
+ .command("get")
42
+ .description("Get a skill by ID")
43
+ .argument("<id>", "Skill ID")
44
+ .action(async (id, _opts, command) => {
45
+ await runAction(command, async () => {
46
+ const client = getClient(command);
47
+ const { data } = await client.GET("/v1/skills/{id}", { params: { path: { id } } });
48
+ formatDetail(data, command);
49
+ });
50
+ });
51
+ cmd
52
+ .command("create")
53
+ .description("Create a skill (add content with versions create or import)")
54
+ .argument("<name>", "Skill name")
55
+ .action(async (name, _opts, command) => {
56
+ await runAction(command, async () => {
57
+ const client = getClient(command);
58
+ const { data } = await client.POST("/v1/skills", { body: { name } });
59
+ formatDetail(data, command);
60
+ });
61
+ });
62
+ cmd
63
+ .command("update")
64
+ .description("Update a skill's status")
65
+ .argument("<id>", "Skill ID")
66
+ .addOption(new Option("--status <status>", "New status").choices(["ACTIVE", "ARCHIVED"]).makeOptionMandatory())
67
+ .action(async (id, opts, command) => {
68
+ await runAction(command, async () => {
69
+ const client = getClient(command);
70
+ const { data } = await client.PUT("/v1/skills/{id}", {
71
+ params: { path: { id } },
72
+ body: { status: opts.status },
73
+ });
74
+ formatDetail(data, command);
75
+ });
76
+ });
77
+ cmd
78
+ .command("delete")
79
+ .description("Delete a skill")
80
+ .argument("<id>", "Skill ID")
81
+ .action(async (id, _opts, command) => {
82
+ await runAction(command, async () => {
83
+ const client = getClient(command);
84
+ await client.DELETE("/v1/skills/{id}", { params: { path: { id } } });
85
+ formatSuccess(`Skill ${id} deleted.`, command);
86
+ });
87
+ });
88
+ cmd
89
+ .command("resolve")
90
+ .description("Resolve a skill by name, name@label or name@version")
91
+ .argument("<ref>", "Skill reference")
92
+ .action(async (ref, _opts, command) => {
93
+ await runAction(command, async () => {
94
+ const client = getClient(command);
95
+ const { data } = await client.GET("/v1/skills/resolve", { params: { query: { ref } } });
96
+ formatDetail(data, command);
97
+ });
98
+ });
99
+ cmd
100
+ .command("import")
101
+ .description("Import a local SKILL.md or zip archive")
102
+ .argument("<path>", "Local SKILL.md or .zip file")
103
+ .action(async (path, _opts, command) => {
104
+ await runAction(command, async () => {
105
+ if (statSync(path).isDirectory())
106
+ throw new Error("Cannot import a directory; zip it first.");
107
+ if (basename(path) !== "SKILL.md" && extname(path).toLowerCase() !== ".zip") {
108
+ throw new Error("Import requires a SKILL.md or .zip file.");
109
+ }
110
+ const config = resolveConfig(command);
111
+ const authHeader = await resolveAuthHeader(config);
112
+ const { blob, filename } = fileToBlob(path);
113
+ const formData = new FormData();
114
+ formData.append("file", blob, filename);
115
+ const data = await withSpinner("Importing skill...", async () => {
116
+ const res = await fetch(`${config.baseUrl.replace(/\/+$/, "")}/v1/skills/import`, {
117
+ method: "POST",
118
+ headers: { Authorization: authHeader },
119
+ body: formData,
120
+ });
121
+ await checkResponse(res);
122
+ return res.json();
123
+ });
124
+ formatDetail(data, command);
125
+ });
126
+ });
127
+ cmd
128
+ .command("export")
129
+ .description("Export a skill version as a zip archive")
130
+ .argument("<id>", "Skill ID")
131
+ .argument("<versionNumber>", "Version number")
132
+ .option("-o, --output <file>", "Output path (default: <skill-name>-v<n>.zip)")
133
+ .action(async (id, versionNumber, opts, command) => {
134
+ await runAction(command, async () => {
135
+ let outputPath = opts.output;
136
+ if (!outputPath) {
137
+ const client = getClient(command);
138
+ const { data } = await client.GET("/v1/skills/{id}", { params: { path: { id } } });
139
+ if (!data?.name)
140
+ throw new Error("Skill name missing; specify an output path with -o.");
141
+ outputPath = `${basename(data.name)}-v${versionNumber}.zip`;
142
+ }
143
+ const config = resolveConfig(command);
144
+ const authHeader = await resolveAuthHeader(config);
145
+ const bytes = await withSpinner("Exporting skill...", async () => {
146
+ const baseUrl = config.baseUrl.replace(/\/+$/, "");
147
+ const res = await fetch(`${baseUrl}/v1/skills/${encodeURIComponent(id)}/versions/${encodeURIComponent(versionNumber)}/export`, {
148
+ headers: { Authorization: authHeader },
149
+ });
150
+ await checkResponse(res);
151
+ return Buffer.from(await res.arrayBuffer());
152
+ });
153
+ writeFileSync(outputPath, bytes);
154
+ formatSuccess(`Wrote ${bytes.length} bytes to ${outputPath}`, command);
155
+ });
156
+ });
157
+ cmd.addCommand(makeSkillVersionsCommand());
158
+ cmd.addCommand(makeSkillLabelsCommand());
159
+ return cmd;
160
+ }
161
+ //# sourceMappingURL=skills.js.map
package/dist/index.js CHANGED
@@ -7,6 +7,8 @@ const pkg = require("../package.json");
7
7
  import { makeConfigCommand } from "./commands/config.js";
8
8
  import { makeSchemasCommand } from "./commands/schemas.js";
9
9
  import { makePromptsCommand } from "./commands/prompts.js";
10
+ import { makeSkillsCommand } from "./commands/skills.js";
11
+ import { makePluginsCommand } from "./commands/plugins.js";
10
12
  import { makeExtractionsCommand } from "./commands/extractions.js";
11
13
  import { makeConvertCommand } from "./commands/convert.js";
12
14
  import { makeAiCommand } from "./commands/ai.js";
@@ -43,6 +45,8 @@ program.addCommand(makeConfigCommand());
43
45
  program.addCommand(makeContextCommand());
44
46
  program.addCommand(makeSchemasCommand());
45
47
  program.addCommand(makePromptsCommand());
48
+ program.addCommand(makeSkillsCommand());
49
+ program.addCommand(makePluginsCommand());
46
50
  program.addCommand(makeExtractionsCommand());
47
51
  program.addCommand(makeConvertCommand());
48
52
  program.addCommand(makeAiCommand());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2kw/ai",
3
- "version": "6.1.0",
3
+ "version": "6.2.0-dev.14",
4
4
  "description": "CLI for 2kw.ai — schema-driven document extraction, an OpenAI-compatible EU LLM gateway, transcription, prompts, datasets, and experiments from your terminal or agentic workflows. Ships as 2kw, backbone, and bb.",
5
5
  "keywords": [
6
6
  "cli",
@@ -54,7 +54,7 @@
54
54
  "ora": "^8.2.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@types/node": "^22.19.17",
57
+ "@types/node": "^22.20.1",
58
58
  "openapi-typescript": "^7.13.0",
59
59
  "tsx": "^4.21.1",
60
60
  "typescript": "^5.9.3",