@unityclaw/skills 1.0.4 → 1.0.5
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-FAGVVFFQ.js → chunk-VTGLNHDK.js} +90 -2
- package/dist/cli.cjs +88 -0
- package/dist/cli.js +1 -1
- package/dist/index.cjs +88 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { spawn } from "child_process";
|
|
2
|
+
import { spawn, execSync } from "child_process";
|
|
3
3
|
import { cp, mkdir, readdir, readFile } from "fs/promises";
|
|
4
|
-
import { existsSync, readdirSync } from "fs";
|
|
4
|
+
import { existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import { fileURLToPath } from "url";
|
|
7
|
+
import * as os from "os";
|
|
8
|
+
import * as readline from "readline";
|
|
7
9
|
function getSkillsDir() {
|
|
8
10
|
const hasSkillDirs = (dir) => {
|
|
9
11
|
try {
|
|
@@ -108,6 +110,57 @@ function getOpenClawSkillsDir() {
|
|
|
108
110
|
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
109
111
|
return process.env.OPENCLAW_SKILLS_DIR || path.join(homeDir, ".openclaw", "skills");
|
|
110
112
|
}
|
|
113
|
+
async function promptForApiKey() {
|
|
114
|
+
const rl = readline.createInterface({
|
|
115
|
+
input: process.stdin,
|
|
116
|
+
output: process.stdout
|
|
117
|
+
});
|
|
118
|
+
return new Promise((resolve) => {
|
|
119
|
+
rl.question("\nEnter your UnityClaw API key (or press Enter to skip): ", (answer) => {
|
|
120
|
+
rl.close();
|
|
121
|
+
resolve(answer.trim() || void 0);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function updateOpenClawEnvConfig(apiKey) {
|
|
126
|
+
const openclawDir = path.join(os.homedir(), ".openclaw");
|
|
127
|
+
const openclawPath = path.join(openclawDir, "openclaw.json");
|
|
128
|
+
let config = {};
|
|
129
|
+
if (existsSync(openclawPath)) {
|
|
130
|
+
try {
|
|
131
|
+
config = JSON.parse(readFileSync(openclawPath, "utf-8"));
|
|
132
|
+
} catch {
|
|
133
|
+
config = {};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (!config.env) config.env = {};
|
|
137
|
+
const env = config.env;
|
|
138
|
+
if (!env.vars) env.vars = {};
|
|
139
|
+
env.vars.UNITYCLAW_API_KEY = apiKey;
|
|
140
|
+
if (!existsSync(openclawDir)) {
|
|
141
|
+
mkdirSync(openclawDir, { recursive: true });
|
|
142
|
+
}
|
|
143
|
+
writeFileSync(openclawPath, JSON.stringify(config, null, 2), "utf-8");
|
|
144
|
+
}
|
|
145
|
+
function hasExistingApiKey() {
|
|
146
|
+
const sdkConfigPath = path.join(os.homedir(), ".unityclaw", "config.json");
|
|
147
|
+
if (existsSync(sdkConfigPath)) {
|
|
148
|
+
try {
|
|
149
|
+
const config = JSON.parse(readFileSync(sdkConfigPath, "utf-8"));
|
|
150
|
+
if (config?.apiKey) return true;
|
|
151
|
+
} catch {
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const openclawPath = path.join(os.homedir(), ".openclaw", "openclaw.json");
|
|
155
|
+
if (existsSync(openclawPath)) {
|
|
156
|
+
try {
|
|
157
|
+
const config = JSON.parse(readFileSync(openclawPath, "utf-8"));
|
|
158
|
+
if (config?.env?.vars?.UNITYCLAW_API_KEY) return true;
|
|
159
|
+
} catch {
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
111
164
|
async function installSkills(target, skills) {
|
|
112
165
|
const targetDir = target === "claude" ? getClaudeSkillsDir() : getOpenClawSkillsDir();
|
|
113
166
|
const skillsDir = getSkillsDir();
|
|
@@ -137,6 +190,41 @@ Installing ${skillsToInstall.length} skill(s):
|
|
|
137
190
|
}
|
|
138
191
|
console.log(`
|
|
139
192
|
\u2728 Done! Skills installed to: ${targetDir}`);
|
|
193
|
+
console.log("target", target);
|
|
194
|
+
console.log("hasExistingApiKey", hasExistingApiKey());
|
|
195
|
+
if (target === "openclaw" && !hasExistingApiKey()) {
|
|
196
|
+
console.log("\n\u{1F527} Configuration:");
|
|
197
|
+
console.log(" UnityClaw API key not found.\n");
|
|
198
|
+
const apiKey = await promptForApiKey();
|
|
199
|
+
if (apiKey) {
|
|
200
|
+
try {
|
|
201
|
+
execSync(`npx @unityclaw/sdk config set apiKey ${apiKey}`, { stdio: "pipe" });
|
|
202
|
+
} catch {
|
|
203
|
+
const configDir = path.join(os.homedir(), ".unityclaw");
|
|
204
|
+
const configPath = path.join(configDir, "config.json");
|
|
205
|
+
let config = {};
|
|
206
|
+
if (existsSync(configPath)) {
|
|
207
|
+
try {
|
|
208
|
+
config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
209
|
+
} catch {
|
|
210
|
+
config = {};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
config.apiKey = apiKey;
|
|
214
|
+
if (!existsSync(configDir)) {
|
|
215
|
+
mkdirSync(configDir, { recursive: true });
|
|
216
|
+
}
|
|
217
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
218
|
+
}
|
|
219
|
+
updateOpenClawEnvConfig(apiKey);
|
|
220
|
+
console.log("\n \u2705 API key saved to:");
|
|
221
|
+
console.log(" - ~/.openclaw/openclaw.json");
|
|
222
|
+
console.log("\n Get your API key at: https://unityclaw.com");
|
|
223
|
+
} else {
|
|
224
|
+
console.log("\n \u26A0\uFE0F Skipped. Configure later with:");
|
|
225
|
+
console.log(" npx @unityclaw/sdk config set apiKey <your-key>");
|
|
226
|
+
}
|
|
227
|
+
}
|
|
140
228
|
}
|
|
141
229
|
async function executeSkill(skillCommand) {
|
|
142
230
|
const args = [
|
package/dist/cli.cjs
CHANGED
|
@@ -33,6 +33,8 @@ var import_promises = require("fs/promises");
|
|
|
33
33
|
var import_fs = require("fs");
|
|
34
34
|
var import_path = __toESM(require("path"), 1);
|
|
35
35
|
var import_url = require("url");
|
|
36
|
+
var os = __toESM(require("os"), 1);
|
|
37
|
+
var readline = __toESM(require("readline"), 1);
|
|
36
38
|
var import_meta = {};
|
|
37
39
|
function getSkillsDir() {
|
|
38
40
|
const hasSkillDirs = (dir) => {
|
|
@@ -138,6 +140,57 @@ function getOpenClawSkillsDir() {
|
|
|
138
140
|
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
139
141
|
return process.env.OPENCLAW_SKILLS_DIR || import_path.default.join(homeDir, ".openclaw", "skills");
|
|
140
142
|
}
|
|
143
|
+
async function promptForApiKey() {
|
|
144
|
+
const rl = readline.createInterface({
|
|
145
|
+
input: process.stdin,
|
|
146
|
+
output: process.stdout
|
|
147
|
+
});
|
|
148
|
+
return new Promise((resolve) => {
|
|
149
|
+
rl.question("\nEnter your UnityClaw API key (or press Enter to skip): ", (answer) => {
|
|
150
|
+
rl.close();
|
|
151
|
+
resolve(answer.trim() || void 0);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function updateOpenClawEnvConfig(apiKey) {
|
|
156
|
+
const openclawDir = import_path.default.join(os.homedir(), ".openclaw");
|
|
157
|
+
const openclawPath = import_path.default.join(openclawDir, "openclaw.json");
|
|
158
|
+
let config = {};
|
|
159
|
+
if ((0, import_fs.existsSync)(openclawPath)) {
|
|
160
|
+
try {
|
|
161
|
+
config = JSON.parse((0, import_fs.readFileSync)(openclawPath, "utf-8"));
|
|
162
|
+
} catch {
|
|
163
|
+
config = {};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (!config.env) config.env = {};
|
|
167
|
+
const env = config.env;
|
|
168
|
+
if (!env.vars) env.vars = {};
|
|
169
|
+
env.vars.UNITYCLAW_API_KEY = apiKey;
|
|
170
|
+
if (!(0, import_fs.existsSync)(openclawDir)) {
|
|
171
|
+
(0, import_fs.mkdirSync)(openclawDir, { recursive: true });
|
|
172
|
+
}
|
|
173
|
+
(0, import_fs.writeFileSync)(openclawPath, JSON.stringify(config, null, 2), "utf-8");
|
|
174
|
+
}
|
|
175
|
+
function hasExistingApiKey() {
|
|
176
|
+
const sdkConfigPath = import_path.default.join(os.homedir(), ".unityclaw", "config.json");
|
|
177
|
+
if ((0, import_fs.existsSync)(sdkConfigPath)) {
|
|
178
|
+
try {
|
|
179
|
+
const config = JSON.parse((0, import_fs.readFileSync)(sdkConfigPath, "utf-8"));
|
|
180
|
+
if (config?.apiKey) return true;
|
|
181
|
+
} catch {
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const openclawPath = import_path.default.join(os.homedir(), ".openclaw", "openclaw.json");
|
|
185
|
+
if ((0, import_fs.existsSync)(openclawPath)) {
|
|
186
|
+
try {
|
|
187
|
+
const config = JSON.parse((0, import_fs.readFileSync)(openclawPath, "utf-8"));
|
|
188
|
+
if (config?.env?.vars?.UNITYCLAW_API_KEY) return true;
|
|
189
|
+
} catch {
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
141
194
|
async function installSkills(target, skills) {
|
|
142
195
|
const targetDir = target === "claude" ? getClaudeSkillsDir() : getOpenClawSkillsDir();
|
|
143
196
|
const skillsDir = getSkillsDir();
|
|
@@ -167,6 +220,41 @@ Installing ${skillsToInstall.length} skill(s):
|
|
|
167
220
|
}
|
|
168
221
|
console.log(`
|
|
169
222
|
\u2728 Done! Skills installed to: ${targetDir}`);
|
|
223
|
+
console.log("target", target);
|
|
224
|
+
console.log("hasExistingApiKey", hasExistingApiKey());
|
|
225
|
+
if (target === "openclaw" && !hasExistingApiKey()) {
|
|
226
|
+
console.log("\n\u{1F527} Configuration:");
|
|
227
|
+
console.log(" UnityClaw API key not found.\n");
|
|
228
|
+
const apiKey = await promptForApiKey();
|
|
229
|
+
if (apiKey) {
|
|
230
|
+
try {
|
|
231
|
+
(0, import_child_process.execSync)(`npx @unityclaw/sdk config set apiKey ${apiKey}`, { stdio: "pipe" });
|
|
232
|
+
} catch {
|
|
233
|
+
const configDir = import_path.default.join(os.homedir(), ".unityclaw");
|
|
234
|
+
const configPath = import_path.default.join(configDir, "config.json");
|
|
235
|
+
let config = {};
|
|
236
|
+
if ((0, import_fs.existsSync)(configPath)) {
|
|
237
|
+
try {
|
|
238
|
+
config = JSON.parse((0, import_fs.readFileSync)(configPath, "utf-8"));
|
|
239
|
+
} catch {
|
|
240
|
+
config = {};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
config.apiKey = apiKey;
|
|
244
|
+
if (!(0, import_fs.existsSync)(configDir)) {
|
|
245
|
+
(0, import_fs.mkdirSync)(configDir, { recursive: true });
|
|
246
|
+
}
|
|
247
|
+
(0, import_fs.writeFileSync)(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
248
|
+
}
|
|
249
|
+
updateOpenClawEnvConfig(apiKey);
|
|
250
|
+
console.log("\n \u2705 API key saved to:");
|
|
251
|
+
console.log(" - ~/.openclaw/openclaw.json");
|
|
252
|
+
console.log("\n Get your API key at: https://unityclaw.com");
|
|
253
|
+
} else {
|
|
254
|
+
console.log("\n \u26A0\uFE0F Skipped. Configure later with:");
|
|
255
|
+
console.log(" npx @unityclaw/sdk config set apiKey <your-key>");
|
|
256
|
+
}
|
|
257
|
+
}
|
|
170
258
|
}
|
|
171
259
|
async function executeSkill(skillCommand) {
|
|
172
260
|
const args2 = [
|
package/dist/cli.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -44,6 +44,8 @@ var import_promises = require("fs/promises");
|
|
|
44
44
|
var import_fs = require("fs");
|
|
45
45
|
var import_path = __toESM(require("path"), 1);
|
|
46
46
|
var import_url = require("url");
|
|
47
|
+
var os = __toESM(require("os"), 1);
|
|
48
|
+
var readline = __toESM(require("readline"), 1);
|
|
47
49
|
var import_meta = {};
|
|
48
50
|
function getSkillsDir() {
|
|
49
51
|
const hasSkillDirs = (dir) => {
|
|
@@ -149,6 +151,57 @@ function getOpenClawSkillsDir() {
|
|
|
149
151
|
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
150
152
|
return process.env.OPENCLAW_SKILLS_DIR || import_path.default.join(homeDir, ".openclaw", "skills");
|
|
151
153
|
}
|
|
154
|
+
async function promptForApiKey() {
|
|
155
|
+
const rl = readline.createInterface({
|
|
156
|
+
input: process.stdin,
|
|
157
|
+
output: process.stdout
|
|
158
|
+
});
|
|
159
|
+
return new Promise((resolve) => {
|
|
160
|
+
rl.question("\nEnter your UnityClaw API key (or press Enter to skip): ", (answer) => {
|
|
161
|
+
rl.close();
|
|
162
|
+
resolve(answer.trim() || void 0);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function updateOpenClawEnvConfig(apiKey) {
|
|
167
|
+
const openclawDir = import_path.default.join(os.homedir(), ".openclaw");
|
|
168
|
+
const openclawPath = import_path.default.join(openclawDir, "openclaw.json");
|
|
169
|
+
let config = {};
|
|
170
|
+
if ((0, import_fs.existsSync)(openclawPath)) {
|
|
171
|
+
try {
|
|
172
|
+
config = JSON.parse((0, import_fs.readFileSync)(openclawPath, "utf-8"));
|
|
173
|
+
} catch {
|
|
174
|
+
config = {};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (!config.env) config.env = {};
|
|
178
|
+
const env = config.env;
|
|
179
|
+
if (!env.vars) env.vars = {};
|
|
180
|
+
env.vars.UNITYCLAW_API_KEY = apiKey;
|
|
181
|
+
if (!(0, import_fs.existsSync)(openclawDir)) {
|
|
182
|
+
(0, import_fs.mkdirSync)(openclawDir, { recursive: true });
|
|
183
|
+
}
|
|
184
|
+
(0, import_fs.writeFileSync)(openclawPath, JSON.stringify(config, null, 2), "utf-8");
|
|
185
|
+
}
|
|
186
|
+
function hasExistingApiKey() {
|
|
187
|
+
const sdkConfigPath = import_path.default.join(os.homedir(), ".unityclaw", "config.json");
|
|
188
|
+
if ((0, import_fs.existsSync)(sdkConfigPath)) {
|
|
189
|
+
try {
|
|
190
|
+
const config = JSON.parse((0, import_fs.readFileSync)(sdkConfigPath, "utf-8"));
|
|
191
|
+
if (config?.apiKey) return true;
|
|
192
|
+
} catch {
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const openclawPath = import_path.default.join(os.homedir(), ".openclaw", "openclaw.json");
|
|
196
|
+
if ((0, import_fs.existsSync)(openclawPath)) {
|
|
197
|
+
try {
|
|
198
|
+
const config = JSON.parse((0, import_fs.readFileSync)(openclawPath, "utf-8"));
|
|
199
|
+
if (config?.env?.vars?.UNITYCLAW_API_KEY) return true;
|
|
200
|
+
} catch {
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
152
205
|
async function installSkills(target, skills) {
|
|
153
206
|
const targetDir = target === "claude" ? getClaudeSkillsDir() : getOpenClawSkillsDir();
|
|
154
207
|
const skillsDir = getSkillsDir();
|
|
@@ -178,6 +231,41 @@ Installing ${skillsToInstall.length} skill(s):
|
|
|
178
231
|
}
|
|
179
232
|
console.log(`
|
|
180
233
|
\u2728 Done! Skills installed to: ${targetDir}`);
|
|
234
|
+
console.log("target", target);
|
|
235
|
+
console.log("hasExistingApiKey", hasExistingApiKey());
|
|
236
|
+
if (target === "openclaw" && !hasExistingApiKey()) {
|
|
237
|
+
console.log("\n\u{1F527} Configuration:");
|
|
238
|
+
console.log(" UnityClaw API key not found.\n");
|
|
239
|
+
const apiKey = await promptForApiKey();
|
|
240
|
+
if (apiKey) {
|
|
241
|
+
try {
|
|
242
|
+
(0, import_child_process.execSync)(`npx @unityclaw/sdk config set apiKey ${apiKey}`, { stdio: "pipe" });
|
|
243
|
+
} catch {
|
|
244
|
+
const configDir = import_path.default.join(os.homedir(), ".unityclaw");
|
|
245
|
+
const configPath = import_path.default.join(configDir, "config.json");
|
|
246
|
+
let config = {};
|
|
247
|
+
if ((0, import_fs.existsSync)(configPath)) {
|
|
248
|
+
try {
|
|
249
|
+
config = JSON.parse((0, import_fs.readFileSync)(configPath, "utf-8"));
|
|
250
|
+
} catch {
|
|
251
|
+
config = {};
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
config.apiKey = apiKey;
|
|
255
|
+
if (!(0, import_fs.existsSync)(configDir)) {
|
|
256
|
+
(0, import_fs.mkdirSync)(configDir, { recursive: true });
|
|
257
|
+
}
|
|
258
|
+
(0, import_fs.writeFileSync)(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
259
|
+
}
|
|
260
|
+
updateOpenClawEnvConfig(apiKey);
|
|
261
|
+
console.log("\n \u2705 API key saved to:");
|
|
262
|
+
console.log(" - ~/.openclaw/openclaw.json");
|
|
263
|
+
console.log("\n Get your API key at: https://unityclaw.com");
|
|
264
|
+
} else {
|
|
265
|
+
console.log("\n \u26A0\uFE0F Skipped. Configure later with:");
|
|
266
|
+
console.log(" npx @unityclaw/sdk config set apiKey <your-key>");
|
|
267
|
+
}
|
|
268
|
+
}
|
|
181
269
|
}
|
|
182
270
|
async function executeSkill(skillCommand) {
|
|
183
271
|
const args = [
|
package/dist/index.js
CHANGED
package/package.json
CHANGED