lokuma-cli 1.4.3 → 1.4.4
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/index.js +41 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -80,8 +80,11 @@ function resolvePath(p) {
|
|
|
80
80
|
if (p.startsWith("~/")) return join(homedir(), p.slice(2));
|
|
81
81
|
return p;
|
|
82
82
|
}
|
|
83
|
-
function buildSkillMd(scriptPath) {
|
|
84
|
-
|
|
83
|
+
function buildSkillMd(scriptPath, apiKey) {
|
|
84
|
+
const keyLine = apiKey ? `LOKUMA_API_KEY = ${apiKey}
|
|
85
|
+
|
|
86
|
+
` : "";
|
|
87
|
+
return `${keyLine}---
|
|
85
88
|
name: frontend-designer
|
|
86
89
|
description: >
|
|
87
90
|
Lokuma design intelligence. Use this skill whenever building or modifying UI:
|
|
@@ -239,7 +242,8 @@ async function initCommand(options) {
|
|
|
239
242
|
}
|
|
240
243
|
await mkdir(dirname(paths.skillMd), { recursive: true });
|
|
241
244
|
await mkdir(dirname(paths.scriptPy), { recursive: true });
|
|
242
|
-
|
|
245
|
+
const apiKey = process.env.LOKUMA_API_KEY ?? "";
|
|
246
|
+
await writeFile(paths.skillMd, buildSkillMd(paths.scriptPy, apiKey), "utf-8");
|
|
243
247
|
await writeFile(paths.scriptPy, DESIGN_PY, "utf-8");
|
|
244
248
|
installed.push({ name: AI_DISPLAY_NAMES[t], skillMd: paths.skillMd, scriptPy: paths.scriptPy });
|
|
245
249
|
}
|
|
@@ -274,8 +278,36 @@ async function initCommand(options) {
|
|
|
274
278
|
// src/commands/auth.ts
|
|
275
279
|
import { writeFileSync, readFileSync as readFileSync2, existsSync, mkdirSync } from "node:fs";
|
|
276
280
|
import { dirname as dirname2, join as join2 } from "node:path";
|
|
281
|
+
import { homedir as homedir2 } from "node:os";
|
|
277
282
|
import { createInterface } from "node:readline";
|
|
278
283
|
import chalk2 from "chalk";
|
|
284
|
+
function resolvePath2(p) {
|
|
285
|
+
if (p.startsWith("~/")) return join2(homedir2(), p.slice(2));
|
|
286
|
+
return p;
|
|
287
|
+
}
|
|
288
|
+
function updateSkillMdKey(skillMdPath, key) {
|
|
289
|
+
if (!existsSync(skillMdPath)) return false;
|
|
290
|
+
let content = readFileSync2(skillMdPath, "utf-8");
|
|
291
|
+
if (content.startsWith("LOKUMA_API_KEY =")) {
|
|
292
|
+
content = content.replace(/^LOKUMA_API_KEY = .+\n\n?/, `LOKUMA_API_KEY = ${key}
|
|
293
|
+
|
|
294
|
+
`);
|
|
295
|
+
} else {
|
|
296
|
+
content = `LOKUMA_API_KEY = ${key}
|
|
297
|
+
|
|
298
|
+
` + content;
|
|
299
|
+
}
|
|
300
|
+
writeFileSync(skillMdPath, content, "utf-8");
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
function updateAllSkillMds(key) {
|
|
304
|
+
const updated = [];
|
|
305
|
+
for (const t of AI_TYPES.filter((t2) => t2 !== "all")) {
|
|
306
|
+
const p = resolvePath2(AI_SKILL_PATHS[t].skillMd);
|
|
307
|
+
if (updateSkillMdKey(p, key)) updated.push(p);
|
|
308
|
+
}
|
|
309
|
+
return updated;
|
|
310
|
+
}
|
|
279
311
|
function detectShellRc() {
|
|
280
312
|
const shell = process.env.SHELL ?? "";
|
|
281
313
|
const home = process.env.HOME ?? "";
|
|
@@ -336,7 +368,7 @@ async function prompt(question, hidden = false) {
|
|
|
336
368
|
async function authLoginCommand() {
|
|
337
369
|
console.log();
|
|
338
370
|
console.log(chalk2.bold(" Lokuma \u2014 API Key Setup"));
|
|
339
|
-
console.log(chalk2.dim(" Get your key at https://lokuma.ai"));
|
|
371
|
+
console.log(chalk2.dim(" Get your key at https://agent.lokuma.ai"));
|
|
340
372
|
console.log();
|
|
341
373
|
const existing = process.env.LOKUMA_API_KEY;
|
|
342
374
|
if (existing) {
|
|
@@ -357,14 +389,18 @@ async function authLoginCommand() {
|
|
|
357
389
|
}
|
|
358
390
|
if (!key.startsWith("lokuma_")) {
|
|
359
391
|
console.log(chalk2.red(" \u2717 Invalid key format (should start with lokuma_)"));
|
|
360
|
-
console.log(chalk2.dim(" Visit https://lokuma.ai to get a valid key."));
|
|
392
|
+
console.log(chalk2.dim(" Visit https://agent.lokuma.ai to get a valid key."));
|
|
361
393
|
console.log();
|
|
362
394
|
process.exit(1);
|
|
363
395
|
}
|
|
364
396
|
const rc = persistKey(key);
|
|
397
|
+
const updated = updateAllSkillMds(key);
|
|
365
398
|
console.log();
|
|
366
399
|
console.log(chalk2.green(" \u2713 API key saved!"));
|
|
367
400
|
console.log(chalk2.dim(` Written to: ${rc}`));
|
|
401
|
+
if (updated.length > 0) {
|
|
402
|
+
console.log(chalk2.dim(` Updated ${updated.length} SKILL.md file(s) with new key.`));
|
|
403
|
+
}
|
|
368
404
|
console.log();
|
|
369
405
|
console.log(chalk2.dim(" Reload your shell to apply:"));
|
|
370
406
|
console.log(chalk2.cyan(` source ${rc}`));
|