volute 0.16.0 → 0.18.0
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.
- package/dist/chunk-AYB7XAWO.js +812 -0
- package/dist/{chunk-3FD4ZZUL.js → chunk-FW5API7X.js} +116 -10
- package/dist/{chunk-3FC42ZBM.js → chunk-GK4E7LM7.js} +3 -0
- package/dist/cli.js +18 -6
- package/dist/connectors/discord.js +1 -1
- package/dist/connectors/slack.js +1 -1
- package/dist/connectors/telegram.js +1 -1
- package/dist/{daemon-restart-MS5FI44G.js → daemon-restart-2HVTHZAT.js} +1 -1
- package/dist/daemon.js +1443 -592
- package/dist/history-YUEKTJ2N.js +108 -0
- package/dist/{mind-manager-PN5SUDJ4.js → mind-manager-Z7O7PN2O.js} +1 -1
- package/dist/{package-3QGV3KX6.js → package-OKLFO7UY.js} +8 -9
- package/dist/{send-KBBZNYG6.js → send-BNDTLUPM.js} +41 -9
- package/dist/skill-2Y42P4JY.js +287 -0
- package/dist/{up-GZLWZAQE.js → up-7B3BWF2U.js} +1 -1
- package/dist/web-assets/assets/index-CtiimdWK.css +1 -0
- package/dist/web-assets/assets/index-kt1_EcuO.js +63 -0
- package/dist/web-assets/index.html +2 -1
- package/drizzle/0006_mind_history.sql +20 -0
- package/drizzle/0007_system_prompts.sql +5 -0
- package/drizzle/0008_volute_channels.sql +24 -0
- package/drizzle/0009_shared_skills.sql +9 -0
- package/drizzle/meta/0006_snapshot.json +7 -0
- package/drizzle/meta/0007_snapshot.json +7 -0
- package/drizzle/meta/0008_snapshot.json +7 -0
- package/drizzle/meta/0009_snapshot.json +7 -0
- package/drizzle/meta/_journal.json +28 -0
- package/package.json +8 -9
- package/templates/_base/.init/.config/prompts.json +5 -0
- package/templates/_base/_skills/volute-mind/SKILL.md +19 -5
- package/templates/_base/src/lib/daemon-client.ts +45 -0
- package/templates/_base/src/lib/logger.ts +19 -0
- package/templates/_base/src/lib/router.ts +48 -41
- package/templates/_base/src/lib/routing.ts +5 -8
- package/templates/_base/src/lib/startup.ts +43 -0
- package/templates/_base/src/lib/transparency.ts +89 -0
- package/templates/_base/src/lib/types.ts +0 -1
- package/templates/_base/src/lib/volute-server.ts +3 -35
- package/templates/claude/src/agent.ts +9 -22
- package/templates/claude/src/lib/hooks/reply-instructions.ts +6 -9
- package/templates/claude/src/lib/stream-consumer.ts +39 -12
- package/templates/pi/src/agent.ts +9 -22
- package/templates/pi/src/lib/event-handler.ts +58 -7
- package/templates/pi/src/lib/reply-instructions-extension.ts +6 -9
- package/dist/chunk-J52CJCVI.js +0 -447
- package/dist/history-LKCJJMUV.js +0 -50
- package/dist/web-assets/assets/index-B1XIIGCh.js +0 -307
- package/templates/_base/src/lib/auto-reply.ts +0 -38
- /package/dist/{chunk-LLBBVTEY.js → chunk-6DVBMLVN.js} +0 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
resolveMindName
|
|
4
|
+
} from "./chunk-NAOW2CLO.js";
|
|
5
|
+
import {
|
|
6
|
+
parseArgs
|
|
7
|
+
} from "./chunk-D424ZQGI.js";
|
|
8
|
+
import {
|
|
9
|
+
daemonFetch
|
|
10
|
+
} from "./chunk-OJQ47SCA.js";
|
|
11
|
+
import "./chunk-M77QBTEH.js";
|
|
12
|
+
import {
|
|
13
|
+
getClient,
|
|
14
|
+
urlOf
|
|
15
|
+
} from "./chunk-4RQBJWQX.js";
|
|
16
|
+
import "./chunk-K3NQKI34.js";
|
|
17
|
+
|
|
18
|
+
// src/commands/history.ts
|
|
19
|
+
function normalizeTimestamp(dateStr) {
|
|
20
|
+
return dateStr.endsWith("Z") ? dateStr : `${dateStr}Z`;
|
|
21
|
+
}
|
|
22
|
+
function formatRow(row) {
|
|
23
|
+
const time = new Date(normalizeTimestamp(row.created_at)).toLocaleString();
|
|
24
|
+
const channel = row.channel ?? "";
|
|
25
|
+
switch (row.type) {
|
|
26
|
+
case "inbound":
|
|
27
|
+
case "outbound": {
|
|
28
|
+
const sender = row.sender ?? (row.type === "outbound" ? "mind" : "unknown");
|
|
29
|
+
return `[${time}] [${channel}] ${sender}: ${row.content ?? ""}`;
|
|
30
|
+
}
|
|
31
|
+
case "text":
|
|
32
|
+
return `[${time}] [text] ${row.content ?? ""}`;
|
|
33
|
+
case "thinking":
|
|
34
|
+
return `[${time}] [thinking] ${(row.content ?? "").slice(0, 200)}${(row.content?.length ?? 0) > 200 ? "..." : ""}`;
|
|
35
|
+
case "tool_use": {
|
|
36
|
+
let toolName = "unknown";
|
|
37
|
+
if (row.metadata) {
|
|
38
|
+
try {
|
|
39
|
+
const meta = JSON.parse(row.metadata);
|
|
40
|
+
toolName = meta.name ?? toolName;
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return `[${time}] [tool] ${toolName}${row.content ? `: ${row.content.slice(0, 100)}` : ""}`;
|
|
45
|
+
}
|
|
46
|
+
case "tool_result":
|
|
47
|
+
return `[${time}] [result] ${(row.content ?? "").slice(0, 200)}${(row.content?.length ?? 0) > 200 ? "..." : ""}`;
|
|
48
|
+
case "usage": {
|
|
49
|
+
if (row.metadata) {
|
|
50
|
+
try {
|
|
51
|
+
const meta = JSON.parse(row.metadata);
|
|
52
|
+
return `[${time}] [usage] in=${meta.input_tokens ?? 0} out=${meta.output_tokens ?? 0}`;
|
|
53
|
+
} catch {
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return `[${time}] [usage]`;
|
|
57
|
+
}
|
|
58
|
+
case "done":
|
|
59
|
+
return `[${time}] [done]`;
|
|
60
|
+
case "log": {
|
|
61
|
+
let category = "";
|
|
62
|
+
if (row.metadata) {
|
|
63
|
+
try {
|
|
64
|
+
const meta = JSON.parse(row.metadata);
|
|
65
|
+
category = meta.category ? `${meta.category}: ` : "";
|
|
66
|
+
} catch {
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return `[${time}] [log] ${category}${row.content ?? ""}`;
|
|
70
|
+
}
|
|
71
|
+
case "session_start":
|
|
72
|
+
return `[${time}] [session_start] ${row.session ?? ""}`;
|
|
73
|
+
default:
|
|
74
|
+
return `[${time}] [${row.type}] ${row.content ?? ""}`;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function run(args) {
|
|
78
|
+
const { flags } = parseArgs(args, {
|
|
79
|
+
mind: { type: "string" },
|
|
80
|
+
channel: { type: "string" },
|
|
81
|
+
limit: { type: "string" },
|
|
82
|
+
full: { type: "boolean" }
|
|
83
|
+
});
|
|
84
|
+
const name = resolveMindName(flags);
|
|
85
|
+
const client = getClient();
|
|
86
|
+
const url = client.api.minds[":name"].history.$url({ param: { name } });
|
|
87
|
+
if (flags.channel) url.searchParams.set("channel", flags.channel);
|
|
88
|
+
if (flags.limit) url.searchParams.set("limit", flags.limit);
|
|
89
|
+
if (flags.full) url.searchParams.set("full", "true");
|
|
90
|
+
const res = await daemonFetch(urlOf(url));
|
|
91
|
+
if (!res.ok) {
|
|
92
|
+
let errorMsg = `Failed to get history: ${res.status}`;
|
|
93
|
+
try {
|
|
94
|
+
const data = await res.json();
|
|
95
|
+
if (data.error) errorMsg = data.error;
|
|
96
|
+
} catch {
|
|
97
|
+
}
|
|
98
|
+
console.error(errorMsg);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
const rows = await res.json();
|
|
102
|
+
for (const row of rows.reverse()) {
|
|
103
|
+
console.log(formatRow(row));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
run
|
|
108
|
+
};
|
|
@@ -4,7 +4,7 @@ import "./chunk-K3NQKI34.js";
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "volute",
|
|
7
|
-
version: "0.
|
|
7
|
+
version: "0.18.0",
|
|
8
8
|
description: "CLI for creating and managing self-modifying AI minds powered by the Claude Agent SDK",
|
|
9
9
|
type: "module",
|
|
10
10
|
license: "MIT",
|
|
@@ -33,8 +33,8 @@ var package_default = {
|
|
|
33
33
|
scripts: {
|
|
34
34
|
dev: "tsx src/cli.ts",
|
|
35
35
|
build: "tsup && npm run build:web",
|
|
36
|
-
"build:web": "vite build --config src/web/
|
|
37
|
-
"dev:web": "vite --config src/web/
|
|
36
|
+
"build:web": "vite build --config src/web/ui/vite.config.ts",
|
|
37
|
+
"dev:web": "vite --config src/web/ui/vite.config.ts",
|
|
38
38
|
test: "node --import tsx --import ./test/setup.ts --test --test-force-exit --test-concurrency=1 test/*.test.ts",
|
|
39
39
|
lint: "biome check src/ test/",
|
|
40
40
|
"lint:fix": "biome check --write src/ test/",
|
|
@@ -42,7 +42,7 @@ var package_default = {
|
|
|
42
42
|
typecheck: "tsc --noEmit",
|
|
43
43
|
"typecheck:templates": "tsc --noEmit -p templates/claude/tsconfig.json && tsc --noEmit -p templates/pi/tsconfig.json",
|
|
44
44
|
"lint:templates": "biome check templates/",
|
|
45
|
-
"typecheck:web": "
|
|
45
|
+
"typecheck:web": "svelte-check --tsconfig src/web/ui/tsconfig.json",
|
|
46
46
|
prepare: "lefthook install",
|
|
47
47
|
prepublishOnly: "npm run build",
|
|
48
48
|
"db:generate": "drizzle-kit generate",
|
|
@@ -53,6 +53,7 @@ var package_default = {
|
|
|
53
53
|
"@hono/zod-validator": "^0.7.6",
|
|
54
54
|
"@libsql/client": "^0.17.0",
|
|
55
55
|
"@slack/bolt": "^4.6.0",
|
|
56
|
+
"adm-zip": "^0.5.16",
|
|
56
57
|
bcryptjs: "^3.0.3",
|
|
57
58
|
"cron-parser": "^5.5.0",
|
|
58
59
|
"discord.js": "^14.25.1",
|
|
@@ -66,18 +67,16 @@ var package_default = {
|
|
|
66
67
|
"@biomejs/biome": "2.3.14",
|
|
67
68
|
"@mariozechner/pi-ai": "^0.52.7",
|
|
68
69
|
"@mariozechner/pi-coding-agent": "^0.52.7",
|
|
70
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
71
|
+
"@types/adm-zip": "^0.5.7",
|
|
69
72
|
"@types/bcryptjs": "^2.4.6",
|
|
70
73
|
"@types/dompurify": "^3.0.5",
|
|
71
74
|
"@types/node": "^25.2.0",
|
|
72
|
-
"@types/react": "^19.2.11",
|
|
73
|
-
"@types/react-dom": "^19.2.3",
|
|
74
|
-
"@vitejs/plugin-react": "^5.1.3",
|
|
75
75
|
dompurify: "^3.3.1",
|
|
76
76
|
"drizzle-kit": "^0.31.8",
|
|
77
77
|
lefthook: "^2.1.0",
|
|
78
78
|
marked: "^17.0.1",
|
|
79
|
-
|
|
80
|
-
"react-dom": "^19.2.4",
|
|
79
|
+
svelte: "^5.53.0",
|
|
81
80
|
tsup: "^8.0.0",
|
|
82
81
|
tsx: "^4.0.0",
|
|
83
82
|
typescript: "^5.7.0",
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
} from "./chunk-NAOW2CLO.js";
|
|
5
5
|
import {
|
|
6
6
|
getChannelDriver
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-FW5API7X.js";
|
|
8
8
|
import {
|
|
9
9
|
parseArgs
|
|
10
10
|
} from "./chunk-D424ZQGI.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-GK4E7LM7.js";
|
|
12
12
|
import {
|
|
13
13
|
daemonFetch
|
|
14
14
|
} from "./chunk-OJQ47SCA.js";
|
|
@@ -22,7 +22,9 @@ import {
|
|
|
22
22
|
import "./chunk-K3NQKI34.js";
|
|
23
23
|
|
|
24
24
|
// src/commands/send.ts
|
|
25
|
+
import { existsSync, readFileSync } from "fs";
|
|
25
26
|
import { userInfo } from "os";
|
|
27
|
+
import { extname } from "path";
|
|
26
28
|
|
|
27
29
|
// src/lib/parse-target.ts
|
|
28
30
|
function parseTarget(target) {
|
|
@@ -71,20 +73,45 @@ async function readStdin() {
|
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
// src/commands/send.ts
|
|
76
|
+
var IMAGE_MEDIA_TYPES = {
|
|
77
|
+
".png": "image/png",
|
|
78
|
+
".jpg": "image/jpeg",
|
|
79
|
+
".jpeg": "image/jpeg",
|
|
80
|
+
".gif": "image/gif",
|
|
81
|
+
".webp": "image/webp"
|
|
82
|
+
};
|
|
83
|
+
function loadImage(imagePath) {
|
|
84
|
+
if (!existsSync(imagePath)) {
|
|
85
|
+
console.error(`Image file not found: ${imagePath}`);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
const ext = extname(imagePath).toLowerCase();
|
|
89
|
+
const mediaType = IMAGE_MEDIA_TYPES[ext];
|
|
90
|
+
if (!mediaType) {
|
|
91
|
+
console.error(`Unsupported image format: ${ext} (supported: png, jpg, jpeg, gif, webp)`);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
const data = readFileSync(imagePath).toString("base64");
|
|
95
|
+
return { media_type: mediaType, data };
|
|
96
|
+
}
|
|
74
97
|
async function run(args) {
|
|
75
98
|
const { positional, flags } = parseArgs(args, {
|
|
76
|
-
mind: { type: "string" }
|
|
99
|
+
mind: { type: "string" },
|
|
100
|
+
image: { type: "string" }
|
|
77
101
|
});
|
|
78
102
|
const target = positional[0];
|
|
79
103
|
const message = positional[1] ?? await readStdin();
|
|
80
|
-
|
|
81
|
-
|
|
104
|
+
const images = flags.image ? [loadImage(flags.image)] : void 0;
|
|
105
|
+
if (!target || !message && !images) {
|
|
106
|
+
console.error('Usage: volute send <target> "<message>" [--mind <name>] [--image <path>]');
|
|
82
107
|
console.error(' echo "message" | volute send <target> [--mind <name>]');
|
|
83
108
|
console.error("");
|
|
84
109
|
console.error("Examples:");
|
|
85
110
|
console.error(' volute send @other-mind "hello"');
|
|
86
111
|
console.error(' volute send animal-chat "hello everyone"');
|
|
87
112
|
console.error(' volute send discord:server/channel "hello"');
|
|
113
|
+
console.error(' volute send @mind "check this out" --image photo.png');
|
|
114
|
+
console.error(" volute send @mind --image photo.png");
|
|
88
115
|
process.exit(1);
|
|
89
116
|
}
|
|
90
117
|
if (target === "system" || target === "@system") {
|
|
@@ -131,7 +158,7 @@ To reply to a person, use their username from the message prefix (e.g. volute se
|
|
|
131
158
|
process.exit(1);
|
|
132
159
|
}
|
|
133
160
|
try {
|
|
134
|
-
await driver.send(env, channelUri, message);
|
|
161
|
+
await driver.send(env, channelUri, message ?? "", images);
|
|
135
162
|
console.log("Message sent.");
|
|
136
163
|
} catch (err) {
|
|
137
164
|
console.error(err instanceof Error ? err.message : String(err));
|
|
@@ -145,7 +172,7 @@ To reply to a person, use their username from the message prefix (e.g. volute se
|
|
|
145
172
|
{
|
|
146
173
|
method: "POST",
|
|
147
174
|
headers: { "Content-Type": "application/json" },
|
|
148
|
-
body: JSON.stringify({ channel:
|
|
175
|
+
body: JSON.stringify({ channel: parsed.uri, content: message ?? "" })
|
|
149
176
|
}
|
|
150
177
|
);
|
|
151
178
|
} catch (err) {
|
|
@@ -160,7 +187,12 @@ To reply to a person, use their username from the message prefix (e.g. volute se
|
|
|
160
187
|
{
|
|
161
188
|
method: "POST",
|
|
162
189
|
headers: { "Content-Type": "application/json" },
|
|
163
|
-
body: JSON.stringify({
|
|
190
|
+
body: JSON.stringify({
|
|
191
|
+
platform: parsed.platform,
|
|
192
|
+
uri: channelUri,
|
|
193
|
+
message: message ?? "",
|
|
194
|
+
images
|
|
195
|
+
})
|
|
164
196
|
}
|
|
165
197
|
);
|
|
166
198
|
if (!res.ok) {
|
|
@@ -176,7 +208,7 @@ To reply to a person, use their username from the message prefix (e.g. volute se
|
|
|
176
208
|
{
|
|
177
209
|
method: "POST",
|
|
178
210
|
headers: { "Content-Type": "application/json" },
|
|
179
|
-
body: JSON.stringify({ channel: channelUri, content: message })
|
|
211
|
+
body: JSON.stringify({ channel: channelUri, content: message ?? "" })
|
|
180
212
|
}
|
|
181
213
|
);
|
|
182
214
|
} catch (err) {
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
resolveMindName
|
|
4
|
+
} from "./chunk-NAOW2CLO.js";
|
|
5
|
+
import {
|
|
6
|
+
parseArgs
|
|
7
|
+
} from "./chunk-D424ZQGI.js";
|
|
8
|
+
import {
|
|
9
|
+
daemonFetch
|
|
10
|
+
} from "./chunk-OJQ47SCA.js";
|
|
11
|
+
import "./chunk-M77QBTEH.js";
|
|
12
|
+
import {
|
|
13
|
+
getClient,
|
|
14
|
+
urlOf
|
|
15
|
+
} from "./chunk-4RQBJWQX.js";
|
|
16
|
+
import "./chunk-K3NQKI34.js";
|
|
17
|
+
|
|
18
|
+
// src/commands/skill.ts
|
|
19
|
+
async function run(args) {
|
|
20
|
+
const subcommand = args[0];
|
|
21
|
+
switch (subcommand) {
|
|
22
|
+
case "list":
|
|
23
|
+
await listSkills(args.slice(1));
|
|
24
|
+
break;
|
|
25
|
+
case "info":
|
|
26
|
+
await infoSkill(args.slice(1));
|
|
27
|
+
break;
|
|
28
|
+
case "install":
|
|
29
|
+
await installSkill(args.slice(1));
|
|
30
|
+
break;
|
|
31
|
+
case "update":
|
|
32
|
+
await updateSkill(args.slice(1));
|
|
33
|
+
break;
|
|
34
|
+
case "publish":
|
|
35
|
+
await publishSkill(args.slice(1));
|
|
36
|
+
break;
|
|
37
|
+
case "remove":
|
|
38
|
+
await removeSkill(args.slice(1));
|
|
39
|
+
break;
|
|
40
|
+
case "uninstall":
|
|
41
|
+
await uninstallSkill(args.slice(1));
|
|
42
|
+
break;
|
|
43
|
+
case "--help":
|
|
44
|
+
case "-h":
|
|
45
|
+
case void 0:
|
|
46
|
+
printUsage();
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
console.error(`Unknown subcommand: ${subcommand}`);
|
|
50
|
+
printUsage();
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function printUsage() {
|
|
55
|
+
console.log(`Usage:
|
|
56
|
+
volute skill list List shared skills available to install
|
|
57
|
+
volute skill list --mind <name> List installed skills for a mind
|
|
58
|
+
volute skill info <name> Show details of a shared skill
|
|
59
|
+
volute skill install <name> --mind Install a shared skill into a mind
|
|
60
|
+
volute skill update <name> --mind Update an installed skill (3-way merge)
|
|
61
|
+
volute skill update --all --mind Update all installed skills
|
|
62
|
+
volute skill publish <name> --mind Publish a mind's skill to the shared repository
|
|
63
|
+
volute skill remove <name> Remove a shared skill
|
|
64
|
+
volute skill uninstall <name> --mind Uninstall a skill from a mind`);
|
|
65
|
+
}
|
|
66
|
+
async function listSkills(args) {
|
|
67
|
+
const { flags } = parseArgs(args, { mind: { type: "string" } });
|
|
68
|
+
if (flags.mind || process.env.VOLUTE_MIND) {
|
|
69
|
+
const mindName = resolveMindName(flags);
|
|
70
|
+
const client = getClient();
|
|
71
|
+
const url = urlOf(client.api.minds[":name"].skills.$url({ param: { name: mindName } }));
|
|
72
|
+
const res = await daemonFetch(url);
|
|
73
|
+
if (!res.ok) {
|
|
74
|
+
const body = await res.json().catch(() => ({ error: "Unknown error" }));
|
|
75
|
+
console.error(`Error: ${body.error}`);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
const skills = await res.json();
|
|
79
|
+
if (skills.length === 0) {
|
|
80
|
+
console.log("No skills installed.");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
console.log(`Skills for ${mindName}:
|
|
84
|
+
`);
|
|
85
|
+
for (const s of skills) {
|
|
86
|
+
const update = s.updateAvailable ? " (update available)" : "";
|
|
87
|
+
const source = s.upstream ? ` [shared:${s.upstream.source} v${s.upstream.version}]` : "";
|
|
88
|
+
console.log(` ${s.id} \u2014 ${s.name}${source}${update}`);
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
const client = getClient();
|
|
92
|
+
const url = urlOf(client.api.skills.$url());
|
|
93
|
+
const res = await daemonFetch(url);
|
|
94
|
+
if (!res.ok) {
|
|
95
|
+
const body = await res.json().catch(() => ({ error: "Unknown error" }));
|
|
96
|
+
console.error(`Error: ${body.error}`);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
const skills = await res.json();
|
|
100
|
+
if (skills.length === 0) {
|
|
101
|
+
console.log("No shared skills available.");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
console.log("Shared skills:\n");
|
|
105
|
+
for (const s of skills) {
|
|
106
|
+
console.log(` ${s.id} \u2014 ${s.name} (v${s.version}, by ${s.author})`);
|
|
107
|
+
if (s.description) console.log(` ${s.description}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async function infoSkill(args) {
|
|
112
|
+
const { positional } = parseArgs(args, {});
|
|
113
|
+
const id = positional[0];
|
|
114
|
+
if (!id) {
|
|
115
|
+
console.error("Usage: volute skill info <name>");
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
const client = getClient();
|
|
119
|
+
const url = urlOf(client.api.skills[":id"].$url({ param: { id } }));
|
|
120
|
+
const res = await daemonFetch(url);
|
|
121
|
+
if (!res.ok) {
|
|
122
|
+
const body = await res.json().catch(() => ({ error: "Unknown error" }));
|
|
123
|
+
console.error(`Error: ${body.error}`);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
const skill = await res.json();
|
|
127
|
+
console.log(`${skill.name} (${skill.id})`);
|
|
128
|
+
console.log(` Version: ${skill.version}`);
|
|
129
|
+
console.log(` Author: ${skill.author}`);
|
|
130
|
+
if (skill.description) console.log(` Description: ${skill.description}`);
|
|
131
|
+
console.log(` Files: ${skill.files.join(", ")}`);
|
|
132
|
+
}
|
|
133
|
+
async function installSkill(args) {
|
|
134
|
+
const { positional, flags } = parseArgs(args, { mind: { type: "string" } });
|
|
135
|
+
const mindName = resolveMindName(flags);
|
|
136
|
+
const skillId = positional[0];
|
|
137
|
+
if (!skillId) {
|
|
138
|
+
console.error("Usage: volute skill install <name> [--mind <name>]");
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
141
|
+
const client = getClient();
|
|
142
|
+
const url = urlOf(client.api.minds[":name"].skills.install.$url({ param: { name: mindName } }));
|
|
143
|
+
const res = await daemonFetch(url, {
|
|
144
|
+
method: "POST",
|
|
145
|
+
headers: { "Content-Type": "application/json" },
|
|
146
|
+
body: JSON.stringify({ skillId })
|
|
147
|
+
});
|
|
148
|
+
if (!res.ok) {
|
|
149
|
+
const body = await res.json().catch(() => ({ error: "Unknown error" }));
|
|
150
|
+
console.error(`Error: ${body.error}`);
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
153
|
+
console.log(`Installed skill "${skillId}" into ${mindName}.`);
|
|
154
|
+
}
|
|
155
|
+
async function updateSkill(args) {
|
|
156
|
+
const { positional, flags } = parseArgs(args, {
|
|
157
|
+
mind: { type: "string" },
|
|
158
|
+
all: { type: "boolean" }
|
|
159
|
+
});
|
|
160
|
+
const mindName = resolveMindName(flags);
|
|
161
|
+
if (flags.all) {
|
|
162
|
+
const client = getClient();
|
|
163
|
+
const listUrl = urlOf(client.api.minds[":name"].skills.$url({ param: { name: mindName } }));
|
|
164
|
+
const listRes = await daemonFetch(listUrl);
|
|
165
|
+
if (!listRes.ok) {
|
|
166
|
+
const body = await listRes.json().catch(() => ({ error: "Unknown error" }));
|
|
167
|
+
console.error(`Error: ${body.error}`);
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
const skills = await listRes.json();
|
|
171
|
+
const updatable = skills.filter((s) => s.updateAvailable && s.upstream);
|
|
172
|
+
if (updatable.length === 0) {
|
|
173
|
+
console.log("All skills are up to date.");
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
let failures = 0;
|
|
177
|
+
for (const s of updatable) {
|
|
178
|
+
const ok2 = await doUpdate(mindName, s.id);
|
|
179
|
+
if (!ok2) failures++;
|
|
180
|
+
}
|
|
181
|
+
if (failures > 0) process.exit(1);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const skillId = positional[0];
|
|
185
|
+
if (!skillId) {
|
|
186
|
+
console.error("Usage: volute skill update <name> [--mind <name>] [--all]");
|
|
187
|
+
process.exit(1);
|
|
188
|
+
}
|
|
189
|
+
const ok = await doUpdate(mindName, skillId);
|
|
190
|
+
if (!ok) process.exit(1);
|
|
191
|
+
}
|
|
192
|
+
async function doUpdate(mindName, skillId) {
|
|
193
|
+
const client = getClient();
|
|
194
|
+
const url = urlOf(client.api.minds[":name"].skills.update.$url({ param: { name: mindName } }));
|
|
195
|
+
const res = await daemonFetch(url, {
|
|
196
|
+
method: "POST",
|
|
197
|
+
headers: { "Content-Type": "application/json" },
|
|
198
|
+
body: JSON.stringify({ skillId })
|
|
199
|
+
});
|
|
200
|
+
if (!res.ok) {
|
|
201
|
+
const body = await res.json().catch(() => ({ error: "Unknown error" }));
|
|
202
|
+
console.error(`Error updating ${skillId}: ${body.error}`);
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
const result = await res.json();
|
|
206
|
+
switch (result.status) {
|
|
207
|
+
case "up-to-date":
|
|
208
|
+
console.log(`${skillId}: already up to date.`);
|
|
209
|
+
break;
|
|
210
|
+
case "updated":
|
|
211
|
+
console.log(`${skillId}: updated successfully.`);
|
|
212
|
+
break;
|
|
213
|
+
case "conflict":
|
|
214
|
+
console.log(`${skillId}: updated with conflicts in:`);
|
|
215
|
+
for (const f of result.conflictFiles ?? []) {
|
|
216
|
+
console.log(` ${f}`);
|
|
217
|
+
}
|
|
218
|
+
console.log("Resolve conflicts and commit manually.");
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
async function publishSkill(args) {
|
|
224
|
+
const { positional, flags } = parseArgs(args, { mind: { type: "string" } });
|
|
225
|
+
const mindName = resolveMindName(flags);
|
|
226
|
+
const skillId = positional[0];
|
|
227
|
+
if (!skillId) {
|
|
228
|
+
console.error("Usage: volute skill publish <name> [--mind <name>]");
|
|
229
|
+
process.exit(1);
|
|
230
|
+
}
|
|
231
|
+
const client = getClient();
|
|
232
|
+
const url = urlOf(client.api.minds[":name"].skills.publish.$url({ param: { name: mindName } }));
|
|
233
|
+
const res = await daemonFetch(url, {
|
|
234
|
+
method: "POST",
|
|
235
|
+
headers: { "Content-Type": "application/json" },
|
|
236
|
+
body: JSON.stringify({ skillId })
|
|
237
|
+
});
|
|
238
|
+
if (!res.ok) {
|
|
239
|
+
const body = await res.json().catch(() => ({ error: "Unknown error" }));
|
|
240
|
+
console.error(`Error: ${body.error}`);
|
|
241
|
+
process.exit(1);
|
|
242
|
+
}
|
|
243
|
+
const skill = await res.json();
|
|
244
|
+
console.log(`Published skill "${skillId}" (v${skill.version}).`);
|
|
245
|
+
}
|
|
246
|
+
async function removeSkill(args) {
|
|
247
|
+
const { positional } = parseArgs(args, {});
|
|
248
|
+
const id = positional[0];
|
|
249
|
+
if (!id) {
|
|
250
|
+
console.error("Usage: volute skill remove <name>");
|
|
251
|
+
process.exit(1);
|
|
252
|
+
}
|
|
253
|
+
const client = getClient();
|
|
254
|
+
const url = urlOf(client.api.skills[":id"].$url({ param: { id } }));
|
|
255
|
+
const res = await daemonFetch(url, { method: "DELETE" });
|
|
256
|
+
if (!res.ok) {
|
|
257
|
+
const body = await res.json().catch(() => ({ error: "Unknown error" }));
|
|
258
|
+
console.error(`Error: ${body.error}`);
|
|
259
|
+
process.exit(1);
|
|
260
|
+
}
|
|
261
|
+
console.log(`Removed shared skill "${id}".`);
|
|
262
|
+
}
|
|
263
|
+
async function uninstallSkill(args) {
|
|
264
|
+
const { positional, flags } = parseArgs(args, { mind: { type: "string" } });
|
|
265
|
+
const mindName = resolveMindName(flags);
|
|
266
|
+
const skillId = positional[0];
|
|
267
|
+
if (!skillId) {
|
|
268
|
+
console.error("Usage: volute skill uninstall <name> [--mind <name>]");
|
|
269
|
+
process.exit(1);
|
|
270
|
+
}
|
|
271
|
+
const client = getClient();
|
|
272
|
+
const url = urlOf(
|
|
273
|
+
client.api.minds[":name"].skills[":skill"].$url({
|
|
274
|
+
param: { name: mindName, skill: skillId }
|
|
275
|
+
})
|
|
276
|
+
);
|
|
277
|
+
const res = await daemonFetch(url, { method: "DELETE" });
|
|
278
|
+
if (!res.ok) {
|
|
279
|
+
const body = await res.json().catch(() => ({ error: "Unknown error" }));
|
|
280
|
+
console.error(`Error: ${body.error}`);
|
|
281
|
+
process.exit(1);
|
|
282
|
+
}
|
|
283
|
+
console.log(`Uninstalled skill "${skillId}" from ${mindName}.`);
|
|
284
|
+
}
|
|
285
|
+
export {
|
|
286
|
+
run
|
|
287
|
+
};
|